2408: Don't use %ll format r=def- a=heinrich5991

It's not supported in MSVS. Fix #2407.

Co-authored-by: heinrich5991 <heinrich5991@gmail.com>
This commit is contained in:
bors[bot] 2020-06-29 12:17:44 +00:00 committed by GitHub
commit 87407be1c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View file

@ -2333,13 +2333,11 @@ int str_length(const char *str)
int str_format(char *buffer, int buffer_size, const char *format, ...)
{
int ret;
#if defined(CONF_FAMILY_WINDOWS)
va_list ap;
va_start(ap, format);
#if defined(__MINGW32__)
ret = __mingw_vsnprintf(buffer, buffer_size, format, ap);
#elif defined(CONF_FAMILY_WINDOWS)
ret = _vsnprintf(buffer, buffer_size, format, ap);
va_end(ap);
buffer[buffer_size-1] = 0; /* assure null termination */
@ -2348,11 +2346,13 @@ int str_format(char *buffer, int buffer_size, const char *format, ...)
if(ret < 0)
ret = buffer_size - 1;
#else
va_list ap;
va_start(ap, format);
ret = vsnprintf(buffer, buffer_size, format, ap);
#endif
va_end(ap);
/* null termination is assured by definition of vsnprintf */
#endif
/* a return value of buffer_size or more indicates truncated output */
if(ret >= buffer_size)

View file

@ -30,7 +30,9 @@ static unsigned int RotateRight32(unsigned int x, int Shift)
void CPrng::Seed(uint64 aSeed[2])
{
m_Seeded = true;
str_format(m_aDescription, sizeof(m_aDescription), "%s:%016llx:%016llx", NAME, aSeed[0], aSeed[1]);
str_format(m_aDescription, sizeof(m_aDescription), "%s:%08x%08x:%08x%08x", NAME,
(unsigned)(aSeed[0] >> 32), (unsigned)aSeed[0],
(unsigned)(aSeed[1] >> 32), (unsigned)aSeed[1]);
m_Increment = (aSeed[1] << 1) | 1;
m_State = aSeed[0] + m_Increment;

View file

@ -736,8 +736,10 @@ void CGameContext::ConDrySave(IConsole::IResult *pResult, void *pUserData)
if(CSaveTeam::HandleSaveError(Result, pResult->m_ClientID, pSelf))
return;
char aTimestamp[32];
str_timestamp(aTimestamp, sizeof(aTimestamp));
char aBuf[64];
str_format(aBuf, sizeof(aBuf), "%s-%lld-%s.save", pSelf->Server()->GetMapName(), time_get(), pSelf->Server()->GetAuthName(pResult->m_ClientID));
str_format(aBuf, sizeof(aBuf), "%s_%s_%s.save", pSelf->Server()->GetMapName(), aTimestamp, pSelf->Server()->GetAuthName(pResult->m_ClientID));
IOHANDLE File = pSelf->Storage()->OpenFile(aBuf, IOFLAG_WRITE, IStorage::TYPE_ALL);
if(!File)
return;