Some cleanup and tweaks.

Basically removal of warnings + added missing info to the readme.
This also removes remaining uses of sprintf (which is dangerous).
This commit is contained in:
Layla Marchant 2020-03-05 16:44:13 -05:00
parent cdf555f17b
commit 47d876c15e
9 changed files with 127 additions and 119 deletions

View File

@ -73,7 +73,8 @@ distribution if possible. If you want or need to compile yourself,
however, instructions follow. however, instructions follow.
Note: Developers compiling the source code from the Git repository, Note: Developers compiling the source code from the Git repository,
please first see the GENERATING CONFIGURE SCRIPT section below. please first see the GENERATING CONFIGURE SCRIPT AND BUILDING LOCALES
section below.
Project: Starfighter depends on the following libraries to build: Project: Starfighter depends on the following libraries to build:
@ -108,12 +109,13 @@ Run "./configure --help" to see all options for compiling.
------------------------------------------------------------------------ ------------------------------------------------------------------------
GENERATING CONFIGURE SCRIPT GENERATING CONFIGURE SCRIPT AND BUILDING LOCALES
If you contribute to Project: Starfighter's source code, you will need If you contribute to Project: Starfighter's source code, you will need
to know how to generate a configure script for compiling the program. to know how to generate a configure script and build locales needed for
NOTE: This is for developers only. End-users simply compiling releases compiling the program. NOTE: This is for developers and other people
of Starfighter from source can ignore this section. compiling source code taken from the Git repository. End-users simply
compiling releases of Starfighter from source can ignore this section.
The following components are required to generate the configure script: The following components are required to generate the configure script:
@ -121,12 +123,17 @@ The following components are required to generate the configure script:
* Automake * Automake
* pkg-config * pkg-config
And the following is required to build locales:
* Python
Once these dependencies are installed, simply do the following from a Once these dependencies are installed, simply do the following from a
terminal window: terminal window:
autoreconf -vif autoreconf -vif
./locale/build.py
The arguments are technically optional, but recommended. The arguments to autoreconf are technically optional, but recommended.
If for some reason you need to remove all of these files from your If for some reason you need to remove all of these files from your
directory, you can do so via the following command (requires Git): directory, you can do so via the following command (requires Git):

View File

@ -6,9 +6,9 @@
bin_PROGRAMS = starfighter bin_PROGRAMS = starfighter
if RUN_IN_PLACE if RUN_IN_PLACE
starfighter_CPPFLAGS = $(STARFIGHTER_CFLAGS) -Wall starfighter_CPPFLAGS = $(STARFIGHTER_CFLAGS) -Wall -Wformat-truncation=0
else else
starfighter_CPPFLAGS = $(STARFIGHTER_CFLAGS) -DDATADIR=\"$(pkgdatadir)\" -Wall starfighter_CPPFLAGS = $(STARFIGHTER_CFLAGS) -DDATADIR=\"$(pkgdatadir)\" -Wall -Wformat-truncation=0
endif endif
starfighter_CFLAGS = $(SDL_CFLAGS) $(PANGO_CFLAGS) starfighter_CFLAGS = $(SDL_CFLAGS) $(PANGO_CFLAGS)

View File

