Remove useless string initialisation code.

In many places strings were initialised with strcpy(string, "") right
before the string was overwritten by another function. In the few cases
where this really might have been useful, just use a static initialiser.
This commit is contained in:
Guus Sliepen 2012-03-11 15:16:19 +01:00
parent 7f58f02277
commit a45df516df
7 changed files with 6 additions and 17 deletions

View File

@ -85,7 +85,6 @@ static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
blevelRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
strcpy(string, "");
sprintf(string, "data/brief%d.txt", mission);
#if USEPACK

View File

@ -74,7 +74,6 @@ void showErrorAndExit(int errorId, const char *name)
switch(errorId)
{
case 0:
strcpy(string, "");
sprintf(string, "%s was not found in the Starfighter data package", name);
drawString(string, -1, 250, FONT_WHITE);
drawString("Please try again. If this error persists, contact the authors", -1, 275, FONT_WHITE);

View File

@ -380,9 +380,10 @@ static void evaluateRequirement(int type, int id, int *completed, int *targetVal
case M_DESTROY_TARGET_TYPE:
if ((*targetValue <= 10) || (*targetValue % 10 == 0))
{
sprintf(message, "Destroy %d more...", *targetValue);
if ((rand() % 2) == 0)
sprintf(message, "%d more to go...", *targetValue);
else
sprintf(message, "Destroy %d more...", *targetValue);
}
break;
case M_DISABLE_TARGET:
@ -480,8 +481,7 @@ Missions 11 and 23 to be exact!
static char revealHiddenObjectives()
{
char allDone = 1;
char string[255];
strcpy(string, "");
char string[255] = "";
for (int i = 0 ; i < 3 ; i++)
{
@ -733,7 +733,6 @@ void missionBriefScreen()
if (currentMission.timeLimit1[0] > 0)
{
char temp[50];
strcpy(temp, "");
if (currentGame.area != 24)
sprintf(temp, "TIME LIMIT: %d minutes", currentMission.timeLimit1[0]);
else
@ -921,7 +920,6 @@ static void loadMissions()
for (int i = 0 ; i < MAX_MISSIONS ; i++)
{
strcpy(filename, "");
sprintf(filename, "data/mission%.2d.dat", i);
#if USEPACK
@ -987,7 +985,6 @@ static void saveMissions()
for (int i = 0 ; i < MAX_MISSIONS ; i++)
{
strcpy(filename, "");
sprintf(filename, "data/mission%.2d.dat", i);
//WRITE MISSION DATA

View File

@ -34,14 +34,13 @@ void loadBackground(const char *filename)
void loadGameGraphics()
{
int index;
char string[75];
char string[75] = "";
freeGraphics();
shipShape[0] = loadImage("gfx/firefly1.png");
shipShape[1] = loadImage("gfx/firefly2.png");
strcpy(string, "");
switch(currentGame.system)
{
case 0:

View File

@ -53,7 +53,6 @@ void loadScriptEvents()
setKlineGreeting();
char filename[255];
strcpy(filename, "");
sprintf(filename, "data/script%d.txt", currentGame.area);
FILE *fp;
@ -143,7 +142,6 @@ static void setScene(int scene)
float sx, sy, x, y, speed;
int index, shape;
strcpy(string, "");
sprintf(string, "data/cutscene%d.dat", scene);
#if USEPACK

View File

@ -25,8 +25,7 @@ static signed char shopSelectedItem;
static void drawSecondaryWeaponSurface()
{
char description[50];
strcpy(description, "");
char description[50] = "";
drawString("Secondary Weapon", 10, 3, FONT_WHITE, shopSurface[2]);

View File

@ -110,14 +110,12 @@ When it is found, return the location.
*/
int locateDataInPak(const char *file, bool required)
{
char packFilename[60];
char packFilename[60] = "";
int packFSize;
int location = 0;
FILE *pak;
strcpy(packFilename, "");
pak = fopen(PACKLOCATION, "rb");
if (pak == NULL)
{