1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00

Replace sprintf by snprintf

This commit is contained in:
Mathieu Schroeter 2017-08-13 17:15:09 +02:00
parent a80c3d09fc
commit b4c5f62dcf
5 changed files with 15 additions and 15 deletions

View File

@ -238,7 +238,7 @@ bool CDecor::LoadImages ()
totalDim.y = DIMCELY * 2 * 6;
iconDim.x = DIMCELX * 2;
iconDim.y = DIMCELY * 2;
sprintf (filename, "image/floor%.3d.png", m_region);
snprintf (filename, sizeof (filename), "image/floor%.3d.png", m_region);
if (!m_pPixmap->Cache (CHFLOOR, filename, totalDim, iconDim))
return false;
@ -246,11 +246,11 @@ bool CDecor::LoadImages ()
totalDim.y = DIMOBJY * 8;
iconDim.x = DIMOBJX;
iconDim.y = DIMOBJY;
sprintf (filename, "image/obj%.3d.png", m_region);
snprintf (filename, sizeof (filename), "image/obj%.3d.png", m_region);
if (!m_pPixmap->Cache (CHOBJECT, filename, totalDim, iconDim))
return false;
sprintf (filename, "image/obj-o%.3d.png", m_region);
snprintf (filename, sizeof (filename), "image/obj-o%.3d.png", m_region);
if (!m_pPixmap->Cache (CHOBJECTo, filename, totalDim, iconDim))
return false;
@ -708,7 +708,7 @@ void CDecor::BuildMoveObject (Sint32 x, Sint32 y, POINT pos, Sint32 rank)
m_pPixmap->DrawIcon (
-1, m_decor[x / 2][y / 2].objectChannel, m_decor[x / 2][y / 2].objectIcon,
pos);
sprintf (string, "%d", m_move[rank].icon - MOVEICONNB);
snprintf (string, sizeof (string), "%d", m_move[rank].icon - MOVEICONNB);
textPos.x = pos.x + DIMCELX / 2 + 32;
textPos.y = pos.y + (DIMOBJY - DIMCELY * 2) + 36;
DrawTextCenter (m_pPixmap, textPos, string, FONTLITTLE);

View File

@ -713,7 +713,7 @@ void CDecor::StatisticDraw ()
m_pPixmap->DrawIcon (-1, CHBUTTON, icon, pos);
nb = pStatistic->nb;
sprintf (text, "%d", nb);
snprintf (text, sizeof (text), "%d", nb);
pos.x += 3 + 34;
pos.y += 5 + 7;
DrawText (m_pPixmap, pos, text);

View File

@ -2100,7 +2100,7 @@ bool CEvent::DrawButtons ()
m_pPixmap->DrawPart (-1, CHBACK, pos, rect, 1); // dessine le fond
if (m_speed > 1)
{
sprintf (res, "x%d", m_speed);
snprintf (res, sizeof (res), "x%d", m_speed);
DrawText (m_pPixmap, pos, res);
}
@ -2178,7 +2178,7 @@ bool CEvent::DrawButtons ()
world = m_fileWorld[i];
time = m_fileTime[i];
sprintf (text, "%d", i + 1);
snprintf (text, sizeof (text), "%d", i + 1);
lg = GetTextWidth (text);
pos.x = (420 + 460) / 2 - lg / 2;
pos.y = 30 + 12 + 42 * i;
@ -2436,19 +2436,19 @@ bool CEvent::DrawButtons ()
DrawTextCenter (gettext ("Music\nvolume"), 399 + 40, 80);
DrawTextCenter (gettext ("Video\nsequences"), 514 + 40, 80);
sprintf (res, "x%d", m_speed);
snprintf (res, sizeof (res), "x%d", m_speed);
lg = GetTextWidth (res);
pos.x = (54 + 40) - lg / 2;
pos.y = 330 - 20;
DrawText (m_pPixmap, pos, res);
sprintf (res, "%d", m_pSound->GetAudioVolume ());
snprintf (res, sizeof (res), "%d", m_pSound->GetAudioVolume ());
lg = GetTextWidth (res);
pos.x = (284 + 40) - lg / 2;
pos.y = 330 - 20;
DrawText (m_pPixmap, pos, res);
sprintf (res, "%d", m_pSound->GetMidiVolume ());
snprintf (res, sizeof (res), "%d", m_pSound->GetMidiVolume ());
lg = GetTextWidth (res);
pos.x = (399 + 40) - lg / 2;
pos.y = 330 - 20;
@ -2465,7 +2465,7 @@ bool CEvent::DrawButtons ()
if (!m_scrollSpeed)
snprintf (res, sizeof (res), "%s", gettext ("None"));
else
sprintf (res, "%d", m_scrollSpeed);
snprintf (res, sizeof (res), "%d", m_scrollSpeed);
lg = GetTextWidth (res);
pos.x = (169 + 40) - lg / 2;
pos.y = 330 - 20;
@ -4275,7 +4275,7 @@ void CEvent::PrivateLibelle ()
snprintf (
buffer, sizeof (buffer), "%s",
gettext ("1|The Blupi population must\n1|be of at least %d Blupi."));
sprintf (string, buffer, term.nbMaxBlupi);
snprintf (string, sizeof (string), buffer, term.nbMaxBlupi);
strcat (m_libelle, "\n1|\n");
strcat (m_libelle, string);
}

View File

@ -137,7 +137,7 @@ void CSound::CacheAll ()
for (i = 0; i < MAXSOUND; i++)
{
sprintf (name, "sound%.3d.wav", i);
snprintf (name, sizeof (name), "sound%.3d.wav", i);
if (!Cache (i, name))
break;
}

View File

@ -335,7 +335,7 @@ void DrawBignum (CPixmap * pPixmap, POINT pos, Sint32 num)
Sint32 start, lg;
RECT rect;
sprintf (string, "%d", num);
snprintf (string, sizeof (string), "%d", num);
rect.top = 0;
rect.bottom = 52;
@ -361,7 +361,7 @@ Sint32 GetBignumWidth (Sint32 num)
Sint32 start, lg;
Sint32 width = -4;
sprintf (string, "%d", num);
snprintf (string, sizeof (string), "%d", num);
while (string[i] != 0)
{