From bbd39aa513caed2d660759b4ccb2894367419c1d Mon Sep 17 00:00:00 2001 From: Jmgr Date: Thu, 20 May 2021 21:47:41 +0100 Subject: [PATCH] Replace sprintfs with strcpy for translatable strings --- Source/DiabloUI/selconn.cpp | 2 +- Source/DiabloUI/selgame.cpp | 2 +- Source/DiabloUI/selhero.cpp | 4 +- Source/appfat.cpp | 4 +- Source/automap.cpp | 6 +- Source/control.cpp | 36 +++++------ Source/cursor.cpp | 2 +- Source/diablo.cpp | 6 +- Source/items.cpp | 126 ++++++++++++++++++------------------ Source/monster.cpp | 8 +-- Source/objects.cpp | 6 +- Source/player.cpp | 2 +- Source/plrmsg.cpp | 2 +- Source/qol/xpbar.cpp | 4 +- Source/quests.cpp | 2 +- Source/stores.cpp | 48 +++++++------- Source/trigs.cpp | 30 ++++----- 17 files changed, 145 insertions(+), 145 deletions(-) diff --git a/Source/DiabloUI/selconn.cpp b/Source/DiabloUI/selconn.cpp index 8fae53186..9ecf2b9ba 100644 --- a/Source/DiabloUI/selconn.cpp +++ b/Source/DiabloUI/selconn.cpp @@ -118,7 +118,7 @@ void SelconnFocus(int value) break; } - snprintf(selconn_MaxPlayers, sizeof(selconn_MaxPlayers), fmt::format(_("Players Supported: {:d}"), players).c_str()); + strncpy(selconn_MaxPlayers, fmt::format(_("Players Supported: {:d}"), players).c_str(), sizeof(selconn_MaxPlayers)); WordWrapArtStr(selconn_Description, DESCRIPTION_WIDTH); } diff --git a/Source/DiabloUI/selgame.cpp b/Source/DiabloUI/selgame.cpp index 1a844e595..6af7b07d5 100644 --- a/Source/DiabloUI/selgame.cpp +++ b/Source/DiabloUI/selgame.cpp @@ -414,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, fmt::format(_(/* TRANSLATORS: Error message when somebody tries to join a game running another version. */ "Your version {:s} does not match the host {:d}.{:d}.{:d}."), PROJECT_VERSION, PROJECT_VERSION_MAJOR, PROJECT_VERSION_MINOR, PROJECT_VERSION_PATCH).c_str()); + strcpy(msg, fmt::format(_(/* TRANSLATORS: Error message when somebody tries to join a game running another version. */ "Your version {:s} does not match the host {:d}.{:d}.{:d}."), 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 fcf365c4a..e06f1b55b 100644 --- a/Source/DiabloUI/selhero.cpp +++ b/Source/DiabloUI/selhero.cpp @@ -344,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), 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()); + strncpy(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(), sizeof(dialogText)); overwrite = UiSelHeroYesNoDialog(title, dialogText); LoadBackgroundArt("ui_art\\selhero.pcx"); @@ -621,7 +621,7 @@ static void UiSelHeroDialog( } else { strncpy(dialogTitle, _("Delete Single Player Hero"), sizeof(dialogTitle) - 1); } - snprintf(dialogText, sizeof(dialogText), fmt::format(_("Are you sure you want to delete the character \"{:s}\"?"), selhero_heroInfo.name).c_str()); + strncpy(dialogText, fmt::format(_("Are you sure you want to delete the character \"{:s}\"?"), selhero_heroInfo.name).c_str(), sizeof(dialogText)); if (UiSelHeroYesNoDialog(dialogTitle, dialogText)) fnremove(&selhero_heroInfo); diff --git a/Source/appfat.cpp b/Source/appfat.cpp index 43b78c3c0..4c9f08a68 100644 --- a/Source/appfat.cpp +++ b/Source/appfat.cpp @@ -116,7 +116,7 @@ void ErrDlg(const char *title, const char *error, const char *logFilePath, int l FreeDlg(); - snprintf(text, sizeof(text), fmt::format(_(/* TRANSLATORS: Error message that displays relevant information for bug report */ "{:s}\n\nThe error occurred at: {:s} line {:d}"), error, logFilePath, logLineNr).c_str()); + strncpy(text, fmt::format(_(/* TRANSLATORS: Error message that displays relevant information for bug report */ "{:s}\n\nThe error occurred at: {:s} line {:d}"), error, logFilePath, logLineNr).c_str(), sizeof(text)); UiErrorOkDialog(title, text); app_fatal(nullptr); @@ -175,7 +175,7 @@ void DirErrorDlg(const char *error) { char text[1024]; - 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()); + strncpy(text, fmt::format(_(/* TRANSLATORS: Error when Program is not allowed to write data */ "Unable to write to location:\n{:s}"), error).c_str(), sizeof(text)); UiErrorOkDialog(_("Read-Only Directory Error"), text); app_fatal(nullptr); diff --git a/Source/automap.cpp b/Source/automap.cpp index 92bda661d..6675eac31 100644 --- a/Source/automap.cpp +++ b/Source/automap.cpp @@ -404,11 +404,11 @@ void DrawAutomapText(const CelOutputBuffer &out) if (currlevel != 0) { if (currlevel >= 17 && currlevel <= 20) { - sprintf(desc, fmt::format(_("Level: Nest {:d}"), currlevel - 16).c_str()); + strcpy(desc, fmt::format(_("Level: Nest {:d}"), currlevel - 16).c_str()); } else if (currlevel >= 21 && currlevel <= 24) { - sprintf(desc, fmt::format(_("Level: Crypt {:d}"), currlevel - 20).c_str()); + strcpy(desc, fmt::format(_("Level: Crypt {:d}"), currlevel - 20).c_str()); } else { - sprintf(desc, fmt::format(_("Level: {:d}"), currlevel).c_str()); + strcpy(desc, fmt::format(_("Level: {:d}"), currlevel).c_str()); } DrawString(out, desc, { 8, nextLine, 0, 0 }); diff --git a/Source/control.cpp b/Source/control.cpp index 544142e1d..3442895fb 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -393,10 +393,10 @@ void DrawSpellList(const CelOutputBuffer &out) DrawSpellCel(out, x, y, *pSpellCels, c); switch (pSplType) { case RSPLTYPE_SKILL: - sprintf(infostr, fmt::format(_("{:s} Skill"), _(spelldata[pSpell].sSkillText)).c_str()); + strcpy(infostr, fmt::format(_("{:s} Skill"), _(spelldata[pSpell].sSkillText)).c_str()); break; case RSPLTYPE_SPELL: - sprintf(infostr, fmt::format(_("{:s} Spell"), _(spelldata[pSpell].sNameText)).c_str()); + strcpy(infostr, fmt::format(_("{:s} Spell"), _(spelldata[pSpell].sNameText)).c_str()); if (pSpell == SPL_HBOLT) { strcpy(tempstr, _("Damages undead only")); AddPanelString(tempstr); @@ -404,11 +404,11 @@ void DrawSpellList(const CelOutputBuffer &out) if (s == 0) strcpy(tempstr, _("Spell Level 0 - Unusable")); else - sprintf(tempstr, fmt::format(_("Spell Level {:d}"), s).c_str()); + strcpy(tempstr, fmt::format(_("Spell Level {:d}"), s).c_str()); AddPanelString(tempstr); break; case RSPLTYPE_SCROLL: { - sprintf(infostr, fmt::format(_("Scroll of {:s}"), _(spelldata[pSpell].sNameText)).c_str()); + strcpy(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() @@ -428,7 +428,7 @@ void DrawSpellList(const CelOutputBuffer &out) AddPanelString(tempstr); } break; case RSPLTYPE_CHARGES: { - sprintf(infostr, fmt::format(_("Staff of {:s}"), _(spelldata[pSpell].sNameText)).c_str()); + strcpy(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); @@ -440,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, fmt::format(_("Spell Hotkey {:s}"), hotkeyName.c_str()).c_str()); + strcpy(tempstr, fmt::format(_("Spell Hotkey {:s}"), hotkeyName.c_str()).c_str()); AddPanelString(tempstr); } } @@ -917,7 +917,7 @@ void CheckPanelInfo() strcpy(infostr, _("Player attack")); } if (PanBtnHotKey[i] != nullptr) { - sprintf(tempstr, fmt::format(_("Hotkey: {:s}"), _(PanBtnHotKey[i])).c_str()); + strcpy(tempstr, fmt::format(_("Hotkey: {:s}"), _(PanBtnHotKey[i])).c_str()); AddPanelString(tempstr); } infoclr = UIS_SILVER; @@ -936,11 +936,11 @@ void CheckPanelInfo() if (v != SPL_INVALID) { switch (plr[myplr]._pRSplType) { case RSPLTYPE_SKILL: - sprintf(tempstr, fmt::format(_("{:s} Skill"), _(spelldata[v].sSkillText)).c_str()); + strcpy(tempstr, fmt::format(_("{:s} Skill"), _(spelldata[v].sSkillText)).c_str()); AddPanelString(tempstr); break; case RSPLTYPE_SPELL: { - sprintf(tempstr, fmt::format(_("{:s} Spell"), _(spelldata[v].sNameText)).c_str()); + strcpy(tempstr, fmt::format(_("{:s} Spell"), _(spelldata[v].sNameText)).c_str()); AddPanelString(tempstr); int c = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[v]; if (c < 0) @@ -948,11 +948,11 @@ void CheckPanelInfo() if (c == 0) strcpy(tempstr, _("Spell Level 0 - Unusable")); else - sprintf(tempstr, fmt::format(_("Spell Level {:d}"), c).c_str()); + strcpy(tempstr, fmt::format(_("Spell Level {:d}"), c).c_str()); AddPanelString(tempstr); } break; case RSPLTYPE_SCROLL: { - sprintf(tempstr, fmt::format(_("Scroll of {:s}"), _(spelldata[v].sNameText)).c_str()); + strcpy(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++) { @@ -973,7 +973,7 @@ void CheckPanelInfo() AddPanelString(tempstr); } break; case RSPLTYPE_CHARGES: - sprintf(tempstr, fmt::format(_("Staff of {:s}"), _(spelldata[v].sNameText)).c_str()); + strcpy(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); @@ -1162,9 +1162,9 @@ void DrawInfoBox(const CelOutputBuffer &out) infoclr = UIS_GOLD; strcpy(infostr, plr[pcursplr]._pName); ClearPanel(); - sprintf(tempstr, fmt::format(_("{:s}, Level: {:d}"), _(ClassStrTbl[static_cast(plr[pcursplr]._pClass)]), plr[pcursplr]._pLevel).c_str()); + strcpy(tempstr, fmt::format(_("{:s}, Level: {:d}"), _(ClassStrTbl[static_cast(plr[pcursplr]._pClass)]), plr[pcursplr]._pLevel).c_str()); AddPanelString(tempstr); - sprintf(tempstr, fmt::format(_("Hit Points {:d} of {:d}"), plr[pcursplr]._pHitPoints >> 6, plr[pcursplr]._pMaxHP >> 6).c_str()); + strcpy(tempstr, fmt::format(_("Hit Points {:d} of {:d}"), plr[pcursplr]._pHitPoints >> 6, plr[pcursplr]._pMaxHP >> 6).c_str()); AddPanelString(tempstr); } } @@ -1627,12 +1627,12 @@ void DrawSpellBook(const CelOutputBuffer &out) int max; GetDamageAmt(sn, &min, &max); if (min != -1) { - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: {:d} Dam: {:d} - {:d}"), mana, min, max).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: {:d} Dam: {:d} - {:d}"), mana, min, max).c_str()); } else { - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: {:d} Dam: n/a"), mana).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: {:d} Dam: n/a"), mana).c_str()); } if (sn == SPL_BONESPIRIT) { - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: {:d} Dam: 1/3 tgt hp"), mana).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: Dam refers to damage. UI constrains, keep short please.*/ "Mana: {:d} Dam: 1/3 tgt hp"), mana).c_str()); } PrintSBookStr(out, 10, yp - 1, tempstr); int lvl = plr[myplr]._pSplLvl[sn] + plr[myplr]._pISplLvlAdd; @@ -1642,7 +1642,7 @@ void DrawSpellBook(const CelOutputBuffer &out) if (lvl == 0) { strcpy(tempstr, _("Spell Level 0 - Unusable")); } else { - sprintf(tempstr, fmt::format(_("Spell Level {:d}"), lvl).c_str()); + strcpy(tempstr, fmt::format(_("Spell Level {:d}"), lvl).c_str()); } } break; } diff --git a/Source/cursor.cpp b/Source/cursor.cpp index ab443fdf5..eccef3b99 100644 --- a/Source/cursor.cpp +++ b/Source/cursor.cpp @@ -205,7 +205,7 @@ void CheckTown() trigflag = true; ClearPanel(); strcpy(infostr, _("Town Portal")); - sprintf(tempstr, fmt::format(_("from {:s}"), plr[missile[mx]._misource]._pName).c_str()); + strcpy(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 98a9ab6c7..db8103ec0 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -283,7 +283,7 @@ static void diablo_parse_flags(int argc, char **argv) debug_mode_key_w = true; #endif } else { - printInConsole(fmt::format(_("unrecognized option '{:s}'\n"), argv[i]).c_str()); + printInConsole("%s", fmt::format(_("unrecognized option '{:s}'\n"), argv[i]).c_str()); print_help_and_exit(); } } @@ -671,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), fmt::format(_("version {:s}"), PROJECT_VERSION).c_str()); + strncpy(gszVersionNumber, fmt::format(_("version {:s}"), PROJECT_VERSION).c_str(), sizeof(gszVersionNumber) / sizeof(char)); } static void diablo_init() @@ -2203,7 +2203,7 @@ void initKeymapActions() _("Nightmare"), _("Hell"), }; - 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()); + strcpy(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 425f2ffa6..3dae184d8 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -1526,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, 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(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); @@ -1568,8 +1568,8 @@ void GetStaffSpell(int i, int lvl, bool onlygood) s = SPL_FIREBOLT; } if (!control_WriteStringToBuffer(istr)) - 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(istr, fmt::format(_("{:s} of {:s}"), items[i]._iName, _(spelldata[bs].sNameText)).c_str()); + strcpy(istr, fmt::format(_("Staff of {:s}"), _(spelldata[bs].sNameText)).c_str()); strcpy(items[i]._iName, istr); strcpy(items[i]._iIName, istr); @@ -2163,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, fmt::format(_("{:s} of {:s}"), items[i]._iIName, _(PL_Suffix[sufidx].PLName)).c_str()); + strcpy(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); @@ -2182,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, fmt::format(_("{:s} of {:s}"), items[i]._iIName, _(PL_Suffix[sufidx].PLName)).c_str()); + strcpy(istr, fmt::format(_("{:s} of {:s}"), items[i]._iIName, _(PL_Suffix[sufidx].PLName)).c_str()); strcpy(items[i]._iIName, istr); } } @@ -2746,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, fmt::format(_(/* TRANSLATORS: {:s} will be a Character Name */ "Ear of {:s}"), tempstr).c_str()); + strcpy(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; @@ -3414,51 +3414,51 @@ void PrintItemPower(char plidx, ItemStruct *x) switch (plidx) { case IPL_TOHIT: case IPL_TOHIT_CURSE: - sprintf(tempstr, fmt::format(_("chance to hit: {:+d}%"), x->_iPLToHit).c_str()); + strcpy(tempstr, fmt::format(_("chance to hit: {:+d}%"), x->_iPLToHit).c_str()); break; case IPL_DAMP: case IPL_DAMP_CURSE: - sprintf(tempstr, fmt::format(_("{:+d}% damage"), x->_iPLDam).c_str()); + strcpy(tempstr, fmt::format(_("{:+d}% damage"), x->_iPLDam).c_str()); break; case IPL_TOHIT_DAMP: case IPL_TOHIT_DAMP_CURSE: - sprintf(tempstr, fmt::format(_("to hit: {:+d}%, {:+d}% damage"), x->_iPLToHit, x->_iPLDam).c_str()); + strcpy(tempstr, fmt::format(_("to hit: {:+d}%, {:+d}% damage"), x->_iPLToHit, x->_iPLDam).c_str()); break; case IPL_ACP: case IPL_ACP_CURSE: - sprintf(tempstr, fmt::format(_("{:+d}% armor"), x->_iPLAC).c_str()); + strcpy(tempstr, fmt::format(_("{:+d}% armor"), x->_iPLAC).c_str()); break; case IPL_SETAC: - sprintf(tempstr, fmt::format(_("armor class: {:d}"), x->_iAC).c_str()); + strcpy(tempstr, fmt::format(_("armor class: {:d}"), x->_iAC).c_str()); break; case IPL_AC_CURSE: - sprintf(tempstr, fmt::format(_("armor class: {:d}"), x->_iAC).c_str()); + strcpy(tempstr, fmt::format(_("armor class: {:d}"), x->_iAC).c_str()); break; case IPL_FIRERES: case IPL_FIRERES_CURSE: if (x->_iPLFR < 75) - sprintf(tempstr, fmt::format(_("Resist Fire: {:+d}%"), x->_iPLFR).c_str()); + strcpy(tempstr, fmt::format(_("Resist Fire: {:+d}%"), 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, fmt::format(_("Resist Lightning: {:+d}%"), x->_iPLLR).c_str()); + strcpy(tempstr, fmt::format(_("Resist Lightning: {:+d}%"), 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, fmt::format(_("Resist Magic: {:+d}%"), x->_iPLMR).c_str()); + strcpy(tempstr, fmt::format(_("Resist Magic: {:+d}%"), 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, fmt::format(_("Resist All: {:+d}%"), x->_iPLFR).c_str()); + strcpy(tempstr, fmt::format(_("Resist All: {:+d}%"), x->_iPLFR).c_str()); if (x->_iPLFR >= 75) /*xgettext:no-c-format*/ strcpy(tempstr, _("Resist All: 75% MAX")); break; @@ -3478,47 +3478,47 @@ void PrintItemPower(char plidx, ItemStruct *x) break; case IPL_FIREDAM: if (x->_iFMinDam == x->_iFMaxDam) - sprintf(tempstr, fmt::format(_("Fire hit damage: {:d}"), x->_iFMinDam).c_str()); + strcpy(tempstr, fmt::format(_("Fire hit damage: {:d}"), x->_iFMinDam).c_str()); else - sprintf(tempstr, fmt::format(_("Fire hit damage: {:d}-{:d}"), x->_iFMinDam, x->_iFMaxDam).c_str()); + strcpy(tempstr, fmt::format(_("Fire hit damage: {:d}-{:d}"), x->_iFMinDam, x->_iFMaxDam).c_str()); break; case IPL_LIGHTDAM: if (x->_iLMinDam == x->_iLMaxDam) - sprintf(tempstr, fmt::format(_("Lightning hit damage: {:d}"), x->_iLMinDam).c_str()); + strcpy(tempstr, fmt::format(_("Lightning hit damage: {:d}"), x->_iLMinDam).c_str()); else - sprintf(tempstr, fmt::format(_("Lightning hit damage: {:d}-{:d}"), x->_iLMinDam, x->_iLMaxDam).c_str()); + strcpy(tempstr, fmt::format(_("Lightning hit damage: {:d}-{:d}"), x->_iLMinDam, x->_iLMaxDam).c_str()); break; case IPL_STR: case IPL_STR_CURSE: - sprintf(tempstr, fmt::format(_("{:+d} to strength"), x->_iPLStr).c_str()); + strcpy(tempstr, fmt::format(_("{:+d} to strength"), x->_iPLStr).c_str()); break; case IPL_MAG: case IPL_MAG_CURSE: - sprintf(tempstr, fmt::format(_("{:+d} to magic"), x->_iPLMag).c_str()); + strcpy(tempstr, fmt::format(_("{:+d} to magic"), x->_iPLMag).c_str()); break; case IPL_DEX: case IPL_DEX_CURSE: - sprintf(tempstr, fmt::format(_("{:+d} to dexterity"), x->_iPLDex).c_str()); + strcpy(tempstr, fmt::format(_("{:+d} to dexterity"), x->_iPLDex).c_str()); break; case IPL_VIT: case IPL_VIT_CURSE: - sprintf(tempstr, fmt::format(_("{:+d} to vitality"), x->_iPLVit).c_str()); + strcpy(tempstr, fmt::format(_("{:+d} to vitality"), x->_iPLVit).c_str()); break; case IPL_ATTRIBS: case IPL_ATTRIBS_CURSE: - sprintf(tempstr, fmt::format(_("{:+d} to all attributes"), x->_iPLStr).c_str()); + strcpy(tempstr, fmt::format(_("{:+d} to all attributes"), x->_iPLStr).c_str()); break; case IPL_GETHIT_CURSE: case IPL_GETHIT: - sprintf(tempstr, fmt::format(_("{:+d} damage from enemies"), x->_iPLGetHit).c_str()); + strcpy(tempstr, fmt::format(_("{:+d} damage from enemies"), x->_iPLGetHit).c_str()); break; case IPL_LIFE: case IPL_LIFE_CURSE: - sprintf(tempstr, fmt::format(_("Hit Points: {:+d}"), x->_iPLHP >> 6).c_str()); + strcpy(tempstr, fmt::format(_("Hit Points: {:+d}"), x->_iPLHP >> 6).c_str()); break; case IPL_MANA: case IPL_MANA_CURSE: - sprintf(tempstr, fmt::format(_("Mana: {:+d}"), x->_iPLMana >> 6).c_str()); + strcpy(tempstr, fmt::format(_("Mana: {:+d}"), x->_iPLMana >> 6).c_str()); break; case IPL_DUR: strcpy(tempstr, _("high durability")); @@ -3530,31 +3530,31 @@ void PrintItemPower(char plidx, ItemStruct *x) strcpy(tempstr, _("indestructible")); break; case IPL_LIGHT: - sprintf(tempstr, fmt::format(_("+{:d}% light radius"), 10 * x->_iPLLight).c_str()); + strcpy(tempstr, fmt::format(_("+{:d}% light radius"), 10 * x->_iPLLight).c_str()); break; case IPL_LIGHT_CURSE: - sprintf(tempstr, fmt::format(_("-{:d}% light radius"), -10 * x->_iPLLight).c_str()); + strcpy(tempstr, fmt::format(_("-{:d}% 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, fmt::format(_("fire arrows damage: {:d}"), x->_iFMinDam).c_str()); + strcpy(tempstr, fmt::format(_("fire arrows damage: {:d}"), x->_iFMinDam).c_str()); else - sprintf(tempstr, fmt::format(_("fire arrows damage: {:d}-{:d}"), x->_iFMinDam, x->_iFMaxDam).c_str()); + strcpy(tempstr, fmt::format(_("fire arrows damage: {:d}-{:d}"), x->_iFMinDam, x->_iFMaxDam).c_str()); break; case IPL_LIGHT_ARROWS: if (x->_iLMinDam == x->_iLMaxDam) - sprintf(tempstr, fmt::format(_("lightning arrows damage {:d}"), x->_iLMinDam).c_str()); + strcpy(tempstr, fmt::format(_("lightning arrows damage {:d}"), x->_iLMinDam).c_str()); else - sprintf(tempstr, fmt::format(_("lightning arrows damage {:d}-{:d}"), x->_iLMinDam, x->_iLMaxDam).c_str()); + strcpy(tempstr, fmt::format(_("lightning arrows damage {:d}-{:d}"), x->_iLMinDam, x->_iLMaxDam).c_str()); break; case IPL_FIREBALL: if (x->_iFMinDam == x->_iFMaxDam) - sprintf(tempstr, fmt::format(_("fireball damage: {:d}"), x->_iFMinDam).c_str()); + strcpy(tempstr, fmt::format(_("fireball damage: {:d}"), x->_iFMinDam).c_str()); else - sprintf(tempstr, fmt::format(_("fireball damage: {:d}-{:d}"), x->_iFMinDam, x->_iFMaxDam).c_str()); + strcpy(tempstr, fmt::format(_("fireball damage: {:d}-{:d}"), x->_iFMinDam, x->_iFMaxDam).c_str()); break; case IPL_THORNS: strcpy(tempstr, _("attacker takes 1-3 damage")); @@ -3651,9 +3651,9 @@ void PrintItemPower(char plidx, ItemStruct *x) break; case IPL_ADDACLIFE: if (x->_iFMinDam == x->_iFMaxDam) - sprintf(tempstr, fmt::format(_("lightning damage: {:d}"), x->_iFMinDam).c_str()); + strcpy(tempstr, fmt::format(_("lightning damage: {:d}"), x->_iFMinDam).c_str()); else - sprintf(tempstr, fmt::format(_("lightning damage: {:d}-{:d}"), x->_iFMinDam, x->_iFMaxDam).c_str()); + strcpy(tempstr, fmt::format(_("lightning damage: {:d}-{:d}"), x->_iFMinDam, x->_iFMaxDam).c_str()); break; case IPL_ADDMANAAC: strcpy(tempstr, _("charged bolts on hits")); @@ -3662,13 +3662,13 @@ void PrintItemPower(char plidx, ItemStruct *x) if (x->_iPLFR <= 0) strcpy(tempstr, " "); else if (x->_iPLFR >= 1) - sprintf(tempstr, fmt::format(_("Resist Fire: {:+d}%"), x->_iPLFR).c_str()); + strcpy(tempstr, fmt::format(_("Resist Fire: {:+d}%"), x->_iPLFR).c_str()); break; case IPL_DEVASTATION: strcpy(tempstr, _("occasional triple damage")); break; case IPL_DECAY: - sprintf(tempstr, fmt::format(_("decaying {:+d}% damage"), x->_iPLDam).c_str()); + strcpy(tempstr, fmt::format(_("decaying {:+d}% damage"), x->_iPLDam).c_str()); break; case IPL_PERIL: strcpy(tempstr, _("2x dmg to monst, 1x to you")); @@ -3677,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, fmt::format(_("low dur, {:+d}% damage"), x->_iPLDam).c_str()); + strcpy(tempstr, fmt::format(_("low dur, {:+d}% damage"), x->_iPLDam).c_str()); break; case IPL_DOPPELGANGER: - sprintf(tempstr, fmt::format(_("to hit: {:+d}%, {:+d}% damage"), x->_iPLToHit, x->_iPLDam).c_str()); + strcpy(tempstr, fmt::format(_("to hit: {:+d}%, {:+d}% damage"), x->_iPLToHit, x->_iPLDam).c_str()); break; case IPL_ACDEMON: strcpy(tempstr, _("extra AC vs demons")); @@ -3799,7 +3799,7 @@ void PrintItemMisc(ItemStruct *x) AddPanelString(tempstr); } if (x->_iMiscId == IMISC_EAR) { - sprintf(tempstr, fmt::format(_("Level: {:d}"), x->_ivalue).c_str()); + strcpy(tempstr, fmt::format(_("Level: {:d}"), x->_ivalue).c_str()); AddPanelString(tempstr); } if (x->_iMiscId == IMISC_AURIC) { @@ -3817,11 +3817,11 @@ static void PrintItemInfo(ItemStruct *x) if (str != 0 || mag != 0 || dex != 0) { strcpy(tempstr, _("Required:")); if (str) - sprintf(tempstr + strlen(tempstr), fmt::format(_(" {:d} Str"), str).c_str()); + strcpy(tempstr + strlen(tempstr), fmt::format(_(" {:d} Str"), str).c_str()); if (mag) - sprintf(tempstr + strlen(tempstr), fmt::format(_(" {:d} Mag"), mag).c_str()); + strcpy(tempstr + strlen(tempstr), fmt::format(_(" {:d} Mag"), mag).c_str()); if (dex) - sprintf(tempstr + strlen(tempstr), fmt::format(_(" {:d} Dex"), dex).c_str()); + strcpy(tempstr + strlen(tempstr), fmt::format(_(" {:d} Dex"), dex).c_str()); AddPanelString(tempstr); } pinfoflag = true; @@ -3832,30 +3832,30 @@ void PrintItemDetails(ItemStruct *x) if (x->_iClass == ICLASS_WEAPON) { if (x->_iMinDam == x->_iMaxDam) { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, fmt::format(_("damage: {:d} Indestructible"), x->_iMinDam).c_str()); + strcpy(tempstr, fmt::format(_("damage: {:d} Indestructible"), x->_iMinDam).c_str()); else - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dur: is durability */ "damage: {:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iDurability, x->_iMaxDur).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: Dur: is durability */ "damage: {:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iDurability, x->_iMaxDur).c_str()); } else { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, fmt::format(_("damage: {:d}-{:d} Indestructible"), x->_iMinDam, x->_iMaxDam).c_str()); + strcpy(tempstr, fmt::format(_("damage: {:d}-{:d} Indestructible"), x->_iMinDam, x->_iMaxDam).c_str()); else - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dur: is durability */ "damage: {:d}-{:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: Dur: is durability */ "damage: {:d}-{:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur).c_str()); } AddPanelString(tempstr); } if (x->_iClass == ICLASS_ARMOR) { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, fmt::format(_("armor: {:d} Indestructible"), x->_iAC).c_str()); + strcpy(tempstr, fmt::format(_("armor: {:d} Indestructible"), x->_iAC).c_str()); else - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: Dur: is durability */ "armor: {:d} Dur: {:d}/{:d}"), x->_iAC, x->_iDurability, x->_iMaxDur).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: Dur: is durability */ "armor: {:d} Dur: {:d}/{:d}"), 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, fmt::format(_(/* TRANSLATORS: dam: is damage Dur: is durability */ "dam: {:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iDurability, x->_iMaxDur).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: dam: is damage Dur: is durability */ "dam: {:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iDurability, x->_iMaxDur).c_str()); else - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: dam: is damage Dur: is durability */ "dam: {:d}-{:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur).c_str()); - sprintf(tempstr, fmt::format(_("Charges: {:d}/{:d}"), x->_iCharges, x->_iMaxCharges).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: dam: is damage Dur: is durability */ "dam: {:d}-{:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur).c_str()); + strcpy(tempstr, fmt::format(_("Charges: {:d}/{:d}"), x->_iCharges, x->_iMaxCharges).c_str()); AddPanelString(tempstr); } if (x->_iPrePower != -1) { @@ -3879,18 +3879,18 @@ void PrintItemDur(ItemStruct *x) if (x->_iClass == ICLASS_WEAPON) { if (x->_iMinDam == x->_iMaxDam) { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, fmt::format(_("damage: {:d} Indestructible"), x->_iMinDam).c_str()); + strcpy(tempstr, fmt::format(_("damage: {:d} Indestructible"), x->_iMinDam).c_str()); else - sprintf(tempstr, fmt::format(_("damage: {:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iDurability, x->_iMaxDur).c_str()); + strcpy(tempstr, fmt::format(_("damage: {:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iDurability, x->_iMaxDur).c_str()); } else { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, fmt::format(_("damage: {:d}-{:d} Indestructible"), x->_iMinDam, x->_iMaxDam).c_str()); + strcpy(tempstr, fmt::format(_("damage: {:d}-{:d} Indestructible"), x->_iMinDam, x->_iMaxDam).c_str()); else - sprintf(tempstr, fmt::format(_("damage: {:d}-{:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur).c_str()); + strcpy(tempstr, fmt::format(_("damage: {:d}-{:d} Dur: {:d}/{:d}"), x->_iMinDam, x->_iMaxDam, x->_iDurability, x->_iMaxDur).c_str()); } AddPanelString(tempstr); if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) { - sprintf(tempstr, fmt::format(_("Charges: {:d}/{:d}"), x->_iCharges, x->_iMaxCharges).c_str()); + strcpy(tempstr, fmt::format(_("Charges: {:d}/{:d}"), x->_iCharges, x->_iMaxCharges).c_str()); AddPanelString(tempstr); } if (x->_iMagical != ITEM_QUALITY_NORMAL) @@ -3898,14 +3898,14 @@ void PrintItemDur(ItemStruct *x) } if (x->_iClass == ICLASS_ARMOR) { if (x->_iMaxDur == DUR_INDESTRUCTIBLE) - sprintf(tempstr, fmt::format(_("armor: {:d} Indestructible"), x->_iAC).c_str()); + strcpy(tempstr, fmt::format(_("armor: {:d} Indestructible"), x->_iAC).c_str()); else - sprintf(tempstr, fmt::format(_("armor: {:d} Dur: {:d}/{:d}"), x->_iAC, x->_iDurability, x->_iMaxDur).c_str()); + strcpy(tempstr, fmt::format(_("armor: {:d} Dur: {:d}/{:d}"), 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, fmt::format(_("Charges: {:d}/{:d}"), x->_iCharges, x->_iMaxCharges).c_str()); + strcpy(tempstr, fmt::format(_("Charges: {:d}/{:d}"), x->_iCharges, x->_iMaxCharges).c_str()); AddPanelString(tempstr); } } diff --git a/Source/monster.cpp b/Source/monster.cpp index aabee38a4..b565db8b0 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4965,9 +4965,9 @@ void PrintMonstHistory(int mt) int minHP, maxHP, res; if (sgOptions.Gameplay.bShowMonsterType) { - sprintf(tempstr, fmt::format(_("Type: {:s} Kills: {:d}"), GetMonsterTypeText(monsterdata[mt])).c_str(), monstkills[mt]); + strcpy(tempstr, fmt::format(_("Type: {:s} Kills: {:d}"), GetMonsterTypeText(monsterdata[mt]), monstkills[mt]).c_str()); } else { - sprintf(tempstr, fmt::format(_("Total kills: {:d}"), monstkills[mt]).c_str()); + strcpy(tempstr, fmt::format(_("Total kills: {:d}"), monstkills[mt]).c_str()); } AddPanelString(tempstr); @@ -5000,7 +5000,7 @@ void PrintMonstHistory(int mt) minHP = 4 * minHP + hpBonusHell; maxHP = 4 * maxHP + hpBonusHell; } - sprintf(tempstr, fmt::format(_("Hit Points: {:d}-{:d}"), minHP, maxHP).c_str()); + strcpy(tempstr, fmt::format(_("Hit Points: {:d}-{:d}"), minHP, maxHP).c_str()); AddPanelString(tempstr); } if (monstkills[mt] >= 15) { @@ -5045,7 +5045,7 @@ void PrintUniqueHistory() int res; if (sgOptions.Gameplay.bShowMonsterType) { - sprintf(tempstr, fmt::format(_("Type: {:s}"), GetMonsterTypeText(*monster[pcursmonst].MData)).c_str()); + strcpy(tempstr, fmt::format(_("Type: {:s}"), GetMonsterTypeText(*monster[pcursmonst].MData)).c_str()); AddPanelString(tempstr); } diff --git a/Source/objects.cpp b/Source/objects.cpp index 969e211e6..acde97e16 100644 --- a/Source/objects.cpp +++ b/Source/objects.cpp @@ -5501,7 +5501,7 @@ void GetObjectStr(int i) break; case OBJ_SHRINEL: case OBJ_SHRINER: - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: {:s} will be a name from the Shrine block above */ "{:s} Shrine"), _(shrinestrs[object[i]._oVar1])).c_str()); + strcpy(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, fmt::format(_(/* TRANSLATORS: {:s} will either be a chest or a door */ "Trapped {:s}"), infostr).c_str()); + strcpy(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, 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(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 36ce8dcbc..1b75eb0d3 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -1886,7 +1886,7 @@ StartPlayerKill(int pnum, int earflag) if (earflag != -1) { if (earflag != 0) { SetPlrHandItem(&ear, IDI_EAR); - sprintf(ear._iName, fmt::format(_("Ear of {:s}"), player._pName).c_str()); + strcpy(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 cc3ca8e07..6725d246b 100644 --- a/Source/plrmsg.cpp +++ b/Source/plrmsg.cpp @@ -72,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, fmt::format(_(/* TRANSLATORS: Shown if player presses "v" button. {:s} is player name, {:d} is level, {:s} is location */ "{:s} (lvl {:d}): {:s}"), plr[pnum]._pName, plr[pnum]._pLevel, pszStr).c_str()); + strcpy(pMsg->str, fmt::format(_(/* TRANSLATORS: Shown if player presses "v" button. {:s} is player name, {:d} is level, {:s} is location */ "{:s} (lvl {:d}): {: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 7a69f880d..35b1b4f98 100644 --- a/Source/qol/xpbar.cpp +++ b/Source/qol/xpbar.cpp @@ -123,7 +123,7 @@ bool CheckXPBarInfo() const int charLevel = player._pLevel; - sprintf(tempstr, fmt::format(_("Level {:d}"), charLevel).c_str()); + strcpy(tempstr, fmt::format(_("Level {:d}"), charLevel).c_str()); AddPanelString(tempstr); if (charLevel == MAXCHARLEVEL - 1) { @@ -149,7 +149,7 @@ bool CheckXPBarInfo() PrintWithSeparator(tempstr + SDL_arraysize("Next Level: ") - 1, ExpLvlsTbl[charLevel]); AddPanelString(tempstr); - sprintf(PrintWithSeparator(tempstr, ExpLvlsTbl[charLevel] - player._pExperience), fmt::format(_(" to Level {:d}"), charLevel + 1).c_str()); + strcpy(PrintWithSeparator(tempstr, ExpLvlsTbl[charLevel] - player._pExperience), fmt::format(_(" to Level {:d}"), charLevel + 1).c_str()); AddPanelString(tempstr); return true; diff --git a/Source/quests.cpp b/Source/quests.cpp index a5d1074cc..23550a572 100644 --- a/Source/quests.cpp +++ b/Source/quests.cpp @@ -281,7 +281,7 @@ bool ForceQuests() for (j = 0; j < 7; j++) { if (qx + questxoff[j] == cursmx && qy + questyoff[j] == cursmy) { - sprintf(infostr, fmt::format(_(/* TRANSLATORS: Used for Quest Portals. {:s} is a Map Name */ "To {:s}"), _(questtrigstr[ql])).c_str()); + strcpy(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; diff --git a/Source/stores.cpp b/Source/stores.cpp index bb0923a42..12ee98a19 100644 --- a/Source/stores.cpp +++ b/Source/stores.cpp @@ -169,7 +169,7 @@ void PrintStoreItem(ItemStruct *x, int l, uint16_t flags) } } if (x->_iMiscId == IMISC_STAFF && x->_iMaxCharges) { - sprintf(tempstr, fmt::format(_("Charges: {:d}/{:d}"), x->_iCharges, x->_iMaxCharges).c_str()); + strcpy(tempstr, fmt::format(_("Charges: {:d}/{:d}"), x->_iCharges, x->_iMaxCharges).c_str()); if (sstr[0]) strcat(sstr, _(", ")); strcat(sstr, tempstr); @@ -180,11 +180,11 @@ void PrintStoreItem(ItemStruct *x, int l, uint16_t flags) } sstr[0] = '\0'; if (x->_iClass == ICLASS_WEAPON) - sprintf(sstr, fmt::format(_("Damage: {:d}-{:d} "), x->_iMinDam, x->_iMaxDam).c_str()); + strcpy(sstr, fmt::format(_("Damage: {:d}-{:d} "), x->_iMinDam, x->_iMaxDam).c_str()); if (x->_iClass == ICLASS_ARMOR) - sprintf(sstr, fmt::format(_("Armor: {:d} "), x->_iAC).c_str()); + strcpy(sstr, fmt::format(_("Armor: {:d} "), x->_iAC).c_str()); if (x->_iMaxDur != DUR_INDESTRUCTIBLE && x->_iMaxDur) { - sprintf(tempstr, fmt::format(_("Dur: {:d}/{:d}, "), x->_iDurability, x->_iMaxDur).c_str()); + strcpy(tempstr, fmt::format(_("Dur: {:d}/{:d}, "), x->_iDurability, x->_iMaxDur).c_str()); strcat(sstr, tempstr); } else { strcat(sstr, _("Indestructible, ")); @@ -199,11 +199,11 @@ void PrintStoreItem(ItemStruct *x, int l, uint16_t flags) } else { strcpy(tempstr, _("Required:")); if (str) - sprintf(tempstr + strlen(tempstr), fmt::format(_(" {:d} Str"), str).c_str()); + strcpy(tempstr + strlen(tempstr), fmt::format(_(" {:d} Str"), str).c_str()); if (mag) - sprintf(tempstr + strlen(tempstr), fmt::format(_(" {:d} Mag"), mag).c_str()); + strcpy(tempstr + strlen(tempstr), fmt::format(_(" {:d} Mag"), mag).c_str()); if (dex) - sprintf(tempstr + strlen(tempstr), fmt::format(_(" {:d} Dex"), dex).c_str()); + strcpy(tempstr + strlen(tempstr), fmt::format(_(" {:d} Dex"), dex).c_str()); strcat(sstr, tempstr); } AddSText(40, l++, sstr, flags, false); @@ -274,7 +274,7 @@ void S_StartSBuy() stextsize = true; stextscrl = true; stextsval = 0; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -339,7 +339,7 @@ bool S_StartSPBuy() stextscrl = true; stextsval = 0; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these premium items for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these premium items for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -467,7 +467,7 @@ void S_StartSSell() if (!sellok) { stextscrl = false; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing I want. Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing I want. Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -477,7 +477,7 @@ void S_StartSSell() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Which item is for sale? Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Which item is for sale? Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -537,7 +537,7 @@ void S_StartSRepair() } if (!repairok) { stextscrl = false; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to repair. Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to repair. Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -549,7 +549,7 @@ void S_StartSRepair() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Repair which item? Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Repair which item? Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -623,7 +623,7 @@ void S_StartWBuy() stextscrl = true; stextsval = 0; stextsmax = 20; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -717,7 +717,7 @@ void S_StartWSell() if (!sellok) { stextscrl = false; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing I want. Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing I want. Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -727,7 +727,7 @@ void S_StartWSell() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Which item is for sale? Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Which item is for sale? Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -793,7 +793,7 @@ void S_StartWRecharge() if (!rechargeok) { stextscrl = false; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to recharge. Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to recharge. Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -803,7 +803,7 @@ void S_StartWRecharge() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Recharge which item? Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Recharge which item? Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -915,7 +915,7 @@ void S_StartBBoy() { stextsize = true; stextscrl = false; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have this item for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have this item for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -989,7 +989,7 @@ void S_StartHBuy() stextsize = true; stextscrl = true; stextsval = 0; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "I have these items for sale: Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -1090,7 +1090,7 @@ void S_StartSIdentify() if (!idok) { stextscrl = false; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to identify. Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "You have nothing to identify. Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -1100,7 +1100,7 @@ void S_StartSIdentify() stextscrl = true; stextsval = 0; stextsmax = plr[myplr]._pNumInv; - sprintf(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Identify which item? Your gold: {:d}"), plr[myplr]._pGold).c_str()); + strcpy(tempstr, fmt::format(_(/* TRANSLATORS: This text is white space sensitive. Check for correct alignment! */ "Identify which item? Your gold: {:d}"), plr[myplr]._pGold).c_str()); AddSText(0, 1, tempstr, UIS_GOLD | UIS_CENTER, false); AddSLine(3); AddSLine(21); @@ -1129,11 +1129,11 @@ void S_StartTalk() stextsize = false; stextscrl = false; - sprintf(tempstr, fmt::format(_("Talk to {:s}"), talkname[talker]).c_str()); + strcpy(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, fmt::format(_("Talking to {:s}"), talkname[talker]).c_str()); + strcpy(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 0aa4f3545..78ce5046b 100644 --- a/Source/trigs.cpp +++ b/Source/trigs.cpp @@ -396,7 +396,7 @@ bool ForceL1Trig() for (i = 0; L1UpList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L1UpList[i]) { if (currlevel > 1) - sprintf(infostr, fmt::format(_("Up to level {:d}"), currlevel - 1).c_str()); + strcpy(infostr, fmt::format(_("Up to level {:d}"), currlevel - 1).c_str()); else strcpy(infostr, _("Up to town")); for (j = 0; j < numtrigs; j++) { @@ -410,7 +410,7 @@ bool ForceL1Trig() } for (i = 0; L1DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L1DownList[i]) { - sprintf(infostr, fmt::format(_("Down to level {:d}"), currlevel + 1).c_str()); + strcpy(infostr, fmt::format(_("Down to level {:d}"), currlevel + 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -423,7 +423,7 @@ bool ForceL1Trig() } else { for (i = 0; L5UpList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L5UpList[i]) { - sprintf(infostr, fmt::format(_("Up to Crypt level {:d}"), currlevel - 21).c_str()); + strcpy(infostr, fmt::format(_("Up to Crypt level {:d}"), currlevel - 21).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABPREVLVL) { cursmx = trigs[j].position.x; @@ -439,7 +439,7 @@ bool ForceL1Trig() } for (i = 0; L5DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L5DownList[i]) { - sprintf(infostr, fmt::format(_("Down to Crypt level {:d}"), currlevel - 19).c_str()); + strcpy(infostr, fmt::format(_("Down to Crypt level {:d}"), currlevel - 19).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -483,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, fmt::format(_("Up to level {:d}"), currlevel - 1).c_str()); + strcpy(infostr, fmt::format(_("Up to level {:d}"), currlevel - 1).c_str()); cursmx = trigs[j].position.x; cursmy = trigs[j].position.y; return true; @@ -495,7 +495,7 @@ bool ForceL2Trig() for (i = 0; L2DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L2DownList[i]) { - sprintf(infostr, fmt::format(_("Down to level {:d}"), currlevel + 1).c_str()); + strcpy(infostr, fmt::format(_("Down to level {:d}"), currlevel + 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -535,7 +535,7 @@ bool ForceL3Trig() if (currlevel < 17) { for (i = 0; L3UpList[i] != -1; ++i) { if (dPiece[cursmx][cursmy] == L3UpList[i]) { - sprintf(infostr, fmt::format(_("Up to level {:d}"), currlevel - 1).c_str()); + strcpy(infostr, fmt::format(_("Up to level {:d}"), currlevel - 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABPREVLVL) { cursmx = trigs[j].position.x; @@ -549,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, fmt::format(_("Down to level {:d}"), currlevel + 1).c_str()); + strcpy(infostr, fmt::format(_("Down to level {:d}"), currlevel + 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -562,7 +562,7 @@ bool ForceL3Trig() } else { for (i = 0; L6UpList[i] != -1; ++i) { if (dPiece[cursmx][cursmy] == L6UpList[i]) { - sprintf(infostr, fmt::format(_("Up to Nest level {:d}"), currlevel - 17).c_str()); + strcpy(infostr, fmt::format(_("Up to Nest level {:d}"), currlevel - 17).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABPREVLVL) { cursmx = trigs[j].position.x; @@ -576,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, fmt::format(_("Down to level {:d}"), currlevel - 15).c_str()); + strcpy(infostr, fmt::format(_("Down to level {:d}"), currlevel - 15).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -634,7 +634,7 @@ bool ForceL4Trig() for (i = 0; L4UpList[i] != -1; ++i) { if (dPiece[cursmx][cursmy] == L4UpList[i]) { - sprintf(infostr, fmt::format(_("Up to level {:d}"), currlevel - 1).c_str()); + strcpy(infostr, fmt::format(_("Up to level {:d}"), currlevel - 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABPREVLVL) { cursmx = trigs[j].position.x; @@ -647,7 +647,7 @@ bool ForceL4Trig() for (i = 0; L4DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L4DownList[i]) { - sprintf(infostr, fmt::format(_("Down to level {:d}"), currlevel + 1).c_str()); + strcpy(infostr, fmt::format(_("Down to level {:d}"), currlevel + 1).c_str()); for (j = 0; j < numtrigs; j++) { if (trigs[j]._tmsg == WM_DIABNEXTLVL) { cursmx = trigs[j].position.x; @@ -717,7 +717,7 @@ bool ForceSKingTrig() for (i = 0; L1UpList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L1UpList[i]) { - sprintf(infostr, fmt::format(_("Back to Level {:d}"), quests[Q_SKELKING]._qlevel).c_str()); + strcpy(infostr, fmt::format(_("Back to Level {:d}"), quests[Q_SKELKING]._qlevel).c_str()); cursmx = trigs[0].position.x; cursmy = trigs[0].position.y; @@ -734,7 +734,7 @@ bool ForceSChambTrig() for (i = 0; L2DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L2DownList[i]) { - sprintf(infostr, fmt::format(_("Back to Level {:d}"), quests[Q_SCHAMB]._qlevel).c_str()); + strcpy(infostr, fmt::format(_("Back to Level {:d}"), quests[Q_SCHAMB]._qlevel).c_str()); cursmx = trigs[0].position.x; cursmy = trigs[0].position.y; @@ -751,7 +751,7 @@ bool ForcePWaterTrig() for (i = 0; L3DownList[i] != -1; i++) { if (dPiece[cursmx][cursmy] == L3DownList[i]) { - sprintf(infostr, fmt::format(_("Back to Level {:d}"), quests[Q_PWATER]._qlevel).c_str()); + strcpy(infostr, fmt::format(_("Back to Level {:d}"), quests[Q_PWATER]._qlevel).c_str()); cursmx = trigs[0].position.x; cursmy = trigs[0].position.y;