mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 07:48:02 +00:00
refactor(Core/Chat): Move SendWorldText(optional) to ChatHandler and … (#19501)
* refactor(Core/Chat): Move SendWorldText(optional) to ChatHandler and allow `fmt` * Update src/server/game/Battlegrounds/BattlegroundQueue.cpp * Update src/server/game/Battlegrounds/BattlegroundQueue.cpp * Update src/server/game/Misc/BanMgr.cpp * Update src/server/game/Misc/BanMgr.cpp * Update src/server/game/Misc/BanMgr.cpp * Update src/server/game/Misc/BanMgr.cpp * Update src/server/game/Misc/BanMgr.cpp * Update src/server/game/Misc/BanMgr.cpp * Update src/server/game/Misc/BanMgr.cpp * Update src/server/game/Misc/BanMgr.cpp
This commit is contained in:
@@ -131,7 +131,7 @@ void AutobroadcastMgr::SendAutobroadcasts()
|
|||||||
|
|
||||||
void AutobroadcastMgr::SendWorldAnnouncement(std::string msg)
|
void AutobroadcastMgr::SendWorldAnnouncement(std::string msg)
|
||||||
{
|
{
|
||||||
sWorld->SendWorldTextOptional(LANG_AUTO_BROADCAST, ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST, msg.data());
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_AUTO_BROADCAST, ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST, msg.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutobroadcastMgr::SendNotificationAnnouncement(std::string msg)
|
void AutobroadcastMgr::SendNotificationAnnouncement(std::string msg)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
/// @todo: Add proper implement of achievement
|
/// @todo: Add proper implement of achievement
|
||||||
|
|
||||||
#include "BattlefieldWG.h"
|
#include "BattlefieldWG.h"
|
||||||
|
#include "Chat.h"
|
||||||
#include "GameTime.h"
|
#include "GameTime.h"
|
||||||
#include "MapMgr.h"
|
#include "MapMgr.h"
|
||||||
#include "Opcodes.h"
|
#include "Opcodes.h"
|
||||||
@@ -290,7 +291,7 @@ void BattlefieldWG::OnBattleStart()
|
|||||||
m_tenacityUpdateTimer = 20000;
|
m_tenacityUpdateTimer = 20000;
|
||||||
|
|
||||||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
||||||
sWorld->SendWorldText(BATTLEFIELD_WG_WORLD_START_MESSAGE);
|
ChatHandler(nullptr).SendWorldText(BATTLEFIELD_WG_WORLD_START_MESSAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BattlefieldWG::UpdateCounterVehicle(bool init)
|
void BattlefieldWG::UpdateCounterVehicle(bool init)
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ArenaTeamMgr.h"
|
#include "ArenaTeamMgr.h"
|
||||||
|
#include "Chat.h"
|
||||||
#include "DatabaseEnv.h"
|
#include "DatabaseEnv.h"
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
@@ -194,9 +195,9 @@ void ArenaTeamMgr::LoadArenaTeams()
|
|||||||
void ArenaTeamMgr::DistributeArenaPoints()
|
void ArenaTeamMgr::DistributeArenaPoints()
|
||||||
{
|
{
|
||||||
// Used to distribute arena points based on last week's stats
|
// Used to distribute arena points based on last week's stats
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_START);
|
ChatHandler(nullptr).SendWorldText(LANG_DIST_ARENA_POINTS_START);
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START);
|
ChatHandler(nullptr).SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START);
|
||||||
|
|
||||||
// Temporary structure for storing maximum points to add values for all players
|
// Temporary structure for storing maximum points to add values for all players
|
||||||
std::map<ObjectGuid, uint32> PlayerPoints;
|
std::map<ObjectGuid, uint32> PlayerPoints;
|
||||||
@@ -232,9 +233,9 @@ void ArenaTeamMgr::DistributeArenaPoints()
|
|||||||
|
|
||||||
PlayerPoints.clear();
|
PlayerPoints.clear();
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END);
|
ChatHandler(nullptr).SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END);
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_START);
|
ChatHandler(nullptr).SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_START);
|
||||||
for (ArenaTeamContainer::iterator titr = GetArenaTeamMapBegin(); titr != GetArenaTeamMapEnd(); ++titr)
|
for (ArenaTeamContainer::iterator titr = GetArenaTeamMapBegin(); titr != GetArenaTeamMapEnd(); ++titr)
|
||||||
{
|
{
|
||||||
if (ArenaTeam* at = titr->second)
|
if (ArenaTeam* at = titr->second)
|
||||||
@@ -246,7 +247,7 @@ void ArenaTeamMgr::DistributeArenaPoints()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_END);
|
ChatHandler(nullptr).SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_END);
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_END);
|
ChatHandler(nullptr).SendWorldText(LANG_DIST_ARENA_POINTS_END);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -618,7 +618,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
|
|||||||
|
|
||||||
// Announce BG starting
|
// Announce BG starting
|
||||||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
|
||||||
sWorld->SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName().c_str(), std::min(GetMinLevel(), (uint32)80), std::min(GetMaxLevel(), (uint32)80));
|
ChatHandler(nullptr).SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName(), std::min(GetMinLevel(), (uint32)80), std::min(GetMaxLevel(), (uint32)80));
|
||||||
|
|
||||||
sScriptMgr->OnBattlegroundStart(this);
|
sScriptMgr->OnBattlegroundStart(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -722,12 +722,12 @@ void BattlegroundMgr::ToggleTesting()
|
|||||||
if (sWorld->getBoolConfig(CONFIG_DEBUG_BATTLEGROUND))
|
if (sWorld->getBoolConfig(CONFIG_DEBUG_BATTLEGROUND))
|
||||||
{
|
{
|
||||||
m_Testing = true;
|
m_Testing = true;
|
||||||
sWorld->SendWorldText(LANG_DEBUG_BG_CONF);
|
ChatHandler(nullptr).SendWorldText(LANG_DEBUG_BG_CONF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Testing = !m_Testing;
|
m_Testing = !m_Testing;
|
||||||
sWorld->SendWorldText(m_Testing ? LANG_DEBUG_BG_ON : LANG_DEBUG_BG_OFF);
|
ChatHandler(nullptr).SendWorldText(m_Testing ? LANG_DEBUG_BG_ON : LANG_DEBUG_BG_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -736,12 +736,12 @@ void BattlegroundMgr::ToggleArenaTesting()
|
|||||||
if (sWorld->getBoolConfig(CONFIG_DEBUG_ARENA))
|
if (sWorld->getBoolConfig(CONFIG_DEBUG_ARENA))
|
||||||
{
|
{
|
||||||
m_ArenaTesting = true;
|
m_ArenaTesting = true;
|
||||||
sWorld->SendWorldText(LANG_DEBUG_ARENA_CONF);
|
ChatHandler(nullptr).SendWorldText(LANG_DEBUG_ARENA_CONF);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_ArenaTesting = !m_ArenaTesting;
|
m_ArenaTesting = !m_ArenaTesting;
|
||||||
sWorld->SendWorldText(m_ArenaTesting ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF);
|
ChatHandler(nullptr).SendWorldText(m_ArenaTesting ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -996,7 +996,7 @@ void BattlegroundQueue::BattlegroundQueueAnnouncerUpdate(uint32 diff, Battlegrou
|
|||||||
uint32 q_min_level = std::min(bracketEntry->minLevel, (uint32) 80);
|
uint32 q_min_level = std::min(bracketEntry->minLevel, (uint32) 80);
|
||||||
uint32 q_max_level = std::min(bracketEntry->maxLevel, (uint32) 80);
|
uint32 q_max_level = std::min(bracketEntry->maxLevel, (uint32) 80);
|
||||||
|
|
||||||
sWorld->SendWorldTextOptional(LANG_BG_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_BG_QUEUE, bgName.c_str(), q_min_level, q_max_level, qPlayers, MaxPlayers);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_BG_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_BG_QUEUE, bgName.c_str(), q_min_level, q_max_level, qPlayers, MaxPlayers);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1077,7 +1077,7 @@ void BattlegroundQueue::SendMessageBGQueue(Player* leader, Battleground* bg, PvP
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sWorld->SendWorldTextOptional(LANG_BG_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_BG_QUEUE, bgName.c_str(), q_min_level, q_max_level, qAlliance + qHorde, MaxPlayers);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_BG_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_BG_QUEUE, bgName.c_str(), q_min_level, q_max_level, qAlliance + qHorde, MaxPlayers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1128,7 +1128,7 @@ void BattlegroundQueue::SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, bgName.c_str(), arenatype.c_str(), q_min_level, q_max_level, qPlayers, playersNeed);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, bgName.c_str(), arenatype.c_str(), q_min_level, q_max_level, qPlayers, playersNeed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1147,16 +1147,16 @@ void BattlegroundQueue::SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo
|
|||||||
switch (announcementDetail)
|
switch (announcementDetail)
|
||||||
{
|
{
|
||||||
case 3:
|
case 3:
|
||||||
sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN_NAME_RATING, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN_NAME_RATING, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN_NAME, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN_NAME, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName, ArenaType, ArenaType);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN_RATING, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, ArenaType, ArenaType, ArenaTeamRating);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN_RATING, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, ArenaType, ArenaType, ArenaTeamRating);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, ArenaType, ArenaType);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, ArenaType, ArenaType);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1187,16 +1187,16 @@ void BattlegroundQueue::SendExitMessageArenaQueue(GroupQueueInfo* ginfo)
|
|||||||
switch (announcementDetail)
|
switch (announcementDetail)
|
||||||
{
|
{
|
||||||
case 3:
|
case 3:
|
||||||
sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT_NAME_RATING, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT_NAME_RATING, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT_NAME, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT_NAME, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName, ArenaType, ArenaType);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT_RATING, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, ArenaType, ArenaType, ArenaTeamRating);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT_RATING, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, ArenaType, ArenaType, ArenaTeamRating);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, ArenaType, ArenaType);
|
ChatHandler(nullptr).SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, ArenaType, ArenaType);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,56 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChatHandler::SendWorldText(std::string_view str)
|
||||||
|
{
|
||||||
|
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
|
||||||
|
for (SessionMap::const_iterator itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
|
||||||
|
{
|
||||||
|
WorldSession* session = itr->second;
|
||||||
|
if (!session)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Player should be in world
|
||||||
|
Player* player = session->GetPlayer();
|
||||||
|
if (!player || !player->IsInWorld())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (std::string_view line : lines)
|
||||||
|
{
|
||||||
|
WorldPacket data;
|
||||||
|
ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
|
||||||
|
player->SendDirectMessage(&data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChatHandler::SendWorldTextOptional(std::string_view str, uint32 flag)
|
||||||
|
{
|
||||||
|
std::vector<std::string_view> lines = Acore::Tokenize(str, '\n', true);
|
||||||
|
for (SessionMap::const_iterator itr = sWorld->GetAllSessions().begin(); itr != sWorld->GetAllSessions().end(); ++itr)
|
||||||
|
{
|
||||||
|
WorldSession* session = itr->second;
|
||||||
|
if (!session)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Player should be in world
|
||||||
|
Player* player = session->GetPlayer();
|
||||||
|
if (!player || !player->IsInWorld())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (sWorld->getBoolConfig(CONFIG_PLAYER_SETTINGS_ENABLED))
|
||||||
|
if (player->GetPlayerSetting(AzerothcorePSSource, SETTING_ANNOUNCER_FLAGS).HasFlag(flag))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (std::string_view line : lines)
|
||||||
|
{
|
||||||
|
WorldPacket data;
|
||||||
|
ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line);
|
||||||
|
player->SendDirectMessage(&data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ChatHandler::SendSysMessage(std::string_view str, bool escapeCharacters)
|
void ChatHandler::SendSysMessage(std::string_view str, bool escapeCharacters)
|
||||||
{
|
{
|
||||||
std::string msg{ str };
|
std::string msg{ str };
|
||||||
|
|||||||
@@ -50,6 +50,30 @@ public:
|
|||||||
|
|
||||||
static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = nullptr; return start; }
|
static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = nullptr; return start; }
|
||||||
|
|
||||||
|
void SendWorldText(std::string_view str);
|
||||||
|
template<typename... Args>
|
||||||
|
void SendWorldText(uint32 strId, Args&&... args)
|
||||||
|
{
|
||||||
|
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)...));
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
template<typename... Args>
|
||||||
|
void SendWorldTextOptional(char const* fmt, uint32 flag, Args&&... args)
|
||||||
|
{
|
||||||
|
SendWorldTextOptional(Acore::StringFormatFmt(fmt, std::forward<Args>(args)...), flag);
|
||||||
|
}
|
||||||
|
|
||||||
// function with different implementation for chat/console
|
// function with different implementation for chat/console
|
||||||
virtual char const* GetAcoreString(uint32 entry) const;
|
virtual char const* GetAcoreString(uint32 entry) const;
|
||||||
virtual void SendSysMessage(std::string_view str, bool escapeCharacters = false);
|
virtual void SendSysMessage(std::string_view str, bool escapeCharacters = false);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "LFGMgr.h"
|
#include "LFGMgr.h"
|
||||||
#include "BattlegroundMgr.h"
|
#include "BattlegroundMgr.h"
|
||||||
|
#include "Chat.h"
|
||||||
#include "CharacterCache.h"
|
#include "CharacterCache.h"
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "DBCStores.h"
|
#include "DBCStores.h"
|
||||||
@@ -805,7 +806,7 @@ namespace lfg
|
|||||||
void LFGMgr::ToggleTesting()
|
void LFGMgr::ToggleTesting()
|
||||||
{
|
{
|
||||||
m_Testing = !m_Testing;
|
m_Testing = !m_Testing;
|
||||||
sWorld->SendWorldText(m_Testing ? LANG_DEBUG_LFG_ON : LANG_DEBUG_LFG_OFF);
|
ChatHandler(nullptr).SendWorldText(m_Testing ? LANG_DEBUG_LFG_ON : LANG_DEBUG_LFG_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "GameEventMgr.h"
|
#include "GameEventMgr.h"
|
||||||
#include "BattlegroundMgr.h"
|
#include "BattlegroundMgr.h"
|
||||||
|
#include "Chat.h"
|
||||||
#include "DisableMgr.h"
|
#include "DisableMgr.h"
|
||||||
#include "GameObjectAI.h"
|
#include "GameObjectAI.h"
|
||||||
#include "GameTime.h"
|
#include "GameTime.h"
|
||||||
@@ -1230,7 +1231,7 @@ void GameEventMgr::ApplyNewEvent(uint16 event_id)
|
|||||||
{
|
{
|
||||||
uint8 announce = mGameEvent[event_id].announce;
|
uint8 announce = mGameEvent[event_id].announce;
|
||||||
if (announce == 1 || (announce == 2 && sWorld->getIntConfig(CONFIG_EVENT_ANNOUNCE)))
|
if (announce == 1 || (announce == 2 && sWorld->getIntConfig(CONFIG_EVENT_ANNOUNCE)))
|
||||||
sWorld->SendWorldText(LANG_EVENTMESSAGE, mGameEvent[event_id].description.c_str());
|
ChatHandler(nullptr).SendWorldText(LANG_EVENTMESSAGE, mGameEvent[event_id].description);
|
||||||
|
|
||||||
LOG_DEBUG("gameevent", "GameEvent {} \"{}\" started.", event_id, mGameEvent[event_id].description);
|
LOG_DEBUG("gameevent", "GameEvent {} \"{}\" started.", event_id, mGameEvent[event_id].description);
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "BanMgr.h"
|
#include "BanMgr.h"
|
||||||
#include "AccountMgr.h"
|
#include "AccountMgr.h"
|
||||||
|
#include "Chat.h"
|
||||||
#include "DatabaseEnv.h"
|
#include "DatabaseEnv.h"
|
||||||
#include "GameTime.h"
|
#include "GameTime.h"
|
||||||
#include "Language.h"
|
#include "Language.h"
|
||||||
@@ -86,9 +87,9 @@ BanReturn BanMgr::BanAccount(std::string const& AccountName, std::string const&
|
|||||||
IsPermanetly = false;
|
IsPermanetly = false;
|
||||||
|
|
||||||
if (!IsPermanetly)
|
if (!IsPermanetly)
|
||||||
sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), secsToTimeString(TimeStringToSecs(Duration), true).c_str(), Reason.c_str());
|
ChatHandler(nullptr).SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, Author, AccountName, secsToTimeString(TimeStringToSecs(Duration), true), Reason);
|
||||||
else
|
else
|
||||||
sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), Reason.c_str());
|
ChatHandler(nullptr).SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, Author, AccountName, Reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BAN_SUCCESS;
|
return BAN_SUCCESS;
|
||||||
@@ -152,9 +153,9 @@ BanReturn BanMgr::BanAccountByPlayerName(std::string const& CharacterName, std::
|
|||||||
AccountMgr::GetName(AccountID, AccountName);
|
AccountMgr::GetName(AccountID, AccountName);
|
||||||
|
|
||||||
if (!IsPermanetly)
|
if (!IsPermanetly)
|
||||||
sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), secsToTimeString(TimeStringToSecs(Duration), true).c_str(), Reason.c_str());
|
ChatHandler(nullptr).SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, Author, AccountName, secsToTimeString(TimeStringToSecs(Duration), true), Reason);
|
||||||
else
|
else
|
||||||
sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), Reason.c_str());
|
ChatHandler(nullptr).SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, Author, AccountName, Reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BAN_SUCCESS;
|
return BAN_SUCCESS;
|
||||||
@@ -188,9 +189,9 @@ BanReturn BanMgr::BanIP(std::string const& IP, std::string const& Duration, std:
|
|||||||
IsPermanetly = false;
|
IsPermanetly = false;
|
||||||
|
|
||||||
if (IsPermanetly)
|
if (IsPermanetly)
|
||||||
sWorld->SendWorldText(LANG_BAN_IP_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), IP.c_str(), Reason.c_str());
|
ChatHandler(nullptr).SendWorldText(LANG_BAN_IP_YOUPERMBANNEDMESSAGE_WORLD, Author, IP, Reason);
|
||||||
else
|
else
|
||||||
sWorld->SendWorldText(LANG_BAN_IP_YOUBANNEDMESSAGE_WORLD, Author.c_str(), IP.c_str(), secsToTimeString(TimeStringToSecs(Duration), true).c_str(), Reason.c_str());
|
ChatHandler(nullptr).SendWorldText(LANG_BAN_IP_YOUBANNEDMESSAGE_WORLD, Author, IP, secsToTimeString(TimeStringToSecs(Duration), true), Reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!resultAccounts)
|
if (!resultAccounts)
|
||||||
@@ -258,9 +259,9 @@ BanReturn BanMgr::BanCharacter(std::string const& CharacterName, std::string con
|
|||||||
IsPermanetly = false;
|
IsPermanetly = false;
|
||||||
|
|
||||||
if (!IsPermanetly)
|
if (!IsPermanetly)
|
||||||
sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD, Author.c_str(), CharacterName.c_str(), secsToTimeString(TimeStringToSecs(Duration), true).c_str(), Reason.c_str());
|
ChatHandler(nullptr).SendWorldText(LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD, Author, CharacterName, secsToTimeString(TimeStringToSecs(Duration), true), Reason);
|
||||||
else
|
else
|
||||||
sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), CharacterName.c_str(), Reason.c_str());
|
ChatHandler(nullptr).SendWorldText(LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD, Author, CharacterName, Reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
return BAN_SUCCESS;
|
return BAN_SUCCESS;
|
||||||
|
|||||||
@@ -566,8 +566,6 @@ public:
|
|||||||
[[nodiscard]] virtual uint16 GetConfigMaxSkillValue() const = 0;
|
[[nodiscard]] virtual uint16 GetConfigMaxSkillValue() const = 0;
|
||||||
virtual void SetInitialWorldSettings() = 0;
|
virtual void SetInitialWorldSettings() = 0;
|
||||||
virtual void LoadConfigSettings(bool reload = false) = 0;
|
virtual void LoadConfigSettings(bool reload = false) = 0;
|
||||||
virtual void SendWorldText(uint32 string_id, ...) = 0;
|
|
||||||
virtual void SendWorldTextOptional(uint32 string_id, uint32 flag, ...) = 0;
|
|
||||||
virtual void SendGMText(uint32 string_id, ...) = 0;
|
virtual void SendGMText(uint32 string_id, ...) = 0;
|
||||||
virtual void SendGlobalMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
|
virtual void SendGlobalMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
|
||||||
virtual void SendGlobalGMMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
|
virtual void SendGlobalGMMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0;
|
||||||
|
|||||||
@@ -2578,53 +2578,6 @@ namespace Acore
|
|||||||
};
|
};
|
||||||
} // namespace Acore
|
} // namespace Acore
|
||||||
|
|
||||||
/// Send a System Message to all players (except self if mentioned)
|
|
||||||
void World::SendWorldText(uint32 string_id, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, string_id);
|
|
||||||
|
|
||||||
Acore::WorldWorldTextBuilder wt_builder(string_id, &ap);
|
|
||||||
Acore::LocalizedPacketListDo<Acore::WorldWorldTextBuilder> wt_do(wt_builder);
|
|
||||||
for (SessionMap::const_iterator itr = _sessions.begin(); itr != _sessions.end(); ++itr)
|
|
||||||
{
|
|
||||||
if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
wt_do(itr->second->GetPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void World::SendWorldTextOptional(uint32 string_id, uint32 flag, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, flag);
|
|
||||||
|
|
||||||
Acore::WorldWorldTextBuilder wt_builder(string_id, &ap);
|
|
||||||
Acore::LocalizedPacketListDo<Acore::WorldWorldTextBuilder> wt_do(wt_builder);
|
|
||||||
for (auto const& itr : _sessions)
|
|
||||||
{
|
|
||||||
if (!itr.second || !itr.second->GetPlayer() || !itr.second->GetPlayer()->IsInWorld())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sWorld->getBoolConfig(CONFIG_PLAYER_SETTINGS_ENABLED))
|
|
||||||
{
|
|
||||||
if (itr.second->GetPlayer()->GetPlayerSetting(AzerothcorePSSource, SETTING_ANNOUNCER_FLAGS).HasFlag(flag))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wt_do(itr.second->GetPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
va_end(ap);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send a System Message to all GMs (except self if mentioned)
|
/// Send a System Message to all GMs (except self if mentioned)
|
||||||
void World::SendGMText(uint32 string_id, ...)
|
void World::SendGMText(uint32 string_id, ...)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -238,7 +238,6 @@ public:
|
|||||||
void SetInitialWorldSettings() override;
|
void SetInitialWorldSettings() override;
|
||||||
void LoadConfigSettings(bool reload = false) override;
|
void LoadConfigSettings(bool reload = false) override;
|
||||||
|
|
||||||
void SendWorldText(uint32 string_id, ...) override;
|
|
||||||
void SendGMText(uint32 string_id, ...) override;
|
void SendGMText(uint32 string_id, ...) override;
|
||||||
void SendGlobalMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) override;
|
void SendGlobalMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) override;
|
||||||
void SendGlobalGMMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) override;
|
void SendGlobalGMMessage(WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) override;
|
||||||
@@ -246,8 +245,6 @@ public:
|
|||||||
void SendZoneText(uint32 zone, const char* text, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) override;
|
void SendZoneText(uint32 zone, const char* text, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) override;
|
||||||
void SendServerMessage(ServerMessageType messageID, std::string stringParam = "", Player* player = nullptr) override;
|
void SendServerMessage(ServerMessageType messageID, std::string stringParam = "", Player* player = nullptr) override;
|
||||||
|
|
||||||
void SendWorldTextOptional(uint32 string_id, uint32 flag, ...) override;
|
|
||||||
|
|
||||||
/// Are we in the middle of a shutdown?
|
/// Are we in the middle of a shutdown?
|
||||||
[[nodiscard]] bool IsShuttingDown() const override { return _shutdownTimer > 0; }
|
[[nodiscard]] bool IsShuttingDown() const override { return _shutdownTimer > 0; }
|
||||||
[[nodiscard]] uint32 GetShutDownTimeLeft() const override { return _shutdownTimer; }
|
[[nodiscard]] uint32 GetShutDownTimeLeft() const override { return _shutdownTimer; }
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public:
|
|||||||
if (WorldSession* session = handler->GetSession())
|
if (WorldSession* session = handler->GetSession())
|
||||||
name = session->GetPlayer()->GetName();
|
name = session->GetPlayer()->GetName();
|
||||||
|
|
||||||
sWorld->SendWorldText(LANG_ANNOUNCE_COLOR, name.c_str(), message.data());
|
handler->SendWorldText(LANG_ANNOUNCE_COLOR, name, message.data());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1404,7 +1404,7 @@ public:
|
|||||||
|
|
||||||
if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD))
|
if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD))
|
||||||
{
|
{
|
||||||
sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), target->GetName().c_str(), kickReasonStr.c_str());
|
handler->SendWorldText(LANG_COMMAND_KICKMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName() : "Server"), target->GetName(), kickReasonStr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2506,7 +2506,7 @@ public:
|
|||||||
|
|
||||||
if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD))
|
if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD))
|
||||||
{
|
{
|
||||||
sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), secsToTimeString(muteDuration, true).c_str(), muteReasonStr.c_str());
|
handler->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy, nameLink, secsToTimeString(muteDuration, true), muteReasonStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, secsToTimeString(muteDuration, true), muteBy, muteReasonStr);
|
ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, secsToTimeString(muteDuration, true), muteBy, muteReasonStr);
|
||||||
@@ -2533,7 +2533,7 @@ public:
|
|||||||
|
|
||||||
if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target)
|
if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD) && !target)
|
||||||
{
|
{
|
||||||
sWorld->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), secsToTimeString(muteDuration, true).c_str(), muteReasonStr.c_str());
|
handler->SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy, nameLink, secsToTimeString(muteDuration, true), muteReasonStr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -281,14 +281,14 @@ public:
|
|||||||
if (caseName == "spells")
|
if (caseName == "spells")
|
||||||
{
|
{
|
||||||
atLogin = AT_LOGIN_RESET_SPELLS;
|
atLogin = AT_LOGIN_RESET_SPELLS;
|
||||||
sWorld->SendWorldText(LANG_RESETALL_SPELLS);
|
handler->SendWorldText(LANG_RESETALL_SPELLS);
|
||||||
if (!handler->GetSession())
|
if (!handler->GetSession())
|
||||||
handler->SendSysMessage(LANG_RESETALL_SPELLS);
|
handler->SendSysMessage(LANG_RESETALL_SPELLS);
|
||||||
}
|
}
|
||||||
else if (caseName == "talents")
|
else if (caseName == "talents")
|
||||||
{
|
{
|
||||||
atLogin = AtLoginFlags(AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS);
|
atLogin = AtLoginFlags(AT_LOGIN_RESET_TALENTS | AT_LOGIN_RESET_PET_TALENTS);
|
||||||
sWorld->SendWorldText(LANG_RESETALL_TALENTS);
|
handler->SendWorldText(LANG_RESETALL_TALENTS);
|
||||||
if (!handler->GetSession())
|
if (!handler->GetSession())
|
||||||
handler->SendSysMessage(LANG_RESETALL_TALENTS);
|
handler->SendSysMessage(LANG_RESETALL_TALENTS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,8 +72,6 @@ public:
|
|||||||
MOCK_METHOD(uint16, GetConfigMaxSkillValue, (), (const));
|
MOCK_METHOD(uint16, GetConfigMaxSkillValue, (), (const));
|
||||||
MOCK_METHOD(void, SetInitialWorldSettings, ());
|
MOCK_METHOD(void, SetInitialWorldSettings, ());
|
||||||
MOCK_METHOD(void, LoadConfigSettings, (bool reload), ());
|
MOCK_METHOD(void, LoadConfigSettings, (bool reload), ());
|
||||||
void SendWorldText(uint32 string_id, ...) override {}
|
|
||||||
void SendWorldTextOptional(uint32 string_id, uint32 flag, ...) override {}
|
|
||||||
void SendGMText(uint32 string_id, ...) override {}
|
void SendGMText(uint32 string_id, ...) override {}
|
||||||
MOCK_METHOD(void, SendGlobalMessage, (WorldPacket const* packet, WorldSession* self, TeamId teamId), ());
|
MOCK_METHOD(void, SendGlobalMessage, (WorldPacket const* packet, WorldSession* self, TeamId teamId), ());
|
||||||
MOCK_METHOD(void, SendGlobalGMMessage, (WorldPacket const* packet, WorldSession* self, TeamId teamId), ());
|
MOCK_METHOD(void, SendGlobalGMMessage, (WorldPacket const* packet, WorldSession* self, TeamId teamId), ());
|
||||||
|
|||||||
Reference in New Issue
Block a user