@ -145,7 +145,7 @@ void engine_showError(int errorId, const char *name)
switch(errorId) switch(errorId)
{ {
case 0: case 0:
sprintf(string, "%s was not found in the Starfighter data package", name); snprintf(string, STRMAX, "%s was not found in the Starfighter data package", name);
screen_renderString(string, -1, 250, FONT_WHITE); screen_renderString(string, -1, 250, FONT_WHITE);
screen_renderString("Please try again. If this error persists, contact the authors", -1, 275, FONT_WHITE); screen_renderString("Please try again. If this error persists, contact the authors", -1, 275, FONT_WHITE);
screen_renderString("or reinstall the game", -1, 300, FONT_WHITE); screen_renderString("or reinstall the game", -1, 300, FONT_WHITE);

View File

@ -285,7 +285,7 @@ static void game_doCollectables()
Collectable *collectable = engine.collectableHead; Collectable *collectable = engine.collectableHead;
Collectable *prevCollectable = engine.collectableHead; Collectable *prevCollectable = engine.collectableHead;
engine.collectableTail = engine.collectableHead; engine.collectableTail = engine.collectableHead;
char temp[40]; char temp[STRMAX_SHORT];
while (collectable->next != NULL) while (collectable->next != NULL)
{ {
@ -313,20 +313,20 @@ static void game_doCollectables()
case P_CASH: case P_CASH:
game.cash += collectable->value; game.cash += collectable->value;
game.cashEarned += collectable->value; game.cashEarned += collectable->value;
sprintf(temp, "Got $%d ", collectable->value); snprintf(temp, STRMAX_SHORT, "Got $%d ", collectable->value);
break; break;
case P_ROCKET: case P_ROCKET:
LIMIT_ADD(player.ammo[1], collectable->value, 0, LIMIT_ADD(player.ammo[1], collectable->value, 0,
game.maxRocketAmmo); game.maxRocketAmmo);
if (player.ammo[1] == game.maxRocketAmmo) if (player.ammo[1] == game.maxRocketAmmo)
sprintf(temp, "Rocket Ammo at Maximum"); strcpy(temp, "Rocket Ammo at Maximum");
else else
{ {
if (collectable->value > 1) if (collectable->value > 1)
sprintf(temp, "Got %d rockets", collectable->value); snprintf(temp, STRMAX_SHORT, "Got %d rockets", collectable->value);
else else
sprintf(temp, "Got a rocket"); strcpy(temp, "Got a rocket");
} }
game.rocketPickups += collectable->value; game.rocketPickups += collectable->value;
break; break;
@ -334,7 +334,7 @@ static void game_doCollectables()
case P_SHIELD: case P_SHIELD:
LIMIT_ADD(player.shield, 10, 0, player.maxShield); LIMIT_ADD(player.shield, 10, 0, player.maxShield);
game.shieldPickups ++; game.shieldPickups ++;
sprintf(temp, "Restored 10 shield points"); strcpy(temp, "Restored 10 shield points");
break; break;
case P_PLASMA_RATE: case P_PLASMA_RATE:
@ -347,11 +347,11 @@ static void game_doCollectables()
weapons[W_PLAYER_WEAPON].reload[0] - 2); weapons[W_PLAYER_WEAPON].reload[0] - 2);
if (weapons[W_PLAYER_WEAPON].reload[0] <= rate2reload[game.maxPlasmaRate]) if (weapons[W_PLAYER_WEAPON].reload[0] <= rate2reload[game.maxPlasmaRate])
sprintf(temp, "Firing rate already at maximum"); strcpy(temp, "Firing rate already at maximum");
else else
{ {
weapons[W_PLAYER_WEAPON].reload[0] -= 2; weapons[W_PLAYER_WEAPON].reload[0] -= 2;
sprintf(temp, "Firing rate increased"); strcpy(temp, "Firing rate increased");
} }
} }
else if ((game.area != MISN_INTERCEPTION) || else if ((game.area != MISN_INTERCEPTION) ||
@ -362,16 +362,16 @@ static void game_doCollectables()
0, game.maxPlasmaAmmo); 0, game.maxPlasmaAmmo);
if (weapons[W_PLAYER_WEAPON].reload[0] <= rate2reload[game.maxPlasmaRate]) if (weapons[W_PLAYER_WEAPON].reload[0] <= rate2reload[game.maxPlasmaRate])
sprintf(temp, "Firing rate already at maximum"); strcpy(temp, "Firing rate already at maximum");
else else
{ {
weapons[W_PLAYER_WEAPON].reload[0] -= 2; weapons[W_PLAYER_WEAPON].reload[0] -= 2;
sprintf(temp, "Firing rate increased"); strcpy(temp, "Firing rate increased");
} }
} }
else else
{ {
sprintf(temp, "Upgrade failed (no plasma ammo)"); strcpy(temp, "Upgrade failed (no plasma ammo)");
} }
break; break;
@ -384,11 +384,11 @@ static void game_doCollectables()
game.maxPlasmaOutput, weapons[W_PLAYER_WEAPON].ammo[0] + 1); game.maxPlasmaOutput, weapons[W_PLAYER_WEAPON].ammo[0] + 1);
if (weapons[W_PLAYER_WEAPON].ammo[0] >= game.maxPlasmaOutput) if (weapons[W_PLAYER_WEAPON].ammo[0] >= game.maxPlasmaOutput)
sprintf(temp, "Plasma output already at maximum"); strcpy(temp, "Plasma output already at maximum");
else else
{ {
weapons[W_PLAYER_WEAPON].ammo[0]++; weapons[W_PLAYER_WEAPON].ammo[0]++;
sprintf(temp, "Plasma output increased"); strcpy(temp, "Plasma output increased");
} }
} }
else if ((game.area != MISN_INTERCEPTION) || else if ((game.area != MISN_INTERCEPTION) ||
@ -399,16 +399,16 @@ static void game_doCollectables()
0, game.maxPlasmaAmmo); 0, game.maxPlasmaAmmo);
if (weapons[W_PLAYER_WEAPON].ammo[0] >= game.maxPlasmaOutput) if (weapons[W_PLAYER_WEAPON].ammo[0] >= game.maxPlasmaOutput)
sprintf(temp, "Plasma output already at maximum"); strcpy(temp, "Plasma output already at maximum");
else else
{ {
weapons[W_PLAYER_WEAPON].ammo[0]++; weapons[W_PLAYER_WEAPON].ammo[0]++;
sprintf(temp, "Plasma output increased"); strcpy(temp, "Plasma output increased");
} }
} }
else else
{ {
sprintf(temp, "Upgrade failed (no plasma ammo)"); strcpy(temp, "Upgrade failed (no plasma ammo)");
} }
break; break;
@ -421,11 +421,11 @@ static void game_doCollectables()
game.maxPlasmaDamage, weapons[W_PLAYER_WEAPON].damage + 1); game.maxPlasmaDamage, weapons[W_PLAYER_WEAPON].damage + 1);
if (weapons[W_PLAYER_WEAPON].damage >= game.maxPlasmaDamage) if (weapons[W_PLAYER_WEAPON].damage >= game.maxPlasmaDamage)
sprintf(temp, "Plasma damage already at maximum"); strcpy(temp, "Plasma damage already at maximum");
else else
{ {
weapons[W_PLAYER_WEAPON].damage++; weapons[W_PLAYER_WEAPON].damage++;
sprintf(temp, "Plasma damage increased"); strcpy(temp, "Plasma damage increased");
} }
} }
else if ((game.area != MISN_INTERCEPTION) || else if ((game.area != MISN_INTERCEPTION) ||
@ -436,16 +436,16 @@ static void game_doCollectables()
0, game.maxPlasmaAmmo); 0, game.maxPlasmaAmmo);
if (weapons[W_PLAYER_WEAPON].damage >= game.maxPlasmaDamage) if (weapons[W_PLAYER_WEAPON].damage >= game.maxPlasmaDamage)
sprintf(temp, "Plasma damage already at maximum"); strcpy(temp, "Plasma damage already at maximum");
else else
{ {
weapons[W_PLAYER_WEAPON].damage++; weapons[W_PLAYER_WEAPON].damage++;
sprintf(temp, "Plasma damage increased"); strcpy(temp, "Plasma damage increased");
} }
} }
else else
{ {
sprintf(temp, "Upgrade failed (no plasma ammo)"); strcpy(temp, "Upgrade failed (no plasma ammo)");
} }
break; break;
@ -466,30 +466,30 @@ static void game_doCollectables()
weapons[W_PLAYER_WEAPON].reload[0] = rate2reload[5]; weapons[W_PLAYER_WEAPON].reload[0] = rate2reload[5];
weapons[W_PLAYER_WEAPON].flags |= WF_SPREAD; weapons[W_PLAYER_WEAPON].flags |= WF_SPREAD;
sprintf(temp, "Picked up a Super Charge!"); strcpy(temp, "Picked up a Super Charge!");
} }
else else
{ {
sprintf(temp, "Damn! Upgrade failed (no plasma ammo)"); strcpy(temp, "Damn! Upgrade failed (no plasma ammo)");
} }
break; break;
case P_PLASMA_AMMO: case P_PLASMA_AMMO:
if (player.ammo[0] >= game.maxPlasmaAmmo) if (player.ammo[0] >= game.maxPlasmaAmmo)
sprintf(temp, "Plasma cells already at Maximum"); strcpy(temp, "Plasma cells already at Maximum");
else else
{ {
LIMIT_ADD(player.ammo[0], collectable->value, LIMIT_ADD(player.ammo[0], collectable->value,
0, game.maxPlasmaAmmo); 0, game.maxPlasmaAmmo);
if (collectable->value > 1) if (collectable->value > 1)
{ {
sprintf(temp, "Got %d plasma cells", collectable->value); snprintf(temp, STRMAX_SHORT, "Got %d plasma cells", collectable->value);
} }
else else
{ {
sprintf(temp, "Got a plasma cell"); strcpy(temp, "Got a plasma cell");
if ((rand() % 25) == 0) if ((rand() % 25) == 0)
sprintf(temp, "Got one whole plasma cell (wahoo!)"); strcpy(temp, "Got one whole plasma cell (wahoo!)");
} }
} }
game.cellPickups += collectable->value; game.cellPickups += collectable->value;
@ -501,16 +501,16 @@ static void game_doCollectables()
break; break;
case P_SLAVES: case P_SLAVES:
sprintf(temp, "Rescued %d slaves", collectable->value); snprintf(temp, STRMAX_SHORT, "Rescued %d slaves", collectable->value);
game.slavesRescued += collectable->value; game.slavesRescued += collectable->value;
break; break;
case P_ESCAPEPOD: case P_ESCAPEPOD:
sprintf(temp, "Picked up an Escape Pod"); strcpy(temp, "Picked up an Escape Pod");
break; break;
case P_ORE: case P_ORE:
sprintf(temp, "Picked up some Ore"); strcpy(temp, "Picked up some Ore");
break; break;
} }
@ -1896,7 +1896,7 @@ static void game_doHud()
/// timer to use single-digit numbers. /// timer to use single-digit numbers.
/// The ":" can also be replaced just like any text. For example, this would be fine: /// The ":" can also be replaced just like any text. For example, this would be fine:
/// "Time Remaining - %d minutes and %d seconds" /// "Time Remaining - %d minutes and %d seconds"
sprintf(text, _("Time Remaining - %.2d:%.2d"), engine.minutes, engine.seconds); snprintf(text, STRMAX_SHORT, _("Time Remaining - %.2d:%.2d"), engine.minutes, engine.seconds);
gfx_createTextObject(TS_TIME, text, 0, 0, fontColor); gfx_createTextObject(TS_TIME, text, 0, 0, fontColor);
screen_blitText(TS_TIME, screen->w / 2 - gfx_textSprites[TS_TIME].image->w / 2, 20); screen_blitText(TS_TIME, screen->w / 2 - gfx_textSprites[TS_TIME].image->w / 2, 20);
} }
@ -1904,13 +1904,13 @@ static void game_doHud()
if (game.area != MISN_INTERCEPTION) if (game.area != MISN_INTERCEPTION)
{ {
/// "%d" must be retained. It is replaced with the number of mission objectives remaining. /// "%d" must be retained. It is replaced with the number of mission objectives remaining.
sprintf(text, _("Objectives Remaining: %d"), (mission.remainingObjectives1 + mission.remainingObjectives2)); snprintf(text, STRMAX_SHORT, _("Objectives Remaining: %d"), (mission.remainingObjectives1 + mission.remainingObjectives2));
gfx_createTextObject(TS_OBJECTIVES, text, 0, 0, FONT_WHITE); gfx_createTextObject(TS_OBJECTIVES, text, 0, 0, FONT_WHITE);
screen_blitText(TS_OBJECTIVES, screen->w - gfx_textSprites[TS_OBJECTIVES].image->w - 25, 20); screen_blitText(TS_OBJECTIVES, screen->w - gfx_textSprites[TS_OBJECTIVES].image->w - 25, 20);
} }
/// "%d" must be retained. It is replaced with the player's current total cash. /// "%d" must be retained. It is replaced with the player's current total cash.
sprintf(text, _("Cash: $%d"), game.cash); snprintf(text, STRMAX_SHORT, _("Cash: $%d"), game.cash);
gfx_createTextObject(TS_CASH, text, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CASH, text, 0, 0, FONT_WHITE);
screen_blitText(TS_CASH, 25, 20); screen_blitText(TS_CASH, 25, 20);
@ -1947,7 +1947,7 @@ static void game_doHud()
if (player.ammo[0] <= 10) fontColor = FONT_RED; if (player.ammo[0] <= 10) fontColor = FONT_RED;
} }
/// "%.3d" must be retained. It is replaced with the amount of plasma ammo. /// "%.3d" must be retained. It is replaced with the amount of plasma ammo.
sprintf(text, _("Plasma: %.3d"), player.ammo[0]); snprintf(text, STRMAX_SHORT, _("Plasma: %.3d"), player.ammo[0]);
gfx_createTextObject(TS_PLASMA, text, 0, 0, fontColor); gfx_createTextObject(TS_PLASMA, text, 0, 0, fontColor);
screen_blitText(TS_PLASMA, screen->w * 5 / 16, screen->h - 50); screen_blitText(TS_PLASMA, screen->w * 5 / 16, screen->h - 50);
@ -1964,7 +1964,7 @@ static void game_doHud()
else else
{ {
/// "%.2d" must be retained. It is replaced with the amount of rocket ammo. /// "%.2d" must be retained. It is replaced with the amount of rocket ammo.
sprintf(text, _("Rockets: %.2d"), player.ammo[1]); snprintf(text, STRMAX_SHORT, _("Rockets: %.2d"), player.ammo[1]);
gfx_createTextObject(TS_AMMO, text, 0, 0, FONT_WHITE); gfx_createTextObject(TS_AMMO, text, 0, 0, FONT_WHITE);
} }
screen_blitText(TS_AMMO, screen->w / 2, screen->h - 50); screen_blitText(TS_AMMO, screen->w / 2, screen->h - 50);

