(svn r27102) -Fix [FS#6194]: money values would end up wrong in strings when outside of the bounds of a 32 bits integer

This commit is contained in:
rubidium 2015-01-01 20:50:43 +00:00
parent 85b93d0e5e
commit 730773f5f1
4 changed files with 4 additions and 3 deletions

View File

@ -201,7 +201,7 @@ char *ScriptText::_GetEncodedText(char *p, char *lastofp, int &param_count)
p = this->paramt[i]->_GetEncodedText(p, lastofp, param_count);
continue;
}
p += seprintf(p, lastofp,":%X", (uint32)this->parami[i]);
p += seprintf(p, lastofp,":" OTTD_PRINTFHEX64, this->parami[i]);
param_count++;
}

View File

@ -129,7 +129,7 @@ public:
private:
StringID string;
char *params[SCRIPT_TEXT_MAX_PARAMETERS];
int parami[SCRIPT_TEXT_MAX_PARAMETERS];
int64 parami[SCRIPT_TEXT_MAX_PARAMETERS];
ScriptText *paramt[SCRIPT_TEXT_MAX_PARAMETERS];
int paramc;

View File

@ -322,6 +322,7 @@
#define OTTD_PRINTF64 "%I64d"
#define OTTD_PRINTFHEX64 "%I64x"
#define PRINTF_SIZE "%Iu"
#define strtoull _strtoui64
#else
#define OTTD_PRINTF64 "%lld"
#define OTTD_PRINTFHEX64 "%llx"

View File

@ -874,7 +874,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
bool lookup = (l == SCC_ENCODED);
if (lookup) s += len;
param = (int32)strtoul(s, &p, 16);
param = strtoull(s, &p, 16);
if (lookup) {
if (param >= TAB_SIZE) {