Browse Source

Converted CZ_CLOSE_DIALOG to struct (#9001)

Lemongrass3110 3 tháng trước cách đây
mục cha
commit
287da33f27
3 tập tin đã thay đổi với 16 bổ sung4 xóa
  1. 9 3
      src/map/clif.cpp
  2. 1 1
      src/map/clif_packetdb.hpp
  3. 6 0
      src/map/packets.hpp

+ 9 - 3
src/map/clif.cpp

@@ -13342,10 +13342,14 @@ void clif_parse_NpcStringInput(int32 fd, map_session_data* sd){
 }
 
 
-/// NPC dialog 'close' click (CZ_CLOSE_DIALOG).
-/// 0146 <npc id>.L
+/// NPC dialog 'close' click.
+/// 0146 <npc id>.L (CZ_CLOSE_DIALOG)
 void clif_parse_NpcCloseClicked(int32 fd,map_session_data *sd)
 {
+	if( sd == nullptr ){
+		return;
+	}
+
 	if (!sd->npc_id) //Avoid parsing anything when the script was done with. [Skotlex]
 		return;
 
@@ -13353,7 +13357,9 @@ void clif_parse_NpcCloseClicked(int32 fd,map_session_data *sd)
 		sd->idletime = last_tick;
 	}
 
-	npc_scriptcont(sd, RFIFOL(fd,packet_db[RFIFOW(fd,0)].pos[0]), true);
+	const PACKET_CZ_CLOSE_DIALOG* p = reinterpret_cast<PACKET_CZ_CLOSE_DIALOG*>( RFIFOP( fd, 0 ) );
+
+	npc_scriptcont( sd, p->GID, true );
 }
 
 

+ 1 - 1
src/map/clif_packetdb.hpp

@@ -141,7 +141,7 @@
 	parseable_packet( HEADER_CZ_MOVETO_MAP, sizeof( PACKET_CZ_MOVETO_MAP ), clif_parse_MapMove, 0 );
 	parseable_packet( HEADER_CZ_INPUT_EDITDLG, sizeof( PACKET_CZ_INPUT_EDITDLG ), clif_parse_NpcAmountInput, 0 );
 	packet(0x0145,19);
-	parseable_packet(0x0146,6,clif_parse_NpcCloseClicked,2);
+	parseable_packet( HEADER_CZ_CLOSE_DIALOG, sizeof( PACKET_CZ_CLOSE_DIALOG ), clif_parse_NpcCloseClicked, 0 );
 	packet(0x0147,39);
 	parseable_packet(0x0149,9,clif_parse_GMReqNoChat,2,6,7);
 	packet(0x014a,6);

+ 6 - 0
src/map/packets.hpp

@@ -1784,6 +1784,12 @@ struct PACKET_CZ_INPUT_EDITDLGSTR{
 } __attribute__((packed));
 DEFINE_PACKET_HEADER(CZ_INPUT_EDITDLGSTR, 0x1d5);
 
+struct PACKET_CZ_CLOSE_DIALOG{
+	int16 packetType;
+	uint32 GID;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(CZ_CLOSE_DIALOG, 0x146);
+
 // 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 )