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

@@ -51,6 +51,28 @@ public:
static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = nullptr; return start; }
void SendGMText(std::string_view str);
template<typename... Args>
void SendGMText(uint32 strId, Args&&... args)
{
// WorldText should be sent to all sessions
SessionMap::const_iterator itr;
for (itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
{
Player* player = itr->second->GetPlayer();
if (player && player->IsInWorld())
{
m_session = player->GetSession();
SendGMText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
}
}
}
template<typename... Args>
void SendGMText(char const* fmt, Args&&... args)
{
SendGMText(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
}
void SendWorldText(std::string_view str);
template<typename... Args>
void SendWorldText(uint32 strId, Args&&... args)