Переглянути джерело

Converted ZC_EFST_SET_ENTER to struct (#9074)

Lemongrass3110 2 місяців тому
батько
коміт
ae173e449d
4 змінених файлів з 54 додано та 42 видалено
  1. 29 39
      src/map/clif.cpp
  2. 0 1
      src/map/clif.hpp
  3. 0 2
      src/map/clif_packetdb.hpp
  4. 25 0
      src/map/packets.hpp

+ 29 - 39
src/map/clif.cpp

@@ -6553,6 +6553,34 @@ void clif_status_change(struct block_list *bl, int32 type, int32 flag, t_tick ti
 	clif_status_change_sub(bl, bl->id, type, flag, tick, val1, val2, val3, ((sd ? (pc_isinvisible(sd) ? SELF : AREA) : AREA_WOS)));
 }
 
+/// Notifies the client when a player enters the screen with an active EFST.
+/// 08ff <id>.L <index>.W <remain msec>.L { <val>.L }*3  (ZC_EFST_SET_ENTER) (PACKETVER >= 20111108)
+/// 0984 <id>.L <index>.W <total msec>.L <remain msec>.L { <val>.L }*3 (ZC_EFST_SET_ENTER2) (PACKETVER >= 20120618)
+void clif_efst_status_change( block_list& bl, block_list& tbl, enum send_target target, efst_type type, t_tick tick, int32 val1, int32 val2, int32 val3 ){
+#if PACKETVER >= 20111108
+	if (type == EFST_BLANK)
+		return;
+
+	if (tick <= 0)
+		tick = 9999;
+
+	PACKET_ZC_EFST_SET_ENTER p{};
+
+	p.packetType = HEADER_ZC_EFST_SET_ENTER;
+	p.targetID = tbl.id;
+	p.type = type;
+	p.duration = client_tick( tick );
+#if PACKETVER >= 20120618
+	p.duration2 = p.duration;
+#endif
+	p.val1 = val1;
+	p.val2 = val2;
+	p.val3 = val3;
+
+	clif_send( &p, sizeof( p ), &bl, target );
+#endif
+}
+
 /**
  * Send any active EFST to those around.
  * @param tbl: Unit to send the packet to
@@ -6616,51 +6644,13 @@ void clif_efst_status_change_sub(struct block_list *tbl, struct block_list *bl,
 		}
 
 #if PACKETVER > 20120418
-		clif_efst_status_change(tbl, bl->id, target, status_db.getIcon(type), tick, sc_display[i]->val1, sc_display[i]->val2, sc_display[i]->val3);
+		clif_efst_status_change( *tbl, *bl, target, status_db.getIcon( type ), tick, sc_display[i]->val1, sc_display[i]->val2, sc_display[i]->val3 );
 #else
 		clif_status_change_sub(tbl, bl->id, status_db.getIcon(type), 1, tick, sc_display[i]->val1, sc_display[i]->val2, sc_display[i]->val3, target);
 #endif
 	}
 }
 
-/// Notifies the client when a player enters the screen with an active EFST.
-/// 08ff <id>.L <index>.W <remain msec>.L { <val>.L }*3  (ZC_EFST_SET_ENTER) (PACKETVER >= 20111108)
-/// 0984 <id>.L <index>.W <total msec>.L <remain msec>.L { <val>.L }*3 (ZC_EFST_SET_ENTER2) (PACKETVER >= 20120618)
-void clif_efst_status_change(struct block_list *bl, int32 tid, enum send_target target, int32 type, t_tick tick, int32 val1, int32 val2, int32 val3) {
-#if PACKETVER >= 20111108
-	unsigned char buf[32];
-#if PACKETVER >= 20120618
-	const int32 cmd = 0x984;
-#elif PACKETVER >= 20111108
-	const int32 cmd = 0x8ff;
-#endif
-	int32 offset = 0;
-
-	if (type == EFST_BLANK)
-		return;
-
-	nullpo_retv(bl);
-
-	if (tick <= 0)
-		tick = 9999;
-
-	WBUFW(buf,offset + 0) = cmd;
-	WBUFL(buf,offset + 2) = tid;
-	WBUFW(buf,offset + 6) = type;
-#if PACKETVER >= 20111108
-	WBUFL(buf,offset + 8) = client_tick(tick); // Set remaining status duration [exneval]
-#if PACKETVER >= 20120618
-	WBUFL(buf,offset + 12) = client_tick(tick);
-	offset += 4;
-#endif
-	WBUFL(buf,offset + 12) = val1;
-	WBUFL(buf,offset + 16) = val2;
-	WBUFL(buf,offset + 20) = val3;
-#endif
-	clif_send(buf,packet_len(cmd),bl,target);
-#endif
-}
-
 /// Send message (modified by [Yor]) (ZC_NOTIFY_PLAYERCHAT).
 /// 008e <packet len>.W <message>.?B
 void clif_displaymessage(const int32 fd, const char* mes)

+ 0 - 1
src/map/clif.hpp

@@ -1009,7 +1009,6 @@ void clif_changemapcell( int16 m, int16 x, int16 y, int16 type, send_target targ
 
 #define clif_status_load(bl, type, flag) clif_status_change((bl), (type), (flag), 0, 0, 0, 0)
 void clif_status_change(struct block_list *bl, int32 type, int32 flag, t_tick tick, int32 val1, int32 val2, int32 val3);
-void clif_efst_status_change(struct block_list *bl, int32 tid, enum send_target target, int32 type, t_tick tick, int32 val1, int32 val2, int32 val3);
 void clif_efst_status_change_sub(struct block_list *tbl, struct block_list *bl, enum send_target target);
 
 void clif_wis_message(map_session_data* sd, const char* nick, const char* mes, size_t mes_len, int32 gmlvl);

+ 0 - 2
src/map/clif_packetdb.hpp

@@ -1653,8 +1653,6 @@
 	packet(0x0979,50); //ackworldinfo
 	packet(0x099b,8); //maptypeproperty2
 	// New Packets
-	packet(0x08ff,24); // ZC_EFST_SET_ENTER
-	packet(0x0984,28); // ZC_EFST_SET_ENTER2
 	packet(0x099f,22); // ZC_SKILL_ENTRY4
 #endif
 

+ 25 - 0
src/map/packets.hpp

@@ -1977,6 +1977,31 @@ struct PACKET_ZC_DISAPPEAR_ENTRY{
 } __attribute__((packed));
 DEFINE_PACKET_HEADER(ZC_DISAPPEAR_ENTRY, 0x132);
 
+#if PACKETVER >= 20120618
+struct PACKET_ZC_EFST_SET_ENTER{
+	uint16 packetType;
+	uint32 targetID;
+	uint16 type;
+	uint32 duration;
+	uint32 duration2;
+	int32 val1;
+	int32 val2;
+	int32 val3;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(ZC_EFST_SET_ENTER, 0x984)
+#else
+struct PACKET_ZC_EFST_SET_ENTER{
+	uint16 packetType;
+	uint32 targetID;
+	uint16 type;
+	uint32 duration;
+	int32 val1;
+	int32 val2;
+	int32 val3;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(ZC_EFST_SET_ENTER, 0x8ff)
+#endif
+
 // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
 #if !defined( sun ) && ( !defined( __NETBSD__ ) || __NetBSD_Version__ >= 600000000 )
 	#pragma pack( pop )