mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +00:00
refactor(Core/World): Move SendGMText to ChatHandler and allow fmt (#19490)
* refactor(Core/World): Move SendGMText to WorldSession and allow `fmt` - Move SendGMText from World to WorldSession - Make SendGMText use fmt - Make SendGMText parse acore_string entries * Update cs_message.cpp * tokenize the string only once * Move to chathandler * Update WorldSession.cpp * make sure we have a session
This commit is contained in:
@@ -99,6 +99,26 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChatHandler::SendGMText(std::string_view str)
|
||||
{
|
||||
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
|
||||
// Session should have permissions to receive global gm messages
|
||||
if (AccountMgr::IsPlayerAccount(m_session->GetSecurity()))
|
||||
return;
|
||||
|
||||
// Player should be in world
|
||||
Player* player = m_session->GetPlayer();
|
||||
if (!player || !player->IsInWorld())
|
||||
return;
|
||||
|
||||
for (std::string_view line : lines)
|
||||
{
|
||||
WorldPacket data;
|
||||
ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void ChatHandler::SendWorldText(std::string_view str)
|
||||
{
|
||||
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
|
||||
|
||||
Reference in New Issue
Block a user