diff --git a/src/common/Define.h b/src/common/Define.h index 1da537e411fc4e..77f9cdc051d997 100644 --- a/src/common/Define.h +++ b/src/common/Define.h @@ -98,8 +98,6 @@ #define UI64LIT(N) UINT64_C(N) #define SI64LIT(N) INT64_C(N) -#define STRING_VIEW_FMT_ARG(str) static_cast((str).length()), (str).data() - typedef std::int64_t int64; typedef std::int32_t int32; typedef std::int16_t int16; diff --git a/src/server/authserver/Server/AuthSession.cpp b/src/server/authserver/Server/AuthSession.cpp index 29400864883581..7173475088a01d 100644 --- a/src/server/authserver/Server/AuthSession.cpp +++ b/src/server/authserver/Server/AuthSession.cpp @@ -28,10 +28,10 @@ #include "Log.h" #include "RealmList.h" #include "SecretMgr.h" +#include "StringConvert.h" #include "TOTP.h" #include "Timer.h" #include "Util.h" -#include "StringConvert.h" #include #include diff --git a/src/server/database/Database/DatabaseWorkerPool.cpp b/src/server/database/Database/DatabaseWorkerPool.cpp index 269ecaf350d39c..76919a5b1077ed 100644 --- a/src/server/database/Database/DatabaseWorkerPool.cpp +++ b/src/server/database/Database/DatabaseWorkerPool.cpp @@ -31,8 +31,8 @@ #include "SQLOperation.h" #include "Transaction.h" #include "WorldDatabase.h" -#include #include +#include #ifdef ACORE_DEBUG #include diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index a2470e63e8879d..68676ca837286b 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -21,8 +21,8 @@ #include "Creature.h" #include "CreatureAI.h" #include "CreatureAIImpl.h" -#include "InstanceScript.h" #include "EventMap.h" +#include "InstanceScript.h" #define CAST_AI(a, b) (dynamic_cast(b)) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 4cfea9a4cb0c95..eb3ad9df10f153 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -21,6 +21,7 @@ #include "ChatTextBuilder.h" #include "CreatureTextMgr.h" #include "GameEventMgr.h" +#include "GameLocale.h" #include "GossipDef.h" #include "GridDefines.h" #include "GridNotifiers.h" @@ -3092,7 +3093,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u case SMART_ACTION_PLAYER_TALK: { ObjectList* targets = GetTargets(e, unit); - char const* text = sObjectMgr->GetAcoreString(e.action.playerTalk.textId, DEFAULT_LOCALE); + char const* text = sGameLocale->GetAcoreString(e.action.playerTalk.textId, DEFAULT_LOCALE); if (targets) for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) diff --git a/src/server/game/Achievements/AchievementMgr.cpp b/src/server/game/Achievements/AchievementMgr.cpp index 35c719643445d7..a2895cd51eb6a9 100644 --- a/src/server/game/Achievements/AchievementMgr.cpp +++ b/src/server/game/Achievements/AchievementMgr.cpp @@ -29,6 +29,7 @@ #include "DatabaseEnv.h" #include "DisableMgr.h" #include "GameEventMgr.h" +#include "GameLocale.h" #include "GameTime.h" #include "GridNotifiersImpl.h" #include "Guild.h" @@ -2262,10 +2263,10 @@ void AchievementMgr::CompletedAchievement(AchievementEntry const* achievement) LocaleConstant localeConstant = GetPlayer()->GetSession()->GetSessionDbLocaleIndex(); if (localeConstant != LOCALE_enUS) { - if(AchievementRewardLocale const* loc = sAchievementMgr->GetAchievementRewardLocale(achievement)) + if (AchievementRewardLocale const* loc = sGameLocale->GetAchievementRewardLocale(achievement->ID)) { - ObjectMgr::GetLocaleString(loc->Subject, localeConstant, subject); - ObjectMgr::GetLocaleString(loc->Text, localeConstant, text); + GameLocale::GetLocaleString(loc->Subject, localeConstant, subject); + GameLocale::GetLocaleString(loc->Text, localeConstant, text); } } @@ -2928,46 +2929,6 @@ void AchievementGlobalMgr::LoadRewards() LOG_INFO("server.loading", " "); } -void AchievementGlobalMgr::LoadRewardLocales() -{ - uint32 oldMSTime = getMSTime(); - - m_achievementRewardLocales.clear(); // need for reload case - - // 0 1 2 3 - QueryResult result = WorldDatabase.Query("SELECT ID, Locale, Subject, Text FROM achievement_reward_locale"); - - if (!result) - { - LOG_INFO("server.loading", ">> Loaded 0 achievement reward locale strings. DB table `achievement_reward_locale` is empty"); - LOG_INFO("server.loading", " "); - return; - } - - do - { - Field* fields = result->Fetch(); - - uint32 ID = fields[0].Get(); - if (m_achievementRewards.find(ID) == m_achievementRewards.end()) - { - LOG_ERROR("sql.sql", "Table `achievement_reward_locale` (Entry: {}) has locale strings for non-existing achievement reward.", ID); - continue; - } - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - AchievementRewardLocale& data = m_achievementRewardLocales[ID]; - ObjectMgr::AddLocaleString(fields[2].Get(), locale, data.Subject); - ObjectMgr::AddLocaleString(fields[3].Get(), locale, data.Text); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Achievement Reward Locale strings in {} ms", (unsigned long)m_achievementRewardLocales.size(), GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); -} - AchievementEntry const* AchievementGlobalMgr::GetAchievement(uint32 achievementId) const { return sAchievementStore.LookupEntry(achievementId); diff --git a/src/server/game/Achievements/AchievementMgr.h b/src/server/game/Achievements/AchievementMgr.h index f385078a915dc8..9393e6b3dae7e0 100644 --- a/src/server/game/Achievements/AchievementMgr.h +++ b/src/server/game/Achievements/AchievementMgr.h @@ -249,14 +249,6 @@ struct AchievementReward typedef std::map AchievementRewards; -struct AchievementRewardLocale -{ - std::vector Subject; - std::vector Text; -}; - -typedef std::map AchievementRewardLocales; - struct CompletedAchievementData { time_t date; @@ -365,12 +357,6 @@ class AchievementGlobalMgr return iter != m_achievementRewards.end() ? &iter->second : nullptr; } - AchievementRewardLocale const* GetAchievementRewardLocale(AchievementEntry const* achievement) const - { - AchievementRewardLocales::const_iterator iter = m_achievementRewardLocales.find(achievement->ID); - return iter != m_achievementRewardLocales.end() ? &iter->second : nullptr; - } - AchievementCriteriaDataSet const* GetCriteriaDataSet(AchievementCriteriaEntry const* achievementCriteria) const { AchievementCriteriaDataMap::const_iterator iter = m_criteriaDataMap.find(achievementCriteria->ID); @@ -385,7 +371,6 @@ class AchievementGlobalMgr void LoadAchievementReferenceList(); void LoadCompletedAchievements(); void LoadRewards(); - void LoadRewardLocales(); [[nodiscard]] AchievementEntry const* GetAchievement(uint32 achievementId) const; @@ -404,7 +389,6 @@ class AchievementGlobalMgr AllCompletedAchievements m_allCompletedAchievements; AchievementRewards m_achievementRewards; - AchievementRewardLocales m_achievementRewardLocales; // pussywizard: std::map m_SpecialList[ACHIEVEMENT_CRITERIA_TYPE_TOTAL]; diff --git a/src/server/game/ArenaSpectator/ArenaSpectator.cpp b/src/server/game/ArenaSpectator/ArenaSpectator.cpp index cc31c7d8ac29ab..bb5743db3db81c 100644 --- a/src/server/game/ArenaSpectator/ArenaSpectator.cpp +++ b/src/server/game/ArenaSpectator/ArenaSpectator.cpp @@ -156,7 +156,7 @@ bool ArenaSpectator::HandleSpectatorSpectateCommand(ChatHandler* handler, std::s { handler->PSendSysMessage("To spectate, please fix the following:"); for (std::list::const_iterator itr = errors.begin(); itr != errors.end(); ++itr) - handler->PSendSysMessage("- %s", (*itr).c_str()); + handler->PSendSysMessage("- {}", (*itr)); return true; } diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index c1418457c95ba2..af66c62745e71b 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -21,9 +21,10 @@ #include "Common.h" #include "DBCStores.h" #include "DatabaseEnv.h" +#include "GameLocale.h" #include "GameTime.h" #include "Item.h" -#include "Logging/Log.h" +#include "Log.h" #include "ObjectMgr.h" #include "Player.h" #include "ScriptMgr.h" @@ -37,7 +38,7 @@ constexpr auto AH_MINIMUM_DEPOSIT = 100; // Proof of concept, we should shift the info we're obtaining in here into AuctionEntry probably static bool SortAuction(AuctionEntry* left, AuctionEntry* right, AuctionSortOrderVector& sortOrder, Player* player, bool checkMinBidBuyout) { - for (auto thisOrder : sortOrder) + for (auto const& thisOrder : sortOrder) { switch (thisOrder.sortOrder) { @@ -99,14 +100,14 @@ static bool SortAuction(AuctionEntry* left, AuctionEntry* right, AuctionSortOrde if (locale > LOCALE_enUS) { - if (ItemLocale const* leftIl = sObjectMgr->GetItemLocale(protoLeft->ItemId)) + if (ItemLocale const* leftIl = sGameLocale->GetItemLocale(protoLeft->ItemId)) { - ObjectMgr::GetLocaleString(leftIl->Name, locale, leftName); + GameLocale::GetLocaleString(leftIl->Name, locale, leftName); } - if (ItemLocale const* rightIl = sObjectMgr->GetItemLocale(protoRight->ItemId)) + if (ItemLocale const* rightIl = sGameLocale->GetItemLocale(protoRight->ItemId)) { - ObjectMgr::GetLocaleString(rightIl->Name, locale, rightName); + GameLocale::GetLocaleString(rightIl->Name, locale, rightName); } } @@ -831,8 +832,8 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player // local name if (loc_idx >= 0) - if (ItemLocale const* il = sObjectMgr->GetItemLocale(proto->ItemId)) - ObjectMgr::GetLocaleString(il->Name, loc_idx, name); + if (ItemLocale const* il = sGameLocale->GetItemLocale(proto->ItemId)) + GameLocale::GetLocaleString(il->Name, loc_idx, name); // DO NOT use GetItemEnchantMod(proto->RandomProperty) as it may return a result // that matches the search but it may not equal item->GetItemRandomPropertyId() diff --git a/src/server/game/Autobroadcast/Autobroadcast.cpp b/src/server/game/Autobroadcast/Autobroadcast.cpp new file mode 100644 index 00000000000000..3f8b7e5bd1491d --- /dev/null +++ b/src/server/game/Autobroadcast/Autobroadcast.cpp @@ -0,0 +1,183 @@ +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "Autobroadcast.h" +#include "Chat.h" +#include "ChatTextBuilder.h" +#include "GameLocale.h" +#include "Language.h" +#include "Player.h" +#include "Realm.h" +#include "Tokenize.h" +#include "World.h" +//#include "GameConfig.h" + +AutobroadcastMgr* AutobroadcastMgr::instance() +{ + static AutobroadcastMgr instance; + return &instance; +} + +void AutobroadcastMgr::Load() +{ + const uint32 oldMSTime = getMSTime(); + + _autobroadcasts.clear(); + _autobroadcastsWeights.clear(); + + LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_AUTOBROADCAST); + stmt->SetData(0, realm.Id.Realm); + + PreparedQueryResult result = LoginDatabase.Query(stmt); + if (!result) + { + LOG_INFO("server.loading", ">> Loaded 0 autobroadcasts definitions. DB table `autobroadcast` is empty for this realm!"); + return; + } + + do + { + Field* fields = result->Fetch(); + uint8 id = fields[0].Get(); + + _autobroadcasts[id] = fields[2].Get(); + _autobroadcastsWeights[id] = fields[1].Get(); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} autobroadcast definitions in {} ms", _autobroadcasts.size(), GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); +} + +void AutobroadcastMgr::Send() +{ + if (_autobroadcasts.empty()) + { + return; + } + + uint32 weight = 0; + uint32 textID = 0; + AutoBroadCastWeightsStore selectionWeights; + + for (const auto& [id, weightId] : _autobroadcastsWeights) + { + if (weightId) + { + weight += weightId; + selectionWeights[id] = weightId; + } + } + + if (weight) + { + uint32 selectedWeight = urand(0, weight - 1); + weight = 0; + + for (const auto& [id, weightId] : selectionWeights) + { + weight += weightId; + if (selectedWeight < weight) + { + textID = id; + break; + } + } + } + else + textID = urand(0, _autobroadcasts.size()); + + if (!textID) + { + LOG_ERROR("autobroadcast", "> AutobroadcastMgr::Send: Empty message id"); + return; + } + + std::string message{ _autobroadcasts.at(textID) }; + + auto SendNotification = [_msg = message, textID]() + { + for (auto const& [accountID, session] : sWorld->GetAllSessions()) + { + Player* player = session->GetPlayer(); + if (!player || !player->IsInWorld()) + { + return; + } + + std::string localeMsg{ _msg }; + + if (auto autoBroadCastLocale = sGameLocale->GetAutoBroadCastLocale(textID)) + { + GameLocale::GetLocaleString(autoBroadCastLocale->Text, player->GetSession()->GetSessionDbLocaleIndex(), localeMsg); + } + + for (std::string_view line : Acore::Tokenize(localeMsg, '\n', true)) + { + WorldPacket data(SMSG_NOTIFICATION, line.size() + 1); + data << line; + player->SendDirectMessage(&data); + } + } + }; + + auto SendWorldText = [_msg = message, textID]() + { + for (auto const& [accountID, session] : sWorld->GetAllSessions()) + { + Player* player = session->GetPlayer(); + if (!player || !player->IsInWorld()) + { + return; + } + + std::string localeMsg{ _msg }; + + if (auto const& autoBroadCastLocale = sGameLocale->GetAutoBroadCastLocale(textID)) + { + GameLocale::GetLocaleString(autoBroadCastLocale->Text, player->GetSession()->GetSessionDbLocaleIndex(), localeMsg); + } + + std::string fmtMessage = Acore::StringFormatFmt(sGameLocale->GetAcoreString(LANG_AUTO_BROADCAST, player->GetSession()->GetSessionDbLocaleIndex()), localeMsg); + + for (std::string_view line : Acore::Tokenize(fmtMessage, '\n', true)) + { + WorldPacket data; + ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line); + player->SendDirectMessage(&data); + } + } + }; + + const AnnounceType announceType = static_cast(sWorld->getIntConfig(CONFIG_AUTOBROADCAST_CENTER)); + + // Send before localize + LOG_INFO("server.worldserver", "AutoBroadcast: '{}'", message); + + switch (announceType) + { + case AnnounceType::WORLD: + SendWorldText(); + break; + case AnnounceType::NOTIFICATION: + SendNotification(); + break; + case AnnounceType::BOTH: + SendNotification(); + SendWorldText(); + break; + } +} diff --git a/src/server/game/Autobroadcast/Autobroadcast.h b/src/server/game/Autobroadcast/Autobroadcast.h new file mode 100644 index 00000000000000..c6938072f2c226 --- /dev/null +++ b/src/server/game/Autobroadcast/Autobroadcast.h @@ -0,0 +1,49 @@ +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _AUTO_BROAD_CAST_H_ +#define _AUTO_BROAD_CAST_H_ + +#include "Common.h" +#include + +enum class AnnounceType : uint8 +{ + WORLD = 0, + NOTIFICATION, + BOTH +}; + +class AC_GAME_API AutobroadcastMgr +{ +public: + static AutobroadcastMgr* instance(); + + void Load(); + void Send(); + +private: + using AutoBroadCastStore = std::unordered_map; + using AutoBroadCastWeightsStore = std::unordered_map; + + AutoBroadCastStore _autobroadcasts; + AutoBroadCastWeightsStore _autobroadcastsWeights; +}; + +#define sAutobroadcastMgr AutobroadcastMgr::instance() + +#endif diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 31462c2863cdfc..e3262128dc1b91 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 "ChatTextBuilder.h" #include "GameTime.h" #include "MapMgr.h" #include "Opcodes.h" @@ -285,7 +286,7 @@ void BattlefieldWG::OnBattleStart() m_tenacityUpdateTimer = 20000; if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE)) - sWorld->SendWorldText(BATTLEFIELD_WG_WORLD_START_MESSAGE); + Acore::Text::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 acce71e3e7690d..9cd4bdbcf51244 100644 --- a/src/server/game/Battlegrounds/ArenaTeamMgr.cpp +++ b/src/server/game/Battlegrounds/ArenaTeamMgr.cpp @@ -16,6 +16,7 @@ */ #include "ArenaTeamMgr.h" +#include "ChatTextBuilder.h" #include "DatabaseEnv.h" #include "Define.h" #include "Language.h" @@ -194,9 +195,8 @@ void ArenaTeamMgr::LoadArenaTeams() void ArenaTeamMgr::DistributeArenaPoints() { // Used to distribute arena points based on last week's stats - sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_START); - - sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START); + Acore::Text::SendWorldText(LANG_DIST_ARENA_POINTS_START); + Acore::Text::SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_START); // Temporary structure for storing maximum points to add values for all players std::map PlayerPoints; @@ -232,9 +232,9 @@ void ArenaTeamMgr::DistributeArenaPoints() PlayerPoints.clear(); - sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END); + Acore::Text::SendWorldText(LANG_DIST_ARENA_POINTS_ONLINE_END); - sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_START); + Acore::Text::SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_START); for (ArenaTeamContainer::iterator titr = GetArenaTeamMapBegin(); titr != GetArenaTeamMapEnd(); ++titr) { if (ArenaTeam* at = titr->second) @@ -245,7 +245,7 @@ void ArenaTeamMgr::DistributeArenaPoints() } } - sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_END); + Acore::Text::SendWorldText(LANG_DIST_ARENA_POINTS_TEAM_END); - sWorld->SendWorldText(LANG_DIST_ARENA_POINTS_END); + Acore::Text::SendWorldText(LANG_DIST_ARENA_POINTS_END); } diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 74fc9c22f62daa..d41c3c2e0a0e7c 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -26,6 +26,7 @@ #include "BattlegroundRL.h" #include "BattlegroundRV.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "Creature.h" #include "Formulas.h" #include "GameGraveyard.h" @@ -39,85 +40,13 @@ #include "ReputationMgr.h" #include "ScriptMgr.h" #include "SpellAuras.h" +#include "Tokenize.h" #include "Transport.h" #include "Util.h" #include "World.h" #include "WorldPacket.h" #include "WorldStatePackets.h" -namespace Acore -{ - class BattlegroundChatBuilder - { - public: - BattlegroundChatBuilder(ChatMsg msgtype, uint32 textId, Player const* source, va_list* args = nullptr) - : _msgtype(msgtype), _textId(textId), _source(source), _args(args) { } - - void operator()(WorldPacket& data, LocaleConstant loc_idx) - { - char const* text = sObjectMgr->GetAcoreString(_textId, loc_idx); - if (_args) - { - // we need copy va_list before use or original va_list will corrupted - va_list ap; - va_copy(ap, *_args); - - char str[2048]; - vsnprintf(str, 2048, text, ap); - va_end(ap); - - do_helper(data, &str[0]); - } - else - do_helper(data, text); - } - - private: - void do_helper(WorldPacket& data, char const* text) - { - ChatHandler::BuildChatPacket(data, _msgtype, LANG_UNIVERSAL, _source, _source, text); - } - - ChatMsg _msgtype; - uint32 _textId; - Player const* _source; - va_list* _args; - }; - - class Battleground2ChatBuilder - { - public: - Battleground2ChatBuilder(ChatMsg msgtype, uint32 textId, Player const* source, int32 arg1, int32 arg2) - : _msgtype(msgtype), _textId(textId), _source(source), _arg1(arg1), _arg2(arg2) {} - - void operator()(WorldPacket& data, LocaleConstant loc_idx) - { - char const* text = sObjectMgr->GetAcoreString(_textId, loc_idx); - char const* arg1str = _arg1 ? sObjectMgr->GetAcoreString(_arg1, loc_idx) : ""; - char const* arg2str = _arg2 ? sObjectMgr->GetAcoreString(_arg2, loc_idx) : ""; - - char str[2048]; - snprintf(str, 2048, text, arg1str, arg2str); - - ChatHandler::BuildChatPacket(data, _msgtype, LANG_UNIVERSAL, _source, _source, str); - } - - private: - ChatMsg _msgtype; - uint32 _textId; - Player const* _source; - uint32 _arg1; - uint32 _arg2; - }; -} // namespace Acore - -template -void Battleground::BroadcastWorker(Do& _do) -{ - for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) - _do(itr->second); -} - Battleground::Battleground() { m_RealTypeID = BATTLEGROUND_TYPE_NONE; @@ -419,13 +348,13 @@ inline void Battleground::_ProcessProgress(uint32 diff) if (newtime > (MINUTE * IN_MILLISECONDS)) { if (newtime / (MINUTE * IN_MILLISECONDS) != m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS)) - PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, CHAT_MSG_SYSTEM, nullptr, (uint32)(m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS))); + Acore::Text::SendBattlegroundMessageToAll(this, CHAT_MSG_SYSTEM, LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, nullptr, (uint32)(m_PrematureCountDownTimer / (MINUTE * IN_MILLISECONDS))); } else { //announce every 15 seconds if (newtime / (15 * IN_MILLISECONDS) != m_PrematureCountDownTimer / (15 * IN_MILLISECONDS)) - PSendMessageToAll(LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, CHAT_MSG_SYSTEM, nullptr, (uint32)(m_PrematureCountDownTimer / IN_MILLISECONDS)); + Acore::Text::SendBattlegroundMessageToAll(this, CHAT_MSG_SYSTEM, LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, nullptr, (uint32)(m_PrematureCountDownTimer / IN_MILLISECONDS)); } m_PrematureCountDownTimer = newtime; } @@ -514,7 +443,7 @@ inline void Battleground::_ProcessJoin(uint32 diff) StartingEventOpenDoors(); - SendWarningToAll(StartMessageIds[BG_STARTING_EVENT_FOURTH]); + Acore::Text::SendBattlegroundWarningToAll(this, StartMessageIds[BG_STARTING_EVENT_FOURTH]); SetStatus(STATUS_IN_PROGRESS); SetStartDelayTime(StartDelayTimes[BG_STARTING_EVENT_FOURTH]); @@ -591,7 +520,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(), std::min(GetMinLevel(), (uint32)80), std::min(GetMaxLevel(), (uint32)80)); + Acore::Text::SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName(), std::min(GetMinLevel(), (uint32)80), std::min(GetMaxLevel(), (uint32)80)); sScriptMgr->OnBattlegroundStart(this); } @@ -1379,7 +1308,9 @@ void Battleground::ReadyMarkerClicked(Player* p) readyMarkerClickedSet.insert(p->GetGUID()); uint32 count = readyMarkerClickedSet.size(); uint32 req = ArenaTeam::GetReqPlayersForType(GetArenaType()); - p->GetSession()->SendNotification("You are marked as ready %u/%u", count, req); + + Acore::Text::SendNotification(p->GetSession(), "You are marked as ready {}/{}", count, req); + if (count == req) { m_Events |= BG_STARTING_EVENT_2; @@ -1747,60 +1678,38 @@ bool Battleground::AddSpiritGuide(uint32 type, float x, float y, float z, float void Battleground::SendMessageToAll(uint32 entry, ChatMsg type, Player const* source) { if (!entry) + { return; + } - Acore::BattlegroundChatBuilder bg_builder(type, entry, source); - Acore::LocalizedPacketDo bg_do(bg_builder); - BroadcastWorker(bg_do); -} - -void Battleground::PSendMessageToAll(uint32 entry, ChatMsg type, Player const* source, ...) -{ - if (!entry) - return; - - va_list ap; - va_start(ap, source); - - Acore::BattlegroundChatBuilder bg_builder(type, entry, source, &ap); - Acore::LocalizedPacketDo bg_do(bg_builder); - BroadcastWorker(bg_do); - - va_end(ap); + for (auto const& [guid, player] : m_Players) + { + WorldPacket data; + ChatHandler::BuildChatPacket(data, type, LANG_UNIVERSAL, source, source, sGameLocale->GetAcoreString(entry, player->GetSession()->GetSessionDbLocaleIndex())); + player->SendDirectMessage(&data); + } } -void Battleground::SendWarningToAll(uint32 entry, ...) +void Battleground::SendMessage2ToAll(uint32 entry, ChatMsg type, Player const* source, uint32 arg1, uint32 arg2) { if (!entry) + { return; + } - std::map localizedPackets; - for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr) + for (auto const& [guid, player] : m_Players) { - if (localizedPackets.find(itr->second->GetSession()->GetSessionDbLocaleIndex()) == localizedPackets.end()) - { - char const* format = sObjectMgr->GetAcoreString(entry, itr->second->GetSession()->GetSessionDbLocaleIndex()); - - char str[1024]; - va_list ap; - va_start(ap, entry); - vsnprintf(str, 1024, format, ap); - va_end(ap); + auto localeIndex = player->GetSession()->GetSessionDbLocaleIndex(); + auto message = sGameLocale->GetAcoreString(entry, localeIndex); + char const* arg1str = arg1 ? sGameLocale->GetAcoreString(arg1, localeIndex) : ""; + char const* arg2str = arg2 ? sGameLocale->GetAcoreString(arg2, localeIndex) : ""; - ChatHandler::BuildChatPacket(localizedPackets[itr->second->GetSession()->GetSessionDbLocaleIndex()], CHAT_MSG_RAID_BOSS_EMOTE, LANG_UNIVERSAL, nullptr, nullptr, str); - } - - itr->second->SendDirectMessage(&localizedPackets[itr->second->GetSession()->GetSessionDbLocaleIndex()]); + WorldPacket data; + ChatHandler::BuildChatPacket(data, type, LANG_UNIVERSAL, source, source, Acore::StringFormatFmt(message, arg1str, arg2str)); + player->SendDirectMessage(&data); } } -void Battleground::SendMessage2ToAll(uint32 entry, ChatMsg type, Player const* source, uint32 arg1, uint32 arg2) -{ - Acore::Battleground2ChatBuilder bg_builder(type, entry, source, arg1, arg2); - Acore::LocalizedPacketDo bg_do(bg_builder); - BroadcastWorker(bg_do); -} - void Battleground::EndNow() { SetStatus(STATUS_WAIT_LEAVE); @@ -1811,7 +1720,7 @@ void Battleground::EndNow() char const* Battleground::GetAcoreString(int32 entry) { // FIXME: now we have different DBC locales and need localized message for each target client - return sObjectMgr->GetAcoreStringForDBCLocale(entry); + return sGameLocale->GetAcoreStringForDBCLocale(entry); } void Battleground::HandleTriggerBuff(GameObject* gameObject) diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 4e5a65c1b6b72f..92c46841201695 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -481,9 +481,6 @@ class Battleground void SendPacketToAll(WorldPacket const* packet); void YellToAll(Creature* creature, const char* text, uint32 language); - template - void BroadcastWorker(Do& _do); - void PlaySoundToAll(uint32 soundId); void CastSpellOnTeam(uint32 spellId, TeamId teamId); void RemoveAuraOnTeam(uint32 spellId, TeamId teamId); @@ -496,9 +493,7 @@ class Battleground virtual void EndBattleground(TeamId winnerTeamId); void BlockMovement(Player* player); - void SendWarningToAll(uint32 entry, ...); void SendMessageToAll(uint32 entry, ChatMsg type, Player const* source = nullptr); - void PSendMessageToAll(uint32 entry, ChatMsg type, Player const* source, ...); // specialized version with 2 string id args void SendMessage2ToAll(uint32 entry, ChatMsg type, Player const* source, uint32 strId1 = 0, uint32 strId2 = 0); diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index 72b3ab612e24f8..b8c52e21c4a17c 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -31,6 +31,7 @@ #include "BattlegroundSA.h" #include "BattlegroundWS.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "Common.h" #include "DisableMgr.h" #include "Formulas.h" @@ -791,12 +792,12 @@ void BattlegroundMgr::ToggleTesting() if (sWorld->getBoolConfig(CONFIG_DEBUG_BATTLEGROUND)) { m_Testing = true; - sWorld->SendWorldText(LANG_DEBUG_BG_CONF); + Acore::Text::SendWorldText(LANG_DEBUG_BG_CONF); } else { m_Testing = !m_Testing; - sWorld->SendWorldText(m_Testing ? LANG_DEBUG_BG_ON : LANG_DEBUG_BG_OFF); + Acore::Text::SendWorldText(m_Testing ? LANG_DEBUG_BG_ON : LANG_DEBUG_BG_OFF); } } @@ -805,12 +806,12 @@ void BattlegroundMgr::ToggleArenaTesting() if (sWorld->getBoolConfig(CONFIG_DEBUG_ARENA)) { m_ArenaTesting = true; - sWorld->SendWorldText(LANG_DEBUG_ARENA_CONF); + Acore::Text::SendWorldText(LANG_DEBUG_ARENA_CONF); } else { m_ArenaTesting = !m_ArenaTesting; - sWorld->SendWorldText(m_ArenaTesting ? LANG_DEBUG_ARENA_ON : LANG_DEBUG_ARENA_OFF); + Acore::Text::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 7449f06587f277..da24c2d3e6c2de 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -22,6 +22,7 @@ #include "BattlegroundSpamProtect.h" #include "Channel.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "GameTime.h" #include "Group.h" #include "Language.h" @@ -700,7 +701,7 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundBracket BattlegroundNeedSet bgsToCheck; // sort from most needing (most empty) to least needing using a std::set with functor - for (auto itr : bgList) + for (auto const& itr : bgList) { Battleground* bg = itr.second; if (!BattlegroundMgr::IsArenaType(bg->GetBgTypeID()) && (bg->GetBgTypeID(true) == m_bgTypeId || m_bgTypeId == BATTLEGROUND_RB) && @@ -985,7 +986,7 @@ void BattlegroundQueue::BattlegroundQueueUpdate(uint32 diff, BattlegroundBracket 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, q_min_level, q_max_level, qPlayers, MaxPlayers); + Acore::Text::SendWorldTextOptional(LANG_BG_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_BG_QUEUE, bgName, q_min_level, q_max_level, qPlayers, MaxPlayers); } else { @@ -1069,7 +1070,7 @@ void BattlegroundQueue::SendMessageBGQueue(Player* leader, Battleground* bg, PvP return; } - sWorld->SendWorldTextOptional(LANG_BG_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_BG_QUEUE, bgName, q_min_level, q_max_level, qAlliance + qHorde, MaxPlayers); + Acore::Text::SendWorldTextOptional(LANG_BG_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_BG_QUEUE, bgName, q_min_level, q_max_level, qAlliance + qHorde, MaxPlayers); } } } @@ -1111,7 +1112,7 @@ void BattlegroundQueue::SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo if (sWorld->getBoolConfig(CONFIG_ARENA_QUEUE_ANNOUNCER_PLAYERONLY)) { ChatHandler(leader->GetSession()).PSendSysMessage(LANG_ARENA_QUEUE_ANNOUNCE_SELF, - bgName, arenatype.c_str(), q_min_level, q_max_level, qPlayers, playersNeed - qPlayers); + bgName, arenatype, q_min_level, q_max_level, qPlayers, playersNeed - qPlayers); } else { @@ -1120,7 +1121,7 @@ void BattlegroundQueue::SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo return; } - sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, bgName, arenatype.c_str(), q_min_level, q_max_level, qPlayers, playersNeed); + Acore::Text::SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, bgName, arenatype.c_str(), q_min_level, q_max_level, qPlayers, playersNeed); } } else @@ -1135,7 +1136,7 @@ void BattlegroundQueue::SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo uint32 ArenaTeamRating = ginfo->ArenaTeamRating; std::string TeamName = team->GetName(); - sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating); + Acore::Text::SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_JOIN, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating); } } @@ -1160,7 +1161,7 @@ void BattlegroundQueue::SendExitMessageArenaQueue(GroupQueueInfo* ginfo) if (ArenaType && ginfo->Players.empty()) { - sWorld->SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating); + Acore::Text::SendWorldTextOptional(LANG_ARENA_QUEUE_ANNOUNCE_WORLD_EXIT, ANNOUNCER_FLAG_DISABLE_ARENA_QUEUE, TeamName.c_str(), ArenaType, ArenaType, ArenaTeamRating); } } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp index c38be999c8e0ca..13cac9f256c99e 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAB.cpp @@ -17,6 +17,7 @@ #include "BattlegroundAB.h" #include "BattlegroundMgr.h" +#include "ChatTextBuilder.h" #include "Creature.h" #include "GameGraveyard.h" #include "Language.h" @@ -182,13 +183,13 @@ void BattlegroundAB::HandleAreaTrigger(Player* player, uint32 trigger) { case 3948: // Arathi Basin Alliance Exit. if (player->GetTeamId() != TEAM_ALLIANCE) - player->GetSession()->SendAreaTriggerMessage("Only The Alliance can use that portal"); + Acore::Text::SendAreaTriggerMessage(player->GetSession(), "Only The Alliance can use that portal"); else player->LeaveBattleground(); break; case 3949: // Arathi Basin Horde Exit. if (player->GetTeamId() != TEAM_HORDE) - player->GetSession()->SendAreaTriggerMessage("Only The Horde can use that portal"); + Acore::Text::SendAreaTriggerMessage(player->GetSession(), "Only The Horde can use that portal"); else player->LeaveBattleground(); break; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp index 517caf0e698467..d9e88f85a9a104 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundAV.cpp @@ -16,6 +16,7 @@ */ #include "BattlegroundAV.h" +#include "ChatTextBuilder.h" #include "Formulas.h" #include "GameEventMgr.h" #include "GameGraveyard.h" @@ -519,13 +520,13 @@ void BattlegroundAV::HandleAreaTrigger(Player* player, uint32 trigger) case 95: case 2608: if (player->GetTeamId() != TEAM_ALLIANCE) - player->GetSession()->SendAreaTriggerMessage("Only The Alliance can use that portal"); + Acore::Text::SendAreaTriggerMessage(player->GetSession(), "Only The Alliance can use that portal"); else player->LeaveBattleground(); break; case 2606: if (player->GetTeamId() != TEAM_HORDE) - player->GetSession()->SendAreaTriggerMessage("Only The Horde can use that portal"); + Acore::Text::SendAreaTriggerMessage(player->GetSession(), "Only The Horde can use that portal"); else player->LeaveBattleground(); break; diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index 5af09724d35a35..c0313b028a283c 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -17,6 +17,7 @@ #include "BattlegroundEY.h" #include "BattlegroundMgr.h" +#include "ChatTextBuilder.h" #include "Creature.h" #include "GameGraveyard.h" #include "GameTime.h" @@ -429,7 +430,7 @@ void BattlegroundEY::EventPlayerClickedOnFlag(Player* player, GameObject* gameOb player->CastSpell(player, BG_EY_NETHERSTORM_FLAG_SPELL, true); player->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_ENTER_PVP_COMBAT); - PSendMessageToAll(LANG_BG_EY_HAS_TAKEN_FLAG, player->GetTeamId() == TEAM_ALLIANCE ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE, nullptr, player->GetName().c_str()); + Acore::Text::SendBattlegroundMessageToAll(this, player->GetTeamId() == TEAM_ALLIANCE ? CHAT_MSG_BG_SYSTEM_ALLIANCE : CHAT_MSG_BG_SYSTEM_HORDE, LANG_BG_EY_HAS_TAKEN_FLAG, player->GetName()); PlaySoundToAll(player->GetTeamId() == TEAM_ALLIANCE ? BG_EY_SOUND_FLAG_PICKED_UP_ALLIANCE : BG_EY_SOUND_FLAG_PICKED_UP_HORDE); UpdateWorldState(NETHERSTORM_FLAG, 0); } diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp index f084f3b6785b1e..81678a0f6f491e 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundSA.cpp @@ -16,6 +16,7 @@ */ #include "BattlegroundSA.h" +#include "ChatTextBuilder.h" #include "GameGraveyard.h" #include "GameObject.h" #include "GameTime.h" @@ -353,7 +354,7 @@ void BattlegroundSA::PostUpdateImpl(uint32 diff) if (TotalTime >= 1min) { - SendWarningToAll(LANG_BG_SA_HAS_BEGUN); + Acore::Text::SendBattlegroundWarningToAll(this, LANG_BG_SA_HAS_BEGUN); TotalTime = 0s; ToggleTimer(); DemolisherStartState(false); @@ -407,7 +408,7 @@ void BattlegroundSA::PostUpdateImpl(uint32 diff) Status = BG_SA_SECOND_WARMUP; TotalTime = 0s; ToggleTimer(); - SendWarningToAll(LANG_BG_SA_ROUND_ONE_END); + Acore::Text::SendBattlegroundWarningToAll(this, LANG_BG_SA_ROUND_ONE_END); UpdateWaitTimer = 5000; SignaledRoundTwo = false; SignaledRoundTwoHalfMin = false; @@ -630,9 +631,9 @@ void BattlegroundSA::EventPlayerDamagedGO(Player* /*player*/, GameObject* go, ui if (eventType == go->GetGOInfo()->building.destroyedEvent) { if (go->GetGOInfo()->building.destroyedEvent == 19837) - SendWarningToAll(LANG_BG_SA_CHAMBER_BREACHED); + Acore::Text::SendBattlegroundWarningToAll(this, LANG_BG_SA_CHAMBER_BREACHED); else - SendWarningToAll(LANG_BG_SA_WAS_DESTROYED, go->GetGOInfo()->name.c_str()); + Acore::Text::SendBattlegroundWarningToAll(this, LANG_BG_SA_WAS_DESTROYED, go->GetGOInfo()->name); uint32 i = GetGateIDFromEntry(go->GetEntry()); switch (i) @@ -667,7 +668,7 @@ void BattlegroundSA::EventPlayerDamagedGO(Player* /*player*/, GameObject* go, ui } if (eventType == go->GetGOInfo()->building.damageEvent) - SendWarningToAll(LANG_BG_SA_IS_UNDER_ATTACK, go->GetGOInfo()->name.c_str()); + Acore::Text::SendBattlegroundWarningToAll(this, LANG_BG_SA_IS_UNDER_ATTACK, go->GetGOInfo()->name); } void BattlegroundSA::HandleKillUnit(Creature* creature, Player* killer) @@ -969,10 +970,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source) UpdateWorldState(BG_SA_LEFT_GY_ALLIANCE, (GraveyardStatus[i] == TEAM_ALLIANCE ? 1 : 0)); UpdateWorldState(BG_SA_LEFT_GY_HORDE, (GraveyardStatus[i] == TEAM_ALLIANCE ? 0 : 1)); - if (Source->GetTeamId() == TEAM_ALLIANCE) - SendWarningToAll(LANG_BG_SA_A_GY_WEST); - else - SendWarningToAll(LANG_BG_SA_H_GY_WEST); + Acore::Text::SendBattlegroundWarningToAll(this, Source->GetTeamId() == TEAM_ALLIANCE ? LANG_BG_SA_A_GY_WEST : LANG_BG_SA_H_GY_WEST); break; case BG_SA_RIGHT_CAPTURABLE_GY: flag = BG_SA_RIGHT_FLAG; @@ -997,10 +995,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source) UpdateWorldState(BG_SA_RIGHT_GY_ALLIANCE, (GraveyardStatus[i] == TEAM_ALLIANCE ? 1 : 0)); UpdateWorldState(BG_SA_RIGHT_GY_HORDE, (GraveyardStatus[i] == TEAM_ALLIANCE ? 0 : 1)); - if (Source->GetTeamId() == TEAM_ALLIANCE) - SendWarningToAll(LANG_BG_SA_A_GY_EAST); - else - SendWarningToAll(LANG_BG_SA_H_GY_EAST); + Acore::Text::SendBattlegroundWarningToAll(this, Source->GetTeamId() == TEAM_ALLIANCE ? LANG_BG_SA_A_GY_EAST : LANG_BG_SA_H_GY_EAST); break; case BG_SA_CENTRAL_CAPTURABLE_GY: flag = BG_SA_CENTRAL_FLAG; @@ -1011,10 +1006,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player* Source) UpdateWorldState(BG_SA_CENTER_GY_ALLIANCE, (GraveyardStatus[i] == TEAM_ALLIANCE ? 1 : 0)); UpdateWorldState(BG_SA_CENTER_GY_HORDE, (GraveyardStatus[i] == TEAM_ALLIANCE ? 0 : 1)); - if (Source->GetTeamId() == TEAM_ALLIANCE) - SendWarningToAll(LANG_BG_SA_A_GY_SOUTH); - else - SendWarningToAll(LANG_BG_SA_H_GY_SOUTH); + Acore::Text::SendBattlegroundWarningToAll(this, Source->GetTeamId() == TEAM_ALLIANCE ? LANG_BG_SA_A_GY_SOUTH : LANG_BG_SA_H_GY_SOUTH); break; default: ABORT(); diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 67ea787ae3c4d0..09235a8b1976d3 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -214,7 +214,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass) playersStore[guid] = pinfo; if (_channelRights.joinMessage.length()) - ChatHandler(player->GetSession()).PSendSysMessage("%s", _channelRights.joinMessage.c_str()); + ChatHandler(player->GetSession()).PSendSysMessage("{}", _channelRights.joinMessage); WorldPacket data; MakeYouJoined(&data); @@ -369,7 +369,7 @@ void Channel::KickOrBan(Player const* player, std::string const& badname, bool b } else { - ChatHandler(player->GetSession()).PSendSysMessage("Character %s has other faction!", badname.c_str()); + ChatHandler(player->GetSession()).PSendSysMessage("Character {} has other faction!", badname); return; } } diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index 3eb76c783d138d..0fdd6ae859e2c0 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -18,9 +18,9 @@ #include "ChannelMgr.h" #include "Log.h" #include "Player.h" -#include "World.h" -#include "Tokenize.h" #include "StringConvert.h" +#include "Tokenize.h" +#include "World.h" ChannelMgr::~ChannelMgr() { diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index cc0bed87b25cf4..97d58256f35430 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -19,6 +19,7 @@ #include "AccountMgr.h" #include "CellImpl.h" #include "Common.h" +#include "GameLocale.h" #include "GridNotifiersImpl.h" #include "Language.h" #include "Log.h" @@ -39,7 +40,7 @@ Player* ChatHandler::GetPlayer() const return m_session ? m_session->GetPlayer() : nullptr; } -char const* ChatHandler::GetAcoreString(uint32 entry) const +std::string ChatHandler::GetAcoreString(uint32 entry) const { return m_session->GetAcoreString(entry); } @@ -161,7 +162,7 @@ bool ChatHandler::_ParseCommands(std::string_view text) return false; // Send error message for GMs - PSendSysMessage(LANG_CMD_INVALID, STRING_VIEW_FMT_ARG(text)); + PSendSysMessage(LANG_CMD_INVALID, text); SetSentErrorMessage(true); return true; } @@ -794,9 +795,9 @@ std::string ChatHandler::GetNameLink(Player* chr) const return playerLink(chr->GetName()); } -char const* CliHandler::GetAcoreString(uint32 entry) const +std::string CliHandler::GetAcoreString(uint32 entry) const { - return sObjectMgr->GetAcoreStringForDBCLocale(entry); + return sGameLocale->GetAcoreStringForDBCLocale(entry); } void CliHandler::SendSysMessage(std::string_view str, bool /*escapeCharacters*/) @@ -880,5 +881,5 @@ LocaleConstant CliHandler::GetSessionDbcLocale() const int CliHandler::GetSessionDbLocaleIndex() const { - return sObjectMgr->GetDBCLocaleIndex(); + return sGameLocale->GetDBCLocaleIndex(); } diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 8972125dd5f500..bfcf7411db9d31 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -51,27 +51,27 @@ class AC_GAME_API ChatHandler static char* LineFromMessage(char*& pos) { char* start = strtok(pos, "\n"); pos = nullptr; return start; } // function with different implementation for chat/console - virtual char const* GetAcoreString(uint32 entry) const; + virtual std::string GetAcoreString(uint32 entry) const; virtual void SendSysMessage(std::string_view str, bool escapeCharacters = false); void SendSysMessage(uint32 entry); template - void PSendSysMessage(char const* fmt, Args&&... args) + void PSendSysMessage(std::string_view fmt, Args&&... args) { - SendSysMessage(Acore::StringFormat(fmt, std::forward(args)...).c_str()); + SendSysMessage(Acore::StringFormatFmt(fmt, std::forward(args)...)); } template void PSendSysMessage(uint32 entry, Args&&... args) { - SendSysMessage(PGetParseString(entry, std::forward(args)...).c_str()); + SendSysMessage(PGetParseString(entry, std::forward(args)...)); } template std::string PGetParseString(uint32 entry, Args&&... args) const { - return Acore::StringFormat(GetAcoreString(entry), std::forward(args)...); + return Acore::StringFormatFmt(GetAcoreString(entry), std::forward(args)...); } bool _ParseCommands(std::string_view text); @@ -138,7 +138,7 @@ class AC_GAME_API CliHandler : public ChatHandler explicit CliHandler(void* callbackArg, Print* zprint) : m_callbackArg(callbackArg), m_print(zprint) { } // overwrite functions - char const* GetAcoreString(uint32 entry) const override; + std::string GetAcoreString(uint32 entry) const override; void SendSysMessage(std::string_view, bool escapeCharacters) override; bool ParseCommands(std::string_view str) override; std::string GetNameLink() const override; diff --git a/src/server/game/Chat/ChatCommands/ChatCommand.cpp b/src/server/game/Chat/ChatCommands/ChatCommand.cpp index 1bcbde69d1ea69..caf37da6e2b2ff 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommand.cpp +++ b/src/server/game/Chat/ChatCommands/ChatCommand.cpp @@ -20,6 +20,7 @@ #include "Chat.h" #include "DBCStores.h" #include "DatabaseEnv.h" +#include "GameLocale.h" #include "Log.h" #include "Player.h" #include "ScriptMgr.h" @@ -28,16 +29,14 @@ #include "WorldSession.h" using ChatSubCommandMap = std::map; +static ChatSubCommandMap COMMAND_MAP; void Acore::Impl::ChatCommands::ChatCommandNode::LoadFromBuilder(ChatCommandBuilder const& builder) { if (std::holds_alternative(builder._data)) { ASSERT(!_invoker, "Duplicate blank sub-command."); - AcoreStrings help; - std::tie(_invoker, help, _permission) = *(std::get(builder._data)); - if (help) - _help.emplace(help); + std::tie(_invoker, _permission) = *(std::get(builder._data)); } else LoadCommandsIntoMap(this, _subCommands, std::get(builder._data)); @@ -65,7 +64,6 @@ void Acore::Impl::ChatCommands::ChatCommandNode::LoadFromBuilder(ChatCommandBuil } } -static ChatSubCommandMap COMMAND_MAP; /*static*/ ChatSubCommandMap const& Acore::Impl::ChatCommands::ChatCommandNode::GetTopLevelMap() { if (COMMAND_MAP.empty()) @@ -73,6 +71,7 @@ static ChatSubCommandMap COMMAND_MAP; return COMMAND_MAP; } + /*static*/ void Acore::Impl::ChatCommands::ChatCommandNode::InvalidateCommandMap() { COMMAND_MAP.clear(); @@ -122,13 +121,15 @@ static ChatSubCommandMap COMMAND_MAP; cmd->_permission.RequiredLevel = secLevel; } - if (std::holds_alternative(cmd->_help)) + if (!cmd->_help.empty()) + { LOG_ERROR("sql.sql", "Table `command` contains duplicate data for command '{}'. Skipped.", name); - - if (std::holds_alternative(cmd->_help)) - cmd->_help.emplace(help); + } else - LOG_ERROR("sql.sql", "Table `command` contains legacy help text for command '{}', which uses `trinity_string`. Skipped.", name); + { + cmd->_help = help; + } + } while (result->NextRow()); } @@ -138,7 +139,7 @@ static ChatSubCommandMap COMMAND_MAP; void Acore::Impl::ChatCommands::ChatCommandNode::ResolveNames(std::string name) { - if (_invoker && std::holds_alternative(_help)) + if (_invoker && _help.empty()) LOG_WARN("sql.sql", "Table `command` is missing help text for command '{}'.", name); _name = name; @@ -192,14 +193,18 @@ void Acore::Impl::ChatCommands::ChatCommandNode::SendCommandHelp(ChatHandler& ha bool const hasInvoker = IsInvokerVisible(handler); if (hasInvoker) { - if (std::holds_alternative(_help)) - handler.SendSysMessage(std::get(_help)); - else if (std::holds_alternative(_help)) - handler.SendSysMessage(std::get(_help)); + if (auto localizeHelp = sGameLocale->GetChatCommandStringHelpLocale(_name, handler.GetSessionDbcLocale())) + { + handler.SendSysMessage(*localizeHelp); + } + else if (!_help.empty()) + { + handler.SendSysMessage(_help); + } else { - handler.PSendSysMessage(LANG_CMD_HELP_GENERIC, STRING_VIEW_FMT_ARG(_name)); - handler.PSendSysMessage(LANG_CMD_NO_HELP_AVAILABLE, STRING_VIEW_FMT_ARG(_name)); + handler.PSendSysMessage(LANG_CMD_HELP_GENERIC, _name); + handler.PSendSysMessage(LANG_CMD_NO_HELP_AVAILABLE, _name); } } @@ -218,14 +223,14 @@ void Acore::Impl::ChatCommands::ChatCommandNode::SendCommandHelp(ChatHandler& ha { if (!hasInvoker) { - handler.PSendSysMessage(LANG_CMD_HELP_GENERIC, STRING_VIEW_FMT_ARG(_name)); + handler.PSendSysMessage(LANG_CMD_HELP_GENERIC, _name); } handler.SendSysMessage(LANG_SUBCMDS_LIST); header = true; } - handler.PSendSysMessage(subCommandHasSubCommand ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, STRING_VIEW_FMT_ARG(it->second._name)); + handler.PSendSysMessage(subCommandHasSubCommand ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, it->second._name); } } @@ -301,14 +306,14 @@ namespace Acore::Impl::ChatCommands if (it2) { /* there are multiple matching subcommands - print possibilities and return */ if (cmd) - handler.PSendSysMessage(LANG_SUBCMD_AMBIGUOUS, STRING_VIEW_FMT_ARG(cmd->_name), COMMAND_DELIMITER, STRING_VIEW_FMT_ARG(token)); + handler.PSendSysMessage(LANG_SUBCMD_AMBIGUOUS, cmd->_name, COMMAND_DELIMITER, token); else - handler.PSendSysMessage(LANG_CMD_AMBIGUOUS, STRING_VIEW_FMT_ARG(token)); + handler.PSendSysMessage(LANG_CMD_AMBIGUOUS, token); - handler.PSendSysMessage(it1->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, STRING_VIEW_FMT_ARG(it1->first)); + handler.PSendSysMessage(it1->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, it1->first); do { - handler.PSendSysMessage(it2->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, STRING_VIEW_FMT_ARG(it2->first)); + handler.PSendSysMessage(it2->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, it2->first); } while (++it2); return true; @@ -365,10 +370,10 @@ namespace Acore::Impl::ChatCommands if (cmd) { cmd->SendCommandHelp(handler); - handler.PSendSysMessage(LANG_SUBCMD_INVALID, STRING_VIEW_FMT_ARG(cmd->_name), COMMAND_DELIMITER, STRING_VIEW_FMT_ARG(token)); + handler.PSendSysMessage(LANG_SUBCMD_INVALID, cmd->_name, COMMAND_DELIMITER, token); } else - handler.PSendSysMessage(LANG_CMD_INVALID, STRING_VIEW_FMT_ARG(token)); + handler.PSendSysMessage(LANG_CMD_INVALID, token); return; } @@ -380,14 +385,14 @@ namespace Acore::Impl::ChatCommands if (it2) { /* there are multiple matching subcommands - print possibilities and return */ if (cmd) - handler.PSendSysMessage(LANG_SUBCMD_AMBIGUOUS, STRING_VIEW_FMT_ARG(cmd->_name), COMMAND_DELIMITER, STRING_VIEW_FMT_ARG(token)); + handler.PSendSysMessage(LANG_SUBCMD_AMBIGUOUS, cmd->_name, COMMAND_DELIMITER, token); else - handler.PSendSysMessage(LANG_CMD_AMBIGUOUS, STRING_VIEW_FMT_ARG(token)); + handler.PSendSysMessage(LANG_CMD_AMBIGUOUS, token); - handler.PSendSysMessage(it1->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, STRING_VIEW_FMT_ARG(it1->first)); + handler.PSendSysMessage(it1->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, it1->first); do { - handler.PSendSysMessage(it2->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, STRING_VIEW_FMT_ARG(it2->first)); + handler.PSendSysMessage(it2->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, it2->first); } while (++it2); return; @@ -408,11 +413,11 @@ namespace Acore::Impl::ChatCommands handler.SendSysMessage(LANG_AVAILABLE_CMDS); do { - handler.PSendSysMessage(it->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, STRING_VIEW_FMT_ARG(it->second._name)); + handler.PSendSysMessage(it->second.HasVisibleSubCommands(handler) ? LANG_SUBCMDS_LIST_ENTRY_ELLIPSIS : LANG_SUBCMDS_LIST_ENTRY, it->second._name); } while (++it); } else - handler.PSendSysMessage(LANG_CMD_INVALID, STRING_VIEW_FMT_ARG(cmdStr)); + handler.PSendSysMessage(LANG_CMD_INVALID, cmdStr); } /*static*/ std::vector Acore::Impl::ChatCommands::ChatCommandNode::GetAutoCompletionsFor(ChatHandler const& handler, std::string_view cmdStr) diff --git a/src/server/game/Chat/ChatCommands/ChatCommand.h b/src/server/game/Chat/ChatCommands/ChatCommand.h index 21a45409af95e2..8f5dc16079622f 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommand.h +++ b/src/server/game/Chat/ChatCommands/ChatCommand.h @@ -187,7 +187,7 @@ namespace Acore::Impl::ChatCommands static void SendCommandHelpFor(ChatHandler& handler, std::string_view cmd); static std::vector GetAutoCompletionsFor(ChatHandler const& handler, std::string_view cmd); - ChatCommandNode() : _name{}, _invoker {}, _permission{}, _help{}, _subCommands{} { } + ChatCommandNode() : _name{}, _invoker{}, _permission{}, _help{}, _subCommands{} { } private: static std::map const& GetTopLevelMap(); @@ -206,7 +206,7 @@ namespace Acore::Impl::ChatCommands std::string _name; CommandInvoker _invoker; CommandPermissions _permission; - std::variant _help; + std::string _help; std::map _subCommands; }; } @@ -220,8 +220,8 @@ namespace Acore::ChatCommands struct InvokerEntry { template - InvokerEntry(T& handler, AcoreStrings help, uint32 securityLevel, Acore::ChatCommands::Console allowConsole) - : _invoker{ handler }, _help{ help }, _permissions{ securityLevel, allowConsole } { } + InvokerEntry(T& handler, uint32 securityLevel, Acore::ChatCommands::Console allowConsole) + : _invoker{ handler }, _permissions{ securityLevel, allowConsole } { } InvokerEntry(InvokerEntry const&) = default; InvokerEntry(InvokerEntry&&) = default; @@ -230,7 +230,7 @@ namespace Acore::ChatCommands AcoreStrings _help; Acore::Impl::ChatCommands::CommandPermissions _permissions; - auto operator*() const { return std::tie(_invoker, _help, _permissions); } + auto operator*() const { return std::tie(_invoker, _permissions); } }; using SubCommandEntry = std::reference_wrapper const>; @@ -238,28 +238,20 @@ namespace Acore::ChatCommands ChatCommandBuilder(ChatCommandBuilder&&) = default; ChatCommandBuilder(ChatCommandBuilder const&) = default; - template - ChatCommandBuilder(char const* name, TypedHandler& handler, AcoreStrings help, uint32 securityLevel, Acore::ChatCommands::Console allowConsole) - : _name{ ASSERT_NOTNULL(name) }, _data{ std::in_place_type, handler, help, securityLevel, allowConsole } { } - template ChatCommandBuilder(char const* name, TypedHandler& handler, uint32 securityLevel, Acore::ChatCommands::Console allowConsole) - : ChatCommandBuilder(name, handler, AcoreStrings(), securityLevel, allowConsole) { } + : _name{ ASSERT_NOTNULL(name) }, _data{ std::in_place_type, handler, securityLevel, allowConsole } { } ChatCommandBuilder(char const* name, std::vector const& subCommands) : _name{ ASSERT_NOTNULL(name) }, _data{ std::in_place_type, subCommands } { } - [[deprecated("char const* parameters to command handlers are deprecated; convert this to a typed argument handler instead")]] - ChatCommandBuilder(char const* name, bool(&handler)(ChatHandler*, char const*), uint32 securityLevel, Acore::ChatCommands::Console allowConsole) - : ChatCommandBuilder(name, handler, AcoreStrings(), securityLevel, allowConsole) { } - template [[deprecated("you are using the old-style command format; convert this to the new format ({ name, handler (not a pointer!), permission, Console::(Yes/No) })")]] ChatCommandBuilder(char const* name, uint32 securityLevel, bool console, TypedHandler* handler, char const*) - : ChatCommandBuilder(name, *handler, AcoreStrings(), securityLevel, static_cast(console)) { } + : ChatCommandBuilder(name, *handler, securityLevel, static_cast(console)) { } [[deprecated("you are using the old-style command format; convert this to the new format ({ name, subCommands })")]] - ChatCommandBuilder(char const* name, uint32, bool, std::nullptr_t, char const*, std::vector const& sub) + ChatCommandBuilder(char const* name, uint32, bool, std::nullptr_t, char const*, std::vector const& sub) : ChatCommandBuilder(name, sub) { } private: diff --git a/src/server/game/Chat/ChatCommands/ChatCommandArgs.cpp b/src/server/game/Chat/ChatCommands/ChatCommandArgs.cpp index 44d77f93353d6c..da32757e694cd4 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandArgs.cpp +++ b/src/server/game/Chat/ChatCommands/ChatCommandArgs.cpp @@ -63,7 +63,7 @@ ChatCommandResult Acore::Impl::ChatCommands::ArgInfo::TryConsum if (val.holds_alternative>()) return FormatAcoreString(handler, LANG_CMDPARSER_GAME_TELE_ID_NO_EXIST, static_cast(std::get>(val))); else - return FormatAcoreString(handler, LANG_CMDPARSER_GAME_TELE_NO_EXIST, STRING_VIEW_FMT_ARG(std::get(val))); + return FormatAcoreString(handler, LANG_CMDPARSER_GAME_TELE_NO_EXIST, std::get(val)); } struct ItemTemplateVisitor diff --git a/src/server/game/Chat/ChatCommands/ChatCommandArgs.h b/src/server/game/Chat/ChatCommands/ChatCommandArgs.h index 6b75e2355bc4bf..65ec5d4edadf17 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandArgs.h +++ b/src/server/game/Chat/ChatCommands/ChatCommandArgs.h @@ -62,12 +62,12 @@ namespace Acore::Impl::ChatCommands if (Optional v = StringTo(token, 0)) val = *v; else - return FormatAcoreString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, STRING_VIEW_FMT_ARG(token), GetTypeName().c_str()); + return FormatAcoreString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, token, GetTypeName().c_str()); if constexpr (std::is_floating_point_v) { if (!std::isfinite(val)) - return FormatAcoreString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, STRING_VIEW_FMT_ARG(token), GetTypeName().c_str()); + return FormatAcoreString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, token, GetTypeName().c_str()); } return tail; @@ -200,7 +200,7 @@ namespace Acore::Impl::ChatCommands } if (next1) - return FormatAcoreString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, STRING_VIEW_FMT_ARG(strVal), GetTypeName().c_str()); + return FormatAcoreString(handler, LANG_CMDPARSER_STRING_VALUE_INVALID, strVal, GetTypeName()); else return next1; } @@ -273,9 +273,9 @@ namespace Acore::Impl::ChatCommands if (!nestedResult.HasErrorMessage()) return thisResult; if (StringStartsWith(nestedResult.GetErrorMessage(), "\"")) - return Acore::StringFormat("\"%s\"\n%s %s", thisResult.GetErrorMessage().c_str(), GetAcoreString(handler, LANG_CMDPARSER_OR), nestedResult.GetErrorMessage().c_str()); + return Acore::StringFormatFmt("\"{}\"\n{} {}", thisResult.GetErrorMessage(), GetAcoreString(handler, LANG_CMDPARSER_OR), nestedResult.GetErrorMessage()); else - return Acore::StringFormat("\"%s\"\n%s \"%s\"", thisResult.GetErrorMessage().c_str(), GetAcoreString(handler, LANG_CMDPARSER_OR), nestedResult.GetErrorMessage().c_str()); + return Acore::StringFormatFmt("\"{}\"\n{} \"{}\"", thisResult.GetErrorMessage(), GetAcoreString(handler, LANG_CMDPARSER_OR), nestedResult.GetErrorMessage()); } } else @@ -286,7 +286,7 @@ namespace Acore::Impl::ChatCommands { ChatCommandResult result = TryAtIndex<0>(val, handler, args); if (result.HasErrorMessage() && (result.GetErrorMessage().find('\n') != std::string::npos)) - return Acore::StringFormat("%s %s", GetAcoreString(handler, LANG_CMDPARSER_EITHER), result.GetErrorMessage().c_str()); + return Acore::StringFormatFmt("{} {}", GetAcoreString(handler, LANG_CMDPARSER_EITHER), result.GetErrorMessage()); return result; } }; diff --git a/src/server/game/Chat/ChatCommands/ChatCommandHelpers.cpp b/src/server/game/Chat/ChatCommands/ChatCommandHelpers.cpp index f8e0efe07e4e61..aedf7d1261de14 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandHelpers.cpp +++ b/src/server/game/Chat/ChatCommands/ChatCommandHelpers.cpp @@ -25,7 +25,7 @@ void Acore::Impl::ChatCommands::SendErrorMessageToHandler(ChatHandler* handler, handler->SetSentErrorMessage(true); } -char const* Acore::Impl::ChatCommands::GetAcoreString(ChatHandler const* handler, AcoreStrings which) +std::string Acore::Impl::ChatCommands::GetAcoreString(ChatHandler const* handler, AcoreStrings which) { return handler->GetAcoreString(which); } diff --git a/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h b/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h index 6ead5173162bb2..328a59cd3cfbc8 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h +++ b/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h @@ -121,11 +121,12 @@ namespace Acore::Impl::ChatCommands }; AC_GAME_API void SendErrorMessageToHandler(ChatHandler* handler, std::string_view str); - AC_GAME_API char const* GetAcoreString(ChatHandler const* handler, AcoreStrings which); + AC_GAME_API std::string GetAcoreString(ChatHandler const* handler, AcoreStrings which); + template std::string FormatAcoreString(ChatHandler const* handler, AcoreStrings which, Ts&&... args) { - return Acore::StringFormat(GetAcoreString(handler, which), std::forward(args)...); + return Acore::StringFormatFmt(GetAcoreString(handler, which), std::forward(args)...); } } diff --git a/src/server/game/Chat/ChatCommands/ChatCommandTags.cpp b/src/server/game/Chat/ChatCommands/ChatCommandTags.cpp index 40fcc277ce23bd..f5b438bc96f2ab 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandTags.cpp +++ b/src/server/game/Chat/ChatCommands/ChatCommandTags.cpp @@ -77,7 +77,7 @@ ChatCommandResult Acore::ChatCommands::AccountIdentifier::TryConsume(ChatHandler // try parsing as account id instead Optional id = Acore::StringTo(text, 10); if (!id) - return FormatAcoreString(handler, LANG_CMDPARSER_ACCOUNT_NAME_NO_EXIST, STRING_VIEW_FMT_ARG(_name)); + return FormatAcoreString(handler, LANG_CMDPARSER_ACCOUNT_NAME_NO_EXIST, _name); _id = *id; @@ -117,7 +117,7 @@ ChatCommandResult Acore::ChatCommands::PlayerIdentifier::TryConsume(ChatHandler _name.assign(val.get()); if (!normalizePlayerName(_name)) - return FormatAcoreString(handler, LANG_CMDPARSER_CHAR_NAME_INVALID, STRING_VIEW_FMT_ARG(_name)); + return FormatAcoreString(handler, LANG_CMDPARSER_CHAR_NAME_INVALID, _name); if ((_player = ObjectAccessor::FindPlayerByName(_name))) { @@ -125,7 +125,7 @@ ChatCommandResult Acore::ChatCommands::PlayerIdentifier::TryConsume(ChatHandler } else if (!(_guid = sCharacterCache->GetCharacterGuidByName(_name))) { - return FormatAcoreString(handler, LANG_CMDPARSER_CHAR_NAME_NO_EXIST, STRING_VIEW_FMT_ARG(_name)); + return FormatAcoreString(handler, LANG_CMDPARSER_CHAR_NAME_NO_EXIST, _name); } return next; diff --git a/src/server/game/Chat/ChatCommands/ChatCommandTags.h b/src/server/game/Chat/ChatCommands/ChatCommandTags.h index 75dd4cc5321345..635811eb5698fc 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandTags.h +++ b/src/server/game/Chat/ChatCommands/ChatCommandTags.h @@ -102,7 +102,7 @@ namespace Acore::ChatCommands return tail; start = args.substr(0, _string.length() + remainingToken.length()); } - return Acore::Impl::ChatCommands::FormatAcoreString(handler, LANG_CMDPARSER_EXACT_SEQ_MISMATCH, STRING_VIEW_FMT_ARG(_string), STRING_VIEW_FMT_ARG(start)); + return Acore::Impl::ChatCommands::FormatAcoreString(handler, LANG_CMDPARSER_EXACT_SEQ_MISMATCH, _string, start); } private: diff --git a/src/server/game/Chat/Hyperlinks.cpp b/src/server/game/Chat/Hyperlinks.cpp index cc9e43cafce43c..cc4fffe5c708b4 100644 --- a/src/server/game/Chat/Hyperlinks.cpp +++ b/src/server/game/Chat/Hyperlinks.cpp @@ -19,6 +19,7 @@ #include "Common.h" #include "DBCStores.h" #include "Errors.h" +#include "GameLocale.h" #include "ObjectMgr.h" #include "QuestDef.h" #include "SharedDefines.h" @@ -134,7 +135,7 @@ struct LinkValidator { static bool IsTextValid(ItemLinkData const& data, std::string_view text) { - ItemLocale const* locale = sObjectMgr->GetItemLocale(data.Item->ItemId); + ItemLocale const* locale = sGameLocale->GetItemLocale(data.Item->ItemId); std::array const* randomSuffixes = nullptr; @@ -151,7 +152,7 @@ struct LinkValidator if (!locale && i != DEFAULT_LOCALE) continue; - std::string_view name = (i == DEFAULT_LOCALE) ? data.Item->Name1 : ObjectMgr::GetLocaleString(locale->Name, i); + std::string_view name = (i == DEFAULT_LOCALE) ? data.Item->Name1 : GameLocale::GetLocaleString(locale->Name, i); if (name.empty()) continue; @@ -188,7 +189,7 @@ struct LinkValidator if (text == data.Quest->GetTitle()) return true; - QuestLocale const* locale = sObjectMgr->GetQuestLocale(data.Quest->GetQuestId()); + QuestLocale const* locale = sGameLocale->GetQuestLocale(data.Quest->GetQuestId()); if (!locale) return false; @@ -197,7 +198,7 @@ struct LinkValidator if (i == DEFAULT_LOCALE) continue; - std::string_view name = ObjectMgr::GetLocaleString(locale->Title, i); + std::string_view name = GameLocale::GetLocaleString(locale->Title, i); if (!name.empty() && (text == name)) return true; } diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 34c1bc6d5dcc07..190217a86d196d 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -20,8 +20,8 @@ #include "GameEventMgr.h" #include "InstanceScript.h" #include "ObjectMgr.h" -#include "Player.h" #include "Pet.h" +#include "Player.h" #include "ReputationMgr.h" #include "ScriptMgr.h" #include "ScriptedCreature.h" diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp index d31413cc674315..59a7a70ff9e9e9 100644 --- a/src/server/game/Conditions/DisableMgr.cpp +++ b/src/server/game/Conditions/DisableMgr.cpp @@ -23,9 +23,9 @@ #include "Player.h" #include "SpellInfo.h" #include "SpellMgr.h" -#include "World.h" -#include "Tokenize.h" #include "StringConvert.h" +#include "Tokenize.h" +#include "World.h" namespace DisableMgr { diff --git a/src/server/game/DungeonFinding/LFG.cpp b/src/server/game/DungeonFinding/LFG.cpp index b22ece09622d27..8aba8a14fd179b 100644 --- a/src/server/game/DungeonFinding/LFG.cpp +++ b/src/server/game/DungeonFinding/LFG.cpp @@ -16,6 +16,7 @@ */ #include "LFG.h" +#include "GameLocale.h" #include "Language.h" #include "ObjectMgr.h" @@ -41,31 +42,31 @@ namespace lfg std::string rolesstr = ""; if (roles & PLAYER_ROLE_TANK) - rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_TANK)); + rolesstr.append(sGameLocale->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_TANK)); if (roles & PLAYER_ROLE_HEALER) { if (!rolesstr.empty()) rolesstr.append(", "); - rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_HEALER)); + rolesstr.append(sGameLocale->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_HEALER)); } if (roles & PLAYER_ROLE_DAMAGE) { if (!rolesstr.empty()) rolesstr.append(", "); - rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_DAMAGE)); + rolesstr.append(sGameLocale->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_DAMAGE)); } if (roles & PLAYER_ROLE_LEADER) { if (!rolesstr.empty()) rolesstr.append(", "); - rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_LEADER)); + rolesstr.append(sGameLocale->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_LEADER)); } if (rolesstr.empty()) - rolesstr.append(sObjectMgr->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_NONE)); + rolesstr.append(sGameLocale->GetAcoreStringForDBCLocale(LANG_LFG_ROLE_NONE)); return rolesstr; } @@ -101,7 +102,7 @@ namespace lfg break; } - return std::string(sObjectMgr->GetAcoreStringForDBCLocale(entry)); + return std::string(sGameLocale->GetAcoreStringForDBCLocale(entry)); } } // namespace lfg diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index ba551a8ae468fe..5058113727497e 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -17,6 +17,7 @@ #include "LFGMgr.h" #include "CharacterCache.h" +#include "ChatTextBuilder.h" #include "Common.h" #include "DBCStores.h" #include "DisableMgr.h" @@ -795,7 +796,7 @@ namespace lfg void LFGMgr::ToggleTesting() { m_Testing = !m_Testing; - sWorld->SendWorldText(m_Testing ? LANG_DEBUG_LFG_ON : LANG_DEBUG_LFG_OFF); + Acore::Text::SendWorldText(m_Testing ? LANG_DEBUG_LFG_ON : LANG_DEBUG_LFG_OFF); } /** diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index eff8aa4b9547a1..8d548c5df9ca98 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -25,6 +25,7 @@ #include "DatabaseEnv.h" #include "Formulas.h" #include "GameEventMgr.h" +#include "GameLocale.h" #include "GameTime.h" #include "GridNotifiers.h" #include "Group.h" @@ -2928,7 +2929,7 @@ std::string const& Creature::GetNameForLocaleIdx(LocaleConstant loc_idx) const if (loc_idx != DEFAULT_LOCALE) { uint8 uloc_idx = uint8(loc_idx); - CreatureLocale const* cl = sObjectMgr->GetCreatureLocale(GetEntry()); + CreatureLocale const* cl = sGameLocale->GetCreatureLocale(GetEntry()); if (cl) { if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty()) diff --git a/src/server/game/Entities/Creature/CreatureData.h b/src/server/game/Entities/Creature/CreatureData.h index 18734e8ba1a613..01da8369420c73 100644 --- a/src/server/game/Entities/Creature/CreatureData.h +++ b/src/server/game/Entities/Creature/CreatureData.h @@ -329,23 +329,6 @@ struct CreatureBaseStats typedef std::unordered_map CreatureBaseStatsContainer; -struct CreatureLocale -{ - std::vector Name; - std::vector Title; -}; - -struct GossipMenuItemsLocale -{ - std::vector OptionText; - std::vector BoxText; -}; - -struct PointOfInterestLocale -{ - std::vector Name; -}; - struct EquipmentInfo { uint32 ItemEntry[MAX_EQUIPMENT_ITEMS]; diff --git a/src/server/game/Entities/Creature/GossipDef.cpp b/src/server/game/Entities/Creature/GossipDef.cpp index 303d829d16e46f..b2634038de4b7b 100644 --- a/src/server/game/Entities/Creature/GossipDef.cpp +++ b/src/server/game/Entities/Creature/GossipDef.cpp @@ -17,6 +17,7 @@ #include "GossipDef.h" #include "Formulas.h" +#include "GameLocale.h" #include "ObjectMgr.h" #include "Opcodes.h" #include "Player.h" @@ -91,18 +92,18 @@ void GossipMenu::AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, ui /// Store texts for localization. std::string strOptionText, strBoxText; - BroadcastText const* optionBroadcastText = sObjectMgr->GetBroadcastText(itr->second.OptionBroadcastTextID); - BroadcastText const* boxBroadcastText = sObjectMgr->GetBroadcastText(itr->second.BoxBroadcastTextID); + BroadcastText const* optionBroadcastText = sGameLocale->GetBroadcastText(itr->second.OptionBroadcastTextID); + BroadcastText const* boxBroadcastText = sGameLocale->GetBroadcastText(itr->second.BoxBroadcastTextID); /// OptionText if (optionBroadcastText) - ObjectMgr::GetLocaleString(optionBroadcastText->MaleText, GetLocale(), strOptionText); + GameLocale::GetLocaleString(optionBroadcastText->Text, GetLocale(), strOptionText); else strOptionText = itr->second.OptionText; /// BoxText if (boxBroadcastText) - ObjectMgr::GetLocaleString(boxBroadcastText->MaleText, GetLocale(), strBoxText); + GameLocale::GetLocaleString(boxBroadcastText->Text, GetLocale(), strBoxText); else strBoxText = itr->second.BoxText; @@ -112,15 +113,15 @@ void GossipMenu::AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, ui if (!optionBroadcastText) { /// Find localizations from database. - if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId))) - ObjectMgr::GetLocaleString(gossipMenuLocale->OptionText, GetLocale(), strOptionText); + if (GossipMenuItemsLocale const* gossipMenuLocale = sGameLocale->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId))) + GameLocale::GetLocaleString(gossipMenuLocale->OptionText, GetLocale(), strOptionText); } if (!boxBroadcastText) { /// Find localizations from database. - if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId))) - ObjectMgr::GetLocaleString(gossipMenuLocale->BoxText, GetLocale(), strBoxText); + if (GossipMenuItemsLocale const* gossipMenuLocale = sGameLocale->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId))) + GameLocale::GetLocaleString(gossipMenuLocale->BoxText, GetLocale(), strBoxText); } } @@ -223,8 +224,8 @@ void PlayerMenu::SendGossipMenu(uint32 titleTextId, ObjectGuid objectGUID) const std::string title = quest->GetTitle(); int32 locale = _session->GetSessionDbLocaleIndex(); - if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) - ObjectMgr::GetLocaleString(localeData->Title, locale, title); + if (QuestLocale const* localeData = sGameLocale->GetQuestLocale(questID)) + GameLocale::GetLocaleString(localeData->Title, locale, title); data << title; } } @@ -249,8 +250,8 @@ void PlayerMenu::SendPointOfInterest(uint32 poiId) const std::string name = poi->Name; int32 locale = _session->GetSessionDbLocaleIndex(); - if (PointOfInterestLocale const* localeData = sObjectMgr->GetPointOfInterestLocale(poiId)) - ObjectMgr::GetLocaleString(localeData->Name, locale, name); + if (PointOfInterestLocale const* localeData = sGameLocale->GetPointOfInterestLocale(poiId)) + GameLocale::GetLocaleString(localeData->Name, locale, name); WorldPacket data(SMSG_GOSSIP_POI, 4 + 4 + 4 + 4 + 4 + 20); // guess size data << uint32(poi->Flags); @@ -329,8 +330,8 @@ void PlayerMenu::SendQuestGiverQuestList(QEmote const& eEmote, const std::string std::string title = quest->GetTitle(); int32 locale = _session->GetSessionDbLocaleIndex(); - if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(questID)) - ObjectMgr::GetLocaleString(localeData->Title, locale, title); + if (QuestLocale const* localeData = sGameLocale->GetQuestLocale(questID)) + GameLocale::GetLocaleString(localeData->Title, locale, title); data << uint32(questID); data << uint32(qmi.QuestIcon); @@ -364,12 +365,12 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU std::string questAreaDescription = quest->GetAreaDescription(); int32 locale = _session->GetSessionDbLocaleIndex(); - if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) + if (QuestLocale const* localeData = sGameLocale->GetQuestLocale(quest->GetQuestId())) { - ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle); - ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails); - ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives); - ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription); + GameLocale::GetLocaleString(localeData->Title, locale, questTitle); + GameLocale::GetLocaleString(localeData->Details, locale, questDetails); + GameLocale::GetLocaleString(localeData->Objectives, locale, questObjectives); + GameLocale::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription); } WorldPacket data(SMSG_QUESTGIVER_QUEST_DETAILS, 500); // guess size @@ -472,16 +473,16 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const questObjectiveText[i] = quest->ObjectiveText[i]; int32 locale = _session->GetSessionDbLocaleIndex(); - if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) + if (QuestLocale const* localeData = sGameLocale->GetQuestLocale(quest->GetQuestId())) { - ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle); - ObjectMgr::GetLocaleString(localeData->Details, locale, questDetails); - ObjectMgr::GetLocaleString(localeData->Objectives, locale, questObjectives); - ObjectMgr::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription); - ObjectMgr::GetLocaleString(localeData->CompletedText, locale, questCompletedText); + GameLocale::GetLocaleString(localeData->Title, locale, questTitle); + GameLocale::GetLocaleString(localeData->Details, locale, questDetails); + GameLocale::GetLocaleString(localeData->Objectives, locale, questObjectives); + GameLocale::GetLocaleString(localeData->AreaDescription, locale, questAreaDescription); + GameLocale::GetLocaleString(localeData->CompletedText, locale, questCompletedText); for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; ++i) - ObjectMgr::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]); + GameLocale::GetLocaleString(localeData->ObjectiveText[i], locale, questObjectiveText[i]); } WorldPacket data(SMSG_QUEST_QUERY_RESPONSE, 100); // guess size @@ -596,11 +597,11 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUI std::string RewardText = quest->GetOfferRewardText(); int32 locale = _session->GetSessionDbLocaleIndex(); - if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) - ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle); + if (QuestLocale const* localeData = sGameLocale->GetQuestLocale(quest->GetQuestId())) + GameLocale::GetLocaleString(localeData->Title, locale, questTitle); - if (QuestOfferRewardLocale const* questOfferRewardLocale = sObjectMgr->GetQuestOfferRewardLocale(quest->GetQuestId())) - ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText); + if (QuestOfferRewardLocale const* questOfferRewardLocale = sGameLocale->GetQuestOfferRewardLocale(quest->GetQuestId())) + GameLocale::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText); WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 400); // guess size data << npcGUID; @@ -689,11 +690,11 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, ObjectGuid npcGU std::string requestItemsText = quest->GetRequestItemsText(); int32 locale = _session->GetSessionDbLocaleIndex(); - if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId())) - ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle); + if (QuestLocale const* localeData = sGameLocale->GetQuestLocale(quest->GetQuestId())) + GameLocale::GetLocaleString(localeData->Title, locale, questTitle); - if (QuestRequestItemsLocale const* questRequestItemsLocale = sObjectMgr->GetQuestRequestItemsLocale(quest->GetQuestId())) - ObjectMgr::GetLocaleString(questRequestItemsLocale->CompletionText, locale, requestItemsText); + if (QuestRequestItemsLocale const* questRequestItemsLocale = sGameLocale->GetQuestRequestItemsLocale(quest->GetQuestId())) + GameLocale::GetLocaleString(questRequestItemsLocale->CompletionText, locale, requestItemsText); if (!quest->GetReqItemsCount() && canComplete) { diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index 834f1da528c507..d19503880ddd3e 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -21,6 +21,7 @@ #include "CreatureAISelector.h" #include "DisableMgr.h" #include "DynamicTree.h" +#include "GameLocale.h" #include "GameObjectAI.h" #include "GameObjectModel.h" #include "GameTime.h" @@ -2139,7 +2140,7 @@ std::string const& GameObject::GetNameForLocaleIdx(LocaleConstant loc_idx) const if (loc_idx != DEFAULT_LOCALE) { uint8 uloc_idx = uint8(loc_idx); - if (GameObjectLocale const* cl = sObjectMgr->GetGameObjectLocale(GetEntry())) + if (GameObjectLocale const* cl = sGameLocale->GetGameObjectLocale(GetEntry())) if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty()) return cl->Name[uloc_idx]; } diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h index 4bd2aca7bd3e77..27c084a1f37e49 100644 --- a/src/server/game/Entities/GameObject/GameObject.h +++ b/src/server/game/Entities/GameObject/GameObject.h @@ -692,12 +692,6 @@ union GameObjectValue } Building; }; -struct GameObjectLocale -{ - std::vector Name; - std::vector CastBarCaption; -}; - // `gameobject_addon` table struct GameObjectAddon { diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 1d2e21a7719a2e..0397bb1ce61127 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -26,10 +26,10 @@ #include "ScriptMgr.h" #include "SpellInfo.h" #include "SpellMgr.h" +#include "StringConvert.h" +#include "Tokenize.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "Tokenize.h" -#include "StringConvert.h" void AddItemsSetItem(Player* player, Item* item) { diff --git a/src/server/game/Entities/Item/ItemTemplate.h b/src/server/game/Entities/Item/ItemTemplate.h index 56da3f8372cc16..9c19777d5a2f26 100644 --- a/src/server/game/Entities/Item/ItemTemplate.h +++ b/src/server/game/Entities/Item/ItemTemplate.h @@ -837,21 +837,10 @@ struct ItemTemplate // Benchmarked: Faster than std::map (insert/find) typedef std::unordered_map ItemTemplateContainer; -struct ItemLocale -{ - std::vector Name; - std::vector Description; -}; - struct ItemSetNameEntry { std::string name; uint32 InventoryType; }; -struct ItemSetNameLocale -{ - std::vector Name; -}; - #endif diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index fe7dc4acb0d655..f537bea9efa9bd 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -37,8 +37,10 @@ #include "ScriptMgr.h" #include "SharedDefines.h" #include "SpellAuraEffects.h" +#include "StringConvert.h" #include "TargetedMovementGenerator.h" #include "TemporarySummon.h" +#include "Tokenize.h" #include "Totem.h" #include "Transport.h" #include "UpdateData.h" @@ -48,8 +50,6 @@ #include "Vehicle.h" #include "World.h" #include "WorldPacket.h" -#include "Tokenize.h" -#include "StringConvert.h" // TODO: this import is not necessary for compilation and marked as unused by the IDE // however, for some reasons removing it would cause a damn linking issue diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index d87a7fd085b39d..01e348a706b2ac 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -20,6 +20,7 @@ #include "Common.h" #include "CreatureAI.h" #include "DatabaseEnv.h" +#include "GameLocale.h" #include "GameTime.h" #include "Group.h" #include "InstanceScript.h" @@ -956,7 +957,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family)) SetName(cFamily->Name[sWorld->GetDefaultDbcLocale()]); else - SetName(creature->GetNameForLocaleIdx(sObjectMgr->GetDBCLocaleIndex())); + SetName(creature->GetNameForLocaleIdx(sGameLocale->GetDBCLocaleIndex())); return true; } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index f3cce991e8e29f..05c420ff94f7e6 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -42,6 +42,7 @@ #include "Formulas.h" #include "GameEventMgr.h" #include "GameGraveyard.h" +#include "GameLocale.h" #include "GameObjectAI.h" #include "GameTime.h" #include "GossipDef.h" @@ -75,7 +76,9 @@ #include "SpellAuraEffects.h" #include "SpellAuras.h" #include "SpellMgr.h" +#include "StringConvert.h" #include "TicketMgr.h" +#include "Tokenize.h" #include "Transport.h" #include "UpdateData.h" #include "UpdateFieldFlags.h" @@ -86,8 +89,6 @@ #include "World.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "Tokenize.h" -#include "StringConvert.h" // TODO: this import is not necessary for compilation and marked as unused by the IDE // however, for some reasons removing it would cause a damn linking issue @@ -6974,7 +6975,7 @@ void Player::ApplyItemEquipSpell(Item* item, bool apply, bool form_change) continue; // Spells that should stay on the caster after removing the item. - constexpr std::array spellExceptions = { /*Electromagnetic Gigaflux Reactivator*/ 11826 }; + constexpr std::array spellExceptions = { /*Electromagnetic Gigaflux Reactivator*/ 11826 }; const auto found = std::find(std::begin(spellExceptions), std::end(spellExceptions), spellData.SpellId); // wrong triggering type @@ -9276,11 +9277,11 @@ void Player::Whisper(std::string_view text, Language language, Player* target, b // announce afk or dnd message if (target->isAFK()) { - ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_AFK, target->GetName().c_str(), target->autoReplyMsg.c_str()); + ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_AFK, target->GetName(), target->autoReplyMsg); } else if (target->isDND()) { - ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, target->GetName().c_str(), target->autoReplyMsg.c_str()); + ChatHandler(GetSession()).PSendSysMessage(LANG_PLAYER_DND, target->GetName(), target->autoReplyMsg); } } @@ -9291,7 +9292,7 @@ void Player::Whisper(uint32 textId, Player* target, bool /*isBossWhisper = false return; } - BroadcastText const* bct = sObjectMgr->GetBroadcastText(textId); + BroadcastText const* bct = sGameLocale->GetBroadcastText(textId); if (!bct) { LOG_ERROR("entities.unit", "Player::Whisper: `broadcast_text` was not {} found", textId); diff --git a/src/server/game/Entities/Player/PlayerGossip.cpp b/src/server/game/Entities/Player/PlayerGossip.cpp index 5a509d0ee982d1..9448c4dc242690 100644 --- a/src/server/game/Entities/Player/PlayerGossip.cpp +++ b/src/server/game/Entities/Player/PlayerGossip.cpp @@ -16,6 +16,7 @@ */ #include "BattlegroundMgr.h" +#include "ChatTextBuilder.h" #include "GossipDef.h" #include "Language.h" #include "ObjectMgr.h" @@ -166,17 +167,17 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool { // search in broadcast_text and broadcast_text_locale std::string strOptionText, strBoxText; - BroadcastText const* optionBroadcastText = sObjectMgr->GetBroadcastText(itr->second.OptionBroadcastTextID); - BroadcastText const* boxBroadcastText = sObjectMgr->GetBroadcastText(itr->second.BoxBroadcastTextID); + BroadcastText const* optionBroadcastText = sGameLocale->GetBroadcastText(itr->second.OptionBroadcastTextID); + BroadcastText const* boxBroadcastText = sGameLocale->GetBroadcastText(itr->second.BoxBroadcastTextID); LocaleConstant locale = GetSession()->GetSessionDbLocaleIndex(); if (optionBroadcastText) - ObjectMgr::GetLocaleString(getGender() == GENDER_MALE ? optionBroadcastText->MaleText : optionBroadcastText->FemaleText, locale, strOptionText); + GameLocale::GetLocaleString(getGender() == GENDER_MALE ? optionBroadcastText->Text : optionBroadcastText->Text1, locale, strOptionText); else strOptionText = itr->second.OptionText; if (boxBroadcastText) - ObjectMgr::GetLocaleString(getGender() == GENDER_MALE ? boxBroadcastText->MaleText : boxBroadcastText->FemaleText, locale, strBoxText); + GameLocale::GetLocaleString(getGender() == GENDER_MALE ? boxBroadcastText->Text : boxBroadcastText->Text1, locale, strBoxText); else strBoxText = itr->second.BoxText; @@ -186,15 +187,15 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool if (strOptionText.empty()) { /// Find localizations from database. - if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, itr->second.OptionID))) - ObjectMgr::GetLocaleString(gossipMenuLocale->OptionText, locale, strOptionText); + if (GossipMenuItemsLocale const* gossipMenuLocale = sGameLocale->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, itr->second.OptionID))) + GameLocale::GetLocaleString(gossipMenuLocale->OptionText, locale, strOptionText); } if (strBoxText.empty()) { /// Find localizations from database. - if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, itr->second.OptionID))) - ObjectMgr::GetLocaleString(gossipMenuLocale->BoxText, locale, strBoxText); + if (GossipMenuItemsLocale const* gossipMenuLocale = sGameLocale->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, itr->second.OptionID))) + GameLocale::GetLocaleString(gossipMenuLocale->BoxText, locale, strBoxText); } } @@ -262,12 +263,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men if (gossipOptionId == GOSSIP_ACTION_TOGGLE_INSTANT_FLIGHT && source->GetUInt32Value(UNIT_NPC_FLAGS) & UNIT_NPC_FLAG_FLIGHTMASTER) { ToggleInstantFlight(); - - if (m_isInstantFlightOn) - GetSession()->SendNotification(LANG_INSTANT_FLIGHT_ON); - else - GetSession()->SendNotification(LANG_INSTANT_FLIGHT_OFF); - + Acore::Text::SendNotification(GetSession(), m_isInstantFlightOn ? LANG_INSTANT_FLIGHT_ON : LANG_INSTANT_FLIGHT_OFF); PlayerTalkClass->SendCloseGossip(); return; } diff --git a/src/server/game/Entities/Player/PlayerQuest.cpp b/src/server/game/Entities/Player/PlayerQuest.cpp index 83380d507e413f..fcf92f6c32c0a3 100644 --- a/src/server/game/Entities/Player/PlayerQuest.cpp +++ b/src/server/game/Entities/Player/PlayerQuest.cpp @@ -17,6 +17,7 @@ #include "CreatureAI.h" #include "DisableMgr.h" +#include "GameLocale.h" #include "GameObjectAI.h" #include "GameTime.h" #include "GitRevision.h" @@ -179,8 +180,8 @@ void Player::SendPreparedQuest(ObjectGuid guid) int loc_idx = GetSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) - if (NpcTextLocale const* nl = sObjectMgr->GetNpcTextLocale(textid)) - ObjectMgr::GetLocaleString(nl->Text_0[0], loc_idx, title); + if (NpcTextLocale const* nl = sGameLocale->GetNpcTextLocale(textid)) + GameLocale::GetLocaleString(nl->Text_0[0], loc_idx, title); } else { @@ -188,8 +189,8 @@ void Player::SendPreparedQuest(ObjectGuid guid) int loc_idx = GetSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) - if (NpcTextLocale const* nl = sObjectMgr->GetNpcTextLocale(textid)) - ObjectMgr::GetLocaleString(nl->Text_1[0], loc_idx, title); + if (NpcTextLocale const* nl = sGameLocale->GetNpcTextLocale(textid)) + GameLocale::GetLocaleString(nl->Text_1[0], loc_idx, title); } } } @@ -2385,8 +2386,8 @@ void Player::SendQuestConfirmAccept(const Quest* quest, Player* pReceiver) int loc_idx = pReceiver->GetSession()->GetSessionDbLocaleIndex(); if (loc_idx >= 0) - if (const QuestLocale* pLocale = sObjectMgr->GetQuestLocale(quest->GetQuestId())) - ObjectMgr::GetLocaleString(pLocale->Title, loc_idx, strTitle); + if (const QuestLocale* pLocale = sGameLocale->GetQuestLocale(quest->GetQuestId())) + GameLocale::GetLocaleString(pLocale->Title, loc_idx, strTitle); WorldPacket data(SMSG_QUEST_CONFIRM_ACCEPT, (4 + quest->GetTitle().size() + 8)); data << uint32(quest->GetQuestId()); diff --git a/src/server/game/Entities/Player/PlayerStorage.cpp b/src/server/game/Entities/Player/PlayerStorage.cpp index c6ab12d3896d18..fdf77ed4ad2456 100644 --- a/src/server/game/Entities/Player/PlayerStorage.cpp +++ b/src/server/game/Entities/Player/PlayerStorage.cpp @@ -28,6 +28,7 @@ #include "Channel.h" #include "CharacterDatabaseCleaner.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "Common.h" #include "ConditionMgr.h" #include "Config.h" @@ -65,6 +66,8 @@ #include "SpellAuraEffects.h" #include "SpellAuras.h" #include "SpellMgr.h" +#include "StringConvert.h" +#include "Tokenize.h" #include "Transport.h" #include "UpdateData.h" #include "UpdateFieldFlags.h" @@ -73,8 +76,6 @@ #include "Weather.h" #include "World.h" #include "WorldPacket.h" -#include "Tokenize.h" -#include "StringConvert.h" // TODO: this import is not necessary for compilation and marked as unused by the IDE // however, for some reasons removing it would cause a damn linking issue @@ -6677,9 +6678,9 @@ void Player::PrettyPrintRequirementsQuestList(const std::vectorGetTitle(); - if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(questTemplate->GetQuestId())) + if (QuestLocale const* questLocale = sGameLocale->GetQuestLocale(questTemplate->GetQuestId())) { - ObjectMgr::GetLocaleString(questLocale->Title, loc_idx, questTitle); + GameLocale::GetLocaleString(questLocale->Title, loc_idx, questTitle); } std::stringstream stream; @@ -6693,11 +6694,11 @@ void Player::PrettyPrintRequirementsQuestList(const std::vectornote.empty()) { - ChatHandler(GetSession()).PSendSysMessage(" - %s", stream.str().c_str()); + ChatHandler(GetSession()).PSendSysMessage(" - {}", stream.str()); } else { - ChatHandler(GetSession()).PSendSysMessage(" - %s %s %s", stream.str().c_str(), sObjectMgr->GetAcoreString(LANG_ACCESS_REQUIREMENT_NOTE, loc_idx), missingReq->note.c_str()); + ChatHandler(GetSession()).PSendSysMessage(" - {} {} {}", stream.str(), sGameLocale->GetAcoreString(LANG_ACCESS_REQUIREMENT_NOTE, loc_idx), missingReq->note); } } } @@ -6713,7 +6714,7 @@ void Player::PrettyPrintRequirementsAchievementsList(const std::vectorname[sObjectMgr->GetDBCLocaleIndex()]; + std::string name = achievementEntry->name[sGameLocale->GetDBCLocaleIndex()]; std::stringstream stream; stream << "|cffff7c0a|Hachievement:"; @@ -6726,11 +6727,11 @@ void Player::PrettyPrintRequirementsAchievementsList(const std::vectornote.empty()) { - ChatHandler(GetSession()).PSendSysMessage(" - %s", stream.str().c_str()); + ChatHandler(GetSession()).PSendSysMessage(" - {}", stream.str()); } else { - ChatHandler(GetSession()).PSendSysMessage(" - %s %s %s", stream.str().c_str(), sObjectMgr->GetAcoreString(LANG_ACCESS_REQUIREMENT_NOTE, loc_idx), missingReq->note.c_str()); + ChatHandler(GetSession()).PSendSysMessage(" - {} {} {}", stream.str(), sGameLocale->GetAcoreString(LANG_ACCESS_REQUIREMENT_NOTE, loc_idx), missingReq->note); } } } @@ -6748,9 +6749,9 @@ void Player::PrettyPrintRequirementsItemsList(const std::vectorName1; - if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplate->ItemId)) + if (ItemLocale const* il = sGameLocale->GetItemLocale(itemTemplate->ItemId)) { - ObjectMgr::GetLocaleString(il->Name, loc_idx, name); + GameLocale::GetLocaleString(il->Name, loc_idx, name); } std::stringstream stream; @@ -6764,11 +6765,11 @@ void Player::PrettyPrintRequirementsItemsList(const std::vectornote.empty()) { - ChatHandler(GetSession()).PSendSysMessage(" - %s", stream.str().c_str()); + ChatHandler(GetSession()).PSendSysMessage(" - {}", stream.str()); } else { - ChatHandler(GetSession()).PSendSysMessage(" - %s %s %s", stream.str().c_str(), sObjectMgr->GetAcoreString(LANG_ACCESS_REQUIREMENT_NOTE, loc_idx), missingReq->note.c_str()); + ChatHandler(GetSession()).PSendSysMessage(" - {} {} {}", stream.str(), sGameLocale->GetAcoreString(LANG_ACCESS_REQUIREMENT_NOTE, loc_idx), missingReq->note); } } } @@ -6794,7 +6795,7 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, target_map, this)) { - GetSession()->SendAreaTriggerMessage("%s", GetSession()->GetAcoreString(LANG_INSTANCE_CLOSED)); + Acore::Text::SendAreaTriggerMessage(GetSession(), LANG_INSTANCE_CLOSED); return false; } @@ -6913,7 +6914,7 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map //Blizzlike method of printing out the requirements if (missingLeaderQuests.size() && !missingLeaderQuests[0]->note.empty()) { - ChatHandler(GetSession()).PSendSysMessage("%s", missingLeaderQuests[0]->note.c_str()); + ChatHandler(GetSession()).PSendSysMessage("{}", missingLeaderQuests[0]->note); } else if (mapDiff->hasErrorMessage) { // if (missingAchievement) covered by this case @@ -6921,11 +6922,11 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map } else if (missingPlayerItems.size()) { - GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_LEVEL_MINREQUIRED_AND_ITEM), LevelMin, sObjectMgr->GetItemTemplate(missingPlayerItems[0]->id)->Name1.c_str()); + Acore::Text::SendAreaTriggerMessage(GetSession(), LANG_LEVEL_MINREQUIRED_AND_ITEM, LevelMin, sObjectMgr->GetItemTemplate(missingPlayerItems[0]->id)->Name1); } else if (LevelMin) { - GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_LEVEL_MINREQUIRED), LevelMin); + Acore::Text::SendAreaTriggerMessage(GetSession(), LANG_LEVEL_MINREQUIRED, LevelMin); } else if (ilvlRequirementNotMet) { @@ -6944,7 +6945,7 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map } if (missingLeaderQuests.size()) { - ChatHandler(GetSession()).PSendSysMessage(LANG_ACCESS_REQUIREMENT_LEADER_COMPLETE_QUESTS, leaderName.c_str()); + ChatHandler(GetSession()).PSendSysMessage(LANG_ACCESS_REQUIREMENT_LEADER_COMPLETE_QUESTS, leaderName); PrettyPrintRequirementsQuestList(missingLeaderQuests); errorAlreadyPrinted = true; } @@ -6957,7 +6958,7 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map } if (missingLeaderAchievements.size()) { - ChatHandler(GetSession()).PSendSysMessage(LANG_ACCESS_REQUIREMENT_LEADER_COMPLETE_ACHIEVEMENTS, leaderName.c_str()); + ChatHandler(GetSession()).PSendSysMessage(LANG_ACCESS_REQUIREMENT_LEADER_COMPLETE_ACHIEVEMENTS, leaderName); PrettyPrintRequirementsAchievementsList(missingLeaderAchievements); errorAlreadyPrinted = true; } @@ -6971,7 +6972,7 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map if (missingLeaderItems.size()) { - ChatHandler(GetSession()).PSendSysMessage(LANG_ACCESS_REQUIREMENT_LEADER_OBTAIN_ITEMS, leaderName.c_str()); + ChatHandler(GetSession()).PSendSysMessage(LANG_ACCESS_REQUIREMENT_LEADER_OBTAIN_ITEMS, leaderName); PrettyPrintRequirementsItemsList(missingLeaderItems); errorAlreadyPrinted = true; } @@ -6983,11 +6984,11 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map if (LevelMin) { - GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_LEVEL_MINREQUIRED), LevelMin); + Acore::Text::SendAreaTriggerMessage(GetSession(), LANG_LEVEL_MINREQUIRED, LevelMin); } else if (LevelMax) { - GetSession()->SendAreaTriggerMessage(GetSession()->GetAcoreString(LANG_ACCESS_REQUIREMENT_MAX_LEVEL), LevelMax); + Acore::Text::SendAreaTriggerMessage(GetSession(), LANG_ACCESS_REQUIREMENT_MAX_LEVEL, LevelMax); } else if (mapDiff->hasErrorMessage && !errorAlreadyPrinted) { diff --git a/src/server/game/Entities/Player/PlayerTaxi.cpp b/src/server/game/Entities/Player/PlayerTaxi.cpp index a4bff7aa68208c..41269bad4d2f37 100644 --- a/src/server/game/Entities/Player/PlayerTaxi.cpp +++ b/src/server/game/Entities/Player/PlayerTaxi.cpp @@ -17,8 +17,8 @@ #include "ObjectMgr.h" #include "Player.h" -#include "Tokenize.h" #include "StringConvert.h" +#include "Tokenize.h" PlayerTaxi::PlayerTaxi() : _taxiSegment(0) { diff --git a/src/server/game/Entities/Player/PlayerUpdates.cpp b/src/server/game/Entities/Player/PlayerUpdates.cpp index d147a03c35e46b..7a03324de13be5 100644 --- a/src/server/game/Entities/Player/PlayerUpdates.cpp +++ b/src/server/game/Entities/Player/PlayerUpdates.cpp @@ -20,6 +20,7 @@ #include "Channel.h" #include "ChannelMgr.h" #include "Formulas.h" +#include "GameLocale.h" #include "GameTime.h" #include "GridNotifiers.h" #include "Group.h" @@ -519,7 +520,7 @@ void Player::UpdateLocalChannels(uint32 newZone) char const* currentNameExt; if (channel->flags & CHANNEL_DBC_FLAG_CITY_ONLY) - currentNameExt = sObjectMgr->GetAcoreStringForDBCLocale( + currentNameExt = sGameLocale->GetAcoreStringForDBCLocale( LANG_CHANNEL_CITY); else currentNameExt = current_zone_name.c_str(); diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index e0064bb88ff57b..2606715440da6d 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -15,8 +15,8 @@ * with this program. If not, see . */ -#include "Creature.h" #include "Config.h" +#include "Creature.h" #include "Pet.h" #include "Player.h" #include "ScriptMgr.h" diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 0888aea9e47a3f..0574de3e860ccf 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -34,6 +34,7 @@ #include "DisableMgr.h" #include "DynamicVisibility.h" #include "Formulas.h" +#include "GameLocale.h" #include "GameTime.h" #include "GridNotifiersImpl.h" #include "Group.h" @@ -58,8 +59,10 @@ #include "SpellAuras.h" #include "SpellInfo.h" #include "SpellMgr.h" +#include "StringConvert.h" #include "TargetedMovementGenerator.h" #include "TemporarySummon.h" +#include "Tokenize.h" #include "Totem.h" #include "TotemAI.h" #include "Transport.h" @@ -68,8 +71,6 @@ #include "Vehicle.h" #include "World.h" #include "WorldPacket.h" -#include "Tokenize.h" -#include "StringConvert.h" #include float baseMoveSpeed[MAX_MOVE_TYPE] = @@ -20422,7 +20423,7 @@ void Unit::Whisper(std::string_view text, Language language, Player* target, boo void Unit::Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject const* target) { - if (!sObjectMgr->GetBroadcastText(textId)) + if (!sGameLocale->GetBroadcastText(textId)) { LOG_ERROR("entities.unit", "Unit::Talk: `broadcast_text` (ID: {}) was not found", textId); return; @@ -20456,7 +20457,7 @@ void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/ return; } - BroadcastText const* bct = sObjectMgr->GetBroadcastText(textId); + BroadcastText const* bct = sGameLocale->GetBroadcastText(textId); if (!bct) { LOG_ERROR("entities.unit", "Unit::Whisper: `broadcast_text` was not {} found", textId); diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp index b2d552ba2b36b2..bca2ccdc4d08e1 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 "ChatTextBuilder.h" #include "DisableMgr.h" #include "GameObjectAI.h" #include "GameTime.h" @@ -1228,7 +1229,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()); + Acore::Text::SendWorldText(LANG_EVENTMESSAGE, mGameEvent[event_id].description.c_str()); LOG_DEBUG("gameevent", "GameEvent {} \"{}\" started.", event_id, mGameEvent[event_id].description); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index ea230ac01220fe..d5bcfcb7784bac 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -26,6 +26,7 @@ #include "DatabaseEnv.h" #include "DisableMgr.h" #include "GameEventMgr.h" +#include "GameLocale.h" #include "GameTime.h" #include "GossipDef.h" #include "GroupMgr.h" @@ -42,14 +43,14 @@ #include "SpellAuras.h" #include "SpellMgr.h" #include "SpellScript.h" +#include "StringConvert.h" +#include "Tokenize.h" #include "Transport.h" #include "Unit.h" #include "UpdateMask.h" #include "Util.h" #include "Vehicle.h" #include "World.h" -#include "StringConvert.h" -#include "Tokenize.h" ScriptMapMap sSpellScripts; ScriptMapMap sEventScripts; @@ -297,8 +298,7 @@ ObjectMgr::ObjectMgr(): _mailId(1), _hiPetNumber(1), _creatureSpawnId(1), - _gameObjectSpawnId(1), - DBCLocaleIndex(LOCALE_enUS) + _gameObjectSpawnId(1) { for (uint8 i = 0; i < MAX_CLASSES; ++i) { @@ -374,106 +374,6 @@ ObjectMgr* ObjectMgr::instance() return &instance; } -void ObjectMgr::AddLocaleString(std::string&& s, LocaleConstant locale, std::vector& data) -{ - if (!s.empty()) - { - if (data.size() <= size_t(locale)) - data.resize(locale + 1); - - data[locale] = std::move(s); - } -} - -void ObjectMgr::LoadCreatureLocales() -{ - uint32 oldMSTime = getMSTime(); - - _creatureLocaleStore.clear(); // need for reload case - - // 0 1 2 3 - QueryResult result = WorldDatabase.Query("SELECT entry, locale, Name, Title FROM creature_template_locale"); - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 ID = fields[0].Get(); - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - CreatureLocale& data = _creatureLocaleStore[ID]; - AddLocaleString(fields[2].Get(), locale, data.Name); - AddLocaleString(fields[3].Get(), locale, data.Title); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Creature Locale strings in {} ms", (unsigned long)_creatureLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - -void ObjectMgr::LoadGossipMenuItemsLocales() -{ - uint32 oldMSTime = getMSTime(); - - _gossipMenuItemsLocaleStore.clear(); // need for reload case - - // 0 1 2 3 4 - QueryResult result = WorldDatabase.Query("SELECT MenuID, OptionID, Locale, OptionText, BoxText FROM gossip_menu_option_locale"); - - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint16 MenuID = fields[0].Get(); - uint16 OptionID = fields[1].Get(); - - LocaleConstant locale = GetLocaleByName(fields[2].Get()); - if (locale == LOCALE_enUS) - continue; - - GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[MAKE_PAIR32(MenuID, OptionID)]; - AddLocaleString(fields[3].Get(), locale, data.OptionText); - AddLocaleString(fields[4].Get(), locale, data.BoxText); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Gossip Menu Option Locale strings in {} ms", (uint32)_gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - -void ObjectMgr::LoadPointOfInterestLocales() -{ - uint32 oldMSTime = getMSTime(); - - _pointOfInterestLocaleStore.clear(); // need for reload case - - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM points_of_interest_locale"); - - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 ID = fields[0].Get(); - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - PointOfInterestLocale& data = _pointOfInterestLocaleStore[ID]; - AddLocaleString(fields[2].Get(), locale, data.Name); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Points Of Interest Locale strings in {} ms", (uint32)_pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - void ObjectMgr::LoadCreatureTemplates() { uint32 oldMSTime = getMSTime(); @@ -2549,34 +2449,6 @@ void ObjectMgr::RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectDat } } -void ObjectMgr::LoadItemLocales() -{ - uint32 oldMSTime = getMSTime(); - - _itemLocaleStore.clear(); // need for reload case - - QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale"); - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 ID = fields[0].Get(); - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - ItemLocale& data = _itemLocaleStore[ID]; - AddLocaleString(fields[2].Get(), locale, data.Name); - AddLocaleString(fields[3].Get(), locale, data.Description); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Item Locale strings in {} ms", (uint32)_itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - void ObjectMgr::LoadItemTemplates() { uint32 oldMSTime = getMSTime(); @@ -3169,34 +3041,6 @@ ItemTemplate const* ObjectMgr::GetItemTemplate(uint32 entry) return entry < _itemTemplateStoreFast.size() ? _itemTemplateStoreFast[entry] : nullptr; } -void ObjectMgr::LoadItemSetNameLocales() -{ - uint32 oldMSTime = getMSTime(); - - _itemSetNameLocaleStore.clear(); // need for reload case - - QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale"); - - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 ID = fields[0].Get(); - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - ItemSetNameLocale& data = _itemSetNameLocaleStore[ID]; - AddLocaleString(fields[2].Get(), locale, data.Name); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Item Set Name Locale strings in {} ms", uint32(_itemSetNameLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); -} - void ObjectMgr::LoadItemSetNames() { uint32 oldMSTime = getMSTime(); @@ -5017,42 +4861,6 @@ void ObjectMgr::LoadQuests() LOG_INFO("server.loading", " "); } -void ObjectMgr::LoadQuestLocales() -{ - uint32 oldMSTime = getMSTime(); - - _questLocaleStore.clear(); // need for reload case - - // 0 1 2 3 4 5 6 7 8 9 10 - QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale"); - - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 ID = fields[0].Get(); - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - QuestLocale& data = _questLocaleStore[ID]; - AddLocaleString(fields[2].Get(), locale, data.Title); - AddLocaleString(fields[3].Get(), locale, data.Details); - AddLocaleString(fields[4].Get(), locale, data.Objectives); - AddLocaleString(fields[5].Get(), locale, data.AreaDescription); - AddLocaleString(fields[6].Get(), locale, data.CompletedText); - - for (uint8 i = 0; i < 4; ++i) - AddLocaleString(fields[i + 7].Get(), locale, data.ObjectiveText[i]); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Quest Locale strings in {} ms", (uint32)_questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - void ObjectMgr::LoadScripts(ScriptsType type) { uint32 oldMSTime = getMSTime(); @@ -5114,7 +4922,7 @@ void ObjectMgr::LoadScripts(ScriptsType type) tableName, tmp.Talk.ChatType, tmp.id); continue; } - if (!GetBroadcastText(uint32(tmp.Talk.TextID))) + if (!sGameLocale->GetBroadcastText(uint32(tmp.Talk.TextID))) { LOG_ERROR("sql.sql", "Table `{}` has invalid talk text id (dataint = {}) in SCRIPT_COMMAND_TALK for script id {}", tableName, tmp.Talk.TextID, tmp.id); @@ -5646,35 +5454,6 @@ PageText const* ObjectMgr::GetPageText(uint32 pageEntry) return nullptr; } -void ObjectMgr::LoadPageTextLocales() -{ - uint32 oldMSTime = getMSTime(); - - _pageTextLocaleStore.clear(); // need for reload case - - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale"); - - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 ID = fields[0].Get(); - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - PageTextLocale& data = _pageTextLocaleStore[ID]; - AddLocaleString(fields[2].Get(), locale, data.Text); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Page Text Locale strings in {} ms", (uint32)_pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - void ObjectMgr::LoadInstanceTemplate() { uint32 oldMSTime = getMSTime(); @@ -5824,15 +5603,15 @@ void ObjectMgr::LoadGossipText() uint32 oldMSTime = getMSTime(); QueryResult result = WorldDatabase.Query("SELECT ID, " - "text0_0, text0_1, BroadcastTextID0, lang0, Probability0, em0_0, em0_1, em0_2, em0_3, em0_4, em0_5, " - "text1_0, text1_1, BroadcastTextID1, lang1, Probability1, em1_0, em1_1, em1_2, em1_3, em1_4, em1_5, " - "text2_0, text2_1, BroadcastTextID2, lang2, Probability2, em2_0, em2_1, em2_2, em2_3, em2_4, em2_5, " - "text3_0, text3_1, BroadcastTextID3, lang3, Probability3, em3_0, em3_1, em3_2, em3_3, em3_4, em3_5, " - "text4_0, text4_1, BroadcastTextID4, lang4, Probability4, em4_0, em4_1, em4_2, em4_3, em4_4, em4_5, " - "text5_0, text5_1, BroadcastTextID5, lang5, Probability5, em5_0, em5_1, em5_2, em5_3, em5_4, em5_5, " - "text6_0, text6_1, BroadcastTextID6, lang6, Probability6, em6_0, em6_1, em6_2, em6_3, em6_4, em6_5, " - "text7_0, text7_1, BroadcastTextID7, lang7, Probability7, em7_0, em7_1, em7_2, em7_3, em7_4, em7_5 " - "FROM npc_text"); + "text0_0, text0_1, BroadcastTextID0, lang0, Probability0, EmoteDelay0_0, Emote0_0, EmoteDelay0_1, Emote0_1, EmoteDelay0_2, Emote0_2, " + "text1_0, text1_1, BroadcastTextID1, lang1, Probability1, EmoteDelay1_0, Emote1_0, EmoteDelay1_1, Emote1_1, EmoteDelay1_2, Emote1_2, " + "text2_0, text2_1, BroadcastTextID2, lang2, Probability2, EmoteDelay2_0, Emote2_0, EmoteDelay2_1, Emote2_1, EmoteDelay2_2, Emote2_2, " + "text3_0, text3_1, BroadcastTextID3, lang3, Probability3, EmoteDelay3_0, Emote3_0, EmoteDelay3_1, Emote3_1, EmoteDelay3_2, Emote3_2, " + "text4_0, text4_1, BroadcastTextID4, lang4, Probability4, EmoteDelay4_0, Emote4_0, EmoteDelay4_1, Emote4_1, EmoteDelay4_2, Emote4_2, " + "text5_0, text5_1, BroadcastTextID5, lang5, Probability5, EmoteDelay5_0, Emote5_0, EmoteDelay5_1, Emote5_1, EmoteDelay5_2, Emote5_2, " + "text6_0, text6_1, BroadcastTextID6, lang6, Probability6, EmoteDelay6_0, Emote6_0, EmoteDelay6_1, Emote6_1, EmoteDelay6_2, Emote6_2, " + "text7_0, text7_1, BroadcastTextID7, lang7, Probability7, EmoteDelay7_0, Emote7_0, EmoteDelay7_1, Emote7_1, EmoteDelay7_2, Emote7_2 " + "FROM npc_text"); if (!result) { @@ -5863,27 +5642,34 @@ void ObjectMgr::LoadGossipText() for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) { - gText.Options[i].Text_0 = fields[cic++].Get(); - gText.Options[i].Text_1 = fields[cic++].Get(); - gText.Options[i].BroadcastTextID = fields[cic++].Get(); - gText.Options[i].Language = fields[cic++].Get(); - gText.Options[i].Probability = fields[cic++].Get(); + GossipTextOption& gOption = gText.Options[i]; + gOption.Text_0 = fields[cic++].Get(); + gOption.Text_1 = fields[cic++].Get(); + gOption.BroadcastTextID = fields[cic++].Get(); + gOption.Language = fields[cic++].Get(); + gOption.Probability = fields[cic++].Get(); for (uint8 j = 0; j < MAX_GOSSIP_TEXT_EMOTES; ++j) { - gText.Options[i].Emotes[j]._Delay = fields[cic++].Get(); - gText.Options[i].Emotes[j]._Emote = fields[cic++].Get(); + gOption.Emotes[j]._Delay = fields[cic++].Get(); + gOption.Emotes[j]._Emote = fields[cic++].Get(); } - } - for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; i++) - { - if (gText.Options[i].BroadcastTextID) + // check broadcast_text correctness + if (gOption.BroadcastTextID) { - if (!GetBroadcastText(gText.Options[i].BroadcastTextID)) + if (BroadcastText const* bcText = sGameLocale->GetBroadcastText(gOption.BroadcastTextID)) + { + if (bcText->Text[DEFAULT_LOCALE] != gOption.Text_0) + LOG_ERROR("sql.sql", "Row {} in table `npc_text` has mismatch between text{}_0 and the corresponding Text in `broadcast_text` row {}", id, i, gOption.BroadcastTextID); + + if (bcText->Text1[DEFAULT_LOCALE] != gOption.Text_1) + LOG_ERROR("sql.sql", "Row {} in table `npc_text` has mismatch between text{}_1 and the corresponding Text1 in `broadcast_text` row {}", id, i, gOption.BroadcastTextID); + } + else { - LOG_ERROR("sql.sql", "GossipText (Id: {}) in table `npc_text` has non-existing or incompatible BroadcastTextID{} {}.", id, i, gText.Options[i].BroadcastTextID); - gText.Options[i].BroadcastTextID = 0; + LOG_ERROR("sql.sql", "GossipText (Id: {}) in table `npc_text` has non-existing or incompatible BroadcastTextID{} {}.", id, i, gOption.BroadcastTextID); + gOption.BroadcastTextID = 0; } } } @@ -5895,41 +5681,6 @@ void ObjectMgr::LoadGossipText() LOG_INFO("server.loading", " "); } -void ObjectMgr::LoadNpcTextLocales() -{ - uint32 oldMSTime = getMSTime(); - - _npcTextLocaleStore.clear(); // need for reload case - - QueryResult result = WorldDatabase.Query("SELECT ID, Locale, " - // 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - "Text0_0, Text0_1, Text1_0, Text1_1, Text2_0, Text2_1, Text3_0, Text3_1, Text4_0, Text4_1, Text5_0, Text5_1, Text6_0, Text6_1, Text7_0, Text7_1 " - "FROM npc_text_locale"); - - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 ID = fields[0].Get(); - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - NpcTextLocale& data = _npcTextLocaleStore[ID]; - for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) - { - AddLocaleString(fields[2 + i * 2].Get(), locale, data.Text_0[i]); - AddLocaleString(fields[3 + i * 2].Get(), locale, data.Text_1[i]); - } - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Npc Text Locale strings in {} ms", (uint32)_npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp) { uint32 oldMSTime = getMSTime(); @@ -6112,64 +5863,6 @@ void ObjectMgr::LoadQuestAreaTriggers() LOG_INFO("server.loading", " "); } -void ObjectMgr::LoadQuestOfferRewardLocale() -{ - uint32 oldMSTime = getMSTime(); - - _questOfferRewardLocaleStore.clear(); // need for reload case - - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale"); - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 id = fields[0].Get(); - std::string localeName = fields[1].Get(); - - LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) - continue; - - QuestOfferRewardLocale& data = _questOfferRewardLocaleStore[id]; - AddLocaleString(fields[2].Get(), locale, data.RewardText); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward locale strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - -void ObjectMgr::LoadQuestRequestItemsLocale() -{ - uint32 oldMSTime = getMSTime(); - - _questRequestItemsLocaleStore.clear(); // need for reload case - - // 0 1 2 - QueryResult result = WorldDatabase.Query("SELECT Id, locale, CompletionText FROM quest_request_items_locale"); - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 id = fields[0].Get(); - std::string localeName = fields[1].Get(); - - LocaleConstant locale = GetLocaleByName(localeName); - if (locale == LOCALE_enUS) - continue; - - QuestRequestItemsLocale& data = _questRequestItemsLocaleStore[id]; - AddLocaleString(fields[2].Get(), locale, data.CompletionText); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Quest Request Items locale strings in {} ms", _questRequestItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - void ObjectMgr::LoadTavernAreaTriggers() { uint32 oldMSTime = getMSTime(); @@ -6780,35 +6473,6 @@ uint32 ObjectMgr::GenerateGameObjectSpawnId() return _gameObjectSpawnId++; } -void ObjectMgr::LoadGameObjectLocales() -{ - uint32 oldMSTime = getMSTime(); - - _gameObjectLocaleStore.clear(); // need for reload case - - // 0 1 2 3 - QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale"); - if (!result) - return; - - do - { - Field* fields = result->Fetch(); - - uint32 ID = fields[0].Get(); - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - GameObjectLocale& data = _gameObjectLocaleStore[ID]; - AddLocaleString(fields[2].Get(), locale, data.Name); - AddLocaleString(fields[3].Get(), locale, data.CastBarCaption); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Gameobject Locale strings in {} ms", (uint32)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - inline void CheckGOLockId(GameObjectTemplate const* goInfo, uint32 dataN, uint32 N) { if (sLockStore.LookupEntry(dataN)) @@ -8111,54 +7775,6 @@ void ObjectMgr::LoadGameObjectForQuests() LOG_INFO("server.loading", " "); } -bool ObjectMgr::LoadAcoreStrings() -{ - uint32 oldMSTime = getMSTime(); - - _acoreStringStore.clear(); // for reload case - QueryResult result = WorldDatabase.Query("SELECT entry, content_default, locale_koKR, locale_frFR, locale_deDE, locale_zhCN, locale_zhTW, locale_esES, locale_esMX, locale_ruRU FROM acore_string"); - if (!result) - { - LOG_INFO("server.loading", ">> Loaded 0 acore strings. DB table `acore_strings` is empty."); - LOG_INFO("server.loading", " "); - return false; - } - - do - { - Field* fields = result->Fetch(); - - uint32 entry = fields[0].Get(); - - AcoreString& data = _acoreStringStore[entry]; - - data.Content.resize(DEFAULT_LOCALE + 1); - - for (uint8 i = 0; i < TOTAL_LOCALES; ++i) - AddLocaleString(fields[i + 1].Get(), LocaleConstant(i), data.Content); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} acore strings in {} ms", (uint32)_acoreStringStore.size(), GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); - - return true; -} - -char const* ObjectMgr::GetAcoreString(uint32 entry, LocaleConstant locale) const -{ - if (AcoreString const* ts = GetAcoreString(entry)) - { - if (ts->Content.size() > size_t(locale) && !ts->Content[locale].empty()) - return ts->Content[locale].c_str(); - - return ts->Content[DEFAULT_LOCALE].c_str(); - } - - LOG_ERROR("sql.sql", "Acore string entry {} not found in DB.", entry); - - return ""; -} - void ObjectMgr::LoadFishingBaseSkillLevel() { uint32 oldMSTime = getMSTime(); @@ -8796,7 +8412,7 @@ void ObjectMgr::LoadGossipMenuItems() gMenuItem.OptionIcon = GOSSIP_ICON_CHAT; } - if (gMenuItem.OptionBroadcastTextID && !GetBroadcastText(gMenuItem.OptionBroadcastTextID)) + if (gMenuItem.OptionBroadcastTextID && !sGameLocale->GetBroadcastText(gMenuItem.OptionBroadcastTextID)) { LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible OptionBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.OptionBroadcastTextID); gMenuItem.OptionBroadcastTextID = 0; @@ -8811,16 +8427,16 @@ void ObjectMgr::LoadGossipMenuItems() gMenuItem.ActionPoiID = 0; } - if (gMenuItem.BoxBroadcastTextID && !GetBroadcastText(gMenuItem.BoxBroadcastTextID)) + if (gMenuItem.BoxBroadcastTextID && !sGameLocale->GetBroadcastText(gMenuItem.BoxBroadcastTextID)) { LOG_ERROR("sql.sql", "Table `gossip_menu_option` for menu {}, id {} has non-existing or incompatible BoxBroadcastTextID {}, ignoring.", gMenuItem.MenuID, gMenuItem.OptionID, gMenuItem.BoxBroadcastTextID); gMenuItem.BoxBroadcastTextID = 0; } - _gossipMenuItemsStore.insert(GossipMenuItemsContainer::value_type(gMenuItem.MenuID, gMenuItem)); + _gossipMenuItemsStore.emplace(gMenuItem.MenuID, gMenuItem); } while (result->NextRow()); - LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option entries in {} ms", uint32(_gossipMenuItemsStore.size()), GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", ">> Loaded {} gossip_menu_option entries in {} ms", _gossipMenuItemsStore.size(), GetMSTimeDiffToNow(oldMSTime)); LOG_INFO("server.loading", " "); } @@ -8915,7 +8531,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 item_id, int32 max if (maxcount > 0 && incrtime == 0) { if (player) - ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 (%u) but IncrTime == 0", maxcount); + ChatHandler(player->GetSession()).PSendSysMessage("MaxCount != 0 ({}) but IncrTime == 0", maxcount); else LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` has `maxcount` ({}) for item {} of vendor (Entry: {}) but `incrtime`=0, ignore", maxcount, item_id, vendor_entry); return false; @@ -9021,130 +8637,6 @@ uint32 ObjectMgr::GetScriptId(std::string const& name) return uint32(itr - _scriptNamesStore.begin()); } -void ObjectMgr::LoadBroadcastTexts() -{ - uint32 oldMSTime = getMSTime(); - - _broadcastTextStore.clear(); // for reload case - - // 0 1 2 3 4 5 6 7 8 9 10 11 12 - QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, MaleText, FemaleText, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text"); - if (!result) - { - LOG_INFO("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty."); - LOG_INFO("server.loading", " "); - return; - } - - _broadcastTextStore.rehash(result->GetRowCount()); - - do - { - Field* fields = result->Fetch(); - - BroadcastText bct; - - bct.Id = fields[0].Get(); - bct.LanguageID = fields[1].Get(); - bct.MaleText[DEFAULT_LOCALE] = fields[2].Get(); - bct.FemaleText[DEFAULT_LOCALE] = fields[3].Get(); - bct.EmoteId1 = fields[4].Get(); - bct.EmoteId2 = fields[5].Get(); - bct.EmoteId3 = fields[6].Get(); - bct.EmoteDelay1 = fields[7].Get(); - bct.EmoteDelay2 = fields[8].Get(); - bct.EmoteDelay3 = fields[9].Get(); - bct.SoundEntriesId = fields[10].Get(); - bct.EmotesID = fields[11].Get(); - bct.Flags = fields[12].Get(); - - if (bct.SoundEntriesId) - { - if (!sSoundEntriesStore.LookupEntry(bct.SoundEntriesId)) - { - LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has SoundEntriesId {} but sound does not exist.", bct.Id, bct.SoundEntriesId); - bct.SoundEntriesId = 0; - } - } - - if (!GetLanguageDescByID(bct.LanguageID)) - { - LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` using Language {} but Language does not exist.", bct.Id, bct.LanguageID); - bct.LanguageID = LANG_UNIVERSAL; - } - - if (bct.EmoteId1) - { - if (!sEmotesStore.LookupEntry(bct.EmoteId1)) - { - LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId1 {} but emote does not exist.", bct.Id, bct.EmoteId1); - bct.EmoteId1 = 0; - } - } - - if (bct.EmoteId2) - { - if (!sEmotesStore.LookupEntry(bct.EmoteId2)) - { - LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId2 {} but emote does not exist.", bct.Id, bct.EmoteId2); - bct.EmoteId2 = 0; - } - } - - if (bct.EmoteId3) - { - if (!sEmotesStore.LookupEntry(bct.EmoteId3)) - { - LOG_DEBUG("misc", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId3 {} but emote does not exist.", bct.Id, bct.EmoteId3); - bct.EmoteId3 = 0; - } - } - - _broadcastTextStore[bct.Id] = bct; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Broadcast texts in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime)); -} - -void ObjectMgr::LoadBroadcastTextLocales() -{ - uint32 oldMSTime = getMSTime(); - - // 0 1 2 3 - QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale"); - - if (!result) - { - LOG_INFO("server.loading", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty."); - LOG_INFO("server.loading", " "); - return; - } - - do - { - Field* fields = result->Fetch(); - - uint32 id = fields[0].Get(); - - BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id); - if (bct == _broadcastTextStore.end()) - { - LOG_ERROR("sql.sql", "BroadcastText (Id: {}) found in table `broadcast_text_locale` but does not exist in `broadcast_text`. Skipped!", id); - continue; - } - - LocaleConstant locale = GetLocaleByName(fields[1].Get()); - if (locale == LOCALE_enUS) - continue; - - AddLocaleString(fields[2].Get(), locale, bct->second.MaleText); - AddLocaleString(fields[3].Get(), locale, bct->second.FemaleText); - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} Broadcast Text Locales in {} ms", uint32(_broadcastTextStore.size()), GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); -} - CreatureBaseStats const* ObjectMgr::GetCreatureBaseStats(uint8 level, uint8 unitClass) { CreatureBaseStatsContainer::const_iterator it = _creatureBaseStatsStore.find(MAKE_PAIR16(level, unitClass)); diff --git a/src/server/game/Globals/ObjectMgr.h b/src/server/game/Globals/ObjectMgr.h index 4a316ee69d944a..58c3c6c553f447 100644 --- a/src/server/game/Globals/ObjectMgr.h +++ b/src/server/game/Globals/ObjectMgr.h @@ -430,48 +430,6 @@ struct AreaTrigger float orientation; }; -struct BroadcastText -{ - BroadcastText() - { - MaleText.resize(DEFAULT_LOCALE + 1); - FemaleText.resize(DEFAULT_LOCALE + 1); - } - - uint32 Id{0}; - uint32 LanguageID{0}; - std::vector MaleText; - std::vector FemaleText; - uint32 EmoteId1{0}; - uint32 EmoteId2{0}; - uint32 EmoteId3{0}; - uint32 EmoteDelay1{0}; - uint32 EmoteDelay2{0}; - uint32 EmoteDelay3{0}; - uint32 SoundEntriesId{0}; - uint32 EmotesID{0}; - uint32 Flags{0}; - // uint32 VerifiedBuild; - - [[nodiscard]] std::string const& GetText(LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE, bool forceGender = false) const - { - if (gender == GENDER_FEMALE && (forceGender || !FemaleText[DEFAULT_LOCALE].empty())) - { - if (FemaleText.size() > size_t(locale) && !FemaleText[locale].empty()) - return FemaleText[locale]; - return FemaleText[DEFAULT_LOCALE]; - } - // else if (gender == GENDER_MALE) - { - if (MaleText.size() > size_t(locale) && !MaleText[locale].empty()) - return MaleText[locale]; - return MaleText[DEFAULT_LOCALE]; - } - } -}; - -typedef std::unordered_map BroadcastTextContainer; - typedef std::set CellGuidSet; struct CellObjectGuids @@ -483,36 +441,13 @@ struct CellObjectGuids typedef std::unordered_map CellObjectGuidsMap; typedef std::unordered_map MapObjectGuids; -// Acore string ranges -#define MIN_ACORE_STRING_ID 1 // 'acore_string' -#define MAX_ACORE_STRING_ID 2000000000 -#define MIN_CREATURE_AI_TEXT_STRING_ID (-1) // 'creature_ai_texts' -#define MAX_CREATURE_AI_TEXT_STRING_ID (-1000000) - // Acore Trainer Reference start range -#define ACORE_TRAINER_START_REF 200000 - -struct AcoreString -{ - std::vector Content; -}; +#define ACORE_TRAINER_START_REF 200000 typedef std::map LinkedRespawnContainer; typedef std::unordered_map CreatureDataContainer; typedef std::unordered_map GameObjectDataContainer; typedef std::map > TempSummonDataContainer; -typedef std::unordered_map CreatureLocaleContainer; -typedef std::unordered_map GameObjectLocaleContainer; -typedef std::unordered_map ItemLocaleContainer; -typedef std::unordered_map ItemSetNameLocaleContainer; -typedef std::unordered_map QuestLocaleContainer; -typedef std::unordered_map QuestOfferRewardLocaleContainer; -typedef std::unordered_map QuestRequestItemsLocaleContainer; -typedef std::unordered_map NpcTextLocaleContainer; -typedef std::unordered_map PageTextLocaleContainer; -typedef std::unordered_map AcoreStringContainer; -typedef std::unordered_map GossipMenuItemsLocaleContainer; -typedef std::unordered_map PointOfInterestLocaleContainer; typedef std::multimap QuestRelations; typedef std::pair QuestRelationBounds; @@ -700,6 +635,12 @@ class ObjectMgr { friend class PlayerDumpReader; + ObjectMgr(ObjectMgr const&) = delete; + ObjectMgr(ObjectMgr&&) = delete; + + ObjectMgr& operator= (ObjectMgr const&) = delete; + ObjectMgr& operator= (ObjectMgr&&) = delete; + private: ObjectMgr(); ~ObjectMgr(); @@ -979,11 +920,7 @@ class ObjectMgr void ValidateSpellScripts(); void InitializeSpellInfoPrecomputedData(); - bool LoadAcoreStrings(); - void LoadBroadcastTexts(); - void LoadBroadcastTextLocales(); void LoadCreatureClassLevelStats(); - void LoadCreatureLocales(); void LoadCreatureTemplates(); void LoadCreatureTemplate(Field* fields); void LoadCreatureTemplateAddons(); @@ -1002,19 +939,9 @@ class ObjectMgr void LoadCreatureModelInfo(); void LoadEquipmentTemplates(); void LoadCreatureMovementOverrides(); - void LoadGameObjectLocales(); void LoadGameobjects(); void LoadItemTemplates(); - void LoadItemLocales(); void LoadItemSetNames(); - void LoadItemSetNameLocales(); - void LoadQuestLocales(); - void LoadNpcTextLocales(); - void LoadQuestOfferRewardLocale(); - void LoadQuestRequestItemsLocale(); - void LoadPageTextLocales(); - void LoadGossipMenuItemsLocales(); - void LoadPointOfInterestLocales(); void LoadInstanceTemplate(); void LoadInstanceEncounters(); void LoadMailLevelRewards(); @@ -1146,13 +1073,6 @@ class ObjectMgr return nullptr; } - [[nodiscard]] BroadcastText const* GetBroadcastText(uint32 id) const - { - BroadcastTextContainer::const_iterator itr = _broadcastTextStore.find(id); - if (itr != _broadcastTextStore.end()) - return &itr->second; - return nullptr; - } [[nodiscard]] CreatureDataContainer const& GetAllCreatureData() const { return _creatureDataStore; } [[nodiscard]] CreatureData const* GetCreatureData(ObjectGuid::LowType spawnId) const { @@ -1177,88 +1097,10 @@ class ObjectMgr if (itr == _gameObjectDataStore.end()) return nullptr; return &itr->second; } - [[nodiscard]] CreatureLocale const* GetCreatureLocale(uint32 entry) const - { - CreatureLocaleContainer::const_iterator itr = _creatureLocaleStore.find(entry); - if (itr == _creatureLocaleStore.end()) return nullptr; - return &itr->second; - } - [[nodiscard]] GameObjectLocale const* GetGameObjectLocale(uint32 entry) const - { - GameObjectLocaleContainer::const_iterator itr = _gameObjectLocaleStore.find(entry); - if (itr == _gameObjectLocaleStore.end()) return nullptr; - return &itr->second; - } - [[nodiscard]] ItemLocale const* GetItemLocale(uint32 entry) const - { - ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry); - if (itr == _itemLocaleStore.end()) return nullptr; - return &itr->second; - } - [[nodiscard]] ItemSetNameLocale const* GetItemSetNameLocale(uint32 entry) const - { - ItemSetNameLocaleContainer::const_iterator itr = _itemSetNameLocaleStore.find(entry); - if (itr == _itemSetNameLocaleStore.end())return nullptr; - return &itr->second; - } - [[nodiscard]] PageTextLocale const* GetPageTextLocale(uint32 entry) const - { - PageTextLocaleContainer::const_iterator itr = _pageTextLocaleStore.find(entry); - if (itr == _pageTextLocaleStore.end()) return nullptr; - return &itr->second; - } - [[nodiscard]] QuestLocale const* GetQuestLocale(uint32 entry) const - { - QuestLocaleContainer::const_iterator itr = _questLocaleStore.find(entry); - if (itr == _questLocaleStore.end()) return nullptr; - return &itr->second; - } - [[nodiscard]] GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const - { - GossipMenuItemsLocaleContainer::const_iterator itr = _gossipMenuItemsLocaleStore.find(entry); - if (itr == _gossipMenuItemsLocaleStore.end()) return nullptr; - return &itr->second; - } - [[nodiscard]] PointOfInterestLocale const* GetPointOfInterestLocale(uint32 poi_id) const - { - PointOfInterestLocaleContainer::const_iterator itr = _pointOfInterestLocaleStore.find(poi_id); - if (itr == _pointOfInterestLocaleStore.end()) return nullptr; - return &itr->second; - } - [[nodiscard]] QuestOfferRewardLocale const* GetQuestOfferRewardLocale(uint32 entry) const - { - auto itr = _questOfferRewardLocaleStore.find(entry); - if (itr == _questOfferRewardLocaleStore.end()) return nullptr; - return &itr->second; - } - [[nodiscard]] QuestRequestItemsLocale const* GetQuestRequestItemsLocale(uint32 entry) const - { - auto itr = _questRequestItemsLocaleStore.find(entry); - if (itr == _questRequestItemsLocaleStore.end()) return nullptr; - return &itr->second; - } - [[nodiscard]] NpcTextLocale const* GetNpcTextLocale(uint32 entry) const - { - NpcTextLocaleContainer::const_iterator itr = _npcTextLocaleStore.find(entry); - if (itr == _npcTextLocaleStore.end()) return nullptr; - return &itr->second; - } + GameObjectData& NewGOData(ObjectGuid::LowType guid) { return _gameObjectDataStore[guid]; } void DeleteGOData(ObjectGuid::LowType guid); - [[nodiscard]] AcoreString const* GetAcoreString(uint32 entry) const - { - AcoreStringContainer::const_iterator itr = _acoreStringStore.find(entry); - if (itr == _acoreStringStore.end()) - return nullptr; - - return &itr->second; - } - [[nodiscard]] char const* GetAcoreString(uint32 entry, LocaleConstant locale) const; - [[nodiscard]] char const* GetAcoreStringForDBCLocale(uint32 entry) const { return GetAcoreString(entry, DBCLocaleIndex); } - [[nodiscard]] LocaleConstant GetDBCLocaleIndex() const { return DBCLocaleIndex; } - void SetDBCLocaleIndex(LocaleConstant locale) { DBCLocaleIndex = locale; } - // grid objects void AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* data); void RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data); @@ -1342,20 +1184,6 @@ class ObjectMgr return _gossipMenuItemsStore.equal_range(uiMenuId); } - static void AddLocaleString(std::string&& s, LocaleConstant locale, std::vector& data); - static std::string_view GetLocaleString(std::vector const& data, size_t locale) - { - if (locale < data.size()) - return data[locale]; - else - return {}; - } - static inline void GetLocaleString(const std::vector& data, int loc_idx, std::string& value) - { - if (data.size() > size_t(loc_idx) && !data[loc_idx].empty()) - value = data[loc_idx]; - } - CharacterConversionMap FactionChangeAchievements; CharacterConversionMap FactionChangeItems; CharacterConversionMap FactionChangeQuests; @@ -1445,8 +1273,6 @@ class ObjectMgr VehicleAccessoryContainer _vehicleTemplateAccessoryStore; VehicleAccessoryContainer _vehicleAccessoryStore; - LocaleConstant DBCLocaleIndex; - PageTextContainer _pageTextStore; InstanceTemplateContainer _instanceTemplateStore; @@ -1500,27 +1326,14 @@ class ObjectMgr CreatureQuestItemMap _creatureQuestItemStore; EquipmentInfoContainer _equipmentInfoStore; LinkedRespawnContainer _linkedRespawnStore; - CreatureLocaleContainer _creatureLocaleStore; GameObjectDataContainer _gameObjectDataStore; - GameObjectLocaleContainer _gameObjectLocaleStore; GameObjectTemplateContainer _gameObjectTemplateStore; GameObjectTemplateAddonContainer _gameObjectTemplateAddonStore; /// Stores temp summon data grouped by summoner's entry, summoner's type and group id TempSummonDataContainer _tempSummonDataStore; - BroadcastTextContainer _broadcastTextStore; ItemTemplateContainer _itemTemplateStore; std::vector _itemTemplateStoreFast; // pussywizard - ItemLocaleContainer _itemLocaleStore; - ItemSetNameLocaleContainer _itemSetNameLocaleStore; - QuestLocaleContainer _questLocaleStore; - QuestOfferRewardLocaleContainer _questOfferRewardLocaleStore; - QuestRequestItemsLocaleContainer _questRequestItemsLocaleStore; - NpcTextLocaleContainer _npcTextLocaleStore; - PageTextLocaleContainer _pageTextLocaleStore; - AcoreStringContainer _acoreStringStore; - GossipMenuItemsLocaleContainer _gossipMenuItemsLocaleStore; - PointOfInterestLocaleContainer _pointOfInterestLocaleStore; CacheVendorItemContainer _cacheVendorItemStore; CacheTrainerSpellContainer _cacheTrainerSpellStore; diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 39a15660648b66..be411de152cd08 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -23,6 +23,7 @@ #include "Chat.h" #include "Config.h" #include "DatabaseEnv.h" +#include "GameLocale.h" #include "GameTime.h" #include "GuildMgr.h" #include "GuildPackets.h" @@ -2387,11 +2388,11 @@ void Guild::_CreateDefaultGuildRanks(LocaleConstant loc) stmt->SetData(0, m_id); CharacterDatabase.Execute(stmt); - _CreateRank(sObjectMgr->GetAcoreString(LANG_GUILD_MASTER, loc), GR_RIGHT_ALL); - _CreateRank(sObjectMgr->GetAcoreString(LANG_GUILD_OFFICER, loc), GR_RIGHT_ALL); - _CreateRank(sObjectMgr->GetAcoreString(LANG_GUILD_VETERAN, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); - _CreateRank(sObjectMgr->GetAcoreString(LANG_GUILD_MEMBER, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); - _CreateRank(sObjectMgr->GetAcoreString(LANG_GUILD_INITIATE, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); + _CreateRank(sGameLocale->GetAcoreString(LANG_GUILD_MASTER, loc), GR_RIGHT_ALL); + _CreateRank(sGameLocale->GetAcoreString(LANG_GUILD_OFFICER, loc), GR_RIGHT_ALL); + _CreateRank(sGameLocale->GetAcoreString(LANG_GUILD_VETERAN, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); + _CreateRank(sGameLocale->GetAcoreString(LANG_GUILD_MEMBER, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); + _CreateRank(sGameLocale->GetAcoreString(LANG_GUILD_INITIATE, loc), GR_RIGHT_GCHATLISTEN | GR_RIGHT_GCHATSPEAK); } bool Guild::_CreateRank(std::string_view name, uint32 rights) diff --git a/src/server/game/Handlers/AuctionHouseHandler.cpp b/src/server/game/Handlers/AuctionHouseHandler.cpp index c03f619aa3cbef..bcd2f15454025f 100644 --- a/src/server/game/Handlers/AuctionHouseHandler.cpp +++ b/src/server/game/Handlers/AuctionHouseHandler.cpp @@ -18,6 +18,7 @@ #include "AsyncAuctionListing.h" #include "AuctionHouseMgr.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "GameTime.h" #include "Language.h" #include "Log.h" @@ -55,7 +56,7 @@ void WorldSession::SendAuctionHello(ObjectGuid guid, Creature* unit) { if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_AUCTION_LEVEL_REQ)) { - SendNotification(GetAcoreString(LANG_AUCTION_REQ), sWorld->getIntConfig(CONFIG_AUCTION_LEVEL_REQ)); + Acore::Text::SendNotification(this, LANG_AUCTION_REQ, sWorld->getIntConfig(CONFIG_AUCTION_LEVEL_REQ)); return; } diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 29b5a6261fd4b6..c89ddb6e41ff5a 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -20,6 +20,7 @@ #include "Battleground.h" #include "BattlegroundMgr.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "DisableMgr.h" #include "GameTime.h" #include "Group.h" @@ -54,7 +55,7 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recvData) if (!_player->GetBGAccessByLevel(bgTypeId)) { // temp, must be gossip message... - SendNotification(LANG_YOUR_BG_LEVEL_REQ_ERROR); + Acore::Text::SendNotification(this, LANG_YOUR_BG_LEVEL_REQ_ERROR); return; } diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index 27e10ceae0cbe4..88054528ea9eb3 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -23,6 +23,7 @@ #include "CharacterCache.h" #include "CharacterPackets.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "Common.h" #include "DatabaseEnv.h" #include "GameTime.h" @@ -840,7 +841,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& holder) // send server info if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1) - chH.PSendSysMessage("%s", GitRevision::GetFullVersion()); + chH.PSendSysMessage("{}", GitRevision::GetFullVersion()); } if (uint32 guildId = sCharacterCache->GetCharacterGuildIdByGuid(pCurrChar->GetGUID())) @@ -888,7 +889,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& holder) // send new char string if not empty if (!sWorld->GetNewCharString().empty()) - chH.PSendSysMessage("%s", sWorld->GetNewCharString().c_str()); + chH.PSendSysMessage("{}", sWorld->GetNewCharString()); } } @@ -973,14 +974,14 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& holder) if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS)) { pCurrChar->resetSpells(); - SendNotification(LANG_RESET_SPELLS); + Acore::Text::SendNotification(this, LANG_RESET_SPELLS); } if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS)) { pCurrChar->resetTalents(true); pCurrChar->SendTalentsInfoData(false); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state - SendNotification(LANG_RESET_TALENTS); + Acore::Text::SendNotification(this, LANG_RESET_TALENTS); } if (pCurrChar->HasAtLoginFlag(AT_LOGIN_CHECK_ACHIEVS)) @@ -1046,7 +1047,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& holder) pCurrChar->SetTaxiCheater(true); if (pCurrChar->IsGameMaster()) - SendNotification(LANG_GM_ON); + Acore::Text::SendNotification(this, LANG_GM_ON); std::string IP_str = GetRemoteAddress(); LOG_INFO("entities.player", "Account: {} (IP: {}) Login Character:[{}] ({}) Level: {}", @@ -1152,7 +1153,7 @@ void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar) // send server info if (sWorld->getIntConfig(CONFIG_ENABLE_SINFO_LOGIN) == 1) - chH.PSendSysMessage("%s", GitRevision::GetFullVersion()); + chH.PSendSysMessage("{}", GitRevision::GetFullVersion()); LOG_DEBUG("network.opcode", "WORLD: Sent server info"); } @@ -1241,7 +1242,7 @@ void WorldSession::HandlePlayerLoginToCharInWorld(Player* pCurrChar) sWorld->ShutdownMsg(true, pCurrChar); if (pCurrChar->IsGameMaster()) - SendNotification(LANG_GM_ON); + Acore::Text::SendNotification(this, LANG_GM_ON); m_playerLoading = false; } diff --git a/src/server/game/Handlers/ChatHandler.cpp b/src/server/game/Handlers/ChatHandler.cpp index 025b9a7cc8fa83..7c79bea7be3413 100644 --- a/src/server/game/Handlers/ChatHandler.cpp +++ b/src/server/game/Handlers/ChatHandler.cpp @@ -20,6 +20,7 @@ #include "ChannelMgr.h" #include "Chat.h" #include "ChatPackets.h" +#include "ChatTextBuilder.h" #include "Common.h" #include "GameTime.h" #include "GridNotifiersImpl.h" @@ -74,7 +75,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) if (lang == LANG_UNIVERSAL && type != CHAT_MSG_AFK && type != CHAT_MSG_DND) { LOG_ERROR("entities.player.cheat", "CMSG_MESSAGECHAT: Possible hacking-attempt: {} tried to send a message in universal language", GetPlayerInfo()); - SendNotification(LANG_UNKNOWN_LANGUAGE); + Acore::Text::SendNotification(this, LANG_UNKNOWN_LANGUAGE); recvData.rfinish(); return; } @@ -85,7 +86,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) LanguageDesc const* langDesc = GetLanguageDescByID(lang); if (!langDesc) { - SendNotification(LANG_UNKNOWN_LANGUAGE); + Acore::Text::SendNotification(this, LANG_UNKNOWN_LANGUAGE); recvData.rfinish(); return; } @@ -105,7 +106,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) if (!foundAura) { - SendNotification(LANG_NOT_LEARNED_LANGUAGE); + Acore::Text::SendNotification(this, LANG_NOT_LEARNED_LANGUAGE); recvData.rfinish(); return; } @@ -137,7 +138,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) if (sender->GetTotalPlayedTime() < minutes * MINUTE) { - SendNotification(LANG_MUTED_PLAYER, minutes); + Acore::Text::SendNotification(this, LANG_MUTED_PLAYER, minutes); recvData.rfinish(); return; } @@ -164,7 +165,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) if (sender->HasAura(1852) && type != CHAT_MSG_WHISPER) { - SendNotification(GetAcoreString(LANG_GM_SILENCE), sender->GetName().c_str()); + Acore::Text::SendNotification(this, LANG_GM_SILENCE, sender->GetName()); recvData.rfinish(); return; } @@ -298,8 +299,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) if (!_player->CanSpeak()) { - std::string timeStr = secsToTimeString(m_muteTime - GameTime::GetGameTime().count()); - SendNotification(GetAcoreString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str()); + Acore::Text::SendNotification(this, LANG_WAIT_BEFORE_SPEAKING, secsToTimeString(m_muteTime - GameTime::GetGameTime().count())); return; } } @@ -358,7 +358,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) if (sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ)) { - SendNotification(GetAcoreString(LANG_SAY_REQ), sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ)); + Acore::Text::SendNotification(this, LANG_SAY_REQ, sWorld->getIntConfig(CONFIG_CHAT_SAY_LEVEL_REQ)); return; } @@ -374,7 +374,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) { if (sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ)) { - SendNotification(GetAcoreString(LANG_WHISPER_REQ), sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ)); + Acore::Text::SendNotification(this, LANG_WHISPER_REQ, sWorld->getIntConfig(CONFIG_CHAT_WHISPER_LEVEL_REQ)); return; } @@ -403,7 +403,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) // pussywizard: optimization if (GetPlayer()->HasAura(1852) && !receiver->IsGameMaster()) { - SendNotification(GetAcoreString(LANG_GM_SILENCE), GetPlayer()->GetName().c_str()); + Acore::Text::SendNotification(this, LANG_GM_SILENCE, GetPlayer()->GetName()); return; } @@ -586,7 +586,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData) { if (sender->getLevel() < sWorld->getIntConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ)) { - SendNotification(GetAcoreString(LANG_CHANNEL_REQ), sWorld->getIntConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ)); + Acore::Text::SendNotification(this, LANG_CHANNEL_REQ, sWorld->getIntConfig(CONFIG_CHAT_CHANNEL_LEVEL_REQ)); return; } } @@ -730,8 +730,7 @@ void WorldSession::HandleTextEmoteOpcode(WorldPacket& recvData) if (!GetPlayer()->CanSpeak()) { - std::string timeStr = secsToTimeString(m_muteTime - GameTime::GetGameTime().count()); - SendNotification(GetAcoreString(LANG_WAIT_BEFORE_SPEAKING), timeStr.c_str()); + Acore::Text::SendNotification(this, LANG_WAIT_BEFORE_SPEAKING, secsToTimeString(m_muteTime - GameTime::GetGameTime().count())); return; } diff --git a/src/server/game/Handlers/GroupHandler.cpp b/src/server/game/Handlers/GroupHandler.cpp index df2778d41ecd0a..3f58b9bc9a20ba 100644 --- a/src/server/game/Handlers/GroupHandler.cpp +++ b/src/server/game/Handlers/GroupHandler.cpp @@ -15,6 +15,7 @@ * with this program. If not, see . */ +#include "ChatTextBuilder.h" #include "DatabaseEnv.h" #include "Group.h" #include "GroupMgr.h" @@ -745,7 +746,7 @@ void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recvData) // Check if player is in BG if (_player->InBattleground()) { - _player->GetSession()->SendNotification(LANG_BG_READY_CHECK_ERROR); + Acore::Text::SendNotification(this, LANG_BG_READY_CHECK_ERROR); return; } } diff --git a/src/server/game/Handlers/ItemHandler.cpp b/src/server/game/Handlers/ItemHandler.cpp index e22d4f5b2d8a40..e526356b18d6c6 100644 --- a/src/server/game/Handlers/ItemHandler.cpp +++ b/src/server/game/Handlers/ItemHandler.cpp @@ -16,6 +16,7 @@ */ #include "Common.h" +#include "GameLocale.h" #include "Item.h" #include "Log.h" #include "ObjectAccessor.h" @@ -550,10 +551,10 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket& recvData) int loc_idx = GetSessionDbLocaleIndex(); if (loc_idx >= 0) { - if (ItemLocale const* il = sObjectMgr->GetItemLocale(pProto->ItemId)) + if (ItemLocale const* il = sGameLocale->GetItemLocale(pProto->ItemId)) { - ObjectMgr::GetLocaleString(il->Name, loc_idx, Name); - ObjectMgr::GetLocaleString(il->Description, loc_idx, Description); + GameLocale::GetLocaleString(il->Name, loc_idx, Name); + GameLocale::GetLocaleString(il->Description, loc_idx, Description); } } // guess size @@ -1203,8 +1204,8 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket& recvData) std::string Name = pName->name; LocaleConstant loc_idx = GetSessionDbLocaleIndex(); if (loc_idx >= 0) - if (ItemSetNameLocale const* isnl = sObjectMgr->GetItemSetNameLocale(itemid)) - ObjectMgr::GetLocaleString(isnl->Name, loc_idx, Name); + if (ItemSetNameLocale const* isnl = sGameLocale->GetItemSetNameLocale(itemid)) + GameLocale::GetLocaleString(isnl->Name, loc_idx, Name); WorldPacket data(SMSG_ITEM_NAME_QUERY_RESPONSE, (4 + Name.size() + 1 + 4)); data << uint32(itemid); diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index fd2f2a1619e783..d54077517cefd1 100644 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -17,6 +17,7 @@ #include "AccountMgr.h" #include "CharacterCache.h" +#include "ChatTextBuilder.h" #include "DBCStores.h" #include "DatabaseEnv.h" #include "GameTime.h" @@ -117,7 +118,7 @@ void WorldSession::HandleSendMail(WorldPacket& recvData) if (player->getLevel() < sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ)) { - SendNotification(GetAcoreString(LANG_MAIL_SENDER_REQ), sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ)); + Acore::Text::SendNotification(this, LANG_MAIL_SENDER_REQ, sWorld->getIntConfig(CONFIG_MAIL_LEVEL_REQ)); return; } @@ -528,7 +529,7 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData) std::string senderName; if (!sCharacterCache->GetCharacterNameByGuid(ObjectGuid(HighGuid::Player, m->sender), senderName)) { - senderName = sObjectMgr->GetAcoreStringForDBCLocale(LANG_UNKNOWN); + senderName = sGameLocale->GetAcoreStringForDBCLocale(LANG_UNKNOWN); } std::string subj = m->subject; CleanStringForMysqlQuery(subj); diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index a53fbdee5d7380..8d30d2f5e4768b 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -21,6 +21,7 @@ #include "BattlegroundMgr.h" #include "CharacterPackets.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "Common.h" #include "CreatureAI.h" #include "DBCEnums.h" @@ -600,7 +601,7 @@ void WorldSession::HandleCharacterAuraFrozen(PreparedQueryResult result) { Field* fields = result->Fetch(); std::string player = fields[0].Get(); - handler.PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS, player.c_str()); + handler.PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS, player); } while (result->NextRow()); } @@ -690,23 +691,6 @@ void WorldSession::HandleResurrectResponseOpcode(WorldPacket& recv_data) GetPlayer()->ResurectUsingRequestData(); } -void WorldSession::SendAreaTriggerMessage(const char* Text, ...) -{ - va_list ap; - char szStr [1024]; - szStr[0] = '\0'; - - va_start(ap, Text); - vsnprintf(szStr, 1024, Text, ap); - va_end(ap); - - uint32 length = strlen(szStr) + 1; - WorldPacket data(SMSG_AREA_TRIGGER_MESSAGE, 4 + length); - data << length; - data << szStr; - SendPacket(&data); -} - void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data) { uint32 triggerId; @@ -1088,7 +1072,7 @@ void WorldSession::HandleWorldTeleportOpcode(WorldPacket& recv_data) if (AccountMgr::IsAdminAccount(GetSecurity())) GetPlayer()->TeleportTo(mapid, PositionX, PositionY, PositionZ, Orientation); else - SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); + Acore::Text::SendNotification(this, LANG_YOU_NOT_HAVE_PERMISSION); } void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) @@ -1099,13 +1083,13 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) if (!AccountMgr::IsAdminAccount(GetSecurity())) { - SendNotification(LANG_YOU_NOT_HAVE_PERMISSION); + Acore::Text::SendNotification(this, LANG_YOU_NOT_HAVE_PERMISSION); return; } if (charname.empty() || !normalizePlayerName (charname)) { - SendNotification(LANG_NEED_CHARACTER_NAME); + Acore::Text::SendNotification(this, LANG_NEED_CHARACTER_NAME); return; } @@ -1113,7 +1097,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) if (!player) { - SendNotification(LANG_PLAYER_NOT_EXIST_OR_OFFLINE, charname.c_str()); + Acore::Text::SendNotification(this, LANG_PLAYER_NOT_EXIST_OR_OFFLINE, charname); return; } @@ -1127,7 +1111,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data) if (!result) { - SendNotification(LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname.c_str()); + Acore::Text::SendNotification(this, LANG_ACCOUNT_FOR_PLAYER_NOT_FOUND, charname); return; } @@ -1349,11 +1333,11 @@ void WorldSession::HandleSetRaidDifficultyOpcode(WorldPacket& recv_data) switch (group->GetDifficultyChangePreventionReason()) { case DIFFICULTY_PREVENTION_CHANGE_BOSS_KILLED: - ChatHandler(this).PSendSysMessage("Raid was in combat recently and may not change difficulty again for %u sec.", preventionTime); + ChatHandler(this).PSendSysMessage("Raid was in combat recently and may not change difficulty again for {} sec.", preventionTime); break; case DIFFICULTY_PREVENTION_CHANGE_RECENTLY_CHANGED: default: - ChatHandler(this).PSendSysMessage("Raid difficulty has changed recently, and may not change again for %u sec.", preventionTime); + ChatHandler(this).PSendSysMessage("Raid difficulty has changed recently, and may not change again for {} sec.", preventionTime); break; } diff --git a/src/server/game/Handlers/NPCHandler.h b/src/server/game/Handlers/NPCHandler.h index 9a4511d0089190..dd0f3ac7ef1c8c 100644 --- a/src/server/game/Handlers/NPCHandler.h +++ b/src/server/game/Handlers/NPCHandler.h @@ -46,16 +46,4 @@ struct GossipText GossipTextOption Options[MAX_GOSSIP_TEXT_OPTIONS]; }; -struct PageTextLocale -{ - std::vector Text; -}; - -struct NpcTextLocale -{ - NpcTextLocale() { Text_0.resize(8); Text_1.resize(8); } - - std::vector> Text_0; - std::vector> Text_1; -}; #endif diff --git a/src/server/game/Handlers/PetitionsHandler.cpp b/src/server/game/Handlers/PetitionsHandler.cpp index e93e920de932ef..85979c5b1e6000 100644 --- a/src/server/game/Handlers/PetitionsHandler.cpp +++ b/src/server/game/Handlers/PetitionsHandler.cpp @@ -17,6 +17,7 @@ #include "ArenaTeam.h" #include "ArenaTeamMgr.h" +#include "ChatTextBuilder.h" #include "Guild.h" #include "GuildMgr.h" #include "Language.h" @@ -94,7 +95,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData) // TODO: find correct opcode if (_player->getLevel() < sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) { - SendNotification(LANG_ARENA_ONE_TOOLOW, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)); + Acore::Text::SendNotification(this, LANG_ARENA_ONE_TOOLOW, sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)); return; } diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp index fca5fc9b7b9f9c..170dfbb0a13432 100644 --- a/src/server/game/Handlers/QueryHandler.cpp +++ b/src/server/game/Handlers/QueryHandler.cpp @@ -16,6 +16,7 @@ */ #include "Common.h" +#include "GameLocale.h" #include "GameTime.h" #include "Log.h" #include "MapMgr.h" @@ -108,10 +109,10 @@ void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recvData) LocaleConstant loc_idx = GetSessionDbLocaleIndex(); if (loc_idx >= 0) { - if (CreatureLocale const* cl = sObjectMgr->GetCreatureLocale(entry)) + if (CreatureLocale const* cl = sGameLocale->GetCreatureLocale(entry)) { - ObjectMgr::GetLocaleString(cl->Name, loc_idx, Name); - ObjectMgr::GetLocaleString(cl->Title, loc_idx, Title); + GameLocale::GetLocaleString(cl->Name, loc_idx, Name); + GameLocale::GetLocaleString(cl->Title, loc_idx, Title); } } // guess size @@ -177,10 +178,10 @@ void WorldSession::HandleGameObjectQueryOpcode(WorldPacket& recvData) LocaleConstant localeConstant = GetSessionDbLocaleIndex(); if (localeConstant >= LOCALE_enUS) - if (GameObjectLocale const* gameObjectLocale = sObjectMgr->GetGameObjectLocale(entry)) + if (GameObjectLocale const* gameObjectLocale = sGameLocale->GetGameObjectLocale(entry)) { - ObjectMgr::GetLocaleString(gameObjectLocale->Name, localeConstant, Name); - ObjectMgr::GetLocaleString(gameObjectLocale->CastBarCaption, localeConstant, CastBarCaption); + GameLocale::GetLocaleString(gameObjectLocale->Name, localeConstant, Name); + GameLocale::GetLocaleString(gameObjectLocale->CastBarCaption, localeConstant, CastBarCaption); } LOG_DEBUG("network", "WORLD: CMSG_GAMEOBJECT_QUERY '{}' - Entry: {}. ", info->name, entry); @@ -305,7 +306,7 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket& recvData) for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) { - BroadcastText const* bct = sObjectMgr->GetBroadcastText(gossip->Options[i].BroadcastTextID); + BroadcastText const* bct = sGameLocale->GetBroadcastText(gossip->Options[i].BroadcastTextID); if (bct) { text0[i] = bct->GetText(locale, GENDER_MALE, true); @@ -319,10 +320,10 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket& recvData) if (locale != DEFAULT_LOCALE && !bct) { - if (NpcTextLocale const* npcTextLocale = sObjectMgr->GetNpcTextLocale(textID)) + if (NpcTextLocale const* npcTextLocale = sGameLocale->GetNpcTextLocale(textID)) { - ObjectMgr::GetLocaleString(npcTextLocale->Text_0[i], locale, text0[i]); - ObjectMgr::GetLocaleString(npcTextLocale->Text_1[i], locale, text1[i]); + GameLocale::GetLocaleString(npcTextLocale->Text_0[i], locale, text0[i]); + GameLocale::GetLocaleString(npcTextLocale->Text_1[i], locale, text1[i]); } } @@ -381,8 +382,8 @@ void WorldSession::HandlePageTextQueryOpcode(WorldPacket& recvData) int loc_idx = GetSessionDbLocaleIndex(); if (loc_idx >= 0) - if (PageTextLocale const* player = sObjectMgr->GetPageTextLocale(pageID)) - ObjectMgr::GetLocaleString(player->Text, loc_idx, Text); + if (PageTextLocale const* player = sGameLocale->GetPageTextLocale(pageID)) + GameLocale::GetLocaleString(player->Text, loc_idx, Text); data << Text; data << uint32(pageText->NextPage); diff --git a/src/server/game/Handlers/QuestHandler.cpp b/src/server/game/Handlers/QuestHandler.cpp index 25366f52a2e8f0..f2febf3b98a1f1 100644 --- a/src/server/game/Handlers/QuestHandler.cpp +++ b/src/server/game/Handlers/QuestHandler.cpp @@ -17,6 +17,7 @@ #include "Battleground.h" #include "BattlegroundAV.h" +#include "ChatTextBuilder.h" #include "GameObjectAI.h" #include "Group.h" #include "Language.h" @@ -584,7 +585,7 @@ void WorldSession::HandlePushQuestToParty(WorldPacket& recvPacket) // Check if player is in BG if (_player->InBattleground()) { - _player->GetSession()->SendNotification(LANG_BG_SHARE_QUEST_ERROR); + Acore::Text::SendNotification(this, LANG_BG_SHARE_QUEST_ERROR); continue; } } diff --git a/src/server/game/Handlers/TicketHandler.cpp b/src/server/game/Handlers/TicketHandler.cpp index 2d2eb9e8c7debc..074c99f1285c16 100644 --- a/src/server/game/Handlers/TicketHandler.cpp +++ b/src/server/game/Handlers/TicketHandler.cpp @@ -16,6 +16,7 @@ */ #include "Chat.h" +#include "ChatTextBuilder.h" #include "GameTime.h" #include "Language.h" #include "Opcodes.h" @@ -35,7 +36,7 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ)) { - SendNotification(GetAcoreString(LANG_TICKET_REQ), sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ)); + Acore::Text::SendNotification(this, LANG_TICKET_REQ, sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ)); return; } @@ -118,7 +119,7 @@ void WorldSession::HandleGMTicketCreateOpcode(WorldPacket& recvData) sTicketMgr->AddTicket(ticket); sTicketMgr->UpdateLastChange(); - sWorld->SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName().c_str(), ticket->GetId()); + Acore::Text::SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName(), ticket->GetId()); response = GMTICKET_RESPONSE_CREATE_SUCCESS; } @@ -145,7 +146,7 @@ void WorldSession::HandleGMTicketUpdateOpcode(WorldPacket& recv_data) ticket->SetMessage(message); ticket->SaveToDB(trans); - sWorld->SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName().c_str(), ticket->GetId()); + Acore::Text::SendGMText(LANG_COMMAND_TICKETUPDATED, GetPlayer()->GetName().c_str(), ticket->GetId()); response = GMTICKET_RESPONSE_UPDATE_SUCCESS; } @@ -163,7 +164,7 @@ void WorldSession::HandleGMTicketDeleteOpcode(WorldPacket& /*recv_data*/) data << uint32(GMTICKET_RESPONSE_TICKET_DELETED); SendPacket(&data); - sWorld->SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName().c_str(), ticket->GetId()); + Acore::Text::SendGMText(LANG_COMMAND_TICKETPLAYERABANDON, GetPlayer()->GetName().c_str(), ticket->GetId()); sTicketMgr->CloseTicket(ticket->GetId(), GetPlayer()->GetGUID()); sTicketMgr->SendTicket(this, nullptr); diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp index 10e24746881cb5..464833cf0a13c6 100644 --- a/src/server/game/Handlers/TradeHandler.cpp +++ b/src/server/game/Handlers/TradeHandler.cpp @@ -15,6 +15,7 @@ * with this program. If not, see . */ +#include "ChatTextBuilder.h" #include "Item.h" #include "Language.h" #include "Log.h" @@ -264,7 +265,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) // not accept case incorrect money amount if (!_player->HasEnoughMoney(my_trade->GetMoney())) { - SendNotification(LANG_NOT_ENOUGH_GOLD); + Acore::Text::SendNotification(this, LANG_NOT_ENOUGH_GOLD); my_trade->SetAccepted(false, true); return; } @@ -272,7 +273,7 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) // not accept case incorrect money amount if (!trader->HasEnoughMoney(his_trade->GetMoney())) { - trader->GetSession()->SendNotification(LANG_NOT_ENOUGH_GOLD); + Acore::Text::SendNotification(trader->GetSession(), LANG_NOT_ENOUGH_GOLD); his_trade->SetAccepted(false, true); return; } @@ -422,8 +423,8 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) { clearAcceptTradeMode(my_trade, his_trade); - SendNotification(LANG_NOT_FREE_TRADE_SLOTS); - trader->GetSession()->SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS); + Acore::Text::SendNotification(this, LANG_NOT_FREE_TRADE_SLOTS); + Acore::Text::SendNotification(trader->GetSession(), LANG_NOT_PARTNER_FREE_TRADE_SLOTS); my_trade->SetAccepted(false); his_trade->SetAccepted(false); delete my_spell; @@ -434,8 +435,8 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/) { clearAcceptTradeMode(my_trade, his_trade); - SendNotification(LANG_NOT_PARTNER_FREE_TRADE_SLOTS); - trader->GetSession()->SendNotification(LANG_NOT_FREE_TRADE_SLOTS); + Acore::Text::SendNotification(this, LANG_NOT_PARTNER_FREE_TRADE_SLOTS); + Acore::Text::SendNotification(trader->GetSession(), LANG_NOT_FREE_TRADE_SLOTS); my_trade->SetAccepted(false); his_trade->SetAccepted(false); delete my_spell; @@ -572,7 +573,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ)) { - SendNotification(GetAcoreString(LANG_TRADE_REQ), sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ)); + Acore::Text::SendNotification(this, LANG_TRADE_REQ, sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ)); return; } @@ -637,7 +638,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket) if (pOther->getLevel() < sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ)) { - SendNotification(GetAcoreString(LANG_TRADE_OTHER_REQ), sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ)); + Acore::Text::SendNotification(this, LANG_TRADE_OTHER_REQ, sWorld->getIntConfig(CONFIG_TRADE_LEVEL_REQ)); return; } diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index 034f528803c478..51fdef2648281e 100644 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -16,6 +16,7 @@ */ #include "InstanceScript.h" +#include "ChatTextBuilder.h" #include "Creature.h" #include "CreatureAI.h" #include "DatabaseEnv.h" @@ -438,7 +439,7 @@ void InstanceScript::DoSendNotifyToInstance(char const* format, ...) va_end(ap); for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i) if (Player* player = i->GetSource()) - player->GetSession()->SendNotification("%s", buff); + Acore::Text::SendNotification(player->GetSession(), buff); } } diff --git a/src/server/game/Locale/GameLocale.cpp b/src/server/game/Locale/GameLocale.cpp new file mode 100644 index 00000000000000..903ee23b9a86a9 --- /dev/null +++ b/src/server/game/Locale/GameLocale.cpp @@ -0,0 +1,1009 @@ +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "GameLocale.h" +#include "AccountMgr.h" +#include "Chat.h" +#include "DBCStores.h" +#include "DatabaseEnv.h" +#include "LocaleCommon.h" +#include "Log.h" +#include "ModuleLocale.h" +#include "ObjectMgr.h" +#include "Realm.h" +#include "SpellInfo.h" +#include "SpellMgr.h" +#include "Timer.h" +#include "World.h" +//#include "GameConfig.h" + +GameLocale* GameLocale::instance() +{ + static GameLocale instance; + return &instance; +} + +void GameLocale::LoadAllLocales() +{ + // Get once for all the locale index of DBC language (console/broadcasts) + SetDBCLocaleIndex(sWorld->GetDefaultDbcLocale()); + + uint32 oldMSTime = getMSTime(); + + LoadBroadcastTexts(); + LoadBroadcastTextLocales(); + LoadAchievementRewardLocales(); + LoadCreatureLocales(); + LoadGameObjectLocales(); + LoadItemLocales(); + LoadItemSetNameLocales(); + LoadNpcTextLocales(); + LoadPageTextLocales(); + LoadGossipMenuItemsLocales(); + LoadPointOfInterestLocales(); + LoadQuestLocales(); + LoadQuestOfferRewardLocale(); + LoadQuestRequestItemsLocale(); + LoadChatCommandsLocales(); + LoadAutoBroadCastLocales(); + //LoadQuestGreetingLocales(); // not implement + + // Load new strings + LoadRaceStrings(); + LoadClassStrings(); + + // Load modules strings + sModuleLocale->Init(); + + LOG_INFO("server.loading", ">> Localization strings loaded in {} ms", GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); +} + +bool GameLocale::LoadAcoreStrings() +{ + uint32 oldMSTime = getMSTime(); + + _acoreStringStore.clear(); // for reload case + + QueryResult result = WorldDatabase.Query("SELECT entry, content_default, locale_koKR, locale_frFR, locale_deDE, locale_zhCN, locale_zhTW, locale_esES, locale_esMX, locale_ruRU FROM acore_string"); + if (!result) + { + LOG_WARN("sql.sql", ">> Loaded 0 warhead strings. DB table `warhead_strings` is empty."); + LOG_WARN("sql.sql", ""); + return false; + } + + do + { + Field* fields = result->Fetch(); + + uint32 entry = fields[0].Get(); + + auto& data = _acoreStringStore[entry]; + + data.Content.resize(DEFAULT_LOCALE + 1); + + for (uint8 i = 0; i < TOTAL_LOCALES; ++i) + Acore::Locale::AddLocaleString(fields[i + 1].Get(), LocaleConstant(i), data.Content); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} acore strings in {} ms", _acoreStringStore.size(), GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", ""); + + return true; +} + +char const* GameLocale::GetAcoreString(uint32 entry, LocaleConstant locale) const +{ + if (auto as = GetAcoreString(entry)) + { + if (as->Content.size() > size_t(locale) && !as->Content[locale].empty()) + return as->Content[locale].c_str(); + + return as->Content[DEFAULT_LOCALE].c_str(); + } + + LOG_ERROR("sql.sql", "Warhead string entry {} not found in DB.", entry); + + return ""; +} + +AcoreString const* GameLocale::GetAcoreString(uint32 entry) const +{ + auto const& itr = _acoreStringStore.find(entry); + if (itr == _acoreStringStore.end()) + return nullptr; + + return &itr->second; +} + +void GameLocale::LoadAchievementRewardLocales() +{ + uint32 oldMSTime = getMSTime(); + + _achievementRewardLocales.clear(); // need for reload case + + // 0 1 2 3 + QueryResult result = WorldDatabase.Query("SELECT ID, Locale, Subject, Text FROM achievement_reward_locale"); + + if (!result) + { + LOG_WARN("sql.sql", ">> Loaded 0 achievement reward locale strings. DB table `achievement_reward_locale` is empty"); + LOG_WARN("sql.sql", " "); + return; + } + + do + { + Field* fields = result->Fetch(); + uint32 ID = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + AchievementRewardLocale& data = _achievementRewardLocales[ID]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Subject); + Acore::Locale::AddLocaleString(fields[3].Get(), locale, data.Text); + + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Achievement Reward Locale strings in {} ms", _achievementRewardLocales.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadBroadcastTexts() +{ + uint32 oldMSTime = getMSTime(); + + _broadcastTextStore.clear(); // for reload case + + // 0 1 2 3 4 5 6 7 8 9 10 11 12 + QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, Text, Text1, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text"); + if (!result) + { + LOG_WARN("sql.sql", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty."); + LOG_WARN("sql.sql", " "); + return; + } + + _broadcastTextStore.rehash(result->GetRowCount()); + + do + { + Field* fields = result->Fetch(); + + BroadcastText bct; + + bct.Id = fields[0].Get(); + bct.LanguageID = fields[1].Get(); + bct.Text[DEFAULT_LOCALE] = fields[2].Get(); + bct.Text1[DEFAULT_LOCALE] = fields[3].Get(); + bct.EmoteId1 = fields[4].Get(); + bct.EmoteId2 = fields[5].Get(); + bct.EmoteId3 = fields[6].Get(); + bct.EmoteDelay1 = fields[7].Get(); + bct.EmoteDelay2 = fields[8].Get(); + bct.EmoteDelay3 = fields[9].Get(); + bct.SoundEntriesId = fields[10].Get(); + bct.EmotesID = fields[11].Get(); + bct.Flags = fields[12].Get(); + + if (bct.SoundEntriesId && !sSoundEntriesStore.LookupEntry(bct.SoundEntriesId)) + { + LOG_DEBUG("broadcasttext", "BroadcastText (Id: {}) in table `broadcast_text` has SoundEntriesID {} but sound does not exist.", bct.Id, bct.SoundEntriesId); + bct.SoundEntriesId = 0; + } + + if (!GetLanguageDescByID(bct.LanguageID)) + { + LOG_DEBUG("broadcasttext", "BroadcastText (Id: {}) in table `broadcast_text` using LanguageID {} but Language does not exist.", bct.Id, bct.LanguageID); + bct.LanguageID = LANG_UNIVERSAL; + } + + if (bct.EmoteId1 && !sEmotesStore.LookupEntry(bct.EmoteId1)) + { + LOG_DEBUG("broadcasttext", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId1 {} but emote does not exist.", bct.Id, bct.EmoteId1); + bct.EmoteId1 = 0; + } + + if (bct.EmoteId2 && !sEmotesStore.LookupEntry(bct.EmoteId2)) + { + LOG_DEBUG("broadcasttext", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId2 {} but emote does not exist.", bct.Id, bct.EmoteId2); + bct.EmoteId2 = 0; + } + + if (bct.EmoteId3 && !sEmotesStore.LookupEntry(bct.EmoteId3)) + { + LOG_DEBUG("broadcasttext", "BroadcastText (Id: {}) in table `broadcast_text` has EmoteId3 {} but emote does not exist.", bct.Id, bct.EmoteId3); + bct.EmoteId3 = 0; + } + + _broadcastTextStore.emplace(bct.Id, bct); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} broadcast texts in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadBroadcastTextLocales() +{ + uint32 oldMSTime = getMSTime(); + + // 0 1 2 3 + QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text, Text1 FROM broadcast_text_locale"); + + if (!result) + { + LOG_WARN("sql.sql", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty."); + LOG_WARN("sql.sql", " "); + return; + } + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + auto const& bct = _broadcastTextStore.find(id); + if (bct == _broadcastTextStore.end()) + { + LOG_ERROR("sql.sql", "BroadcastText (Id: {}) in table `broadcast_text_locale` does not exist. Skipped!", id); + continue; + } + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, bct->second.Text); + Acore::Locale::AddLocaleString(fields[3].Get(), locale, bct->second.Text1); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} broadcast text locales in {} ms", _broadcastTextStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadCreatureLocales() +{ + uint32 oldMSTime = getMSTime(); + + _creatureLocaleStore.clear(); // need for reload case + + // 0 1 2 3 + QueryResult result = WorldDatabase.Query("SELECT entry, locale, Name, Title FROM creature_template_locale"); + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + CreatureLocale& data = _creatureLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Name); + Acore::Locale::AddLocaleString(fields[3].Get(), locale, data.Title); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} creature Locale strings in {} ms", static_cast(_creatureLocaleStore.size()), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadGossipMenuItemsLocales() +{ + uint32 oldMSTime = getMSTime(); + + _gossipMenuItemsLocaleStore.clear(); // need for reload case + + // 0 1 2 3 4 + QueryResult result = WorldDatabase.Query("SELECT MenuID, OptionID, Locale, OptionText, BoxText FROM gossip_menu_option_locale"); + + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint16 menuId = fields[0].Get(); + uint16 optionId = fields[1].Get(); + + LocaleConstant locale = GetLocaleByName(fields[2].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + GossipMenuItemsLocale& data = _gossipMenuItemsLocaleStore[MAKE_PAIR32(menuId, optionId)]; + + Acore::Locale::AddLocaleString(fields[3].Get(), locale, data.OptionText); + Acore::Locale::AddLocaleString(fields[4].Get(), locale, data.BoxText); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Gossip Menu Option Locale strings in {} ms", _gossipMenuItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadGameObjectLocales() +{ + uint32 oldMSTime = getMSTime(); + + _gameObjectLocaleStore.clear(); // need for reload case + + // 0 1 2 3 + QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale"); + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + GameObjectLocale& data = _gameObjectLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Name); + Acore::Locale::AddLocaleString(fields[3].Get(), locale, data.CastBarCaption); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Gameobject Locale strings in {} ms", _gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadItemLocales() +{ + uint32 oldMSTime = getMSTime(); + + _itemLocaleStore.clear(); // need for reload case + + QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name, Description FROM item_template_locale"); + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + ItemLocale& data = _itemLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Name); + Acore::Locale::AddLocaleString(fields[3].Get(), locale, data.Description); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Item Locale strings in {} ms", _itemLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadItemSetNameLocales() +{ + uint32 oldMSTime = getMSTime(); + + _itemSetNameLocaleStore.clear(); // need for reload case + + QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM item_set_names_locale"); + + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + ItemSetNameLocale& data = _itemSetNameLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Name); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Item Set Name Locale strings in {} ms", _itemSetNameLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadNpcTextLocales() +{ + uint32 oldMSTime = getMSTime(); + + _npcTextLocaleStore.clear(); // need for reload case + + QueryResult result = WorldDatabase.Query("SELECT ID, Locale, " + // 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 + "Text0_0, Text0_1, Text1_0, Text1_1, Text2_0, Text2_1, Text3_0, Text3_1, Text4_0, Text4_1, Text5_0, Text5_1, Text6_0, Text6_1, Text7_0, Text7_1 " + "FROM npc_text_locale"); + + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + NpcTextLocale& data = _npcTextLocaleStore[id]; + + for (uint8 i = 0; i < MAX_GOSSIP_TEXT_OPTIONS; ++i) + { + Acore::Locale::AddLocaleString(fields[2 + i * 2].Get(), locale, data.Text_0[i]); + Acore::Locale::AddLocaleString(fields[3 + i * 2].Get(), locale, data.Text_1[i]); + } + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Npc Text Locale strings in {} ms", _npcTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadPageTextLocales() +{ + uint32 oldMSTime = getMSTime(); + + _pageTextLocaleStore.clear(); // need for reload case + + // 0 1 2 + QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text FROM page_text_locale"); + + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + PageTextLocale& data = _pageTextLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Text); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Page Text Locale strings in {} ms", _pageTextLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadPointOfInterestLocales() +{ + uint32 oldMSTime = getMSTime(); + + _pointOfInterestLocaleStore.clear(); // need for reload case + + // 0 1 2 + QueryResult result = WorldDatabase.Query("SELECT ID, locale, Name FROM points_of_interest_locale"); + + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + PointOfInterestLocale& data = _pointOfInterestLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Name); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Points Of Interest Locale strings in {} ms", _pointOfInterestLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadQuestLocales() +{ + uint32 oldMSTime = getMSTime(); + + _questLocaleStore.clear(); // need for reload case + + // 0 1 2 3 4 5 6 7 8 9 10 + QueryResult result = WorldDatabase.Query("SELECT ID, locale, Title, Details, Objectives, EndText, CompletedText, ObjectiveText1, ObjectiveText2, ObjectiveText3, ObjectiveText4 FROM quest_template_locale"); + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + QuestLocale& data = _questLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Title); + Acore::Locale::AddLocaleString(fields[3].Get(), locale, data.Details); + Acore::Locale::AddLocaleString(fields[4].Get(), locale, data.Objectives); + Acore::Locale::AddLocaleString(fields[5].Get(), locale, data.AreaDescription); + Acore::Locale::AddLocaleString(fields[6].Get(), locale, data.CompletedText); + + for (uint8 i = 0; i < 4; ++i) + Acore::Locale::AddLocaleString(fields[i + 7].Get(), locale, data.ObjectiveText[i]); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Quest Locale strings in {} ms", _questLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadQuestOfferRewardLocale() +{ + uint32 oldMSTime = getMSTime(); + + _questOfferRewardLocaleStore.clear(); // need for reload case + + // 0 1 2 + QueryResult result = WorldDatabase.Query("SELECT Id, locale, RewardText FROM quest_offer_reward_locale"); + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + QuestOfferRewardLocale& data = _questOfferRewardLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.RewardText); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Quest Offer Reward locale strings in {} ms", _questOfferRewardLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadQuestRequestItemsLocale() +{ + uint32 oldMSTime = getMSTime(); + + _questRequestItemsLocaleStore.clear(); // need for reload case + + // 0 1 2 + QueryResult result = WorldDatabase.Query("SELECT Id, locale, CompletionText FROM quest_request_items_locale"); + if (!result) + return; + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + QuestRequestItemsLocale& data = _questRequestItemsLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.CompletionText); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Quest Request Items locale strings in {} ms", _questRequestItemsLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadChatCommandsLocales() +{ + uint32 oldMSTime = getMSTime(); + + _chatCommandStringStore.clear(); // need for reload case + + // 0 1 2 + QueryResult result = WorldDatabase.Query("SELECT `Command`, `Locale`, `Content` FROM commands_help_locale"); + if (!result) + { + return; + } + + do + { + Field* fields = result->Fetch(); + std::string commandName = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + ChatCommandHelpLocale& data = _chatCommandStringStore[commandName]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Content); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Chat commands help strings locale in {} ms", _chatCommandStringStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadAutoBroadCastLocales() +{ + uint32 oldMSTime = getMSTime(); + + _autobroadLocaleStore.clear(); // need for reload case + + // 0 1 2 + QueryResult result = LoginDatabase.Query("SELECT `ID`, `Locale`, `Text` FROM `autobroadcast_locale` WHERE `RealmID` = -1 OR RealmID = '{}'", realm.Id.Realm); + if (!result) + { + return; + } + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + auto& data = _autobroadLocaleStore[id]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.Text); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} autobroadcast text locale in {} ms", _chatCommandStringStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadQuestGreetingLocales() +{ + uint32 oldMSTime = getMSTime(); + + _questGreetingLocaleStore.clear(); // need for reload case + + // 0 1 2 3 + QueryResult result = WorldDatabase.Query("SELECT ID, Type, Locale, Greeting FROM quest_greeting_locale"); + if (!result) + { + LOG_INFO("server.loading", ">> Loaded 0 quest_greeting locales. DB table `quest_greeting_locale` is empty."); + return; + } + + do + { + Field* fields = result->Fetch(); + uint32 id = fields[0].Get(); + uint8 type = fields[1].Get(); + + // overwrite + switch (type) + { + case 0: // Creature + type = TYPEID_UNIT; + break; + case 1: // GameObject + type = TYPEID_GAMEOBJECT; + break; + default: + break; + } + + LocaleConstant locale = GetLocaleByName(fields[2].Get()); + if (locale == LOCALE_enUS) + continue; + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + QuestGreetingLocale& data = _questGreetingLocaleStore[MAKE_PAIR32(id, type)]; + + Acore::Locale::AddLocaleString(fields[3].Get(), locale, data.greeting); + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} quest greeting locale strings in {} ms", _questGreetingLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +AchievementRewardLocale const* GameLocale::GetAchievementRewardLocale(uint32 entry) const +{ + auto const& itr = _achievementRewardLocales.find(entry); + return itr != _achievementRewardLocales.end() ? &itr->second : nullptr; +} + +BroadcastText const* GameLocale::GetBroadcastText(uint32 id) const +{ + auto const& itr = _broadcastTextStore.find(id); + return itr != _broadcastTextStore.end() ? &itr->second : nullptr; +} + +CreatureLocale const* GameLocale::GetCreatureLocale(uint32 entry) const +{ + auto const& itr = _creatureLocaleStore.find(entry); + return itr != _creatureLocaleStore.end() ? &itr->second : nullptr; +} + +GameObjectLocale const* GameLocale::GetGameObjectLocale(uint32 entry) const +{ + auto const& itr = _gameObjectLocaleStore.find(entry); + return itr != _gameObjectLocaleStore.end() ? &itr->second : nullptr; +} + +GossipMenuItemsLocale const* GameLocale::GetGossipMenuItemsLocale(uint32 entry) const +{ + auto const& itr = _gossipMenuItemsLocaleStore.find(entry); + return itr != _gossipMenuItemsLocaleStore.end() ? &itr->second : nullptr; +} + +ItemLocale const* GameLocale::GetItemLocale(uint32 entry) const +{ + auto const& itr = _itemLocaleStore.find(entry); + return itr != _itemLocaleStore.end() ? &itr->second : nullptr; +} + +ItemSetNameLocale const* GameLocale::GetItemSetNameLocale(uint32 entry) const +{ + auto const& itr = _itemSetNameLocaleStore.find(entry); + return itr != _itemSetNameLocaleStore.end() ? &itr->second : nullptr; +} + +NpcTextLocale const* GameLocale::GetNpcTextLocale(uint32 entry) const +{ + auto const& itr = _npcTextLocaleStore.find(entry); + return itr != _npcTextLocaleStore.end() ? &itr->second : nullptr; +} + +PageTextLocale const* GameLocale::GetPageTextLocale(uint32 entry) const +{ + auto const& itr = _pageTextLocaleStore.find(entry); + return itr != _pageTextLocaleStore.end() ? &itr->second : nullptr; +} + +PointOfInterestLocale const* GameLocale::GetPointOfInterestLocale(uint32 entry) const +{ + auto const& itr = _pointOfInterestLocaleStore.find(entry); + return itr != _pointOfInterestLocaleStore.end() ? &itr->second : nullptr; +} + +QuestLocale const* GameLocale::GetQuestLocale(uint32 entry) const +{ + auto const& itr = _questLocaleStore.find(entry); + return itr != _questLocaleStore.end() ? &itr->second : nullptr; +} + +QuestOfferRewardLocale const* GameLocale::GetQuestOfferRewardLocale(uint32 entry) const +{ + auto const& itr = _questOfferRewardLocaleStore.find(entry); + return itr != _questOfferRewardLocaleStore.end() ? &itr->second : nullptr; +} + +QuestRequestItemsLocale const* GameLocale::GetQuestRequestItemsLocale(uint32 entry) const +{ + auto const& itr = _questRequestItemsLocaleStore.find(entry); + return itr != _questRequestItemsLocaleStore.end() ? &itr->second : nullptr; +} + +QuestGreetingLocale const* GameLocale::GetQuestGreetingLocale(uint32 id) const +{ + auto const& itr = _questGreetingLocaleStore.find(id); + return itr != _questGreetingLocaleStore.end() ? &itr->second : nullptr; +} + +AutobroadcastLocale const* GameLocale::GetAutoBroadCastLocale(uint32 id) const +{ + auto const& itr = _autobroadLocaleStore.find(id); + return itr != _autobroadLocaleStore.end() ? &itr->second : nullptr; +} + +Optional GameLocale::GetChatCommandStringHelpLocale(std::string const& commandName, LocaleConstant locale) const +{ + auto const& itr = _chatCommandStringStore.find(commandName); + if (itr == _chatCommandStringStore.end()) + { + //LOG_ERROR("sql.sql", "> Missing help text localisation for commnd '{}'", commandName); + return std::nullopt; + } + + if (itr->second.Content.size() > size_t(locale) && !itr->second.Content[locale].empty()) + { + return itr->second.Content.at(locale); + } + + return itr->second.Content[DEFAULT_LOCALE]; +} + +// New locale +void GameLocale::LoadRaceStrings() +{ + uint32 oldMSTime = getMSTime(); + + _raceStringStore.clear(); // need for reload case + + QueryResult result = WorldDatabase.Query("SELECT ID, Locale, NameMale, NameFemale FROM `string_race`"); + if (!result) + { + LOG_WARN("sql.sql", "> DB table `string_race` is empty"); + return; + } + + do + { + Field* fields = result->Fetch(); + uint32 ID = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + auto& data = _raceStringStore[ID]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.NameMale); + Acore::Locale::AddLocaleString(fields[3].Get(), locale, data.NameFemale); + + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Race strings in {} ms", _raceStringStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +void GameLocale::LoadClassStrings() +{ + uint32 oldMSTime = getMSTime(); + + _classStringStore.clear(); // need for reload case + + QueryResult result = WorldDatabase.Query("SELECT ID, Locale, NameMale, NameFemale FROM `string_class`"); + if (!result) + { + LOG_WARN("sql.sql", "> DB table `string_class` is empty"); + return; + } + + do + { + Field* fields = result->Fetch(); + + uint32 ID = fields[0].Get(); + + LocaleConstant locale = GetLocaleByName(fields[1].Get()); + + /*if (CONF_GET_BOOL("Language.SupportOnlyDefault") && locale != GetDBCLocaleIndex()) + continue;*/ + + auto& data = _classStringStore[ID]; + + Acore::Locale::AddLocaleString(fields[2].Get(), locale, data.NameMale); + Acore::Locale::AddLocaleString(fields[3].Get(), locale, data.NameFemale); + + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} Class strings in {} ms", _classStringStore.size(), GetMSTimeDiffToNow(oldMSTime)); +} + +RaceString const* GameLocale::GetRaseString(uint32 id) const +{ + auto const& itr = _raceStringStore.find(id); + return itr != _raceStringStore.end() ? &itr->second : nullptr; +} + +ClassString const* GameLocale::GetClassString(uint32 id) const +{ + auto const& itr = _classStringStore.find(id); + return itr != _classStringStore.end() ? &itr->second : nullptr; +} + +std::string const GameLocale::GetItemNameLocale(uint32 itemID, int8 index_loc /*= DEFAULT_LOCALE*/) +{ + ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemID); + ItemLocale const* itemLocale = GetItemLocale(itemID); + std::string name; + + if (itemLocale) + name = itemLocale->Name[index_loc]; + + if (name.empty() && itemTemplate) + name = itemTemplate->Name1; + + return name; +} + +std::string const GameLocale::GetItemLink(uint32 itemID, int8 index_loc /*= DEFAULT_LOCALE*/) +{ + ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(itemID); + if (!itemTemplate) + return ""; + + std::string name = GetItemNameLocale(itemID, index_loc); + uint32 color = ItemQualityColors[itemTemplate ? itemTemplate->Quality : uint32(ITEM_QUALITY_POOR)]; + + return Acore::StringFormatFmt("|c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r", color, itemID, name); +} + +std::string const GameLocale::GetSpellLink(uint32 spellID, int8 index_loc /*= DEFAULT_LOCALE*/) +{ + auto const& spell = sSpellMgr->GetSpellInfo(spellID); + if (!spell) + return ""; + + return Acore::StringFormatFmt("|cffffffff|Hspell:{}|h[{}]|h|r", spell->Id, spell->SpellName[index_loc]); +} + +std::string const GameLocale::GetSpellNamelocale(uint32 spellID, int8 index_loc /*= DEFAULT_LOCALE*/) +{ + auto const& spell = sSpellMgr->GetSpellInfo(spellID); + if (!spell) + return ""; + + return spell->SpellName[index_loc]; +} + +std::string const GameLocale::GetCreatureNamelocale(uint32 creatureEntry, int8 index_loc /*= DEFAULT_LOCALE*/) +{ + auto creatureTemplate = sObjectMgr->GetCreatureTemplate(creatureEntry); + auto cretureLocale = GetCreatureLocale(creatureEntry); + std::string name; + + if (cretureLocale) + name = cretureLocale->Name[index_loc].c_str(); + + if (name.empty() && creatureTemplate) + name = creatureTemplate->Name.c_str(); + + if (name.empty()) + name = "Unknown creature"; + + return name; +} diff --git a/src/server/game/Locale/GameLocale.h b/src/server/game/Locale/GameLocale.h new file mode 100644 index 00000000000000..59585c51ee949e --- /dev/null +++ b/src/server/game/Locale/GameLocale.h @@ -0,0 +1,364 @@ +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _GAME_LOCALE_H_ +#define _GAME_LOCALE_H_ + +#include "Common.h" +#include "Optional.h" +#include "SharedDefines.h" +#include +#include + +struct AcoreString +{ + std::vector Content; +}; + +struct AutobroadcastLocale +{ + std::vector Text; +}; + +struct ChatCommandHelpLocale +{ + std::vector Content; +}; + +// Default locales +struct AchievementRewardLocale +{ + std::vector Subject; + std::vector Text; +}; + +struct CreatureLocale +{ + std::vector Name; + std::vector Title; +}; + +struct GameObjectLocale +{ + std::vector Name; + std::vector CastBarCaption; +}; + +struct GossipMenuItemsLocale +{ + std::vector OptionText; + std::vector BoxText; +}; + +struct ItemLocale +{ + std::vector Name; + std::vector Description; +}; + +struct ItemSetNameLocale +{ + std::vector Name; +}; + +struct NpcTextLocale +{ + NpcTextLocale() { Text_0.resize(8); Text_1.resize(8); } + + std::vector> Text_0; + std::vector> Text_1; +}; + +struct PageTextLocale +{ + std::vector Text; +}; + +struct PointOfInterestLocale +{ + std::vector Name; +}; + +struct QuestLocale +{ + QuestLocale() { ObjectiveText.resize(4); } + + std::vector Title; + std::vector Details; + std::vector Objectives; + std::vector OfferRewardText; + std::vector RequestItemsText; + std::vector AreaDescription; + std::vector CompletedText; + std::vector> ObjectiveText; +}; + +struct QuestRequestItemsLocale +{ + std::vector CompletionText; +}; + +struct QuestOfferRewardLocale +{ + std::vector RewardText; +}; + +struct QuestGreetingLocale +{ + std::vector greeting; +}; + +struct BroadcastText +{ + BroadcastText() + { + Text.resize(DEFAULT_LOCALE + 1); + Text1.resize(DEFAULT_LOCALE + 1); + } + + uint32 Id{ 0 }; + uint32 LanguageID{ 0 }; + std::vector Text; + std::vector Text1; + uint32 EmoteId1{ 0 }; + uint32 EmoteId2{ 0 }; + uint32 EmoteId3{ 0 }; + uint32 EmoteDelay1{ 0 }; + uint32 EmoteDelay2{ 0 }; + uint32 EmoteDelay3{ 0 }; + uint32 SoundEntriesId{ 0 }; + uint32 EmotesID{ 0 }; + uint32 Flags{ 0 }; + // uint32 VerifiedBuild; + + [[nodiscard]] std::string const& GetText(LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE, bool forceGender = false) const + { + if ((gender == GENDER_FEMALE || gender == GENDER_NONE) && (forceGender || !Text1[DEFAULT_LOCALE].empty())) + { + if (Text1.size() > size_t(locale) && !Text1[locale].empty()) + { + return Text1.at(locale); + } + + return Text1.at(DEFAULT_LOCALE); + } + // else if (gender == GENDER_MALE) + { + if (Text.size() > size_t(locale) && !Text[locale].empty()) + { + return Text.at(locale); + } + + return Text.at(DEFAULT_LOCALE); + } + } +}; + +// New strings and locales +struct RaceString +{ + RaceString() + { + NameMale.resize(DEFAULT_LOCALE + 1); + NameFemale.resize(DEFAULT_LOCALE + 1); + } + + std::vector NameMale; + std::vector NameFemale; + + [[nodiscard]] std::string const& GetText(LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE) const + { + if (gender == GENDER_FEMALE) + { + if (NameFemale.size() > size_t(locale) && !NameFemale[locale].empty()) + { + return NameFemale.at(locale); + } + + if (NameMale.size() > size_t(locale) && !NameMale[locale].empty()) + { + return NameMale.at(locale); + } + + return NameFemale.at(DEFAULT_LOCALE); + } + + if (NameMale.size() > size_t(locale) && !NameMale[locale].empty()) + { + return NameMale.at(locale); + } + + return NameMale.at(DEFAULT_LOCALE); + } +}; + +struct ClassString +{ + ClassString() + { + NameMale.resize(DEFAULT_LOCALE + 1); + NameFemale.resize(DEFAULT_LOCALE + 1); + } + + std::vector NameMale; + std::vector NameFemale; + + [[nodiscard]] std::string const& GetText(LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE) const + { + if (gender == GENDER_FEMALE) + { + if (NameFemale.size() > size_t(locale) && !NameFemale[locale].empty()) + { + return NameFemale.at(locale); + } + + if (NameMale.size() > size_t(locale) && !NameMale[locale].empty()) + { + return NameMale.at(locale); + } + + return NameFemale.at(DEFAULT_LOCALE); + } + + if (NameMale.size() > size_t(locale) && !NameMale[locale].empty()) + { + return NameMale.at(locale); + } + + return NameMale.at(DEFAULT_LOCALE); + } +}; + +class AC_GAME_API GameLocale +{ +private: + GameLocale() = default; + ~GameLocale() = default; + + GameLocale(GameLocale const&) = delete; + GameLocale(GameLocale&&) = delete; + GameLocale& operator= (GameLocale const&) = delete; + GameLocale& operator= (GameLocale&&) = delete; + +public: + static GameLocale* instance(); + + void LoadAllLocales(); + bool LoadAcoreStrings(); + + static inline std::string_view GetLocaleString(std::vector const& data, size_t locale) + { + if (locale < data.size()) + return data.at(locale); + else + return {}; + } + + static inline void GetLocaleString(const std::vector& data, int loc_idx, std::string& value) + { + if (data.size() > size_t(loc_idx) && !data[loc_idx].empty()) + value = data[loc_idx]; + } + + AcoreString const* GetAcoreString(uint32 entry) const; + char const* GetAcoreString(uint32 entry, LocaleConstant locale) const; + char const* GetAcoreStringForDBCLocale(uint32 entry) const { return GetAcoreString(entry, DBCLocaleIndex); } + + LocaleConstant GetDBCLocaleIndex() const { return DBCLocaleIndex; } + void SetDBCLocaleIndex(LocaleConstant locale) { DBCLocaleIndex = locale; } + + void LoadAchievementRewardLocales(); + void LoadBroadcastTexts(); + void LoadBroadcastTextLocales(); + void LoadCreatureLocales(); + void LoadGameObjectLocales(); + void LoadItemLocales(); + void LoadItemSetNameLocales(); + void LoadQuestLocales(); + void LoadNpcTextLocales(); + void LoadQuestOfferRewardLocale(); + void LoadQuestRequestItemsLocale(); + void LoadPageTextLocales(); + void LoadGossipMenuItemsLocales(); + void LoadPointOfInterestLocales(); + void LoadQuestGreetingLocales(); + void LoadChatCommandsLocales(); + void LoadAutoBroadCastLocales(); + + [[nodiscard]] AchievementRewardLocale const* GetAchievementRewardLocale(uint32 entry) const; + [[nodiscard]] BroadcastText const* GetBroadcastText(uint32 id) const; + [[nodiscard]] CreatureLocale const* GetCreatureLocale(uint32 entry) const; + [[nodiscard]] GameObjectLocale const* GetGameObjectLocale(uint32 entry) const; + [[nodiscard]] GossipMenuItemsLocale const* GetGossipMenuItemsLocale(uint32 entry) const; + [[nodiscard]] ItemLocale const* GetItemLocale(uint32 entry) const; + [[nodiscard]] ItemSetNameLocale const* GetItemSetNameLocale(uint32 entry) const; + [[nodiscard]] NpcTextLocale const* GetNpcTextLocale(uint32 entry) const; + [[nodiscard]] PageTextLocale const* GetPageTextLocale(uint32 entry) const; + [[nodiscard]] PointOfInterestLocale const* GetPointOfInterestLocale(uint32 entry) const; + [[nodiscard]] QuestLocale const* GetQuestLocale(uint32 entry) const; + [[nodiscard]] QuestOfferRewardLocale const* GetQuestOfferRewardLocale(uint32 entry) const; + [[nodiscard]] QuestRequestItemsLocale const* GetQuestRequestItemsLocale(uint32 entry) const; + [[nodiscard]] QuestGreetingLocale const* GetQuestGreetingLocale(uint32 id) const; + [[nodiscard]] AutobroadcastLocale const* GetAutoBroadCastLocale(uint32 id) const; + + // + std::string const GetItemNameLocale(uint32 itemID, int8 index_loc = DEFAULT_LOCALE); + std::string const GetItemLink(uint32 itemID, int8 index_loc = DEFAULT_LOCALE); + std::string const GetSpellLink(uint32 spellID, int8 index_loc = DEFAULT_LOCALE); + std::string const GetSpellNamelocale(uint32 spellID, int8 index_loc = DEFAULT_LOCALE); + std::string const GetCreatureNamelocale(uint32 creatureEntry, int8 index_loc = DEFAULT_LOCALE); + + // New strings and locales + void LoadRaceStrings(); + void LoadClassStrings(); + + RaceString const* GetRaseString(uint32 id) const; + ClassString const* GetClassString(uint32 id) const; + + Optional GetChatCommandStringHelpLocale(std::string const& commandName, LocaleConstant locale) const; + +private: + std::unordered_map _acoreStringStore; + LocaleConstant DBCLocaleIndex = LOCALE_enUS; + + std::unordered_map _achievementRewardLocales; + std::unordered_map _broadcastTextStore; + std::unordered_map _creatureLocaleStore; + std::unordered_map _gameObjectLocaleStore; + std::unordered_map _gossipMenuItemsLocaleStore; + std::unordered_map _itemLocaleStore; + std::unordered_map _itemSetNameLocaleStore; + std::unordered_map _npcTextLocaleStore; + std::unordered_map _pageTextLocaleStore; + std::unordered_map _pointOfInterestLocaleStore; + std::unordered_map _questLocaleStore; + std::unordered_map _questGreetingLocaleStore; + std::unordered_map _questOfferRewardLocaleStore; + std::unordered_map _questRequestItemsLocaleStore; + std::unordered_map _autobroadLocaleStore; + + // New strings and locales + std::unordered_map _raceStringStore; + std::unordered_map _classStringStore; + + // Chat command help locales + std::unordered_map _chatCommandStringStore; +}; + +#define sGameLocale GameLocale::instance() + +#endif // _GAME_LOCALE_H_ diff --git a/src/server/game/Locale/LocaleCommon.cpp b/src/server/game/Locale/LocaleCommon.cpp new file mode 100644 index 00000000000000..332c605afcb204 --- /dev/null +++ b/src/server/game/Locale/LocaleCommon.cpp @@ -0,0 +1,29 @@ +/* + * This file is part of the AzerothCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "LocaleCommon.h" + +void Acore::Locale::AddLocaleString(std::string_view str, LocaleConstant locale, std::vector& data) +{ + if (str.empty()) + return; + + if (data.size() <= size_t(locale)) + data.resize(size_t(locale) + 1); + + data[locale] = std::string(str); +} diff --git a/src/server/game/Locale/LocaleCommon.h b/src/server/game/Locale/LocaleCommon.h new file mode 100644 index 00000000000000..992671ef97e212 --- /dev/null +++ b/src/server/game/Locale/LocaleCommon.h @@ -0,0 +1,29 @@ +/* + * This file is part of the WarheadCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _LOCALE_COMMON_H_ +#define _LOCALE_COMMON_H_ + +#include "Common.h" +#include + +namespace Acore::Locale +{ + void AC_GAME_API AddLocaleString(std::string_view str, LocaleConstant locale, std::vector& data); +} + +#endif // _LOCALE_COMMON_H_ diff --git a/src/server/game/Locale/ModuleLocale.cpp b/src/server/game/Locale/ModuleLocale.cpp new file mode 100644 index 00000000000000..eab4c6e4c2a209 --- /dev/null +++ b/src/server/game/Locale/ModuleLocale.cpp @@ -0,0 +1,129 @@ +/* + * This file is part of the WarheadCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "ModuleLocale.h" +#include "AccountMgr.h" +#include "Chat.h" +#include "DBCStores.h" +#include "DatabaseEnv.h" +#include "LocaleCommon.h" +#include "Log.h" +#include "Optional.h" +#include "Player.h" +#include "Tokenize.h" +#include "World.h" + +ModuleLocale* ModuleLocale::instance() +{ + static ModuleLocale instance; + return &instance; +} + +void ModuleLocale::Init() +{ + LOG_INFO("server.loading", " "); + LOG_INFO("server.loading", ">> Loading modules strings"); + LoadModuleString(); +} + +Optional ModuleLocale::GetModuleString(std::string const& entry, uint8 _locale) const +{ + if (entry.empty()) + { + LOG_ERROR("locale.module", "> ModulesLocales: Entry is empty!"); + return std::nullopt; + } + + auto const& itr = _modulesStringStore.find(entry); + if (itr == _modulesStringStore.end()) + { + LOG_FATAL("locale.module", "> ModulesLocales: Not found strings for entry ({})", entry); + ABORT(); + return {}; + } + + return itr->second.GetText(_locale); +} + +void ModuleLocale::LoadModuleString() +{ + uint32 oldMSTime = getMSTime(); + + _modulesStringStore.clear(); + + QueryResult result = WorldDatabase.Query("SELECT `Entry`, `Locale`, `Text` FROM `string_module`"); + if (!result) + { + LOG_INFO("server.loading", "> DB table `string_module` is empty"); + LOG_INFO("server.loading", " "); + return; + } + + do + { + Field* fields = result->Fetch(); + + auto& data = _modulesStringStore[fields[0].Get()]; + + Acore::Locale::AddLocaleString(fields[2].Get(), GetLocaleByName(fields[1].Get()), data.Content); + + } while (result->NextRow()); + + LOG_INFO("server.loading", ">> Loaded {} module strings in {} ms", _modulesStringStore.size(), GetMSTimeDiffToNow(oldMSTime)); + LOG_INFO("server.loading", " "); +} + +void ModuleLocale::SendPlayerMessageFmt(Player* player, std::function const& msg) +{ + if (!msg) + return; + + for (std::string_view line : Acore::Tokenize(msg(player->GetSession()->GetSessionDbLocaleIndex()), '\n', true)) + { + WorldPacket data; + ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line); + SendPlayerPacket(player, &data); + } +} + +void ModuleLocale::SendGlobalMessageFmt(bool gmOnly, std::function const& msg) +{ + if (!msg) + return; + + for (auto const& [accountID, session] : sWorld->GetAllSessions()) + { + Player* player = session->GetPlayer(); + if (!player || !player->IsInWorld()) + return; + + if (AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) && gmOnly) + continue; + + for (std::string_view line : Acore::Tokenize(msg(player->GetSession()->GetSessionDbLocaleIndex()), '\n', true)) + { + WorldPacket data; + ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line); + SendPlayerPacket(player, &data); + } + } +} + +void ModuleLocale::SendPlayerPacket(Player* player, WorldPacket* data) +{ + player->SendDirectMessage(data); +} diff --git a/src/server/game/Locale/ModuleLocale.h b/src/server/game/Locale/ModuleLocale.h new file mode 100644 index 00000000000000..333b9b1bebfc70 --- /dev/null +++ b/src/server/game/Locale/ModuleLocale.h @@ -0,0 +1,110 @@ +/* + * This file is part of the WarheadCore Project. See AUTHORS file for Copyright information + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by the + * Free Software Foundation; either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef _MODULES_LOCALE_H_ +#define _MODULES_LOCALE_H_ + +#include "Common.h" +#include "Optional.h" +#include "StringFormat.h" +#include +#include +#include + +class Player; +class WorldPacket; + +struct ModuleString +{ + ModuleString() + { + Content.resize(DEFAULT_LOCALE + 1); + } + + std::vector Content; + + Optional GetText(uint8 locale = 0) const + { + if (Content.size() > size_t(locale) && !Content[locale].empty()) + return Content[locale]; + + if (!Content[DEFAULT_LOCALE].empty()) + return Content[DEFAULT_LOCALE]; + + return std::nullopt; + } +}; + +class AC_GAME_API ModuleLocale +{ +private: + ModuleLocale() = default; + ~ModuleLocale() = default; + + ModuleLocale(ModuleLocale const&) = delete; + ModuleLocale(ModuleLocale&&) = delete; + ModuleLocale& operator= (ModuleLocale const&) = delete; + ModuleLocale& operator= (ModuleLocale&&) = delete; + +public: + static ModuleLocale* instance(); + + void Init(); + void LoadModuleString(); + + Optional GetModuleString(std::string const& entry, uint8 _locale) const; + + // Get localized message + template + inline std::string GetLocaleMessage(std::string const& entry, uint8 localeIndex, Args&&... args) + { + return Acore::StringFormatFmt(*GetModuleString(entry, localeIndex), std::forward(args)...); + } + + void SendPlayerMessageFmt(Player* player, std::function const& msg); + void SendGlobalMessageFmt(bool gmOnly, std::function const& msg); + + // Send localized message to player + template + void SendPlayerMessage(Player* player, std::string const& entry, Args&&... args) + { + SendPlayerMessageFmt(player, [&](uint8 index) + { + return GetLocaleMessage(entry, index, std::forward(args)...); + }); + } + + // Send localized message to all player + template + void SendGlobalMessage(bool gmOnly, std::string const& entry, Args&&... args) + { + SendGlobalMessageFmt(gmOnly, [&](uint8 index) + { + return GetLocaleMessage(entry, index, std::forward(args)...); + }); + } + +private: + std::unordered_map _modulesStringStore; + + // Send packets + void SendPlayerPacket(Player* player, WorldPacket* data); +}; + +#define sModuleLocale ModuleLocale::instance() + +#endif // _MODULES_LOCALE_H_ diff --git a/src/server/game/Maps/MapMgr.cpp b/src/server/game/Maps/MapMgr.cpp index 983de0a9a4b13d..3bfefb48d073be 100644 --- a/src/server/game/Maps/MapMgr.cpp +++ b/src/server/game/Maps/MapMgr.cpp @@ -17,6 +17,7 @@ #include "MapMgr.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "DatabaseEnv.h" #include "GridDefines.h" #include "Group.h" @@ -168,7 +169,7 @@ Map::EnterState MapMgr::PlayerCannotEnter(uint32 mapid, Player* player, bool log { // probably there must be special opcode, because client has this string constant in GlobalStrings.lua // TODO: this is not a good place to send the message - player->GetSession()->SendAreaTriggerMessage(player->GetSession()->GetAcoreString(LANG_INSTANCE_RAID_GROUP_ONLY), mapName); + Acore::Text::SendAreaTriggerMessage(player->GetSession(), LANG_INSTANCE_RAID_GROUP_ONLY, mapName); LOG_DEBUG("maps", "MAP: Player '{}' must be in a raid group to enter instance '{}'", player->GetName(), mapName); return Map::CANNOT_ENTER_NOT_IN_RAID; } diff --git a/src/server/game/Misc/BanMgr.cpp b/src/server/game/Misc/BanMgr.cpp index e55d4e276d1d2a..b31e8a1e23c955 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 "ChatTextBuilder.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()); + Acore::Text::SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), secsToTimeString(TimeStringToSecs(Duration), true).c_str(), Reason.c_str()); else - sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), Reason.c_str()); + Acore::Text::SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), Reason.c_str()); } 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()); + Acore::Text::SendWorldText(LANG_BAN_ACCOUNT_YOUBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), secsToTimeString(TimeStringToSecs(Duration), true).c_str(), Reason.c_str()); else - sWorld->SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), Reason.c_str()); + Acore::Text::SendWorldText(LANG_BAN_ACCOUNT_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), AccountName.c_str(), Reason.c_str()); } 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()); + Acore::Text::SendWorldText(LANG_BAN_IP_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), IP.c_str(), Reason.c_str()); else - sWorld->SendWorldText(LANG_BAN_IP_YOUBANNEDMESSAGE_WORLD, Author.c_str(), IP.c_str(), secsToTimeString(TimeStringToSecs(Duration), true).c_str(), Reason.c_str()); + Acore::Text::SendWorldText(LANG_BAN_IP_YOUBANNEDMESSAGE_WORLD, Author.c_str(), IP.c_str(), secsToTimeString(TimeStringToSecs(Duration), true).c_str(), Reason.c_str()); } 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()); + Acore::Text::SendWorldText(LANG_BAN_CHARACTER_YOUBANNEDMESSAGE_WORLD, Author.c_str(), CharacterName.c_str(), secsToTimeString(TimeStringToSecs(Duration), true).c_str(), Reason.c_str()); else - sWorld->SendWorldText(LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), CharacterName.c_str(), Reason.c_str()); + Acore::Text::SendWorldText(LANG_BAN_CHARACTER_YOUPERMBANNEDMESSAGE_WORLD, Author.c_str(), CharacterName.c_str(), Reason.c_str()); } return BAN_SUCCESS; diff --git a/src/server/game/Motd/ServerMotd.cpp b/src/server/game/Motd/ServerMotd.cpp index 0ff8eab9ef7e3d..7bbb1ce41c7d95 100644 --- a/src/server/game/Motd/ServerMotd.cpp +++ b/src/server/game/Motd/ServerMotd.cpp @@ -18,9 +18,9 @@ #include "ServerMotd.h" #include "Opcodes.h" #include "ScriptMgr.h" +#include "Tokenize.h" #include "Util.h" #include "WorldPacket.h" -#include "Tokenize.h" #include namespace diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h index 734151b5ef548c..efd9c27914f54f 100644 --- a/src/server/game/Quests/QuestDef.h +++ b/src/server/game/Quests/QuestDef.h @@ -176,30 +176,6 @@ enum QuestSpecialFlags QUEST_SPECIAL_FLAGS_PLAYER_KILL = 0x800 // Internal flag computed only }; -struct QuestLocale -{ - QuestLocale() { ObjectiveText.resize(QUEST_OBJECTIVES_COUNT); } - - std::vector Title; - std::vector Details; - std::vector Objectives; - std::vector OfferRewardText; - std::vector RequestItemsText; - std::vector AreaDescription; - std::vector CompletedText; - std::vector< std::vector > ObjectiveText; -}; - -struct QuestRequestItemsLocale -{ - std::vector CompletionText; -}; - -struct QuestOfferRewardLocale -{ - std::vector RewardText; -}; - // This Quest class provides a convenient way to access a few pretotaled (cached) quest details, // all base quest information, and any utility functions such as generating the amount of // xp to give diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp index c07b31b6da1cb3..caf36b142c5499 100644 --- a/src/server/game/Server/WorldSession.cpp +++ b/src/server/game/Server/WorldSession.cpp @@ -25,6 +25,7 @@ #include "CharacterPackets.h" #include "Common.h" #include "DatabaseEnv.h" +#include "GameLocale.h" #include "GameTime.h" #include "Group.h" #include "Guild.h" @@ -723,8 +724,8 @@ bool WorldSession::ValidateHyperlinksAndMaybeKick(std::string_view str) if (Acore::Hyperlinks::CheckAllLinks(str)) return true; - LOG_ERROR("network", "Player {}{} sent a message with an invalid link:\n%.*s", GetPlayer()->GetName(), - GetPlayer()->GetGUID().ToString(), STRING_VIEW_FMT_ARG(str)); + LOG_ERROR("network", "Player {}{} sent a message with an invalid link:\n{}", GetPlayer()->GetName(), + GetPlayer()->GetGUID().ToString(), str); if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK)) KickPlayer("WorldSession::ValidateHyperlinksAndMaybeKick Invalid chat link"); @@ -737,8 +738,8 @@ bool WorldSession::DisallowHyperlinksAndMaybeKick(std::string_view str) if (str.find('|') == std::string_view::npos) return true; - LOG_ERROR("network", "Player {} {} sent a message which illegally contained a hyperlink:\n%.*s", GetPlayer()->GetName(), - GetPlayer()->GetGUID().ToString(), STRING_VIEW_FMT_ARG(str)); + LOG_ERROR("network", "Player {} {} sent a message which illegally contained a hyperlink:\n{}", GetPlayer()->GetName(), + GetPlayer()->GetGUID().ToString(), str); if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK)) KickPlayer("WorldSession::DisallowHyperlinksAndMaybeKick Illegal chat link"); @@ -746,44 +747,9 @@ bool WorldSession::DisallowHyperlinksAndMaybeKick(std::string_view str) return false; } -void WorldSession::SendNotification(const char* format, ...) +std::string WorldSession::GetAcoreString(uint32 entry) const { - if (format) - { - va_list ap; - char szStr[1024]; - szStr[0] = '\0'; - va_start(ap, format); - vsnprintf(szStr, 1024, format, ap); - va_end(ap); - - WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr) + 1)); - data << szStr; - SendPacket(&data); - } -} - -void WorldSession::SendNotification(uint32 string_id, ...) -{ - char const* format = GetAcoreString(string_id); - if (format) - { - va_list ap; - char szStr[1024]; - szStr[0] = '\0'; - va_start(ap, string_id); - vsnprintf(szStr, 1024, format, ap); - va_end(ap); - - WorldPacket data(SMSG_NOTIFICATION, (strlen(szStr) + 1)); - data << szStr; - SendPacket(&data); - } -} - -char const* WorldSession::GetAcoreString(uint32 entry) const -{ - return sObjectMgr->GetAcoreString(entry, GetSessionDbLocaleIndex()); + return sGameLocale->GetAcoreString(entry, GetSessionDbLocaleIndex()); } void WorldSession::Handle_NULL(WorldPacket& null) diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 520805264b2547..1018efc1099975 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -323,11 +323,8 @@ class WorldSession void WriteMovementInfo(WorldPacket* data, MovementInfo* mi); void SendPacket(WorldPacket const* packet); - void SendNotification(const char* format, ...) ATTR_PRINTF(2, 3); - void SendNotification(uint32 string_id, ...); void SendPetNameInvalid(uint32 error, std::string const& name, DeclinedName* declinedName); void SendPartyResult(PartyOperation operation, std::string const& member, PartyResult res, uint32 val = 0); - void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2, 3); void SendSetPhaseShift(uint32 phaseShift); void SendQueryTimeResponse(); @@ -474,7 +471,7 @@ class WorldSession // Locales LocaleConstant GetSessionDbcLocale() const { return m_sessionDbcLocale; } LocaleConstant GetSessionDbLocaleIndex() const { return m_sessionDbLocaleIndex; } - char const* GetAcoreString(uint32 entry) const; + std::string GetAcoreString(uint32 entry) const; uint32 GetLatency() const { return m_latency; } void SetLatency(uint32 latency) { m_latency = latency; } diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 5556bade2b2953..cad93882f2968a 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -22,6 +22,7 @@ #include "BattlegroundSA.h" #include "BattlegroundWS.h" #include "CellImpl.h" +#include "ChatTextBuilder.h" #include "Common.h" #include "Creature.h" #include "DynamicObject.h" @@ -6322,7 +6323,7 @@ void Spell::EffectPlaySound(SpellEffIndex effIndex) { case 58730: // Restricted Flight Area case 58600: // Restricted Flight Area - player->GetSession()->SendNotification(LANG_ZONE_NOFLYZONE); + Acore::Text::SendNotification(player->GetSession(), LANG_ZONE_NOFLYZONE); break; default: break; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index d22ebff47f6a28..63e50cbae45071 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -26,12 +26,12 @@ #include "MapMgr.h" #include "ObjectMgr.h" #include "Player.h" +#include "ScriptMgr.h" #include "SharedDefines.h" #include "Spell.h" #include "SpellAuraDefines.h" #include "SpellAuras.h" #include "SpellInfo.h" -#include "ScriptMgr.h" #include "World.h" bool IsPrimaryProfessionSkill(uint32 skill) diff --git a/src/server/game/Texts/ChatTextBuilder.cpp b/src/server/game/Texts/ChatTextBuilder.cpp index 79f27913c4439c..1304d588108f30 100644 --- a/src/server/game/Texts/ChatTextBuilder.cpp +++ b/src/server/game/Texts/ChatTextBuilder.cpp @@ -16,46 +16,189 @@ */ #include "ChatTextBuilder.h" +#include "Battleground.h" #include "Chat.h" -#include "ObjectMgr.h" -#include +#include "Player.h" +#include "PlayerSettings.h" +#include "Tokenize.h" +#include "World.h" +#include "WorldSession.h" -void Acore::BroadcastTextBuilder::operator()(WorldPacket& data, LocaleConstant locale) const +namespace { - BroadcastText const* bct = sObjectMgr->GetBroadcastText(_textId); - ChatHandler::BuildChatPacket(data, _msgType, bct ? Language(bct->LanguageID) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale); + void SendPlayerMessage(Player* player, ChatMsg type, std::string_view message) + { + for (std::string_view line : Acore::Tokenize(message, '\n', true)) + { + WorldPacket data; + ChatHandler::BuildChatPacket(data, type, LANG_UNIVERSAL, nullptr, nullptr, line); + player->SendDirectMessage(&data); + } + } + + // Default send message + void SendPlayerMessage(Player* player, std::string_view message) + { + SendPlayerMessage(player, CHAT_MSG_SYSTEM, message); + } } -size_t Acore::BroadcastTextBuilder::operator()(WorldPacket* data, LocaleConstant locale) const +void Acore::Text::SendWorldTextFmt(AcoreFmtText const& msg) { - BroadcastText const* bct = sObjectMgr->GetBroadcastText(_textId); - return ChatHandler::BuildChatPacket(*data, _msgType, bct ? Language(bct->LanguageID) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale); + if (!msg) + { + //LOG_ERROR("", "> SendWorldText. Empty message. Skip"); + return; + } + + for (auto const& [accountID, session] : sWorld->GetAllSessions()) + { + Player* player = session->GetPlayer(); + if (!player || !player->IsInWorld()) + { + return; + } + + SendPlayerMessage(player, msg(player->GetSession()->GetSessionDbLocaleIndex())); + } } -void Acore::CustomChatTextBuilder::operator()(WorldPacket& data, LocaleConstant locale) const +void Acore::Text::SendWorldTextOptionalFmt(AcoreFmtText const& msg, uint32 flag) { - ChatHandler::BuildChatPacket(data, _msgType, _language, _source, _target, _text, 0, "", locale); + if (!msg) + { + //LOG_ERROR("", "> SendWorldTextOptionalFmt. Empty message. Skip"); + return; + } + + for (auto const& [accountID, session] : sWorld->GetAllSessions()) + { + Player* player = session->GetPlayer(); + if (!player || !player->IsInWorld()) + { + return; + } + + if (sWorld->getBoolConfig(CONFIG_PLAYER_SETTINGS_ENABLED) && player->GetPlayerSetting(AzerothcorePSSource, SETTING_ANNOUNCER_FLAGS).HasFlag(flag)) + { + continue; + } + + SendPlayerMessage(player, msg(player->GetSession()->GetSessionDbLocaleIndex())); + } } -void Acore::AcoreStringChatBuilder::operator()(WorldPacket& data, LocaleConstant locale) const +void Acore::Text::SendGMTextFmt(AcoreFmtText const& msg) { - char const* text = sObjectMgr->GetAcoreString(_textId, locale); + if (!msg) + { + //LOG_ERROR("", "> SendGMText. Empty message. Skip"); + return; + } + + for (auto const& [accountID, session] : sWorld->GetAllSessions()) + { + Player* player = session->GetPlayer(); + if (!player || !player->IsInWorld()) + { + return; + } + + if (AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity())) + { + continue; + } + + SendPlayerMessage(player, msg(player->GetSession()->GetSessionDbLocaleIndex())); + } +} - if (_args) +void Acore::Text::SendBattlegroundWarningToAllFmt(Battleground* bg, AcoreFmtText const& msg) +{ + if (!bg) { - // we need copy va_list before use or original va_list will corrupted - va_list ap; - va_copy(ap, *_args); + return; + } - static size_t const BufferSize = 2048; - char strBuffer[BufferSize]; - vsnprintf(strBuffer, BufferSize, text, ap); - va_end(ap); + for (auto const& itr : bg->GetPlayers()) + { + SendPlayerMessage(itr.second, CHAT_MSG_RAID_BOSS_EMOTE, msg(itr.second->GetSession()->GetSessionDbLocaleIndex())); + } +} - ChatHandler::BuildChatPacket(data, _msgType, LANG_UNIVERSAL, _source, _target, strBuffer, 0, "", locale); +void Acore::Text::SendBattlegroundMessageToAllFmt(Battleground* bg, ChatMsg type, AcoreFmtText const& msg) +{ + if (!bg) + { + return; } - else + + for (auto const& itr : bg->GetPlayers()) { - ChatHandler::BuildChatPacket(data, _msgType, LANG_UNIVERSAL, _source, _target, text, 0, "", locale); + SendPlayerMessage(itr.second, type, msg(itr.second->GetSession()->GetSessionDbLocaleIndex())); } } + +void Acore::Text::SendNotificationFmt(AcoreFmtText const& msg, WorldSession* session) +{ + if (!msg) + { + //LOG_ERROR("", "> SendWorldText. Empty message. Skip"); + return; + } + + SendNotification(session, msg(session->GetSessionDbLocaleIndex())); +} + +void Acore::Text::SendAreaTriggerMessageFmt(AcoreFmtText const& msg, WorldSession* session) +{ + if (!msg) + { + //LOG_ERROR("", "> SendWorldText. Empty message. Skip"); + return; + } + + SendAreaTriggerMessage(session, msg(session->GetSessionDbLocaleIndex())); +} + +void Acore::Text::SendNotification(WorldSession* session, std::string_view text) +{ + WorldPacket data(SMSG_NOTIFICATION, text.size() + 1); + data << text; + session->SendPacket(&data); +} + +void Acore::Text::SendNotification(WorldSession* session, uint32 stringID) +{ + SendNotification(session, sGameLocale->GetAcoreString(stringID, session->GetSessionDbLocaleIndex())); +} + +void Acore::Text::SendAreaTriggerMessage(WorldSession* session, std::string_view text) +{ + WorldPacket data(SMSG_AREA_TRIGGER_MESSAGE, 4 + text.size()); + data << uint32(text.size()); + data << text; + session->SendPacket(&data); +} + +void Acore::Text::SendAreaTriggerMessage(WorldSession* session, uint32 stringID) +{ + SendAreaTriggerMessage(session, sGameLocale->GetAcoreString(stringID, session->GetSessionDbLocaleIndex())); +} + +void Acore::BroadcastTextBuilder::operator()(WorldPacket& data, LocaleConstant locale) const +{ + BroadcastText const* bct = sGameLocale->GetBroadcastText(_textId); + ChatHandler::BuildChatPacket(data, _msgType, bct ? Language(bct->LanguageID) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale); +} + +size_t Acore::BroadcastTextBuilder::operator()(WorldPacket* data, LocaleConstant locale) const +{ + BroadcastText const* bct = sGameLocale->GetBroadcastText(_textId); + return ChatHandler::BuildChatPacket(*data, _msgType, bct ? Language(bct->LanguageID) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale); +} + +void Acore::CustomChatTextBuilder::operator()(WorldPacket& data, LocaleConstant locale) const +{ + ChatHandler::BuildChatPacket(data, _msgType, _language, _source, _target, _text, 0, "", locale); +} diff --git a/src/server/game/Texts/ChatTextBuilder.h b/src/server/game/Texts/ChatTextBuilder.h index ec1fce7d72ba5e..f63126fd7b1ed7 100644 --- a/src/server/game/Texts/ChatTextBuilder.h +++ b/src/server/game/Texts/ChatTextBuilder.h @@ -18,65 +18,157 @@ #ifndef __CHATTEXT_BUILDER_H #define __CHATTEXT_BUILDER_H -#include "Common.h" -#include "SharedDefines.h" -#include +#include "GameLocale.h" +#include "StringFormat.h" +#include +class Battleground; class WorldObject; class WorldPacket; +class WorldSession; + +namespace Acore::Text +{ + using AcoreFmtText = std::function; + + // Get localized message + template + inline std::string GetLocaleMessage(uint8 localeIndex, uint32 id, Args&&... args) + { + return StringFormatFmt(sGameLocale->GetAcoreString(id, LocaleConstant(localeIndex)), std::forward(args)...); + } + + // Helper fmt functions + void SendWorldTextFmt(AcoreFmtText const& msg); + void SendWorldTextOptionalFmt(AcoreFmtText const& msg, uint32 flag); + void SendGMTextFmt(AcoreFmtText const& msg); + void SendNotificationFmt(AcoreFmtText const& msg, WorldSession* session); + void SendAreaTriggerMessageFmt(AcoreFmtText const& msg, WorldSession* session); + void SendBattlegroundWarningToAllFmt(Battleground* bg, AcoreFmtText const& msg); + void SendBattlegroundMessageToAllFmt(Battleground* bg, ChatMsg type, AcoreFmtText const& msg); + + // Helper default functions + void SendNotification(WorldSession* session, std::string_view text); + void SendNotification(WorldSession* session, uint32 stringID); + void SendAreaTriggerMessage(WorldSession* session, std::string_view text); + void SendAreaTriggerMessage(WorldSession* session, uint32 stringID); + + // Send a System Message to all players (except self if mentioned) + template + inline void SendWorldText(uint32 id, Args&&... args) + { + SendWorldTextFmt([&](uint8 localeIndex) + { + return GetLocaleMessage(localeIndex, id, std::forward(args)...); + }); + } + + // Send a optional System Message to all players (except self if mentioned) + template + inline void SendWorldTextOptional(uint32 id, uint32 flag, Args&&... args) + { + SendWorldTextOptionalFmt([&](uint8 localeIndex) + { + return GetLocaleMessage(localeIndex, id, std::forward(args)...); + }, flag); + } + + // Send a System Message to all GMs (except self if mentioned) + template + inline void SendGMText(uint32 id, Args&&... args) + { + SendGMTextFmt([&](uint8 localeIndex) + { + return GetLocaleMessage(localeIndex, id, std::forward(args)...); + }); + } + + // Send a Battleground warning message to all players + template + inline void SendBattlegroundWarningToAll(Battleground* bg, uint32 id, Args&&... args) + { + SendBattlegroundWarningToAllFmt(bg, [&](uint8 localeIndex) + { + return GetLocaleMessage(localeIndex, id, std::forward(args)...); + }); + } + + // Send a Battleground with type message to all players + template + inline void SendBattlegroundMessageToAll(Battleground* bg, ChatMsg type, uint32 id, Args&&... args) + { + SendBattlegroundMessageToAllFmt(bg, type, [&](uint8 localeIndex) + { + return GetLocaleMessage(localeIndex, id, std::forward(args)...); + }); + } + + template + inline void SendNotification(WorldSession* session, std::string_view fmt, Args&&... args) + { + SendNotification(session, StringFormatFmt(fmt, std::forward(args)...)); + } + + template + inline void SendNotification(WorldSession* session, uint32 stringID, Args&&... args) + { + SendNotificationFmt([&](uint8 localeIndex) + { + return GetLocaleMessage(localeIndex, stringID, std::forward(args)...); + }, session); + } + + template + inline void SendAreaTriggerMessage(WorldSession* session, std::string_view fmt, Args&&... args) + { + SendAreaTriggerMessage(session, StringFormatFmt(fmt, std::forward(args)...)); + } + + template + inline void SendAreaTriggerMessage(WorldSession* session, uint32 stringID, Args&&... args) + { + SendAreaTriggerMessageFmt([&](uint8 localeIndex) + { + return GetLocaleMessage(localeIndex, stringID, std::forward(args)...); + }, session); + } +} namespace Acore { class BroadcastTextBuilder { - public: - BroadcastTextBuilder(WorldObject const* obj, ChatMsg msgType, uint32 textId, uint8 gender, WorldObject const* target = nullptr, uint32 achievementId = 0) - : _source(obj), _msgType(msgType), _textId(textId), _gender(gender), _target(target), _achievementId(achievementId) { } - - void operator()(WorldPacket& data, LocaleConstant locale) const; - size_t operator()(WorldPacket* data, LocaleConstant locale) const; - - private: - WorldObject const* _source; - ChatMsg _msgType; - uint32 _textId; - uint8 _gender; - WorldObject const* _target; - uint32 _achievementId; + public: + BroadcastTextBuilder(WorldObject const* obj, ChatMsg msgType, uint32 textId, uint8 gender, WorldObject const* target = nullptr, uint32 achievementId = 0) + : _source(obj), _msgType(msgType), _textId(textId), _gender(gender), _target(target), _achievementId(achievementId) { } + + void operator()(WorldPacket& data, LocaleConstant locale) const; + size_t operator()(WorldPacket* data, LocaleConstant locale) const; + + private: + WorldObject const* _source; + ChatMsg _msgType; + uint32 _textId; + uint8 _gender; + WorldObject const* _target; + uint32 _achievementId; }; class CustomChatTextBuilder { - public: - CustomChatTextBuilder(WorldObject const* obj, ChatMsg msgType, std::string_view text, Language language = LANG_UNIVERSAL, WorldObject const* target = nullptr) - : _source(obj), _msgType(msgType), _text(text), _language(language), _target(target) { } - - void operator()(WorldPacket& data, LocaleConstant locale) const; - - private: - WorldObject const* _source; - ChatMsg _msgType; - std::string _text; - Language _language; - WorldObject const* _target; - }; + public: + CustomChatTextBuilder(WorldObject const* obj, ChatMsg msgType, std::string_view text, Language language = LANG_UNIVERSAL, WorldObject const* target = nullptr) + : _source(obj), _msgType(msgType), _text(text), _language(language), _target(target) { } - class AcoreStringChatBuilder - { - public: - AcoreStringChatBuilder(WorldObject const* obj, ChatMsg msgType, uint32 textId, WorldObject const* target = nullptr, va_list* args = nullptr) - : _source(obj), _msgType(msgType), _textId(textId), _target(target), _args(args) { } - - void operator()(WorldPacket& data, LocaleConstant locale) const; - - private: - WorldObject const* _source; - ChatMsg _msgType; - uint32 _textId; - WorldObject const* _target; - va_list* _args; + void operator()(WorldPacket& data, LocaleConstant locale) const; + + private: + WorldObject const* _source; + ChatMsg _msgType; + std::string _text; + Language _language; + WorldObject const* _target; }; } -// namespace Acore #endif // __CHATTEXT_BUILDER_H diff --git a/src/server/game/Texts/CreatureTextMgr.cpp b/src/server/game/Texts/CreatureTextMgr.cpp index eda2f978df479b..5728a0a0d85ecf 100644 --- a/src/server/game/Texts/CreatureTextMgr.cpp +++ b/src/server/game/Texts/CreatureTextMgr.cpp @@ -21,8 +21,10 @@ #include "Chat.h" #include "Common.h" #include "DatabaseEnv.h" +#include "GameLocale.h" #include "GridNotifiers.h" #include "GridNotifiersImpl.h" +#include "LocaleCommon.h" #include "ObjectMgr.h" class CreatureTextBuilder @@ -143,7 +145,7 @@ void CreatureTextMgr::LoadCreatureTexts() } if (temp.BroadcastTextId) { - if (!sObjectMgr->GetBroadcastText(temp.BroadcastTextId)) + if (!sGameLocale->GetBroadcastText(temp.BroadcastTextId)) { LOG_ERROR("sql.sql", "CreatureTextMgr: Entry {}, Group {}, Id {} in table `creature_text` has non-existing or incompatible BroadcastTextId {}.", temp.entry, temp.group, temp.id, temp.BroadcastTextId); temp.BroadcastTextId = 0; @@ -189,7 +191,7 @@ void CreatureTextMgr::LoadCreatureTextLocales() continue; CreatureTextLocale& data = mLocaleTextMap[CreatureTextId(CreatureId, GroupId, ID)]; - ObjectMgr::AddLocaleString(fields[4].Get(), locale, data.Text); + Acore::Locale::AddLocaleString(fields[4].Get(), locale, data.Text); } while (result->NextRow()); LOG_INFO("server.loading", ">> Loaded {} Creature Text Locale in {} ms", uint32(mLocaleTextMap.size()), GetMSTimeDiffToNow(oldMSTime)); @@ -486,7 +488,7 @@ std::string CreatureTextMgr::GetLocalizedChatString(uint32 entry, uint8 gender, std::string baseText = ""; - BroadcastText const* bct = sObjectMgr->GetBroadcastText(groupItr->BroadcastTextId); + BroadcastText const* bct = sGameLocale->GetBroadcastText(groupItr->BroadcastTextId); if (bct) baseText = bct->GetText(locale, gender); else @@ -496,7 +498,7 @@ std::string CreatureTextMgr::GetLocalizedChatString(uint32 entry, uint8 gender, { LocaleCreatureTextMap::const_iterator locItr = mLocaleTextMap.find(CreatureTextId(entry, uint32(textGroup), id)); if (locItr != mLocaleTextMap.end()) - ObjectMgr::GetLocaleString(locItr->second.Text, locale, baseText); + GameLocale::GetLocaleString(locItr->second.Text, locale, baseText); } return baseText; diff --git a/src/server/game/Tickets/TicketMgr.cpp b/src/server/game/Tickets/TicketMgr.cpp index 6cf59cba4a861c..1874ab3467668e 100644 --- a/src/server/game/Tickets/TicketMgr.cpp +++ b/src/server/game/Tickets/TicketMgr.cpp @@ -407,7 +407,7 @@ void TicketMgr::ShowList(ChatHandler& handler, bool onlineOnly) const for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr) if (!itr->second->IsClosed() && !itr->second->IsCompleted()) if (!onlineOnly || itr->second->GetPlayer()) - handler.SendSysMessage(itr->second->FormatMessageString(handler).c_str()); + handler.SendSysMessage(itr->second->FormatMessageString(handler)); } void TicketMgr::ShowClosedList(ChatHandler& handler) const @@ -415,7 +415,7 @@ void TicketMgr::ShowClosedList(ChatHandler& handler) const handler.SendSysMessage(LANG_COMMAND_TICKETSHOWCLOSEDLIST); for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr) if (itr->second->IsClosed()) - handler.SendSysMessage(itr->second->FormatMessageString(handler).c_str()); + handler.SendSysMessage(itr->second->FormatMessageString(handler)); } void TicketMgr::ShowEscalatedList(ChatHandler& handler) const @@ -423,7 +423,7 @@ void TicketMgr::ShowEscalatedList(ChatHandler& handler) const handler.SendSysMessage(LANG_COMMAND_TICKETSHOWESCALATEDLIST); for (GmTicketList::const_iterator itr = _ticketList.begin(); itr != _ticketList.end(); ++itr) if (!itr->second->IsClosed() && itr->second->GetEscalatedStatus() == TICKET_IN_ESCALATION_QUEUE) - handler.SendSysMessage(itr->second->FormatMessageString(handler).c_str()); + handler.SendSysMessage(itr->second->FormatMessageString(handler)); } void TicketMgr::SendTicket(WorldSession* session, GmTicket* ticket) const diff --git a/src/server/game/Tools/PlayerDump.h b/src/server/game/Tools/PlayerDump.h index 493b6da85d77a0..209ac5742c8e2e 100644 --- a/src/server/game/Tools/PlayerDump.h +++ b/src/server/game/Tools/PlayerDump.h @@ -18,11 +18,11 @@ #ifndef _PLAYER_DUMP_H #define _PLAYER_DUMP_H -#include +#include "ObjectGuid.h" #include #include #include -#include "ObjectGuid.h" +#include enum DumpTableType { diff --git a/src/server/game/World/IWorld.h b/src/server/game/World/IWorld.h index c23544c2da52f9..c660f1c6fc6061 100644 --- a/src/server/game/World/IWorld.h +++ b/src/server/game/World/IWorld.h @@ -499,7 +499,6 @@ class IWorld [[nodiscard]] virtual WorldSession* FindOfflineSession(uint32 id) const = 0; [[nodiscard]] virtual WorldSession* FindOfflineSessionForCharacterGUID(ObjectGuid::LowType guidLow) const = 0; virtual void AddSession(WorldSession* s) = 0; - virtual void SendAutoBroadcast() = 0; virtual bool KickSession(uint32 id) = 0; virtual void UpdateMaxSessionCounters() = 0; [[nodiscard]] virtual const SessionMap& GetAllSessions() const = 0; @@ -536,10 +535,7 @@ 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 SendGlobalText(const char* text, WorldSession* self) = 0; - virtual void SendGMText(uint32 string_id, ...) = 0; + virtual void SendGlobalText(std::string_view text, WorldSession* self) = 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 bool SendZoneMessage(uint32 zone, WorldPacket const* packet, WorldSession* self = nullptr, TeamId teamId = TEAM_NEUTRAL) = 0; @@ -579,7 +575,6 @@ class IWorld [[nodiscard]] virtual char const* GetWorldDBRevision() const = 0; [[nodiscard]] virtual char const* GetCharacterDBRevision() const = 0; [[nodiscard]] virtual char const* GetAuthDBRevision() const = 0; - virtual void LoadAutobroadcasts() = 0; virtual void UpdateAreaDependentAuras() = 0; [[nodiscard]] virtual uint32 GetCleaningFlags() const = 0; virtual void SetCleaningFlags(uint32 flags) = 0; diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index cd2aaf45af3ede..72400cc7f059d3 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -26,6 +26,7 @@ #include "ArenaTeamMgr.h" #include "AsyncAuctionListing.h" #include "AuctionHouseMgr.h" +#include "Autobroadcast.h" #include "BattlefieldMgr.h" #include "BattlegroundMgr.h" #include "CalendarMgr.h" @@ -46,6 +47,7 @@ #include "DynamicVisibility.h" #include "GameEventMgr.h" #include "GameGraveyard.h" +#include "GameLocale.h" #include "GameTime.h" #include "GitRevision.h" #include "GridNotifiersImpl.h" @@ -78,6 +80,7 @@ #include "SpellMgr.h" #include "TaskScheduler.h" #include "TicketMgr.h" +#include "Tokenize.h" #include "Transport.h" #include "TransportMgr.h" #include "UpdateTime.h" @@ -1499,7 +1502,7 @@ void World::SetInitialWorldSettings() ///- Loading strings. Getting no records means core load has to be canceled because no error message can be output. LOG_INFO("server.loading", " "); LOG_INFO("server.loading", "Loading acore strings..."); - if (!sObjectMgr->LoadAcoreStrings()) + if (!sGameLocale->LoadAcoreStrings()) exit(1); // Error message displayed in function already ///- Update the realm entry in the database with the realm type from the config file @@ -1578,27 +1581,8 @@ void World::SetInitialWorldSettings() LOG_INFO("server.loading", "Loading instances..."); sInstanceSaveMgr->LoadInstances(); - LOG_INFO("server.loading", "Loading Broadcast texts..."); - sObjectMgr->LoadBroadcastTexts(); - sObjectMgr->LoadBroadcastTextLocales(); - - LOG_INFO("server.loading", "Loading Localization strings..."); - uint32 oldMSTime = getMSTime(); - sObjectMgr->LoadCreatureLocales(); - sObjectMgr->LoadGameObjectLocales(); - sObjectMgr->LoadItemLocales(); - sObjectMgr->LoadItemSetNameLocales(); - sObjectMgr->LoadQuestLocales(); - sObjectMgr->LoadQuestOfferRewardLocale(); - sObjectMgr->LoadQuestRequestItemsLocale(); - sObjectMgr->LoadNpcTextLocales(); - sObjectMgr->LoadPageTextLocales(); - sObjectMgr->LoadGossipMenuItemsLocales(); - sObjectMgr->LoadPointOfInterestLocales(); - - sObjectMgr->SetDBCLocaleIndex(GetDefaultDbcLocale()); // Get once for all the locale index of DBC language (console/broadcasts) - LOG_INFO("server.loading", ">> Localization strings loaded in {} ms", GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); + LOG_INFO("server.loading", "Loading Game locale texts..."); + sGameLocale->LoadAllLocales(); LOG_INFO("server.loading", "Loading Page Texts..."); sObjectMgr->LoadPageTexts(); @@ -1833,20 +1817,23 @@ void World::SetInitialWorldSettings() LOG_INFO("server.loading", "Loading Achievements..."); sAchievementMgr->LoadAchievementReferenceList(); + LOG_INFO("server.loading", "Loading Achievement Criteria Lists..."); sAchievementMgr->LoadAchievementCriteriaList(); + LOG_INFO("server.loading", "Loading Achievement Criteria Data..."); sAchievementMgr->LoadAchievementCriteriaData(); + LOG_INFO("server.loading", "Loading Achievement Rewards..."); sAchievementMgr->LoadRewards(); - LOG_INFO("server.loading", "Loading Achievement Reward Locales..."); - sAchievementMgr->LoadRewardLocales(); + LOG_INFO("server.loading", "Loading Completed Achievements..."); sAchievementMgr->LoadCompletedAchievements(); ///- Load dynamic data tables from the database LOG_INFO("server.loading", "Loading Item Auctions..."); sAuctionMgr->LoadAuctionItems(); + LOG_INFO("server.loading", "Loading Auctions..."); sAuctionMgr->LoadAuctions(); @@ -1938,7 +1925,7 @@ void World::SetInitialWorldSettings() ///- Load AutoBroadCast LOG_INFO("server.loading", "Loading Autobroadcasts..."); - LoadAutobroadcasts(); + sAutobroadcastMgr->Load(); ///- Load and initialize scripts sObjectMgr->LoadSpellScripts(); // must be after load Creature/Gameobject(Template/Data) @@ -2171,41 +2158,6 @@ void World::DetectDBCLang() LOG_INFO("server.loading", " "); } -void World::LoadAutobroadcasts() -{ - uint32 oldMSTime = getMSTime(); - - m_Autobroadcasts.clear(); - m_AutobroadcastsWeights.clear(); - - uint32 realmId = sConfigMgr->GetOption("RealmID", 0); - LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_AUTOBROADCAST); - stmt->SetData(0, realmId); - PreparedQueryResult result = LoginDatabase.Query(stmt); - - if (!result) - { - LOG_INFO("server.loading", ">> Loaded 0 autobroadcasts definitions. DB table `autobroadcast` is empty for this realm!"); - return; - } - - uint32 count = 0; - - do - { - Field* fields = result->Fetch(); - uint8 id = fields[0].Get(); - - m_Autobroadcasts[id] = fields[2].Get(); - m_AutobroadcastsWeights[id] = fields[1].Get(); - - ++count; - } while (result->NextRow()); - - LOG_INFO("server.loading", ">> Loaded {} autobroadcast definitions in {} ms", count, GetMSTimeDiffToNow(oldMSTime)); - LOG_INFO("server.loading", " "); -} - /// Update the World ! void World::Update(uint32 diff) { @@ -2365,7 +2317,7 @@ void World::Update(uint32 diff) { METRIC_TIMER("world_update_time", METRIC_TAG("type", "Send autobroadcast")); m_timers[WUPDATE_AUTOBROADCAST].Reset(); - SendAutoBroadcast(); + sAutobroadcastMgr->Send(); } } @@ -2525,7 +2477,7 @@ namespace Acore explicit WorldWorldTextBuilder(uint32 textId, va_list* args = nullptr) : i_textId(textId), i_args(args) {} void operator()(WorldPacketList& data_list, LocaleConstant loc_idx) { - char const* text = sObjectMgr->GetAcoreString(i_textId, loc_idx); + char const* text = sGameLocale->GetAcoreString(i_textId, loc_idx); if (i_args) { @@ -2560,91 +2512,16 @@ 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 = m_sessions.begin(); itr != m_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 : m_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, ...) -{ - va_list ap; - va_start(ap, string_id); - - Acore::WorldWorldTextBuilder wt_builder(string_id, &ap); - Acore::LocalizedPacketListDo wt_do(wt_builder); - for (SessionMap::iterator itr = m_sessions.begin(); itr != m_sessions.end(); ++itr) - { - if (!itr->second || !itr->second->GetPlayer() || !itr->second->GetPlayer()->IsInWorld()) - continue; - - if (AccountMgr::IsPlayerAccount(itr->second->GetSecurity())) - continue; - - wt_do(itr->second->GetPlayer()); - } - - va_end(ap); -} - /// DEPRECATED, only for debug purpose. Send a System Message to all players (except self if mentioned) -void World::SendGlobalText(const char* text, WorldSession* self) +void World::SendGlobalText(std::string_view text, WorldSession* self) { WorldPacket data; - // need copy to prevent corruption by strtok call in LineFromMessage original string - char* buf = strdup(text); - char* pos = buf; - - while (char* line = ChatHandler::LineFromMessage(pos)) + for (std::string_view line : Acore::Tokenize(text, '\n', true)) { ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, line); SendGlobalMessage(&data, self); } - - free(buf); } /// Send a packet to all players (or players selected team) in the zone (except self if mentioned) @@ -2945,68 +2822,6 @@ void World::ProcessCliCommands() } } -void World::SendAutoBroadcast() -{ - if (m_Autobroadcasts.empty()) - return; - - uint32 weight = 0; - AutobroadcastsWeightMap selectionWeights; - - std::string msg; - - for (AutobroadcastsWeightMap::const_iterator it = m_AutobroadcastsWeights.begin(); it != m_AutobroadcastsWeights.end(); ++it) - { - if (it->second) - { - weight += it->second; - selectionWeights[it->first] = it->second; - } - } - - if (weight) - { - uint32 selectedWeight = urand(0, weight - 1); - weight = 0; - for (AutobroadcastsWeightMap::const_iterator it = selectionWeights.begin(); it != selectionWeights.end(); ++it) - { - weight += it->second; - if (selectedWeight < weight) - { - msg = m_Autobroadcasts[it->first]; - break; - } - } - } - else - msg = m_Autobroadcasts[urand(0, m_Autobroadcasts.size())]; - - uint32 abcenter = sWorld->getIntConfig(CONFIG_AUTOBROADCAST_CENTER); - - if (abcenter == 0) - { - sWorld->SendWorldTextOptional(LANG_AUTO_BROADCAST, ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST, msg.c_str()); - } - - else if (abcenter == 1) - { - WorldPacket data(SMSG_NOTIFICATION, (msg.size() + 1)); - data << msg; - sWorld->SendGlobalMessage(&data); - } - - else if (abcenter == 2) - { - sWorld->SendWorldTextOptional(LANG_AUTO_BROADCAST, ANNOUNCER_FLAG_DISABLE_AUTOBROADCAST, msg.c_str()); - - WorldPacket data(SMSG_NOTIFICATION, (msg.size() + 1)); - data << msg; - sWorld->SendGlobalMessage(&data); - } - - LOG_DEBUG("server.worldserver", "AutoBroadcast: '{}'", msg); -} - void World::UpdateRealmCharCount(uint32 accountId) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_COUNT); diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 423bba6691b72c..6113857116e180 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -163,7 +163,6 @@ class World: public IWorld [[nodiscard]] WorldSession* FindOfflineSession(uint32 id) const override; [[nodiscard]] WorldSession* FindOfflineSessionForCharacterGUID(ObjectGuid::LowType guidLow) const override; void AddSession(WorldSession* s) override; - void SendAutoBroadcast() override; bool KickSession(uint32 id) override; /// Get the number of current active sessions void UpdateMaxSessionCounters() override; @@ -241,17 +240,13 @@ class World: public IWorld void SetInitialWorldSettings() override; void LoadConfigSettings(bool reload = false) override; - void SendWorldText(uint32 string_id, ...) override; - void SendGlobalText(const char* text, WorldSession* self) override; - void SendGMText(uint32 string_id, ...) override; + void SendGlobalText(std::string_view text, WorldSession* self) 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; bool SendZoneMessage(uint32 zone, WorldPacket const* packet, 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 SendWorldTextOptional(uint32 string_id, uint32 flag, ...) override; - /// Are we in the middle of a shutdown? [[nodiscard]] bool IsShuttingDown() const override { return m_ShutdownTimer > 0; } [[nodiscard]] uint32 GetShutDownTimeLeft() const override { return m_ShutdownTimer; } @@ -345,8 +340,6 @@ class World: public IWorld [[nodiscard]] char const* GetCharacterDBRevision() const override { return m_CharacterDBRevision.c_str(); } [[nodiscard]] char const* GetAuthDBRevision() const override { return m_AuthDBRevision.c_str(); } - void LoadAutobroadcasts() override; - void UpdateAreaDependentAuras() override; [[nodiscard]] uint32 GetCleaningFlags() const override { return m_CleaningFlags; } @@ -444,12 +437,6 @@ class World: public IWorld std::string m_CharacterDBRevision; std::string m_AuthDBRevision; - typedef std::map AutobroadcastsMap; - AutobroadcastsMap m_Autobroadcasts; - - typedef std::map AutobroadcastsWeightMap; - AutobroadcastsWeightMap m_AutobroadcastsWeights; - void ProcessQueryCallbacks(); QueryCallbackProcessor _queryProcessor; diff --git a/src/server/scripts/Commands/PlayerCommand.cpp b/src/server/scripts/Commands/PlayerCommand.cpp index 4e145300854766..5c5aef330cb6da 100644 --- a/src/server/scripts/Commands/PlayerCommand.cpp +++ b/src/server/scripts/Commands/PlayerCommand.cpp @@ -38,7 +38,7 @@ bool Acore::PlayerCommand::HandleLearnSpellCommand(ChatHandler* handler, Player* } else { - handler->PSendSysMessage(LANG_TARGET_KNOWN_SPELL, handler->GetNameLink(targetPlayer).c_str()); + handler->PSendSysMessage(LANG_TARGET_KNOWN_SPELL, handler->GetNameLink(targetPlayer)); } handler->SetSentErrorMessage(true); diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 1b042b11bdbc52..14935721764008 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -168,7 +168,7 @@ class account_commandscript : public CommandScript } // new suggestion, or no token specified, output TOTP parameters - handler->PSendSysMessage(LANG_2FA_SECRET_SUGGESTION, Acore::Encoding::Base32::Encode(pair.first->second).c_str()); + handler->PSendSysMessage(LANG_2FA_SECRET_SUGGESTION, Acore::Encoding::Base32::Encode(pair.first->second)); handler->SetSentErrorMessage(true); return false; } @@ -346,7 +346,7 @@ class account_commandscript : public CommandScript std::string accountName = account; if (!Utf8ToUpperOnlyLatin(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -354,7 +354,7 @@ class account_commandscript : public CommandScript uint32 accountId = AccountMgr::GetId(accountName); if (!accountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -369,18 +369,18 @@ class account_commandscript : public CommandScript switch (result) { case AOR_OK: - handler->PSendSysMessage(LANG_ACCOUNT_DELETED, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_DELETED, accountName); break; case AOR_NAME_NOT_EXIST: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; case AOR_DB_INTERNAL_ERROR: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED_SQL_ERROR, accountName); handler->SetSentErrorMessage(true); return false; default: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_DELETED, accountName); handler->SetSentErrorMessage(true); return false; } @@ -424,12 +424,12 @@ class account_commandscript : public CommandScript { Field* fieldsLogin = resultLogin->Fetch(); handler->PSendSysMessage(LANG_ACCOUNT_LIST_LINE, - fieldsLogin[0].Get().c_str(), name.c_str(), fieldsLogin[1].Get().c_str(), + fieldsLogin[0].Get(), name, fieldsLogin[1].Get(), fieldsDB[2].Get(), fieldsDB[3].Get(), fieldsLogin[3].Get(), fieldsLogin[2].Get()); } else - handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name); } while (result->NextRow()); handler->SendSysMessage(LANG_ACCOUNT_LIST_BAR); @@ -453,7 +453,7 @@ class account_commandscript : public CommandScript std::string accountName = _accountName; if (!Utf8ToUpperOnlyLatin(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -461,7 +461,7 @@ class account_commandscript : public CommandScript uint32 accountId = AccountMgr::GetId(accountName); if (!accountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -639,7 +639,7 @@ class account_commandscript : public CommandScript if (!Utf8ToUpperOnlyLatin(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -647,7 +647,7 @@ class account_commandscript : public CommandScript uint32 targetAccountId = AccountMgr::GetId(accountName); if (!targetAccountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -696,7 +696,7 @@ class account_commandscript : public CommandScript stmt->SetData(1, targetAccountId); LoginDatabase.Execute(stmt); - handler->PSendSysMessage(LANG_2FA_SECRET_SET_COMPLETE, accountName.c_str()); + handler->PSendSysMessage(LANG_2FA_SECRET_SET_COMPLETE, accountName); return true; } @@ -736,7 +736,7 @@ class account_commandscript : public CommandScript accountName = account; if (!Utf8ToUpperOnlyLatin(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -744,7 +744,7 @@ class account_commandscript : public CommandScript accountId = AccountMgr::GetId(accountName); if (!accountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -767,7 +767,7 @@ class account_commandscript : public CommandScript LoginDatabase.Execute(stmt); - handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName.c_str(), accountId, *expansion); + handler->PSendSysMessage(LANG_ACCOUNT_SETADDON, accountName, accountId, *expansion); return true; } @@ -802,7 +802,7 @@ class account_commandscript : public CommandScript targetAccountName = arg1; if (!Utf8ToUpperOnlyLatin(targetAccountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, targetAccountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, targetAccountName); handler->SetSentErrorMessage(true); return false; } @@ -890,7 +890,7 @@ class account_commandscript : public CommandScript LoginDatabase.Execute(stmt); } - handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName.c_str(), gm); + handler->PSendSysMessage(LANG_YOU_CHANGE_SECURITY, targetAccountName, gm); return true; } @@ -911,7 +911,7 @@ class account_commandscript : public CommandScript std::string accountName = account; if (!Utf8ToUpperOnlyLatin(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -919,7 +919,7 @@ class account_commandscript : public CommandScript uint32 targetAccountId = AccountMgr::GetId(accountName); if (!targetAccountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -944,7 +944,7 @@ class account_commandscript : public CommandScript handler->SendSysMessage(LANG_COMMAND_PASSWORD); break; case AOR_NAME_NOT_EXIST: - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; case AOR_PASS_TOO_LONG: diff --git a/src/server/scripts/Commands/cs_arena.cpp b/src/server/scripts/Commands/cs_arena.cpp index 5b0bfd662100eb..06f6b00c5f3613 100644 --- a/src/server/scripts/Commands/cs_arena.cpp +++ b/src/server/scripts/Commands/cs_arena.cpp @@ -59,7 +59,7 @@ class arena_commandscript : public CommandScript { if (sArenaTeamMgr->GetArenaTeamByName(name)) { - handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, name.c_str()); + handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, name); handler->SetSentErrorMessage(true); return false; } @@ -72,7 +72,7 @@ class arena_commandscript : public CommandScript if (Player::GetArenaTeamIdFromDB(captain->GetGUID(), type) != 0) { - handler->PSendSysMessage(LANG_ARENA_ERROR_SIZE, captain->GetName().c_str()); + handler->PSendSysMessage(LANG_ARENA_ERROR_SIZE, captain->GetName()); handler->SetSentErrorMessage(true); return false; } @@ -88,7 +88,7 @@ class arena_commandscript : public CommandScript } sArenaTeamMgr->AddArenaTeam(arena); - handler->PSendSysMessage(LANG_ARENA_CREATE, arena->GetName().c_str(), arena->GetId(), arena->GetType(), arena->GetCaptain().GetCounter()); + handler->PSendSysMessage(LANG_ARENA_CREATE, arena->GetName(), arena->GetId(), arena->GetType(), arena->GetCaptain().GetCounter()); return true; } @@ -116,7 +116,7 @@ class arena_commandscript : public CommandScript delete(arena); - handler->PSendSysMessage(LANG_ARENA_DISBAND, name.c_str(), teamId); + handler->PSendSysMessage(LANG_ARENA_DISBAND, name, teamId); return true; } @@ -125,14 +125,14 @@ class arena_commandscript : public CommandScript ArenaTeam* arena = sArenaTeamMgr->GetArenaTeamByName(oldName); if (!arena) { - handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_NOT_FOUND, oldName.c_str()); + handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_NOT_FOUND, oldName); handler->SetSentErrorMessage(true); return false; } if (sArenaTeamMgr->GetArenaTeamByName(newName)) { - handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, oldName.c_str()); + handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, oldName); handler->SetSentErrorMessage(true); return false; } @@ -151,7 +151,7 @@ class arena_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_ARENA_RENAME, arena->GetId(), oldName.c_str(), newName.c_str()); + handler->PSendSysMessage(LANG_ARENA_RENAME, arena->GetId(), oldName, newName); return true; } @@ -181,14 +181,14 @@ class arena_commandscript : public CommandScript if (!arena->IsMember(target->GetGUID())) { - handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_MEMBER, target->GetName().c_str(), arena->GetName().c_str()); + handler->PSendSysMessage(LANG_ARENA_ERROR_NOT_MEMBER, target->GetName(), arena->GetName()); handler->SetSentErrorMessage(true); return false; } if (arena->GetCaptain() == target->GetGUID()) { - handler->PSendSysMessage(LANG_ARENA_ERROR_CAPTAIN, target->GetName().c_str(), arena->GetName().c_str()); + handler->PSendSysMessage(LANG_ARENA_ERROR_CAPTAIN, target->GetName(), arena->GetName()); handler->SetSentErrorMessage(true); return false; } @@ -197,7 +197,7 @@ class arena_commandscript : public CommandScript sCharacterCache->GetCharacterNameByGuid(arena->GetCaptain(), oldCaptainName); arena->SetCaptain(target->GetGUID()); - handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName().c_str(), arena->GetId(), oldCaptainName.c_str(), target->GetName().c_str()); + handler->PSendSysMessage(LANG_ARENA_CAPTAIN, arena->GetName(), arena->GetId(), oldCaptainName, target->GetName()); return true; } @@ -212,10 +212,10 @@ class arena_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_ARENA_INFO_HEADER, arena->GetName().c_str(), arena->GetId(), arena->GetRating(), arena->GetType(), arena->GetType()); + handler->PSendSysMessage(LANG_ARENA_INFO_HEADER, arena->GetName(), arena->GetId(), arena->GetRating(), arena->GetType(), arena->GetType()); for (auto const& itr : arena->GetMembers()) - handler->PSendSysMessage(LANG_ARENA_INFO_MEMBERS, itr.Name.c_str(), itr.Guid.GetCounter(), itr.PersonalRating, (arena->GetCaptain() == itr.Guid ? "- Captain" : "")); + handler->PSendSysMessage(LANG_ARENA_INFO_MEMBERS, itr.Name, itr.Guid.GetCounter(), itr.PersonalRating, (arena->GetCaptain() == itr.Guid ? "- Captain" : "")); return true; } @@ -232,7 +232,7 @@ class arena_commandscript : public CommandScript { if (handler->GetSession()) { - handler->PSendSysMessage(LANG_ARENA_LOOKUP, team->GetName().c_str(), team->GetId(), team->GetType(), team->GetType()); + handler->PSendSysMessage(LANG_ARENA_LOOKUP, team->GetName(), team->GetId(), team->GetType(), team->GetType()); found = true; continue; } @@ -240,7 +240,7 @@ class arena_commandscript : public CommandScript } if (!found) - handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_NOT_FOUND, std::string(needle).c_str()); + handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_NOT_FOUND, std::string(needle)); return true; } diff --git a/src/server/scripts/Commands/cs_bag.cpp b/src/server/scripts/Commands/cs_bag.cpp index d190b790f57cc2..6382013829c3f6 100644 --- a/src/server/scripts/Commands/cs_bag.cpp +++ b/src/server/scripts/Commands/cs_bag.cpp @@ -148,7 +148,7 @@ class bg_commandscript : public CommandScript str << " items from your bags."; - handler->SendSysMessage(str.str().c_str()); + handler->SendSysMessage(str.str()); return true; }; diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index f17e470fc47c9b..9569bc354bc530 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -132,17 +132,17 @@ class ban_commandscript : public CommandScript if (atoi(durationStr) > 0) { if (!sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) - handler->PSendSysMessage(LANG_BAN_YOUBANNED, name.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + handler->PSendSysMessage(LANG_BAN_YOUBANNED, name, secsToTimeString(TimeStringToSecs(durationStr), true), reasonStr); } else { if (!sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) - handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name.c_str(), reasonStr); + handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, name, reasonStr); } break; case BAN_NOTFOUND: { - handler->PSendSysMessage(LANG_BAN_NOTFOUND, "character", name.c_str()); + handler->PSendSysMessage(LANG_BAN_NOTFOUND, "character", name); handler->SetSentErrorMessage(true); return false; } @@ -187,7 +187,7 @@ class ban_commandscript : public CommandScript case BAN_ACCOUNT: if (!Utf8ToUpperOnlyLatin(nameOrIP)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, nameOrIP.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, nameOrIP); handler->SetSentErrorMessage(true); return false; } @@ -228,12 +228,12 @@ class ban_commandscript : public CommandScript if (atoi(durationStr) > 0) { if (!sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) - handler->PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP.c_str(), secsToTimeString(TimeStringToSecs(durationStr), true).c_str(), reasonStr); + handler->PSendSysMessage(LANG_BAN_YOUBANNED, nameOrIP, secsToTimeString(TimeStringToSecs(durationStr), true), reasonStr); } else { if (!sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD)) - handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP.c_str(), reasonStr); + handler->PSendSysMessage(LANG_BAN_YOUPERMBANNED, nameOrIP, reasonStr); } break; case BAN_SYNTAX_ERROR: @@ -242,13 +242,13 @@ class ban_commandscript : public CommandScript switch (mode) { default: - handler->PSendSysMessage(LANG_BAN_NOTFOUND, "account", nameOrIP.c_str()); + handler->PSendSysMessage(LANG_BAN_NOTFOUND, "account", nameOrIP); break; case BAN_CHARACTER: - handler->PSendSysMessage(LANG_BAN_NOTFOUND, "character", nameOrIP.c_str()); + handler->PSendSysMessage(LANG_BAN_NOTFOUND, "character", nameOrIP); break; case BAN_IP: - handler->PSendSysMessage(LANG_BAN_NOTFOUND, "ip", nameOrIP.c_str()); + handler->PSendSysMessage(LANG_BAN_NOTFOUND, "ip", nameOrIP); break; } handler->SetSentErrorMessage(true); @@ -275,7 +275,7 @@ class ban_commandscript : public CommandScript std::string accountName = nameStr; if (!Utf8ToUpperOnlyLatin(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -283,7 +283,7 @@ class ban_commandscript : public CommandScript uint32 accountId = AccountMgr::GetId(accountName); if (!accountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); return true; } @@ -311,7 +311,7 @@ class ban_commandscript : public CommandScript bool permanent = (fields[1].Get() == uint64(0)); std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].Get(), true); handler->PSendSysMessage(LANG_BANINFO_HISTORYENTRY, - fields[0].Get().c_str(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].Get().c_str(), fields[5].Get().c_str()); + fields[0].Get(), banTime, active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].Get(), fields[5].Get()); } while (result->NextRow()); return true; @@ -344,11 +344,11 @@ class ban_commandscript : public CommandScript PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) { - handler->PSendSysMessage(LANG_CHAR_NOT_BANNED, name.c_str()); + handler->PSendSysMessage(LANG_CHAR_NOT_BANNED, name); return true; } - handler->PSendSysMessage(LANG_BANINFO_BANHISTORY, name.c_str()); + handler->PSendSysMessage(LANG_BANINFO_BANHISTORY, name); do { Field* fields = result->Fetch(); @@ -359,7 +359,7 @@ class ban_commandscript : public CommandScript bool permanent = (fields[1].Get() == uint32(0)); std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].Get(), true); handler->PSendSysMessage(LANG_BANINFO_HISTORYENTRY, - fields[0].Get().c_str(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].Get().c_str(), fields[5].Get().c_str()); + fields[0].Get(), banTime, active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].Get(), fields[5].Get()); } while (result->NextRow()); return true; @@ -390,8 +390,8 @@ class ban_commandscript : public CommandScript Field* fields = result->Fetch(); bool permanent = !fields[6].Get(); handler->PSendSysMessage(LANG_BANINFO_IPENTRY, - fields[0].Get().c_str(), fields[1].Get().c_str(), permanent ? handler->GetAcoreString(LANG_BANINFO_NEVER) : fields[2].Get().c_str(), - permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[3].Get(), true).c_str(), fields[4].Get().c_str(), fields[5].Get().c_str()); + fields[0].Get(), fields[1].Get(), permanent ? handler->GetAcoreString(LANG_BANINFO_NEVER) : fields[2].Get(), + permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[3].Get(), true), fields[4].Get(), fields[5].Get()); return true; } @@ -443,7 +443,7 @@ class ban_commandscript : public CommandScript if (banResult) { Field* fields2 = banResult->Fetch(); - handler->PSendSysMessage("%s", fields2[0].Get().c_str()); + handler->PSendSysMessage("{}", fields2[0].Get()); } } while (result->NextRow()); } @@ -479,17 +479,17 @@ class ban_commandscript : public CommandScript if (fields2[0].Get() == fields2[1].Get()) { - handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", - accountName.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, - fields2[2].Get().c_str(), fields2[3].Get().c_str()); + handler->PSendSysMessage("|%-15.15s|{:02}-{:02}-{:02} {:02}:{:02}| permanent |%-15.15s|%-15.15s|", + accountName, tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, + fields2[2].Get(), fields2[3].Get()); } else { tm tmUnban = Acore::Time::TimeBreakdown(fields2[1].Get()); - handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", - accountName.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, + handler->PSendSysMessage("|%-15.15s|{:02}-{:02}-{:02} {:02}:{:02}|{:02}-{:02}-{:02} {:02}:{:02}|%-15.15s|%-15.15s|", + accountName, tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min, - fields2[2].Get().c_str(), fields2[3].Get().c_str()); + fields2[2].Get(), fields2[3].Get()); } } while (banInfo->NextRow()); } @@ -533,7 +533,7 @@ class ban_commandscript : public CommandScript PreparedQueryResult banResult = CharacterDatabase.Query(stmt2); if (banResult) - handler->PSendSysMessage("%s", (*banResult)[0].Get().c_str()); + handler->PSendSysMessage("{}", (*banResult)[0].Get()); } while (result->NextRow()); } // Console wide output @@ -563,17 +563,17 @@ class ban_commandscript : public CommandScript if (banFields[0].Get() == banFields[1].Get()) { - handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", - char_name.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, - banFields[2].Get().c_str(), banFields[3].Get().c_str()); + handler->PSendSysMessage("|%-15.15s|{:02}-{:02}-{:02} {:02}:{:02}| permanent |%-15.15s|%-15.15s|", + char_name, tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, + banFields[2].Get(), banFields[3].Get()); } else { tm tmUnban = Acore::Time::TimeBreakdown(banFields[1].Get()); - handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", - char_name.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, + handler->PSendSysMessage("|%-15.15s|{:02}-{:02}-{:02} {:02}:{:02}|{:02}-{:02}-{:02} {:02}:{:02}|%-15.15s|%-15.15s|", + char_name, tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min, - banFields[2].Get().c_str(), banFields[3].Get().c_str()); + banFields[2].Get(), banFields[3].Get()); } } while (banInfo->NextRow()); } @@ -620,7 +620,7 @@ class ban_commandscript : public CommandScript do { Field* fields = result->Fetch(); - handler->PSendSysMessage("%s", fields[0].Get().c_str()); + handler->PSendSysMessage("{}", fields[0].Get()); } while (result->NextRow()); } // Console wide output @@ -636,17 +636,17 @@ class ban_commandscript : public CommandScript tm tmBan = Acore::Time::TimeBreakdown(fields[1].Get()); if (fields[1].Get() == fields[2].Get()) { - handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", - fields[0].Get().c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, - fields[3].Get().c_str(), fields[4].Get().c_str()); + handler->PSendSysMessage("|%-15.15s|{:02}-{:02}-{:02} {:02}:{:02}| permanent |%-15.15s|%-15.15s|", + fields[0].Get(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, + fields[3].Get(), fields[4].Get()); } else { tm tmUnban = Acore::Time::TimeBreakdown(fields[2].Get()); - handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", - fields[0].Get().c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, + handler->PSendSysMessage("|%-15.15s|{:02}-{:02}-{:02} {:02}:{:02}|{:02}-{:02}-{:02} {:02}:{:02}|%-15.15s|%-15.15s|", + fields[0].Get(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min, - fields[3].Get().c_str(), fields[4].Get().c_str()); + fields[3].Get(), fields[4].Get()); } } while (result->NextRow()); @@ -715,7 +715,7 @@ class ban_commandscript : public CommandScript case BAN_ACCOUNT: if (!Utf8ToUpperOnlyLatin(nameOrIP)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, nameOrIP.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, nameOrIP); handler->SetSentErrorMessage(true); return false; } @@ -738,21 +738,21 @@ class ban_commandscript : public CommandScript { case BAN_ACCOUNT: if (sBan->RemoveBanAccount(nameOrIP)) - handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str()); + handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP); else - handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str()); + handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP); break; case BAN_CHARACTER: if (sBan->RemoveBanAccountByPlayerName(nameOrIP)) - handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str()); + handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP); else - handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str()); + handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP); break; case BAN_IP: if (sBan->RemoveBanIP(nameOrIP)) - handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP.c_str()); + handler->PSendSysMessage(LANG_UNBAN_UNBANNED, nameOrIP); else - handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP.c_str()); + handler->PSendSysMessage(LANG_UNBAN_ERROR, nameOrIP); break; default: break; diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 3305748dfea3f5..14cce30f0da1af 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -187,12 +187,12 @@ class character_commandscript : public CommandScript if (!handler->GetSession()) handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CONSOLE, - itr->lowGuid, itr->name.c_str(), itr->accountName.empty() ? "" : itr->accountName.c_str(), - itr->accountId, dateStr.c_str()); + itr->lowGuid, itr->name, itr->accountName.empty() ? "" : itr->accountName, + itr->accountId, dateStr); else handler->PSendSysMessage(LANG_CHARACTER_DELETED_LIST_LINE_CHAT, - itr->lowGuid, itr->name.c_str(), itr->accountName.empty() ? "" : itr->accountName.c_str(), - itr->accountId, dateStr.c_str()); + itr->lowGuid, itr->name, itr->accountName.empty() ? "" : itr->accountName, + itr->accountId, dateStr); } if (!handler->GetSession()) @@ -213,7 +213,7 @@ class character_commandscript : public CommandScript { if (delInfo.accountName.empty()) // account does not exist { - handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name.c_str(), delInfo.lowGuid, delInfo.accountId); + handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_ACCOUNT, delInfo.name, delInfo.lowGuid, delInfo.accountId); return; } @@ -221,13 +221,13 @@ class character_commandscript : public CommandScript uint32 charcount = AccountMgr::GetCharactersCount(delInfo.accountId); if (charcount >= 10) { - handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name.c_str(), delInfo.lowGuid, delInfo.accountId); + handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_FULL, delInfo.name, delInfo.lowGuid, delInfo.accountId); return; } if (sCharacterCache->GetCharacterGuidByName(delInfo.name)) { - handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name.c_str(), delInfo.lowGuid, delInfo.accountId); + handler->PSendSysMessage(LANG_CHARACTER_DELETED_SKIP_NAME, delInfo.name, delInfo.lowGuid, delInfo.accountId); return; } @@ -256,11 +256,11 @@ class character_commandscript : public CommandScript if (handler->needReportToTarget(player)) { if (oldLevel == newLevel) - ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, handler->GetNameLink().c_str()); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_PROGRESS_RESET, handler->GetNameLink()); else if (oldLevel < newLevel) - ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink().c_str(), newLevel); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_UP, handler->GetNameLink(), newLevel); else // if (oldlevel > newlevel) - ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, handler->GetNameLink().c_str(), newLevel); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_LEVEL_DOWN, handler->GetNameLink(), newLevel); } } else @@ -290,7 +290,7 @@ class character_commandscript : public CommandScript Player const* target = player->GetConnectedPlayer(); LocaleConstant loc = handler->GetSessionDbcLocale(); - char const* knownStr = handler->GetAcoreString(LANG_KNOWN); + std::string knownStr = handler->GetAcoreString(LANG_KNOWN); // Search in CharTitles.dbc for (uint32 id = 0; id < sCharTitlesStore.GetNumRows(); id++) @@ -306,7 +306,7 @@ class character_commandscript : public CommandScript if (!*name) continue; - char const* activeStr = ""; + std::string activeStr = ""; if (target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index) activeStr = handler->GetAcoreString(LANG_ACTIVE); @@ -314,7 +314,7 @@ class character_commandscript : public CommandScript // send title in "id (idx:idx) - [namedlink locale]" format if (handler->GetSession()) - handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->bit_index, id, titleName.c_str(), localeNames[loc], knownStr, activeStr); + handler->PSendSysMessage(LANG_TITLE_LIST_CHAT, id, titleInfo->bit_index, id, titleName, localeNames[loc], knownStr, activeStr); else handler->PSendSysMessage(LANG_TITLE_LIST_CONSOLE, id, titleInfo->bit_index, name, localeNames[loc], knownStr, activeStr); } @@ -367,7 +367,7 @@ class character_commandscript : public CommandScript PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) { - handler->PSendSysMessage(LANG_RENAME_PLAYER_ALREADY_EXISTS, newName.c_str()); + handler->PSendSysMessage(LANG_RENAME_PLAYER_ALREADY_EXISTS, newName); handler->SetSentErrorMessage(true); return false; } @@ -394,13 +394,13 @@ class character_commandscript : public CommandScript sCharacterCache->UpdateCharacterData(player->GetGUID(), newName); - handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, player->GetName().c_str(), newName.c_str()); + handler->PSendSysMessage(LANG_RENAME_PLAYER_WITH_NEW_NAME, player->GetName(), newName); } else { if (Player* target = player->GetConnectedPlayer()) { - handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_RENAME_PLAYER, handler->GetNameLink(target)); target->SetAtLoginFlag(AT_LOGIN_RENAME); } else @@ -409,7 +409,7 @@ class character_commandscript : public CommandScript if (handler->HasLowerSecurity(nullptr, player->GetGUID())) return false; - handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->SetData(0, uint16(AT_LOGIN_RENAME)); @@ -445,7 +445,7 @@ class character_commandscript : public CommandScript HandleCharacterLevel(player->GetConnectedPlayer(), player->GetGUID(), oldlevel, newlevel, handler); if (!handler->GetSession() || (handler->GetSession()->GetPlayer() != player->GetConnectedPlayer())) // including chr == NULL - handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(*player).c_str(), newlevel); + handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(*player), newlevel); return true; } @@ -460,12 +460,12 @@ class character_commandscript : public CommandScript if (Player* target = player->GetConnectedPlayer()) { - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target)); target->SetAtLoginFlag(AT_LOGIN_CUSTOMIZE); } else { - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->SetData(0, static_cast(AT_LOGIN_CUSTOMIZE)); stmt->SetData(1, player->GetGUID().GetCounter()); @@ -484,12 +484,12 @@ class character_commandscript : public CommandScript if (Player* target = player->GetConnectedPlayer()) { - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target)); target->SetAtLoginFlag(AT_LOGIN_CHANGE_FACTION); } else { - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->SetData(0, uint16(AT_LOGIN_CHANGE_FACTION)); stmt->SetData(1, player->GetGUID().GetCounter()); @@ -508,12 +508,12 @@ class character_commandscript : public CommandScript if (Player* target = player->GetConnectedPlayer()) { - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER, handler->GetNameLink(target)); target->SetAtLoginFlag(AT_LOGIN_CHANGE_RACE); } else { - handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); stmt->SetData(0, uint16(AT_LOGIN_CHANGE_RACE)); stmt->SetData(1, player->GetGUID().GetCounter()); @@ -566,7 +566,7 @@ class character_commandscript : public CommandScript if (faction.Flags & FACTION_FLAG_INACTIVE) ss << handler->GetAcoreString(LANG_FACTION_INACTIVE); - handler->SendSysMessage(ss.str().c_str()); + handler->SendSysMessage(ss.str()); } return true; @@ -746,7 +746,7 @@ class character_commandscript : public CommandScript AccountMgr::GetName(accountId, accountName); Player::DeleteFromDB(player.GetGUID().GetCounter(), accountId, true, true); - handler->PSendSysMessage(LANG_CHARACTER_DELETED, player.GetName().c_str(), player.GetGUID().GetCounter(), accountName.c_str(), accountId); + handler->PSendSysMessage(LANG_CHARACTER_DELETED, player.GetName(), player.GetGUID().GetCounter(), accountName, accountId); return true; } @@ -771,7 +771,7 @@ class character_commandscript : public CommandScript HandleCharacterLevel(player->GetConnectedPlayer(), player->GetGUID(), oldlevel, newlevel, handler); if (!handler->GetSession() || (handler->GetSession()->GetPlayer() != player->GetConnectedPlayer())) // including chr == NULL - handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(*player).c_str(), newlevel); + handler->PSendSysMessage(LANG_YOU_CHANGE_LVL, handler->playerLink(*player), newlevel); return true; } @@ -822,15 +822,15 @@ class character_commandscript : public CommandScript handler->PSendSysMessage(LANG_COMMAND_IMPORT_SUCCESS); break; case DUMP_FILE_OPEN_ERROR: - handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str()); + handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName); handler->SetSentErrorMessage(true); return false; case DUMP_FILE_BROKEN: - handler->PSendSysMessage(LANG_DUMP_BROKEN, fileName.c_str()); + handler->PSendSysMessage(LANG_DUMP_BROKEN, fileName); handler->SetSentErrorMessage(true); return false; case DUMP_TOO_MANY_CHARS: - handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID()); + handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName(), account.GetID()); handler->SetSentErrorMessage(true); return false; default: @@ -869,7 +869,7 @@ class character_commandscript : public CommandScript case DUMP_SUCCESS: break; case DUMP_TOO_MANY_CHARS: - handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName().c_str(), account.GetID()); + handler->PSendSysMessage(LANG_ACCOUNT_CHARACTER_LIST_FULL, account.GetName(), account.GetID()); handler->SetSentErrorMessage(true); return false; case DUMP_FILE_OPEN_ERROR: // this error code should not happen @@ -895,7 +895,7 @@ class character_commandscript : public CommandScript handler->PSendSysMessage(LANG_COMMAND_EXPORT_SUCCESS); break; case DUMP_FILE_OPEN_ERROR: - handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName.c_str()); + handler->PSendSysMessage(LANG_FILE_OPEN_FAIL, fileName); handler->SetSentErrorMessage(true); return false; case DUMP_CHARACTER_DELETED: @@ -956,7 +956,7 @@ class character_commandscript : public CommandScript std::ostringstream ItemString; ItemString << std::hex << ItemQualityColors[item->GetTemplate()->Quality]; - handler->PSendSysMessage("%u - |c%s|Hitem:%u:0:0:0:0:0:0:0:0:0|h[%s]|h|r - %u", Counter, ItemString.str().c_str(), item->GetEntry(), item->GetTemplate()->Name1.c_str(), item->GetCount()); + handler->PSendSysMessage("{} - |c{}|Hitem:{}:0:0:0:0:0:0:0:0:0|h[{}]|h|r - {}", Counter, ItemString.str(), item->GetEntry(), item->GetTemplate()->Name1, item->GetCount()); } } } @@ -972,7 +972,7 @@ class character_commandscript : public CommandScript std::ostringstream ItemString; ItemString << std::hex << ItemQualityColors[item->GetTemplate()->Quality]; - handler->PSendSysMessage("%u - |c%s|Hitem:%u:0:0:0:0:0:0:0:0:0|h[%s]|h|r - %u", Counter, ItemString.str().c_str(), item->GetEntry(), item->GetTemplate()->Name1.c_str(), item->GetCount()); + handler->PSendSysMessage("{} - |c{}|Hitem:{}:0:0:0:0:0:0:0:0:0|h[{}]|h|r - {}", Counter, ItemString.str(), item->GetEntry(), item->GetTemplate()->Name1, item->GetCount()); } } } @@ -1012,43 +1012,43 @@ class character_commandscript : public CommandScript switch (SkillID) { case SKILL_ALCHEMY: - handler->PSendSysMessage("%u - Alchemy - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Alchemy - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_BLACKSMITHING: - handler->PSendSysMessage("%u - Blacksmithing - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Blacksmithing - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_ENCHANTING: - handler->PSendSysMessage("%u - Enchanting - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Enchanting - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_ENGINEERING: - handler->PSendSysMessage("%u - Engineering - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Engineering - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_INSCRIPTION: - handler->PSendSysMessage("%u - Inscription - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Inscription - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_JEWELCRAFTING: - handler->PSendSysMessage("%u - Jewelcrafting - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Jewelcrafting - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_LEATHERWORKING: - handler->PSendSysMessage("%u - Leatherworking - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Leatherworking - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_TAILORING: - handler->PSendSysMessage("%u - Tailoring - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Tailoring - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_SKINNING: - handler->PSendSysMessage("%u - Skinning - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Skinning - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_HERBALISM: - handler->PSendSysMessage("%u - Herbalism - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Herbalism - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_MINING: - handler->PSendSysMessage("%u - Mining - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Mining - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_COOKING: - handler->PSendSysMessage("%u - Cooking - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - Cooking - {}", Counter, player->GetSkillValue(SkillID)); break; case SKILL_FIRST_AID: - handler->PSendSysMessage("%u - First Aid - %u", Counter, player->GetSkillValue(SkillID)); + handler->PSendSysMessage("{} - First Aid - {}", Counter, player->GetSkillValue(SkillID)); break; default: break; diff --git a/src/server/scripts/Commands/cs_cheat.cpp b/src/server/scripts/Commands/cs_cheat.cpp index e6919d0cc3ec10..d09866b59fdd01 100644 --- a/src/server/scripts/Commands/cs_cheat.cpp +++ b/src/server/scripts/Commands/cs_cheat.cpp @@ -185,16 +185,16 @@ class cheat_commandscript : public CommandScript if (enable) { chr->SetTaxiCheater(true); - handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr).c_str()); + handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr)); if (handler->needReportToTarget(chr)) - ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, handler->GetNameLink().c_str()); + ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, handler->GetNameLink()); } else { chr->SetTaxiCheater(false); - handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str()); + handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr)); if (handler->needReportToTarget(chr)) - ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink().c_str()); + ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink()); } return true; @@ -212,15 +212,15 @@ class cheat_commandscript : public CommandScript if (reveal) { - handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(chr).c_str()); + handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(chr)); if (handler->needReportToTarget(chr)) - ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, handler->GetNameLink().c_str()); + ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, handler->GetNameLink()); } else { - handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, handler->GetNameLink(chr).c_str()); + handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, handler->GetNameLink(chr)); if (handler->needReportToTarget(chr)) - ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, handler->GetNameLink().c_str()); + ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, handler->GetNameLink()); } for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i) diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 871e67bd26e694..60216833d4f5e9 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -128,14 +128,14 @@ class debug_commandscript : public CommandScript auto const& itr = sFlyByCameraStore.find(cineSeq->cinematicCamera); if (itr != sFlyByCameraStore.end()) { - handler->PSendSysMessage("Waypoints for sequence %u, camera %u", cinematicId, cineSeq->cinematicCamera); + handler->PSendSysMessage("Waypoints for sequence {}, camera {}", cinematicId, cineSeq->cinematicCamera); uint32 count = 1; for (FlyByCamera cam : itr->second) { - handler->PSendSysMessage("%02u - %7ums [%f, %f, %f] Facing %f (%f degrees)", count, cam.timeStamp, cam.locations.x, cam.locations.y, cam.locations.z, cam.locations.w, cam.locations.w * (180 / M_PI)); + handler->PSendSysMessage("{:02} - {:7}ms [{}, {}, {}] Facing {} ({} degrees)", count, cam.timeStamp, cam.locations.x, cam.locations.y, cam.locations.z, cam.locations.w, cam.locations.w * (180 / M_PI)); count++; } - handler->PSendSysMessage("%lu waypoints dumped", itr->second.size()); + handler->PSendSysMessage("{} waypoints dumped", itr->second.size()); } } @@ -425,7 +425,7 @@ class debug_commandscript : public CommandScript data.hexlike(); player->GetSession()->SendPacket(&data); - handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName().c_str()); + handler->PSendSysMessage(LANG_COMMAND_OPCODESENT, data.GetOpcode(), unit->GetName()); return true; } @@ -483,9 +483,9 @@ class debug_commandscript : public CommandScript if (!target) return false; - handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, SpawnID %u) is %s", - target->GetName().c_str(), target->GetGUID().GetCounter(), target->GetSpawnId(), - target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient"); + handler->PSendSysMessage("Loot recipient for creature {} (GUID {}, SpawnID {}) is {}", + target->GetName(), target->GetGUID().GetCounter(), target->GetSpawnId(), + target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName() : "offline") : "no loot recipient"); return true; } @@ -523,7 +523,7 @@ class debug_commandscript : public CommandScript if (!listQueue && !checkAll) { itemState = "The player has the following " + itemState + " items: "; - handler->SendSysMessage(itemState.c_str()); + handler->SendSysMessage(itemState); for (uint8 i = PLAYER_SLOT_START; i < PLAYER_SLOT_END; ++i) { if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) @@ -536,10 +536,10 @@ class debug_commandscript : public CommandScript for (uint8 j = 0; j < bag->GetBagSize(); ++j) if (Item* item2 = bag->GetItemByPos(j)) if (item2->GetState() == state) - handler->PSendSysMessage("bag: 255 slot: %d %s owner: %s", item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str()); + handler->PSendSysMessage("bag: 255 slot: {} {} owner: {}", item2->GetSlot(), item2->GetGUID().ToString(), item2->GetOwnerGUID().ToString()); } else if (item->GetState() == state) - handler->PSendSysMessage("bag: 255 slot: %d %s owner: %s", item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str()); + handler->PSendSysMessage("bag: 255 slot: {} {} owner: {}", item->GetSlot(), item->GetGUID().ToString(), item->GetOwnerGUID().ToString()); } } } @@ -570,7 +570,7 @@ class debug_commandscript : public CommandScript break; } - handler->PSendSysMessage("bag: %d slot: %d guid: %d - state: %s", bagSlot, item->GetSlot(), item->GetGUID().GetCounter(), st.c_str()); + handler->PSendSysMessage("bag: {} slot: {} guid: {} - state: {}", bagSlot, item->GetSlot(), item->GetGUID().GetCounter(), st); } if (updateQueue.empty()) @@ -592,21 +592,21 @@ class debug_commandscript : public CommandScript if (item->GetSlot() != i) { - handler->PSendSysMessage("Item with slot %d and guid %d has an incorrect slot value: %d", i, item->GetGUID().GetCounter(), item->GetSlot()); + handler->PSendSysMessage("Item with slot {} and guid {} has an incorrect slot value: {}", i, item->GetGUID().GetCounter(), item->GetSlot()); error = true; continue; } if (item->GetOwnerGUID() != player->GetGUID()) { - handler->PSendSysMessage("The item with slot %d %s does have non-matching owner guid %s and %s!", item->GetSlot(), item->GetGUID().ToString().c_str(), item->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str()); + handler->PSendSysMessage("The item with slot {} {} does have non-matching owner guid {} and {}!", item->GetSlot(), item->GetGUID().ToString(), item->GetOwnerGUID().ToString(), player->GetGUID().ToString()); error = true; continue; } if (Bag* container = item->GetContainer()) { - handler->PSendSysMessage("The item with slot %d %s has a container (slot: %d, %s) but shouldn't!", item->GetSlot(), item->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str()); + handler->PSendSysMessage("The item with slot {} {} has a container (slot: {}, {}) but shouldn't!", item->GetSlot(), item->GetGUID().ToString(), container->GetSlot(), container->GetGUID().ToString()); error = true; continue; } @@ -616,28 +616,28 @@ class debug_commandscript : public CommandScript uint16 qp = item->GetQueuePos(); if (qp > updateQueue.size()) { - handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) larger than the update queue size! ", item->GetSlot(), item->GetGUID().GetCounter(), qp); + handler->PSendSysMessage("The item with slot {} and guid {} has its queuepos ({}) larger than the update queue size! ", item->GetSlot(), item->GetGUID().GetCounter(), qp); error = true; continue; } if (updateQueue[qp] == nullptr) { - handler->PSendSysMessage("The item with slot %d and guid %d has its queuepos (%d) pointing to NULL in the queue!", item->GetSlot(), item->GetGUID().GetCounter(), qp); + handler->PSendSysMessage("The item with slot {} and guid {} has its queuepos ({}) pointing to NULL in the queue!", item->GetSlot(), item->GetGUID().GetCounter(), qp); error = true; continue; } if (updateQueue[qp] != item) { - handler->PSendSysMessage("The item with slot %d and guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", item->GetSlot(), item->GetGUID().GetCounter(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().GetCounter()); + handler->PSendSysMessage("The item with slot {} and guid {} has a queuepos ({}) that points to another item in the queue (bag: {}, slot: {}, guid: {})", item->GetSlot(), item->GetGUID().GetCounter(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().GetCounter()); error = true; continue; } } else if (item->GetState() != ITEM_UNCHANGED) { - handler->PSendSysMessage("The item with slot %d and guid %d is not in queue but should be (state: %d)!", item->GetSlot(), item->GetGUID().GetCounter(), item->GetState()); + handler->PSendSysMessage("The item with slot {} and guid {} is not in queue but should be (state: {})!", item->GetSlot(), item->GetGUID().GetCounter(), item->GetState()); error = true; continue; } @@ -652,14 +652,14 @@ class debug_commandscript : public CommandScript if (item2->GetSlot() != j) { - handler->PSendSysMessage("The item in bag %d and slot %d (guid: %d) has an incorrect slot value: %d", bag->GetSlot(), j, item2->GetGUID().GetCounter(), item2->GetSlot()); + handler->PSendSysMessage("The item in bag {} and slot {} (guid: {}) has an incorrect slot value: {}", bag->GetSlot(), j, item2->GetGUID().GetCounter(), item2->GetSlot()); error = true; continue; } if (item2->GetOwnerGUID() != player->GetGUID()) { - handler->PSendSysMessage("The item in bag %d at slot %d and %s, the owner (%s) and the player (%s) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), item2->GetOwnerGUID().ToString().c_str(), player->GetGUID().ToString().c_str()); + handler->PSendSysMessage("The item in bag {} at slot {} and {}, the owner ({}) and the player ({}) don't match!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString(), item2->GetOwnerGUID().ToString(), player->GetGUID().ToString()); error = true; continue; } @@ -667,14 +667,14 @@ class debug_commandscript : public CommandScript Bag* container = item2->GetContainer(); if (!container) { - handler->PSendSysMessage("The item in bag %d at slot %d %s has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str()); + handler->PSendSysMessage("The item in bag {} at slot {} {} has no container!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString()); error = true; continue; } if (container != bag) { - handler->PSendSysMessage("The item in bag %d at slot %d %s has a different container(slot %d %s)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString().c_str(), container->GetSlot(), container->GetGUID().ToString().c_str()); + handler->PSendSysMessage("The item in bag {} at slot {} {} has a different container(slot {} {})!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().ToString(), container->GetSlot(), container->GetGUID().ToString()); error = true; continue; } @@ -684,28 +684,28 @@ class debug_commandscript : public CommandScript uint16 qp = item2->GetQueuePos(); if (qp > updateQueue.size()) { - handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().GetCounter(), qp); + handler->PSendSysMessage("The item in bag {} at slot {} having guid {} has a queuepos ({}) larger than the update queue size! ", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().GetCounter(), qp); error = true; continue; } if (updateQueue[qp] == nullptr) { - handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().GetCounter(), qp); + handler->PSendSysMessage("The item in bag {} at slot {} having guid {} has a queuepos ({}) that points to NULL in the queue!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().GetCounter(), qp); error = true; continue; } if (updateQueue[qp] != item2) { - handler->PSendSysMessage("The item in bag %d at slot %d having guid %d has a queuepos (%d) that points to another item in the queue (bag: %d, slot: %d, guid: %d)", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().GetCounter(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().GetCounter()); + handler->PSendSysMessage("The item in bag {} at slot {} having guid {} has a queuepos ({}) that points to another item in the queue (bag: {}, slot: {}, guid: {})", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().GetCounter(), qp, updateQueue[qp]->GetBagSlot(), updateQueue[qp]->GetSlot(), updateQueue[qp]->GetGUID().GetCounter()); error = true; continue; } } else if (item2->GetState() != ITEM_UNCHANGED) { - handler->PSendSysMessage("The item in bag %d at slot %d having guid %d is not in queue but should be (state: %d)!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().GetCounter(), item2->GetState()); + handler->PSendSysMessage("The item in bag {} at slot {} having guid {} is not in queue but should be (state: {})!", bag->GetSlot(), item2->GetSlot(), item2->GetGUID().GetCounter(), item2->GetState()); error = true; continue; } @@ -747,7 +747,7 @@ class debug_commandscript : public CommandScript if (test != item) { - handler->SendSysMessage(Acore::StringFormatFmt("queue({}): The bag({}) and slot({}) values for the %s are incorrect, {} is there instead!", index, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString(), test->GetGUID().ToString())); + handler->SendSysMessage(Acore::StringFormatFmt("queue({}): The bag({}) and slot({}) values for the {} are incorrect, {} is there instead!", index, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString(), test->GetGUID().ToString())); error = true; continue; } @@ -788,18 +788,18 @@ class debug_commandscript : public CommandScript ThreatContainer::StorageType::const_iterator itr; uint32 count = 0; - handler->PSendSysMessage("Threat list of %s (%s)", target->GetName().c_str(), target->GetGUID().ToString().c_str()); + handler->PSendSysMessage("Threat list of {} ({})", target->GetName(), target->GetGUID().ToString()); for (itr = threatList.begin(); itr != threatList.end(); ++itr) { Unit* unit = (*itr)->getTarget(); if (!unit) { - handler->PSendSysMessage(" %u. No Unit - threat %f", ++count, (*itr)->getThreat()); + handler->PSendSysMessage(" {}. No Unit - threat {}", ++count, (*itr)->getThreat()); continue; } - handler->PSendSysMessage(" %u. %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat()); + handler->PSendSysMessage(" {}. {} ({}) - threat {}", ++count, unit->GetName(), unit->GetGUID().ToString(), (*itr)->getThreat()); } auto const& threatList2 = target->getThreatMgr().getOfflineThreatList(); @@ -808,11 +808,11 @@ class debug_commandscript : public CommandScript Unit* unit = (*itr)->getTarget(); if (!unit) { - handler->PSendSysMessage(" %u. [offline] No Unit - threat %f", ++count, (*itr)->getThreat()); + handler->PSendSysMessage(" {}. [offline] No Unit - threat {}", ++count, (*itr)->getThreat()); continue; } - handler->PSendSysMessage(" %u. [offline] %s (%s) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), (*itr)->getThreat()); + handler->PSendSysMessage(" {}. [offline] {} ({}) - threat {}", ++count, unit->GetName(), unit->GetGUID().ToString(), (*itr)->getThreat()); } handler->SendSysMessage("End of threat list."); @@ -829,18 +829,18 @@ class debug_commandscript : public CommandScript HostileReference* ref = target->getHostileRefMgr().getFirst(); uint32 count = 0; - handler->PSendSysMessage("Hostil reference list of %s (%s)", target->GetName().c_str(), target->GetGUID().ToString().c_str()); + handler->PSendSysMessage("Hostil reference list of {} ({})", target->GetName(), target->GetGUID().ToString()); while (ref) { if (Unit* unit = ref->GetSource()->GetOwner()) { - handler->PSendSysMessage(" %u. %s %s (%s) - threat %f", ++count, (ref->isOnline() ? "" : "[offline]"), - unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), ref->getThreat()); + handler->PSendSysMessage(" {}. {} {} ({}) - threat {}", ++count, (ref->isOnline() ? "" : "[offline]"), + unit->GetName(), unit->GetGUID().ToString(), ref->getThreat()); } else { - handler->PSendSysMessage(" %u. No Owner - threat %f", ++count, ref->getThreat()); + handler->PSendSysMessage(" {}. No Owner - threat {}", ++count, ref->getThreat()); } ref = ref->next(); @@ -857,7 +857,7 @@ class debug_commandscript : public CommandScript return false; //target->SetVehicleId(id); - handler->PSendSysMessage("Vehicle id set to %u", id); + handler->PSendSysMessage("Vehicle id set to {}", id); return true; } @@ -885,7 +885,7 @@ class debug_commandscript : public CommandScript passenger->EnterVehicle(target, *seatId); } - handler->PSendSysMessage("Unit %u entered vehicle %hhd", entry, *seatId); + handler->PSendSysMessage("Unit {} entered vehicle %hhd", entry, *seatId); return true; } @@ -929,7 +929,7 @@ class debug_commandscript : public CommandScript while (ss.str().size() < 128000) ss << "This is a dummy string to push the packet's size beyond 128000 bytes. "; - handler->SendSysMessage(ss.str().c_str()); + handler->SendSysMessage(ss.str()); return true; } @@ -951,7 +951,7 @@ class debug_commandscript : public CommandScript uint32 value = i->GetUInt32Value(index); - handler->PSendSysMessage("Item %u: value at %u is %u", guid, index, value); + handler->PSendSysMessage("Item {}: value at {} is {}", guid, index, value); return true; } @@ -990,7 +990,7 @@ class debug_commandscript : public CommandScript if (Unit* unit = handler->getSelectedUnit()) unit->HandleEmoteCommand(emote); - handler->PSendSysMessage("Playing emote %s", EnumUtils::ToConstant(emote)); + handler->PSendSysMessage("Playing emote {}", EnumUtils::ToConstant(emote)); return true; } @@ -1000,10 +1000,10 @@ class debug_commandscript : public CommandScript if (Unit* unit = handler->getSelectedUnit()) { Player* player = handler->GetSession()->GetPlayer(); - handler->PSendSysMessage("Checking LoS %s -> %s:", player->GetName().c_str(), unit->GetName().c_str()); - handler->PSendSysMessage(" VMAP LoS: %s", player->IsWithinLOSInMap(unit, LINEOFSIGHT_CHECK_VMAP) ? "clear" : "obstructed"); - handler->PSendSysMessage(" GObj LoS: %s", player->IsWithinLOSInMap(unit, LINEOFSIGHT_CHECK_GOBJECT) ? "clear" : "obstructed"); - handler->PSendSysMessage("%s is %sin line of sight of %s.", unit->GetName().c_str(), (player->IsWithinLOSInMap(unit) ? "" : "not "), player->GetName().c_str()); + handler->PSendSysMessage("Checking LoS {} -> {}:", player->GetName(), unit->GetName()); + handler->PSendSysMessage(" VMAP LoS: {}", player->IsWithinLOSInMap(unit, LINEOFSIGHT_CHECK_VMAP) ? "clear" : "obstructed"); + handler->PSendSysMessage(" GObj LoS: {}", player->IsWithinLOSInMap(unit, LINEOFSIGHT_CHECK_GOBJECT) ? "clear" : "obstructed"); + handler->PSendSysMessage("{} is {}in line of sight of {}.", unit->GetName(), (player->IsWithinLOSInMap(unit) ? "" : "not "), player->GetName()); return true; } diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index 30b28f12e3b031..d567e9a30a97e2 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -154,7 +154,7 @@ class disable_commandscript : public CommandScript PreparedQueryResult result = WorldDatabase.Query(stmt); if (result) { - handler->PSendSysMessage("This %s (Id: %u) is already disabled.", disableTypeStr.c_str(), entry); + handler->PSendSysMessage("This {} (Id: {}) is already disabled.", disableTypeStr, entry); handler->SetSentErrorMessage(true); return false; } @@ -166,7 +166,7 @@ class disable_commandscript : public CommandScript stmt->SetData(3, disableComment); WorldDatabase.Execute(stmt); - handler->PSendSysMessage("Add Disabled %s (Id: %u) for reason %s", disableTypeStr.c_str(), entry, disableComment.c_str()); + handler->PSendSysMessage("Add Disabled {} (Id: {}) for reason {}", disableTypeStr, entry, disableComment); return true; } @@ -242,7 +242,7 @@ class disable_commandscript : public CommandScript PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) { - handler->PSendSysMessage("This %s (Id: %u) is not disabled.", disableTypeStr.c_str(), entry); + handler->PSendSysMessage("This {} (Id: {}) is not disabled.", disableTypeStr, entry); handler->SetSentErrorMessage(true); return false; } @@ -252,7 +252,7 @@ class disable_commandscript : public CommandScript stmt->SetData(1, disableType); WorldDatabase.Execute(stmt); - handler->PSendSysMessage("Remove Disabled %s (Id: %u)", disableTypeStr.c_str(), entry); + handler->PSendSysMessage("Remove Disabled {} (Id: {})", disableTypeStr, entry); return true; } diff --git a/src/server/scripts/Commands/cs_event.cpp b/src/server/scripts/Commands/cs_event.cpp index f1c1da6b7d94c8..daaaff9bf4ca0e 100644 --- a/src/server/scripts/Commands/cs_event.cpp +++ b/src/server/scripts/Commands/cs_event.cpp @@ -62,7 +62,7 @@ class event_commandscript : public CommandScript GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap(); GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); - char const* active = handler->GetAcoreString(LANG_ACTIVE); + std::string active = handler->GetAcoreString(LANG_ACTIVE); for (uint16 eventId : activeEvents) { @@ -70,11 +70,11 @@ class event_commandscript : public CommandScript if (handler->GetSession()) { - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.description.c_str(), active); + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, eventId, eventId, eventData.description, active); } else { - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.description.c_str(), active); + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, eventId, eventData.description, active); } ++counter; @@ -111,7 +111,7 @@ class event_commandscript : public CommandScript GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList(); bool active = activeEvents.find(eventId) != activeEvents.end(); - char const* activeStr = active ? handler->GetAcoreString(LANG_ACTIVE) : ""; + std::string activeStr = active ? handler->GetAcoreString(LANG_ACTIVE) : ""; std::string startTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.start)); std::string endTimeStr = Acore::Time::TimeToTimestampStr(Seconds(eventData.end)); @@ -123,9 +123,8 @@ class event_commandscript : public CommandScript std::string occurenceStr = secsToTimeString(eventData.occurence * MINUTE, true); std::string lengthStr = secsToTimeString(eventData.length * MINUTE, true); - handler->PSendSysMessage(LANG_EVENT_INFO, uint16(eventId), eventData.description.c_str(), activeStr, - startTimeStr.c_str(), endTimeStr.c_str(), occurenceStr.c_str(), lengthStr.c_str(), - nextStr.c_str()); + handler->PSendSysMessage(LANG_EVENT_INFO, uint16(eventId), eventData.description, activeStr, + startTimeStr, endTimeStr, occurenceStr, lengthStr, nextStr); return true; } diff --git a/src/server/scripts/Commands/cs_gear.cpp b/src/server/scripts/Commands/cs_gear.cpp index 6e3e4c97cfe8dc..2fee3a13a44424 100644 --- a/src/server/scripts/Commands/cs_gear.cpp +++ b/src/server/scripts/Commands/cs_gear.cpp @@ -68,11 +68,11 @@ class gear_commandscript : public CommandScript std::string nameLink = handler->playerLink(target->GetName()); - handler->PSendSysMessage(LANG_YOU_REPAIR_ITEMS, nameLink.c_str()); + handler->PSendSysMessage(LANG_YOU_REPAIR_ITEMS, nameLink); if (handler->needReportToTarget(target->GetConnectedPlayer())) { - ChatHandler(target->GetConnectedPlayer()->GetSession()).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, nameLink.c_str()); + ChatHandler(target->GetConnectedPlayer()->GetSession()).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, nameLink); } return true; @@ -87,8 +87,8 @@ class gear_commandscript : public CommandScript return false; } - handler->PSendSysMessage("Character: %s", player->GetPlayerName().c_str()); - handler->PSendSysMessage("Current equipment average item level: |cff00ffff%u|r", (int16)player->GetAverageItemLevel()); + handler->PSendSysMessage("Character: {}", player->GetPlayerName()); + handler->PSendSysMessage("Current equipment average item level: |cff00ffff{}|r", (int16)player->GetAverageItemLevel()); if (sWorld->getIntConfig(CONFIG_MIN_LEVEL_STAT_SAVE)) { @@ -110,11 +110,11 @@ class gear_commandscript : public CommandScript uint32 SpellPower = fields[8].Get(); uint32 Resilience = fields[9].Get(); - handler->PSendSysMessage("Health: |cff00ffff%u|r - Stamina: |cff00ffff%u|r", MaxHealth, Stamina); - handler->PSendSysMessage("Strength: |cff00ffff%u|r - Agility: |cff00ffff%u|r", Strength, Agility); - handler->PSendSysMessage("Intellect: |cff00ffff%u|r - Spirit: |cff00ffff%u|r", Intellect, Spirit); - handler->PSendSysMessage("AttackPower: |cff00ffff%u|r - SpellPower: |cff00ffff%u|r", AttackPower, SpellPower); - handler->PSendSysMessage("Armor: |cff00ffff%u|r - Resilience: |cff00ffff%u|r", Armor, Resilience); + handler->PSendSysMessage("Health: |cff00ffff{}|r - Stamina: |cff00ffff{}|r", MaxHealth, Stamina); + handler->PSendSysMessage("Strength: |cff00ffff{}|r - Agility: |cff00ffff{}|r", Strength, Agility); + handler->PSendSysMessage("Intellect: |cff00ffff{}|r - Spirit: |cff00ffff{}|r", Intellect, Spirit); + handler->PSendSysMessage("AttackPower: |cff00ffff{}|r - SpellPower: |cff00ffff{}|r", AttackPower, SpellPower); + handler->PSendSysMessage("Armor: |cff00ffff{}|r - Resilience: |cff00ffff{}|r", Armor, Resilience); } } diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 06fb48581bb876..15e7c259f936bb 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -24,6 +24,7 @@ EndScriptData */ #include "AccountMgr.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "DatabaseEnv.h" #include "Language.h" #include "ObjectAccessor.h" @@ -68,22 +69,22 @@ class gm_commandscript : public CommandScript if (!enableArg) { if (!AccountMgr::IsPlayerAccount(session->GetSecurity()) && session->GetPlayer()->isGMChat()) - session->SendNotification(LANG_GM_CHAT_ON); + Acore::Text::SendNotification(session, LANG_GM_CHAT_ON); else - session->SendNotification(LANG_GM_CHAT_OFF); + Acore::Text::SendNotification(session, LANG_GM_CHAT_OFF); return true; } if (*enableArg) { session->GetPlayer()->SetGMChat(true); - session->SendNotification(LANG_GM_CHAT_ON); + Acore::Text::SendNotification(session, LANG_GM_CHAT_ON); return true; } else { session->GetPlayer()->SetGMChat(false); - session->SendNotification(LANG_GM_CHAT_OFF); + Acore::Text::SendNotification(session, LANG_GM_CHAT_OFF); return true; } } @@ -108,7 +109,7 @@ class gm_commandscript : public CommandScript data << target->GetPackGUID(); data << uint32(0); // unknown target->SendMessageToSet(&data, true); - handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target).c_str(), enable ? "on" : "off"); + handler->PSendSysMessage(LANG_COMMAND_FLYMODE_STATUS, handler->GetNameLink(target), enable ? "on" : "off"); return true; } @@ -132,17 +133,11 @@ class gm_commandscript : public CommandScript handler->SendSysMessage(LANG_GMS_ON_SRV); handler->SendSysMessage("========================"); } + std::string const& name = player->GetName(); - uint8 size = uint8(name.size()); uint8 security = playerSec; - uint8 max = ((16 - size) / 2); - uint8 max2 = max; - if ((max + max2 + size) == 16) - max2 = max - 1; - if (handler->GetSession()) - handler->PSendSysMessage("| %s GMLevel %u", name.c_str(), security); - else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name.c_str(), max2, " ", security); + + handler->PSendSysMessage("| {} GMLevel {}", name, security); } } if (footer) @@ -171,14 +166,7 @@ class gm_commandscript : public CommandScript Field* fields = result->Fetch(); std::string name = fields[0].Get(); uint8 security = fields[1].Get(); - uint8 max = (16 - name.length()) / 2; - uint8 max2 = max; - if ((max + max2 + name.length()) == 16) - max2 = max - 1; - if (handler->GetSession()) - handler->PSendSysMessage("| %s GMLevel %u", name.c_str(), security); - else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name.c_str(), max2, " ", security); + handler->PSendSysMessage("| {} GMLevel {}", name, security); } while (result->NextRow()); handler->SendSysMessage("========================"); } @@ -207,14 +195,14 @@ class gm_commandscript : public CommandScript _player->SetGMVisible(true); _player->UpdateObjectVisibility(); - handler->GetSession()->SendNotification(LANG_INVISIBLE_VISIBLE); + Acore::Text::SendNotification(handler->GetSession(), LANG_INVISIBLE_VISIBLE); } else { _player->AddAura(VISUAL_AURA, _player); _player->SetGMVisible(false); _player->UpdateObjectVisibility(); - handler->GetSession()->SendNotification(LANG_INVISIBLE_INVISIBLE); + Acore::Text::SendNotification(handler->GetSession(), LANG_INVISIBLE_INVISIBLE); } return true; @@ -224,7 +212,7 @@ class gm_commandscript : public CommandScript { handler->GetPlayer()->SetGameMaster(true); handler->GetPlayer()->UpdateTriggerVisibility(); - handler->GetSession()->SendNotification(LANG_GM_ON); + Acore::Text::SendNotification(handler->GetSession(), LANG_GM_ON); return true; } @@ -232,7 +220,7 @@ class gm_commandscript : public CommandScript { handler->GetPlayer()->SetGameMaster(false); handler->GetPlayer()->UpdateTriggerVisibility(); - handler->GetSession()->SendNotification(LANG_GM_OFF); + Acore::Text::SendNotification(handler->GetSession(), LANG_GM_OFF); return true; } }; diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 7fbf3778082dd9..fc36d374431e27 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -150,7 +150,7 @@ class gobject_commandscript : public CommandScript /// @todo is it really necessary to add both the real and DB table guid here ? sObjectMgr->AddGameobjectToGrid(guidLow, sObjectMgr->GetGOData(guidLow)); - handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, uint32(objectId), objectInfo->name.c_str(), guidLow, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); + handler->PSendSysMessage(LANG_GAMEOBJECT_ADD, uint32(objectId), objectInfo->name, guidLow, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ()); return true; } @@ -277,7 +277,7 @@ class gobject_commandscript : public CommandScript GameObject* target = handler->GetObjectFromPlayerMapByDbGuid(guidLow); - handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name.c_str(), guidLow, id, x, y, z, mapId, o, phase); + handler->PSendSysMessage(LANG_GAMEOBJECT_DETAIL, guidLow, objectInfo->name, guidLow, id, x, y, z, mapId, o, phase); if (target) { @@ -288,7 +288,7 @@ class gobject_commandscript : public CommandScript std::string curRespawnDelayStr = secsToTimeString(curRespawnDelay, true); std::string defRespawnDelayStr = secsToTimeString(target->GetRespawnDelay(), true); - handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str()); + handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr, curRespawnDelayStr); } return true; } @@ -362,7 +362,7 @@ class gobject_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId()); + handler->PSendSysMessage(LANG_COMMAND_TURNOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name, object->GetSpawnId()); return true; } @@ -419,7 +419,7 @@ class gobject_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name.c_str(), object->GetSpawnId()); + handler->PSendSysMessage(LANG_COMMAND_MOVEOBJMESSAGE, object->GetSpawnId(), object->GetGOInfo()->name, object->GetSpawnId()); return true; } @@ -485,7 +485,7 @@ class gobject_commandscript : public CommandScript if (!gameObjectInfo) continue; - handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gameObjectInfo->name.c_str(), x, y, z, mapId, "", ""); + handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gameObjectInfo->name, x, y, z, mapId, "", ""); ++count; } while (result->NextRow()); @@ -539,15 +539,15 @@ class gobject_commandscript : public CommandScript handler->PSendSysMessage(LANG_GOINFO_DISPLAYID, displayId); if (gameObject) { - handler->PSendSysMessage("LootMode: %u", gameObject->GetLootMode()); - handler->PSendSysMessage("LootState: %u", gameObject->getLootState()); - handler->PSendSysMessage("GOState: %u", gameObject->GetGoState()); - handler->PSendSysMessage("PhaseMask: %u", gameObject->GetPhaseMask()); - handler->PSendSysMessage("IsLootEmpty: %u", gameObject->loot.empty()); - handler->PSendSysMessage("IsLootLooted: %u", gameObject->loot.isLooted()); + handler->PSendSysMessage("LootMode: {}", gameObject->GetLootMode()); + handler->PSendSysMessage("LootState: {}", gameObject->getLootState()); + handler->PSendSysMessage("GOState: {}", gameObject->GetGoState()); + handler->PSendSysMessage("PhaseMask: {}", gameObject->GetPhaseMask()); + handler->PSendSysMessage("IsLootEmpty: {}", gameObject->loot.empty()); + handler->PSendSysMessage("IsLootLooted: {}", gameObject->loot.isLooted()); } - handler->PSendSysMessage(LANG_GOINFO_NAME, name.c_str()); + handler->PSendSysMessage(LANG_GOINFO_NAME, name); return true; } @@ -583,7 +583,7 @@ class gobject_commandscript : public CommandScript { object->SendCustomAnim(*objectState); } - handler->PSendSysMessage("Set gobject type %d state %u", objectType, *objectState); + handler->PSendSysMessage("Set gobject type {} state {}", objectType, *objectState); return true; } }; diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp index e2553dd22c8054..9ac45b8efaaf6c 100644 --- a/src/server/scripts/Commands/cs_group.cpp +++ b/src/server/scripts/Commands/cs_group.cpp @@ -157,7 +157,7 @@ class group_commandscript : public CommandScript { groupSource->AddMember(playerTarget); groupSource->BroadcastGroupUpdate(); - handler->PSendSysMessage(LANG_GROUP_PLAYER_JOINED, playerTarget->GetName().c_str(), playerSource->GetName().c_str()); + handler->PSendSysMessage(LANG_GROUP_PLAYER_JOINED, playerTarget->GetName(), playerSource->GetName()); return true; } else @@ -170,7 +170,7 @@ class group_commandscript : public CommandScript else { // group is full or target player already in a group - handler->PSendSysMessage(LANG_GROUP_ALREADY_IN_GROUP, playerTarget->GetName().c_str()); + handler->PSendSysMessage(LANG_GROUP_ALREADY_IN_GROUP, playerTarget->GetName()); return true; } } @@ -178,7 +178,7 @@ class group_commandscript : public CommandScript else { // specified source player is not in a group - handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, playerSource->GetName().c_str()); + handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, playerSource->GetName()); return true; } } @@ -215,7 +215,7 @@ class group_commandscript : public CommandScript if (!groupTarget) { - handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, target->GetName().c_str()); + handler->PSendSysMessage(LANG_GROUP_NOT_IN_GROUP, target->GetName()); return true; } diff --git a/src/server/scripts/Commands/cs_guild.cpp b/src/server/scripts/Commands/cs_guild.cpp index 45efab856b7e5c..3a8648712a6e24 100644 --- a/src/server/scripts/Commands/cs_guild.cpp +++ b/src/server/scripts/Commands/cs_guild.cpp @@ -274,18 +274,18 @@ class guild_commandscript : public CommandScript return false; // Display Guild Information - handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName().c_str(), guild->GetId()); // Guild Id + Name + handler->PSendSysMessage(LANG_GUILD_INFO_NAME, guild->GetName(), guild->GetId()); // Guild Id + Name std::string guildMasterName; if (sCharacterCache->GetCharacterNameByGuid(guild->GetLeaderGUID(), guildMasterName)) { - handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName.c_str(), guild->GetLeaderGUID().GetCounter()); // Guild Master + handler->PSendSysMessage(LANG_GUILD_INFO_GUILD_MASTER, guildMasterName, guild->GetLeaderGUID().GetCounter()); // Guild Master } - handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, Acore::Time::TimeToHumanReadable(Seconds(guild->GetCreatedDate())).c_str()); // Creation Date + handler->PSendSysMessage(LANG_GUILD_INFO_CREATION_DATE, Acore::Time::TimeToHumanReadable(Seconds(guild->GetCreatedDate()))); // Creation Date handler->PSendSysMessage(LANG_GUILD_INFO_MEMBER_COUNT, guild->GetMemberCount()); // Number of Members handler->PSendSysMessage(LANG_GUILD_INFO_BANK_GOLD, guild->GetTotalBankMoney() / 100 / 100); // Bank Gold (in gold coins) - handler->PSendSysMessage(LANG_GUILD_INFO_MOTD, guild->GetMOTD().c_str()); // Message of the day - handler->PSendSysMessage(LANG_GUILD_INFO_EXTRA_INFO, guild->GetInfo().c_str()); // Extra Information + handler->PSendSysMessage(LANG_GUILD_INFO_MOTD, guild->GetMOTD()); // Message of the day + handler->PSendSysMessage(LANG_GUILD_INFO_EXTRA_INFO, guild->GetInfo()); // Extra Information return true; } }; diff --git a/src/server/scripts/Commands/cs_instance.cpp b/src/server/scripts/Commands/cs_instance.cpp index d9170ad6cd41e7..018f79bbcc3f6f 100644 --- a/src/server/scripts/Commands/cs_instance.cpp +++ b/src/server/scripts/Commands/cs_instance.cpp @@ -76,13 +76,13 @@ class instance_commandscript : public CommandScript uint32 resetTime = bind.extended ? save->GetExtendedResetTime() : save->GetResetTime(); uint32 ttr = (resetTime >= GameTime::GetGameTime().count() ? resetTime - GameTime::GetGameTime().count() : 0); std::string timeleft = secsToTimeString(ttr); - handler->PSendSysMessage("map: %d, inst: %d, perm: %s, diff: %d, canReset: %s, TTR: %s%s", - mapId, save->GetInstanceId(), bind.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str(), (bind.extended ? " (extended)" : "")); + handler->PSendSysMessage("map: {}, inst: {}, perm: {}, diff: {}, canReset: {}, TTR: {}{}", + mapId, save->GetInstanceId(), bind.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft, (bind.extended ? " (extended)" : "")); counter++; } } - handler->PSendSysMessage("player binds: %d", counter); + handler->PSendSysMessage("player binds: {}", counter); return true; } @@ -114,7 +114,7 @@ class instance_commandscript : public CommandScript uint32 resetTime = itr->second.extended ? save->GetExtendedResetTime() : save->GetResetTime(); uint32 ttr = (resetTime >= GameTime::GetGameTime().count() ? resetTime - GameTime::GetGameTime().count() : 0); std::string timeleft = secsToTimeString(ttr); - handler->PSendSysMessage("unbinding map: %d, inst: %d, perm: %s, diff: %d, canReset: %s, TTR: %s%s", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft.c_str(), (itr->second.extended ? " (extended)" : "")); + handler->PSendSysMessage("unbinding map: {}, inst: {}, perm: {}, diff: {}, canReset: {}, TTR: {}{}", itr->first, save->GetInstanceId(), itr->second.perm ? "yes" : "no", save->GetDifficulty(), save->CanReset() ? "yes" : "no", timeleft, (itr->second.extended ? " (extended)" : "")); sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), itr->first, Difficulty(i), true, player); itr = m_boundInstances.begin(); counter++; @@ -124,7 +124,7 @@ class instance_commandscript : public CommandScript } } - handler->PSendSysMessage("instances unbound: %d", counter); + handler->PSendSysMessage("instances unbound: {}", counter); return true; } @@ -133,13 +133,13 @@ class instance_commandscript : public CommandScript { uint32 dungeon = 0, battleground = 0, arena = 0, spectators = 0; sMapMgr->GetNumInstances(dungeon, battleground, arena); - handler->PSendSysMessage("instances loaded: dungeons (%d), battlegrounds (%d), arenas (%d)", dungeon, battleground, arena); + handler->PSendSysMessage("instances loaded: dungeons ({}), battlegrounds ({}), arenas ({})", dungeon, battleground, arena); dungeon = 0; battleground = 0; arena = 0; spectators = 0; sMapMgr->GetNumPlayersInInstances(dungeon, battleground, arena, spectators); - handler->PSendSysMessage("players in instances: dungeons (%d), battlegrounds (%d), arenas (%d + %d spect)", dungeon, battleground, arena, spectators); + handler->PSendSysMessage("players in instances: dungeons ({}), battlegrounds ({}), arenas ({} + {} spect)", dungeon, battleground, arena, spectators); handler->SetSentErrorMessage(true); return false; @@ -213,7 +213,7 @@ class instance_commandscript : public CommandScript map->GetInstanceScript()->SetBossState(encounterId, EncounterState(state)); std::string stateName = InstanceScript::GetBossStateName(state); - handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state, stateName.c_str()); + handler->PSendSysMessage(LANG_COMMAND_INST_SET_BOSS_STATE, encounterId, state, stateName); return true; } @@ -261,7 +261,7 @@ class instance_commandscript : public CommandScript uint32 state = map->GetInstanceScript()->GetBossState(encounterId); std::string stateName = InstanceScript::GetBossStateName(state); - handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state, stateName.c_str()); + handler->PSendSysMessage(LANG_COMMAND_INST_GET_BOSS_STATE, encounterId, state, stateName); return true; } }; diff --git a/src/server/scripts/Commands/cs_inventory.cpp b/src/server/scripts/Commands/cs_inventory.cpp index 649fe310cc6b74..cb8b7171b8c73f 100644 --- a/src/server/scripts/Commands/cs_inventory.cpp +++ b/src/server/scripts/Commands/cs_inventory.cpp @@ -175,7 +175,7 @@ class inventory_commandscript : public CommandScript str << "."; - handler->SendSysMessage(str.str().c_str()); + handler->SendSysMessage(str.str()); return true; } diff --git a/src/server/scripts/Commands/cs_item.cpp b/src/server/scripts/Commands/cs_item.cpp index d3edb1133915b7..13ebe3fe7d5c4d 100644 --- a/src/server/scripts/Commands/cs_item.cpp +++ b/src/server/scripts/Commands/cs_item.cpp @@ -116,7 +116,7 @@ class item_commandscript : public CommandScript CharacterDatabase.Execute(delStmt); std::string nameLink = handler->playerLink(player.GetName()); - handler->PSendSysMessage(LANG_MAIL_SENT, nameLink.c_str()); + handler->PSendSysMessage(LANG_MAIL_SENT, nameLink); return true; } diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index 6ea772dd49e9b5..76f3a949f1f8ec 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -302,7 +302,7 @@ class learn_commandscript : public CommandScript target->LearnCustomSpells(); target->learnQuestRewardedSpells(); - handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_COMMAND_LEARN_ALL_DEFAULT_AND_QUEST, handler->GetNameLink(target)); return true; } diff --git a/src/server/scripts/Commands/cs_lfg.cpp b/src/server/scripts/Commands/cs_lfg.cpp index 681de423566a0b..7555836144b19b 100644 --- a/src/server/scripts/Commands/cs_lfg.cpp +++ b/src/server/scripts/Commands/cs_lfg.cpp @@ -32,9 +32,9 @@ void GetPlayerInfo(ChatHandler* handler, Player* player) lfg::LfgDungeonSet dungeons = sLFGMgr->GetSelectedDungeons(guid); std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid)); - handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName().c_str(), - state.c_str(), uint8(dungeons.size()), lfg::ConcatenateDungeons(dungeons).c_str(), - lfg::GetRolesString(sLFGMgr->GetRoles(guid)).c_str(), sLFGMgr->GetComment(guid).c_str()); + handler->PSendSysMessage(LANG_LFG_PLAYER_INFO, player->GetName(), + state, uint8(dungeons.size()), lfg::ConcatenateDungeons(dungeons), + lfg::GetRolesString(sLFGMgr->GetRoles(guid)), sLFGMgr->GetComment(guid)); } using namespace Acore::ChatCommands; @@ -90,14 +90,14 @@ class lfg_commandscript : public CommandScript groupTarget = target->GetGroup(); if (!groupTarget) { - handler->PSendSysMessage(LANG_LFG_NOT_IN_GROUP, player->GetName().c_str()); + handler->PSendSysMessage(LANG_LFG_NOT_IN_GROUP, player->GetName()); return true; } ObjectGuid guid = groupTarget->GetGUID(); std::string const& state = lfg::GetStateString(sLFGMgr->GetState(guid)); handler->PSendSysMessage(LANG_LFG_GROUP_INFO, groupTarget->isLFGGroup(), - state.c_str(), sLFGMgr->GetDungeon(guid)); + state, sLFGMgr->GetDungeon(guid)); for (GroupReference* itr = groupTarget->GetFirstMember(); itr != nullptr; itr = itr->next()) GetPlayerInfo(handler, itr->GetSource()); diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index 7e9d44ddfc11dd..4f35355ad27b2e 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -127,9 +127,9 @@ class list_commandscript : public CommandScript for (std::unordered_multimap::const_iterator itr = creBounds.first; itr != creBounds.second;) { if (handler->GetSession()) - handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->IsAlive() ? "*" : " "); + handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->IsAlive() ? "*" : " "); else - handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->IsAlive() ? "*" : " "); + handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->IsAlive() ? "*" : " "); ++itr; } liveFound = true; @@ -139,9 +139,9 @@ class list_commandscript : public CommandScript if (!liveFound) { if (handler->GetSession()) - handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name.c_str(), x, y, z, mapId, "", ""); + handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, cInfo->Name, x, y, z, mapId, "", ""); else - handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name.c_str(), x, y, z, mapId, "", ""); + handler->PSendSysMessage(LANG_CREATURE_LIST_CONSOLE, guid, cInfo->Name, x, y, z, mapId, "", ""); } } while (result->NextRow()); @@ -208,7 +208,7 @@ class list_commandscript : public CommandScript else itemPos = ""; - handler->PSendSysMessage(LANG_ITEMLIST_SLOT, itemGuid, ownerName.c_str(), ownerGuid, ownerAccountId, itemPos); + handler->PSendSysMessage(LANG_ITEMLIST_SLOT, itemGuid, ownerName, ownerGuid, ownerAccountId, itemPos); } while (result->NextRow()); @@ -255,7 +255,7 @@ class list_commandscript : public CommandScript char const* itemPos = "[in mail]"; - handler->PSendSysMessage(LANG_ITEMLIST_MAIL, itemGuid, itemSenderName.c_str(), itemSender, itemSenderAccountId, itemReceiverName.c_str(), itemReceiver, itemReceiverAccount, itemPos); + handler->PSendSysMessage(LANG_ITEMLIST_MAIL, itemGuid, itemSenderName, itemSender, itemSenderAccountId, itemReceiverName, itemReceiver, itemReceiverAccount, itemPos); } while (result->NextRow()); @@ -299,7 +299,7 @@ class list_commandscript : public CommandScript char const* itemPos = "[in auction]"; - handler->PSendSysMessage(LANG_ITEMLIST_AUCTION, itemGuid, ownerName.c_str(), owner, ownerAccountId, itemPos); + handler->PSendSysMessage(LANG_ITEMLIST_AUCTION, itemGuid, ownerName, owner, ownerAccountId, itemPos); } while (result->NextRow()); } @@ -330,7 +330,7 @@ class list_commandscript : public CommandScript char const* itemPos = "[in guild bank]"; - handler->PSendSysMessage(LANG_ITEMLIST_GUILD, itemGuid, guildName.c_str(), guildGuid, itemPos); + handler->PSendSysMessage(LANG_ITEMLIST_GUILD, itemGuid, guildName, guildGuid, itemPos); } while (result->NextRow()); @@ -415,9 +415,9 @@ class list_commandscript : public CommandScript for (std::unordered_multimap::const_iterator itr = goBounds.first; itr != goBounds.second;) { if (handler->GetSession()) - handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->isSpawned() ? "*" : " "); + handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->isSpawned() ? "*" : " "); else - handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name.c_str(), x, y, z, mapId, itr->second->GetGUID().ToString().c_str(), itr->second->isSpawned() ? "*" : " "); + handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapId, itr->second->GetGUID().ToString(), itr->second->isSpawned() ? "*" : " "); ++itr; } liveFound = true; @@ -427,9 +427,9 @@ class list_commandscript : public CommandScript if (!liveFound) { if (handler->GetSession()) - handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name.c_str(), x, y, z, mapId, "", ""); + handler->PSendSysMessage(LANG_GO_LIST_CHAT, guid, entry, guid, gInfo->name, x, y, z, mapId, "", ""); else - handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name.c_str(), x, y, z, mapId, "", ""); + handler->PSendSysMessage(LANG_GO_LIST_CONSOLE, guid, gInfo->name, x, y, z, mapId, "", ""); } } while (result->NextRow()); @@ -467,8 +467,8 @@ class list_commandscript : public CommandScript wstrToLower(namePart); - char const* talentStr = handler->GetAcoreString(LANG_TALENT); - char const* passiveStr = handler->GetAcoreString(LANG_PASSIVE); + std::string talentStr = handler->GetAcoreString(LANG_TALENT); + std::string passiveStr = handler->GetAcoreString(LANG_PASSIVE); Unit::AuraApplicationMap const& auras = unit->GetAppliedAuras(); handler->PSendSysMessage(LANG_COMMAND_TARGET_LISTAURAS, auras.size()); @@ -485,7 +485,7 @@ class list_commandscript : public CommandScript std::ostringstream ss_name; ss_name << "|cffffffff|Hspell:" << aura->GetId() << "|h[" << name << "]|h|r"; - handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str().c_str() : name), + handler->PSendSysMessage(LANG_COMMAND_TARGET_AURADETAIL, aura->GetId(), (handler->GetSession() ? ss_name.str() : name), aurApp->GetEffectMask(), aura->GetCharges(), aura->GetStackAmount(), aurApp->GetSlot(), aura->GetDuration(), aura->GetMaxDuration(), (aura->IsPassive() ? passiveStr : ""), (talent ? talentStr : ""), aura->GetCasterGUID().IsPlayer() ? "player" : "creature", diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index d4f2ce45b812c0..92b7df70c374c4 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -26,6 +26,7 @@ EndScriptData */ #include "CharacterCache.h" #include "Chat.h" #include "GameEventMgr.h" +#include "GameLocale.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "Player.h" @@ -153,7 +154,7 @@ class lookup_commandscript : public CommandScript ss << areaEntry->ID << " - " << name << ' ' << localeNames[locale]; } - handler->SendSysMessage(ss.str().c_str()); + handler->SendSysMessage(ss.str()); if (!found) { @@ -195,7 +196,7 @@ class lookup_commandscript : public CommandScript { uint32 id = creatureTemplate.Entry; uint8 localeIndex = handler->GetSessionDbLocaleIndex(); - if (CreatureLocale const* creatureLocale = sObjectMgr->GetCreatureLocale(id)) + if (CreatureLocale const* creatureLocale = sGameLocale->GetCreatureLocale(id)) { if (creatureLocale->Name.size() > localeIndex && !creatureLocale->Name[localeIndex].empty()) { @@ -211,11 +212,11 @@ class lookup_commandscript : public CommandScript if (handler->GetSession()) { - handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str()); + handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name); } else { - handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str()); + handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name); } if (!found) @@ -244,11 +245,11 @@ class lookup_commandscript : public CommandScript if (handler->GetSession()) { - handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str()); + handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name); } else { - handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str()); + handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name); } if (!found) @@ -308,15 +309,15 @@ class lookup_commandscript : public CommandScript return true; } - char const* active = activeEvents.find(id) != activeEvents.end() ? handler->GetAcoreString(LANG_ACTIVE) : ""; + std::string active = activeEvents.find(id) != activeEvents.end() ? handler->GetAcoreString(LANG_ACTIVE) : ""; if (handler->GetSession()) { - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description.c_str(), active); + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CHAT, id, id, eventData.description, active); } else { - handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description.c_str(), active); + handler->PSendSysMessage(LANG_EVENT_ENTRY_LIST_CONSOLE, id, eventData.description, active); } if (!found) @@ -455,7 +456,7 @@ class lookup_commandscript : public CommandScript ss << handler->GetAcoreString(LANG_FACTION_NOREPUTATION); } - handler->SendSysMessage(ss.str().c_str()); + handler->SendSysMessage(ss.str()); if (!found) { @@ -500,7 +501,7 @@ class lookup_commandscript : public CommandScript if (localeIndex >= 0) { uint8 ulocaleIndex = uint8(localeIndex); - if (ItemLocale const* il = sObjectMgr->GetItemLocale(itemTemplate.ItemId)) + if (ItemLocale const* il = sGameLocale->GetItemLocale(itemTemplate.ItemId)) { if (il->Name.size() > ulocaleIndex && !il->Name[ulocaleIndex].empty()) { @@ -516,11 +517,11 @@ class lookup_commandscript : public CommandScript if (handler->GetSession()) { - handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, itemTemplate.ItemId, name.c_str()); + handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, itemTemplate.ItemId, name); } else { - handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name.c_str()); + handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name); } if (!found) @@ -550,11 +551,11 @@ class lookup_commandscript : public CommandScript if (handler->GetSession()) { - handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, itemTemplate.ItemId, name.c_str()); + handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itemTemplate.ItemId, itemTemplate.ItemId, name); } else { - handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name.c_str()); + handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itemTemplate.ItemId, name); } if (!found) @@ -640,11 +641,11 @@ class lookup_commandscript : public CommandScript // send item set in "id - [namedlink locale]" format if (handler->GetSession()) { - handler->PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name.c_str(), localeNames[locale]); + handler->PSendSysMessage(LANG_ITEMSET_LIST_CHAT, id, id, name, localeNames[locale]); } else { - handler->PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name.c_str(), localeNames[locale]); + handler->PSendSysMessage(LANG_ITEMSET_LIST_CONSOLE, id, name, localeNames[locale]); } if (!found) @@ -687,7 +688,7 @@ class lookup_commandscript : public CommandScript for (auto const& [entry, gameObjectTemplate] : *sObjectMgr->GetGameObjectTemplates()) { uint8 localeIndex = handler->GetSessionDbLocaleIndex(); - if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(gameObjectTemplate.entry)) + if (GameObjectLocale const* objectLocalte = sGameLocale->GetGameObjectLocale(gameObjectTemplate.entry)) { if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty()) { @@ -703,11 +704,11 @@ class lookup_commandscript : public CommandScript if (handler->GetSession()) { - handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name.c_str()); + handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name); } else { - handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name.c_str()); + handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name); } if (!found) @@ -736,11 +737,11 @@ class lookup_commandscript : public CommandScript if (handler->GetSession()) { - handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name.c_str()); + handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, gameObjectTemplate.entry, gameObjectTemplate.entry, name); } else { - handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name.c_str()); + handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, gameObjectTemplate.entry, name); } if (!found) @@ -788,7 +789,7 @@ class lookup_commandscript : public CommandScript if (localeIndex >= 0) { uint8 ulocaleIndex = uint8(localeIndex); - if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(qInfo->GetQuestId())) + if (QuestLocale const* questLocale = sGameLocale->GetQuestLocale(qInfo->GetQuestId())) { if (questLocale->Title.size() > ulocaleIndex && !questLocale->Title[ulocaleIndex].empty()) { @@ -802,7 +803,7 @@ class lookup_commandscript : public CommandScript return true; } - char const* statusStr = ""; + std::string statusStr = ""; if (target) { @@ -826,11 +827,11 @@ class lookup_commandscript : public CommandScript if (handler->GetSession()) { - handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr); + handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title, statusStr); } else { - handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr); + handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title, statusStr); } if (!found) @@ -858,7 +859,7 @@ class lookup_commandscript : public CommandScript return true; } - char const* statusStr = ""; + std::string statusStr = ""; if (target) { @@ -882,11 +883,11 @@ class lookup_commandscript : public CommandScript if (handler->GetSession()) { - handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr); + handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title, statusStr); } else { - handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr); + handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title, statusStr); } if (!found) @@ -981,17 +982,17 @@ class lookup_commandscript : public CommandScript uint32 permValue = target->GetSkillPermBonusValue(skillInfo->id); uint32 tempValue = target->GetSkillTempBonusValue(skillInfo->id); - valStr = Acore::StringFormat(handler->GetAcoreString(LANG_SKILL_VALUES), curValue, maxValue, permValue, tempValue); + valStr = Acore::StringFormatFmt(handler->GetAcoreString(LANG_SKILL_VALUES), curValue, maxValue, permValue, tempValue); } // send skill in "id - [namedlink locale]" format if (handler->GetSession()) { - handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, skillInfo->id, skillInfo->id, name.c_str(), localeNames[locale], knownStr.c_str(), valStr.c_str()); + handler->PSendSysMessage(LANG_SKILL_LIST_CHAT, skillInfo->id, skillInfo->id, name, localeNames[locale], knownStr, valStr); } else { - handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, skillInfo->id, name.c_str(), localeNames[locale], knownStr.c_str(), valStr.c_str()); + handler->PSendSysMessage(LANG_SKILL_LIST_CONSOLE, skillInfo->id, name, localeNames[locale], knownStr, valStr); } if (!found) @@ -1143,7 +1144,7 @@ class lookup_commandscript : public CommandScript ss << handler->GetAcoreString(LANG_ACTIVE); } - handler->SendSysMessage(ss.str().c_str()); + handler->SendSysMessage(ss.str()); if (!found) { @@ -1259,7 +1260,7 @@ class lookup_commandscript : public CommandScript ss << handler->GetAcoreString(LANG_ACTIVE); } - handler->SendSysMessage(ss.str().c_str()); + handler->SendSysMessage(ss.str()); if (!found) { @@ -1342,12 +1343,12 @@ class lookup_commandscript : public CommandScript // send taxinode in "id - [name] (Map:m X:x Y:y Z:z)" format if (handler->GetSession()) { - handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, nodeEntry->ID, nodeEntry->ID, name.c_str(), localeNames[locale], + handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CHAT, nodeEntry->ID, nodeEntry->ID, name, localeNames[locale], nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z); } else { - handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, nodeEntry->ID, name.c_str(), localeNames[locale], + handler->PSendSysMessage(LANG_TAXINODE_ENTRY_LIST_CONSOLE, nodeEntry->ID, name, localeNames[locale], nodeEntry->map_id, nodeEntry->x, nodeEntry->y, nodeEntry->z); } @@ -1417,7 +1418,7 @@ class lookup_commandscript : public CommandScript } else { - handler->PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str().c_str()); + handler->PSendSysMessage(LANG_COMMAND_TELE_LOCATION, reply.str()); } if (limitReached) @@ -1495,8 +1496,8 @@ class lookup_commandscript : public CommandScript return true; } - char const* knownStr = target && target->HasTitle(titleInfo) ? handler->GetAcoreString(LANG_KNOWN) : ""; - char const* activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index ? handler->GetAcoreString(LANG_ACTIVE) : ""; + std::string knownStr = target && target->HasTitle(titleInfo) ? handler->GetAcoreString(LANG_KNOWN) : ""; + std::string activeStr = target && target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index ? handler->GetAcoreString(LANG_ACTIVE) : ""; std::string titleNameStr = Acore::StringFormat(name, targetName); @@ -1584,7 +1585,7 @@ class lookup_commandscript : public CommandScript break; } - handler->SendSysMessage(ss.str().c_str()); + handler->SendSysMessage(ss.str()); ++counter; } @@ -1677,7 +1678,7 @@ class lookup_commandscript : public CommandScript if (result2) { - handler->PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, accountName.c_str(), accountId); + handler->PSendSysMessage(LANG_LOOKUP_PLAYER_ACCOUNT, accountName, accountId); do { @@ -1696,11 +1697,11 @@ class lookup_commandscript : public CommandScript if (plevel > 0 && prace > 0 && prace <= RACE_DRAENEI && pclass > 0 && pclass <= CLASS_DRUID) { - handler->PSendSysMessage(" %s (GUID %u) - %s - %s - %u%s", name.c_str(), guid, EnumUtils::ToTitle(Races(prace)), EnumUtils::ToTitle(Classes(pclass)), plevel, (online ? " - [ONLINE]" : "")); + handler->PSendSysMessage(" {} (GUID {}) - {} - {} - {}{}", name, guid, EnumUtils::ToTitle(Races(prace)), EnumUtils::ToTitle(Classes(pclass)), plevel, (online ? " - [ONLINE]" : "")); } else { - handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name.c_str(), guid); + handler->PSendSysMessage(LANG_LOOKUP_PLAYER_CHARACTER, name, guid); } ++counter; diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index 76849599563287..4149d941ad212e 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -24,6 +24,7 @@ EndScriptData */ #include "Channel.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "DBCStores.h" #include "DatabaseEnv.h" #include "Language.h" @@ -65,7 +66,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()); + Acore::Text::SendWorldText(LANG_ANNOUNCE_COLOR, name.c_str(), message.data()); return true; } @@ -78,7 +79,7 @@ class message_commandscript : public CommandScript if (WorldSession* session = handler->GetSession()) name = session->GetPlayer()->GetName(); - sWorld->SendGMText(LANG_GM_ANNOUNCE_COLOR, name.c_str(), message.data()); + Acore::Text::SendGMText(LANG_GM_ANNOUNCE_COLOR, name, message); return true; } @@ -88,7 +89,7 @@ class message_commandscript : public CommandScript if (message.empty()) return false; - sWorld->SendServerMessage(SERVER_MSG_STRING, Acore::StringFormat(handler->GetAcoreString(LANG_SYSTEMMESSAGE), message.data()).c_str()); + sWorld->SendServerMessage(SERVER_MSG_STRING, Acore::StringFormatFmt(handler->GetAcoreString(LANG_SYSTEMMESSAGE), message.data())); return true; } @@ -98,7 +99,7 @@ class message_commandscript : public CommandScript if (message.empty()) return false; - sWorld->SendGMText(LANG_GM_BROADCAST, message.data()); + Acore::Text::SendGMText(LANG_GM_BROADCAST, message); return true; } diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index ac474772d634af..3226aa8ed801e3 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -21,6 +21,7 @@ #include "CellImpl.h" #include "CharacterCache.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "GameGraveyard.h" #include "GameTime.h" #include "GridNotifiers.h" @@ -55,7 +56,7 @@ constexpr auto SPELL_FREEZE = 9454; std::string const GetLocalizeCreatureName(Creature* creature, LocaleConstant locale) { auto creatureTemplate = sObjectMgr->GetCreatureTemplate(creature->GetEntry()); - auto cretureLocale = sObjectMgr->GetCreatureLocale(creature->GetEntry()); + auto cretureLocale = sGameLocale->GetCreatureLocale(creature->GetEntry()); std::string name; if (cretureLocale) @@ -357,43 +358,43 @@ class misc_commandscript : public CommandScript switch (error) { case 1: - handler->PSendSysMessage("Player %s not found.", last_name.c_str()); + handler->PSendSysMessage("Player {} not found.", last_name); break; case 2: - handler->PSendSysMessage("Player %s is being teleported.", last_name.c_str()); + handler->PSendSysMessage("Player {} is being teleported.", last_name); break; case 3: - handler->PSendSysMessage("Player %s is in instance/battleground/arena.", last_name.c_str()); + handler->PSendSysMessage("Player {} is in instance/battleground/arena.", last_name); break; case 4: - handler->PSendSysMessage("Player %s is in LFG system.", last_name.c_str()); + handler->PSendSysMessage("Player {} is in LFG system.", last_name); break; case 5: - handler->PSendSysMessage("Player %s is queued for battleground/arena.", last_name.c_str()); + handler->PSendSysMessage("Player {} is queued for battleground/arena.", last_name); break; case 6: - handler->PSendSysMessage("Player %s is not in group.", last_name.c_str()); + handler->PSendSysMessage("Player {} is not in group.", last_name); break; case 7: - handler->PSendSysMessage("Player %s is not in normal group.", last_name.c_str()); + handler->PSendSysMessage("Player {} is not in normal group.", last_name); break; case 8: - handler->PSendSysMessage("Group of player %s has invalid member count.", last_name.c_str()); + handler->PSendSysMessage("Group of player {} has invalid member count.", last_name); break; case 9: - handler->PSendSysMessage("Players %s are not in the same group.", last_name.c_str()); + handler->PSendSysMessage("Players {} are not in the same group.", last_name); break; case 10: - handler->PSendSysMessage("Player %s is in flight.", last_name.c_str()); + handler->PSendSysMessage("Player {} is in flight.", last_name); break; case 11: - handler->PSendSysMessage("Player %s is dead.", last_name.c_str()); + handler->PSendSysMessage("Player {} is dead.", last_name); break; case 12: - handler->PSendSysMessage("Player %s is in a group.", last_name.c_str()); + handler->PSendSysMessage("Player {} is in a group.", last_name); break; case 13: - handler->PSendSysMessage("Player %s occurs more than once.", last_name.c_str()); + handler->PSendSysMessage("Player {} occurs more than once.", last_name); break; } @@ -457,7 +458,7 @@ class misc_commandscript : public CommandScript auto SetDevMod = [&](bool enable) { - session->SendNotification(enable ? LANG_DEV_ON : LANG_DEV_OFF); + Acore::Text::SendNotification(session, enable ? LANG_DEV_ON : LANG_DEV_OFF); session->GetPlayer()->SetDeveloper(enable); sScriptMgr->OnHandleDevCommand(handler->GetSession()->GetPlayer(), enable); }; @@ -580,7 +581,7 @@ class misc_commandscript : public CommandScript if (object->GetTransport()) { - handler->PSendSysMessage("Transport offset: %.2f, %.2f, %.2f, %.2f", object->m_movementInfo.transport.pos.GetPositionX(), object->m_movementInfo.transport.pos.GetPositionY(), object->m_movementInfo.transport.pos.GetPositionZ(), object->m_movementInfo.transport.pos.GetOrientation()); + handler->PSendSysMessage("Transport offset: {0:.2f}, {0:.2f}, {0:.2f}, {0:.2f}", object->m_movementInfo.transport.pos.GetPositionX(), object->m_movementInfo.transport.pos.GetPositionY(), object->m_movementInfo.transport.pos.GetPositionZ(), object->m_movementInfo.transport.pos.GetOrientation()); } return true; @@ -690,7 +691,7 @@ class misc_commandscript : public CommandScript // only allow if gm mode is on if (!_player->IsGameMaster()) { - handler->PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink.c_str()); + handler->PSendSysMessage(LANG_CANNOT_GO_TO_BG_GM, nameLink); handler->SetSentErrorMessage(true); return false; } @@ -712,7 +713,7 @@ class misc_commandscript : public CommandScript // we are in group, we can go only if we are in the player group if (_player->GetGroup() != targetPlayer->GetGroup()) { - handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY, nameLink.c_str()); + handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_PARTY, nameLink); handler->SetSentErrorMessage(true); return false; } @@ -722,7 +723,7 @@ class misc_commandscript : public CommandScript // we are not in group, let's verify our GM mode if (!_player->IsGameMaster()) { - handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM, nameLink.c_str()); + handler->PSendSysMessage(LANG_CANNOT_GO_TO_INST_GM, nameLink); handler->SetSentErrorMessage(true); return false; } @@ -748,7 +749,7 @@ class misc_commandscript : public CommandScript } } - handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str()); + handler->PSendSysMessage(LANG_APPEARING_AT, nameLink); // stop flight if need if (_player->IsInFlight()) @@ -774,7 +775,7 @@ class misc_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_APPEARING_AT, nameLink.c_str()); + handler->PSendSysMessage(LANG_APPEARING_AT, nameLink); // to point where player stay (if loaded) float x, y, z, o; @@ -839,7 +840,7 @@ class misc_commandscript : public CommandScript if (targetPlayer->IsBeingTeleported()) { - handler->PSendSysMessage(LANG_IS_TELEPORTED, nameLink.c_str()); + handler->PSendSysMessage(LANG_IS_TELEPORTED, nameLink); handler->SetSentErrorMessage(true); return false; } @@ -879,16 +880,16 @@ class misc_commandscript : public CommandScript (handler->GetSession()->GetPlayer()->GetGroup()->GetLeaderGUID() != handler->GetSession()->GetPlayer()->GetGUID())) // the last check is a bit excessive, but let it be, just in case { - handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink.c_str()); + handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, nameLink); handler->SetSentErrorMessage(true); return false; } } - handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), ""); + handler->PSendSysMessage(LANG_SUMMONING, nameLink, ""); if (handler->needReportToTarget(targetPlayer)) { - ChatHandler(targetPlayer->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str()); + ChatHandler(targetPlayer->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName())); } // stop flight if need @@ -916,7 +917,7 @@ class misc_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_SUMMONING, nameLink.c_str(), handler->GetAcoreString(LANG_OFFLINE)); + handler->PSendSysMessage(LANG_SUMMONING, nameLink, handler->GetAcoreString(LANG_OFFLINE)); // in point where GM stay Player::SavePositionInDB(handler->GetSession()->GetPlayer()->GetMapId(), @@ -958,7 +959,7 @@ class misc_commandscript : public CommandScript if (!group) { - handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str()); + handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink); handler->SetSentErrorMessage(true); return false; } @@ -996,7 +997,7 @@ class misc_commandscript : public CommandScript if (player->IsBeingTeleported()) { - handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); + handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink); handler->SetSentErrorMessage(true); return false; } @@ -1008,16 +1009,16 @@ class misc_commandscript : public CommandScript if (playerMap->Instanceable() && playerMap->GetInstanceId() != gmMap->GetInstanceId()) { // cannot summon from instance to instance - handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink.c_str()); + handler->PSendSysMessage(LANG_CANNOT_SUMMON_TO_INST, plNameLink); handler->SetSentErrorMessage(true); return false; } } - handler->PSendSysMessage(LANG_SUMMONING, plNameLink.c_str(), ""); + handler->PSendSysMessage(LANG_SUMMONING, plNameLink, ""); if (handler->needReportToTarget(player)) { - ChatHandler(player->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink().c_str()); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->GetNameLink()); } // stop flight if need @@ -1151,7 +1152,7 @@ class misc_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_OBJECT_GUID, guid.ToString().c_str()); + handler->PSendSysMessage(LANG_OBJECT_GUID, guid.ToString()); return true; } @@ -1182,7 +1183,7 @@ class misc_commandscript : public CommandScript if (!spell) { target->RemoveAllSpellCooldown(); - handler->PSendSysMessage(LANG_REMOVEALL_COOLDOWN, nameLink.c_str()); + handler->PSendSysMessage(LANG_REMOVEALL_COOLDOWN, nameLink); } else { @@ -1194,7 +1195,7 @@ class misc_commandscript : public CommandScript } target->RemoveSpellCooldown(spell.value()->Id, true); - handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spell.value()->Id, target == handler->GetSession()->GetPlayer() ? handler->GetAcoreString(LANG_YOU) : nameLink.c_str()); + handler->PSendSysMessage(LANG_REMOVE_COOLDOWN, spell.value()->Id, target == handler->GetSession()->GetPlayer() ? handler->GetAcoreString(LANG_YOU) : nameLink); } return true; } @@ -1249,7 +1250,7 @@ class misc_commandscript : public CommandScript if (targetPlayer->IsBeingTeleported()) { - handler->PSendSysMessage(LANG_IS_TELEPORTED, handler->playerLink(target->GetName()).c_str()); + handler->PSendSysMessage(LANG_IS_TELEPORTED, handler->playerLink(target->GetName())); handler->SetSentErrorMessage(true); return false; } @@ -1339,11 +1340,11 @@ 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()); + Acore::Text::SendWorldText(LANG_COMMAND_KICKMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), target->GetName().c_str(), kickReasonStr.c_str()); } else { - handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, target->GetName().c_str()); + handler->PSendSysMessage(LANG_COMMAND_KICKMESSAGE, target->GetName()); } targetPlayer->GetSession()->KickPlayer("HandleKickPlayerCommand"); @@ -1520,7 +1521,7 @@ class misc_commandscript : public CommandScript team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ALLIANCE); } - handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, graveyardId, team_name.c_str(), zone_id); + handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNEAREST, graveyardId, team_name, zone_id); } else { @@ -1539,7 +1540,7 @@ class misc_commandscript : public CommandScript team_name = handler->GetAcoreString(LANG_COMMAND_GRAVEYARD_ALLIANCE); } - handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name.c_str()); + handler->PSendSysMessage(LANG_COMMAND_ZONENOGRAFACTION, zone_id, team_name); } return true; @@ -1652,19 +1653,19 @@ class misc_commandscript : public CommandScript if (!playerTarget->HasItemCount(itemId, 0)) { // output that player don't have any items to destroy - handler->PSendSysMessage(LANG_REMOVEITEM_FAILURE, handler->GetNameLink(playerTarget).c_str(), itemId); + handler->PSendSysMessage(LANG_REMOVEITEM_FAILURE, handler->GetNameLink(playerTarget), itemId); } else if (!playerTarget->HasItemCount(itemId, -count)) { // output that player don't have as many items that you want to destroy - handler->PSendSysMessage(LANG_REMOVEITEM_ERROR, handler->GetNameLink(playerTarget).c_str(), itemId); + handler->PSendSysMessage(LANG_REMOVEITEM_ERROR, handler->GetNameLink(playerTarget), itemId); } } else { // output successful amount of destroyed items playerTarget->DestroyItemCount(itemId, -count, true, false); - handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget).c_str()); + handler->PSendSysMessage(LANG_REMOVEITEM, itemId, -count, handler->GetNameLink(playerTarget)); } return true; @@ -1873,7 +1874,7 @@ class misc_commandscript : public CommandScript // add the skill to the player's book with step 1 (which is the first rank, in most cases something // like 'Apprentice '. target->SetSkill(skillID, targetHasSkill ? target->GetSkillStep(skillID) : 1, level, max); - handler->PSendSysMessage(LANG_SET_SKILL, skillID, skillLine->name[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max); + handler->PSendSysMessage(LANG_SET_SKILL, skillID, skillLine->name[handler->GetSessionDbcLocale()], handler->GetNameLink(target), level, max); return true; } @@ -1936,8 +1937,8 @@ class misc_commandscript : public CommandScript uint32 mapId; uint32 areaId; uint32 phase = 0; - char const* areaName = nullptr; - char const* zoneName = nullptr; + std::string areaName = ""; + std::string zoneName = ""; // Guild data print variables defined so that they exist, but are not necessarily used uint32 guildId = 0; @@ -2121,7 +2122,7 @@ class misc_commandscript : public CommandScript // Initiate output // Output I. LANG_PINFO_PLAYER - handler->PSendSysMessage(LANG_PINFO_PLAYER, playerTarget ? "" : handler->GetAcoreString(LANG_OFFLINE), nameLink.c_str(), target->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_PINFO_PLAYER, playerTarget ? "" : handler->GetAcoreString(LANG_OFFLINE), nameLink, target->GetGUID().GetCounter()); // Output II. LANG_PINFO_GM_ACTIVE if character is gamemaster if (playerTarget && playerTarget->IsGameMaster()) @@ -2132,29 +2133,29 @@ class misc_commandscript : public CommandScript // Output III. LANG_PINFO_BANNED if ban exists and is applied if (banTime >= 0) { - handler->PSendSysMessage(LANG_PINFO_BANNED, banType.c_str(), banReason.c_str(), banTime > 0 ? secsToTimeString(banTime - GameTime::GetGameTime().count(), true).c_str() : handler->GetAcoreString(LANG_PERMANENTLY), bannedBy.c_str()); + handler->PSendSysMessage(LANG_PINFO_BANNED, banType, banReason, banTime > 0 ? secsToTimeString(banTime - GameTime::GetGameTime().count(), true) : handler->GetAcoreString(LANG_PERMANENTLY), bannedBy); } // Output IV. LANG_PINFO_MUTED if mute is applied if (muteTime > 0) { - handler->PSendSysMessage(LANG_PINFO_MUTED, muteReason.c_str(), secsToTimeString(muteTime - GameTime::GetGameTime().count(), true).c_str(), muteBy.c_str()); + handler->PSendSysMessage(LANG_PINFO_MUTED, muteReason, secsToTimeString(muteTime - GameTime::GetGameTime().count(), true), muteBy); } // Output V. LANG_PINFO_ACC_ACCOUNT - handler->PSendSysMessage(LANG_PINFO_ACC_ACCOUNT, userName.c_str(), accId, security); + handler->PSendSysMessage(LANG_PINFO_ACC_ACCOUNT, userName, accId, security); // Output VI. LANG_PINFO_ACC_LASTLOGIN - handler->PSendSysMessage(LANG_PINFO_ACC_LASTLOGIN, lastLogin.c_str(), failedLogins); + handler->PSendSysMessage(LANG_PINFO_ACC_LASTLOGIN, lastLogin, failedLogins); // Output VII. LANG_PINFO_ACC_OS - handler->PSendSysMessage(LANG_PINFO_ACC_OS, OS.c_str(), latency); + handler->PSendSysMessage(LANG_PINFO_ACC_OS, OS, latency); // Output VIII. LANG_PINFO_ACC_REGMAILS - handler->PSendSysMessage(LANG_PINFO_ACC_REGMAILS, regMail.c_str(), eMail.c_str()); + handler->PSendSysMessage(LANG_PINFO_ACC_REGMAILS, regMail, eMail); // Output IX. LANG_PINFO_ACC_IP - handler->PSendSysMessage(LANG_PINFO_ACC_IP, lastIp.c_str(), locked ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO)); + handler->PSendSysMessage(LANG_PINFO_ACC_IP, lastIp, locked ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO)); // Output X. LANG_PINFO_CHR_LEVEL if (level != sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)) @@ -2167,78 +2168,15 @@ class misc_commandscript : public CommandScript } // Output XI. LANG_PINFO_CHR_RACE - switch (raceid) - { - case RACE_HUMAN: - raceStr = "Human"; - break; - case RACE_ORC: - raceStr = "Orc"; - break; - case RACE_DWARF: - raceStr = "Dwarf"; - break; - case RACE_NIGHTELF: - raceStr = "Night Elf"; - break; - case RACE_UNDEAD_PLAYER: - raceStr = "Undead"; - break; - case RACE_TAUREN: - raceStr = "Tauren"; - break; - case RACE_GNOME: - raceStr = "Gnome"; - break; - case RACE_TROLL: - raceStr = "Troll"; - break; - case RACE_BLOODELF: - raceStr = "Blood Elf"; - break; - case RACE_DRAENEI: - raceStr = "Draenei"; - break; - } - - switch (classid) - { - case CLASS_WARRIOR: - classStr = "Warrior"; - break; - case CLASS_PALADIN: - classStr = "Paladin"; - break; - case CLASS_HUNTER: - classStr = "Hunter"; - break; - case CLASS_ROGUE: - classStr = "Rogue"; - break; - case CLASS_PRIEST: - classStr = "Priest"; - break; - case CLASS_DEATH_KNIGHT: - classStr = "Death Knight"; - break; - case CLASS_SHAMAN: - classStr = "Shaman"; - break; - case CLASS_MAGE: - classStr = "Mage"; - break; - case CLASS_WARLOCK: - classStr = "Warlock"; - break; - case CLASS_DRUID: - classStr = "Druid"; - break; - } + auto _race = sGameLocale->GetRaseString(raceid); + auto _class = sGameLocale->GetClassString(classid); + raceStr = _race ? _race->GetText(handler->GetSessionDbcLocale(), gender) : handler->GetAcoreString(LANG_UNKNOWN); + classStr = _class ? _class->GetText(handler->GetSessionDbcLocale(), gender) : handler->GetAcoreString(LANG_UNKNOWN); - handler->PSendSysMessage(LANG_PINFO_CHR_RACE, (gender == 0 ? handler->GetAcoreString(LANG_CHARACTER_GENDER_MALE) : handler->GetAcoreString(LANG_CHARACTER_GENDER_FEMALE)), raceStr.c_str(), classStr.c_str()); + handler->PSendSysMessage(LANG_PINFO_CHR_RACE, (gender == 0 ? handler->GetAcoreString(LANG_CHARACTER_GENDER_MALE) : handler->GetAcoreString(LANG_CHARACTER_GENDER_FEMALE)), raceStr, classStr); // Output XII. LANG_PINFO_CHR_ALIVE - handler->PSendSysMessage(LANG_PINFO_CHR_ALIVE, alive.c_str()); + handler->PSendSysMessage(LANG_PINFO_CHR_ALIVE, alive); // Output XIII. LANG_PINFO_CHR_PHASE if player is not in GM mode (GM is in every phase) if (playerTarget && !playerTarget->IsGameMaster()) // IsInWorld() returns false on loadingscreen, so it's more @@ -2269,12 +2207,12 @@ class misc_commandscript : public CommandScript } } - if (!zoneName) + if (zoneName.empty()) { zoneName = handler->GetAcoreString(LANG_UNKNOWN); } - if (areaName) + if (areaName.empty()) { handler->PSendSysMessage(LANG_PINFO_CHR_MAP_WITH_AREA, map->name[locale], zoneName, areaName); } @@ -2286,22 +2224,22 @@ class misc_commandscript : public CommandScript // Output XVII. - XVIX. if they are not empty if (!guildName.empty()) { - handler->PSendSysMessage(LANG_PINFO_CHR_GUILD, guildName.c_str(), guildId); - handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_RANK, guildRank.c_str(), uint32(guildRankId)); + handler->PSendSysMessage(LANG_PINFO_CHR_GUILD, guildName, guildId); + handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_RANK, guildRank, uint32(guildRankId)); if (!note.empty()) { - handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_NOTE, note.c_str()); + handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_NOTE, note); } if (!officeNote.empty()) { - handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_ONOTE, officeNote.c_str()); + handler->PSendSysMessage(LANG_PINFO_CHR_GUILD_ONOTE, officeNote); } } // Output XX. LANG_PINFO_CHR_PLAYEDTIME - handler->PSendSysMessage(LANG_PINFO_CHR_PLAYEDTIME, (secsToTimeString(totalPlayerTime, true)).c_str()); + handler->PSendSysMessage(LANG_PINFO_CHR_PLAYEDTIME, (secsToTimeString(totalPlayerTime, true))); // Mail Data - an own query, because it may or may not be useful. // SQL: "SELECT SUM(CASE WHEN (checked & 1) THEN 1 ELSE 0 END) AS 'readmail', COUNT(*) AS 'totalmail' FROM mail WHERE `receiver` = ?" @@ -2417,10 +2355,10 @@ 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(), notSpeakTime, muteReasonStr.c_str()); + Acore::Text::SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); } - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy.c_str(), muteReasonStr.c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_DISABLED, notSpeakTime, muteBy, muteReasonStr); } else { @@ -2444,7 +2382,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(), notSpeakTime, muteReasonStr.c_str()); + Acore::Text::SendWorldText(LANG_COMMAND_MUTEMESSAGE_WORLD, muteBy.c_str(), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); } else { @@ -2454,7 +2392,7 @@ class misc_commandscript : public CommandScript for (HashMapHolder::MapType::const_iterator itr = m.begin(); itr != m.end(); ++itr) if (itr->second->GetSession()->GetSecurity()) ChatHandler(itr->second->GetSession()).PSendSysMessage(target ? LANG_YOU_DISABLE_CHAT : LANG_COMMAND_DISABLE_CHAT_DELAYED, - (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : handler->GetAcoreString(LANG_CONSOLE)), nameLink.c_str(), notSpeakTime, muteReasonStr.c_str()); + (handler->GetSession() ? handler->GetSession()->GetPlayerName() : handler->GetAcoreString(LANG_CONSOLE)), nameLink, notSpeakTime, muteReasonStr); } return true; @@ -2515,7 +2453,7 @@ class misc_commandscript : public CommandScript ChatHandler(playerTarget->GetSession()).PSendSysMessage(LANG_YOUR_CHAT_ENABLED); } - handler->PSendSysMessage(LANG_YOU_ENABLE_CHAT, handler->playerLink(target->GetName().c_str())); + handler->PSendSysMessage(LANG_YOU_ENABLE_CHAT, handler->playerLink(target->GetName())); return true; } @@ -2525,7 +2463,7 @@ class misc_commandscript : public CommandScript { if (!Utf8ToUpperOnlyLatin(accountName)) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); handler->SetSentErrorMessage(true); return false; } @@ -2533,7 +2471,7 @@ class misc_commandscript : public CommandScript uint32 accountId = AccountMgr::GetId(accountName); if (!accountId) { - handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName.c_str()); + handler->PSendSysMessage(LANG_ACCOUNT_NOT_EXIST, accountName); return false; } @@ -2557,7 +2495,7 @@ class misc_commandscript : public CommandScript do { Field* fields = result->Fetch(); - handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, Acore::Time::TimeToHumanReadable(Seconds(fields[0].Get())).c_str(), fields[1].Get(), fields[2].Get().c_str(), fields[3].Get().c_str()); + handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, Acore::Time::TimeToHumanReadable(Seconds(fields[0].Get())), fields[1].Get(), fields[2].Get(), fields[3].Get()); } while (result->NextRow()); return true; @@ -2623,11 +2561,11 @@ class misc_commandscript : public CommandScript } else if (target->GetTypeId() == TYPEID_PLAYER) { - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName(), target->GetGUID().GetCounter()); } else { - handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName(), target->GetGUID().GetCounter()); } break; } @@ -2649,11 +2587,11 @@ class misc_commandscript : public CommandScript } else if (target->GetTypeId() == TYPEID_PLAYER) { - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName(), target->GetGUID().GetCounter()); } else { - handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUID().GetCounter()); + handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName(), target->GetGUID().GetCounter()); } break; } @@ -2810,7 +2748,7 @@ class misc_commandscript : public CommandScript Player* playerTarget = target->GetConnectedPlayer(); if (playerTarget && !creatureTarget) { - handler->PSendSysMessage(LANG_COMMAND_FREEZE, target->GetName().c_str()); + handler->PSendSysMessage(LANG_COMMAND_FREEZE, target->GetName()); if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_FREEZE)) { @@ -2821,7 +2759,7 @@ class misc_commandscript : public CommandScript } else if (creatureTarget && creatureTarget->IsAlive()) { - handler->PSendSysMessage(LANG_COMMAND_FREEZE, GetLocalizeCreatureName(creatureTarget, handler->GetSessionDbcLocale()).c_str()); + handler->PSendSysMessage(LANG_COMMAND_FREEZE, GetLocalizeCreatureName(creatureTarget, handler->GetSessionDbcLocale())); if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(SPELL_FREEZE)) { @@ -2856,13 +2794,13 @@ class misc_commandscript : public CommandScript if (!creatureTarget && playerTarget && playerTarget->HasAura(SPELL_FREEZE)) { - handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName().c_str()); + handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName()); playerTarget->RemoveAurasDueToSpell(SPELL_FREEZE); return true; } else if (creatureTarget && creatureTarget->HasAura(SPELL_FREEZE)) { - handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, GetLocalizeCreatureName(creatureTarget, handler->GetSessionDbcLocale()).c_str()); + handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, GetLocalizeCreatureName(creatureTarget, handler->GetSessionDbcLocale())); creatureTarget->RemoveAurasDueToSpell(SPELL_FREEZE); return true; } @@ -2871,7 +2809,7 @@ class misc_commandscript : public CommandScript CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN); stmt->SetData(0, target->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); - handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName().c_str()); + handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName()); return true; } @@ -2960,7 +2898,7 @@ class misc_commandscript : public CommandScript return false; } - const char* str = sObjectMgr->GetAcoreString(id, locale ? static_cast(*locale) : DEFAULT_LOCALE); + const char* str = sGameLocale->GetAcoreString(id, locale ? static_cast(*locale) : DEFAULT_LOCALE); if (!strcmp(str, "")) { diff --git a/src/server/scripts/Commands/cs_mmaps.cpp b/src/server/scripts/Commands/cs_mmaps.cpp index eaf9323121f71b..9d84b2f90887f7 100644 --- a/src/server/scripts/Commands/cs_mmaps.cpp +++ b/src/server/scripts/Commands/cs_mmaps.cpp @@ -101,17 +101,17 @@ class mmaps_commandscript : public CommandScript bool result = path.CalculatePath(x, y, z, false); Movement::PointsArray const& pointPath = path.GetPath(); - handler->PSendSysMessage("%s's path to %s:", target->GetName().c_str(), player->GetName().c_str()); - handler->PSendSysMessage("Building: %s", useStraightPath ? "StraightPath" : useRaycast ? "Raycast" : "SmoothPath"); - handler->PSendSysMessage(Acore::StringFormatFmt("Result: {} - Length: {} - Type: {}", (result ? "true" : "false"), pointPath.size(), path.GetPathType()).c_str()); + handler->PSendSysMessage("{}'s path to {}:", target->GetName(), player->GetName()); + handler->PSendSysMessage("Building: {}", useStraightPath ? "StraightPath" : useRaycast ? "Raycast" : "SmoothPath"); + handler->PSendSysMessage(Acore::StringFormatFmt("Result: {} - Length: {} - Type: {}", (result ? "true" : "false"), pointPath.size(), path.GetPathType())); G3D::Vector3 const& start = path.GetStartPosition(); G3D::Vector3 const& end = path.GetEndPosition(); G3D::Vector3 const& actualEnd = path.GetActualEndPosition(); - handler->PSendSysMessage("StartPosition (%.3f, %.3f, %.3f)", start.x, start.y, start.z); - handler->PSendSysMessage("EndPosition (%.3f, %.3f, %.3f)", end.x, end.y, end.z); - handler->PSendSysMessage("ActualEndPosition (%.3f, %.3f, %.3f)", actualEnd.x, actualEnd.y, actualEnd.z); + handler->PSendSysMessage("StartPosition ({0:.3f}, {0:.3f}, {0:.3f})", start.x, start.y, start.z); + handler->PSendSysMessage("EndPosition ({0:.3f}, {0:.3f}, {0:.3f})", end.x, end.y, end.z); + handler->PSendSysMessage("ActualEndPosition ({0:.3f}, {0:.3f}, {0:.3f})", actualEnd.x, actualEnd.y, actualEnd.z); if (!player->IsGameMaster()) handler->PSendSysMessage("Enable GM mode to see the path points."); @@ -132,8 +132,8 @@ class mmaps_commandscript : public CommandScript int32 gx = 32 - player->GetPositionX() / SIZE_OF_GRIDS; int32 gy = 32 - player->GetPositionY() / SIZE_OF_GRIDS; - handler->PSendSysMessage("%03u%02i%02i.mmtile", player->GetMapId(), gx, gy); - handler->PSendSysMessage("gridloc [%i, %i]", gy, gx); + handler->PSendSysMessage("{:03}{:02}{:02}.mmtile", player->GetMapId(), gx, gy); + handler->PSendSysMessage("gridloc [{}, {}]", gy, gx); // calculate navmesh tile location dtNavMesh const* navmesh = MMAP::MMapFactory::createOrGetMMapMgr()->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()); @@ -153,7 +153,7 @@ class mmaps_commandscript : public CommandScript int32 tilex = int32((y - min[0]) / SIZE_OF_GRIDS); int32 tiley = int32((x - min[2]) / SIZE_OF_GRIDS); - handler->PSendSysMessage("Calc [%02i, %02i]", tilex, tiley); + handler->PSendSysMessage("Calc [{:02}, {:02}]", tilex, tiley); // navmesh poly -> navmesh tile location dtQueryFilterExt filter = dtQueryFilterExt(); @@ -174,7 +174,7 @@ class mmaps_commandscript : public CommandScript { if (tile) { - handler->PSendSysMessage("Dt [%02i,%02i]", tile->header->x, tile->header->y); + handler->PSendSysMessage("Dt [{:02},{:02}]", tile->header->x, tile->header->y); return false; } } @@ -204,7 +204,7 @@ class mmaps_commandscript : public CommandScript if (!tile || !tile->header) continue; - handler->PSendSysMessage("[%02i, %02i]", tile->header->x, tile->header->y); + handler->PSendSysMessage("[{:02}, {:02}]", tile->header->x, tile->header->y); } return true; @@ -213,10 +213,10 @@ class mmaps_commandscript : public CommandScript static bool HandleMmapStatsCommand(ChatHandler* handler) { handler->PSendSysMessage("mmap stats:"); - //handler->PSendSysMessage(" global mmap pathfinding is %sabled", DisableMgr::IsPathfindingEnabled(mapId) ? "en" : "dis"); + //handler->PSendSysMessage(" global mmap pathfinding is {}abled", DisableMgr::IsPathfindingEnabled(mapId) ? "en" : "dis"); MMAP::MMapMgr* manager = MMAP::MMapFactory::createOrGetMMapMgr(); - handler->PSendSysMessage(" %u maps loaded with %u tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount()); + handler->PSendSysMessage(" {} maps loaded with {} tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount()); dtNavMesh const* navmesh = manager->GetNavMesh(handler->GetSession()->GetPlayer()->GetMapId()); if (!navmesh) @@ -248,11 +248,11 @@ class mmaps_commandscript : public CommandScript } handler->PSendSysMessage("Navmesh stats:"); - handler->PSendSysMessage(" %u tiles loaded", tileCount); - handler->PSendSysMessage(" %u BVTree nodes", nodeCount); - handler->PSendSysMessage(" %u polygons (%u vertices)", polyCount, vertCount); - handler->PSendSysMessage(" %u triangles (%u vertices)", triCount, triVertCount); - handler->PSendSysMessage(" %.2f MB of data (not including pointers)", ((float)dataSize / sizeof(unsigned char)) / 1048576); + handler->PSendSysMessage(" {} tiles loaded", tileCount); + handler->PSendSysMessage(" {} BVTree nodes", nodeCount); + handler->PSendSysMessage(" {} polygons ({} vertices)", polyCount, vertCount); + handler->PSendSysMessage(" {} triangles ({} vertices)", triCount, triVertCount); + handler->PSendSysMessage(" {0:.2f} MB of data (not including pointers)", ((float)dataSize / sizeof(unsigned char)) / 1048576); return true; } @@ -270,7 +270,7 @@ class mmaps_commandscript : public CommandScript if (!creatureList.empty()) { - handler->PSendSysMessage(Acore::StringFormatFmt("Found {} Creatures.", creatureList.size()).c_str()); + handler->PSendSysMessage(Acore::StringFormatFmt("Found {} Creatures.", creatureList.size())); uint32 paths = 0; uint32 uStartTime = getMSTime(); @@ -285,10 +285,10 @@ class mmaps_commandscript : public CommandScript } uint32 uPathLoadTime = getMSTimeDiff(uStartTime, getMSTime()); - handler->PSendSysMessage("Generated %i paths in %i ms", paths, uPathLoadTime); + handler->PSendSysMessage("Generated {} paths in {} ms", paths, uPathLoadTime); } else - handler->PSendSysMessage("No creatures in %f yard range.", radius); + handler->PSendSysMessage("No creatures in {} yard range.", radius); return true; } diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index 6d1c08c4022002..ac05607efc09a7 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -95,11 +95,11 @@ class modify_commandscript : public CommandScript { if (Player* player = target->ToPlayer()) { - handler->PSendSysMessage(resourceMessage, std::forward(args)..., handler->GetNameLink(player).c_str()); + handler->PSendSysMessage(resourceMessage, std::forward(args)..., handler->GetNameLink(player)); if (handler->needReportToTarget(player)) { - ChatHandler(player->GetSession()).PSendSysMessage(resourceReportMessage, handler->GetNameLink().c_str(), std::forward(args)...); + ChatHandler(player->GetSession()).PSendSysMessage(resourceReportMessage, handler->GetNameLink(), std::forward(args)...); } } } @@ -138,11 +138,11 @@ class modify_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_YOU_CHANGE_HP, handler->GetNameLink(target).c_str(), healthPoints, healthPoints); + handler->PSendSysMessage(LANG_YOU_CHANGE_HP, handler->GetNameLink(target), healthPoints, healthPoints); if (handler->needReportToTarget(target)) { - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_HP_CHANGED, handler->GetNameLink().c_str(), healthPoints, healthPoints); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_HP_CHANGED, handler->GetNameLink(), healthPoints, healthPoints); } target->SetMaxHealth(healthPoints); @@ -161,11 +161,11 @@ class modify_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_YOU_CHANGE_MANA, handler->GetNameLink(target).c_str(), manaPoints, manaPoints); + handler->PSendSysMessage(LANG_YOU_CHANGE_MANA, handler->GetNameLink(target), manaPoints, manaPoints); if (handler->needReportToTarget(target)) { - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MANA_CHANGED, handler->GetNameLink().c_str(), manaPoints, manaPoints); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MANA_CHANGED, handler->GetNameLink(), manaPoints, manaPoints); } target->SetMaxPower(POWER_MANA, manaPoints); @@ -186,11 +186,11 @@ class modify_commandscript : public CommandScript energyPoints *= 10; - handler->PSendSysMessage(LANG_YOU_CHANGE_ENERGY, handler->GetNameLink(target).c_str(), energyPoints / 10, energyPoints / 10); + handler->PSendSysMessage(LANG_YOU_CHANGE_ENERGY, handler->GetNameLink(target), energyPoints / 10, energyPoints / 10); if (handler->needReportToTarget(target)) { - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, handler->GetNameLink().c_str(), energyPoints / 10, energyPoints / 10); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, handler->GetNameLink(), energyPoints / 10, energyPoints / 10); } target->SetMaxPower(POWER_ENERGY, energyPoints); @@ -213,11 +213,11 @@ class modify_commandscript : public CommandScript ragePoints *= 10; - handler->PSendSysMessage(LANG_YOU_CHANGE_RAGE, handler->GetNameLink(target).c_str(), ragePoints / 10, ragePoints / 10); + handler->PSendSysMessage(LANG_YOU_CHANGE_RAGE, handler->GetNameLink(target), ragePoints / 10, ragePoints / 10); if (handler->needReportToTarget(target)) { - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, handler->GetNameLink().c_str(), ragePoints / 10, ragePoints / 10); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, handler->GetNameLink(), ragePoints / 10, ragePoints / 10); } target->SetMaxPower(POWER_RAGE, ragePoints); @@ -238,11 +238,11 @@ class modify_commandscript : public CommandScript runePoints *= 10; - handler->PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, handler->GetNameLink(target).c_str(), runePoints / 10, runePoints / 10); + handler->PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, handler->GetNameLink(target), runePoints / 10, runePoints / 10); if (handler->needReportToTarget(target)) { - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, handler->GetNameLink().c_str(), runePoints / 10, runePoints / 10); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, handler->GetNameLink(), runePoints / 10, runePoints / 10); } target->SetMaxPower(POWER_RUNIC_POWER, runePoints); @@ -329,10 +329,10 @@ class modify_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellFlatID, val, mark ? *mark : 65535, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellFlatID, val, mark ? *mark : 65535, handler->GetNameLink(target)); if (handler->needReportToTarget(target)) { - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, handler->GetNameLink().c_str(), spellFlatID, val, mark ? *mark : 65535); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, handler->GetNameLink(), spellFlatID, val, mark ? *mark : 65535); } WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1 + 1 + 2 + 2)); @@ -418,7 +418,7 @@ class modify_commandscript : public CommandScript if (player->IsInFlight() && checkInFlight) { - handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT, handler->GetNameLink(player).c_str()); + handler->PSendSysMessage(LANG_CHAR_IN_FLIGHT, handler->GetNameLink(player)); handler->SetSentErrorMessage(true); return false; } @@ -524,9 +524,9 @@ class modify_commandscript : public CommandScript if (handler->HasLowerSecurity(player)) return false; - handler->PSendSysMessage(LANG_YOU_CHANGE_SIZE, scale, handler->GetNameLink(player).c_str()); + handler->PSendSysMessage(LANG_YOU_CHANGE_SIZE, scale, handler->GetNameLink(player)); if (handler->needReportToTarget(player)) - ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, handler->GetNameLink().c_str(), scale); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, handler->GetNameLink(), scale); } target->SetObjectScale(scale); @@ -633,9 +633,9 @@ class modify_commandscript : public CommandScript LOG_DEBUG("chat.system", handler->GetAcoreString(LANG_CURRENT_MONEY), targetMoney, moneyToAdd, newmoney); if (newmoney <= 0) { - handler->PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, handler->GetNameLink(target)); if (handler->needReportToTarget(target)) - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, handler->GetNameLink().c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_ALL_MONEY_GONE, handler->GetNameLink()); target->SetMoney(0); } @@ -644,17 +644,17 @@ class modify_commandscript : public CommandScript if (newmoney > MAX_MONEY_AMOUNT) newmoney = MAX_MONEY_AMOUNT; - handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, std::abs(moneyToAdd), handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, std::abs(moneyToAdd), handler->GetNameLink(target)); if (handler->needReportToTarget(target)) - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), std::abs(moneyToAdd)); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink(), std::abs(moneyToAdd)); target->SetMoney(newmoney); } } else { - handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, moneyToAdd, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, moneyToAdd, handler->GetNameLink(target)); if (handler->needReportToTarget(target)) - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink().c_str(), moneyToAdd); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink(), moneyToAdd); if (moneyToAdd >= MAX_MONEY_AMOUNT) moneyToAdd = MAX_MONEY_AMOUNT; @@ -733,7 +733,7 @@ class modify_commandscript : public CommandScript target->ModifyHonorPoints(amount); - handler->PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, handler->GetNameLink(target).c_str(), target->GetHonorPoints()); + handler->PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, handler->GetNameLink(target), target->GetHonorPoints()); return true; } @@ -820,7 +820,7 @@ class modify_commandscript : public CommandScript if (r >= MAX_REPUTATION_RANK) { - handler->PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, rankStr.c_str()); + handler->PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, rankStr); handler->SetSentErrorMessage(true); return false; } @@ -855,7 +855,7 @@ class modify_commandscript : public CommandScript target->GetReputationMgr().SendState(target->GetReputationMgr().GetState(factionEntry)); handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[handler->GetSessionDbcLocale()], factionId, - handler->GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry)); + handler->GetNameLink(target), target->GetReputationMgr().GetReputation(factionEntry)); return true; } @@ -929,7 +929,7 @@ class modify_commandscript : public CommandScript target->ModifyArenaPoints(amount); - handler->PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, handler->GetNameLink(target).c_str(), target->GetArenaPoints()); + handler->PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, handler->GetNameLink(target), target->GetArenaPoints()); return true; } @@ -987,11 +987,11 @@ class modify_commandscript : public CommandScript char const* gender_full = gender ? "female" : "male"; - handler->PSendSysMessage(LANG_YOU_CHANGE_GENDER, handler->GetNameLink(target).c_str(), gender_full); + handler->PSendSysMessage(LANG_YOU_CHANGE_GENDER, handler->GetNameLink(target), gender_full); if (handler->needReportToTarget(target)) { - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, handler->GetNameLink().c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOUR_GENDER_CHANGED, gender_full, handler->GetNameLink()); } return true; diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index b0aa93d69286ee..225429ad6ea966 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -297,7 +297,7 @@ class npc_commandscript : public CommandScript sObjectMgr->AddVendorItem(vendor_entry, itemId, maxcount, incrtime, extendedcost); - handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, item->Name1.c_str(), maxcount, incrtime, extendedcost); + handler->PSendSysMessage(LANG_ITEM_ADDED_TO_LIST, itemId, item->Name1, maxcount, incrtime, extendedcost); return true; } @@ -432,7 +432,7 @@ class npc_commandscript : public CommandScript return false; } - handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, item->Name1.c_str()); + handler->PSendSysMessage(LANG_ITEM_DELETED_FROM_LIST, itemId, item->Name1); return true; } @@ -551,7 +551,7 @@ class npc_commandscript : public CommandScript creature->AI()->SetData(data_1, data_2); std::string AIorScript = !creature->GetAIName().empty() ? "AI type: " + creature->GetAIName() : (!creature->GetScriptName().empty() ? "Script Name: " + creature->GetScriptName() : "No AI or Script Name Set"); - handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID().GetCounter(), creature->GetEntry(), creature->GetName().c_str(), data_1, data_2, AIorScript.c_str()); + handler->PSendSysMessage(LANG_NPC_SETDATA, creature->GetGUID().GetCounter(), creature->GetEntry(), creature->GetName(), data_1, data_2, AIorScript); return true; } @@ -571,7 +571,7 @@ class npc_commandscript : public CommandScript // Follow player - Using pet's default dist and angle creature->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, creature->GetFollowAngle()); - handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName().c_str()); + handler->PSendSysMessage(LANG_CREATURE_FOLLOW_YOU_NOW, creature->GetName()); return true; } @@ -615,13 +615,13 @@ class npc_commandscript : public CommandScript handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, target->GetCurrentEquipmentId(), target->GetOriginalEquipmentId()); handler->PSendSysMessage(LANG_NPCINFO_HEALTH, target->GetCreateHealth(), target->GetMaxHealth(), target->GetHealth()); handler->PSendSysMessage(LANG_NPCINFO_FLAGS, target->GetUInt32Value(UNIT_FIELD_FLAGS), target->GetUInt32Value(UNIT_FIELD_FLAGS_2), target->GetUInt32Value(UNIT_DYNAMIC_FLAGS), target->GetFaction()); - handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr.c_str(), curRespawnDelayStr.c_str()); + handler->PSendSysMessage(LANG_COMMAND_RAWPAWNTIMES, defRespawnDelayStr, curRespawnDelayStr); handler->PSendSysMessage(LANG_NPCINFO_LOOT, cInfo->lootid, cInfo->pickpocketLootId, cInfo->SkinLootId); handler->PSendSysMessage(LANG_NPCINFO_DUNGEON_ID, target->GetInstanceId()); handler->PSendSysMessage(LANG_NPCINFO_PHASEMASK, target->GetPhaseMask()); handler->PSendSysMessage(LANG_NPCINFO_ARMOR, target->GetArmor()); handler->PSendSysMessage(LANG_NPCINFO_POSITION, float(target->GetPositionX()), float(target->GetPositionY()), float(target->GetPositionZ())); - handler->PSendSysMessage(LANG_NPCINFO_AIINFO, target->GetAIName().c_str(), target->GetScriptName().c_str()); + handler->PSendSysMessage(LANG_NPCINFO_AIINFO, target->GetAIName(), target->GetScriptName()); for (uint8 i = 0; i < NPCFLAG_COUNT; i++) { @@ -688,7 +688,7 @@ class npc_commandscript : public CommandScript if (!creatureTemplate) continue; - handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, creatureTemplate->Name.c_str(), x, y, z, mapId, "", ""); + handler->PSendSysMessage(LANG_CREATURE_LIST_CHAT, guid, guid, creatureTemplate->Name, x, y, z, mapId, "", ""); ++count; } while (result->NextRow()); @@ -791,7 +791,7 @@ class npc_commandscript : public CommandScript if (!sCreatureDisplayInfoStore.LookupEntry(displayId)) { - handler->PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, Acore::ToString(displayId).c_str()); + handler->PSendSysMessage(LANG_COMMAND_FACTION_INVPARAM, Acore::ToString(displayId)); handler->SetSentErrorMessage(true); return false; } @@ -1065,7 +1065,7 @@ class npc_commandscript : public CommandScript if (/*creature->GetMotionMaster()->empty() ||*/ creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE) { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); handler->SetSentErrorMessage(true); return false; } @@ -1074,7 +1074,7 @@ class npc_commandscript : public CommandScript if (mgen->GetTarget() != player) { - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName()); handler->SetSentErrorMessage(true); return false; } @@ -1082,7 +1082,7 @@ class npc_commandscript : public CommandScript // reset movement creature->GetMotionMaster()->MovementExpired(true); - handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str()); + handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName()); return true; } @@ -1196,7 +1196,7 @@ class npc_commandscript : public CommandScript ObjectGuid::LowType lowguid = creature->GetSpawnId(); if (creature->GetFormation()) { - handler->PSendSysMessage("Selected creature is already member of group %u", creature->GetFormation()->GetId()); + handler->PSendSysMessage("Selected creature is already member of group {}", creature->GetFormation()->GetId()); return false; } @@ -1222,7 +1222,7 @@ class npc_commandscript : public CommandScript WorldDatabase.Execute(stmt); - handler->PSendSysMessage("Creature %u added to formation with leader %u", lowguid, leaderGUID); + handler->PSendSysMessage("Creature {} added to formation with leader {}", lowguid, leaderGUID); return true; } @@ -1240,19 +1240,19 @@ class npc_commandscript : public CommandScript if (!creature->GetSpawnId()) { - handler->PSendSysMessage("Selected creature %u isn't in creature table", creature->GetGUID().GetCounter()); + handler->PSendSysMessage("Selected creature {} isn't in creature table", creature->GetGUID().GetCounter()); handler->SetSentErrorMessage(true); return false; } if (!sObjectMgr->SetCreatureLinkedRespawn(creature->GetSpawnId(), linkguid)) { - handler->PSendSysMessage("Selected creature can't link with guid '%u'", linkguid); + handler->PSendSysMessage("Selected creature can't link with guid '{}'", linkguid); handler->SetSentErrorMessage(true); return false; } - handler->PSendSysMessage("LinkGUID '%u' added to creature with DBTableGUID: '%u'", linkguid, creature->GetSpawnId()); + handler->PSendSysMessage("LinkGUID '{}' added to creature with DBTableGUID: '{}'", linkguid, creature->GetSpawnId()); return true; } }; diff --git a/src/server/scripts/Commands/cs_pet.cpp b/src/server/scripts/Commands/cs_pet.cpp index 45e922b671d961..389477f5512efd 100644 --- a/src/server/scripts/Commands/cs_pet.cpp +++ b/src/server/scripts/Commands/cs_pet.cpp @@ -116,7 +116,7 @@ class pet_commandscript : public CommandScript uint32 spellDifficultyId = sSpellMgr->GetSpellDifficultyId(spell->Id); if (bounds.first != bounds.second || spellDifficultyId) { - handler->PSendSysMessage("Spell %u cannot be learnt using a command!", spell->Id); + handler->PSendSysMessage("Spell {} cannot be learnt using a command!", spell->Id); handler->SetSentErrorMessage(true); return false; } @@ -124,13 +124,13 @@ class pet_commandscript : public CommandScript // Check if pet already has it if (pet->HasSpell(spell->Id)) { - handler->PSendSysMessage("Pet already has spell: %u", spell->Id); + handler->PSendSysMessage("Pet already has spell: {}", spell->Id); handler->SetSentErrorMessage(true); return false; } pet->learnSpell(spell->Id); - handler->PSendSysMessage("Pet has learned spell %u", spell->Id); + handler->PSendSysMessage("Pet has learned spell {}", spell->Id); return true; } diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 5f0d8d9116a4cb..c465a1500fb6d8 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -83,7 +83,7 @@ class quest_commandscript : public CommandScript { if (player->IsActiveQuest(entry)) { - handler->PSendSysMessage(LANG_COMMAND_QUEST_ACTIVE, quest->GetTitle().c_str(), entry); + handler->PSendSysMessage(LANG_COMMAND_QUEST_ACTIVE, quest->GetTitle(), entry); handler->SetSentErrorMessage(true); return false; } @@ -101,7 +101,7 @@ class quest_commandscript : public CommandScript if (result) { - handler->PSendSysMessage(LANG_COMMAND_QUEST_ACTIVE, quest->GetTitle().c_str(), entry); + handler->PSendSysMessage(LANG_COMMAND_QUEST_ACTIVE, quest->GetTitle(), entry); handler->SetSentErrorMessage(true); return false; } @@ -130,7 +130,7 @@ class quest_commandscript : public CommandScript CharacterDatabase.Execute(stmt); } - handler->PSendSysMessage(LANG_COMMAND_QUEST_ADD, quest->GetTitle().c_str(), entry); + handler->PSendSysMessage(LANG_COMMAND_QUEST_ADD, quest->GetTitle(), entry); handler->SetSentErrorMessage(false); return true; } @@ -222,7 +222,7 @@ class quest_commandscript : public CommandScript CharacterDatabase.CommitTransaction(trans); } - handler->PSendSysMessage(LANG_COMMAND_QUEST_REMOVED, quest->GetTitle().c_str(), entry); + handler->PSendSysMessage(LANG_COMMAND_QUEST_REMOVED, quest->GetTitle(), entry); handler->SetSentErrorMessage(false); return true; } @@ -491,7 +491,7 @@ class quest_commandscript : public CommandScript CharacterDatabase.Execute(stmt); } - handler->PSendSysMessage(LANG_COMMAND_QUEST_COMPLETE, quest->GetTitle().c_str(), entry); + handler->PSendSysMessage(LANG_COMMAND_QUEST_COMPLETE, quest->GetTitle(), entry); handler->SetSentErrorMessage(false); return true; } @@ -739,7 +739,7 @@ class quest_commandscript : public CommandScript CharacterDatabase.CommitTransaction(trans); } - handler->PSendSysMessage(LANG_COMMAND_QUEST_REWARDED, quest->GetTitle().c_str(), entry); + handler->PSendSysMessage(LANG_COMMAND_QUEST_REWARDED, quest->GetTitle(), entry); handler->SetSentErrorMessage(false); return true; } diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index 7f5ab230cd3dc2..ac45813154d7f3 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -24,11 +24,13 @@ EndScriptData */ #include "AchievementMgr.h" #include "AuctionHouseMgr.h" +#include "Autobroadcast.h" #include "BattlegroundMgr.h" #include "Chat.h" #include "CreatureTextMgr.h" #include "DisableMgr.h" #include "GameGraveyard.h" +#include "GameLocale.h" #include "LFGMgr.h" #include "Language.h" #include "MapMgr.h" @@ -80,9 +82,11 @@ class reload_commandscript : public CommandScript { "areatrigger_tavern", HandleReloadAreaTriggerTavernCommand, SEC_ADMINISTRATOR, Console::Yes }, { "areatrigger_teleport", HandleReloadAreaTriggerTeleportCommand, SEC_ADMINISTRATOR, Console::Yes }, { "autobroadcast", HandleReloadAutobroadcastCommand, SEC_ADMINISTRATOR, Console::Yes }, + { "autobroadcast_locale", HandleReloadLocalesAutobroadcastCommand, SEC_ADMINISTRATOR, Console::Yes }, { "broadcast_text", HandleReloadBroadcastTextCommand, SEC_ADMINISTRATOR, Console::Yes }, { "battleground_template", HandleReloadBattlegroundTemplate, SEC_ADMINISTRATOR, Console::Yes }, { "command", HandleReloadCommandCommand, SEC_ADMINISTRATOR, Console::Yes }, + { "commands_help_locale", HandleReloadLocalesChatCommandsHelpCommand, SEC_ADMINISTRATOR, Console::Yes }, { "conditions", HandleReloadConditions, SEC_ADMINISTRATOR, Console::Yes }, { "config", HandleReloadConfigCommand, SEC_ADMINISTRATOR, Console::Yes }, { "creature_text", HandleReloadCreatureText, SEC_ADMINISTRATOR, Console::Yes }, @@ -329,6 +333,8 @@ class reload_commandscript : public CommandScript HandleReloadLocalesQuestCommand(handler); HandleReloadLocalesQuestOfferRewardCommand(handler); HandleReloadLocalesQuestRequestItemsCommand(handler); + HandleReloadLocalesAutobroadcastCommand(handler); + HandleReloadLocalesChatCommandsHelpCommand(handler); return true; } @@ -392,16 +398,32 @@ class reload_commandscript : public CommandScript static bool HandleReloadAutobroadcastCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Autobroadcasts..."); - sWorld->LoadAutobroadcasts(); + sAutobroadcastMgr->Load(); handler->SendGlobalGMSysMessage("DB table `autobroadcast` reloaded."); return true; } + static bool HandleReloadLocalesAutobroadcastCommand(ChatHandler* handler) + { + LOG_INFO("server.loading", "Re-Loading Autobroadcasts locales..."); + sGameLocale->LoadAutoBroadCastLocales(); + handler->SendGlobalGMSysMessage("DB table `autobroadcast_locale` reloaded."); + return true; + } + + static bool HandleReloadLocalesChatCommandsHelpCommand(ChatHandler* handler) + { + LOG_INFO("server.loading", "Re-Loading ChatCommands help locales..."); + sGameLocale->LoadChatCommandsLocales(); + handler->SendGlobalGMSysMessage("DB table `commands_help_locale` reloaded."); + return true; + } + static bool HandleReloadBroadcastTextCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Broadcast texts..."); - sObjectMgr->LoadBroadcastTexts(); - sObjectMgr->LoadBroadcastTextLocales(); + sGameLocale->LoadBroadcastTexts(); + sGameLocale->LoadBroadcastTextLocales(); handler->SendGlobalGMSysMessage("DB table `broadcast_text` reloaded."); return true; } @@ -682,7 +704,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadAcoreStringCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading acore_string Table!"); - sObjectMgr->LoadAcoreStrings(); + sGameLocale->LoadAcoreStrings(); handler->SendGlobalGMSysMessage("DB table `acore_string` reloaded."); return true; } @@ -1010,7 +1032,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesAchievementRewardCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Achievement Reward Data Locale..."); - sAchievementMgr->LoadRewardLocales(); + sGameLocale->LoadAchievementRewardLocales(); handler->SendGlobalGMSysMessage("DB table `achievement_reward_locale` reloaded."); return true; } @@ -1026,7 +1048,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesCreatureCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Creature Template Locale..."); - sObjectMgr->LoadCreatureLocales(); + sGameLocale->LoadCreatureLocales(); handler->SendGlobalGMSysMessage("DB table `creature_template_locale` reloaded."); return true; } @@ -1042,7 +1064,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesGameobjectCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Gameobject Template Locale ... "); - sObjectMgr->LoadGameObjectLocales(); + sGameLocale->LoadGameObjectLocales(); handler->SendGlobalGMSysMessage("DB table `gameobject_template_locale` reloaded."); return true; } @@ -1050,7 +1072,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesGossipMenuOptionCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Gossip Menu Option Locale ... "); - sObjectMgr->LoadGossipMenuItemsLocales(); + sGameLocale->LoadGossipMenuItemsLocales(); handler->SendGlobalGMSysMessage("DB table `gossip_menu_option_locale` reloaded."); return true; } @@ -1058,7 +1080,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesItemCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Item Template Locale ... "); - sObjectMgr->LoadItemLocales(); + sGameLocale->LoadItemLocales(); handler->SendGlobalGMSysMessage("DB table `item_template_locale` reloaded."); return true; } @@ -1066,7 +1088,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesItemSetNameCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Item set name Locale... "); - sObjectMgr->LoadItemSetNameLocales(); + sGameLocale->LoadItemSetNameLocales(); handler->SendGlobalGMSysMessage("DB table `item_set_name_locale` reloaded."); return true; } @@ -1074,7 +1096,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesNpcTextCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading NPC Text Locale ... "); - sObjectMgr->LoadNpcTextLocales(); + sGameLocale->LoadNpcTextLocales(); handler->SendGlobalGMSysMessage("DB table `npc_text_locale` reloaded."); return true; } @@ -1082,7 +1104,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesPageTextCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Page Text Locale ... "); - sObjectMgr->LoadPageTextLocales(); + sGameLocale->LoadPageTextLocales(); handler->SendGlobalGMSysMessage("DB table `page_text_locale` reloaded."); handler->SendGlobalGMSysMessage("You need to delete your client cache or change the cache number in config in order for your players see the changes."); return true; @@ -1091,7 +1113,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesPointsOfInterestCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Points Of Interest Locale ... "); - sObjectMgr->LoadPointOfInterestLocales(); + sGameLocale->LoadPointOfInterestLocales(); handler->SendGlobalGMSysMessage("DB table `points_of_interest_locale` reloaded."); return true; } @@ -1099,7 +1121,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesQuestCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Locales Quest ... "); - sObjectMgr->LoadQuestLocales(); + sGameLocale->LoadQuestLocales(); handler->SendGlobalGMSysMessage("DB table `quest_template_locale` reloaded."); return true; } @@ -1107,7 +1129,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesQuestOfferRewardCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Quest Offer Reward Locale... "); - sObjectMgr->LoadQuestOfferRewardLocale(); + sGameLocale->LoadQuestOfferRewardLocale(); handler->SendGlobalGMSysMessage("DB table `quest_offer_reward_locale` reloaded."); return true; } @@ -1115,7 +1137,7 @@ class reload_commandscript : public CommandScript static bool HandleReloadLocalesQuestRequestItemsCommand(ChatHandler* handler) { LOG_INFO("server.loading", "Re-Loading Quest Request Item Locale... "); - sObjectMgr->LoadQuestRequestItemsLocale(); + sGameLocale->LoadQuestRequestItemsLocale(); handler->SendGlobalGMSysMessage("DB table `quest_request_item_locale` reloaded."); return true; } diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index e38a1f10ce47b7..4c195764168c78 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -24,6 +24,7 @@ EndScriptData */ #include "AchievementMgr.h" #include "Chat.h" +#include "ChatTextBuilder.h" #include "Language.h" #include "ObjectAccessor.h" #include "Pet.h" @@ -173,7 +174,7 @@ class reset_commandscript : public CommandScript ChatHandler(target->GetSession()).SendSysMessage(LANG_RESET_SPELLS); if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) - handler->PSendSysMessage(LANG_RESET_SPELLS_ONLINE, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_RESET_SPELLS_ONLINE, handler->GetNameLink(target)); } else { @@ -182,7 +183,7 @@ class reset_commandscript : public CommandScript stmt->SetData(1, targetGuid.GetCounter()); CharacterDatabase.Execute(stmt); - handler->PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName.c_str()); + handler->PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName); } return true; @@ -225,7 +226,7 @@ class reset_commandscript : public CommandScript ChatHandler(owner->ToPlayer()->GetSession()).SendSysMessage(LANG_RESET_PET_TALENTS); if (!handler->GetSession() || handler->GetSession()->GetPlayer() != owner->ToPlayer()) - handler->PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE, handler->GetNameLink(owner->ToPlayer()).c_str()); + handler->PSendSysMessage(LANG_RESET_PET_TALENTS_ONLINE, handler->GetNameLink(owner->ToPlayer())); } return true; } @@ -241,7 +242,7 @@ class reset_commandscript : public CommandScript target->SendTalentsInfoData(false); ChatHandler(target->GetSession()).SendSysMessage(LANG_RESET_TALENTS); if (!handler->GetSession() || handler->GetSession()->GetPlayer() != target) - handler->PSendSysMessage(LANG_RESET_TALENTS_ONLINE, handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_RESET_TALENTS_ONLINE, handler->GetNameLink(target)); Pet* pet = target->GetPet(); Pet::resetTalentsForAllPetsOf(target, pet); @@ -257,7 +258,7 @@ class reset_commandscript : public CommandScript CharacterDatabase.Execute(stmt); std::string nameLink = handler->playerLink(targetName); - handler->PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink.c_str()); + handler->PSendSysMessage(LANG_RESET_TALENTS_OFFLINE, nameLink); return true; } @@ -279,14 +280,14 @@ class reset_commandscript : public CommandScript if (caseName == "spells") { atLogin = AT_LOGIN_RESET_SPELLS; - sWorld->SendWorldText(LANG_RESETALL_SPELLS); + Acore::Text::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); + Acore::Text::SendWorldText(LANG_RESETALL_TALENTS); if (!handler->GetSession()) handler->SendSysMessage(LANG_RESETALL_TALENTS); } diff --git a/src/server/scripts/Commands/cs_send.cpp b/src/server/scripts/Commands/cs_send.cpp index 65133672b5930c..3efd9ccb51465c 100644 --- a/src/server/scripts/Commands/cs_send.cpp +++ b/src/server/scripts/Commands/cs_send.cpp @@ -16,6 +16,7 @@ */ #include "Chat.h" +#include "ChatTextBuilder.h" #include "DatabaseEnv.h" #include "Item.h" #include "Language.h" @@ -130,7 +131,7 @@ class send_commandscript : public CommandScript draft.SendMailTo(trans, MailReceiver(target->GetConnectedPlayer(), target->GetGUID().GetCounter()), sender); CharacterDatabase.CommitTransaction(trans); - handler->PSendSysMessage(LANG_MAIL_SENT, handler->playerLink(target->GetName()).c_str()); + handler->PSendSysMessage(LANG_MAIL_SENT, handler->playerLink(target->GetName())); return true; } @@ -155,7 +156,7 @@ class send_commandscript : public CommandScript draft.SendMailTo(trans, MailReceiver(target->GetConnectedPlayer(), target->GetGUID().GetCounter()), sender); CharacterDatabase.CommitTransaction(trans); - handler->PSendSysMessage(LANG_MAIL_SENT, handler->playerLink(target->GetName()).c_str()); + handler->PSendSysMessage(LANG_MAIL_SENT, handler->playerLink(target->GetName())); return true; } @@ -172,15 +173,14 @@ class send_commandscript : public CommandScript } Player* player = target->GetConnectedPlayer(); - std::string msg = std::string{ message }; /// - Send the message // Use SendAreaTriggerMessage for fastest delivery. - player->GetSession()->SendAreaTriggerMessage("%s", msg.c_str()); - player->GetSession()->SendAreaTriggerMessage("|cffff0000[Message from administrator]:|r"); + Acore::Text::SendAreaTriggerMessage(player->GetSession(), message); + Acore::Text::SendAreaTriggerMessage(player->GetSession(), "|cffff0000[Message from administrator]:|r"); // Confirmation message - handler->PSendSysMessage(LANG_SENDMESSAGE, handler->playerLink(target->GetName()).c_str(), msg.c_str()); + handler->PSendSysMessage(LANG_SENDMESSAGE, handler->playerLink(target->GetName()), message); return true; } @@ -208,7 +208,7 @@ class send_commandscript : public CommandScript CharacterDatabase.CommitTransaction(trans); - handler->PSendSysMessage(LANG_MAIL_SENT, handler->playerLink(target->GetName()).c_str()); + handler->PSendSysMessage(LANG_MAIL_SENT, handler->playerLink(target->GetName())); return true; } }; diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 5b93fa5184fdc7..f149da98c4f26f 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -125,19 +125,19 @@ class server_commandscript : public CommandScript if (dbPort) dbPortOutput = Acore::StringFormatFmt("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort); else - dbPortOutput = Acore::StringFormat("Realm Id: %u not found in `realmlist` table. Please check your setup", realm.Id.Realm); + dbPortOutput = Acore::StringFormatFmt("Realm Id: {} not found in `realmlist` table. Please check your setup", realm.Id.Realm); } - handler->PSendSysMessage("%s", GitRevision::GetFullVersion()); - handler->PSendSysMessage("Using SSL version: %s (library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); - handler->PSendSysMessage("Using Boost version: %i.%i.%i", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100); - handler->PSendSysMessage("Using MySQL version: %u", MySQL::GetLibraryVersion()); - handler->PSendSysMessage("Using CMake version: %s", GitRevision::GetCMakeVersion()); + handler->SendSysMessage(GitRevision::GetFullVersion()); + handler->PSendSysMessage("Using SSL version: {} (library: {})", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); + handler->PSendSysMessage("Using Boost version: {}.{}.{}", BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100); + handler->PSendSysMessage("Using MySQL version: {}", MySQL::GetLibraryVersion()); + handler->PSendSysMessage("Using CMake version: {}", GitRevision::GetCMakeVersion()); - handler->PSendSysMessage("Compiled on: %s", GitRevision::GetHostOSVersion()); + handler->PSendSysMessage("Compiled on: {}", GitRevision::GetHostOSVersion()); handler->PSendSysMessage("Worldserver listening connections on port %" PRIu16, worldPort); - handler->PSendSysMessage("%s", dbPortOutput.c_str()); + handler->PSendSysMessage("{}", dbPortOutput); bool vmapIndoorCheck = sWorld->getBoolConfig(CONFIG_VMAP_INDOOR_CHECK); bool vmapLOSCheck = VMAP::VMapFactory::createOrGetVMapMgr()->isLineOfSightCalcEnabled(); @@ -150,7 +150,7 @@ class server_commandscript : public CommandScript subDirs.emplace_back("maps"); if (vmapIndoorCheck || vmapLOSCheck || vmapHeightCheck) { - handler->PSendSysMessage("VMAPs status: Enabled. LineOfSight: %i, getHeight: %i, indoorCheck: %i", vmapLOSCheck, vmapHeightCheck, vmapIndoorCheck); + handler->PSendSysMessage("VMAPs status: Enabled. LineOfSight: {}, getHeight: {}, indoorCheck: {}", vmapLOSCheck, vmapHeightCheck, vmapIndoorCheck); subDirs.emplace_back("vmaps"); } else @@ -171,7 +171,7 @@ class server_commandscript : public CommandScript if (!std::filesystem::exists(mapPath)) { - handler->PSendSysMessage("%s directory doesn't exist!. Using path: %s", subDir.c_str(), mapPath.generic_string().c_str()); + handler->PSendSysMessage("{} directory doesn't exist!. Using path: {}", subDir, mapPath.generic_string()); continue; } @@ -183,7 +183,7 @@ class server_commandscript : public CommandScript return val; }); - handler->PSendSysMessage(Acore::StringFormatFmt("{} directory located in {}. Total size: {} bytes", subDir.c_str(), mapPath.generic_string().c_str(), folderSize).c_str()); + handler->PSendSysMessage(Acore::StringFormatFmt("{} directory located in {}. Total size: {} bytes", subDir, mapPath.generic_string(), folderSize)); } LocaleConstant defaultLocale = sWorld->GetDefaultDbcLocale(); @@ -210,16 +210,16 @@ class server_commandscript : public CommandScript availableLocales += " "; } - handler->PSendSysMessage("Using %s DBC Locale as default. All available DBC locales: %s", localeNames[defaultLocale], availableLocales.c_str()); + handler->PSendSysMessage("Using {} DBC Locale as default. All available DBC locales: {}", localeNames[defaultLocale], availableLocales); - handler->PSendSysMessage("Using World DB: %s", sWorld->GetDBVersion()); - handler->PSendSysMessage("Using World DB Revision: %s", sWorld->GetWorldDBRevision()); - handler->PSendSysMessage("Using Character DB Revision: %s", sWorld->GetCharacterDBRevision()); - handler->PSendSysMessage("Using Auth DB Revision: %s", sWorld->GetAuthDBRevision()); + handler->PSendSysMessage("Using World DB: {}", sWorld->GetDBVersion()); + handler->PSendSysMessage("Using World DB Revision: {}", sWorld->GetWorldDBRevision()); + handler->PSendSysMessage("Using Character DB Revision: {}", sWorld->GetCharacterDBRevision()); + handler->PSendSysMessage("Using Auth DB Revision: {}", sWorld->GetAuthDBRevision()); - handler->PSendSysMessage("LoginDatabase queue size: %zu", LoginDatabase.QueueSize()); - handler->PSendSysMessage("CharacterDatabase queue size: %zu", CharacterDatabase.QueueSize()); - handler->PSendSysMessage("WorldDatabase queue size: %zu", WorldDatabase.QueueSize()); + handler->PSendSysMessage("LoginDatabase queue size: {}", LoginDatabase.QueueSize()); + handler->PSendSysMessage("CharacterDatabase queue size: {}", CharacterDatabase.QueueSize()); + handler->PSendSysMessage("WorldDatabase queue size: {}", WorldDatabase.QueueSize()); if (Acore::Module::GetEnableModulesList().empty()) handler->SendSysMessage("No modules enabled"); @@ -242,19 +242,19 @@ class server_commandscript : public CommandScript uint32 queuedSessionCount = sWorld->GetQueuedSessionCount(); uint32 connPeak = sWorld->GetMaxActiveSessionCount(); - handler->PSendSysMessage("%s", GitRevision::GetFullVersion()); + handler->PSendSysMessage("{}", GitRevision::GetFullVersion()); if (!queuedSessionCount) - handler->PSendSysMessage("Connected players: %u. Characters in world: %u.", activeSessionCount, playerCount); + handler->PSendSysMessage("Connected players: {}. Characters in world: {}.", activeSessionCount, playerCount); else - handler->PSendSysMessage("Connected players: %u. Characters in world: %u. Queue: %u.", activeSessionCount, playerCount, queuedSessionCount); + handler->PSendSysMessage("Connected players: {}. Characters in world: {}. Queue: {}.", activeSessionCount, playerCount, queuedSessionCount); - handler->PSendSysMessage("Connection peak: %u.", connPeak); - handler->PSendSysMessage(LANG_UPTIME, secsToTimeString(GameTime::GetUptime().count()).c_str()); - handler->PSendSysMessage("Update time diff: %ums, average: %ums.", sWorldUpdateTime.GetLastUpdateTime(), sWorldUpdateTime.GetAverageUpdateTime()); + handler->PSendSysMessage("Connection peak: {}.", connPeak); + handler->PSendSysMessage(LANG_UPTIME, secsToTimeString(GameTime::GetUptime().count())); + handler->PSendSysMessage("Update time diff: {}ms, average: {}ms.", sWorldUpdateTime.GetLastUpdateTime(), sWorldUpdateTime.GetAverageUpdateTime()); //! Can't use sWorld->ShutdownMsg here in case of console command if (sWorld->IsShuttingDown()) - handler->PSendSysMessage(LANG_SHUTDOWN_TIMELEFT, secsToTimeString(sWorld->GetShutDownTimeLeft()).append(".").c_str()); + handler->PSendSysMessage(LANG_SHUTDOWN_TIMELEFT, secsToTimeString(sWorld->GetShutDownTimeLeft()).append(".")); return true; } diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index fb29793eb9591a..2c0ddecb3e596e 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -135,14 +135,14 @@ class tele_commandscript : public CommandScript if (target->IsBeingTeleported()) { - handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink.c_str()); + handler->PSendSysMessage(LANG_IS_TELEPORTED, chrNameLink); handler->SetSentErrorMessage(true); return false; } - handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink.c_str(), "", locationName.c_str()); + handler->PSendSysMessage(LANG_TELEPORTING_TO, chrNameLink, "", locationName); if (handler->needReportToTarget(target)) - ChatHandler(target->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink().c_str()); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, handler->GetNameLink()); // stop flight if need if (target->IsInFlight()) @@ -163,7 +163,7 @@ class tele_commandscript : public CommandScript std::string nameLink = handler->playerLink(player.GetName()); - handler->PSendSysMessage(LANG_TELEPORTING_TO, nameLink.c_str(), handler->GetAcoreString(LANG_OFFLINE), locationName.c_str()); + handler->PSendSysMessage(LANG_TELEPORTING_TO, nameLink, handler->GetAcoreString(LANG_OFFLINE), locationName); Player::SavePositionInDB({ mapId, pos }, sMapMgr->GetZoneId(PHASEMASK_NORMAL, { mapId, pos }), player.GetGUID(), nullptr); } @@ -242,7 +242,7 @@ class tele_commandscript : public CommandScript Group* grp = target->GetGroup(); if (!grp) { - handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink.c_str()); + handler->PSendSysMessage(LANG_NOT_IN_GROUP, nameLink); handler->SetSentErrorMessage(true); return false; } @@ -262,13 +262,13 @@ class tele_commandscript : public CommandScript if (player->IsBeingTeleported()) { - handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink.c_str()); + handler->PSendSysMessage(LANG_IS_TELEPORTED, plNameLink); continue; } - handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink.c_str(), "", tele->name.c_str()); + handler->PSendSysMessage(LANG_TELEPORTING_TO, plNameLink, "", tele->name); if (handler->needReportToTarget(player)) - ChatHandler(player->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink.c_str()); + ChatHandler(player->GetSession()).PSendSysMessage(LANG_TELEPORTED_TO_BY, nameLink); // stop flight if need if (target->IsInFlight()) diff --git a/src/server/scripts/Commands/cs_ticket.cpp b/src/server/scripts/Commands/cs_ticket.cpp index 39b7c3780e933c..a7893090658acf 100644 --- a/src/server/scripts/Commands/cs_ticket.cpp +++ b/src/server/scripts/Commands/cs_ticket.cpp @@ -123,7 +123,7 @@ class ticket_commandscript : public CommandScript Player* player = handler->GetSession() ? handler->GetSession()->GetPlayer() : nullptr; if (player && ticket->IsAssignedNotTo(player->GetGUID())) { - handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId(), target.c_str()); + handler->PSendSysMessage(LANG_COMMAND_TICKETALREADYASSIGNED, ticket->GetId(), target); return true; } @@ -442,7 +442,7 @@ class ticket_commandscript : public CommandScript ticket->SetViewed(); ticket->SaveToDB(trans); - handler->SendSysMessage(ticket->FormatMessageString(*handler, true).c_str()); + handler->SendSysMessage(ticket->FormatMessageString(*handler, true)); return true; } @@ -485,7 +485,7 @@ class ticket_commandscript : public CommandScript ticket->SetViewed(); ticket->SaveToDB(trans); - handler->SendSysMessage(ticket->FormatMessageString(*handler, true).c_str()); + handler->SendSysMessage(ticket->FormatMessageString(*handler, true)); return true; } diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 222065741152c8..de9c1908df7059 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -103,7 +103,7 @@ class wp_commandscript : public CommandScript uint32 maxpathid = result->Fetch()->Get(); pathid = maxpathid + 1; - handler->PSendSysMessage("%s%s|r", "|cff00ff00", "New path started."); + handler->PSendSysMessage("{}{}|r", "|cff00ff00", "New path started."); } } else @@ -114,7 +114,7 @@ class wp_commandscript : public CommandScript if (!pathid) { - handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Current creature haven't loaded path."); + handler->PSendSysMessage("{}{}|r", "|cffff33ff", "Current creature haven't loaded path."); return true; } @@ -138,7 +138,7 @@ class wp_commandscript : public CommandScript WorldDatabase.Execute(stmt); - handler->PSendSysMessage("%s%s%u%s%u%s|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point + 1, "|r|cff00ff00 created. "); + handler->PSendSysMessage("{}{}{}{}{}{}|r", "|cff00ff00", "PathID: |r|cff00ffff", pathid, "|r|cff00ff00: Waypoint |r|cff00ffff", point + 1, "|r|cff00ff00 created. "); return true; } // HandleWpAddCommand @@ -170,7 +170,7 @@ class wp_commandscript : public CommandScript if (target->GetEntry() == 1) { - handler->PSendSysMessage("%s%s|r", "|cffff33ff", "You want to load path to a waypoint? Aren't you?"); + handler->PSendSysMessage("{}{}|r", "|cffff33ff", "You want to load path to a waypoint? Aren't you?"); handler->SetSentErrorMessage(true); return false; } @@ -179,7 +179,7 @@ class wp_commandscript : public CommandScript if (!pathid) { - handler->PSendSysMessage("%s%s|r", "|cffff33ff", "No valid path number provided."); + handler->PSendSysMessage("{}{}|r", "|cffff33ff", "No valid path number provided."); return true; } @@ -233,7 +233,7 @@ class wp_commandscript : public CommandScript if (!id) return false; - handler->PSendSysMessage("%s%s|r|cff00ffff%u|r", "|cff00ff00", "Loading Path: ", id); + handler->PSendSysMessage("{}{}|r|cff00ffff{}|r", "|cff00ff00", "Loading Path: ", id); sWaypointMgr->ReloadPath(id); return true; } @@ -244,7 +244,7 @@ class wp_commandscript : public CommandScript if (!target) { - handler->PSendSysMessage("%s%s|r", "|cff33ffff", "You must select target."); + handler->PSendSysMessage("{}{}|r", "|cff33ffff", "You must select target."); return true; } @@ -274,7 +274,7 @@ class wp_commandscript : public CommandScript target->Say("Path unloaded.", LANG_UNIVERSAL); return true; } - handler->PSendSysMessage("%s%s|r", "|cffff33ff", "Target have no loaded path."); + handler->PSendSysMessage("{}{}|r", "|cffff33ff", "Target have no loaded path."); } return true; } @@ -313,10 +313,10 @@ class wp_commandscript : public CommandScript WorldDatabase.Execute(stmt); - handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id); + handler->PSendSysMessage("{}{}{}|r", "|cff00ff00", "Wp Event: New waypoint event added: ", id); } else - handler->PSendSysMessage("|cff00ff00Wp Event: You have choosed an existing waypoint script guid: %u|r", id); + handler->PSendSysMessage("|cff00ff00Wp Event: You have choosed an existing waypoint script guid: {}|r", id); } else { @@ -332,7 +332,7 @@ class wp_commandscript : public CommandScript WorldDatabase.Execute(stmt); - handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: New waypoint event added: |r|cff00ffff", id + 1); + handler->PSendSysMessage("{}{}{}|r", "|cff00ff00", "Wp Event: New waypoint event added: |r|cff00ffff", id + 1); } return true; @@ -342,7 +342,7 @@ class wp_commandscript : public CommandScript { if (!arg_id) { - handler->PSendSysMessage("%s%s|r", "|cff33ffff", "Wp Event: You must provide waypoint script id."); + handler->PSendSysMessage("{}{}|r", "|cff33ffff", "Wp Event: You must provide waypoint script id."); return true; } @@ -358,7 +358,7 @@ class wp_commandscript : public CommandScript if (!result) { - handler->PSendSysMessage("%s%s%u|r", "|cff33ffff", "Wp Event: No waypoint scripts found on id: ", id); + handler->PSendSysMessage("{}{}{}|r", "|cff33ffff", "Wp Event: No waypoint scripts found on id: ", id); return true; } @@ -378,7 +378,7 @@ class wp_commandscript : public CommandScript a10 = fields[8].Get(); a11 = fields[9].Get(); - handler->PSendSysMessage("|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, datatext: |r|cff00ffff%s|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); + handler->PSendSysMessage("|cffff33ffid:|r|cff00ffff {}|r|cff00ff00, guid: |r|cff00ffff{}|r|cff00ff00, delay: |r|cff00ffff{}|r|cff00ff00, command: |r|cff00ffff{}|r|cff00ff00, datalong: |r|cff00ffff{}|r|cff00ff00, datalong2: |r|cff00ffff{}|r|cff00ff00, datatext: |r|cff00ffff{}|r|cff00ff00, posx: |r|cff00ffff{}|r|cff00ff00, posy: |r|cff00ffff{}|r|cff00ff00, posz: |r|cff00ffff{}|r|cff00ff00, orientation: |r|cff00ffff{}|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); } while (result->NextRow()); } @@ -406,10 +406,10 @@ class wp_commandscript : public CommandScript WorldDatabase.Execute(stmt); - handler->PSendSysMessage("%s%s%u|r", "|cff00ff00", "Wp Event: Waypoint script removed: ", id); + handler->PSendSysMessage("{}{}{}|r", "|cff00ff00", "Wp Event: Waypoint script removed: ", id); } else - handler->PSendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: %u|r", id); + handler->PSendSysMessage("|cffff33ffWp Event: ERROR: you have selected a non existing script: {}|r", id); return true; } @@ -461,7 +461,7 @@ class wp_commandscript : public CommandScript if (arg_str_2 == "setid") { uint32 newid = atoi(arg_3); - handler->PSendSysMessage("%s%s|r|cff00ffff%u|r|cff00ff00%s|r|cff00ffff%u|r", "|cff00ff00", "Wp Event: Wypoint scipt guid: ", newid, " id changed: ", id); + handler->PSendSysMessage("{}{}|r|cff00ffff{}|r|cff00ff00{}|r|cff00ffff{}|r", "|cff00ff00", "Wp Event: Wypoint scipt guid: ", newid, " id changed: ", id); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_ID); @@ -493,7 +493,7 @@ class wp_commandscript : public CommandScript WorldDatabase.Execute(stmt); - handler->PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff %u|r|cff00ff00 position_x updated.|r", id); + handler->PSendSysMessage("|cff00ff00Waypoint script:|r|cff00ffff {}|r|cff00ff00 position_x updated.|r", id); return true; } else if (arg_str_2 == "posy") @@ -505,7 +505,7 @@ class wp_commandscript : public CommandScript WorldDatabase.Execute(stmt); - handler->PSendSysMessage("|cff00ff00Waypoint script: %u position_y updated.|r", id); + handler->PSendSysMessage("|cff00ff00Waypoint script: {} position_y updated.|r", id); return true; } else if (arg_str_2 == "posz") @@ -517,7 +517,7 @@ class wp_commandscript : public CommandScript WorldDatabase.Execute(stmt); - handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 position_z updated.|r", id); + handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff{}|r|cff00ff00 position_z updated.|r", id); return true; } else if (arg_str_2 == "orientation") @@ -529,14 +529,14 @@ class wp_commandscript : public CommandScript WorldDatabase.Execute(stmt); - handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 orientation updated.|r", id); + handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff{}|r|cff00ff00 orientation updated.|r", id); return true; } else if (arg_str_2 == "dataint") { WorldDatabase.Execute("UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, atoi(arg_3), id); // Query can't be a prepared statement - handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id); + handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff{}|r|cff00ff00 dataint updated.|r", id); return true; } else @@ -546,7 +546,7 @@ class wp_commandscript : public CommandScript WorldDatabase.Execute("UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, arg_str_3, id); // Query can't be a prepared statement } } - handler->PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r", "|cff00ff00", "Waypoint script:", id, arg_2, "updated."); + handler->PSendSysMessage("{}{}|r|cff00ffff{}:|r|cff00ff00 {} {}|r", "|cff00ff00", "Waypoint script:", id, arg_2, "updated."); } return true; } @@ -646,7 +646,7 @@ class wp_commandscript : public CommandScript if (show == "del") { - handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff%u|r", pathid); + handler->PSendSysMessage("|cff00ff00DEBUG: wp modify del, PathID: |r|cff00ffff{}|r", pathid); if (wpSpawnId != 0) if (Creature* wpCreature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(target->GetGUID())) @@ -674,7 +674,7 @@ class wp_commandscript : public CommandScript if (show == "move") { - handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff%u|r", pathid); + handler->PSendSysMessage("|cff00ff00DEBUG: wp move, PathID: |r|cff00ffff{}|r", pathid); Player* chr = handler->GetSession()->GetPlayer(); Map* map = chr->GetMap(); @@ -792,7 +792,7 @@ class wp_commandscript : public CommandScript std::string show = show_str; - //handler->PSendSysMessage("wpshow - show: %s", show); + //handler->PSendSysMessage("wpshow - show: {}", show); // Show info for the selected waypoint if (show == "info") @@ -828,11 +828,11 @@ class wp_commandscript : public CommandScript uint32 ev_id = fields[4].Get(); uint32 ev_chance = fields[5].Get(); - handler->PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid); - handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay); - handler->PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff%u|r", flag); - handler->PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff%u|r", ev_id); - handler->PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff%u|r", ev_chance); + handler->PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff{}|r|cff00ff00, Path ID: |r|cff00ffff{}|r", point, pathid); + handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff{}|r", delay); + handler->PSendSysMessage("|cff00ff00Show info: Move flag: |r|cff00ffff{}|r", flag); + handler->PSendSysMessage("|cff00ff00Show info: Waypoint event: |r|cff00ffff{}|r", ev_id); + handler->PSendSysMessage("|cff00ff00Show info: Event chance: |r|cff00ffff{}|r", ev_chance); } while (result->NextRow()); return true; @@ -853,7 +853,7 @@ class wp_commandscript : public CommandScript return false; } - handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff%u|r", pathid); + handler->PSendSysMessage("|cff00ff00DEBUG: wp on, PathID: |cff00ffff{}|r", pathid); // Delete all visuals for this NPC stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_WPGUID_BY_ID); @@ -950,7 +950,7 @@ class wp_commandscript : public CommandScript if (show == "first") { - handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid); + handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: {}|r", pathid); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID); stmt->SetData(0, pathid); @@ -1000,7 +1000,7 @@ class wp_commandscript : public CommandScript if (show == "last") { - handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid); + handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff{}|r", pathid); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID); stmt->SetData(0, pathid); diff --git a/src/server/scripts/Northrend/zone_wintergrasp.cpp b/src/server/scripts/Northrend/zone_wintergrasp.cpp index f602368bc456ff..eaa091a2df0777 100644 --- a/src/server/scripts/Northrend/zone_wintergrasp.cpp +++ b/src/server/scripts/Northrend/zone_wintergrasp.cpp @@ -20,6 +20,7 @@ #include "BattlefieldWG.h" #include "CombatAI.h" #include "GameGraveyard.h" +#include "GameLocale.h" #include "GameObjectAI.h" #include "GameTime.h" #include "ObjectMgr.h" @@ -213,7 +214,7 @@ class npc_wg_spirit_guide : public CreatureScript GraveyardVect graveyard = wintergrasp->GetGraveyardVector(); for (uint8 i = 0; i < graveyard.size(); i++) if (graveyard[i]->GetControlTeamId() == player->GetTeamId()) - AddGossipItemFor(player, GOSSIP_ICON_CHAT, sObjectMgr->GetAcoreStringForDBCLocale(((BfGraveyardWG*)graveyard[i])->GetTextId()), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + i); + AddGossipItemFor(player, GOSSIP_ICON_CHAT, sGameLocale->GetAcoreStringForDBCLocale(((BfGraveyardWG*)graveyard[i])->GetTextId()), GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + i); SendGossipMenuFor(player, player->GetGossipTextId(creature), creature->GetGUID()); return true; diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp index 27bb6010277221..5dcc8f3b1972dc 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPEP.cpp @@ -17,6 +17,7 @@ #include "OutdoorPvPEP.h" #include "GameGraveyard.h" +#include "GameLocale.h" #include "GameObject.h" #include "Language.h" #include "MapMgr.h" @@ -40,12 +41,12 @@ void OPvPCapturePointEP_EWT::ChangeState() // if changing from controlling alliance to horde or vice versa if ( m_OldState == OBJECTIVESTATE_ALLIANCE && m_OldState != m_State ) { - sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_EWT_A)); + sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_EWT_A)); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_EWT, TEAM_NEUTRAL); } else if ( m_OldState == OBJECTIVESTATE_HORDE && m_OldState != m_State ) { - sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_EWT_H)); + sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_EWT_H)); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_EWT, TEAM_NEUTRAL); } @@ -58,14 +59,14 @@ void OPvPCapturePointEP_EWT::ChangeState() artkit = 2; SummonSupportUnitAtNorthpassTower(TEAM_ALLIANCE); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_EWT, TEAM_ALLIANCE); - if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_EWT_A)); + if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_EWT_A)); break; case OBJECTIVESTATE_HORDE: m_TowerState = EP_TS_H; artkit = 1; SummonSupportUnitAtNorthpassTower(TEAM_HORDE); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_EWT, TEAM_HORDE); - if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_EWT_H)); + if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_EWT_H)); break; case OBJECTIVESTATE_NEUTRAL: m_TowerState = EP_TS_N; @@ -172,12 +173,12 @@ void OPvPCapturePointEP_NPT::ChangeState() // if changing from controlling alliance to horde or vice versa if ( m_OldState == OBJECTIVESTATE_ALLIANCE && m_OldState != m_State ) { - sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_NPT_A)); + sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_NPT_A)); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_NPT, TEAM_NEUTRAL); } else if ( m_OldState == OBJECTIVESTATE_HORDE && m_OldState != m_State ) { - sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_NPT_H)); + sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_NPT_H)); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_NPT, TEAM_NEUTRAL); } @@ -190,14 +191,14 @@ void OPvPCapturePointEP_NPT::ChangeState() artkit = 2; SummonGO(TEAM_ALLIANCE); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_NPT, TEAM_ALLIANCE); - if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_NPT_A)); + if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_NPT_A)); break; case OBJECTIVESTATE_HORDE: m_TowerState = EP_TS_H; artkit = 1; SummonGO(TEAM_HORDE); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_NPT, TEAM_HORDE); - if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_NPT_H)); + if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_NPT_H)); break; case OBJECTIVESTATE_NEUTRAL: m_TowerState = EP_TS_N; @@ -314,12 +315,12 @@ void OPvPCapturePointEP_CGT::ChangeState() // if changing from controlling alliance to horde or vice versa if ( m_OldState == OBJECTIVESTATE_ALLIANCE && m_OldState != m_State ) { - sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_CGT_A)); + sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_CGT_A)); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_CGT, TEAM_NEUTRAL); } else if ( m_OldState == OBJECTIVESTATE_HORDE && m_OldState != m_State ) { - sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_CGT_H)); + sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_CGT_H)); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_CGT, TEAM_NEUTRAL); } @@ -332,14 +333,14 @@ void OPvPCapturePointEP_CGT::ChangeState() artkit = 2; LinkGraveyard(TEAM_ALLIANCE); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_CGT, TEAM_ALLIANCE); - if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_CGT_A)); + if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_CGT_A)); break; case OBJECTIVESTATE_HORDE: m_TowerState = EP_TS_H; artkit = 1; LinkGraveyard(TEAM_HORDE); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_CGT, TEAM_HORDE); - if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_CGT_H)); + if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_CGT_H)); break; case OBJECTIVESTATE_NEUTRAL: m_TowerState = EP_TS_N; @@ -441,12 +442,12 @@ void OPvPCapturePointEP_PWT::ChangeState() // if changing from controlling alliance to horde or vice versa if ( m_OldState == OBJECTIVESTATE_ALLIANCE && m_OldState != m_State ) { - sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_PWT_A)); + sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_PWT_A)); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_PWT, TEAM_NEUTRAL); } else if ( m_OldState == OBJECTIVESTATE_HORDE && m_OldState != m_State ) { - sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_PWT_H)); + sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_LOSE_PWT_H)); ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_PWT, TEAM_NEUTRAL); } @@ -459,14 +460,14 @@ void OPvPCapturePointEP_PWT::ChangeState() SummonFlightMaster(TEAM_ALLIANCE); artkit = 2; ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_PWT, TEAM_ALLIANCE); - if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_PWT_A)); + if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_PWT_A)); break; case OBJECTIVESTATE_HORDE: m_TowerState = EP_TS_H; SummonFlightMaster(TEAM_HORDE); artkit = 1; ((OutdoorPvPEP*)m_PvP)->SetControlledState(EP_PWT, TEAM_HORDE); - if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_PWT_H)); + if (m_OldState != m_State) sWorld->SendZoneText(EP_GraveYardZone, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_CAPTURE_PWT_H)); break; case OBJECTIVESTATE_NEUTRAL: m_TowerState = EP_TS_N; @@ -573,7 +574,7 @@ void OPvPCapturePointEP_PWT::SummonFlightMaster(TeamId teamId) GossipOption gso; gso.Action = GOSSIP_OPTION_OUTDOORPVP; gso.GossipId = 0; - gso.OptionText.assign(sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_FLIGHT_NPT)); + gso.OptionText.assign(sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_FLIGHT_NPT)); gso.Id = 50; gso.Icon = 0; gso.NpcFlag = 0; @@ -583,7 +584,7 @@ void OPvPCapturePointEP_PWT::SummonFlightMaster(TeamId teamId) gso.Action = GOSSIP_OPTION_OUTDOORPVP; gso.GossipId = 0; - gso.OptionText.assign(sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_FLIGHT_EWT)); + gso.OptionText.assign(sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_FLIGHT_EWT)); gso.Id = 50; gso.Icon = 0; gso.NpcFlag = 0; @@ -593,7 +594,7 @@ void OPvPCapturePointEP_PWT::SummonFlightMaster(TeamId teamId) gso.Action = GOSSIP_OPTION_OUTDOORPVP; gso.GossipId = 0; - gso.OptionText.assign(sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_EP_FLIGHT_CGT)); + gso.OptionText.assign(sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_EP_FLIGHT_CGT)); gso.Id = 50; gso.Icon = 0; gso.NpcFlag = 0; diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp index 47ac8c1e988d0b..5eae4616cd353c 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPHP.cpp @@ -16,6 +16,7 @@ */ #include "OutdoorPvPHP.h" +#include "GameLocale.h" #include "Language.h" #include "MapMgr.h" #include "ObjectMgr.h" @@ -180,13 +181,13 @@ void OPvPCapturePointHP::ChangeState() field = HP_MAP_A[m_TowerType]; if (uint32 alliance_towers = ((OutdoorPvPHP*)m_PvP)->GetAllianceTowersControlled()) ((OutdoorPvPHP*)m_PvP)->SetAllianceTowersControlled(--alliance_towers); - sWorld->SendZoneText(OutdoorPvPHPBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(HP_LANG_LOSE_A[m_TowerType])); + sWorld->SendZoneText(OutdoorPvPHPBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(HP_LANG_LOSE_A[m_TowerType])); break; case OBJECTIVESTATE_HORDE: field = HP_MAP_H[m_TowerType]; if (uint32 horde_towers = ((OutdoorPvPHP*)m_PvP)->GetHordeTowersControlled()) ((OutdoorPvPHP*)m_PvP)->SetHordeTowersControlled(--horde_towers); - sWorld->SendZoneText(OutdoorPvPHPBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(HP_LANG_LOSE_H[m_TowerType])); + sWorld->SendZoneText(OutdoorPvPHPBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(HP_LANG_LOSE_H[m_TowerType])); break; case OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE: field = HP_MAP_N[m_TowerType]; @@ -223,7 +224,7 @@ void OPvPCapturePointHP::ChangeState() uint32 alliance_towers = ((OutdoorPvPHP*)m_PvP)->GetAllianceTowersControlled(); if (alliance_towers < 3) ((OutdoorPvPHP*)m_PvP)->SetAllianceTowersControlled(++alliance_towers); - sWorld->SendZoneText(OutdoorPvPHPBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(HP_LANG_CAPTURE_A[m_TowerType])); + sWorld->SendZoneText(OutdoorPvPHPBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(HP_LANG_CAPTURE_A[m_TowerType])); break; } case OBJECTIVESTATE_HORDE: @@ -234,7 +235,7 @@ void OPvPCapturePointHP::ChangeState() uint32 horde_towers = ((OutdoorPvPHP*)m_PvP)->GetHordeTowersControlled(); if (horde_towers < 3) ((OutdoorPvPHP*)m_PvP)->SetHordeTowersControlled(++horde_towers); - sWorld->SendZoneText(OutdoorPvPHPBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(HP_LANG_CAPTURE_H[m_TowerType])); + sWorld->SendZoneText(OutdoorPvPHPBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(HP_LANG_CAPTURE_H[m_TowerType])); break; } case OBJECTIVESTATE_NEUTRAL_ALLIANCE_CHALLENGE: diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp index 5c359cb7cfb8f5..2f1e2a99b004b2 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPNA.cpp @@ -17,6 +17,7 @@ #include "OutdoorPvPNA.h" #include "GameGraveyard.h" +#include "GameLocale.h" #include "Language.h" #include "MapMgr.h" #include "ObjectMgr.h" @@ -138,9 +139,9 @@ void OPvPCapturePointNA::FactionTakeOver(TeamId teamId) if (m_ControllingFaction != TEAM_NEUTRAL) sGraveyard->RemoveGraveyardLink(NA_HALAA_GRAVEYARD, NA_HALAA_GRAVEYARD_ZONE, m_ControllingFaction, false); if (m_ControllingFaction == TEAM_ALLIANCE) - sWorld->SendZoneText(NA_HALAA_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_NA_LOSE_A)); + sWorld->SendZoneText(NA_HALAA_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_NA_LOSE_A)); else if (m_ControllingFaction == TEAM_HORDE) - sWorld->SendZoneText(NA_HALAA_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_NA_LOSE_H)); + sWorld->SendZoneText(NA_HALAA_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_NA_LOSE_H)); m_ControllingFaction = teamId; if (m_ControllingFaction != TEAM_NEUTRAL) @@ -162,7 +163,7 @@ void OPvPCapturePointNA::FactionTakeOver(TeamId teamId) m_PvP->SendUpdateWorldState(NA_UI_HORDE_GUARDS_SHOW, 0); m_PvP->SendUpdateWorldState(NA_UI_ALLIANCE_GUARDS_SHOW, 1); m_PvP->SendUpdateWorldState(NA_UI_GUARDS_LEFT, m_GuardsAlive); - sWorld->SendZoneText(NA_HALAA_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_NA_CAPTURE_A)); + sWorld->SendZoneText(NA_HALAA_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_NA_CAPTURE_A)); } else { @@ -174,7 +175,7 @@ void OPvPCapturePointNA::FactionTakeOver(TeamId teamId) m_PvP->SendUpdateWorldState(NA_UI_HORDE_GUARDS_SHOW, 1); m_PvP->SendUpdateWorldState(NA_UI_ALLIANCE_GUARDS_SHOW, 0); m_PvP->SendUpdateWorldState(NA_UI_GUARDS_LEFT, m_GuardsAlive); - sWorld->SendZoneText(NA_HALAA_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_NA_CAPTURE_H)); + sWorld->SendZoneText(NA_HALAA_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_NA_CAPTURE_H)); } UpdateWyvernRoostWorldState(NA_ROOST_S); UpdateWyvernRoostWorldState(NA_ROOST_N); diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp index 3dc99602927ea9..e095d87e6f8a64 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPSI.cpp @@ -16,6 +16,7 @@ */ #include "OutdoorPvPSI.h" +#include "GameLocale.h" #include "GameObject.h" #include "Language.h" #include "MapMgr.h" @@ -101,7 +102,7 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger) if (m_Gathered_A >= SI_MAX_RESOURCES) { TeamApplyBuff(TEAM_ALLIANCE, SI_CENARION_FAVOR, 0, player); - sWorld->SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_SI_CAPTURE_A)); + sWorld->SendZoneText(OutdoorPvPSIBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_SI_CAPTURE_A)); m_LastController = TEAM_ALLIANCE; m_Gathered_A = 0; m_Gathered_H = 0; @@ -127,7 +128,7 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger) if (m_Gathered_H >= SI_MAX_RESOURCES) { TeamApplyBuff(TEAM_HORDE, SI_CENARION_FAVOR, 0, player); - sWorld->SendZoneText(OutdoorPvPSIBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_SI_CAPTURE_H)); + sWorld->SendZoneText(OutdoorPvPSIBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_SI_CAPTURE_H)); m_LastController = TEAM_HORDE; m_Gathered_A = 0; m_Gathered_H = 0; diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp index cb611c3ec8f260..83463297cae113 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPTF.cpp @@ -16,6 +16,7 @@ */ #include "OutdoorPvPTF.h" +#include "GameLocale.h" #include "Language.h" #include "MapMgr.h" #include "ObjectMgr.h" @@ -290,14 +291,14 @@ void OPvPCapturePointTF::ChangeState() { if (uint32 alliance_towers = ((OutdoorPvPTF*)m_PvP)->GetAllianceTowersControlled()) ((OutdoorPvPTF*)m_PvP)->SetAllianceTowersControlled(--alliance_towers); - sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_TF_LOSE_A)); + sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_TF_LOSE_A)); } // if changing from controlling horde to alliance else if (m_OldState == OBJECTIVESTATE_HORDE) { if (uint32 horde_towers = ((OutdoorPvPTF*)m_PvP)->GetHordeTowersControlled()) ((OutdoorPvPTF*)m_PvP)->SetHordeTowersControlled(--horde_towers); - sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_TF_LOSE_H)); + sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_TF_LOSE_H)); } uint32 artkit = 21; @@ -312,7 +313,7 @@ void OPvPCapturePointTF::ChangeState() if (alliance_towers < TF_TOWER_NUM) ((OutdoorPvPTF*)m_PvP)->SetAllianceTowersControlled(++alliance_towers); - sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_TF_CAPTURE_A)); + sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_TF_CAPTURE_A)); for (PlayerSet::iterator itr = m_activePlayers[0].begin(); itr != m_activePlayers[0].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) @@ -327,7 +328,7 @@ void OPvPCapturePointTF::ChangeState() if (horde_towers < TF_TOWER_NUM) ((OutdoorPvPTF*)m_PvP)->SetHordeTowersControlled(++horde_towers); - sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_TF_CAPTURE_H)); + sWorld->SendZoneText(OutdoorPvPTFBuffZones[0], sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_TF_CAPTURE_H)); for (PlayerSet::iterator itr = m_activePlayers[1].begin(); itr != m_activePlayers[1].end(); ++itr) if (Player* player = ObjectAccessor::FindPlayer(*itr)) diff --git a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp index f701b22fa5f30f..1befc5cdea3c52 100644 --- a/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp +++ b/src/server/scripts/OutdoorPvP/OutdoorPvPZM.cpp @@ -18,6 +18,7 @@ #include "OutdoorPvPZM.h" #include "Creature.h" #include "GameGraveyard.h" +#include "GameLocale.h" #include "ObjectAccessor.h" #include "ObjectMgr.h" #include "OutdoorPvPMgr.h" @@ -78,14 +79,14 @@ void OPvPCapturePointZM_Beacon::ChangeState() { if (uint32 alliance_towers = ((OutdoorPvPZM*)m_PvP)->GetAllianceTowersControlled()) ((OutdoorPvPZM*)m_PvP)->SetAllianceTowersControlled(--alliance_towers); - sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(ZMBeaconLoseA[m_TowerType])); + sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(ZMBeaconLoseA[m_TowerType])); } // if changing from controlling horde to alliance else if (m_OldState == OBJECTIVESTATE_HORDE) { if (uint32 horde_towers = ((OutdoorPvPZM*)m_PvP)->GetHordeTowersControlled()) ((OutdoorPvPZM*)m_PvP)->SetHordeTowersControlled(--horde_towers); - sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(ZMBeaconLoseH[m_TowerType])); + sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(ZMBeaconLoseH[m_TowerType])); } switch (m_State) @@ -96,7 +97,7 @@ void OPvPCapturePointZM_Beacon::ChangeState() uint32 alliance_towers = ((OutdoorPvPZM*)m_PvP)->GetAllianceTowersControlled(); if (alliance_towers < ZM_NUM_BEACONS) ((OutdoorPvPZM*)m_PvP)->SetAllianceTowersControlled(++alliance_towers); - sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(ZMBeaconCaptureA[m_TowerType])); + sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(ZMBeaconCaptureA[m_TowerType])); break; } case OBJECTIVESTATE_HORDE: @@ -105,7 +106,7 @@ void OPvPCapturePointZM_Beacon::ChangeState() uint32 horde_towers = ((OutdoorPvPZM*)m_PvP)->GetHordeTowersControlled(); if (horde_towers < ZM_NUM_BEACONS) ((OutdoorPvPZM*)m_PvP)->SetHordeTowersControlled(++horde_towers); - sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(ZMBeaconCaptureH[m_TowerType])); + sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(ZMBeaconCaptureH[m_TowerType])); break; } case OBJECTIVESTATE_NEUTRAL: @@ -223,7 +224,7 @@ int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player* player, GameObject* go) if (player->HasAura(ZM_BATTLE_STANDARD_A) && m_GraveYardState != ZM_GRAVEYARD_A) { if (m_GraveYardState == ZM_GRAVEYARD_H) - sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_ZM_LOSE_GY_H)); + sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_ZM_LOSE_GY_H)); m_GraveYardState = ZM_GRAVEYARD_A; DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant AddObject(0, ZM_Banner_A.entry, ZM_Banner_A.map, ZM_Banner_A.x, ZM_Banner_A.y, ZM_Banner_A.z, ZM_Banner_A.o, ZM_Banner_A.rot0, ZM_Banner_A.rot1, ZM_Banner_A.rot2, ZM_Banner_A.rot3); @@ -231,12 +232,12 @@ int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player* player, GameObject* go) sGraveyard->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_ALLIANCE, false); // add gy m_PvP->TeamApplyBuff(TEAM_ALLIANCE, ZM_CAPTURE_BUFF, 0, player); player->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_A); - sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_A)); + sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_A)); } else if (player->HasAura(ZM_BATTLE_STANDARD_H) && m_GraveYardState != ZM_GRAVEYARD_H) { if (m_GraveYardState == ZM_GRAVEYARD_A) - sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_ZM_LOSE_GY_A)); + sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_ZM_LOSE_GY_A)); m_GraveYardState = ZM_GRAVEYARD_H; DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant AddObject(0, ZM_Banner_H.entry, ZM_Banner_H.map, ZM_Banner_H.x, ZM_Banner_H.y, ZM_Banner_H.z, ZM_Banner_H.o, ZM_Banner_H.rot0, ZM_Banner_H.rot1, ZM_Banner_H.rot2, ZM_Banner_H.rot3); @@ -244,7 +245,7 @@ int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player* player, GameObject* go) sGraveyard->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_HORDE, false); // add gy m_PvP->TeamApplyBuff(TEAM_HORDE, ZM_CAPTURE_BUFF, 0, player); player->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_H); - sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetAcoreStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_H)); + sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sGameLocale->GetAcoreStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_H)); } UpdateTowerState(); } diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp index cc052f3ba615fa..c90f0ac158d68c 100644 --- a/src/server/scripts/Spells/spell_item.cpp +++ b/src/server/scripts/Spells/spell_item.cpp @@ -22,6 +22,7 @@ */ #include "Battleground.h" +#include "GameLocale.h" #include "GameTime.h" #include "Player.h" #include "ScriptMgr.h" @@ -69,16 +70,16 @@ class spell_item_titanium_seal_of_dalaran : public SpellScript if (Player* player = caster->ToPlayer()) { LocaleConstant loc_idx = player->GetSession()->GetSessionDbLocaleIndex(); - if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(TITANIUM_SEAL_OF_DALARAN_BROADCAST_TEXT_ID_FLIP)) + if (BroadcastText const* bct = sGameLocale->GetBroadcastText(TITANIUM_SEAL_OF_DALARAN_BROADCAST_TEXT_ID_FLIP)) player->TextEmote(bct->GetText(loc_idx, player->getGender())); if (urand(0, 1)) { - if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(TITANIUM_SEAL_OF_DALARAN_BROADCAST_TEXT_ID_FACE_DOWN)) + if (BroadcastText const* bct = sGameLocale->GetBroadcastText(TITANIUM_SEAL_OF_DALARAN_BROADCAST_TEXT_ID_FACE_DOWN)) player->TextEmote(bct->GetText(loc_idx, player->getGender())); } else { - if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(TITANIUM_SEAL_OF_DALARAN_BROADCAST_TEXT_ID_HEADS_UP)) + if (BroadcastText const* bct = sGameLocale->GetBroadcastText(TITANIUM_SEAL_OF_DALARAN_BROADCAST_TEXT_ID_HEADS_UP)) player->TextEmote(bct->GetText(loc_idx, player->getGender())); } } @@ -602,19 +603,19 @@ class spell_item_feast : public SpellScript switch(GetSpellInfo()->Id) { case SPELL_GREAT_FEAST: - if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(GREAT_FEAST_BROADCAST_TEXT_ID_PREPARE)) + if (BroadcastText const* bct = sGameLocale->GetBroadcastText(GREAT_FEAST_BROADCAST_TEXT_ID_PREPARE)) player->TextEmote(bct->GetText(loc_idx, player->getGender()).c_str(), player); break; case SPELL_FISH_FEAST: - if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(FISH_FEAST_BROADCAST_TEXT_ID_PREPARE)) + if (BroadcastText const* bct = sGameLocale->GetBroadcastText(FISH_FEAST_BROADCAST_TEXT_ID_PREPARE)) player->TextEmote(bct->GetText(loc_idx, player->getGender()).c_str(), player); break; case SPELL_SMALL_FEAST: - if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(SMALL_FEAST_BROADCAST_TEXT_ID_PREPARE)) + if (BroadcastText const* bct = sGameLocale->GetBroadcastText(SMALL_FEAST_BROADCAST_TEXT_ID_PREPARE)) player->TextEmote(bct->GetText(loc_idx, player->getGender()).c_str(), player); break; case SPELL_GIGANTIC_FEAST: - if (BroadcastText const* bct = sObjectMgr->GetBroadcastText(GIGANTIC_FEAST_BROADCAST_TEXT_ID_PREPARE)) + if (BroadcastText const* bct = sGameLocale->GetBroadcastText(GIGANTIC_FEAST_BROADCAST_TEXT_ID_PREPARE)) player->TextEmote(bct->GetText(loc_idx, player->getGender()).c_str(), player); break; } diff --git a/src/server/scripts/World/go_scripts.cpp b/src/server/scripts/World/go_scripts.cpp index 4c05c2a390ba6f..7815c96bf49057 100644 --- a/src/server/scripts/World/go_scripts.cpp +++ b/src/server/scripts/World/go_scripts.cpp @@ -42,6 +42,7 @@ go_veil_skith_cage EndContentData */ #include "CellImpl.h" +#include "ChatTextBuilder.h" #include "GameObjectAI.h" #include "GameTime.h" #include "GridNotifiersImpl.h" @@ -1120,7 +1121,7 @@ class go_tele_to_dalaran_crystal : public GameObjectScript if (player->GetQuestRewardStatus(QUEST_TELE_CRYSTAL_FLAG)) return false; - player->GetSession()->SendNotification(GO_TELE_TO_DALARAN_CRYSTAL_FAILED); + Acore::Text::SendNotification(player->GetSession(), GO_TELE_TO_DALARAN_CRYSTAL_FAILED); return true; } @@ -1661,7 +1662,7 @@ class go_amberpine_outhouse : public GameObjectScript else { CloseGossipMenuFor(player); - player->GetSession()->SendNotification(GO_ANDERHOLS_SLIDER_CIDER_NOT_FOUND); + Acore::Text::SendNotification(player->GetSession(), GO_ANDERHOLS_SLIDER_CIDER_NOT_FOUND); return false; } } diff --git a/src/test/mocks/WorldMock.h b/src/test/mocks/WorldMock.h index 832d4917a4c78f..7a55183c7c263a 100644 --- a/src/test/mocks/WorldMock.h +++ b/src/test/mocks/WorldMock.h @@ -19,8 +19,8 @@ #define AZEROTHCORE_WORLDMOCK_H #include "ArenaSpectator.h" -#include "IWorld.h" #include "Duration.h" +#include "IWorld.h" #include "gmock/gmock.h" #pragma GCC diagnostic push @@ -36,7 +36,6 @@ class WorldMock: public IWorld MOCK_METHOD(WorldSession*, FindOfflineSession, (uint32 id), (const)); MOCK_METHOD(WorldSession*, FindOfflineSessionForCharacterGUID, (ObjectGuid::LowType guidLow),(const)); MOCK_METHOD(void, AddSession, (WorldSession* s), ()); - MOCK_METHOD(void, SendAutoBroadcast, ()); MOCK_METHOD(bool, KickSession, (uint32 id), ()); MOCK_METHOD(void, UpdateMaxSessionCounters, ()); MOCK_METHOD(const SessionMap&, GetAllSessions, (), (const)); @@ -73,10 +72,7 @@ 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 {} - MOCK_METHOD(void, SendGlobalText, (const char* text, WorldSession* self), ()); - void SendGMText(uint32 string_id, ...) override {} + MOCK_METHOD(void, SendGlobalText, (std::string_view text, WorldSession* self), ()); MOCK_METHOD(void, SendGlobalMessage, (WorldPacket const* packet, WorldSession* self, TeamId teamId), ()); MOCK_METHOD(void, SendGlobalGMMessage, (WorldPacket const* packet, WorldSession* self, TeamId teamId), ()); MOCK_METHOD(bool, SendZoneMessage, (uint32 zone, WorldPacket const* packet, WorldSession* self, TeamId teamId), ()); @@ -116,7 +112,6 @@ class WorldMock: public IWorld MOCK_METHOD(char const *, GetWorldDBRevision, (), (const)); MOCK_METHOD(char const *, GetCharacterDBRevision, (), (const)); MOCK_METHOD(char const *, GetAuthDBRevision, (), (const)); - MOCK_METHOD(void, LoadAutobroadcasts, ()); MOCK_METHOD(void, UpdateAreaDependentAuras, ()); MOCK_METHOD(uint32, GetCleaningFlags, (), (const)); MOCK_METHOD(void, SetCleaningFlags, (uint32 flags), ());