View File

@ -240,70 +240,70 @@ static void intermission_setStatusLines()
/// Status Screen text /// Status Screen text
/// Retain "%s" as-is. It is replaced with the current difficulty. /// Retain "%s" as-is. It is replaced with the current difficulty.
sprintf(string, _("Difficulty : %s"), difficulty); snprintf(string, STRMAX_SHORT, _("Difficulty : %s"), difficulty);
gfx_createTextObject(TS_STATUS_DIFFICULTY, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_STATUS_DIFFICULTY, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of shots fired. /// Retain "%d" as-is. It is replaced with the number of shots fired.
sprintf(string, _("Shots Fired : %d"), game.shots); snprintf(string, STRMAX_SHORT, _("Shots Fired : %d"), game.shots);
gfx_createTextObject(TS_SHOTS_FIRED, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_SHOTS_FIRED, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of hits scored. /// Retain "%d" as-is. It is replaced with the number of hits scored.
sprintf(string, _("Hits Scored : %d"), game.hits); snprintf(string, STRMAX_SHORT, _("Hits Scored : %d"), game.hits);
gfx_createTextObject(TS_HITS_SCORED, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_HITS_SCORED, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the firing accuracy as a percentage. /// Retain "%d" as-is. It is replaced with the firing accuracy as a percentage.
/// Note: To use the "%" symbol, you must enter "%%", as you can see in /// Note: To use the "%" symbol, you must enter "%%", as you can see in
/// the English version. /// the English version.
sprintf(string, _("Accuracy : %d%%"), game.accuracy); snprintf(string, STRMAX_SHORT, _("Accuracy : %d%%"), game.accuracy);
gfx_createTextObject(TS_ACCURACY, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_ACCURACY, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of kills. /// Retain "%d" as-is. It is replaced with the number of kills.
sprintf(string, _("Enemies Killed by Others : %d"), game.totalOtherKills); snprintf(string, STRMAX_SHORT, _("Enemies Killed by Others : %d"), game.totalOtherKills);
gfx_createTextObject(TS_OTHER_KILLS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_OTHER_KILLS, string, 0, 0, FONT_WHITE);
/// Retain "%d" as-is. It is replaced with the amount of cash earned. /// Retain "%d" as-is. It is replaced with the amount of cash earned.
sprintf(string, _("Total Cash Earned : %d"), game.cashEarned); snprintf(string, STRMAX_SHORT, _("Total Cash Earned : %d"), game.cashEarned);
gfx_createTextObject(TS_CASH_EARNED, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CASH_EARNED, string, 0, 0, FONT_WHITE);
gfx_createTextObject(TS_CHRIS_HEADER, _("*** Chris ***"), 0, 0, FONT_WHITE); gfx_createTextObject(TS_CHRIS_HEADER, _("*** Chris ***"), 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of kills. /// Retain "%d" as-is. It is replaced with the number of kills.
sprintf(string, _("Enemies Killed : %d"), game.totalKills); snprintf(string, STRMAX_SHORT, _("Enemies Killed : %d"), game.totalKills);
gfx_createTextObject(TS_CHRIS_KILLS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CHRIS_KILLS, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of shield restores picked up. /// Retain "%d" as-is. It is replaced with the number of shield restores picked up.
sprintf(string, _("Shield Restores Picked Up : %d"), game.shieldPickups); snprintf(string, STRMAX_SHORT, _("Shield Restores Picked Up : %d"), game.shieldPickups);
gfx_createTextObject(TS_CHRIS_SHIELD_PICKUPS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CHRIS_SHIELD_PICKUPS, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of plasma cells picked up. /// Retain "%d" as-is. It is replaced with the number of plasma cells picked up.
sprintf(string, _("Plasma Cells Picked Up : %d"), game.cellPickups); snprintf(string, STRMAX_SHORT, _("Plasma Cells Picked Up : %d"), game.cellPickups);
gfx_createTextObject(TS_CHRIS_PLASMA_PICKUPS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CHRIS_PLASMA_PICKUPS, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of rockets picked up. /// Retain "%d" as-is. It is replaced with the number of rockets picked up.
sprintf(string, _("Rockets Picked Up : %d"), game.rocketPickups); snprintf(string, STRMAX_SHORT, _("Rockets Picked Up : %d"), game.rocketPickups);
gfx_createTextObject(TS_CHRIS_ROCKET_PICKUPS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CHRIS_ROCKET_PICKUPS, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of powerups picked up. /// Retain "%d" as-is. It is replaced with the number of powerups picked up.
sprintf(string, _("Powerups Picked Up : %d"), game.powerups); snprintf(string, STRMAX_SHORT, _("Powerups Picked Up : %d"), game.powerups);
gfx_createTextObject(TS_CHRIS_POWERUP_PICKUPS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CHRIS_POWERUP_PICKUPS, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of mines destroyed. /// Retain "%d" as-is. It is replaced with the number of mines destroyed.
sprintf(string, _("Mines Destroyed : %d"), game.minesKilled); snprintf(string, STRMAX_SHORT, _("Mines Destroyed : %d"), game.minesKilled);
gfx_createTextObject(TS_CHRIS_MINES_KILLED, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CHRIS_MINES_KILLED, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of slaves rescued. /// Retain "%d" as-is. It is replaced with the number of slaves rescued.
sprintf(string, _("Slaves Rescued : %d"), game.slavesRescued); snprintf(string, STRMAX_SHORT, _("Slaves Rescued : %d"), game.slavesRescued);
gfx_createTextObject(TS_CHRIS_SLAVES_RESCUED, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CHRIS_SLAVES_RESCUED, string, 0, 0, FONT_WHITE);
if (game.hasWingMate1) if (game.hasWingMate1)
@ -312,12 +312,12 @@ static void intermission_setStatusLines()
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of kills. /// Retain "%d" as-is. It is replaced with the number of kills.
sprintf(string, _("Enemies Killed : %d"), game.wingMate1Kills); snprintf(string, STRMAX_SHORT, _("Enemies Killed : %d"), game.wingMate1Kills);
gfx_createTextObject(TS_PHOEBE_KILLS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_PHOEBE_KILLS, string, 0, 0, FONT_WHITE);
/// Retain /// Retain
/// Status Screen text "%d" as-is. It is replaced with the number of ejections. /// Status Screen text "%d" as-is. It is replaced with the number of ejections.
sprintf(string, _("Ejections : %d"), game.wingMate1Ejects); snprintf(string, STRMAX_SHORT, _("Ejections : %d"), game.wingMate1Ejects);
gfx_createTextObject(TS_PHOEBE_DEATHS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_PHOEBE_DEATHS, string, 0, 0, FONT_WHITE);
} }
else else
@ -334,12 +334,12 @@ static void intermission_setStatusLines()
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of kills. /// Retain "%d" as-is. It is replaced with the number of kills.
sprintf(string, _("Enemies Killed : %d"), game.wingMate2Kills); snprintf(string, STRMAX_SHORT, _("Enemies Killed : %d"), game.wingMate2Kills);
gfx_createTextObject(TS_URSULA_KILLS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_URSULA_KILLS, string, 0, 0, FONT_WHITE);
/// Status Screen text /// Status Screen text
/// Retain "%d" as-is. It is replaced with the number of ejections. /// Retain "%d" as-is. It is replaced with the number of ejections.
sprintf(string, _("Ejections : %d"), game.wingMate2Ejects); snprintf(string, STRMAX_SHORT, _("Ejections : %d"), game.wingMate2Ejects);
gfx_createTextObject(TS_URSULA_DEATHS, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_URSULA_DEATHS, string, 0, 0, FONT_WHITE);
} }
else else
@ -365,7 +365,7 @@ static void intermission_setStatusLines()
/// For example, the "%02ld" sequences may be changed to "%ld" if /// For example, the "%02ld" sequences may be changed to "%ld" if
/// you wish to not force two digits to be filled in (e.g. to render /// you wish to not force two digits to be filled in (e.g. to render
/// the number 3 as "3" instead of "03"). /// the number 3 as "3" instead of "03").
snprintf(string, sizeof string, _("Total Time : %ld:%02ld:%02ld"), timeTaken / 3600, (timeTaken / 60) % 60, timeTaken % 60); snprintf(string, STRMAX_SHORT, _("Total Time : %ld:%02ld:%02ld"), timeTaken / 3600, (timeTaken / 60) % 60, timeTaken % 60);
gfx_createTextObject(TS_STATUS_FOOTER, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_STATUS_FOOTER, string, 0, 0, FONT_WHITE);
} }
@ -811,7 +811,7 @@ static int intermission_renderDialog(SDL_Surface *comms, int y, int face, const
static void intermission_createMissionDetailSurface(SDL_Surface *comms, int missionSlot) static void intermission_createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
{ {
char string[2000]; char string[STRMAX];
int y = 10; int y = 10;
int misn = -1; int misn = -1;
@ -921,7 +921,7 @@ static void intermission_createMissionDetailSurface(SDL_Surface *comms, int miss
/// Mission dialog: Eyananth, interceptions (Sid Wilson) /// Mission dialog: Eyananth, interceptions (Sid Wilson)
/// "%d" must be retained as-is. It is replaced with the number of slaves that /// "%d" must be retained as-is. It is replaced with the number of slaves that
/// need to be rescued. /// need to be rescued.
sprintf(string, _("As you know, WEAPCO has many slaves in this system. If we free a large number of them, it might help to spark a rebellion. I estimate that we will need to rescue around %d to make a difference."), SLAVE_RESCUE_TARGET); snprintf(string, STRMAX, _("As you know, WEAPCO has many slaves in this system. If we free a large number of them, it might help to spark a rebellion. I estimate that we will need to rescue around %d to make a difference."), SLAVE_RESCUE_TARGET);
y = intermission_renderDialog(comms, y, FS_SID, string); y = intermission_renderDialog(comms, y, FS_SID, string);
/// Mission dialog: Eyananth, interceptions (Chris Bainfield) /// Mission dialog: Eyananth, interceptions (Chris Bainfield)
@ -1226,7 +1226,7 @@ static void intermission_createMissionDetailSurface(SDL_Surface *comms, int miss
strcpy(string, "Hey, why am I talking to myself? This shouldn't happen! Clearly, this must be a bug."); strcpy(string, "Hey, why am I talking to myself? This shouldn't happen! Clearly, this must be a bug.");
y = intermission_renderDialog(comms, y, FS_CHRIS, string); y = intermission_renderDialog(comms, y, FS_CHRIS, string);
sprintf(string, "I should go to starfighter.nongnu.org and report this bug there. In that report, I should mention that the mission number is %d.", misn); snprintf(string, STRMAX, "I should go to starfighter.nongnu.org and report this bug there. In that report, I should mention that the mission number is %d.", misn);
y = intermission_renderDialog(comms, y, FS_CHRIS, string); y = intermission_renderDialog(comms, y, FS_CHRIS, string);
strcpy(string, "Wait, what am I still talking into empty space for? It's not like anyone can hear me..."); strcpy(string, "Wait, what am I still talking into empty space for? It's not like anyone can hear me...");
@ -1502,7 +1502,7 @@ int intermission()
audio_playMusic("music/through_space.ogg", -1); audio_playMusic("music/through_space.ogg", -1);
/// Retain "%s" as-is. It is replaced with the current system name. /// Retain "%s" as-is. It is replaced with the current system name.
sprintf(string, _("System : %s"), game_systemNames[game.system]); snprintf(string, STRMAX_SHORT, _("System : %s"), game_systemNames[game.system]);
gfx_createTextObject(TS_CURRENT_SYSTEM, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_CURRENT_SYSTEM, string, 0, 0, FONT_WHITE);
gfx_createTextObject(TS_INFO_START_MISSION, _("Start Next Mission"), 0, 0, FONT_WHITE); gfx_createTextObject(TS_INFO_START_MISSION, _("Start Next Mission"), 0, 0, FONT_WHITE);
@ -1517,14 +1517,14 @@ int intermission()
/// Retain "%s" as-is. It is replaced with the name of the planet /// Retain "%s" as-is. It is replaced with the name of the planet
/// the player is currently stationed on. /// the player is currently stationed on.
sprintf(string, _("Stationed At: %s"), intermission_planets[game.stationedPlanet].name); snprintf(string, STRMAX_SHORT, _("Stationed At: %s"), intermission_planets[game.stationedPlanet].name);
gfx_createTextObject(TS_CURRENT_PLANET, string, 90, 0, FONT_WHITE); gfx_createTextObject(TS_CURRENT_PLANET, string, 90, 0, FONT_WHITE);
if (game.destinationPlanet > -1) if (game.destinationPlanet > -1)
{ {
/// Retain "%s" as-is. It is replaced with the name of the planet /// Retain "%s" as-is. It is replaced with the name of the planet
/// the player's destination is currently set to. /// the player's destination is currently set to.
sprintf(string, _("Destination: %s"), intermission_planets[game.destinationPlanet].name); snprintf(string, STRMAX_SHORT, _("Destination: %s"), intermission_planets[game.destinationPlanet].name);
} }
else else
{ {
@ -1639,7 +1639,7 @@ int intermission()
{ {
/// Retain "%s" as-is. It is replaced with the name of the planet /// Retain "%s" as-is. It is replaced with the name of the planet
/// the player's destination is currently set to. /// the player's destination is currently set to.
sprintf(string, "Destination: %s", intermission_planets[game.destinationPlanet].name); snprintf(string, STRMAX_SHORT, "Destination: %s", intermission_planets[game.destinationPlanet].name);
gfx_createTextObject(TS_DEST_PLANET, string, 0, 0, FONT_WHITE); gfx_createTextObject(TS_DEST_PLANET, string, 0, 0, FONT_WHITE);
} }
@ -1701,7 +1701,7 @@ int intermission()
player.shield = player.maxShield; player.shield = player.maxShield;
/// Retain "%s" as-is. It is replaced with the name of the planet /// Retain "%s" as-is. It is replaced with the name of the planet
/// the player's destination is currently set to. /// the player's destination is currently set to.
sprintf(string, _("Stationed At: %s"), snprintf(string, STRMAX_SHORT, _("Stationed At: %s"),
intermission_planets[game.stationedPlanet].name); intermission_planets[game.stationedPlanet].name);
gfx_createTextObject(TS_CURRENT_PLANET, string, 90, 0, FONT_WHITE); gfx_createTextObject(TS_CURRENT_PLANET, string, 90, 0, FONT_WHITE);
section = 1; section = 1;

View File

@ -651,7 +651,7 @@ static void mission_evaluate(int type, int id, int *completed, int *targetValue,
"$%d more to collect...\n" "$%d more to collect...\n"
"$%d more needed...", "$%d more needed...",
*targetValue)); *targetValue));
sprintf(message, fmt, *targetValue); snprintf(message, STRMAX_SHORT, fmt, *targetValue);
break; break;
case P_CARGO: case P_CARGO:
radio_getRandomMessage(fmt, ngettext( radio_getRandomMessage(fmt, ngettext(
@ -670,7 +670,7 @@ static void mission_evaluate(int type, int id, int *completed, int *targetValue,
"%d more cargo pods needed...\n" "%d more cargo pods needed...\n"
"Collect %d remaining cargo pods...", "Collect %d remaining cargo pods...",
*targetValue)); *targetValue));
sprintf(message, fmt, *targetValue); snprintf(message, STRMAX_SHORT, fmt, *targetValue);
break; break;
case P_ORE: case P_ORE:
radio_getRandomMessage(fmt,ngettext( radio_getRandomMessage(fmt,ngettext(
@ -687,7 +687,7 @@ static void mission_evaluate(int type, int id, int *completed, int *targetValue,
"%d more pieces of ore to collect...\n" "%d more pieces of ore to collect...\n"
"%d more pieces of ore needed...", "%d more pieces of ore needed...",
*targetValue)); *targetValue));
sprintf(message, fmt, *targetValue); snprintf(message, STRMAX_SHORT, fmt, *targetValue);
break; break;
} }
break; break;
@ -696,14 +696,14 @@ static void mission_evaluate(int type, int id, int *completed, int *targetValue,
switch(id) switch(id)
{ {
case P_CARGO: case P_CARGO:
sprintf(message, _("Cargo pod destroyed!")); strcpy(message, _("Cargo pod destroyed!"));
if (game.area == MISN_CERADSE) // Get lectured by Sid if (game.area == MISN_CERADSE) // Get lectured by Sid
/// Dialog (Sid Wilson) /// Dialog (Sid Wilson)
/// Used when a cargo pod is destroyed in the Ceradse mission. /// Used when a cargo pod is destroyed in the Ceradse mission.
radio_setMessage(FS_SID, _("Chris, we needed that pod! I told you that we couldn't afford to lose a single one!"), 1); radio_setMessage(FS_SID, _("Chris, we needed that pod! I told you that we couldn't afford to lose a single one!"), 1);
break; break;
case P_ESCAPEPOD: case P_ESCAPEPOD:
sprintf(message, _("Escape Pod lost!")); strcpy(message, _("Escape Pod lost!"));
if (game.area == MISN_ODEON) // Get lectured by Phoebe if (game.area == MISN_ODEON) // Get lectured by Phoebe
{ {
/// Dialog (Phoebe Lexx) /// Dialog (Phoebe Lexx)
@ -757,7 +757,7 @@ static void mission_evaluate(int type, int id, int *completed, int *targetValue,
"%d targets remain...\n" "%d targets remain...\n"
"Destroy %d remaining targets...", "Destroy %d remaining targets...",
*targetValue)); *targetValue));
sprintf(message, fmt, *targetValue); snprintf(message, STRMAX_SHORT, fmt, *targetValue);
} }
break; break;
case M_DISABLE_TARGET: case M_DISABLE_TARGET:
@ -775,7 +775,7 @@ static void mission_evaluate(int type, int id, int *completed, int *targetValue,
"%d more targets to disable...\n" "%d more targets to disable...\n"
"Disable %d remaining targets...", "Disable %d remaining targets...",
*targetValue)); *targetValue));
sprintf(message, fmt, *targetValue); snprintf(message, STRMAX_SHORT, fmt, *targetValue);
break; break;
} }
@ -877,7 +877,7 @@ void mission_updateRequirements(int type, int id, int value)
"At least %d more slaves to rescue...\n" "At least %d more slaves to rescue...\n"
"At least %d more rescued slaves needed...", "At least %d more rescued slaves needed...",
slavesNeeded)); slavesNeeded));
sprintf(message, fmt, slavesNeeded); snprintf(message, STRMAX_SHORT, fmt, slavesNeeded);
info_setLine(message, FONT_CYAN); info_setLine(message, FONT_CYAN);
} }
} }
@ -1151,6 +1151,8 @@ mission begins playing here.
*/ */
void mission_showStartScreen() void mission_showStartScreen()
{ {
char temp[STRMAX_SHORT];
screen_clear(black); screen_clear(black);
renderer_update(); renderer_update();
@ -1184,18 +1186,17 @@ void mission_showStartScreen()
if (mission.timeLimit1[0] > 0) if (mission.timeLimit1[0] > 0)
{ {
char temp[50];
if (game.area != MISN_MARS) if (game.area != MISN_MARS)
{ {
/// "%d" must be retained. It is replaced with the mission time /// "%d" must be retained. It is replaced with the mission time
/// limit in minutes. /// limit in minutes.
sprintf(temp, _("TIME LIMIT: %d minutes"), mission.timeLimit1[0]); snprintf(temp, STRMAX_SHORT, _("TIME LIMIT: %d minutes"), mission.timeLimit1[0]);
} }
else else
{ {
/// "%d" must be retained. It is replaced with the mission required /// "%d" must be retained. It is replaced with the mission required
/// survival time in minutes. /// survival time in minutes.
sprintf(temp, _("SURVIVAL FOR %d minutes"), mission.timeLimit1[0]); snprintf(temp, STRMAX_SHORT, _("SURVIVAL FOR %d minutes"), mission.timeLimit1[0]);
} }
screen_renderUnicode(temp, -1, screen->h / 2 + 195, FONT_RED); screen_renderUnicode(temp, -1, screen->h / 2 + 195, FONT_RED);
} }
@ -1246,7 +1247,7 @@ of the screen.
void mission_showFinishedScreen() void mission_showFinishedScreen()
{ {
int shield_bonus; int shield_bonus;
char temp[STRMAX]; char temp[STRMAX_SHORT];
if (game.area != MISN_INTERCEPTION) if (game.area != MISN_INTERCEPTION)
{ {
@ -1342,7 +1343,7 @@ void mission_showFinishedScreen()
{ {
/// "%d" must be retained. It is replaced with the money earned /// "%d" must be retained. It is replaced with the money earned
/// from the shield bonus. /// from the shield bonus.
sprintf(temp, _("Shield Bonus: $%d"), shield_bonus); snprintf(temp, STRMAX_SHORT, _("Shield Bonus: $%d"), shield_bonus);
screen_renderUnicode(temp, -1, screen->h / 2 + 130, FONT_WHITE); screen_renderUnicode(temp, -1, screen->h / 2 + 130, FONT_WHITE);
} }
@ -1358,7 +1359,7 @@ void mission_showFinishedScreen()
/// the "%02ld" sequences may be changed to "%ld" if you wish to /// the "%02ld" sequences may be changed to "%ld" if you wish to
/// not force two digits to be filled in (e.g. to render the number /// not force two digits to be filled in (e.g. to render the number
/// 3 as "3" instead of "03"). /// 3 as "3" instead of "03").
snprintf(temp, sizeof temp, _("Mission Time: %02ld:%02ld"), engine.timeTaken / 60, engine.timeTaken % 60); snprintf(temp, STRMAX_SHORT, _("Mission Time: %02ld:%02ld"), engine.timeTaken / 60, engine.timeTaken % 60);
screen_renderUnicode(temp, -1, screen->h / 2 + 200, FONT_WHITE); screen_renderUnicode(temp, -1, screen->h / 2 + 200, FONT_WHITE);

View File

@ -35,7 +35,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "screen.h" #include "screen.h"
#include "weapons.h" #include "weapons.h"
static char saveSlot[10][25]; static char saveSlot[10][STRMAX_SHORT];
/* /*
Reads in each save game that it finds and gives it an appropriate Reads in each save game that it finds and gives it an appropriate
@ -60,20 +60,20 @@ int save_initSlots()
//READ SAVE GAME DATA //READ SAVE GAME DATA
for (int i = 0 ; i <= 5 ; i++) for (int i = 0 ; i <= 5 ; i++)
{ {
sprintf(fileName, "%ssave%.2d.sav", engine.configDirectory, i); snprintf(fileName, PATH_MAX, "%ssave%.2d.sav", engine.configDirectory, i);
fp = fopen(fileName, "r"); fp = fopen(fileName, "r");
if (fp != NULL) if (fp != NULL)
{ {
if (fscanf(fp, "%d%*c", &game.saveFormat) < 1) if (fscanf(fp, "%d%*c", &game.saveFormat) < 1)
{ {
printf("Error: Could not determine the version of the save file.\n"); printf("Error: Could not determine the version of the save file.\n");
sprintf(saveSlot[i], "Corrupt Game Data"); strcpy(saveSlot[i], "Corrupt Game Data");
} }
else else
{ {
if (i == 0) if (i == 0)
{ {
sprintf(saveSlot[i], _("AUTOSAVE")); strcpy(saveSlot[i], _("AUTOSAVE"));
continueSaveIndex = 0; continueSaveIndex = 0;
} }
else else
@ -81,11 +81,11 @@ int save_initSlots()
if (fscanf(fp, "%*[^\n]%*c%*[^\n]%*c%d %*d %*d%*c%[^\n]%*c", &system, if (fscanf(fp, "%*[^\n]%*c%*[^\n]%*c%d %*d %*d%*c%[^\n]%*c", &system,
stationedName) < 2) stationedName) < 2)
{ {
sprintf(saveSlot[i], _("Corrupt Game Data")); strcpy(saveSlot[i], _("Corrupt Game Data"));
} }
else else
{ {
sprintf(saveSlot[i], "%s, %s", game_systemNames[system], snprintf(saveSlot[i], STRMAX_SHORT, "%s, %s", game_systemNames[system],
stationedName); stationedName);
} }
} }
@ -104,13 +104,13 @@ int save_initSlots()
} }
else else
{ {
sprintf(fileName, "%ssave%.2d.dat", engine.configDirectory, i); snprintf(fileName, PATH_MAX, "%ssave%.2d.dat", engine.configDirectory, i);
fp = fopen(fileName, "r"); fp = fopen(fileName, "r");
if (fp == NULL) if (fp == NULL)
{ {
/// Used for empty save slots. /// Used for empty save slots.
sprintf(saveSlot[i], (i == 0 ? _("AUTOSAVE (Empty)") : _("Empty"))); strcpy(saveSlot[i], (i == 0 ? _("AUTOSAVE (Empty)") : _("Empty")));
if (engine.gameSection == SECTION_TITLE) if (engine.gameSection == SECTION_TITLE)
gfx_createTextObject(TS_SAVESLOT_0 + i, saveSlot[i], gfx_createTextObject(TS_SAVESLOT_0 + i, saveSlot[i],
0, imagePos, FONT_WHITE); 0, imagePos, FONT_WHITE);
@ -119,18 +119,18 @@ int save_initSlots()
{ {
if (i == 0) if (i == 0)
{ {
sprintf(saveSlot[i], _("AUTOSAVE")); strcpy(saveSlot[i], _("AUTOSAVE"));
continueSaveIndex = 0; continueSaveIndex = 0;
} }
else else
{ {
if (fread(&tempGame, sizeof(Game), 1, fp) != 1) if (fread(&tempGame, sizeof(Game), 1, fp) != 1)
{ {
sprintf(saveSlot[i], _("Corrupt Game Data")); strcpy(saveSlot[i], _("Corrupt Game Data"));
} }
else else
{ {
sprintf(saveSlot[i], "%s, %s", game_systemNames[tempGame.system], snprintf(saveSlot[i], STRMAX_SHORT, "%s, %s", game_systemNames[tempGame.system],
tempGame.stationedName); tempGame.stationedName);
} }
} }
@ -163,7 +163,7 @@ int save_load(int slot)
FILE *fp; FILE *fp;
unsigned long timeTaken; unsigned long timeTaken;
sprintf(filename, "%ssave%.2d.sav", engine.configDirectory, slot); snprintf(filename, PATH_MAX, "%ssave%.2d.sav", engine.configDirectory, slot);
fp = fopen(filename, "r"); fp = fopen(filename, "r");
if (fp != NULL) if (fp != NULL)
@ -233,7 +233,7 @@ int save_load(int slot)
} }
else else
{ {
sprintf(filename, "%ssave%.2d.dat", engine.configDirectory, slot); snprintf(filename, PATH_MAX, "%ssave%.2d.dat", engine.configDirectory, slot);
fp = fopen(filename, "rb"); fp = fopen(filename, "rb");
if (fp == NULL) if (fp == NULL)
@ -281,7 +281,7 @@ void save(int slot)
return; return;
} }
sprintf(fileName, "%ssave%.2d.sav", engine.configDirectory, slot); snprintf(fileName, PATH_MAX, "%ssave%.2d.sav", engine.configDirectory, slot);
fp = fopen(fileName, "w"); fp = fopen(fileName, "w");
@ -456,7 +456,7 @@ int save_showSlots(SDL_Surface *savesSurface, int saveSlot, int x, int y)
x + 253, y + 265, 100, 25)) x + 253, y + 265, 100, 25))
{ {
char filename[PATH_MAX]; char filename[PATH_MAX];
sprintf(filename, "%ssave%.2d.sav", engine.configDirectory, snprintf(filename, PATH_MAX, "%ssave%.2d.sav", engine.configDirectory,
saveSlot); saveSlot);
remove(filename); remove(filename);
save_initSlots(); save_initSlots();

View File

@ -52,7 +52,7 @@ static void sell(int i);
static void drawSecondaryWeaponSurface() static void drawSecondaryWeaponSurface()
{ {
char description[50] = ""; char description[STRMAX_SHORT] = "";
gfx_renderUnicode(_("Secondary Weapon"), 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]); gfx_renderUnicode(_("Secondary Weapon"), 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]);
@ -101,7 +101,7 @@ static void drawSecondaryWeaponSurface()
(player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_NONE)) (player.weaponType[1] != W_CHARGER) && (player.weaponType[1] != W_NONE))
{ {
/// Retain "%d" as-is. It is replaced with the rocket capacity of the Firefly. /// Retain "%d" as-is. It is replaced with the rocket capacity of the Firefly.
sprintf(description, _("Capacity : %d"), game.maxRocketAmmo); snprintf(description, STRMAX_SHORT, _("Capacity : %d"), game.maxRocketAmmo);
gfx_renderUnicode(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]); gfx_renderUnicode(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SECONDARY]);
} }
} }
@ -285,38 +285,38 @@ static void drawShop()
gfx_renderUnicode(_("Primary Weapon"), 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); gfx_renderUnicode(_("Primary Weapon"), 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]);
/// Shop info: min plasma output /// Shop info: min plasma output
/// Retain "%d" as-is. It is replaced with the min plasma output. /// Retain "%d" as-is. It is replaced with the min plasma output.
sprintf(description, _("Cannons: %d"), game.minPlasmaOutput); snprintf(description, STRMAX, _("Cannons: %d"), game.minPlasmaOutput);
gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]);
/// Shop info: min plasma damage /// Shop info: min plasma damage
/// Retain "%d" as-is. It is replaced with the min plasma damage. /// Retain "%d" as-is. It is replaced with the min plasma damage.
sprintf(description, _("Power: Stage %d"), snprintf(description, STRMAX, _("Power: Stage %d"),
game.minPlasmaDamage); game.minPlasmaDamage);
gfx_renderUnicode(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); gfx_renderUnicode(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]);
/// Shop info: min plasma rate /// Shop info: min plasma rate
/// Retain "%d" as-is. It is replaced with the min plasma cooling. /// Retain "%d" as-is. It is replaced with the min plasma cooling.
sprintf(description, _("Cooling: Stage %d"), snprintf(description, STRMAX, _("Cooling: Stage %d"),
game.minPlasmaRate); game.minPlasmaRate);
gfx_renderUnicode(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]); gfx_renderUnicode(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_PRIMARY]);
gfx_renderUnicode(_("Powerup Weapon"), 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); gfx_renderUnicode(_("Powerup Weapon"), 10, 3, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]);
/// Shop info: max plasma output /// Shop info: max plasma output
/// Retain "%d" as-is. It is replaced with the max plasma output. /// Retain "%d" as-is. It is replaced with the max plasma output.
sprintf(description, _("Splitter: Stage %d"), snprintf(description, STRMAX, _("Splitter: Stage %d"),
game.maxPlasmaOutput); game.maxPlasmaOutput);
gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]);
/// Shop info: max plasma damage /// Shop info: max plasma damage
/// Retain "%d" as-is. It is replaced with the max plasma damage. /// Retain "%d" as-is. It is replaced with the max plasma damage.
sprintf(description, _("Condensor: Stage %d"), snprintf(description, STRMAX, _("Condensor: Stage %d"),
game.maxPlasmaDamage); game.maxPlasmaDamage);
gfx_renderUnicode(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); gfx_renderUnicode(description, 10, 37, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]);
/// Shop info: max plasma rate /// Shop info: max plasma rate
/// Retain "%d" as-is. It is replaced with the max plasma cooling. /// Retain "%d" as-is. It is replaced with the max plasma cooling.
sprintf(description, _("L.Nitrogen: Stage %d"), snprintf(description, STRMAX, _("L.Nitrogen: Stage %d"),
game.maxPlasmaRate); game.maxPlasmaRate);
gfx_renderUnicode(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); gfx_renderUnicode(description, 10, 52, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]);
/// Shop info: max plasma ammo /// Shop info: max plasma ammo
/// Retain "%d" as-is. It is replaced with the Firefly's plasma ammo capacity. /// Retain "%d" as-is. It is replaced with the Firefly's plasma ammo capacity.
sprintf(description, _("Capacity: %d"), game.maxPlasmaAmmo); snprintf(description, STRMAX, _("Capacity: %d"), game.maxPlasmaAmmo);
gfx_renderUnicode(description, 10, 67, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]); gfx_renderUnicode(description, 10, 67, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_POWERUP]);
drawSecondaryWeaponSurface(); drawSecondaryWeaponSurface();
@ -346,20 +346,20 @@ static void drawShop()
} }
/// Retain "%d" as-is. It is replaced with the Firefly's max shield. /// Retain "%d" as-is. It is replaced with the Firefly's max shield.
sprintf(description, _("Shield: %d"), player.maxShield); snprintf(description, STRMAX, _("Shield: %d"), player.maxShield);
gfx_renderUnicode(description, 10, 6, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); gfx_renderUnicode(description, 10, 6, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]);
/// Retain "%d" as-is. It is replaced with the player's current cash. /// Retain "%d" as-is. It is replaced with the player's current cash.
sprintf(description, _("Cash: $%d"), game.cash); snprintf(description, STRMAX, _("Cash: $%d"), game.cash);
gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); gfx_renderUnicode(description, 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]);
/// Retain "%.3d". It is replaced with the ship's current number of plasma cells. /// Retain "%.3d". It is replaced with the ship's current number of plasma cells.
/// "%.3d" can be changed to "%d" if you wish to not fill in space with zeroes, /// "%.3d" can be changed to "%d" if you wish to not fill in space with zeroes,
/// e.g. render the number 5 as "5" rather than "005". /// e.g. render the number 5 as "5" rather than "005".
sprintf(description, _("Plasma Cells: %.3d"), player.ammo[0]); snprintf(description, STRMAX, _("Plasma Cells: %.3d"), player.ammo[0]);
gfx_renderUnicode(description, SHOP_WIDTH - gfx_unicodeWidth(description) - 10, 6, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); gfx_renderUnicode(description, SHOP_WIDTH - gfx_unicodeWidth(description) - 10, 6, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]);
/// Retain "%.2d". It is replaced with the ship's current number of rockets. /// Retain "%.2d". It is replaced with the ship's current number of rockets.
/// "%.2d" can be changed to "%d" if you wish to not fill in space with zeroes, /// "%.2d" can be changed to "%d" if you wish to not fill in space with zeroes,
/// e.g. render the number 3 as "3" rather than "03". /// e.g. render the number 3 as "3" rather than "03".
sprintf(description, _("Rockets: %.2d"), player.ammo[1]); snprintf(description, STRMAX, _("Rockets: %.2d"), player.ammo[1]);
gfx_renderUnicode(description, SHOP_WIDTH - gfx_unicodeWidth(description) - 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]); gfx_renderUnicode(description, SHOP_WIDTH - gfx_unicodeWidth(description) - 10, 22, FONT_WHITE, 0, gfx_shopSprites[SHOP_S_SHIP_INFO]);
gfx_shopSprites[SHOP_S_ITEM_INFO] = gfx_createSurface(SHOP_WIDTH + 1, 56); gfx_shopSprites[SHOP_S_ITEM_INFO] = gfx_createSurface(SHOP_WIDTH + 1, 56);
@ -414,7 +414,7 @@ static void drawShop()
/// Used to put a shop item's name next to its price. /// Used to put a shop item's name next to its price.
/// "%s" is replaced with the item name, and "%d" is replaced /// "%s" is replaced with the item name, and "%d" is replaced
/// with the item price. /// with the item price.
sprintf(description, _("%s ($%d)"), snprintf(description, STRMAX, _("%s ($%d)"),
shopItems[shopSelectedItem].description, shopItems[shopSelectedItem].description,
shopItems[shopSelectedItem].price); shopItems[shopSelectedItem].price);
} }
@ -422,7 +422,7 @@ static void drawShop()
{ {
/// Used for shop items that cannot be bought. /// Used for shop items that cannot be bought.
/// "%s" is replaced with the item name. /// "%s" is replaced with the item name.
sprintf(description, _("%s (N/A)"), snprintf(description, STRMAX, _("%s (N/A)"),
shopItems[shopSelectedItem].description); shopItems[shopSelectedItem].description);
} }
gfx_renderUnicode(shopItems[shopSelectedItem].name, 5, 22, gfx_renderUnicode(shopItems[shopSelectedItem].name, 5, 22,
@ -533,7 +533,7 @@ void shop_init()
/// Shop item description: Homing Missile Launcher /// Shop item description: Homing Missile Launcher
/// %i must be retained. It is replaced by the maximum missile /// %i must be retained. It is replaced by the maximum missile
/// capacity of the weapon. /// capacity of the weapon.
sprintf(shopItems[SHOP_HOMING_MISSILE].description, _("Fires homing missile (max %i missiles)"), MAX_HOMING); snprintf(shopItems[SHOP_HOMING_MISSILE].description, STRMAX, _("Fires homing missile (max %i missiles)"), MAX_HOMING);
shopItems[SHOP_HOMING_MISSILE].image = SP_HOMING_MISSILE; shopItems[SHOP_HOMING_MISSILE].image = SP_HOMING_MISSILE;
shopItems[SHOP_CHARGER].price = 10000; shopItems[SHOP_CHARGER].price = 10000;
@ -547,7 +547,7 @@ void shop_init()
/// Shop item description: Dual Homing Missile Launcher /// Shop item description: Dual Homing Missile Launcher
/// %i must be retained. It is replaced by the maximum missile /// %i must be retained. It is replaced by the maximum missile
/// capacity of the weapon. /// capacity of the weapon.
sprintf(shopItems[SHOP_DOUBLE_HOMING_MISSILES].description, _("Fires two homing missiles (max %i missiles)"), MAX_DOUBLE_HOMING); snprintf(shopItems[SHOP_DOUBLE_HOMING_MISSILES].description, STRMAX, _("Fires two homing missiles (max %i missiles)"), MAX_DOUBLE_HOMING);
shopItems[SHOP_DOUBLE_HOMING_MISSILES].image = SP_DOUBLE_HOMING_MISSILES; shopItems[SHOP_DOUBLE_HOMING_MISSILES].image = SP_DOUBLE_HOMING_MISSILES;
shopItems[SHOP_MICRO_HOMING_MISSILES].price = 15000; shopItems[SHOP_MICRO_HOMING_MISSILES].price = 15000;
@ -555,7 +555,7 @@ void shop_init()
/// Shop item description: Micro Homing Missile Launcher /// Shop item description: Micro Homing Missile Launcher
/// %i must be retained. It is replaced by the maximum missile /// %i must be retained. It is replaced by the maximum missile
/// capacity of the weapon. /// capacity of the weapon.
sprintf(shopItems[SHOP_MICRO_HOMING_MISSILES].description, _("Fires several small homing missiles (max %i missiles)"), MAX_MICRO_HOMING); snprintf(shopItems[SHOP_MICRO_HOMING_MISSILES].description, STRMAX, _("Fires several small homing missiles (max %i missiles)"), MAX_MICRO_HOMING);
shopItems[SHOP_MICRO_HOMING_MISSILES].image = SP_MICRO_HOMING_MISSILES; shopItems[SHOP_MICRO_HOMING_MISSILES].image = SP_MICRO_HOMING_MISSILES;
shopSelectedItem = SHOP_NOTHING; shopSelectedItem = SHOP_NOTHING;

View File

@ -195,7 +195,7 @@ int title_show()
int redGlow = 255; int redGlow = 255;
int redDir = -2; int redDir = -2;
char buildVersion[25]; char buildVersion[STRMAX_SHORT];
int selectedOption = 1; int selectedOption = 1;
int skip = 0; int skip = 0;
@ -255,7 +255,7 @@ int title_show()
gfx_renderString("Copyright 2015-2019 Layla Marchant", gfx_renderString("Copyright 2015-2019 Layla Marchant",
5, 2 * MENU_SPACING, FONT_WHITE, 0, copyrightText); 5, 2 * MENU_SPACING, FONT_WHITE, 0, copyrightText);
sprintf(buildVersion, "Version %s", VERSION ); snprintf(buildVersion, STRMAX_SHORT, "Version %s", VERSION );
infoText = gfx_createSurface(strlen(buildVersion) * (PIXFONT_W + 1) + 6, MENU_SPACING); infoText = gfx_createSurface(strlen(buildVersion) * (PIXFONT_W + 1) + 6, MENU_SPACING);
gfx_renderString(buildVersion, 0, 0, FONT_WHITE, 0, infoText); gfx_renderString(buildVersion, 0, 0, FONT_WHITE, 0, infoText);