Codechange: use fmt::format for FormatHexNumber

This commit is contained in:
Rubidium 2023-04-19 21:44:56 +02:00 committed by rubidium42
parent 630d3bc053
commit 75cd790ab9
2 changed files with 2 additions and 16 deletions

View File

@ -298,21 +298,6 @@
#endif
#define PACK(type_dec) PACK_N(type_dec, 1)
/* MSVCRT of course has to have a different syntax for long long *sigh* */
#if defined(_MSC_VER)
# define OTTD_PRINTF64 "%I64d"
# define OTTD_PRINTF64U "%I64u"
# define OTTD_PRINTFHEX64 "%I64x"
#elif defined(__MINGW32__)
# define OTTD_PRINTF64 "%I64d"
# define OTTD_PRINTF64U "%I64llu"
# define OTTD_PRINTFHEX64 "%I64x"
#else
# define OTTD_PRINTF64 "%lld"
# define OTTD_PRINTF64U "%llu"
# define OTTD_PRINTFHEX64 "%llx"
#endif
/*
* When making a (pure) debug build, the compiler will by default disable
* inlining of functions. This has a detremental effect on the performance of

View File

@ -39,6 +39,7 @@
#include "newgrf_engine.h"
#include "core/backup_type.hpp"
#include <stack>
#include <charconv>
#include "table/strings.h"
#include "table/control_codes.h"
@ -382,7 +383,7 @@ static char *FormatZerofillNumber(char *buff, int64 number, int64 count, const c
static char *FormatHexNumber(char *buff, uint64 number, const char *last)
{
return buff + seprintf(buff, last, "0x" OTTD_PRINTFHEX64, number);
return strecpy(buff, fmt::format("0x{:X}", number).c_str(), last);
}
/**