Browse Source

Fix MSVC C4477 warning

Also take translation in to account when printing XP info
pull/2330/head
Anders Jenbo 5 years ago
parent
commit
7f5ea145e9
  1. 7
      Source/qol/common.cpp
  2. 2
      Source/qol/common.h
  3. 6
      Source/qol/xpbar.cpp

7
Source/qol/common.cpp

@ -11,17 +11,18 @@
#include "engine/render/text_render.hpp"
#include "qol/monhealthbar.h"
#include "qol/xpbar.h"
#include "utils/language.h"
namespace devilution {
char *PrintWithSeparator(char *out, int64_t n)
char *PrintWithSeparator(char *out, int n)
{
if (n < 1000) {
return out + sprintf(out, "%ld", n);
return out + sprintf(out, "%d", n);
}
char *append = PrintWithSeparator(out, n / 1000);
return append + sprintf(append, ",%03ld", n % 1000);
return append + sprintf(append, _(/* TRANSLATORS: Decimal separator */ ",%03d"), n % 1000);
}
void FreeQol()

2
Source/qol/common.h

@ -17,7 +17,7 @@ struct Surface;
* @param n Number to print
* @return Address of first character after printed number
*/
char *PrintWithSeparator(char *out, int64_t n);
char *PrintWithSeparator(char *out, int n);
void FreeQol();
void InitQol();

6
Source/qol/xpbar.cpp

@ -133,7 +133,7 @@ bool CheckXPBarInfo()
infoclr = UIS_GOLD;
strcpy(tempstr, _("Experience: "));
PrintWithSeparator(tempstr + SDL_arraysize("Experience: ") - 1, ExpLvlsTbl[charLevel - 1]);
PrintWithSeparator(tempstr + strlen(tempstr), ExpLvlsTbl[charLevel - 1]);
AddPanelString(tempstr);
AddPanelString(_("Maximum Level"));
@ -144,11 +144,11 @@ bool CheckXPBarInfo()
infoclr = UIS_SILVER;
strcpy(tempstr, _("Experience: "));
PrintWithSeparator(tempstr + SDL_arraysize("Experience: ") - 1, player._pExperience);
PrintWithSeparator(tempstr + strlen(tempstr), player._pExperience);
AddPanelString(tempstr);
strcpy(tempstr, _("Next Level: "));
PrintWithSeparator(tempstr + SDL_arraysize("Next Level: ") - 1, ExpLvlsTbl[charLevel]);
PrintWithSeparator(tempstr + strlen(tempstr), ExpLvlsTbl[charLevel]);
AddPanelString(tempstr);
strcpy(PrintWithSeparator(tempstr, ExpLvlsTbl[charLevel] - player._pExperience), fmt::format(_(" to Level {:d}"), charLevel + 1).c_str());

Loading…
Cancel
Save