diff --git a/Source/DiabloUI/selconn.cpp b/Source/DiabloUI/selconn.cpp index 51d02986b..8a09052c0 100644 --- a/Source/DiabloUI/selconn.cpp +++ b/Source/DiabloUI/selconn.cpp @@ -1,3 +1,5 @@ +#include + #include "DiabloUI/diabloui.h" #include "DiabloUI/text.h" #include "stores.h" @@ -116,7 +118,7 @@ void SelconnFocus(int value) break; } - snprintf(selconn_MaxPlayers, sizeof(selconn_MaxPlayers), _("Players Supported: %i"), players); + snprintf(selconn_MaxPlayers, sizeof(selconn_MaxPlayers), fmt::format(_("Players Supported: %i"), players).c_str()); WordWrapArtStr(selconn_Description, DESCRIPTION_WIDTH); } diff --git a/Source/DiabloUI/selgame.cpp b/Source/DiabloUI/selgame.cpp index ce7a40cd5..85ad97238 100644 --- a/Source/DiabloUI/selgame.cpp +++ b/Source/DiabloUI/selgame.cpp @@ -1,5 +1,7 @@ #include "selgame.h" +#include + #include "DiabloUI/diabloui.h" #include "DiabloUI/dialogs.h" #include "DiabloUI/selhero.h" @@ -412,7 +414,7 @@ static bool IsGameCompatible(GameData *data) UiSelOkDialog(title, _("The host is running a different game than you."), false); } else { char msg[64]; - sprintf(msg, _( /* TRANSLATORS: Error message when somebody tries to join a game running another version. */ "Your version %s does not match the host %i.%i.%i."), PROJECT_VERSION, PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH); + sprintf(msg, fmt::format(_(/* TRANSLATORS: Error message when somebody tries to join a game running another version. */ "Your version %s does not match the host %i.%i.%i."), PROJECT_VERSION, PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH).c_str()); UiSelOkDialog(title, msg, false); } diff --git a/Source/DiabloUI/selhero.cpp b/Source/DiabloUI/selhero.cpp index 1c76b4359..eaa080631 100644 --- a/Source/DiabloUI/selhero.cpp +++ b/Source/DiabloUI/selhero.cpp @@ -4,6 +4,8 @@ #include #include +#include + #include "DiabloUI/diabloui.h" #include "DiabloUI/dialogs.h" #include "DiabloUI/scrollbar.h" @@ -342,7 +344,7 @@ void SelheroNameSelect(int value) if (strcasecmp(selhero_heros[i].name, selhero_heroInfo.name) == 0) { ArtBackground.Unload(); char dialogText[256]; - snprintf(dialogText, sizeof(dialogText), _( /* Error message when User tries to create multiple heros with the same name */ "Character already exists. Do you want to overwrite \"%s\"?"), selhero_heroInfo.name); + snprintf(dialogText, sizeof(dialogText), fmt::format(_(/* Error message when User tries to create multiple heros with the same name */ "Character already exists. Do you want to overwrite \"%s\"?"), selhero_heroInfo.name).c_str()); overwrite = UiSelHeroYesNoDialog(title, dialogText); LoadBackgroundArt("ui_art\\selhero.pcx"); @@ -355,7 +357,7 @@ void SelheroNameSelect(int value) SelheroLoadSelect(1); return; } - UiErrorOkDialog(_( /* TRANSLATORS: Error Message */ "Unable to create character."), vecSelDlgItems); + UiErrorOkDialog(_(/* TRANSLATORS: Error Message */ "Unable to create character."), vecSelDlgItems); } } @@ -619,7 +621,7 @@ static void UiSelHeroDialog( } else { strncpy(dialogTitle, _("Delete Single Player Hero"), sizeof(dialogTitle) - 1); } - snprintf(dialogText, sizeof(dialogText), _("Are you sure you want to delete the character \"%s\"?"), selhero_heroInfo.name); + snprintf(dialogText, sizeof(dialogText), fmt::format(_("Are you sure you want to delete the character \"%s\"?"), selhero_heroInfo.name).c_str()); if (UiSelHeroYesNoDialog(dialogTitle, dialogText)) fnremove(&selhero_heroInfo); diff --git a/Source/appfat.cpp b/Source/appfat.cpp index f65113d0a..1c1a6e71e 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -6,6 +6,8 @@ #include +#include + #include "diablo.h" #include "storm/storm.h" #include "utils/ui_fwd.h" @@ -114,7 +116,7 @@ void ErrDlg(const char *title, const char *error, const char *logFilePath, int l FreeDlg(); - snprintf(text, sizeof(text), _( /* TRANSLATORS: Error message that displays relevant information for bug report */ "%s\n\nThe error occurred at: %s line %i"), error, logFilePath, logLineNr); + snprintf(text, sizeof(text), fmt::format(_(/* TRANSLATORS: Error message that displays relevant information for bug report */ "%s\n\nThe error occurred at: %s line %i"), error, logFilePath, logLineNr).c_str()); UiErrorOkDialog(title, text); app_fatal(nullptr); @@ -134,13 +136,13 @@ void FileErrDlg(const char *error) snprintf( text, sizeof(text), - _( /* TRANSLATORS: Error Message when diabdat.mpq is broken. Keep values unchanged. */ "Unable to open a required file.\n" - "\n" - "Verify that the MD5 of diabdat.mpq matches one of the following values\n" - "011bc6518e6166206231080a4440b373\n" - "68f049866b44688a7af65ba766bef75a\n" - "\n" - "The problem occurred when loading:\n%s"), + _(/* TRANSLATORS: Error Message when diabdat.mpq is broken. Keep values unchanged. */ "Unable to open a required file.\n" + "\n" + "Verify that the MD5 of diabdat.mpq matches one of the following values\n" + "011bc6518e6166206231080a4440b373\n" + "68f049866b44688a7af65ba766bef75a\n" + "\n" + "The problem occurred when loading:\n%s"), error); UiErrorOkDialog(_("Data File Error"), text); @@ -173,7 +175,7 @@ void DirErrorDlg(const char *error) { char text[1024]; - snprintf(text, sizeof(text), _( /* TRANSLATORS: Error when Program is not allowed to write data */"Unable to write to location:\n%s"), error); + snprintf(text, sizeof(text), fmt::format(_(/* TRANSLATORS: Error when Program is not allowed to write data */ "Unable to write to location:\n%s"), error).c_str()); UiErrorOkDialog(_("Read-Only Directory Error"), text); app_fatal(nullptr); diff --git a/Source/automap.cpp b/Source/automap.cpp index ab746fcfe..23693ccee 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -7,6 +7,8 @@ #include +#include + #include "control.h" #include "engine/render/automap_render.hpp" #include "inv.h" @@ -402,11 +404,11 @@ void DrawAutomapText(const CelOutputBuffer &out) if (currlevel != 0) { if (currlevel >= 17 && currlevel <= 20) { - sprintf(desc, _("Level: Nest %i"), currlevel - 16); + sprintf(desc, fmt::format(_("Level: Nest %i"), currlevel - 16).c_str()); } else if (currlevel >= 21 && currlevel <= 24) { - sprintf(desc, _("Level: Crypt %i"), currlevel - 20); + sprintf(desc, fmt::format(_("Level: Crypt %i"), currlevel - 20).c_str()); } else { - sprintf(desc, _("Level: %i"), currlevel); + sprintf(desc, fmt::format(_("Level: %i"), currlevel).c_str()); } DrawString(out, desc, { 8, nextLine, 0, 0 }); diff --git a/Source/control.cpp b/Source/control.cpp index ff4e5ed65..d613d9e9d 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include "DiabloUI/diabloui.h" #include "automap.h" #include "controls/keymapper.hpp" @@ -391,10 +393,10 @@ void DrawSpellList(const CelOutputBuffer &out) DrawSpellCel(out, x, y, *pSpellCels, c); switch (pSplType) { case RSPLTYPE_SKILL: - sprintf(infostr, _("%s Skill"), _(spelldata[pSpell].sSkillText)); + sprintf(infostr, fmt::format(_("%s Skill"), _(spelldata[pSpell].sSkillText)).c_str()); break; case RSPLTYPE_SPELL: - sprintf(infostr, _("%s Spell"), _(spelldata[pSpell].sNameText)); + sprintf(infostr, fmt::format(_("%s Spell"), _(spelldata[pSpell].sNameText)).c_str()); if (pSpell == SPL_HBOLT) { strcpy(tempstr, _("Damages undead only")); AddPanelString(tempstr); @@ -402,11 +404,11 @@ void DrawSpellList(const CelOutputBuffer &out) if (s == 0) strcpy(tempstr, _("Spell Level 0 - Unusable")); else - sprintf(tempstr, _("Spell Level %i"), s); + sprintf(tempstr, fmt::format(_("Spell Level %i"), s).c_str()); AddPanelString(tempstr); break; case RSPLTYPE_SCROLL: { - sprintf(infostr, _("Scroll of %s"), _(spelldata[pSpell].sNameText)); + sprintf(infostr, fmt::format(_("Scroll of %s"), _(spelldata[pSpell].sNameText)).c_str()); int v = 0; for (int t = 0; t < plr[myplr]._pNumInv; t++) { if (!plr[myplr].InvList[t].isEmpty() @@ -426,7 +428,7 @@ void DrawSpellList(const CelOutputBuffer &out) AddPanelString(tempstr); } break; case RSPLTYPE_CHARGES: { - sprintf(infostr, _("Staff of %s"), _(spelldata[pSpell].sNameText)); + sprintf(infostr, fmt::format(_("Staff of %s"), _(spelldata[pSpell].sNameText)).c_str()); int charges = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges; sprintf(tempstr, ngettext("%i Charge", "%i Charges", charges), charges); AddPanelString(tempstr); @@ -438,7 +440,7 @@ void DrawSpellList(const CelOutputBuffer &out) if (plr[myplr]._pSplHotKey[t] == pSpell && plr[myplr]._pSplTHotKey[t] == pSplType) { auto hotkeyName = keymapper.keyNameForAction(quickSpellActionIndexes[t]); PrintSBookHotkey(out, x, y, hotkeyName); - sprintf(tempstr, _("Spell Hotkey %s"), hotkeyName.c_str()); + sprintf(tempstr, fmt::format(_("Spell Hotkey %s"), hotkeyName.c_str()).c_str()); AddPanelString(tempstr); } } @@ -915,7 +917,7 @@ void CheckPanelInfo() strcpy(infostr, _("Player attack")); } if (PanBtnHotKey[i] != nullptr) { - sprintf(tempstr, _("Hotkey: %s"), _(PanBtnHotKey[i])); + sprintf(tempstr, fmt::format(_("Hotkey: %s"), _(PanBtnHotKey[i])).c_str()); AddPanelString(tempstr); } infoclr = UIS_SILVER; @@ -934,11 +936,11 @@ void CheckPanelInfo() if (v != SPL_INVALID) { switch (plr[myplr]._pRSplType) { case RSPLTYPE_SKILL: - sprintf(tempstr, _("%s Skill"), _(spelldata[v].sSkillText)); + sprintf(tempstr, fmt::format(_("%s Skill"), _(spelldata[v].sSkillText)).c_str()); AddPanelString(tempstr); break; case RSPLTYPE_SPELL: { - sprintf(tempstr, _("%s Spell"), _(spelldata[v].sNameText)); + sprintf(tempstr, fmt::format(_("%s Spell"), _(spelldata[v].sNameText)).c_str()); AddPanelString(tempstr); int c = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v]; if (c < 0) @@ -946,11 +948,11 @@ void CheckPanelInfo() if (c == 0) strcpy(tempstr, _("Spell Level 0 - Unusable")); else - sprintf(tempstr, _("Spell Level %i"), c); + sprintf(tempstr, fmt::format(_("Spell Level %i"), c).c_str()); AddPanelString(tempstr); } break; case RSPLTYPE_SCROLL: { - sprintf(tempstr, _("Scroll of %s"), _(spelldata[v].sNameText)); + sprintf(tempstr, fmt::format(_("Scroll of %s"), _(spelldata[v].sNameText)).c_str()); AddPanelString(tempstr); int s = 0; for (int i = 0; i < plr[myplr]._pNumInv; i++) { @@ -971,7 +973,7 @@ void CheckPanelInfo() AddPanelString(tempstr); } break; case RSPLTYPE_CHARGES: - sprintf(tempstr, _("Staff of %s"), _(spelldata[v].sNameText)); + sprintf(tempstr, fmt::format(_("Staff of %s"), _(spelldata[v].sNameText)).c_str()); AddPanelString(tempstr); sprintf(tempstr, ngettext("%i Charge", "%i Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges), plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges); AddPanelString(tempstr); @@ -1160,9 +1162,9 @@ void DrawInfoBox(const CelOutputBuffer &out) infoclr = UIS_GOLD; strcpy(infostr, plr[pcursplr]._pName); ClearPanel(); - sprintf(tempstr, _("%s, Level: %i"), _(ClassStrTbl[static_cast(plr[pcursplr]._pClass)]), plr[pcursplr]._pLevel); + sprintf(tempstr, fmt::format(_("%s, Level: %i"), _(ClassStrTbl[static_cast(plr[pcursplr]._pClass)]), plr[pcursplr]._pLevel).c_str()); AddPanelString(tempstr); - sprintf(tempstr, _("Hit Points %i of %i"), plr[pcursplr]._pHitPoints >> 6, plr[pcursplr]._pMaxHP >> 6); + sprintf(tempstr, fmt::format(_("Hit Points %i of %i"), plr[pcursplr]._pHitPoints >> 6, plr[pcursplr]._pMaxHP >> 6).c_str()); AddPanelString(tempstr); } } @@ -1625,12 +1627,12 @@ void DrawSpellBook(const CelOutputBuffer &out) int max; GetDamageAmt(sn, &min, &max); if (min != -1) { - sprintf(tempstr, _(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: %i Dam: %i - %i"), mana, min, max); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: %i Dam: %i - %i"), mana, min, max).c_str()); } else { - sprintf(tempstr, _(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: %i Dam: n/a"), mana); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: %i Dam: n/a"), mana).c_str()); } if (sn == SPL_BONESPIRIT) { - sprintf(tempstr, _(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: %i Dam: 1/3 tgt hp"), mana); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: %i Dam: 1/3 tgt hp"), mana).c_str()); } PrintSBookStr(out, 10, yp - 1, tempstr); int lvl = plr[myplr]._pSplLvl[sn] + plr[myplr]._pISplLvlAdd; @@ -1640,7 +1642,7 @@ void DrawSpellBook(const CelOutputBuffer &out) if (lvl == 0) { strcpy(tempstr, _("Spell Level 0 - Unusable")); } else { - sprintf(tempstr, _("Spell Level %i"), lvl); + sprintf(tempstr, fmt::format(_("Spell Level %i"), lvl).c_str()); } } break; } diff --git a/Source/cursor.cpp b/Source/cursor.cpp index ea626b2ea..7225512f6 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -5,6 +5,8 @@ */ #include "cursor.h" +#include + #include "control.h" #include "doom.h" #include "engine.h" @@ -203,7 +205,7 @@ void CheckTown() trigflag = true; ClearPanel(); strcpy(infostr, _("Town Portal")); - sprintf(tempstr, _("from %s"), plr[missile[mx]._misource]._pName); + sprintf(tempstr, fmt::format(_("from %s"), plr[missile[mx]._misource]._pName).c_str()); AddPanelString(tempstr); cursmx = missile[mx].position.tile.x; cursmy = missile[mx].position.tile.y; diff --git a/Source/diablo.cpp b/Source/diablo.cpp index fa8d23c1d..256ec8b0c 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -5,6 +5,8 @@ */ #include +#include + #include #include "automap.h" @@ -177,22 +179,22 @@ void initKeymapActions(); [[noreturn]] static void print_help_and_exit() { - printInConsole("%s", _( /* TRANSLATORS: Commandline Option */ "Options:\n")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-h, --help", _("Print this message and exit")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--version", _("Print the version and exit")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--data-dir", _("Specify the folder of diabdat.mpq")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--save-dir", _("Specify the folder of save files")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--config-dir", _("Specify the location of diablo.ini")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--ttf-dir", _("Specify the location of the .ttf font")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--ttf-name", _("Specify the name of a custom .ttf font")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-n", _("Skip startup videos")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-f", _("Display frames per second")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-x", _("Run in windowed mode")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--verbose", _("Enable verbose logging")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--spawn", _("Force spawn mode even if diabdat.mpq is found")); - printInConsole("%s", _( /* TRANSLATORS: Commandline Option */ "\nHellfire options:\n")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--diablo", _("Force diablo mode even if hellfire.mpq is found")); - printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--nestart", _("Use alternate nest palette")); + printInConsole("%s", _(/* TRANSLATORS: Commandline Option */ "Options:\n")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-h, --help", _("Print this message and exit")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--version", _("Print the version and exit")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--data-dir", _("Specify the folder of diabdat.mpq")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--save-dir", _("Specify the folder of save files")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--config-dir", _("Specify the location of diablo.ini")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--ttf-dir", _("Specify the location of the .ttf font")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--ttf-name", _("Specify the name of a custom .ttf font")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-n", _("Skip startup videos")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-f", _("Display frames per second")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "-x", _("Run in windowed mode")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--verbose", _("Enable verbose logging")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--spawn", _("Force spawn mode even if diabdat.mpq is found")); + printInConsole("%s", _(/* TRANSLATORS: Commandline Option */ "\nHellfire options:\n")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--diablo", _("Force diablo mode even if hellfire.mpq is found")); + printInConsole(" %-20s %-30s\n", /* TRANSLATORS: Commandline Option */ "--nestart", _("Use alternate nest palette")); #ifdef _DEBUG printInConsole("\nDebug options:\n"); printInConsole(" %-20s %-30s\n", "-w", "Enable cheats"); @@ -281,7 +283,7 @@ static void diablo_parse_flags(int argc, char **argv) debug_mode_key_w = true; #endif } else { - printInConsole(_("unrecognized option '%s'\n"), argv[i]); + printInConsole(fmt::format(_("unrecognized option '%s'\n"), argv[i]).c_str()); print_help_and_exit(); } } @@ -421,8 +423,8 @@ static void run_game_loop(interface_mode uMsg) gbGameLoopStartup = false; DrawAndBlit(); #ifdef GPERF_HEAP_FIRST_GAME_ITERATION - if (run_game_iteration++ == 0) - HeapProfilerDump("first_game_iteration"); + if (run_game_iteration++ == 0) + HeapProfilerDump("first_game_iteration"); #endif } @@ -669,7 +671,7 @@ char gszProductName[64] = "DevilutionX vUnknown"; static void SetApplicationVersions() { snprintf(gszProductName, sizeof(gszProductName) / sizeof(char), "%s v%s", PROJECT_NAME, PROJECT_VERSION); - snprintf(gszVersionNumber, sizeof(gszVersionNumber) / sizeof(char), _("version %s"), PROJECT_VERSION); + snprintf(gszVersionNumber, sizeof(gszVersionNumber) / sizeof(char), fmt::format(_("version %s"), PROJECT_VERSION).c_str()); } static void diablo_init() @@ -2201,7 +2203,7 @@ void initKeymapActions() _("Nightmare"), _("Hell"), }; - sprintf(pszStr, _( /* TRANSLATORS: %s means: Character Name, Game Version, Game Difficulty. */ "%s, version = %s, mode = %s"), gszProductName, PROJECT_VERSION, difficulties[sgGameInitInfo.nDifficulty]); + sprintf(pszStr, fmt::format(_(/* TRANSLATORS: %s means: Character Name, Game Version, Game Difficulty. */ "%s, version = %s, mode = %s"), gszProductName, PROJECT_VERSION, difficulties[sgGameInitInfo.nDifficulty]).c_str()); NetSendCmdString(1 << myplr, pszStr); }, }); diff --git a/Source/items.cpp b/Source/items.cpp index 0bf50103b..5c04028bd 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -8,6 +8,8 @@ #include #include +#include + #include "cursor.h" #include "doom.h" #include "dx.h" @@ -1524,7 +1526,7 @@ void GetStaffPower(int i, int lvl, int bs, bool onlygood) sprintf(istr, "%s %s", _(PL_Prefix[preidx].PLName), items[i]._iIName); strcpy(items[i]._iIName, istr); } - sprintf(istr, _( /* TRANSLATORS: Constructs item names. Format: of . Example: King's Long Sword of the Whale */ "%s of %s"), items[i]._iIName, _(spelldata[bs].sNameText)); + sprintf(istr, fmt::format(_(/* TRANSLATORS: Constructs item names. Format: of . Example: King's Long Sword of the Whale */ "%s of %s"), items[i]._iIName, _(spelldata[bs].sNameText)).c_str()); strcpy(items[i]._iIName, istr); if (items[i]._iMagical == ITEM_QUALITY_NORMAL) strcpy(items[i]._iName, items[i]._iIName); @@ -1566,8 +1568,8 @@ void GetStaffSpell(int i, int lvl, bool onlygood) s = SPL_FIREBOLT; } if (!control_WriteStringToBuffer(istr)) - sprintf(istr, _("%s of %s"), items[i]._iName, _(spelldata[bs].sNameText)); - sprintf(istr, _("Staff of %s"), _(spelldata[bs].sNameText)); + sprintf(istr, fmt::format(_("%s of %s"), items[i]._iName, _(spelldata[bs].sNameText)).c_str()); + sprintf(istr, fmt::format(_("Staff of %s"), _(spelldata[bs].sNameText)).c_str()); strcpy(items[i]._iName, istr); strcpy(items[i]._iIName, istr); @@ -2161,7 +2163,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, affix_item_type flgs, bool only } if (nl != 0) { sufidx = l[GenerateRnd(nl)]; - sprintf(istr, _("%s of %s"), items[i]._iIName, _(PL_Suffix[sufidx].PLName)); + sprintf(istr, fmt::format(_("%s of %s"), items[i]._iIName, _(PL_Suffix[sufidx].PLName)).c_str()); strcpy(items[i]._iIName, istr); items[i]._iMagical = ITEM_QUALITY_MAGIC; SaveItemSuffix(i, sufidx); @@ -2180,7 +2182,7 @@ void GetItemPower(int i, int minlvl, int maxlvl, affix_item_type flgs, bool only strcpy(items[i]._iIName, istr); } if (sufidx != -1) { - sprintf(istr, _("%s of %s"), items[i]._iIName, _(PL_Suffix[sufidx].PLName)); + sprintf(istr, fmt::format(_("%s of %s"), items[i]._iIName, _(PL_Suffix[sufidx].PLName)).c_str()); strcpy(items[i]._iIName, istr); } } @@ -2744,7 +2746,7 @@ void RecreateEar(int ii, uint16_t ic, int iseed, int Id, int dur, int mdur, int tempstr[14] = (ibuff >> 8) & 0x7F; tempstr[15] = ibuff & 0x7F; tempstr[16] = '\0'; - sprintf(items[ii]._iName, _( /* TRANSLATORS: %s will be a Character Name */ "Ear of %s"), tempstr); + sprintf(items[ii]._iName, fmt::format(_(/* TRANSLATORS: %s will be a Character Name */ "Ear of %s"), tempstr).c_str()); items[ii]._iCurs = ((ivalue >> 6) & 3) + ICURS_EAR_SORCERER; items[ii]._ivalue = ivalue & 0x3F; items[ii]._iCreateInfo = ic; @@ -3412,51 +3414,51 @@ void PrintItemPower(char plidx, ItemStruct *x) switch (plidx) { case IPL_TOHIT: case IPL_TOHIT_CURSE: - sprintf(tempstr, _("chance to hit: %+i%%"), x->_iPLToHit); + sprintf(tempstr, fmt::format(_("chance to hit: %+i%%"), x->_iPLToHit).c_str()); break; case IPL_DAMP: case IPL_DAMP_CURSE: - sprintf(tempstr, _("%+i%% damage"), x->_iPLDam); + sprintf(tempstr, fmt::format(_("%+i%% damage"), x->_iPLDam).c_str()); break; case IPL_TOHIT_DAMP: case IPL_TOHIT_DAMP_CURSE: - sprintf(tempstr, _("to hit: %+i%%, %+i%% damage"), x->_iPLToHit, x->_iPLDam); + sprintf(tempstr, fmt::format(_("to hit: %+i%%, %+i%% damage"), x->_iPLToHit, x->_iPLDam).c_str()); break; case IPL_ACP: case IPL_ACP_CURSE: - sprintf(tempstr, _("%+i%% armor"), x->_iPLAC); + sprintf(tempstr, fmt::format(_("%+i%% armor"), x->_iPLAC).c_str()); break; case IPL_SETAC: - sprintf(tempstr, _("armor class: %i"), x->_iAC); + sprintf(tempstr, fmt::format(_("armor class: %i"), x->_iAC).c_str()); break; case IPL_AC_CURSE: - sprintf(tempstr, _("armor class: %i"), x->_iAC); + sprintf(tempstr, fmt::format(_("armor class: %i"), x->_iAC).c_str()); break; case IPL_FIRERES: case IPL_FIRERES_CURSE: if (x->_iPLFR < 75) - sprintf(tempstr, _("Resist Fire: %+i%%"), x->_iPLFR); + sprintf(tempstr, fmt::format(_("Resist Fire: %+i%%"), x->_iPLFR).c_str()); else /*xgettext:no-c-format*/ strcpy(tempstr, _("Resist Fire: 75% MAX")); break; case IPL_LIGHTRES: case IPL_LIGHTRES_CURSE: if (x->_iPLLR < 75) - sprintf(tempstr, _("Resist Lightning: %+i%%"), x->_iPLLR); + sprintf(tempstr, fmt::format(_("Resist Lightning: %+i%%"), x->_iPLLR).c_str()); else /*xgettext:no-c-format*/ strcpy(tempstr, _("Resist Lightning: 75% MAX")); break; case IPL_MAGICRES: case IPL_MAGICRES_CURSE: if (x->_iPLMR < 75) - sprintf(tempstr, _("Resist Magic: %+i%%"), x->_iPLMR); + sprintf(tempstr, fmt::format(_("Resist Magic: %+i%%"), x->_iPLMR).c_str()); else /*xgettext:no-c-format*/ strcpy(tempstr, _("Resist Magic: 75% MAX")); break; case IPL_ALLRES: case IPL_ALLRES_CURSE: if (x->_iPLFR < 75) - sprintf(tempstr, _("Resist All: %+i%%"), x->_iPLFR); + sprintf(tempstr, fmt::format(_("Resist All: %+i%%"), x->_iPLFR).c_str()); if (x->_iPLFR >= 75) /*xgettext:no-c-format*/ strcpy(tempstr, _("Resist All: 75% MAX")); break; @@ -3476,47 +3478,47 @@ void PrintItemPower(char plidx, ItemStruct *x) break; case IPL_FIREDAM: if (x->_iFMinDam == x->_iFMaxDam) - sprintf(tempstr, _("Fire hit damage: %i"), x->_iFMinDam); + sprintf(tempstr, fmt::format(_("Fire hit damage: %i"), x->_iFMinDam).c_str()); else - sprintf(tempstr, _("Fire hit damage: %i-%i"), x->_iFMinDam, x->_iFMaxDam); + sprintf(tempstr, fmt::format(_("Fire hit damage: %i-%i"), x->_iFMinDam, x->_iFMaxDam).c_str()); break; case IPL_LIGHTDAM: if (x->_iLMinDam == x->_iLMaxDam) - sprintf(tempstr, _("Lightning hit damage: %i"), x->_iLMinDam); + sprintf(tempstr, fmt::format(_("Lightning hit damage: %i"), x->_iLMinDam).c_str()); else - sprintf(tempstr, _("Lightning hit damage: %i-%i"), x->_iLMinDam, x->_iLMaxDam); + sprintf(tempstr, fmt::format(_("Lightning hit damage: %i-%i"), x->_iLMinDam, x->_iLMaxDam).c_str()); break; case IPL_STR: case IPL_STR_CURSE: - sprintf(tempstr, _("%+i to strength"), x->_iPLStr); + sprintf(tempstr, fmt::format(_("%+i to strength"), x->_iPLStr).c_str()); break; case IPL_MAG: case IPL_MAG_CURSE: - sprintf(tempstr, _("%+i to magic"), x->_iPLMag); + sprintf(tempstr, fmt::format(_("%+i to magic"), x->_iPLMag).c_str()); break; case IPL_DEX: case IPL_DEX_CURSE: - sprintf(tempstr, _("%+i to dexterity"), x->_iPLDex); + sprintf(tempstr, fmt::format(_("%+i to dexterity"), x->_iPLDex).c_str()); break; case IPL_VIT: case IPL_VIT_CURSE: - sprintf(tempstr, _("%+i to vitality"), x->_iPLVit); + sprintf(tempstr, fmt::format(_("%+i to vitality"), x->_iPLVit).c_str()); break; case IPL_ATTRIBS: case IPL_ATTRIBS_CURSE: - sprintf(tempstr, _("%+i to all attributes"), x->_iPLStr); + sprintf(tempstr, fmt::format(_("%+i to all attributes"), x->_iPLStr).c_str()); break; case IPL_GETHIT_CURSE: case IPL_GETHIT: - sprintf(tempstr, _("%+i damage from enemies"), x->_iPLGetHit); + sprintf(tempstr, fmt::format(_("%+i damage from enemies"), x->_iPLGetHit).c_str()); break; case IPL_LIFE: case IPL_LIFE_CURSE: - sprintf(tempstr, _("Hit Points: %+i"), x->_iPLHP >> 6); + sprintf(tempstr, fmt::format(_("Hit Points: %+i"), x->_iPLHP >> 6).c_str()); break; case IPL_MANA: case IPL_MANA_CURSE: - sprintf(tempstr, _("Mana: %+i"), x->_iPLMana >> 6); + sprintf(tempstr, fmt::format(_("Mana: %+i"), x->_iPLMana >> 6).c_str()); break; case IPL_DUR: strcpy(tempstr, _("high durability")); @@ -3528,31 +3530,31 @@ void PrintItemPower(char plidx, ItemStruct *x) strcpy(tempstr, _("indestructible")); break; case IPL_LIGHT: - sprintf(tempstr, _("+%i%% light radius"), 10 * x->_iPLLight); + sprintf(tempstr, fmt::format(_("+%i%% light radius"), 10 * x->_iPLLight).c_str()); break; case IPL_LIGHT_CURSE: - sprintf(tempstr, _("-%i%% light radius"), -10 * x->_iPLLight); + sprintf(tempstr, fmt::format(_("-%i%% light radius"), -10 * x->_iPLLight).c_str()); break; case IPL_MULT_ARROWS: strcpy(tempstr, _("multiple arrows per shot")); break; case IPL_FIRE_ARROWS: if (x->_iFMinDam == x->_iFMaxDam) - sprintf(tempstr, _("fire arrows damage: %i"), x->_iFMinDam); + sprintf(tempstr, fmt::format(_("fire arrows damage: %i"), x->_iFMinDam).c_str()); else - sprintf(tempstr, _("fire arrows damage: %i-%i"), x->_iFMinDam, x->_iFMaxDam); + sprintf(tempstr, fmt::format(_("fire arrows damage: %i-%i"), x->_iFMinDam, x->_iFMaxDam).c_str()); break; case IPL_LIGHT_ARROWS: if (x->_iLMinDam == x->_iLMaxDam) - sprintf(tempstr, _("lightning arrows damage %i"), x->_iLMinDam); + sprintf(tempstr, fmt::format(_("lightning arrows damage %i"), x->_iLMinDam).c_str()); else - sprintf(tempstr, _("lightning arrows damage %i-%i"), x->_iLMinDam, x->_iLMaxDam); + sprintf(tempstr, fmt::format(_("lightning arrows damage %i-%i"), x->_iLMinDam, x->_iLMaxDam).c_str()); break; case IPL_FIREBALL: if (x->_iFMinDam == x->_iFMaxDam) - sprintf(tempstr, _("fireball damage: %i"), x->_iFMinDam); + sprintf(tempstr, fmt::format(_("fireball damage: %i"), x->_iFMinDam).c_str()); else - sprintf(tempstr, _("fireball damage: %i-%i"), x->_iFMinDam, x->_iFMaxDam); + sprintf(tempstr, fmt::format(_("fireball damage: %i-%i"), x->_iFMinDam, x->_iFMaxDam).c_str()); break; case IPL_THORNS: strcpy(tempstr, _("attacker takes 1-3 damage")); @@ -3649,9 +3651,9 @@ void PrintItemPower(char plidx, ItemStruct *x) break; case IPL_ADDACLIFE: if (x->_iFMinDam == x->_iFMaxDam) - sprintf(tempstr, _("lightning damage: %i"), x->_iFMinDam); + sprintf(tempstr, fmt::format(_("lightning damage: %i"), x->_iFMinDam).c_str()); else - sprintf(tempstr, _("lightning damage: %i-%i"), x->_iFMinDam, x->_iFMaxDam); + sprintf(tempstr, fmt::format(_("lightning damage: %i-%i"), x->_iFMinDam, x->_iFMaxDam).c_str()); break; case IPL_ADDMANAAC: strcpy(tempstr, _("charged bolts on hits")); @@ -3660,13 +3662,13 @@ void PrintItemPower(char plidx, ItemStruct *x) if (x->_iPLFR <= 0) strcpy(tempstr, " "); else if (x->_iPLFR >= 1) - sprintf(tempstr, _("Resist Fire: %+i%%"), x->_iPLFR); + sprintf(tempstr, fmt::format(_("Resist Fire: %+i%%"), x->_iPLFR).c_str()); break; case IPL_DEVASTATION: strcpy(tempstr, _("occasional triple damage")); break; case IPL_DECAY: - sprintf(tempstr, _("decaying %+i%% damage"), x->_iPLDam); + sprintf(tempstr, fmt::format(_("decaying %+i%% damage"), x->_iPLDam).c_str()); break; case IPL_PERIL: strcpy(tempstr, _("2x dmg to monst, 1x to you")); @@ -3675,10 +3677,10 @@ void PrintItemPower(char plidx, ItemStruct *x) /*xgettext:no-c-format*/ strcpy(tempstr, _("Random 0 - 500% damage")); break; case IPL_CRYSTALLINE: - sprintf(tempstr, _("low dur, %+i%% damage"), x->_iPLDam); + sprintf(tempstr, fmt::format(_("low dur, %+i%% damage"), x->_iPLDam).c_str()); break; case IPL_DOPPELGANGER: - sprintf(tempstr, _("to hit: %+i%%, %+i%% damage"), x->_iPLToHit, x->_iPLDam); + sprintf(tempstr, fmt::format(_("to hit: %+i%%, %+i%% damage"), x->_iPLToHit, x->_iPLDam).c_str()); break; case IPL_ACDEMON: strcpy(tempstr, _("extra AC vs demons")); @@ -3797,7 +3799,7 @@ void PrintItemMisc(ItemStruct *x) AddPanelString(tempstr); } if (x->_iMiscId == IMISC_EAR) { - sprintf(tempstr, _("Level: %i"), x->_ivalue); + sprintf(tempstr, fmt::format(_("Level: %i"), x->_ivalue).c_str()); AddPanelString(tempstr); } if (x->_iMiscId == IMISC_AURIC) { @@ -3815,11 +3817,11 @@ static void PrintItemInfo(ItemStruct *x) if (str != 0 || mag != 0 || dex != 0) { strcpy(tempstr, _("Required:")); if (str) - sprintf(tempstr + strlen(tempstr), _(" %i Str"), str); + sprintf(tempstr + strlen(tempstr), fmt::format(_(" %i Str"), str).c_str()); if (mag) - sprintf(tempstr + strlen(tempstr), _(" %i Mag"), mag); + sprintf(tempstr + strlen(tempstr), fmt::format(_(" %i Mag"), mag).c_str()); if (dex) - sprintf(tempstr + strlen(tempstr), _(" %i Dex"), dex); + sprintf(tempstr + strlen(tempstr), fmt::format(_(" %i Dex"), dex).c_str()); AddPanelString(tempstr); } pinfoflag = true; @@ -3830,30 +3832,30 @@ void PrintItemDetails(ItemStruct *x) if (x->_iClass == ICLASS_WEAPON) { if (x->_iMinDam == x->_iMaxDam) { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, _("damage: %i Indestructible"), x->_iMinDam); + sprintf(tempstr, fmt::format(_("damage: %i Indestructible"), x->_iMinDam).c_str()); else - sprintf(tempstr, _( /* TRANSLATORS: Dur: is durability */ "damage: %i Dur: %i/%i"), x->_iMinDam, x->_iDurability, x->_iMaxDur); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dur: is durability */ "damage: %i Dur: %i/%i"), x->_iMinDam, x->_iDurability, x->_iMaxDur).c_str()); } else { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, _("damage: %i-%i Indestructible"), x->_iMinDam, x->_iMaxDam); + sprintf(tempstr, fmt::format(_("damage: %i-%i Indestructible"), x->_iMinDam, x->_iMaxDam).c_str()); else - sprintf(tempstr, _( /* TRANSLATORS: Dur: is durability */ "damage: %i-%i Dur: %i/%i"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dur: is durability */ "damage: %i-%i Dur: %i/%i"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur).c_str()); } AddPanelString(tempstr); } if (x->_iClass == ICLASS_ARMOR) { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, _("armor: %i Indestructible"), x->_iAC); + sprintf(tempstr, fmt::format(_("armor: %i Indestructible"), x->_iAC).c_str()); else - sprintf(tempstr, _( /* TRANSLATORS: Dur: is durability */ "armor: %i Dur: %i/%i"), x->_iAC, x->_iDurability, x->_iMaxDur); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dur: is durability */ "armor: %i Dur: %i/%i"), x->_iAC, x->_iDurability, x->_iMaxDur).c_str()); AddPanelString(tempstr); } if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges != 0) { if (x->_iMinDam == x->_iMaxDam) - sprintf(tempstr, _( /* TRANSLATORS: dam: is damage Dur: is durability */ "dam: %i Dur: %i/%i"), x->_iMinDam, x->_iDurability, x->_iMaxDur); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: dam: is damage Dur: is durability */ "dam: %i Dur: %i/%i"), x->_iMinDam, x->_iDurability, x->_iMaxDur).c_str()); else - sprintf(tempstr, _( /* TRANSLATORS: dam: is damage Dur: is durability */ "dam: %i-%i Dur: %i/%i"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur); - sprintf(tempstr, _("Charges: %i/%i"), x->_iCharges, x->_iMaxCharges); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: dam: is damage Dur: is durability */ "dam: %i-%i Dur: %i/%i"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur).c_str()); + sprintf(tempstr, fmt::format(_("Charges: %i/%i"), x->_iCharges, x->_iMaxCharges).c_str()); AddPanelString(tempstr); } if (x->_iPrePower != -1) { @@ -3877,18 +3879,18 @@ void PrintItemDur(ItemStruct *x) if (x->_iClass == ICLASS_WEAPON) { if (x->_iMinDam == x->_iMaxDam) { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, _("damage: %i Indestructible"), x->_iMinDam); + sprintf(tempstr, fmt::format(_("damage: %i Indestructible"), x->_iMinDam).c_str()); else - sprintf(tempstr, _("damage: %i Dur: %i/%i"), x->_iMinDam, x->_iDurability, x->_iMaxDur); + sprintf(tempstr, fmt::format(_("damage: %i Dur: %i/%i"), x->_iMinDam, x->_iDurability, x->_iMaxDur).c_str()); } else { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, _("damage: %i-%i Indestructible"), x->_iMinDam, x->_iMaxDam); + sprintf(tempstr, fmt::format(_("damage: %i-%i Indestructible"), x->_iMinDam, x->_iMaxDam).c_str()); else - sprintf(tempstr, _("damage: %i-%i Dur: %i/%i"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur); + sprintf(tempstr, fmt::format(_("damage: %i-%i Dur: %i/%i"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur).c_str()); } AddPanelString(tempstr); if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) { - sprintf(tempstr, _("Charges: %i/%i"), x->_iCharges, x->_iMaxCharges); + sprintf(tempstr, fmt::format(_("Charges: %i/%i"), x->_iCharges, x->_iMaxCharges).c_str()); AddPanelString(tempstr); } if (x->_iMagical != ITEM_QUALITY_NORMAL) @@ -3896,14 +3898,14 @@ void PrintItemDur(ItemStruct *x) } if (x->_iClass == ICLASS_ARMOR) { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, _("armor: %i Indestructible"), x->_iAC); + sprintf(tempstr, fmt::format(_("armor: %i Indestructible"), x->_iAC).c_str()); else - sprintf(tempstr, _("armor: %i Dur: %i/%i"), x->_iAC, x->_iDurability, x->_iMaxDur); + sprintf(tempstr, fmt::format(_("armor: %i Dur: %i/%i"), x->_iAC, x->_iDurability, x->_iMaxDur).c_str()); AddPanelString(tempstr); if (x->_iMagical != ITEM_QUALITY_NORMAL) AddPanelString(_("Not Identified")); if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) { - sprintf(tempstr, _("Charges: %i/%i"), x->_iCharges, x->_iMaxCharges); + sprintf(tempstr, fmt::format(_("Charges: %i/%i"), x->_iCharges, x->_iMaxCharges).c_str()); AddPanelString(tempstr); } } diff --git a/Source/monster.cpp b/Source/monster.cpp index dd40c551b..e2894e9b5 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -9,6 +9,8 @@ #include #include +#include + #include "control.h" #include "cursor.h" #include "dead.h" @@ -1671,7 +1673,7 @@ void SpawnLoot(int i, bool sendmsg) Monst = &monster[i]; if (QuestStatus(Q_GARBUD) && Monst->_uniqtype - 1 == UMT_GARBUD) { - CreateTypeItem(Monst->position.tile + Point{1, 1}, true, ITYPE_MACE, IMISC_NONE, true, false); + CreateTypeItem(Monst->position.tile + Point { 1, 1 }, true, ITYPE_MACE, IMISC_NONE, true, false); } else if (Monst->_uniqtype - 1 == UMT_DEFILER) { if (effect_is_playing(USFX_DEFILER8)) stream_stop(); @@ -2415,7 +2417,7 @@ bool M_DoTalk(int i) quests[Q_GARBUD]._qlog = true; // BUGFIX: (?) for other quests qactive and qlog go together, maybe this should actually go into the if above (fixed) } if (monster[i].mtalkmsg == TEXT_GARBUD2 && !(monster[i]._mFlags & MFLAG_QUEST_COMPLETE)) { - SpawnItem(i, monster[i].position.tile + Point{1, 1}, true); + SpawnItem(i, monster[i].position.tile + Point { 1, 1 }, true); monster[i]._mFlags |= MFLAG_QUEST_COMPLETE; } } @@ -2424,7 +2426,7 @@ bool M_DoTalk(int i) && !(monster[i]._mFlags & MFLAG_QUEST_COMPLETE)) { quests[Q_ZHAR]._qactive = QUEST_ACTIVE; quests[Q_ZHAR]._qlog = true; - CreateTypeItem(monster[i].position.tile + Point{1,1}, false, ITYPE_MISC, IMISC_BOOK, true, false); + CreateTypeItem(monster[i].position.tile + Point { 1, 1 }, false, ITYPE_MISC, IMISC_BOOK, true, false); monster[i]._mFlags |= MFLAG_QUEST_COMPLETE; } if (monster[i]._uniqtype - 1 == UMT_SNOTSPIL) { @@ -4963,9 +4965,9 @@ void PrintMonstHistory(int mt) int minHP, maxHP, res; if (sgOptions.Gameplay.bShowMonsterType) { - sprintf(tempstr, _("Type: %s Kills: %i"), GetMonsterTypeText(monsterdata[mt]), monstkills[mt]); + sprintf(tempstr, fmt::format(_("Type: %s Kills: %i"), GetMonsterTypeText(monsterdata[mt])).c_str(), monstkills[mt]); } else { - sprintf(tempstr, _("Total kills: %i"), monstkills[mt]); + sprintf(tempstr, fmt::format(_("Total kills: %i"), monstkills[mt]).c_str()); } AddPanelString(tempstr); @@ -4998,7 +5000,7 @@ void PrintMonstHistory(int mt) minHP = 4 * minHP + hpBonusHell; maxHP = 4 * maxHP + hpBonusHell; } - sprintf(tempstr, _("Hit Points: %i-%i"), minHP, maxHP); + sprintf(tempstr, fmt::format(_("Hit Points: %i-%i"), minHP, maxHP).c_str()); AddPanelString(tempstr); } if (monstkills[mt] >= 15) { @@ -5043,7 +5045,7 @@ void PrintUniqueHistory() int res; if (sgOptions.Gameplay.bShowMonsterType) { - sprintf(tempstr, _("Type: %s"), GetMonsterTypeText(*monster[pcursmonst].MData)); + sprintf(tempstr, fmt::format(_("Type: %s"), GetMonsterTypeText(*monster[pcursmonst].MData)).c_str()); AddPanelString(tempstr); } diff --git a/Source/msg.cpp b/Source/msg.cpp index c8a2934e4..2be2b3bc0 100644 --- a/Source/msg.cpp +++ b/Source/msg.cpp @@ -6,6 +6,8 @@ #include #include +#include + #include "DiabloUI/diabloui.h" #include "automap.h" #include "control.h" @@ -1391,7 +1393,7 @@ static DWORD On_SBSPELL(TCmd *pCmd, int pnum) plr[pnum]._pSplFrom = 1; plr[pnum].destAction = ACTION_SPELL; } else - msg_errorf(_("%s has cast an illegal spell."), plr[pnum]._pName); + msg_errorf(fmt::format(_("%s has cast an illegal spell."), plr[pnum]._pName).c_str()); } return sizeof(*p); @@ -1662,7 +1664,7 @@ static DWORD On_SPELLXYD(TCmd *pCmd, int pnum) plr[pnum]._pSplType = plr[pnum]._pRSplType; plr[pnum]._pSplFrom = 0; } else - msg_errorf(_("%s has cast an illegal spell."), plr[pnum]._pName); + msg_errorf(fmt::format(_("%s has cast an illegal spell."), plr[pnum]._pName).c_str()); } return sizeof(*p); @@ -1684,7 +1686,7 @@ static DWORD On_SPELLXY(TCmd *pCmd, int pnum) plr[pnum]._pSplType = plr[pnum]._pRSplType; plr[pnum]._pSplFrom = 0; } else - msg_errorf(_("%s has cast an illegal spell."), plr[pnum]._pName); + msg_errorf(fmt::format(_("%s has cast an illegal spell."), plr[pnum]._pName).c_str()); } return sizeof(*p); @@ -1706,7 +1708,7 @@ static DWORD On_TSPELLXY(TCmd *pCmd, int pnum) plr[pnum]._pSplType = plr[pnum]._pTSplType; plr[pnum]._pSplFrom = 2; } else - msg_errorf(_("%s has cast an illegal spell."), plr[pnum]._pName); + msg_errorf(fmt::format(_("%s has cast an illegal spell."), plr[pnum]._pName).c_str()); } return sizeof(*p); @@ -1826,7 +1828,7 @@ static DWORD On_SPELLID(TCmd *pCmd, int pnum) plr[pnum]._pSplType = plr[pnum]._pRSplType; plr[pnum]._pSplFrom = 0; } else - msg_errorf(_("%s has cast an illegal spell."), plr[pnum]._pName); + msg_errorf(fmt::format(_("%s has cast an illegal spell."), plr[pnum]._pName).c_str()); } return sizeof(*p); @@ -1847,7 +1849,7 @@ static DWORD On_SPELLPID(TCmd *pCmd, int pnum) plr[pnum]._pSplType = plr[pnum]._pRSplType; plr[pnum]._pSplFrom = 0; } else - msg_errorf(_("%s has cast an illegal spell."), plr[pnum]._pName); + msg_errorf(fmt::format(_("%s has cast an illegal spell."), plr[pnum]._pName).c_str()); } return sizeof(*p); @@ -1868,7 +1870,7 @@ static DWORD On_TSPELLID(TCmd *pCmd, int pnum) plr[pnum]._pSplType = plr[pnum]._pTSplType; plr[pnum]._pSplFrom = 2; } else - msg_errorf(_("%s has cast an illegal spell."), plr[pnum]._pName); + msg_errorf(fmt::format(_("%s has cast an illegal spell."), plr[pnum]._pName).c_str()); } return sizeof(*p); @@ -1889,7 +1891,7 @@ static DWORD On_TSPELLPID(TCmd *pCmd, int pnum) plr[pnum]._pSplType = plr[pnum]._pTSplType; plr[pnum]._pSplFrom = 2; } else - msg_errorf(_("%s has cast an illegal spell."), plr[pnum]._pName); + msg_errorf(fmt::format(_("%s has cast an illegal spell."), plr[pnum]._pName).c_str()); } return sizeof(*p); @@ -2225,7 +2227,7 @@ static DWORD On_PLAYER_JOINLEVEL(TCmd *pCmd, int pnum) InitPlrGFXMem(plr[pnum]); plr[pnum].plractive = true; gbActivePlayers++; - EventPlrMsg(_("Player '%s' (level %i) just joined the game"), plr[pnum]._pName, plr[pnum]._pLevel); + EventPlrMsg(fmt::format(_("Player '%s' (level %i) just joined the game"), plr[pnum]._pName, plr[pnum]._pLevel).c_str()); } if (plr[pnum].plractive && myplr != pnum) { diff --git a/Source/multi.cpp b/Source/multi.cpp index 53e661244..92bf6d705 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -7,6 +7,8 @@ #include #include +#include + #include "DiabloUI/diabloui.h" #include "diablo.h" #include "dthread.h" @@ -860,7 +862,7 @@ void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, bool recv) } else { szEvent = _("Player '%s' (level %i) is already in the game"); } - EventPlrMsg(szEvent, plr[pnum]._pName, plr[pnum]._pLevel); + EventPlrMsg(fmt::format(szEvent, plr[pnum]._pName, plr[pnum]._pLevel).c_str()); LoadPlrGFX(pnum, PFILE_STAND); SyncInitPlr(pnum); diff --git a/Source/objects.cpp b/Source/objects.cpp index dfabb4544..566ea790e 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -87,7 +87,7 @@ int bxadd[8] = { -1, 0, 1, -1, 1, -1, 0, 1 }; int byadd[8] = { -1, -1, -1, 0, 0, 1, 1, 1 }; /** Maps from shrine_id to shrine name. */ const char *const shrinestrs[] = { - // TRANSLATORS: Shrine Name Block + // TRANSLATORS: Shrine Name Block N_("Mysterious"), N_("Hidden"), N_("Gloomy"), @@ -252,22 +252,22 @@ shrine_gametype shrineavail[] = { }; /** Maps from book_id to book name. */ const char *const StoryBookName[] = { - N_( /* TRANSLATORS: Book Title */ "The Great Conflict"), - N_( /* TRANSLATORS: Book Title */ "The Wages of Sin are War"), - N_( /* TRANSLATORS: Book Title */ "The Tale of the Horadrim"), - N_( /* TRANSLATORS: Book Title */ "The Dark Exile"), - N_( /* TRANSLATORS: Book Title */ "The Sin War"), - N_( /* TRANSLATORS: Book Title */ "The Binding of the Three"), - N_( /* TRANSLATORS: Book Title */ "The Realms Beyond"), - N_( /* TRANSLATORS: Book Title */ "Tale of the Three"), - N_( /* TRANSLATORS: Book Title */ "The Black King"), - N_( /* TRANSLATORS: Book Title */ "Journal: The Ensorcellment"), - N_( /* TRANSLATORS: Book Title */ "Journal: The Meeting"), - N_( /* TRANSLATORS: Book Title */ "Journal: The Tirade"), - N_( /* TRANSLATORS: Book Title */ "Journal: His Power Grows"), - N_( /* TRANSLATORS: Book Title */ "Journal: NA-KRUL"), - N_( /* TRANSLATORS: Book Title */ "Journal: The End"), - N_( /* TRANSLATORS: Book Title */ "A Spellbook"), + N_(/* TRANSLATORS: Book Title */ "The Great Conflict"), + N_(/* TRANSLATORS: Book Title */ "The Wages of Sin are War"), + N_(/* TRANSLATORS: Book Title */ "The Tale of the Horadrim"), + N_(/* TRANSLATORS: Book Title */ "The Dark Exile"), + N_(/* TRANSLATORS: Book Title */ "The Sin War"), + N_(/* TRANSLATORS: Book Title */ "The Binding of the Three"), + N_(/* TRANSLATORS: Book Title */ "The Realms Beyond"), + N_(/* TRANSLATORS: Book Title */ "Tale of the Three"), + N_(/* TRANSLATORS: Book Title */ "The Black King"), + N_(/* TRANSLATORS: Book Title */ "Journal: The Ensorcellment"), + N_(/* TRANSLATORS: Book Title */ "Journal: The Meeting"), + N_(/* TRANSLATORS: Book Title */ "Journal: The Tirade"), + N_(/* TRANSLATORS: Book Title */ "Journal: His Power Grows"), + N_(/* TRANSLATORS: Book Title */ "Journal: NA-KRUL"), + N_(/* TRANSLATORS: Book Title */ "Journal: The End"), + N_(/* TRANSLATORS: Book Title */ "A Spellbook"), }; /** Specifies the speech IDs of each dungeon type narrator book, for each player class. */ _speech_id StoryText[3][3] = { @@ -3006,7 +3006,7 @@ void OperateBookLever(int pnum, int i) quests[Q_BLOOD]._qactive = QUEST_ACTIVE; quests[Q_BLOOD]._qlog = true; quests[Q_BLOOD]._qvar1 = 1; - SpawnQuestItem(IDI_BLDSTONE, {2 * setpc_x + 25, 2 * setpc_y + 33}, 0, true); + SpawnQuestItem(IDI_BLDSTONE, { 2 * setpc_x + 25, 2 * setpc_y + 33 }, 0, true); } object[i]._otype = object[i]._otype; if (object[i]._otype == OBJ_STEELTOME && quests[Q_WARLORD]._qvar1 == 0) { @@ -3303,13 +3303,13 @@ void OperatePedistal(int pnum, int i) if (!deltaload) PlaySfxLoc(LS_PUDDLE, object[i].position.x, object[i].position.y); ObjChangeMap(setpc_x, setpc_y + 3, setpc_x + 2, setpc_y + 7); - SpawnQuestItem(IDI_BLDSTONE, {2 * setpc_x + 19, 2 * setpc_y + 26}, 0, true); + SpawnQuestItem(IDI_BLDSTONE, { 2 * setpc_x + 19, 2 * setpc_y + 26 }, 0, true); } if (object[i]._oVar6 == 2) { if (!deltaload) PlaySfxLoc(LS_PUDDLE, object[i].position.x, object[i].position.y); ObjChangeMap(setpc_x + 6, setpc_y + 3, setpc_x + setpc_w, setpc_y + 7); - SpawnQuestItem(IDI_BLDSTONE, {2 * setpc_x + 31, 2 * setpc_y + 26}, 0, true); + SpawnQuestItem(IDI_BLDSTONE, { 2 * setpc_x + 31, 2 * setpc_y + 26 }, 0, true); } if (object[i]._oVar6 == 3) { if (!deltaload) @@ -3808,11 +3808,11 @@ bool OperateShrineDivine(int pnum, int x, int y) return false; if (currlevel < 4) { - CreateTypeItem({x, y}, false, ITYPE_MISC, IMISC_FULLMANA, false, true); - CreateTypeItem({x, y}, false, ITYPE_MISC, IMISC_FULLHEAL, false, true); + CreateTypeItem({ x, y }, false, ITYPE_MISC, IMISC_FULLMANA, false, true); + CreateTypeItem({ x, y }, false, ITYPE_MISC, IMISC_FULLHEAL, false, true); } else { - CreateTypeItem({x, y}, false, ITYPE_MISC, IMISC_FULLREJUV, false, true); - CreateTypeItem({x, y}, false, ITYPE_MISC, IMISC_FULLREJUV, false, true); + CreateTypeItem({ x, y }, false, ITYPE_MISC, IMISC_FULLREJUV, false, true); + CreateTypeItem({ x, y }, false, ITYPE_MISC, IMISC_FULLREJUV, false, true); } plr[pnum]._pMana = plr[pnum]._pMaxMana; @@ -5501,7 +5501,7 @@ void GetObjectStr(int i) break; case OBJ_SHRINEL: case OBJ_SHRINER: - sprintf(tempstr, _( /* TRANSLATORS: %s will be a name from the Shrine block above */ "%s Shrine"), _(shrinestrs[object[i]._oVar1])); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: %s will be a name from the Shrine block above */ "%s Shrine"), _(shrinestrs[object[i]._oVar1])).c_str()); strcpy(infostr, tempstr); break; case OBJ_SKELBOOK: @@ -5570,13 +5570,13 @@ void GetObjectStr(int i) } if (plr[myplr]._pClass == HeroClass::Rogue) { if (object[i]._oTrapFlag) { - sprintf(tempstr, _( /* TRANSLATORS: %s will either be a chest or a door */ "Trapped %s"), infostr); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: %s will either be a chest or a door */ "Trapped %s"), infostr).c_str()); strcpy(infostr, tempstr); infoclr = UIS_RED; } } if (objectIsDisabled(i)) { - sprintf(tempstr, _( /* TRANSLATORS: If user enabled diablo.ini setting "Disable Crippling Shrines" is set to 1; also used for Na-Kruls leaver */ "%s (disabled)"), infostr); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: If user enabled diablo.ini setting "Disable Crippling Shrines" is set to 1; also used for Na-Kruls leaver */ "%s (disabled)"), infostr).c_str()); strcpy(infostr, tempstr); infoclr = UIS_RED; } diff --git a/Source/player.cpp b/Source/player.cpp index bd3cfcc4a..ca30bc1d7 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -357,8 +357,7 @@ void PlayerStruct::Stop() bool PlayerStruct::IsWalking() const { - switch (_pmode) - { + switch (_pmode) { case PM_WALK: case PM_WALK2: case PM_WALK3: @@ -1887,7 +1886,7 @@ StartPlayerKill(int pnum, int earflag) if (earflag != -1) { if (earflag != 0) { SetPlrHandItem(&ear, IDI_EAR); - sprintf(ear._iName, _("Ear of %s"), player._pName); + sprintf(ear._iName, fmt::format(_("Ear of %s"), player._pName).c_str()); if (player._pClass == HeroClass::Sorcerer) { ear._iCurs = ICURS_EAR_SORCERER; } else if (player._pClass == HeroClass::Warrior) { diff --git a/Source/plrmsg.cpp b/Source/plrmsg.cpp index f83062792..a462bc6c2 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -5,6 +5,8 @@ */ #include "plrmsg.h" +#include + #include "control.h" #include "engine/render/text_render.hpp" #include "inv.h" @@ -70,7 +72,7 @@ void SendPlrMsg(int pnum, const char *pszStr) pMsg->time = SDL_GetTicks(); assert(strlen(plr[pnum]._pName) < PLR_NAME_LEN); assert(strlen(pszStr) < MAX_SEND_STR_LEN); - sprintf(pMsg->str, _(/* TRANSLATORS: Shown if player presses "v" button. %s is player name, %i is level, %s is location */ "%s (lvl %i): %s"), plr[pnum]._pName, plr[pnum]._pLevel, pszStr); + sprintf(pMsg->str, fmt::format(_(/* TRANSLATORS: Shown if player presses "v" button. %s is player name, %i is level, %s is location */ "%s (lvl %i): %s"), plr[pnum]._pName, plr[pnum]._pLevel, pszStr).c_str()); } void ClearPlrMsg() diff --git a/Source/qol/xpbar.cpp b/Source/qol/xpbar.cpp index 8c178867a..6e3b86fa5 100644 --- a/Source/qol/xpbar.cpp +++ b/Source/qol/xpbar.cpp @@ -4,14 +4,16 @@ * Adds XP bar QoL feature */ +#include + +#include + #include "DiabloUI/art_draw.h" #include "common.h" #include "control.h" #include "options.h" #include "utils/language.h" -#include - namespace devilution { namespace { @@ -121,7 +123,7 @@ bool CheckXPBarInfo() const int charLevel = player._pLevel; - sprintf(tempstr, _("Level %i"), charLevel); + sprintf(tempstr, fmt::format(_("Level %i"), charLevel).c_str()); AddPanelString(tempstr); if (charLevel == MAXCHARLEVEL - 1) { @@ -147,7 +149,7 @@ bool CheckXPBarInfo() PrintWithSeparator(tempstr + SDL_arraysize("Next Level: ") - 1, ExpLvlsTbl[charLevel]); AddPanelString(tempstr); - sprintf(PrintWithSeparator(tempstr, ExpLvlsTbl[charLevel] - player._pExperience), _(" to Level %i"), charLevel + 1); + sprintf(PrintWithSeparator(tempstr, ExpLvlsTbl[charLevel] - player._pExperience), fmt::format(_(" to Level %i"), charLevel + 1).c_str()); AddPanelString(tempstr); return true; diff --git a/Source/quests.cpp b/Source/quests.cpp index 40d2fb19c..39f5fa33a 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -4,6 +4,8 @@ * Implementation of functionality for handling quests. */ +#include + #include "control.h" #include "cursor.h" #include "engine/render/cel_render.hpp" @@ -75,11 +77,11 @@ char questxoff[7] = { 0, -1, 0, -1, -2, -1, -2 }; */ char questyoff[7] = { 0, 0, -1, -1, -1, -2, -2 }; const char *const questtrigstr[5] = { - N_( /* TRANSLATORS: Quest Map*/ "King Leoric's Tomb"), - N_( /* TRANSLATORS: Quest Map*/ "The Chamber of Bone"), - N_( /* TRANSLATORS: Quest Map*/ "Maze"), - N_( /* TRANSLATORS: Quest Map*/ "A Dark Passage"), - N_( /* TRANSLATORS: Quest Map*/ "Unholy Altar") + N_(/* TRANSLATORS: Quest Map*/ "King Leoric's Tomb"), + N_(/* TRANSLATORS: Quest Map*/ "The Chamber of Bone"), + N_(/* TRANSLATORS: Quest Map*/ "Maze"), + N_(/* TRANSLATORS: Quest Map*/ "A Dark Passage"), + N_(/* TRANSLATORS: Quest Map*/ "Unholy Altar") }; /** * A quest group containing the three quests the Butcher, @@ -279,7 +281,7 @@ bool ForceQuests() for (j = 0; j < 7; j++) { if (qx + questxoff[j] == cursmx && qy + questyoff[j] == cursmy) { - sprintf(infostr, _( /* TRANSLATORS: Used for Quest Portals. %s is a Map Name */ "To %s"), _(questtrigstr[ql])); + sprintf(infostr, fmt::format(_(/* TRANSLATORS: Used for Quest Portals. %s is a Map Name */ "To %s"), _(questtrigstr[ql])).c_str()); cursmx = qx; cursmy = qy; return true; @@ -675,7 +677,7 @@ void ResyncQuests() } if (currlevel == quests[Q_MUSHROOM]._qlevel) { if (quests[Q_MUSHROOM]._qactive == QUEST_INIT && quests[Q_MUSHROOM]._qvar1 == QS_INIT) { - SpawnQuestItem(IDI_FUNGALTM, {0, 0}, 5, true); + SpawnQuestItem(IDI_FUNGALTM, { 0, 0 }, 5, true); quests[Q_MUSHROOM]._qvar1 = QS_TOMESPAWNED; } else { if (quests[Q_MUSHROOM]._qactive == QUEST_ACTIVE) { @@ -690,7 +692,7 @@ void ResyncQuests() } if (currlevel == quests[Q_VEIL]._qlevel + 1 && quests[Q_VEIL]._qactive == QUEST_ACTIVE && quests[Q_VEIL]._qvar1 == 0) { quests[Q_VEIL]._qvar1 = 1; - SpawnQuestItem(IDI_GLDNELIX, {0, 0}, 5, true); + SpawnQuestItem(IDI_GLDNELIX, { 0, 0 }, 5, true); } if (setlevel && setlvlnum == SL_VILEBETRAYER) { if (quests[Q_BETRAYER]._qvar1 >= 4) diff --git a/Source/stores.cpp b/Source/stores.cpp index 08845fe45..2616f206e 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -7,6 +7,8 @@ #include +#include + #include "cursor.h" #include "engine/render/cel_render.hpp" #include "engine/render/text_render.hpp" @@ -167,7 +169,7 @@ void PrintStoreItem(ItemStruct *x, int l, uint16_t flags) } } if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) { - sprintf(tempstr, _("Charges: %i/%i"), x->_iCharges, x->_iMaxCharges); + sprintf(tempstr, fmt::format(_("Charges: %i/%i"), x->_iCharges, x->_iMaxCharges).c_str()); if (sstr[0]) strcat(sstr, _(", ")); strcat(sstr, tempstr); @@ -178,11 +180,11 @@ void PrintStoreItem(ItemStruct *x, int l, uint16_t flags) } sstr[0] = '\0'; if (x->_iClass == ICLASS_WEAPON) - sprintf(sstr, _("Damage: %i-%i "), x->_iMinDam, x->_iMaxDam); + sprintf(sstr, fmt::format(_("Damage: %i-%i "), x->_iMinDam, x->_iMaxDam).c_str()); if (x->_iClass == ICLASS_ARMOR) - sprintf(sstr, _("Armor: %i "), x->_iAC); + sprintf(sstr, fmt::format(_("Armor: %i "), x->_iAC).c_str()); if (x->_iMaxDur != DUR_INDESTRUCTIBLE && x->_iMaxDur) { - sprintf(tempstr, _("Dur: %i/%i, "), x->_iDurability, x->_iMaxDur); + sprintf(tempstr, fmt::format(_("Dur: %i/%i, "), x->_iDurability, x->_iMaxDur).c_str()); strcat(sstr, tempstr); } else { strcat(sstr, _("Indestructible, ")); @@ -197,11 +199,11 @@ void PrintStoreItem(ItemStruct *x, int l, uint16_t flags) } else { strcpy(tempstr, _("Required:")); if (str) - sprintf(tempstr + strlen(tempstr), _(" %i Str"), str); + sprintf(tempstr + strlen(tempstr), fmt::format(_(" %i Str"), str).c_str()); if (mag) - sprintf(tempstr + strlen(tempstr), _(" %i Mag"), mag); + sprintf(tempstr + strlen(tempstr), fmt::format(_(" %i Mag"), mag).c_str()); if (dex) - sprintf(tempstr + strlen(tempstr), _(" %i Dex"), dex); + sprintf(tempstr + strlen(tempstr), fmt::format(_(" %i Dex"), dex).c_str()); strcat(sstr, tempstr); } AddSText(40, l++, sstr, flags, false); @@ -272,7 +274,7 @@ void S_StartSBuy() stextsize = true; stextscrl = true; stextsval = 0; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -337,7 +339,7 @@ bool S_StartSPBuy() stextscrl = true; stextsval = 0; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these premium items for sale: Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these premium items for sale: Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -465,7 +467,7 @@ void S_StartSSell() if (!sellok) { stextscrl = false; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing I want. Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing I want. Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -475,7 +477,7 @@ void S_StartSSell() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Which item is for sale? Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Which item is for sale? Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -535,7 +537,7 @@ void S_StartSRepair() } if (!repairok) { stextscrl = false; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to repair. Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to repair. Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -547,7 +549,7 @@ void S_StartSRepair() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Repair which item? Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Repair which item? Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -621,7 +623,7 @@ void S_StartWBuy() stextscrl = true; stextsval = 0; stextsmax = 20; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -715,7 +717,7 @@ void S_StartWSell() if (!sellok) { stextscrl = false; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing I want. Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing I want. Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -725,7 +727,7 @@ void S_StartWSell() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Which item is for sale? Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Which item is for sale? Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -791,7 +793,7 @@ void S_StartWRecharge() if (!rechargeok) { stextscrl = false; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to recharge. Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to recharge. Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -801,7 +803,7 @@ void S_StartWRecharge() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Recharge which item? Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Recharge which item? Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -913,7 +915,7 @@ void S_StartBBoy() { stextsize = true; stextscrl = false; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have this item for sale: Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have this item for sale: Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -987,7 +989,7 @@ void S_StartHBuy() stextsize = true; stextscrl = true; stextsval = 0; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -1088,7 +1090,7 @@ void S_StartSIdentify() if (!idok) { stextscrl = false; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to identify. Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to identify. Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -1098,7 +1100,7 @@ void S_StartSIdentify() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, _( /* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Identify which item? Your gold: %i"), plr[myplr]._pGold); + sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Identify which item? Your gold: %i"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -1127,11 +1129,11 @@ void S_StartTalk() stextsize = false; stextscrl = false; - sprintf(tempstr, _("Talk to %s"), talkname[talker]); + sprintf(tempstr, fmt::format(_("Talk to %s"), talkname[talker]).c_str()); AddSText(0, 2, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(5); if (gbIsSpawn) { - sprintf(tempstr, _("Talking to %s"), talkname[talker]); + sprintf(tempstr, fmt::format(_("Talking to %s"), talkname[talker]).c_str()); AddSText(0, 10, tempstr, UIS_SILVER | UIS_CENTER, false); AddSText(0, 12, _("is not available"), UIS_SILVER | UIS_CENTER, false); AddSText(0, 14, _("in the shareware"), UIS_SILVER | UIS_CENTER, false); diff --git a/Source/trigs.cpp b/Source/trigs.cpp index f1c922130..e0d3985a4 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -5,6 +5,8 @@ */ #include "trigs.h" +#include + #include "control.h" #include "cursor.h" #include "error.h" @@ -394,7 +396,7 @@ bool ForceL1Trig() for (i = 0; L1UpList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L1UpList[i]) { if (currlevel > 1) - sprintf(infostr, _("Up to level %i"), currlevel - 1); + sprintf(infostr, fmt::format(_("Up to level %i"), currlevel - 1).c_str()); else strcpy(infostr, _("Up to town")); for (j = 0; j < numtrigs; j++) { @@ -408,7 +410,7 @@ bool ForceL1Trig() } for (i = 0; L1DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L1DownList[i]) { - sprintf(infostr, _("Down to level %i"), currlevel + 1); + sprintf(infostr, fmt::format(_("Down to level %i"), currlevel + 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -421,7 +423,7 @@ bool ForceL1Trig() } else { for (i = 0; L5UpList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L5UpList[i]) { - sprintf(infostr, _("Up to Crypt level %i"), currlevel - 21); + sprintf(infostr, fmt::format(_("Up to Crypt level %i"), currlevel - 21).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABPREVLVL) { cursmx = trigs[j].position.x; @@ -437,7 +439,7 @@ bool ForceL1Trig() } for (i = 0; L5DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L5DownList[i]) { - sprintf(infostr, _("Down to Crypt level %i"), currlevel - 19); + sprintf(infostr, fmt::format(_("Down to Crypt level %i"), currlevel - 19).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -481,7 +483,7 @@ bool ForceL2Trig() dx = abs(trigs[j].position.x - cursmx); dy = abs(trigs[j].position.y - cursmy); if (dx < 4 && dy < 4) { - sprintf(infostr, _("Up to level %i"), currlevel - 1); + sprintf(infostr, fmt::format(_("Up to level %i"), currlevel - 1).c_str()); cursmx = trigs[j].position.x; cursmy = trigs[j].position.y; return true; @@ -493,7 +495,7 @@ bool ForceL2Trig() for (i = 0; L2DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L2DownList[i]) { - sprintf(infostr, _("Down to level %i"), currlevel + 1); + sprintf(infostr, fmt::format(_("Down to level %i"), currlevel + 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -533,7 +535,7 @@ bool ForceL3Trig() if (currlevel < 17) { for (i = 0; L3UpList[i] != -1; ++i) { if (dPiece[cursmx][cursmy] == L3UpList[i]) { - sprintf(infostr, _("Up to level %i"), currlevel - 1); + sprintf(infostr, fmt::format(_("Up to level %i"), currlevel - 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABPREVLVL) { cursmx = trigs[j].position.x; @@ -547,7 +549,7 @@ bool ForceL3Trig() if (dPiece[cursmx][cursmy] == L3DownList[i] || dPiece[cursmx + 1][cursmy] == L3DownList[i] || dPiece[cursmx + 2][cursmy] == L3DownList[i]) { - sprintf(infostr, _("Down to level %i"), currlevel + 1); + sprintf(infostr, fmt::format(_("Down to level %i"), currlevel + 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -560,7 +562,7 @@ bool ForceL3Trig() } else { for (i = 0; L6UpList[i] != -1; ++i) { if (dPiece[cursmx][cursmy] == L6UpList[i]) { - sprintf(infostr, _("Up to Nest level %i"), currlevel - 17); + sprintf(infostr, fmt::format(_("Up to Nest level %i"), currlevel - 17).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABPREVLVL) { cursmx = trigs[j].position.x; @@ -574,7 +576,7 @@ bool ForceL3Trig() if (dPiece[cursmx][cursmy] == L6DownList[i] || dPiece[cursmx + 1][cursmy] == L6DownList[i] || dPiece[cursmx + 2][cursmy] == L6DownList[i]) { - sprintf(infostr, _("Down to level %i"), currlevel - 15); + sprintf(infostr, fmt::format(_("Down to level %i"), currlevel - 15).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -632,7 +634,7 @@ bool ForceL4Trig() for (i = 0; L4UpList[i] != -1; ++i) { if (dPiece[cursmx][cursmy] == L4UpList[i]) { - sprintf(infostr, _("Up to level %i"), currlevel - 1); + sprintf(infostr, fmt::format(_("Up to level %i"), currlevel - 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABPREVLVL) { cursmx = trigs[j].position.x; @@ -645,7 +647,7 @@ bool ForceL4Trig() for (i = 0; L4DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L4DownList[i]) { - sprintf(infostr, _("Down to level %i"), currlevel + 1); + sprintf(infostr, fmt::format(_("Down to level %i"), currlevel + 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -715,7 +717,7 @@ bool ForceSKingTrig() for (i = 0; L1UpList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L1UpList[i]) { - sprintf(infostr, _("Back to Level %i"), quests[Q_SKELKING]._qlevel); + sprintf(infostr, fmt::format(_("Back to Level %i"), quests[Q_SKELKING]._qlevel).c_str()); cursmx = trigs[0].position.x; cursmy = trigs[0].position.y; @@ -732,7 +734,7 @@ bool ForceSChambTrig() for (i = 0; L2DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L2DownList[i]) { - sprintf(infostr, _("Back to Level %i"), quests[Q_SCHAMB]._qlevel); + sprintf(infostr, fmt::format(_("Back to Level %i"), quests[Q_SCHAMB]._qlevel).c_str()); cursmx = trigs[0].position.x; cursmy = trigs[0].position.y; @@ -749,7 +751,7 @@ bool ForcePWaterTrig() for (i = 0; L3DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L3DownList[i]) { - sprintf(infostr, _("Back to Level %i"), quests[Q_PWATER]._qlevel); + sprintf(infostr, fmt::format(_("Back to Level %i"), quests[Q_PWATER]._qlevel).c_str()); cursmx = trigs[0].position.x; cursmy = trigs[0].position.y;