diff --git a/src/server/game/Autobroadcast/AutobroadcastMgr.cpp b/src/server/game/Autobroadcast/AutobroadcastMgr.cpp index a0d00dd81607a4..8b31bf8936ceda 100644 --- a/src/server/game/Autobroadcast/AutobroadcastMgr.cpp +++ b/src/server/game/Autobroadcast/AutobroadcastMgr.cpp @@ -131,7 +131,7 @@ void AutobroadcastMgr::SendAutobroadcasts() 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) diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 6697ffe36f6fc8..ce81b448b33958 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -20,6 +20,7 @@ /// @todo: Add proper implement of achievement #include "BattlefieldWG.h" +#include "Chat.h" #include "GameTime.h" #include "MapMgr.h" #include "Opcodes.h" @@ -290,7 +291,7 @@ void BattlefieldWG::OnBattleStart() m_tenacityUpdateTimer = 20000; 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) diff --git a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp index 629296d2e62a77..e36b874acc5a98 100644 --- a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp +++ b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp @@ -16,6 +16,7 @@ */ #include "ArenaTeamMgr.h" +#include "Chat.h" #include "DatabaseEnv.h" #include "Define.h" #include "Language.h" @@ -194,9 +195,9 @@ void ArenaTeamMgr::LoadArenaTeams() void ArenaTeamMgr::DistributeArenaPoints() { // 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 std::map PlayerPoints; @@ -232,9 +233,9 @@ void ArenaTeamMgr::DistributeArenaPoints() 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) { 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); } diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index a315ba93514782..d3189c258e9e82 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -618,7 +618,7 @@ inline void Battleground::_ProcessJoin(uint32 diff) // Announce BG starting 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); } diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 8336352ea9e1ca..db6b96b5be9626 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -722,12 +722,12 @@ void BattlegroundMgr::ToggleTesting() if (sWorld->getBoolConfig(CONFIG_DEBUG_BATTLEGROUND)) { m_Testing = true; - sWorld->SendWorldText(LANG_DEBUG_BG_CONF); + ChatHandler(nullptr).SendWorldText(LANG_DEBUG_BG_CONF); } else { 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)) { m_ArenaTesting = true; - sWorld->SendWorldText(LANG_DEBUG_ARENA_CONF); + ChatHandler(nullptr).SendWorldText(LANG_DEBUG_ARENA_CONF); } else { 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); } } diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index e0b77a01a62b71..cef257d0f49cfa 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -996,7 +996,7 @@ void BattlegroundQueue::BattlegroundQueueAnnouncerUpdate(uint32 diff, Battlegrou uint32 q_min_level = std::min(bracketEntry->minLevel, (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 { @@ -1077,7 +1077,7 @@ void BattlegroundQueue::SendMessageBGQueue(Player* leader, Battleground* bg, PvP 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; } - 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 @@ -1147,16 +1147,16 @@ void BattlegroundQueue::SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo switch (announcementDetail) { 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; 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; 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; 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; } } @@ -1187,16 +1187,16 @@ void BattlegroundQueue::SendExitMessageArenaQueue(GroupQueueInfo* ginfo) switch (announcementDetail) { 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; 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; 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; 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; } } diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index fcd405fa9d0581..1cc245c3e6657d 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -99,6 +99,56 @@ bool ChatHandler::HasLowerSecurityAccount(WorldSession* target, uint32 target_ac return false; } +void ChatHandler::SendWorldText(std::string_view str) +{ + std::vector 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 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) { std::string msg{ str }; diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index acb6760db66cc6..eb0d7256e99177 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -50,6 +50,30 @@ class AC_GAME_API ChatHandler static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = nullptr; return start; } + void SendWorldText(std::string_view str); + template + void SendWorldText(uint32 strId, Args&&... args) + { + SendWorldText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward(args)...)); + } + template + void SendWorldText(char const* fmt, Args&&... args) + { + SendWorldText(Acore::StringFormatFmt(fmt, std::forward(args)...)); + } + + void SendWorldTextOptional(std::string_view str, uint32 flag); + template + void SendWorldTextOptional(uint32 strId, uint32 flag, Args&&... args) + { + SendWorldTextOptional(Acore::StringFormatFmt(GetAcoreString(strId), std::forward(args)...), flag); + } + template + void SendWorldTextOptional(char const* fmt, uint32 flag, Args&&... args) + { + SendWorldTextOptional(Acore::StringFormatFmt(fmt, std::forward(args)...), flag); + } + // function with different implementation for chat/console virtual char const* GetAcoreString(uint32 entry) const; virtual void SendSysMessage(std::string_view str, bool escapeCharacters = false); diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index d5a275812a592b..9136d3b1ae1f06 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -17,6 +17,7 @@ #include "LFGMgr.h" #include "BattlegroundMgr.h" +#include "Chat.h" #include "CharacterCache.h" #include "Common.h" #include "DBCStores.h" @@ -805,7 +806,7 @@ namespace lfg void LFGMgr::ToggleTesting() { 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); } /** diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index 073352c4cf61df..f835af43e25324 100644 --- a/src/server/game/Events/GameEventMgr.cpp +++ b/src/server/game/Events/GameEventMgr.cpp @@ -17,6 +17,7 @@ #include "GameEventMgr.h" #include "BattlegroundMgr.h" +#include "Chat.h" #include "DisableMgr.h" #include "GameObjectAI.h" #include "GameTime.h" @@ -1230,7 +1231,7 @@ void GameEventMgr::ApplyNewEvent(uint16 event_id) { uint8 announce = mGameEvent[event_id].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); diff --git a/src/server/game/Misc/BanMgr.cpp b/src/server/game/Misc/BanMgr.cpp index e55d4e276d1d2a..e3102c67ef11d5 100644 --- a/src/server/game/Misc/BanMgr.cpp +++ b/src/server/game/Misc/BanMgr.cpp @@ -17,6 +17,7 @@ #include "BanMgr.h" #include "AccountMgr.h" +#include "Chat.h" #include "DatabaseEnv.h" #include "GameTime.h" #include "Language.h" @@ -86,9 +87,9 @@ BanReturn BanMgr::BanAccount(std::string const& AccountName, std::string const& IsPermanetly = false; 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 - 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; @@ -152,9 +153,9 @@ BanReturn BanMgr::BanAccountByPlayerName(std::string const& CharacterName, std:: AccountMgr::GetName(AccountID, AccountName); 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 - 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; @@ -188,9 +189,9 @@ BanReturn BanMgr::BanIP(std::string const& IP, std::string const& Duration, std: IsPermanetly = false; 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 - 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) @@ -258,9 +259,9 @@ BanReturn BanMgr::BanCharacter(std::string const& CharacterName, std::string con IsPermanetly = false; 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 - 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; diff --git a/src/server/game/World/IWorld.h b/src/server/game/World/IWorld.h index cec7b45486854a..1771d7f4135a6c 100644 --- a/src/server/game/World/IWorld.h +++ b/src/server/game/World/IWorld.h @@ -566,8 +566,6 @@ class IWorld [[nodiscard]] virtual uint16 GetConfigMaxSkillValue() const = 0; virtual void SetInitialWorldSettings() = 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 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; diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index b42d97fe36dd6b..1d46005e0bce7a 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -2578,53 +2578,6 @@ 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 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 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) void World::SendGMText(uint32 string_id, ...) { diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 3968dbd8f5488f..9126df816bfa1a 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -238,7 +238,6 @@ class World: public IWorld void SetInitialWorldSettings() override; void LoadConfigSettings(bool reload = false) override; - void SendWorldText(uint32 string_id, ...) override; void SendGMText(uint32 string_id, ...) 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; @@ -246,8 +245,6 @@ class World: public IWorld 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 SendWorldTextOptional(uint32 string_id, uint32 flag, ...) override; - /// Are we in the middle of a shutdown? [[nodiscard]] bool IsShuttingDown() const override { return _shutdownTimer > 0; } [[nodiscard]] uint32 GetShutDownTimeLeft() const override { return _shutdownTimer; } diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index 104c162777bf87..f2ef607523cc22 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -64,7 +64,7 @@ class message_commandscript : public CommandScript if (WorldSession* session = handler->GetSession()) name = session->GetPlayer()->GetName(); - sWorld->SendWorldText(LANG_ANNOUNCE_COLOR, name.c_str(), message.data()); + handler->SendWorldText(LANG_ANNOUNCE_COLOR, name, message.data()); return true; } diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 572bc3376f8f94..fe32b740c0335e 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1404,7 +1404,7 @@ class misc_commandscript : public CommandScript 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 { @@ -2506,7 +2506,7 @@ class misc_commandscript : public CommandScript 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); @@ -2533,7 +2533,7 @@ class misc_commandscript : public CommandScript 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 { diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index 26bf8109d36dc8..646f8a79352f93 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -281,14 +281,14 @@ class reset_commandscript : public CommandScript if (caseName == "spells") { atLogin = AT_LOGIN_RESET_SPELLS; - sWorld->SendWorldText(LANG_RESETALL_SPELLS); + handler->SendWorldText(LANG_RESETALL_SPELLS); if (!handler->GetSession()) handler->SendSysMessage(LANG_RESETALL_SPELLS); } else if (caseName == "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()) handler->SendSysMessage(LANG_RESETALL_TALENTS); } diff --git a/src/test/mocks/WorldMock.h b/src/test/mocks/WorldMock.h index 3ac4d571dbde0c..5c00ae829cee6f 100644 --- a/src/test/mocks/WorldMock.h +++ b/src/test/mocks/WorldMock.h @@ -72,8 +72,6 @@ class WorldMock: public IWorld MOCK_METHOD(uint16, GetConfigMaxSkillValue, (), (const)); MOCK_METHOD(void, SetInitialWorldSettings, ()); 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 {} MOCK_METHOD(void, SendGlobalMessage, (WorldPacket const* packet, WorldSession* self, TeamId teamId), ()); MOCK_METHOD(void, SendGlobalGMMessage, (WorldPacket const* packet, WorldSession* self, TeamId teamId), ());