mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 09:17:36 +01:00
Core/PacketIO: Fixed SMSG_GUILD_EVENT for empty MOTD broken after cd28423a4e
Closes #26522
This commit is contained in:
@@ -1894,7 +1894,7 @@ void Guild::SendLoginInfo(WorldSession* session)
|
||||
{
|
||||
WorldPackets::Guild::GuildEvent motd;
|
||||
motd.Type = GE_MOTD;
|
||||
motd.Params[0] = m_motd.c_str();
|
||||
motd.Params.emplace_back(m_motd);
|
||||
session->SendPacket(motd.Write());
|
||||
|
||||
TC_LOG_DEBUG("guild", "SMSG_GUILD_EVENT [%s] MOTD", session->GetPlayerInfo().c_str());
|
||||
@@ -2828,13 +2828,26 @@ void Guild::_SendBankContentUpdate(uint8 tabId, SlotIds slots) const
|
||||
_SendBankList(nullptr, tabId, false, &slots);
|
||||
}
|
||||
|
||||
void Guild::_BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, std::string_view param1, std::string_view param2, std::string_view param3) const
|
||||
void Guild::_BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid,
|
||||
Optional<std::string_view> param1 /*= {}*/, Optional<std::string_view> param2 /*= {}*/, Optional<std::string_view> param3 /*= {}*/) const
|
||||
{
|
||||
WorldPackets::Guild::GuildEvent event;
|
||||
event.Type = guildEvent;
|
||||
event.Params[0] = param1;
|
||||
event.Params[1] = param2;
|
||||
event.Params[2] = param3;
|
||||
if (param1)
|
||||
event.Params.push_back(*param1);
|
||||
|
||||
if (param2)
|
||||
{
|
||||
event.Params.resize(2);
|
||||
event.Params[1] = *param2;
|
||||
}
|
||||
|
||||
if (param3)
|
||||
{
|
||||
event.Params.resize(3);
|
||||
event.Params[2] = *param3;
|
||||
}
|
||||
|
||||
event.Guid = guid;
|
||||
BroadcastPacket(event.Write());
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "Optional.h"
|
||||
#include "SharedDefines.h"
|
||||
#include <set>
|
||||
#include <unordered_map>
|
||||
@@ -820,6 +821,6 @@ class TC_GAME_API Guild
|
||||
void _SendBankContentUpdate(uint8 tabId, SlotIds slots) const;
|
||||
void _SendBankList(WorldSession* session = nullptr, uint8 tabId = 0, bool sendFullSlots = false, SlotIds* slots = nullptr) const;
|
||||
|
||||
void _BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, std::string_view param1 = "", std::string_view param2 = "", std::string_view param3 = "") const;
|
||||
void _BroadcastEvent(GuildEvents guildEvent, ObjectGuid guid, Optional<std::string_view> param1 = {}, Optional<std::string_view> param2 = {}, Optional<std::string_view> param3 = {}) const;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -122,10 +122,9 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Guild::GuildRosterMemberD
|
||||
WorldPacket const* WorldPackets::Guild::GuildEvent::Write()
|
||||
{
|
||||
_worldPacket << uint8(Type);
|
||||
uint8 paramCount = Params[2].empty() ? (Params[1].empty() ? (Params[0].empty() ? 0 : 1) : 2) : 3;
|
||||
_worldPacket << uint8(paramCount);
|
||||
for (uint8 i = 0; i < paramCount; ++i)
|
||||
_worldPacket << Params[i];
|
||||
_worldPacket << uint8(Params.size());
|
||||
for (std::string_view param : Params)
|
||||
_worldPacket << param;
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "Guild.h"
|
||||
#include "ObjectGuid.h"
|
||||
#include "PacketUtilities.h"
|
||||
#include <boost/container/static_vector.hpp>
|
||||
#include <array>
|
||||
|
||||
namespace WorldPackets
|
||||
@@ -207,7 +208,7 @@ namespace WorldPackets
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
uint8 Type = 0;
|
||||
std::array<std::string_view, 3> Params = { };
|
||||
boost::container::static_vector<std::string_view, 3> Params;
|
||||
ObjectGuid Guid;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user