From a44d9540fb28cad1ac3da07f512fece15cbf00d8 Mon Sep 17 00:00:00 2001 From: Lemongrass3110 Date: Mon, 6 May 2024 02:04:51 +0200 Subject: [PATCH] Fixed clif_wis_message (#8308) Fixes #8307 Thanks to @mrpond --- src/map/clif.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 75dc344c6c..9df1175a96 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -7037,27 +7037,30 @@ void clif_upgrademessage( map_session_data* sd, int result, t_itemid item_id ){ /// 0097 .W .24B .?B /// 0097 .W .24B .L .?B (PACKETVER >= 20091104) void clif_wis_message(map_session_data* sd, const char* nick, const char* mes, size_t mes_len, int gmlvl){ - PACKET_ZC_WHISPER p; + PACKET_ZC_WHISPER* p = reinterpret_cast( packet_buffer ); - p.PacketType = HEADER_ZC_WHISPER; - p.PacketLength = static_cast( mes_len ); - safestrncpy(p.sender, nick, NAME_LENGTH); - safestrncpy(p.message, mes, mes_len); + p->PacketType = HEADER_ZC_WHISPER; + p->PacketLength = sizeof( *p ); + safestrncpy( p->sender, nick, NAME_LENGTH ); + safestrncpy( p->message, mes, mes_len ); + p->PacketLength += static_castPacketLength )>( mes_len ); #if PACKETVER >= 20091104 map_session_data* ssd = map_nick2sd(nick, false); + // If it is not a message from the server or a player from another map-server if (ssd) { gmlvl = pc_get_group_level(ssd); } - p.isAdmin = (gmlvl == 99) ? 1 : 0; + + p->isAdmin = (gmlvl == 99) ? 1 : 0; #endif #if PACKETVER_MAIN_NUM >= 20131204 || PACKETVER_RE_NUM >= 20131120 || defined(PACKETVER_ZERO) - p.senderGID = ssd->bl.id; + p->senderGID = ssd->bl.id; #endif - clif_send( &p, sizeof( p ), &sd->bl, SELF ); + clif_send( p, p->PacketLength, &sd->bl, SELF ); }