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:
Kitzunu
2024-08-09 01:12:33 +02:00
committed by GitHub
parent fdd8ff6e04
commit bb7765d91e
9 changed files with 53 additions and 35 deletions

View File

@@ -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);