diff --git a/apps/Fmt/FormatReplace.py b/apps/Fmt/FormatReplace.py index a25a02ed5..a9d553f14 100644 --- a/apps/Fmt/FormatReplace.py +++ b/apps/Fmt/FormatReplace.py @@ -62,12 +62,12 @@ def isPAppend(line): else : return False -# def isStringFormat(line): -# substring = 'StringFormat' -# if substring in line: -# return True -# else : -# return False +def isStringFormat(line): + substring = 'StringFormat' + if substring in line: + return True + else : + return False def haveDelimeter(line): if ';' in line: @@ -96,8 +96,8 @@ def checkSoloLine(line): # return handleCleanup(line), False # elif isPSendSysMessage(line): # return handleCleanup(line), False - # elif isStringFormat(line): - # return handleCleanup(line), False + elif isStringFormat(line): + return handleCleanup(line), False else: return line, False @@ -122,8 +122,8 @@ def startMultiLine(line): elif isPAppend(line): line = line.replace("PAppend", "Append"); return handleCleanup(line), True - # elif isStringFormat(line): - # return handleCleanup(line), True + elif isStringFormat(line): + return handleCleanup(line), True else : return line, False diff --git a/src/common/Banner.cpp b/src/common/Banner.cpp index f77c9abee..65f5ab577 100644 --- a/src/common/Banner.cpp +++ b/src/common/Banner.cpp @@ -21,7 +21,7 @@ void Acore::Banner::Show(std::string_view applicationName, void(*log)(std::string_view text), void(*logExtraInfo)()) { - log(Acore::StringFormatFmt("{} ({})", GitRevision::GetFullVersion(), applicationName)); + log(Acore::StringFormat("{} ({})", GitRevision::GetFullVersion(), applicationName)); log(" to stop.\n"); log(" █████╗ ███████╗███████╗██████╗ ██████╗ ████████╗██╗ ██╗"); log(" ██╔══██╗╚══███╔╝██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝██║ ██║"); diff --git a/src/common/Collision/Management/MMapMgr.cpp b/src/common/Collision/Management/MMapMgr.cpp index bb6791057..480a2db2d 100644 --- a/src/common/Collision/Management/MMapMgr.cpp +++ b/src/common/Collision/Management/MMapMgr.cpp @@ -85,7 +85,7 @@ namespace MMAP } // load and init dtNavMesh - read parameters from file - std::string fileName = Acore::StringFormat(MAP_FILE_NAME_FORMAT, sConfigMgr->GetOption("DataDir", ".").c_str(), mapId); + std::string fileName = Acore::StringFormat(MAP_FILE_NAME_FORMAT, sConfigMgr->GetOption("DataDir", "."), mapId); FILE* file = fopen(fileName.c_str(), "rb"); if (!file) @@ -146,7 +146,7 @@ namespace MMAP } // load this tile :: mmaps/MMMXXYY.mmtile - std::string fileName = Acore::StringFormat(TILE_FILE_NAME_FORMAT, sConfigMgr->GetOption("DataDir", ".").c_str(), mapId, x, y); + std::string fileName = Acore::StringFormat(TILE_FILE_NAME_FORMAT, sConfigMgr->GetOption("DataDir", "."), mapId, x, y); FILE* file = fopen(fileName.c_str(), "rb"); if (!file) { diff --git a/src/common/Configuration/Config.cpp b/src/common/Configuration/Config.cpp index 2261c14b1..5f653fa96 100644 --- a/src/common/Configuration/Config.cpp +++ b/src/common/Configuration/Config.cpp @@ -65,7 +65,7 @@ namespace template inline void PrintError(std::string_view filename, Format&& fmt, Args&& ... args) { - std::string message = Acore::StringFormatFmt(std::forward(fmt), std::forward(args)...); + std::string message = Acore::StringFormat(std::forward(fmt), std::forward(args)...); if (IsAppConfig(filename)) { @@ -117,7 +117,7 @@ namespace return false; } - throw ConfigException(Acore::StringFormatFmt("Config::LoadFile: Failed open {}file '{}'", isOptional ? "optional " : "", file)); + throw ConfigException(Acore::StringFormat("Config::LoadFile: Failed open {}file '{}'", isOptional ? "optional " : "", file)); } uint32 count = 0; @@ -144,7 +144,7 @@ namespace // read line error if (!in.good() && !in.eof()) - throw ConfigException(Acore::StringFormatFmt("> Config::LoadFile: Failure to read line number {} in file '{}'", lineNumber, file)); + throw ConfigException(Acore::StringFormat("> Config::LoadFile: Failure to read line number {} in file '{}'", lineNumber, file)); // remove whitespace in line line = Acore::String::Trim(line, in.getloc()); @@ -187,7 +187,7 @@ namespace return false; } - throw ConfigException(Acore::StringFormatFmt("Config::LoadFile: Empty file '{}'", file)); + throw ConfigException(Acore::StringFormat("Config::LoadFile: Empty file '{}'", file)); } // Add correct keys if file load without errors diff --git a/src/common/Debugging/Errors.cpp b/src/common/Debugging/Errors.cpp index 9ca5f8c29..b42b34a18 100644 --- a/src/common/Debugging/Errors.cpp +++ b/src/common/Debugging/Errors.cpp @@ -62,19 +62,19 @@ namespace inline std::string MakeMessage(std::string_view messageType, std::string_view file, uint32 line, std::string_view function, std::string_view message, std::string_view fmtMessage = {}, std::string_view debugInfo = {}) { - std::string msg = Acore::StringFormatFmt("\n>> {}\n\n# Location: {}:{}\n# Function: {}\n# Condition: {}\n", messageType, file, line, function, message); + std::string msg = Acore::StringFormat("\n>> {}\n\n# Location: {}:{}\n# Function: {}\n# Condition: {}\n", messageType, file, line, function, message); if (!fmtMessage.empty()) { - msg.append(Acore::StringFormatFmt("# Message: {}\n", fmtMessage)); + msg.append(Acore::StringFormat("# Message: {}\n", fmtMessage)); } if (!debugInfo.empty()) { - msg.append(Acore::StringFormatFmt("\n# Debug info: {}\n", debugInfo)); + msg.append(Acore::StringFormat("\n# Debug info: {}\n", debugInfo)); } - return Acore::StringFormatFmt( + return Acore::StringFormat( "#{0:-^{2}}#\n" " {1: ^{2}} \n" "#{0:-^{2}}#\n", "", msg, 70); @@ -90,14 +90,14 @@ namespace */ inline std::string MakeAbortMessage(std::string_view file, uint32 line, std::string_view function, std::string_view fmtMessage = {}) { - std::string msg = Acore::StringFormatFmt("\n>> ABORTED\n\n# Location '{}:{}'\n# Function '{}'\n", file, line, function); + std::string msg = Acore::StringFormat("\n>> ABORTED\n\n# Location '{}:{}'\n# Function '{}'\n", file, line, function); if (!fmtMessage.empty()) { - msg.append(Acore::StringFormatFmt("# Message '{}'\n", fmtMessage)); + msg.append(Acore::StringFormat("# Message '{}'\n", fmtMessage)); } - return Acore::StringFormatFmt( + return Acore::StringFormat( "\n#{0:-^{2}}#\n" " {1: ^{2}} \n" "#{0:-^{2}}#\n", "", msg, 70); @@ -148,7 +148,7 @@ void Acore::Abort(std::string_view file, uint32 line, std::string_view function, void Acore::AbortHandler(int sigval) { // nothing useful to log here, no way to pass args - std::string formattedMessage = StringFormatFmt("Caught signal {}\n", sigval); + std::string formattedMessage = StringFormat("Caught signal {}\n", sigval); fmt::print(stderr, "{}", formattedMessage); fflush(stderr); Crash(formattedMessage.c_str()); diff --git a/src/common/Debugging/Errors.h b/src/common/Debugging/Errors.h index 0155d0ddb..24a36f1e8 100644 --- a/src/common/Debugging/Errors.h +++ b/src/common/Debugging/Errors.h @@ -31,19 +31,19 @@ namespace Acore template AC_COMMON_API inline void Assert(std::string_view file, uint32 line, std::string_view function, std::string_view debugInfo, std::string_view message, std::string_view fmt, Args&&... args) { - Assert(file, line, function, debugInfo, message, StringFormatFmt(fmt, std::forward(args)...)); + Assert(file, line, function, debugInfo, message, StringFormat(fmt, std::forward(args)...)); } template AC_COMMON_API inline void Fatal(std::string_view file, uint32 line, std::string_view function, std::string_view message, std::string_view fmt, Args&&... args) { - Fatal(file, line, function, message, StringFormatFmt(fmt, std::forward(args)...)); + Fatal(file, line, function, message, StringFormat(fmt, std::forward(args)...)); } template AC_COMMON_API inline void Abort(std::string_view file, uint32 line, std::string_view function, std::string_view fmt, Args&&... args) { - Abort(file, line, function, StringFormatFmt(fmt, std::forward(args)...)); + Abort(file, line, function, StringFormat(fmt, std::forward(args)...)); } AC_COMMON_API void Warning(std::string_view file, uint32 line, std::string_view function, std::string_view message); diff --git a/src/common/Logging/AppenderConsole.cpp b/src/common/Logging/AppenderConsole.cpp index e7c63eadb..db5a47336 100644 --- a/src/common/Logging/AppenderConsole.cpp +++ b/src/common/Logging/AppenderConsole.cpp @@ -52,7 +52,7 @@ void AppenderConsole::InitColors(std::string const& name, std::string_view str) std::vector colorStrs = Acore::Tokenize(str, ' ', false); if (colorStrs.size() != NUM_ENABLED_LOG_LEVELS) { - throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Invalid color data '{}' for console appender {} (expected {} entries, got {})", + throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color data '{}' for console appender {} (expected {} entries, got {})", str, name, NUM_ENABLED_LOG_LEVELS, colorStrs.size())); } @@ -64,7 +64,7 @@ void AppenderConsole::InitColors(std::string const& name, std::string_view str) } else { - throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Invalid color '{}' for log level {} on console appender {}", + throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid color '{}' for log level {} on console appender {}", colorStrs[i], EnumUtils::ToTitle(static_cast(i)), name)); } } diff --git a/src/common/Logging/AppenderFile.cpp b/src/common/Logging/AppenderFile.cpp index 81b84cb98..9b4aa53ca 100644 --- a/src/common/Logging/AppenderFile.cpp +++ b/src/common/Logging/AppenderFile.cpp @@ -31,7 +31,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap { if (args.size() < 4) { - throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Missing file name for appender {}", name)); + throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Missing file name for appender {}", name)); } _fileName.assign(args[3]); @@ -63,7 +63,7 @@ AppenderFile::AppenderFile(uint8 id, std::string const& name, LogLevel level, Ap } else { - throw InvalidAppenderArgsException(Acore::StringFormatFmt("Log::CreateAppenderFromConfig: Invalid size '{}' for appender {}", args[5], name)); + throw InvalidAppenderArgsException(Acore::StringFormat("Log::CreateAppenderFromConfig: Invalid size '{}' for appender {}", args[5], name)); } } diff --git a/src/common/Logging/Log.h b/src/common/Logging/Log.h index f60bb0367..e4b6d6142 100644 --- a/src/common/Logging/Log.h +++ b/src/common/Logging/Log.h @@ -69,7 +69,7 @@ public: template inline void outMessage(std::string const& filter, LogLevel const level, Acore::FormatString fmt, Args&&... args) { - _outMessage(filter, level, Acore::StringFormatFmt(fmt, std::forward(args)...)); + _outMessage(filter, level, Acore::StringFormat(fmt, std::forward(args)...)); } template @@ -80,7 +80,7 @@ public: return; } - _outCommand(Acore::StringFormatFmt(fmt, std::forward(args)...), std::to_string(account)); + _outCommand(Acore::StringFormat(fmt, std::forward(args)...), std::to_string(account)); } void SetRealmId(uint32 id); diff --git a/src/common/Utilities/StringFormat.h b/src/common/Utilities/StringFormat.h index fa5aeb461..d4d93f232 100644 --- a/src/common/Utilities/StringFormat.h +++ b/src/common/Utilities/StringFormat.h @@ -26,27 +26,12 @@ namespace Acore { - /// Default AC string format function. - template - inline std::string StringFormat(Format&& fmt, Args&& ... args) - { - try - { - return fmt::sprintf(std::forward(fmt), std::forward(args)...); - } - catch (const fmt::format_error& formatError) - { - std::string error = "An error occurred formatting string \"" + std::string(fmt) + "\" : " + std::string(formatError.what()); - return error; - } - } - template using FormatString = fmt::format_string; - // Default string format function. + /// Default AC string format function. template - inline std::string StringFormatFmt(FormatString fmt, Args&&... args) + inline std::string StringFormat(FormatString fmt, Args&&... args) { try { diff --git a/src/common/Utilities/Timer.cpp b/src/common/Utilities/Timer.cpp index e7cb691a1..54913163f 100644 --- a/src/common/Utilities/Timer.cpp +++ b/src/common/Utilities/Timer.cpp @@ -86,27 +86,27 @@ AC_COMMON_API std::string Acore::Time::ToTimeString(uint64 duratio { if (days) { - return Acore::StringFormatFmt("{}:{:02}:{:02}:{:02}:{:02}:{:02}", days, hours, minutes, secs, millisecs); + return Acore::StringFormat("{}:{:02}:{:02}:{:02}:{:02}:{:02}", days, hours, minutes, secs, millisecs); } else if (hours) { - return Acore::StringFormatFmt("{}:{:02}:{:02}:{:02}:{:02}", hours, minutes, secs, millisecs); + return Acore::StringFormat("{}:{:02}:{:02}:{:02}:{:02}", hours, minutes, secs, millisecs); } else if (minutes) { - return Acore::StringFormatFmt("{}:{:02}:{:02}:{:02}", minutes, secs, millisecs); + return Acore::StringFormat("{}:{:02}:{:02}:{:02}", minutes, secs, millisecs); } else if (secs) { - return Acore::StringFormatFmt("{}:{:02}:{:02}", secs, millisecs); + return Acore::StringFormat("{}:{:02}:{:02}", secs, millisecs); } else if (millisecs) { - return Acore::StringFormatFmt("{}:{:02}", millisecs); + return Acore::StringFormat("{}:{:02}", millisecs); } else // microsecs { - return Acore::StringFormatFmt("{}", microsecs); + return Acore::StringFormat("{}", microsecs); } } diff --git a/src/server/database/Database/DatabaseWorkerPool.h b/src/server/database/Database/DatabaseWorkerPool.h index 181dd7f58..233fd5cf2 100644 --- a/src/server/database/Database/DatabaseWorkerPool.h +++ b/src/server/database/Database/DatabaseWorkerPool.h @@ -103,7 +103,7 @@ public: if (sql.empty()) return; - Execute(Acore::StringFormatFmt(sql, std::forward(args)...)); + Execute(Acore::StringFormat(sql, std::forward(args)...)); } //! Enqueues a one-way SQL operation in prepared statement format that will be executed asynchronously. @@ -126,7 +126,7 @@ public: if (sql.empty()) return; - DirectExecute(Acore::StringFormatFmt(sql, std::forward(args)...)); + DirectExecute(Acore::StringFormat(sql, std::forward(args)...)); } //! Directly executes a one-way SQL operation in prepared statement format, that will block the calling thread until finished. @@ -149,7 +149,7 @@ public: if (sql.empty()) return QueryResult(nullptr); - return Query(Acore::StringFormatFmt(sql, std::forward(args)...)); + return Query(Acore::StringFormat(sql, std::forward(args)...)); } //! Directly executes an SQL query in prepared format that will block the calling thread until finished. diff --git a/src/server/database/Database/PreparedStatement.cpp b/src/server/database/Database/PreparedStatement.cpp index 4059509dc..4b8f870ea 100644 --- a/src/server/database/Database/PreparedStatement.cpp +++ b/src/server/database/Database/PreparedStatement.cpp @@ -104,7 +104,7 @@ bool PreparedStatementTask::Execute() template std::string PreparedStatementData::ToString(T value) { - return Acore::StringFormatFmt("{}", value); + return Acore::StringFormat("{}", value); } template<> diff --git a/src/server/database/Database/Transaction.h b/src/server/database/Database/Transaction.h index 5d82703ae..448925053 100644 --- a/src/server/database/Database/Transaction.h +++ b/src/server/database/Database/Transaction.h @@ -45,7 +45,7 @@ public: template void Append(std::string_view sql, Args&&... args) { - Append(Acore::StringFormatFmt(sql, std::forward(args)...)); + Append(Acore::StringFormat(sql, std::forward(args)...)); } [[nodiscard]] std::size_t GetSize() const { return m_queries.size(); } diff --git a/src/server/database/Updater/DBUpdater.cpp b/src/server/database/Updater/DBUpdater.cpp index ffbdc1827..7b3ead066 100644 --- a/src/server/database/Updater/DBUpdater.cpp +++ b/src/server/database/Updater/DBUpdater.cpp @@ -235,7 +235,7 @@ bool DBUpdater::Update(DatabaseWorkerPool& pool, std::string_view modulesL auto CheckUpdateTable = [&](std::string const& tableName) { - auto checkTable = DBUpdater::Retrieve(pool, Acore::StringFormatFmt("SHOW TABLES LIKE '{}'", tableName)); + auto checkTable = DBUpdater::Retrieve(pool, Acore::StringFormat("SHOW TABLES LIKE '{}'", tableName)); if (!checkTable) { LOG_WARN("sql.updates", "> Table '{}' not exist! Try add based table", tableName); @@ -279,7 +279,7 @@ bool DBUpdater::Update(DatabaseWorkerPool& pool, std::string_view modulesL return false; } - std::string const info = Acore::StringFormatFmt("Containing {} new and {} archived updates.", result.recent, result.archived); + std::string const info = Acore::StringFormat("Containing {} new and {} archived updates.", result.recent, result.archived); if (!result.updated) LOG_INFO("sql.updates", ">> {} database is up-to-date! {}", DBUpdater::GetTableName(), info); @@ -307,7 +307,7 @@ bool DBUpdater::Update(DatabaseWorkerPool& pool, std::vector auto CheckUpdateTable = [&](std::string const& tableName) { - auto checkTable = DBUpdater::Retrieve(pool, Acore::StringFormatFmt("SHOW TABLES LIKE '{}'", tableName)); + auto checkTable = DBUpdater::Retrieve(pool, Acore::StringFormat("SHOW TABLES LIKE '{}'", tableName)); if (!checkTable) { Path const temp(GetBaseFilesDirectory() + tableName + ".sql"); @@ -507,7 +507,7 @@ void DBUpdater::ApplyFile(DatabaseWorkerPool& pool, std::string const& hos // Execute sql file args.emplace_back("-e"); - args.emplace_back(Acore::StringFormat("BEGIN; SOURCE %s; COMMIT;", path.generic_string().c_str())); + args.emplace_back(Acore::StringFormat("BEGIN; SOURCE {}; COMMIT;", path.generic_string())); // Database if (!database.empty()) diff --git a/src/server/game/Battlegrounds/ArenaScore.h b/src/server/game/Battlegrounds/ArenaScore.h index d29c1487c..3363c60f6 100644 --- a/src/server/game/Battlegrounds/ArenaScore.h +++ b/src/server/game/Battlegrounds/ArenaScore.h @@ -35,7 +35,7 @@ protected: // For Logging purpose std::string ToString() const override { - return Acore::StringFormatFmt("Damage done: {}, Healing done: {}, Killing blows: {}", DamageDone, HealingDone, KillingBlows); + return Acore::StringFormat("Damage done: {}, Healing done: {}, Killing blows: {}", DamageDone, HealingDone, KillingBlows); } uint8 PvPTeamId; diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index cef257d0f..1d602967d 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -1107,7 +1107,7 @@ void BattlegroundQueue::SendJoinMessageArenaQueue(Player* leader, GroupQueueInfo BattlegroundBracketId bracketId = bracketEntry->GetBracketId(); auto bgName = bg->GetName(); - auto arenatype = Acore::StringFormat("%uv%u", ginfo->ArenaType, ginfo->ArenaType); + auto arenatype = Acore::StringFormat("{}v{}", ginfo->ArenaType, ginfo->ArenaType); uint32 playersNeed = ArenaTeam::GetReqPlayersForType(ginfo->ArenaType); uint32 q_min_level = std::min(bracketEntry->minLevel, (uint32)80); uint32 q_max_level = std::min(bracketEntry->maxLevel, (uint32)80); diff --git a/src/server/game/Chat/Chat.h b/src/server/game/Chat/Chat.h index 8ef21176e..8a31c3c76 100644 --- a/src/server/game/Chat/Chat.h +++ b/src/server/game/Chat/Chat.h @@ -56,13 +56,13 @@ public: void SendNotification(uint32 strId, Args&&... args) { if (HasSession()) - SendNotification(Acore::StringFormatFmt(GetAcoreString(strId), std::forward(args)...)); + SendNotification(Acore::StringFormat(GetAcoreString(strId), std::forward(args)...)); } template void SendNotification(char const* fmt, Args&&... args) { if (HasSession()) - SendNotification(Acore::StringFormatFmt(fmt, std::forward(args)...)); + SendNotification(Acore::StringFormat(fmt, std::forward(args)...)); } void SendGMText(std::string_view str); @@ -73,7 +73,7 @@ public: DoForAllValidSessions([&](Player* player) { m_session = player->GetSession(); - SendGMText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward(args)...)); + SendGMText(Acore::StringFormat(GetAcoreString(strId), std::forward(args)...)); }); } template @@ -83,7 +83,7 @@ public: DoForAllValidSessions([&](Player* player) { m_session = player->GetSession(); - SendGMText(Acore::StringFormatFmt(fmt, std::forward(args)...)); + SendGMText(Acore::StringFormat(fmt, std::forward(args)...)); }); } @@ -95,7 +95,7 @@ public: DoForAllValidSessions([&](Player* player) { m_session = player->GetSession(); - SendWorldText(Acore::StringFormatFmt(GetAcoreString(strId), std::forward(args)...)); + SendWorldText(Acore::StringFormat(GetAcoreString(strId), std::forward(args)...)); }); } template @@ -105,7 +105,7 @@ public: DoForAllValidSessions([&](Player* player) { m_session = player->GetSession(); - SendWorldText(Acore::StringFormatFmt(fmt, std::forward(args)...)); + SendWorldText(Acore::StringFormat(fmt, std::forward(args)...)); }); } @@ -117,7 +117,7 @@ public: DoForAllValidSessions([&](Player* player) { m_session = player->GetSession(); - SendWorldTextOptional(Acore::StringFormatFmt(GetAcoreString(strId), std::forward(args)...), flag); + SendWorldTextOptional(Acore::StringFormat(GetAcoreString(strId), std::forward(args)...), flag); }); } template @@ -127,7 +127,7 @@ public: DoForAllValidSessions([&](Player* player) { m_session = player->GetSession(); - SendWorldTextOptional(Acore::StringFormatFmt(fmt, std::forward(args)...), flag); + SendWorldTextOptional(Acore::StringFormat(fmt, std::forward(args)...), flag); }); } @@ -142,7 +142,7 @@ public: void PSendSysMessage(char const* fmt, Args&&... args) { if (HasSession()) - SendSysMessage(Acore::StringFormatFmt(fmt, std::forward(args)...)); + SendSysMessage(Acore::StringFormat(fmt, std::forward(args)...)); } template @@ -155,7 +155,7 @@ public: template std::string PGetParseString(uint32 entry, Args&&... args) const { - return Acore::StringFormatFmt(GetAcoreString(entry), std::forward(args)...); + return Acore::StringFormat(GetAcoreString(entry), std::forward(args)...); } std::string const* GetModuleString(std::string module, uint32 id) const; @@ -170,7 +170,7 @@ public: template std::string PGetParseModuleString(std::string module, uint32 id, Args&&... args) const { - return Acore::StringFormatFmt(GetModuleString(module, id)->c_str(), std::forward(args)...); + return Acore::StringFormat(GetModuleString(module, id)->c_str(), std::forward(args)...); } void SendErrorMessage(uint32 entry); diff --git a/src/server/game/Chat/ChatCommands/ChatCommand.cpp b/src/server/game/Chat/ChatCommands/ChatCommand.cpp index 916b83919..93bcd25f4 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommand.cpp +++ b/src/server/game/Chat/ChatCommands/ChatCommand.cpp @@ -175,7 +175,7 @@ static void LogCommandUsage(WorldSession const& session, std::string_view cmdStr zoneName = zone->area_name[locale]; } - std::string logMessage = Acore::StringFormatFmt("Command: {} [Player: {} ({}) (Account: {}) X: {} Y: {} Z: {} Map: {} ({}) Area: {} ({}) Zone: {} ({}) Selected: {} ({})]", + std::string logMessage = Acore::StringFormat("Command: {} [Player: {} ({}) (Account: {}) X: {} Y: {} Z: {} Map: {} ({}) Area: {} ({}) Zone: {} ({}) Selected: {} ({})]", cmdStr, player->GetName(), player->GetGUID().ToString(), session.GetAccountId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), @@ -443,11 +443,11 @@ namespace Acore::Impl::ChatCommands { if (prefix.empty()) { - return Acore::StringFormatFmt("{}{}{}", match, COMMAND_DELIMITER, suffix); + return Acore::StringFormat("{}{}{}", match, COMMAND_DELIMITER, suffix); } else { - return Acore::StringFormatFmt("{}{}{}{}{}", prefix, COMMAND_DELIMITER, match, COMMAND_DELIMITER, suffix); + return Acore::StringFormat("{}{}{}{}{}", prefix, COMMAND_DELIMITER, match, COMMAND_DELIMITER, suffix); } }); @@ -465,7 +465,7 @@ namespace Acore::Impl::ChatCommands path.assign(it1->first); else { - path = Acore::StringFormatFmt("{}{}{}", path, COMMAND_DELIMITER, it1->first); + path = Acore::StringFormat("{}{}{}", path, COMMAND_DELIMITER, it1->first); } cmd = &it1->second; map = &cmd->_subCommands; @@ -477,7 +477,7 @@ namespace Acore::Impl::ChatCommands { /* there is some trailing text, leave it as is */ if (cmd) { /* if we matched a command at some point, auto-complete it */ - return { Acore::StringFormatFmt("{}{}{}", path, COMMAND_DELIMITER, oldTail) }; + return { Acore::StringFormat("{}{}{}", path, COMMAND_DELIMITER, oldTail) }; } else return {}; @@ -490,7 +490,7 @@ namespace Acore::Impl::ChatCommands return std::string(match); else { - return Acore::StringFormatFmt("{}{}{}", prefix, COMMAND_DELIMITER, match); + return Acore::StringFormat("{}{}{}", prefix, COMMAND_DELIMITER, match); } }); diff --git a/src/server/game/Chat/ChatCommands/ChatCommand.h b/src/server/game/Chat/ChatCommands/ChatCommand.h index 079f40a50..ce1ead8b5 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommand.h +++ b/src/server/game/Chat/ChatCommands/ChatCommand.h @@ -91,7 +91,7 @@ namespace Acore::Impl::ChatCommands return result2; if (result1.HasErrorMessage() && result2.HasErrorMessage()) { - return Acore::StringFormatFmt("{} \"{}\"\n{} \"{}\"", + return Acore::StringFormat("{} \"{}\"\n{} \"{}\"", GetAcoreString(handler, LANG_CMDPARSER_EITHER), result2.GetErrorMessage(), GetAcoreString(handler, LANG_CMDPARSER_OR), result1.GetErrorMessage()); } diff --git a/src/server/game/Chat/ChatCommands/ChatCommandArgs.h b/src/server/game/Chat/ChatCommands/ChatCommandArgs.h index 524cc608e..af1b0b3e8 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandArgs.h +++ b/src/server/game/Chat/ChatCommands/ChatCommandArgs.h @@ -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::StringFormat("\"{}\"\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::StringFormat("\"{}\"\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::StringFormat("{} {}", GetAcoreString(handler, LANG_CMDPARSER_EITHER), result.GetErrorMessage()); return result; } }; diff --git a/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h b/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h index f5b4cf5af..e7e803a5e 100644 --- a/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h +++ b/src/server/game/Chat/ChatCommands/ChatCommandHelpers.h @@ -125,7 +125,7 @@ namespace Acore::Impl::ChatCommands template std::string FormatAcoreString(ChatHandler const* handler, AcoreStrings which, Ts&&... args) { - return Acore::StringFormatFmt(GetAcoreString(handler, which), std::forward(args)...); + return Acore::StringFormat(GetAcoreString(handler, which), std::forward(args)...); } } diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index 96f066a9e..95fbdd787 100644 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -304,7 +304,7 @@ void PlayerDump::InitializeTables() // item0 - item18 for (uint32 j = 0; j < EQUIPMENT_SLOT_END; ++j) { - std::string itColumn = Acore::StringFormat("item%u", j); + std::string itColumn = Acore::StringFormat("item{}", j); MarkDependentColumn(t, itColumn, GUID_TYPE_ITEM); } break; @@ -923,7 +923,7 @@ DumpReturn PlayerDumpReader::LoadDump(std::istream& input, uint32 account, std:: if (name.empty()) { // generate a temporary name - std::string guidPart = Acore::StringFormat("%X", guid); + std::string guidPart = Acore::StringFormat("{:X}", guid); std::size_t maxCharsFromOriginalName = MAX_PLAYER_NAME - guidPart.length(); name = GetColumn(ts, line, "name").substr(0, maxCharsFromOriginalName) + guidPart; diff --git a/src/server/game/Warden/Warden.cpp b/src/server/game/Warden/Warden.cpp index 298264e46..e32fcc1c9 100644 --- a/src/server/game/Warden/Warden.cpp +++ b/src/server/game/Warden/Warden.cpp @@ -246,14 +246,14 @@ void Warden::ApplyPenalty(uint16 checkId, std::string const& reason) if (Player const* plr = _session->GetPlayer()) { std::string const reportFormat = "Player {} (guid {}, account id: {}) failed warden {} check ({}). Action: {}"; - reportMsg = Acore::StringFormatFmt(reportFormat, plr->GetName(), plr->GetGUID().GetCounter(), _session->GetAccountId(), + reportMsg = Acore::StringFormat(reportFormat, plr->GetName(), plr->GetGUID().GetCounter(), _session->GetAccountId(), checkId, ((checkData && !checkData->Comment.empty()) ? checkData->Comment : ""), GetWardenActionStr(action)); } else { std::string const reportFormat = "Account id: {} failed warden {} check. Action: {}"; - reportMsg = Acore::StringFormatFmt(reportFormat, _session->GetAccountId(), checkId, GetWardenActionStr(action)); + reportMsg = Acore::StringFormat(reportFormat, _session->GetAccountId(), checkId, GetWardenActionStr(action)); } } else @@ -261,12 +261,12 @@ void Warden::ApplyPenalty(uint16 checkId, std::string const& reason) if (Player const* plr = _session->GetPlayer()) { std::string const reportFormat = "Player {} (guid {}, account id: {}) triggered warden penalty by reason: {}. Action: {}"; - reportMsg = Acore::StringFormatFmt(reportFormat, plr->GetName(), plr->GetGUID().GetCounter(), _session->GetAccountId(), causeMsg, GetWardenActionStr(action)); + reportMsg = Acore::StringFormat(reportFormat, plr->GetName(), plr->GetGUID().GetCounter(), _session->GetAccountId(), causeMsg, GetWardenActionStr(action)); } else { std::string const reportFormat = "Account id: {} failed warden {} check. Action: {}"; - reportMsg = Acore::StringFormatFmt(reportFormat, _session->GetAccountId(), causeMsg, GetWardenActionStr(action)); + reportMsg = Acore::StringFormat(reportFormat, _session->GetAccountId(), causeMsg, GetWardenActionStr(action)); } } diff --git a/src/server/game/Warden/WardenCheckMgr.cpp b/src/server/game/Warden/WardenCheckMgr.cpp index 301659781..0ac1c7e36 100644 --- a/src/server/game/Warden/WardenCheckMgr.cpp +++ b/src/server/game/Warden/WardenCheckMgr.cpp @@ -137,7 +137,7 @@ void WardenCheckMgr::LoadWardenChecks() continue; } - std::string str2 = Acore::StringFormat("%04u", id); + std::string str2 = Acore::StringFormat("{:04}", id); ASSERT(str2.size() == 4); std::copy(str2.begin(), str2.end(), wardenCheck.IdStr.begin()); diff --git a/src/server/game/Warden/WardenPayloadMgr.cpp b/src/server/game/Warden/WardenPayloadMgr.cpp index 4f88f1891..d6a06edc3 100644 --- a/src/server/game/Warden/WardenPayloadMgr.cpp +++ b/src/server/game/Warden/WardenPayloadMgr.cpp @@ -74,7 +74,7 @@ bool WardenPayloadMgr::RegisterPayload(std::string const& payload, uint16 payloa wCheck.Str = payload; wCheck.CheckId = payloadId; - std::string idStr = Acore::StringFormat("%04u", payloadId); + std::string idStr = Acore::StringFormat("{:04}", payloadId); ASSERT(idStr.size() == 4); std::copy(idStr.begin(), idStr.end(), wCheck.IdStr.begin()); diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 44d14e6e6..fc479a383 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -310,7 +310,7 @@ public: if (target->GetUInt32Value(PLAYER_CHOSEN_TITLE) == titleInfo->bit_index) activeStr = handler->GetAcoreString(LANG_ACTIVE); - std::string titleName = Acore::StringFormat(name, player->GetName().c_str()); + std::string titleName = Acore::StringFormat(name, player->GetName()); // send title in "id (idx:idx) - [namedlink locale]" format if (handler->GetSession()) diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 3053564e6..852c79a3a 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -733,14 +733,14 @@ public: if (item->GetOwnerGUID() != player->GetGUID()) { - handler->SendSysMessage(Acore::StringFormatFmt("queue({}): For the item {}, the owner ({}) and the player ({}) don't match!", index, item->GetGUID().ToString(), item->GetOwnerGUID().ToString(), player->GetGUID().ToString())); + handler->SendSysMessage(Acore::StringFormat("queue({}): For the item {}, the owner ({}) and the player ({}) don't match!", index, item->GetGUID().ToString(), item->GetOwnerGUID().ToString(), player->GetGUID().ToString())); error = true; continue; } if (item->GetQueuePos() != index) { - handler->SendSysMessage(Acore::StringFormatFmt("queue({}): For the item {}, the queuepos doesn't match it's position in the queue!", index, item->GetGUID().ToString())); + handler->SendSysMessage(Acore::StringFormat("queue({}): For the item {}, the queuepos doesn't match it's position in the queue!", index, item->GetGUID().ToString())); error = true; continue; } @@ -752,14 +752,14 @@ public: if (!test) { - handler->SendSysMessage(Acore::StringFormatFmt("queue({}): The bag({}) and slot({}) values for {} are incorrect, the player doesn't have any item at that position!", index, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString())); + handler->SendSysMessage(Acore::StringFormat("queue({}): The bag({}) and slot({}) values for {} are incorrect, the player doesn't have any item at that position!", index, item->GetBagSlot(), item->GetSlot(), item->GetGUID().ToString())); error = true; continue; } if (test != item) { - 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())); + handler->SendSysMessage(Acore::StringFormat("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; } diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index dd42ce23d..717e94ef7 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -87,7 +87,7 @@ public: if (message.empty()) return false; - sWorld->SendServerMessage(SERVER_MSG_STRING, Acore::StringFormatFmt(handler->GetAcoreString(LANG_SYSTEMMESSAGE), message.data())); + sWorld->SendServerMessage(SERVER_MSG_STRING, Acore::StringFormat(handler->GetAcoreString(LANG_SYSTEMMESSAGE), message.data())); return true; } diff --git a/src/server/scripts/Commands/cs_send.cpp b/src/server/scripts/Commands/cs_send.cpp index 3645370ae..d09e9e292 100644 --- a/src/server/scripts/Commands/cs_send.cpp +++ b/src/server/scripts/Commands/cs_send.cpp @@ -79,7 +79,7 @@ public: itemCount = *Acore::StringTo(itemTokens.at(1)); break; default: - handler->SendSysMessage(Acore::StringFormatFmt("> Incorrect item list format for '{}'", itemString)); + handler->SendSysMessage(Acore::StringFormat("> Incorrect item list format for '{}'", itemString)); continue; } diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index dc9ee029f..39d2fd8a9 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -121,9 +121,9 @@ public: dbPort = (*res)[0].Get(); if (dbPort) - dbPortOutput = Acore::StringFormatFmt("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort); + dbPortOutput = Acore::StringFormat("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort); else - dbPortOutput = Acore::StringFormatFmt("Realm Id: {} not found in `realmlist` table. Please check your setup", realm.Id.Realm); + dbPortOutput = Acore::StringFormat("Realm Id: {} not found in `realmlist` table. Please check your setup", realm.Id.Realm); } HandleServerInfoCommand(handler); diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 1e7eccb93..e77fa638f 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -144,7 +144,7 @@ class spell_the_flag_of_ownership : public SpellScript LocaleConstant loc_idx = caster->ToPlayer()->GetSession()->GetSessionDbLocaleIndex(); BroadcastText const* bct = sObjectMgr->GetBroadcastText(TEXT_FLAG_OF_OWNERSHIP); - std::string bctMsg = Acore::StringFormat(bct->GetText(loc_idx, caster->getGender()), caster->GetName().c_str(), target->GetName().c_str()); + std::string bctMsg = Acore::StringFormat(bct->GetText(loc_idx, caster->getGender()), caster->GetName(), target->GetName()); caster->Talk(bctMsg, CHAT_MSG_MONSTER_EMOTE, LANG_UNIVERSAL, sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_TEXTEMOTE), target); haveTarget = true; diff --git a/src/server/shared/DataStores/DBCDatabaseLoader.cpp b/src/server/shared/DataStores/DBCDatabaseLoader.cpp index 37e2884d6..1985b01bb 100644 --- a/src/server/shared/DataStores/DBCDatabaseLoader.cpp +++ b/src/server/shared/DataStores/DBCDatabaseLoader.cpp @@ -36,7 +36,7 @@ DBCDatabaseLoader::DBCDatabaseLoader(char const* tableName, char const* dbcForma char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable) { - std::string query = Acore::StringFormat("SELECT * FROM `%s` ORDER BY `ID` DESC", _sqlTableName); + std::string query = Acore::StringFormat("SELECT * FROM `{}` ORDER BY `ID` DESC", _sqlTableName); // no error if empty set QueryResult result = WorldDatabase.Query(query); diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp index dab792c77..b17b85dce 100644 --- a/src/server/shared/Packets/ByteBuffer.cpp +++ b/src/server/shared/Packets/ByteBuffer.cpp @@ -51,7 +51,7 @@ ByteBufferSourceException::ByteBufferSourceException(std::size_t pos, std::size_ ByteBufferInvalidValueException::ByteBufferInvalidValueException(char const* type, char const* value) { - message().assign(Acore::StringFormat("Invalid %s value (%s) found in ByteBuffer", type, value)); + message().assign(Acore::StringFormat("Invalid {} value ({}) found in ByteBuffer", type, value)); } ByteBuffer& ByteBuffer::operator>>(float& value) diff --git a/src/server/shared/Secrets/SecretMgr.cpp b/src/server/shared/Secrets/SecretMgr.cpp index cfc42e4ca..5f4d345b5 100644 --- a/src/server/shared/Secrets/SecretMgr.cpp +++ b/src/server/shared/Secrets/SecretMgr.cpp @@ -188,11 +188,11 @@ Optional SecretMgr::AttemptTransition(Secrets i, Optional(totpSecret, oldSecret->ToByteArray()); if (!success) - return Acore::StringFormat("Cannot decrypt old TOTP tokens - value of '%s' is incorrect for some users!", secret_info[i].oldKey); + return Acore::StringFormat("Cannot decrypt old TOTP tokens - value of '{}' is incorrect for some users!", secret_info[i].oldKey); } if (newSecret) diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index 1d2d47a37..6f9806e34 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -990,7 +990,7 @@ void ExtractMapsFromMpq(uint32 build) { printf("Extract %s (%d/%u) \n", map_ids[z].name, z + 1, map_count); // Loadup map grid data - mpqMapName = Acore::StringFormat(R"(World\Maps\%s\%s.wdt)", map_ids[z].name, map_ids[z].name); + mpqMapName = Acore::StringFormat(R"(World\Maps\{}\{}.wdt)", map_ids[z].name, map_ids[z].name); WDT_file wdt; if (!wdt.loadFile(mpqMapName, false)) { @@ -1004,8 +1004,8 @@ void ExtractMapsFromMpq(uint32 build) { if (!wdt.main->adt_list[y][x].exist) continue; - mpqFileName = Acore::StringFormat(R"(World\Maps\%s\%s_%u_%u.adt)", map_ids[z].name, map_ids[z].name, x, y); - outputFileName = Acore::StringFormat("%s/maps/%03u%02u%02u.map", output_path, map_ids[z].id, y, x); + mpqFileName = Acore::StringFormat(R"(World\Maps\{}\{}_{}_{}.adt)", map_ids[z].name, map_ids[z].name, x, y); + outputFileName = Acore::StringFormat("{}/maps/{:03}{:02}{:02}.map", output_path, map_ids[z].id, y, x); ConvertADT(mpqFileName, outputFileName, y, x, build); } // draw progress bar