瀏覽代碼

Converted CZ_REQ_WEAR_EQUIP to struct (#8794)

Lemongrass3110 6 月之前
父節點
當前提交
a6e79e4bfe
共有 3 個文件被更改,包括 28 次插入18 次删除
  1. 10 16
      src/map/clif.cpp
  2. 1 2
      src/map/clif_packetdb.hpp
  3. 17 0
      src/map/packets.hpp

+ 10 - 16
src/map/clif.cpp

@@ -12061,18 +12061,19 @@ void clif_parse_UseItem(int fd, map_session_data *sd)
 /// Request to equip an item
 /// 00a9 <index>.W <position>.W (CZ_REQ_WEAR_EQUIP).
 /// 0998 <index>.W <position>.L (CZ_REQ_WEAR_EQUIP_V5)
-void clif_parse_EquipItem(int fd,map_session_data *sd)
-{
-	int index;
-	struct s_packet_db* info = &packet_db[RFIFOW(fd,0)];
+void clif_parse_EquipItem( int fd, map_session_data* sd ){
+	const PACKET_CZ_REQ_WEAR_EQUIP* p = reinterpret_cast<PACKET_CZ_REQ_WEAR_EQUIP*>( RFIFOP( fd, 0 ) );
 
 	if(pc_isdead(sd)) {
 		clif_clearunit_area( sd->bl, CLR_DEAD );
 		return;
 	}
-	index = RFIFOW(fd,info->pos[0])-2;
-	if (index < 0 || index >= MAX_INVENTORY)
-		return; //Out of bounds check.
+
+	uint16 index = server_index( p->index );
+
+	if( index >= MAX_INVENTORY ){
+		return;
+	}
 
 	if((sd->npc_id && !sd->npc_item_flag) || (sd->state.block_action & PCBLOCK_EQUIP)) {
 		clif_msg_color( sd, MSI_CAN_NOT_EQUIP_ITEM, color_table[COLOR_RED] );
@@ -12105,15 +12106,8 @@ void clif_parse_EquipItem(int fd,map_session_data *sd)
 	//Client doesn't send the position for ammo.
 	if(sd->inventory_data[index]->type == IT_AMMO)
 		pc_equipitem(sd,index,EQP_AMMO);
-	else {
-	int req_pos;
-
-#if PACKETVER  >= 20120925
-		req_pos = RFIFOL(fd,info->pos[1]);
-#else
-		req_pos = (int)RFIFOW(fd,info->pos[1]);
-#endif
-		pc_equipitem(sd,index,req_pos);
+	else{
+		pc_equipitem( sd, index, p->position );
 	}
 }
 

+ 1 - 2
src/map/clif_packetdb.hpp

@@ -57,7 +57,7 @@
 	packet( storageListEquipType, -1 );
 	parseable_packet(0x00a7,8,clif_parse_UseItem,2,4);
 	packet( useItemAckType, sizeof( struct PACKET_ZC_USE_ITEM_ACK ) );
-	parseable_packet(0x00a9,6,clif_parse_EquipItem,2,4);
+	parseable_packet( HEADER_CZ_REQ_WEAR_EQUIP, sizeof( PACKET_CZ_REQ_WEAR_EQUIP ), clif_parse_EquipItem, 0 );
 	parseable_packet(0x00ab,4,clif_parse_UnequipItem,2);
 	packet(0x00ae,-1);
 	parseable_packet(0x00b2,3,clif_parse_Restart,2);
@@ -1710,7 +1710,6 @@
 	packet(0x0977,14); //Monster HP Bar
 	parseable_packet(0x0978,6,clif_parse_reqworldinfo,2);
 	packet(0x0979,50); //ackworldinfo
-	parseable_packet(0x0998,8,clif_parse_EquipItem,2,4); // CZ_REQ_WEAR_EQUIP_V5
 	packet(0x099b,8); //maptypeproperty2
 	// New Packets
 	packet(0x08ff,24); // ZC_EFST_SET_ENTER

+ 17 - 0
src/map/packets.hpp

@@ -1424,6 +1424,23 @@ struct PACKET_CZ_BROADCAST{
 } __attribute__((packed));
 DEFINE_PACKET_HEADER(CZ_BROADCAST, 0x99);
 
+#if PACKETVER >= 20120925
+// CZ_REQ_WEAR_EQUIP_V5
+struct PACKET_CZ_REQ_WEAR_EQUIP{
+	int16 packetType;
+	uint16 index;
+	uint32 position;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(CZ_REQ_WEAR_EQUIP, 0x998);
+#else
+struct PACKET_CZ_REQ_WEAR_EQUIP{
+	int16 packetType;
+	uint16 index;
+	uint16 position;
+} __attribute__((packed));
+DEFINE_PACKET_HEADER(CZ_REQ_WEAR_EQUIP, 0xa9);
+#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 )