refactor(Core/Packet): Chat (#9509)

* Chat

* .

* Update GameObject.cpp

* Update Object.cpp

* Update Player.cpp
This commit is contained in:
IntelligentQuantum
2022-01-08 13:41:06 +03:30
committed by GitHub
parent 03efc110a0
commit 725b1266b4
20 changed files with 153 additions and 48 deletions

View File

@@ -547,7 +547,7 @@ public:
virtual void SendGlobalGMMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
virtual bool SendZoneMessage(uint32 zone, WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
virtual void SendZoneText(uint32 zone, const char* text, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
virtual void SendServerMessage(ServerMessageType type, const char* text = "", Player* player = nullptr) = 0;
virtual void SendServerMessage(ServerMessageType messageID, std::string stringParam = "", Player* player = nullptr) = 0;
virtual bool IsShuttingDown() const = 0;
virtual uint32 GetShutDownTimeLeft() const = 0;
virtual void ShutdownServ(uint32 time, uint32 options, uint8 exitcode, const std::string& reason = std::string()) = 0;

View File

@@ -34,6 +34,7 @@
#include "ChannelMgr.h"
#include "CharacterDatabaseCleaner.h"
#include "Chat.h"
#include "ChatPackets.h"
#include "Common.h"
#include "ConditionMgr.h"
#include "Config.h"
@@ -2814,7 +2815,7 @@ void World::ShutdownMsg(bool show, Player* player, const std::string& reason)
ServerMessageType msgid = (m_ShutdownMask & SHUTDOWN_MASK_RESTART) ? SERVER_MSG_RESTART_TIME : SERVER_MSG_SHUTDOWN_TIME;
SendServerMessage(msgid, str.c_str(), player);
SendServerMessage(msgid, str, player);
LOG_DEBUG("server.worldserver", "Server is %s in %s", (m_ShutdownMask & SHUTDOWN_MASK_RESTART ? "restart" : "shuttingdown"), str.c_str());
}
}
@@ -2839,17 +2840,17 @@ void World::ShutdownCancel()
}
/// Send a server message to the user(s)
void World::SendServerMessage(ServerMessageType type, const char* text, Player* player)
void World::SendServerMessage(ServerMessageType messageID, std::string stringParam /*= ""*/, Player* player /*= nullptr*/)
{
WorldPacket data(SMSG_SERVER_MESSAGE, 50); // guess size
data << uint32(type);
if (type <= SERVER_MSG_STRING)
data << text;
WorldPackets::Chat::ChatServerMessage chatServerMessage;
chatServerMessage.MessageID = int32(messageID);
if (messageID <= SERVER_MSG_STRING)
chatServerMessage.StringParam = stringParam;
if (player)
player->GetSession()->SendPacket(&data);
player->SendDirectMessage(chatServerMessage.Write());
else
SendGlobalMessage(&data);
SendGlobalMessage(chatServerMessage.Write());
}
void World::UpdateSessions(uint32 diff)

View File

@@ -260,7 +260,7 @@ public:
void SendGlobalGMMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL);
bool SendZoneMessage(uint32 zone, WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL);
void SendZoneText(uint32 zone, const char* text, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL);
void SendServerMessage(ServerMessageType type, const char* text = "", Player* player = nullptr);
void SendServerMessage(ServerMessageType messageID, std::string stringParam = "", Player* player = nullptr);
void SendWorldTextOptional(uint32 string_id, uint32 flag, ...);