From 00c88167ce31584490677f444e3e5a42835cdf46 Mon Sep 17 00:00:00 2001 From: AoShinHo <126742159+AoShinRO@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:47:16 -0300 Subject: [PATCH] Converted ZC_REQ_TAKEOFF_EQUIP_ACK to struct (#8580) --------- Co-authored-by: Lemongrass3110 Co-authored-by: Atemo --- src/map/clif.cpp | 37 ++++++++++++------------------------- src/map/clif.hpp | 2 +- src/map/clif_packetdb.hpp | 3 --- src/map/packets.hpp | 26 ++++++++++++++++++++++++++ src/map/pc.cpp | 10 +++++----- 5 files changed, 44 insertions(+), 34 deletions(-) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 29e25c8111..a34d9a8113 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -4247,35 +4247,22 @@ void clif_equipitemack( map_session_data& sd, uint8 flag, int index, int pos ){ /// 00ac .W .W .B (ZC_REQ_TAKEOFF_EQUIP_ACK) /// 08d1 .W .W .B (ZC_REQ_TAKEOFF_EQUIP_ACK2) /// 099a .W .L .B (ZC_ACK_TAKEOFF_EQUIP_V5) -/// @ok : //inversed for v2 v5 +/// @success : //inversed for v2 v5 /// 0 = failure /// 1 = success -void clif_unequipitemack(map_session_data *sd,int n,int pos,int ok) -{ - int fd, header, offs = 0; -#if PACKETVER >= 20130000 - header = 0x99a; - ok = ok ? 0 : 1; -#elif PACKETVER >= 20110824 - header = 0x8d1; - ok = ok ? 0 : 1; -#else - header = 0xac; +void clif_unequipitemack( map_session_data& sd, uint16 server_index, int32 pos, bool success ){ +#if PACKETVER >= 20110824 + success = !success; #endif - nullpo_retv(sd); - fd=sd->fd; - WFIFOHEAD(fd, packet_len(header)); - WFIFOW(fd,offs+0) = header; - WFIFOW(fd,offs+2) = n+2; -#if PACKETVER >= 20130000 - WFIFOL(fd,offs+4) = pos; - offs += 2; -#else - WFIFOW(fd,offs+4) = pos; -#endif - WFIFOB(fd,offs+6) = ok; - WFIFOSET(fd, packet_len(header)); + PACKET_ZC_REQ_TAKEOFF_EQUIP_ACK p{}; + + p.packetType = HEADER_ZC_REQ_TAKEOFF_EQUIP_ACK; + p.index = client_index(server_index); + p.wearLocation = static_cast(pos); + p.flag = success; + + clif_send(&p,sizeof(p),&sd.bl,SELF); } diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 51e1f98997..3a2bc89f66 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -874,7 +874,7 @@ void clif_arrow_fail( map_session_data& sd, e_action_failure type ); void clif_arrow_create_list( map_session_data& sd ); void clif_statusupack( map_session_data& sd, int32 type, bool success, int32 val = 0 ); void clif_equipitemack( map_session_data& sd, uint8 flag, int index, int pos = 0 ); // self -void clif_unequipitemack(map_session_data *sd,int n,int pos,int ok); // self +void clif_unequipitemack( map_session_data& sd, uint16 server_index, int32 pos, bool success ); void clif_misceffect( block_list& bl, e_notify_effect type ); void clif_changeoption_target(struct block_list* bl, struct block_list* target); #define clif_changeoption(bl) clif_changeoption_target(bl, nullptr) // area diff --git a/src/map/clif_packetdb.hpp b/src/map/clif_packetdb.hpp index 9b49220062..7591a05a96 100644 --- a/src/map/clif_packetdb.hpp +++ b/src/map/clif_packetdb.hpp @@ -60,7 +60,6 @@ packet( useItemAckType, sizeof( struct PACKET_ZC_USE_ITEM_ACK ) ); parseable_packet(0x00a9,6,clif_parse_EquipItem,2,4); parseable_packet(0x00ab,4,clif_parse_UnequipItem,2); - packet(0x00ac,7); packet(0x00ae,-1); parseable_packet(0x00b2,3,clif_parse_Restart,2); parseable_packet(0x00b8,7,clif_parse_NpcSelectMenu,2,6); @@ -1501,7 +1500,6 @@ parseable_packet(0x0838,6,clif_parse_SolveCharName,2); parseable_packet(0x0439,8,clif_parse_UseItem,2,4); packet(0x08d2,10); - packet(0x08d1,7); #endif // 2011-11-02aRagexe @@ -1734,7 +1732,6 @@ 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(0x099a,9); // take_off_equipv5 packet(0x099b,8); //maptypeproperty2 // New Packets packet(0x08ff,24); // ZC_EFST_SET_ENTER diff --git a/src/map/packets.hpp b/src/map/packets.hpp index 5a35037456..0588aa1572 100644 --- a/src/map/packets.hpp +++ b/src/map/packets.hpp @@ -852,6 +852,32 @@ struct PACKET_ZC_EQUIP_ARROW { } __attribute__((packed)); DEFINE_PACKET_HEADER(ZC_EQUIP_ARROW, 0x13c) +#if PACKETVER >= 20130000 +struct PACKET_ZC_REQ_TAKEOFF_EQUIP_ACK{ + uint16 packetType; + uint16 index; + uint32 wearLocation; + uint8 flag; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_REQ_TAKEOFF_EQUIP_ACK, 0x99a) +#elif PACKETVER >= 20110824 +struct PACKET_ZC_REQ_TAKEOFF_EQUIP_ACK{ + uint16 packetType; + uint16 index; + uint16 wearLocation; + uint8 flag; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_REQ_TAKEOFF_EQUIP_ACK, 0x8d1) +#else +struct PACKET_ZC_REQ_TAKEOFF_EQUIP_ACK{ + uint16 packetType; + uint16 index; + uint16 wearLocation; + bool flag; +} __attribute__((packed)); +DEFINE_PACKET_HEADER(ZC_REQ_TAKEOFF_EQUIP_ACK, 0xac) +#endif + struct PACKET_ZC_CLOSE_STORE { int16 packetType; } __attribute__((packed)); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 106614f600..bb8946c57d 100755 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -12262,18 +12262,18 @@ bool pc_unequipitem(map_session_data *sd, int n, int flag) { nullpo_retr(false,sd); if (n < 0 || n >= MAX_INVENTORY) { - clif_unequipitemack(sd,0,0,0); + clif_unequipitemack(*sd,0,0,false); return false; } if (!(pos = sd->inventory.u.items_inventory[n].equip)) { - clif_unequipitemack(sd,n,0,0); + clif_unequipitemack(*sd,n,0,false); return false; //Nothing to unequip } // status change that makes player cannot unequip equipment if (!(flag&2) && sd->sc.count &&( sd->sc.cant.unequip || (sd->sc.getSCE(SC_PYROCLASTIC) && sd->inventory_data[n]->type == IT_WEAPON))) // can't switch weapon { - clif_unequipitemack(sd,n,0,0); + clif_unequipitemack(*sd,n,0,false); return false; } @@ -12312,7 +12312,7 @@ bool pc_unequipitem(map_session_data *sd, int n, int flag) { if(pos & EQP_SHOES) clif_changelook(&sd->bl,LOOK_SHOES,0); - clif_unequipitemack(sd,n,pos,1); + clif_unequipitemack(*sd,n,pos,true); pc_set_costume_view(sd); status_db.removeByStatusFlag(&sd->bl, { SCF_REMOVEONUNEQUIP }); @@ -12333,7 +12333,7 @@ bool pc_unequipitem(map_session_data *sd, int n, int flag) { if (idx >= 0) { sd->equip_index[EQI_AMMO] = -1; - clif_unequipitemack(sd, idx, sd->inventory.u.items_inventory[idx].equip, 1); + clif_unequipitemack(*sd, idx, sd->inventory.u.items_inventory[idx].equip, true); pc_unequipitem_sub(sd, idx, 0); } }