mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-27 23:56:25 +00:00
fix(Core/World): Crash on SendWorldText(Optional) (#19531)
* fix(Core/World): Crash on SendWorldText(Optional) * WorldText should be sent to all sessions * now it works
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "ChatCommand.h"
|
||||
#include "Errors.h"
|
||||
#include "Player.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "WorldSession.h"
|
||||
#include <vector>
|
||||
@@ -54,24 +55,64 @@ public:
|
||||
template<typename... Args>
|
||||
void SendWorldText(uint32 strId, Args&&... args)
|
||||
{
|
||||
SendWorldText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<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();
|
||||
SendWorldText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...));
|
||||
}
|
||||
}
|
||||
}
|
||||
template<typename... Args>
|
||||
void SendWorldText(char const* fmt, Args&&... args)
|
||||
{
|
||||
SendWorldText(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
|
||||
// WorldTextOptional 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();
|
||||
SendWorldText(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SendWorldTextOptional(std::string_view str, uint32 flag);
|
||||
template<typename... Args>
|
||||
void SendWorldTextOptional(uint32 strId, uint32 flag, Args&&... args)
|
||||
{
|
||||
SendWorldTextOptional(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...), flag);
|
||||
// WorldTextOptional 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();
|
||||
SendWorldTextOptional(Acore::StringFormatFmt(GetAcoreString(strId), std::forward<Args>(args)...), flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
template<typename... Args>
|
||||
void SendWorldTextOptional(char const* fmt, uint32 flag, Args&&... args)
|
||||
{
|
||||
SendWorldTextOptional(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...), flag);
|
||||
// WorldTextOptional 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();
|
||||
SendWorldTextOptional(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...), flag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// function with different implementation for chat/console
|
||||
|
||||
Reference in New Issue
Block a user