diff --git a/Source/DiabloUI/diabloui.cpp b/Source/DiabloUI/diabloui.cpp index 27d8bca8a..2681e2550 100644 --- a/Source/DiabloUI/diabloui.cpp +++ b/Source/DiabloUI/diabloui.cpp @@ -3,8 +3,6 @@ #include #include -#include - #include "DiabloUI/art_draw.h" #include "DiabloUI/button.h" #include "DiabloUI/dialogs.h" @@ -28,6 +26,7 @@ #include "utils/sdl_compat.h" #include "utils/sdl_geometry.h" #include "utils/sdl_wrap.h" +#include "utils/str_cat.hpp" #include "utils/stubs.h" #include "utils/utf8.hpp" @@ -547,7 +546,7 @@ void LoadHeros() for (size_t i = 0; i <= enum_size::value; ++i) { char portraitPath[18]; - *fmt::format_to(portraitPath, FMT_COMPILE("ui_art\\hero{}.pcx"), i) = '\0'; + *BufCopy(portraitPath, "ui_art\\hero", i, ".pcx") = '\0'; SDL_RWops *handle = OpenAsset(portraitPath); if (handle == nullptr) { diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 95c145cf2..088090bee 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -79,6 +79,7 @@ #include "utils/language.h" #include "utils/paths.h" #include "utils/stdcompat/string_view.hpp" +#include "utils/str_cat.hpp" #include "utils/utf8.hpp" #ifdef __vita__ @@ -967,8 +968,8 @@ void DiabloInitScreen() void SetApplicationVersions() { - *fmt::format_to_n(gszProductName, sizeof(gszProductName) - 1, "{} v{}", PROJECT_NAME, PROJECT_VERSION).out = '\0'; - CopyUtf8(gszVersionNumber, fmt::format(fmt::runtime(_("version {:s}")), PROJECT_VERSION), sizeof(gszVersionNumber)); + *BufCopy(gszProductName, PROJECT_NAME, " v", PROJECT_VERSION) = '\0'; + *BufCopy(gszVersionNumber, "version ", PROJECT_VERSION) = '\0'; } void DiabloInit() diff --git a/Source/discord/discord.cpp b/Source/discord/discord.cpp index cffb3b85a..da146e9aa 100644 --- a/Source/discord/discord.cpp +++ b/Source/discord/discord.cpp @@ -110,13 +110,14 @@ std::string GetTooltipString() std::string GetPlayerAssetString() { - char heroChar = CharChar[static_cast(MyPlayer->_pClass)]; - char armourChar = ArmourChar[tracked_data.playerGfx >> 4]; - char wpnChar = WepChar[tracked_data.playerGfx & 0xF]; - - std::string result = fmt::format("{}{}{}as", heroChar, armourChar, wpnChar); - std::transform(std::begin(result), std::end(result), std::begin(result), [](char c) { return static_cast(std::tolower(c)); }); - return result; + char chars[5] { + CharChar[static_cast(MyPlayer->_pClass)] - ('a' - 'A'), + ArmourChar[tracked_data.playerGfx >> 4] - ('a' - 'A'), + WepChar[tracked_data.playerGfx & 0xF] - ('a' - 'A'), + 'a', + 's' + }; + return std::string(chars, 5); } void ResetStartTime() diff --git a/Source/engine/demomode.cpp b/Source/engine/demomode.cpp index 1a769da8d..b5f0abb82 100644 --- a/Source/engine/demomode.cpp +++ b/Source/engine/demomode.cpp @@ -12,6 +12,7 @@ #include "pfile.h" #include "utils/display.h" #include "utils/paths.h" +#include "utils/str_cat.hpp" namespace devilution { @@ -75,9 +76,7 @@ void WriteToDemo(T value) bool LoadDemoMessages(int i) { std::ifstream demofile; - char demoFilename[16]; - *fmt::format_to_n(demoFilename, 15, "demo_{}.dmo", i).out = '\0'; - demofile.open(paths::PrefPath() + demoFilename, std::fstream::binary); + demofile.open(StrCat(paths::PrefPath(), "demo_", i, ".dmo"), std::fstream::binary); if (!demofile.is_open()) { return false; } @@ -269,9 +268,7 @@ void RecordMessage(tagMSG *lpMsg) void NotifyGameLoopStart() { if (IsRecording()) { - char demoFilename[16]; - *fmt::format_to_n(demoFilename, 15, "demo_{}.dmo", RecordNumber).out = '\0'; - DemoRecording.open(paths::PrefPath() + demoFilename, std::fstream::trunc | std::fstream::binary); + DemoRecording.open(StrCat(paths::PrefPath(), "demo_", RecordNumber, ".dmo"), std::fstream::trunc | std::fstream::binary); constexpr uint8_t version = 0; WriteToDemo(version); WriteToDemo(gSaveNumber); diff --git a/Source/mpq/mpq_writer.cpp b/Source/mpq/mpq_writer.cpp index d4feb19e6..1d5262371 100644 --- a/Source/mpq/mpq_writer.cpp +++ b/Source/mpq/mpq_writer.cpp @@ -6,8 +6,6 @@ #include #include -#include - #include "appfat.h" #include "encrypt.h" #include "engine.h" @@ -160,7 +158,7 @@ MpqWriter::MpqWriter(const char *path) } return; on_error: - app_fatal(fmt::format("{}\n{}\n{}", _("Failed to open archive for writing."), path, error)); + app_fatal(StrCat(_("Failed to open archive for writing."), "\n", path, "\n", error)); } MpqWriter::~MpqWriter()