diff --git a/Source/control.cpp b/Source/control.cpp index 3442895fb..31027f388 100644 --- a/Source/control.cpp +++ b/Source/control.cpp @@ -424,13 +424,13 @@ void DrawSpellList(const CelOutputBuffer &out) v++; } } - sprintf(tempstr, ngettext("%i Scroll", "%i Scrolls", v), v); + strcpy(tempstr, fmt::format(ngettext("{:d} Scroll", "{:d} Scrolls", v), v).c_str()); AddPanelString(tempstr); } break; case RSPLTYPE_CHARGES: { 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); + strcpy(tempstr, fmt::format(ngettext("{:d} Charge", "{:d} Charges", charges), charges).c_str()); AddPanelString(tempstr); } break; case RSPLTYPE_INVALID: @@ -969,13 +969,13 @@ void CheckPanelInfo() s++; } } - sprintf(tempstr, ngettext("%i Scroll", "%i Scrolls", s), s); + strcpy(tempstr, fmt::format(ngettext("{:d} Scroll", "{:d} Scrolls", s), s).c_str()); AddPanelString(tempstr); } break; case RSPLTYPE_CHARGES: 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); + strcpy(tempstr, fmt::format(ngettext("{:d} Charge", "{:d} Charges", plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges), plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges).c_str()); AddPanelString(tempstr); break; case RSPLTYPE_INVALID: @@ -1121,7 +1121,7 @@ void DrawInfoBox(const CelOutputBuffer &out) } else if (pcurs >= CURSOR_FIRSTITEM) { if (plr[myplr].HoldItem._itype == ITYPE_GOLD) { int nGold = plr[myplr].HoldItem._ivalue; - sprintf(infostr, ngettext("%i gold piece", "%i gold pieces", nGold), nGold); + strcpy(infostr, fmt::format(ngettext("{:d} gold piece", "{:d} gold pieces", nGold), nGold).c_str()); } else if (!plr[myplr].HoldItem._iStatFlag) { ClearPanel(); AddPanelString(_("Requirements not met")); @@ -1619,7 +1619,7 @@ void DrawSpellBook(const CelOutputBuffer &out) break; case RSPLTYPE_CHARGES: { int charges = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCharges; - sprintf(tempstr, ngettext("Staff (%i charge)", "Staff (%i charges)", charges), charges); + strcpy(tempstr, fmt::format(ngettext("Staff ({:d} charge)", "Staff ({:d} charges)", charges), charges).c_str()); } break; default: { int mana = GetManaAmount(myplr, sn) >> 6; @@ -1681,13 +1681,14 @@ void DrawGoldSplit(const CelOutputBuffer &out, int amount) CelDrawTo(out, dialogX, 178, *pGBoxBuff, 1); - sprintf( + strcpy( tempstr, - ngettext( - /* TRANSLATORS: %u is a number. Dialog is shown when splitting a stash of Gold.*/ "You have %u gold piece. How many do you want to remove?", - "You have %u gold pieces. How many do you want to remove?", - initialDropGoldValue), - initialDropGoldValue); + fmt::format(ngettext( + /* TRANSLATORS: {:d} is a number. Dialog is shown when splitting a stash of Gold.*/ "You have {:d} gold piece. How many do you want to remove?", + "You have {:d} gold pieces. How many do you want to remove?", + initialDropGoldValue), + initialDropGoldValue) + .c_str()); WordWrapGameString(tempstr, 200); DrawString(out, tempstr, { dialogX + 31, 87, 200, 50 }, UIS_GOLD | UIS_CENTER, 1, 17); diff --git a/Source/inv.cpp b/Source/inv.cpp index abfa4a225..2be040a45 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -5,6 +5,8 @@ */ #include +#include + #include "cursor.h" #include "engine/render/cel_render.hpp" #include "engine/render/text_render.hpp" @@ -2048,7 +2050,7 @@ char CheckInvHLight() if (pi->_itype == ITYPE_GOLD) { nGold = pi->_ivalue; - sprintf(infostr, ngettext("%i gold piece", "%i gold pieces", nGold), nGold); + strcpy(infostr, fmt::format(ngettext("{:d} gold piece", "{:d} gold pieces", nGold), nGold).c_str()); } else { if (pi->_iMagical == ITEM_QUALITY_MAGIC) { infoclr = UIS_BLUE; diff --git a/Source/items.cpp b/Source/items.cpp index 3dae184d8..98150c36c 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -3037,7 +3037,7 @@ void GetItemStr(int i) infoclr = UIS_GOLD; } else { int nGold = items[i]._ivalue; - sprintf(infostr, ngettext("%i gold piece", "%i gold pieces", nGold), nGold); + strcpy(infostr, fmt::format(ngettext("{:d} gold piece", "{:d} gold pieces", nGold), nGold).c_str()); } } @@ -3464,9 +3464,9 @@ void PrintItemPower(char plidx, ItemStruct *x) break; case IPL_SPLLVLADD: if (x->_iSplLvlAdd > 0) - sprintf(tempstr, ngettext("spells are increased %i level", "spells are increased %i levels", x->_iSplLvlAdd), x->_iSplLvlAdd); + strcpy(tempstr, fmt::format(ngettext("spells are increased {:d} level", "spells are increased {:d} levels", x->_iSplLvlAdd), x->_iSplLvlAdd).c_str()); else if (x->_iSplLvlAdd < 0) - sprintf(tempstr, ngettext("spells are decreased %i level", "spells are decreased %i levels", -x->_iSplLvlAdd), -x->_iSplLvlAdd); + strcpy(tempstr, fmt::format(ngettext("spells are decreased {:d} level", "spells are decreased {:d} levels", -x->_iSplLvlAdd), -x->_iSplLvlAdd).c_str()); else if (x->_iSplLvlAdd == 0) strcpy(tempstr, _("spell levels unchanged (?)")); break; @@ -3474,7 +3474,7 @@ void PrintItemPower(char plidx, ItemStruct *x) strcpy(tempstr, _("Extra charges")); break; case IPL_SPELL: - sprintf(tempstr, ngettext("%i %s charge", "%i %s charges", x->_iMaxCharges), x->_iMaxCharges, _(spelldata[x->_iSpell].sNameText)); + strcpy(tempstr, fmt::format(ngettext("{:d} {:s} charge", "{:d} {:s} charges", x->_iMaxCharges), x->_iMaxCharges, _(spelldata[x->_iSpell].sNameText)).c_str()); break; case IPL_FIREDAM: if (x->_iFMinDam == x->_iFMaxDam) @@ -3617,7 +3617,7 @@ void PrintItemPower(char plidx, ItemStruct *x) strcpy(tempstr, _("fast block")); break; case IPL_DAMMOD: - sprintf(tempstr, ngettext("adds %i point to damage", "adds %i points to damage", x->_iPLDamMod), x->_iPLDamMod); + strcpy(tempstr, fmt::format(ngettext("adds {:d} point to damage", "adds {:d} points to damage", x->_iPLDamMod), x->_iPLDamMod).c_str()); break; case IPL_RNDARROWVEL: strcpy(tempstr, _("fires random speed arrows"));