From fe9f617f97f321506b35cae3b99b58006f85d754 Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Mon, 13 May 2024 11:45:00 +0200 Subject: [PATCH] Fixed clif_sendfakenpc (#8330) Fixes #8321 Fixes #8328 Thanks to @kaninhot004 --- src/map/clif.cpp | 66 ++++++++++++++++++++++++++++++++++++++------- src/map/packets.hpp | 36 ------------------------- 2 files changed, 56 insertions(+), 46 deletions(-) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 0529422bd5..fd03f27a4d 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -2545,19 +2545,65 @@ void clif_scriptclear( map_session_data& sd, int npcid ){ void clif_sendfakenpc( map_session_data& sd, uint32 npcid ){ sd.state.using_fake_npc = 1; - PACKET_ZC_NOTIFY_STANDENTRY packet{}; + // Code below is a copy of clif_set_unit_idle + struct packet_idle_unit p; - packet.packetType = HEADER_ZC_NOTIFY_STANDENTRY; -#if PACKETVER >= 20071106 - packet.objecttype = 0; + p.PacketType = idle_unitType; +#if PACKETVER >= 20091103 + p.PacketLength = sizeof(p); + p.objecttype = 0x1; // NPC_TYPE +#endif +#if PACKETVER >= 20131223 + p.AID = npcid; + p.GID = 0; +#else + p.GID = npcid; +#endif + p.speed = 0; + p.bodyState = 0; + p.healthState = 0; + p.effectState = 0; + p.job = JT_HIDDEN_NPC; + p.head = 0; + p.weapon = 0; +#if PACKETVER < 7 || PACKETVER_MAIN_NUM >= 20181121 || PACKETVER_RE_NUM >= 20180704 || PACKETVER_ZERO_NUM >= 20181114 + p.shield = 0; +#endif + p.accessory = 0; + p.accessory2 = 0; + p.accessory3 = 0; + p.headpalette = 0; + p.bodypalette = 0; + p.headDir = 0; +#if PACKETVER >= 20101124 + p.robe = 0; +#endif + p.GUID = 0; + p.GEmblemVer = 0; + p.honor = 0; + p.virtue = 0; + p.isPKModeON = 0; + p.sex = SEX_FEMALE; + WBUFPOS( &p.PosDir[0], 0, sd.bl.x, sd.bl.y, sd.ud.dir ); + p.xSize = p.ySize = 5; + p.state = 0; + p.clevel = 0; +#if PACKETVER >= 20080102 + p.font = 0; +#endif +#if PACKETVER >= 20120221 + p.maxHP = -1; + p.HP = -1; +#endif +#if PACKETVER >= 20150513 + p.body = 0; +#endif +/* Might be earlier, this is when the named item bug began */ +#if PACKETVER >= 20131223 + safestrncpy( p.name, "", NAME_LENGTH); #endif - packet.GID = npcid; - packet.job = JT_HIDDEN_NPC; - WBUFPOS(packet.PosDir,0,sd.bl.x,sd.bl.y,sd.ud.dir); - packet.xSize = 5; - packet.ySize = 5; - clif_send( &packet, sizeof( packet ), &sd.bl, SELF ); + clif_send( &p, sizeof( p ), &sd.bl, SELF ); } diff --git a/src/map/packets.hpp b/src/map/packets.hpp index 0324606dc8..772ee0fb80 100644 --- a/src/map/packets.hpp +++ b/src/map/packets.hpp @@ -709,42 +709,6 @@ struct PACKET_ZC_CLOSE_DIALOG { } __attribute__((packed)); DEFINE_PACKET_HEADER(ZC_CLOSE_DIALOG, 0xb6) -struct PACKET_ZC_NOTIFY_STANDENTRY { - int16 packetType; -#if PACKETVER >= 20071106 - uint8 objecttype; -#endif - uint32 GID; - int16 speed; - int16 bodyState; - int16 effectState; - int16 job; - int16 head; - int16 weapon; - int16 accessory; - int16 shield; - int16 accessory2; - int16 accessory3; - int16 headpalette; - int16 bodypalette; - int16 headDir; - uint32 GUID; - int16 GEmblemVer; - int16 honor; - int16 virtue; - bool isPKModeON; - uint8 sex; - uint8 PosDir[3]; - uint8 xSize; - uint8 ySize; - uint8 state; - int16 clevel; - uint16 spr_idx; - uint16 effect_idx; - unsigned char scale; -} __attribute__((packed)); -DEFINE_PACKET_HEADER(ZC_NOTIFY_STANDENTRY, 0x78) - struct PACKET_ZC_MENU_LIST { int16 packetType; int16 packetLength;