Corrected bad use of fscanf.
In most cases, this has also resulted in limits being lifted. (The only place I haven't done this is for planets in intermission.cpp, but I think I'll take away that 10-planet limit as well.)
This commit is contained in:
parent
e6c59d2a24
commit
d4d64dda6b
|
@ -1,5 +1,4 @@
|
||||||
Krass Tyler
|
Krass Tyler
|
||||||
8
|
|
||||||
FACE_KRASS
|
FACE_KRASS
|
||||||
Hey, boy! You still owe me money for the Firefly I stole for you! But instead, I want you to go to the WEAPCO training ground and destroy all the craft there.
|
Hey, boy! You still owe me money for the Firefly I stole for you! But instead, I want you to go to the WEAPCO training ground and destroy all the craft there.
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Phoebe Lexx
|
Phoebe Lexx
|
||||||
6
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
A WEAPCO scientist just fled in an escape pod, I'm going after them.
|
A WEAPCO scientist just fled in an escape pod, I'm going after them.
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Phoebe Lexx
|
Phoebe Lexx
|
||||||
10
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
I've received word that a rebellion is underway thanks to the slave being rescued.
|
I've received word that a rebellion is underway thanks to the slave being rescued.
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
8
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
What have you managed to find out about that experimental fighter?
|
What have you managed to find out about that experimental fighter?
|
||||||
FACE_SID
|
FACE_SID
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Phoebe Lexx
|
Phoebe Lexx
|
||||||
10
|
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
I've located my sister's ship currently in orbit around Odeon. She's ignoring my hails though.
|
I've located my sister's ship currently in orbit around Odeon. She's ignoring my hails though.
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
4
|
|
||||||
FACE_SID
|
FACE_SID
|
||||||
A rebel group in this sector has organised a counter strike. If we can help them secure a victory it will be a real boost to morale.
|
A rebel group in this sector has organised a counter strike. If we can help them secure a victory it will be a real boost to morale.
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
6
|
|
||||||
FACE_SID
|
FACE_SID
|
||||||
Seems like taking out that WEAPCO mining ship wasn't such a good idea. The Ore it collected from those asteroids is needed in weapon production.
|
Seems like taking out that WEAPCO mining ship wasn't such a good idea. The Ore it collected from those asteroids is needed in weapon production.
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Krass Tyler
|
Krass Tyler
|
||||||
8
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
I need you to help us out with something. In order to give the rebellion here a chance we're taking out key WEAPCO plants.
|
I need you to help us out with something. In order to give the rebellion here a chance we're taking out key WEAPCO plants.
|
||||||
FACE_KRASS
|
FACE_KRASS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Ursula Lexx
|
Ursula Lexx
|
||||||
8
|
|
||||||
FACE_URSULA
|
FACE_URSULA
|
||||||
I've remembered something. WEAPCO are transporting some high level personnel to Poswic.
|
I've remembered something. WEAPCO are transporting some high level personnel to Poswic.
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Phoebe Lexx
|
Phoebe Lexx
|
||||||
6
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
Phoebe, I need you to keep an eye on things here! I'm going after that ship!
|
Phoebe, I need you to keep an eye on things here! I'm going after that ship!
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
8
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
We've got to start from the outside and work our way in. That will give us less chance of being flanked during the final operation.
|
We've got to start from the outside and work our way in. That will give us less chance of being flanked during the final operation.
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
8
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
Hey, Sid, what's up?
|
Hey, Sid, what's up?
|
||||||
FACE_SID
|
FACE_SID
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
8
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
We've got to start from the outside and work our way in. That will give us less chance of being flanked during the final operation.
|
We've got to start from the outside and work our way in. That will give us less chance of being flanked during the final operation.
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
8
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
We've got to start from the outside and work our way in. That will give us less chance of being flanked during the final operation.
|
We've got to start from the outside and work our way in. That will give us less chance of being flanked during the final operation.
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Phoebe and Ursula
|
Phoebe and Ursula
|
||||||
8
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
WEAPCO have set up a highly dangerous defense line between Saturn and Uranus. I'll need your help to take it out.
|
WEAPCO have set up a highly dangerous defense line between Saturn and Uranus. I'll need your help to take it out.
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
8
|
|
||||||
FACE_SID
|
FACE_SID
|
||||||
Whilst you were gone I picked up a distress call coming from around Jupiter.
|
Whilst you were gone I picked up a distress call coming from around Jupiter.
|
||||||
FACE_URSULA
|
FACE_URSULA
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
4
|
|
||||||
FACE_SID
|
FACE_SID
|
||||||
Chris, we've got a small problem. WEAPCO have mined the asteroid belt in the system. We'll need to clear a way through!
|
Chris, we've got a small problem. WEAPCO have mined the asteroid belt in the system. We'll need to clear a way through!
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Everyone
|
Everyone
|
||||||
8
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
Okay people, this is the big one. We go in fast and we go in hard. Don't hold back and hit them with everything we've got!
|
Okay people, this is the big one. We go in fast and we go in hard. Don't hold back and hit them with everything we've got!
|
||||||
FACE_SID
|
FACE_SID
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Kline Kethlan
|
Kline Kethlan
|
||||||
4
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
I'm going to give you one last warning, Kethlan - Surrender now!
|
I'm going to give you one last warning, Kethlan - Surrender now!
|
||||||
FACE_KLINE
|
FACE_KLINE
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
8
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
Missile boats?!!
|
Missile boats?!!
|
||||||
FACE_SID
|
FACE_SID
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
6
|
|
||||||
FACE_SID
|
FACE_SID
|
||||||
We're going to have to clear the mine field that's been building up here recently. I have a feeling that WEAPCO have deployed some miners in the area and are testing the effectiveness of the field. Removing the mines will help interplanetary traffic to start up again.
|
We're going to have to clear the mine field that's been building up here recently. I have a feeling that WEAPCO have deployed some miners in the area and are testing the effectiveness of the field. Removing the mines will help interplanetary traffic to start up again.
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
6
|
|
||||||
FACE_SID
|
FACE_SID
|
||||||
CHRIS!!!! We've got a major problem here!!! WEAPCO have decided to retaliate!! But they've decided it'll take too long to hunt you down so instead they're going to destroy Spirit! The explosion will destroy everything in the system!! You've only got about 3 minutes to destroy the frigate before it's in range!
|
CHRIS!!!! We've got a major problem here!!! WEAPCO have decided to retaliate!! But they've decided it'll take too long to hunt you down so instead they're going to destroy Spirit! The explosion will destroy everything in the system!! You've only got about 3 minutes to destroy the frigate before it's in range!
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
6
|
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
WEAPCO has many slaves in this system. If we free a large number of them, it might help to spark a rebellion movement.
|
WEAPCO has many slaves in this system. If we free a large number of them, it might help to spark a rebellion movement.
|
||||||
FACE_SID
|
FACE_SID
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
(unknown)
|
(unknown)
|
||||||
10
|
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
Help!! This is an SOS!! Can anyone hear me??! I was intercepted by a large WEAPCO force near Nerod! I'm in need of assistance!!
|
Help!! This is an SOS!! Can anyone hear me??! I was intercepted by a large WEAPCO force near Nerod! I'm in need of assistance!!
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
8
|
|
||||||
FACE_SID
|
FACE_SID
|
||||||
I've just received another SOS. This one is coming from a supply craft that is under attack.
|
I've just received another SOS. This one is coming from a supply craft that is under attack.
|
||||||
FACE_CHRIS
|
FACE_CHRIS
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
Sid Wilson
|
Sid Wilson
|
||||||
10
|
|
||||||
FACE_SID
|
FACE_SID
|
||||||
I need some resources before we leave, it'll make life a lot easier in Mordor. Problem is that the parts are proprietry of WEAPCO.
|
I need some resources before we leave, it'll make life a lot easier in Mordor. Problem is that the parts are proprietry of WEAPCO.
|
||||||
FACE_PHOEBE
|
FACE_PHOEBE
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
And so it was that in the year 2579 the galactic weapons corporation
|
|
||||||
WEAPCO was defeated thanks to the valiant efforts of a few determined
|
|
||||||
individuals; A cause that would be remembered throughout the rest of
|
|
||||||
human history as Project: Starfighter.
|
|
||||||
66
|
|
||||||
000 +++ CAST +++
|
000 +++ CAST +++
|
||||||
030 Chris Bainfield
|
030 Chris Bainfield
|
||||||
020 Krass Tylar
|
020 Krass Tylar
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
And so it was that in the year 2579 the galactic weapons corporation
|
||||||
|
WEAPCO was defeated thanks to the valiant efforts of a few determined
|
||||||
|
individuals; A cause that would be remembered throughout the rest of
|
||||||
|
human history as Project: Starfighter.
|
|
@ -7,4 +7,3 @@
|
||||||
40 The people cried out for a saviour... for someone to come and
|
40 The people cried out for a saviour... for someone to come and
|
||||||
20 light this dark hour...
|
20 light this dark hour...
|
||||||
80 ... and someone did.
|
80 ... and someone did.
|
||||||
-1
|
|
||||||
|
|
|
@ -294,14 +294,10 @@ static void getPreDefinedAliens()
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fscanf(fp, "%d ", &index);
|
while (fscanf(fp, "%d %d ", &index, &alienType) == 2)
|
||||||
|
|
||||||
while (index != -1)
|
|
||||||
{
|
{
|
||||||
placeAttempt = 0;
|
placeAttempt = 0;
|
||||||
|
|
||||||
fscanf(fp, "%d ", &alienType);
|
|
||||||
|
|
||||||
enemy[index] = defEnemy[alienType];
|
enemy[index] = defEnemy[alienType];
|
||||||
enemy[index].owner = &enemy[index];
|
enemy[index].owner = &enemy[index];
|
||||||
enemy[index].target = &enemy[index];
|
enemy[index].target = &enemy[index];
|
||||||
|
@ -311,7 +307,7 @@ static void getPreDefinedAliens()
|
||||||
/*
|
/*
|
||||||
we make 1000 attempts to place this enemy since it is required. If after 1000 attempts
|
we make 1000 attempts to place this enemy since it is required. If after 1000 attempts
|
||||||
we still have managed to place the alien, then it simple isn't going to happen and we
|
we still have managed to place the alien, then it simple isn't going to happen and we
|
||||||
will just exit the same. The chances of this happening are very very low!
|
will just exit the game. The chances of this happening are very very low!
|
||||||
*/
|
*/
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -376,8 +372,6 @@ static void getPreDefinedAliens()
|
||||||
if (index == WC_BOSS)
|
if (index == WC_BOSS)
|
||||||
enemy[index].chance[1] = 5;
|
enemy[index].chance[1] = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
fscanf(fp, "%d ", &index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
|
@ -86,15 +86,16 @@ static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
|
||||||
|
|
||||||
fp = fopen(string, "rb");
|
fp = fopen(string, "rb");
|
||||||
|
|
||||||
fscanf(fp, "%[^\n]%*c", name);
|
if (fscanf(fp, "%[^\n]%*c", name) < 1)
|
||||||
|
{
|
||||||
|
printf("Warning: Failed to retrieve name from \"%s\"\n", string);
|
||||||
|
strcpy(name, "Error");
|
||||||
|
}
|
||||||
sprintf(string, "+++ Communication with %s +++", name);
|
sprintf(string, "+++ Communication with %s +++", name);
|
||||||
drawString(string, -1, 20, FONT_GREEN, comms);
|
drawString(string, -1, 20, FONT_GREEN, comms);
|
||||||
|
|
||||||
fscanf(fp, "%d%*c", &lines);
|
while (fscanf(fp, "%[^\n]%*c", string) == 1)
|
||||||
|
|
||||||
for (int i = 0 ; i < lines ; i++)
|
|
||||||
{
|
{
|
||||||
fscanf(fp, "%[^\n]%*c", string);
|
|
||||||
faceNumber = getFace(string);
|
faceNumber = getFace(string);
|
||||||
if (faceNumber > -1)
|
if (faceNumber > -1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -318,7 +318,7 @@ int mainGameLoop()
|
||||||
doCutscene(6);
|
doCutscene(6);
|
||||||
break;
|
break;
|
||||||
case 26:
|
case 26:
|
||||||
doCredits();
|
doCredits(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,8 @@ void initSystem()
|
||||||
|
|
||||||
if (fp != NULL)
|
if (fp != NULL)
|
||||||
{
|
{
|
||||||
fscanf(fp, "%d %d %d", &fullScreen, &useSound, &useMusic);
|
if (fscanf(fp, "%d %d %d", &fullScreen, &useSound, &useMusic) < 3)
|
||||||
|
printf("Warning: Config file \"%s\" is not correctly formatted\n", filename);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ static void setSystemPlanets()
|
||||||
{
|
{
|
||||||
if (fscanf(fp, "%d %s %d", &distance, name, &image) < 3)
|
if (fscanf(fp, "%d %s %d", &distance, name, &image) < 3)
|
||||||
{
|
{
|
||||||
printf("Warning: Data file \"%s\" is not correctly formatted\n", string);
|
printf("Warning: Data for planet %i in \"%s\" is not correctly formatted\n", i, string);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ static void setSystemPlanets()
|
||||||
(fscanf(fp, "%[^\n]%*c", from) < 1) ||
|
(fscanf(fp, "%[^\n]%*c", from) < 1) ||
|
||||||
(fscanf(fp, "%[^\n]%*c", subject) < 1))
|
(fscanf(fp, "%[^\n]%*c", subject) < 1))
|
||||||
{
|
{
|
||||||
printf("Warning: Data file \"%s\" is not correctly formatted\n", string);
|
printf("Warning: Mission data for planet %i in \"%s\" is not correctly formatted\n", i, string);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,9 @@ void loadGameGraphics()
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
||||||
fscanf(fp, "%d %s", &index, string);
|
while (fscanf(fp, "%d %s", &index, string) == 2)
|
||||||
while (index != -1)
|
|
||||||
{
|
{
|
||||||
shipShape[index] = loadImage(string);
|
shipShape[index] = loadImage(string);
|
||||||
fscanf(fp, "%d %s", &index, string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -113,11 +111,9 @@ void loadGameGraphics()
|
||||||
|
|
||||||
fp = fopen(string, "rb");
|
fp = fopen(string, "rb");
|
||||||
|
|
||||||
fscanf(fp, "%d %s", &index, string);
|
while (fscanf(fp, "%d %s", &index, string) == 2)
|
||||||
while (index != -1)
|
|
||||||
{
|
{
|
||||||
shape[index] = loadImage(string);
|
shape[index] = loadImage(string);
|
||||||
fscanf(fp, "%d %s", &index, string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
|
@ -62,12 +62,10 @@ void loadScriptEvents()
|
||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fscanf(fp, "%d ", &time);
|
while (fscanf(fp, "%d %s %d %d ", &time, face, &entity, &flags) == 4)
|
||||||
|
|
||||||
while (time != 0)
|
|
||||||
{
|
{
|
||||||
fscanf(fp, "%s %d %d ", face, &entity, &flags);
|
if (fscanf(fp, "%[^\n]%*c", message) < 1)
|
||||||
fscanf(fp, "%[^\n]%*c", message);
|
strcpy(message, "Error: Text missing");
|
||||||
|
|
||||||
gameEvent[i].time = time;
|
gameEvent[i].time = time;
|
||||||
gameEvent[i].face = getFace(face);
|
gameEvent[i].face = getFace(face);
|
||||||
|
@ -76,8 +74,6 @@ void loadScriptEvents()
|
||||||
strcpy(gameEvent[i].message, message);
|
strcpy(gameEvent[i].message, message);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
fscanf(fp, "%d ", &time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -136,19 +132,22 @@ static void setScene(int scene)
|
||||||
fp = fopen(string, "rb");
|
fp = fopen(string, "rb");
|
||||||
|
|
||||||
// Load in the specified background
|
// Load in the specified background
|
||||||
fscanf(fp, "%s", string);
|
if (fscanf(fp, "%s", string) < 1)
|
||||||
|
{
|
||||||
|
printf("Warning: didn't find a background definition for \"%s\"\n", string);
|
||||||
|
strcpy(string, "gfx/spirit.jpg");
|
||||||
|
}
|
||||||
loadBackground(string);
|
loadBackground(string);
|
||||||
|
|
||||||
// Set the star speed
|
// Set the star speed
|
||||||
fscanf(fp, "%f %f", &sx, &sy);
|
if (fscanf(fp, "%f %f", &sx, &sy) < 2)
|
||||||
|
printf("Warning: failed to read star speed data for cutscene");
|
||||||
engine.ssx = sx;
|
engine.ssx = sx;
|
||||||
engine.ssy = sy;
|
engine.ssy = sy;
|
||||||
|
|
||||||
// Read in the specs for each ship
|
// Read in the specs for each ship
|
||||||
for (int i = 0 ; i < 15 ; i++)
|
while (fscanf(fp, "%d %d %f %f %f", &index, &shape, &x, &y, &speed) == 5)
|
||||||
{
|
{
|
||||||
fscanf(fp, "%d %d %f %f %f", &index, &shape, &x, &y, &speed);
|
|
||||||
|
|
||||||
if (x < 0) x = (rand() % abs((int)x));
|
if (x < 0) x = (rand() % abs((int)x));
|
||||||
if (y < 0) y = (rand() % abs((int)y));
|
if (y < 0) y = (rand() % abs((int)y));
|
||||||
if (speed <= -1) speed = 1 + (rand() % abs((int)speed));
|
if (speed <= -1) speed = 1 + (rand() % abs((int)speed));
|
||||||
|
@ -164,16 +163,16 @@ static void setScene(int scene)
|
||||||
}
|
}
|
||||||
|
|
||||||
// And finally read in the messages
|
// And finally read in the messages
|
||||||
for (int i = 0 ; i < 10 ; i++)
|
index = 0;
|
||||||
|
while (fscanf(fp, "%s%*c %[^\n]", face, string) == 2)
|
||||||
{
|
{
|
||||||
fscanf(fp, "%s%*c", face);
|
|
||||||
fscanf(fp, "%[^\n]", string);
|
|
||||||
|
|
||||||
if (strcmp(string, "@none@") == 0)
|
if (strcmp(string, "@none@") == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
cutMessage[i].face = getFace(face);
|
cutMessage[index].face = getFace(face);
|
||||||
strcpy(cutMessage[i].message, string);
|
strcpy(cutMessage[index].message, string);
|
||||||
|
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
|
@ -373,7 +373,7 @@ int doTitle()
|
||||||
// if someone has invoked the credits cheat
|
// if someone has invoked the credits cheat
|
||||||
if (engine.cheatCredits)
|
if (engine.cheatCredits)
|
||||||
{
|
{
|
||||||
doCredits();
|
doCredits(false);
|
||||||
engine.cheatCredits = false;
|
engine.cheatCredits = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,18 +534,12 @@ void showStory()
|
||||||
int nextPos = -1;
|
int nextPos = -1;
|
||||||
char string[255];
|
char string[255];
|
||||||
|
|
||||||
fscanf(fp, "%d ", &nextPos);
|
while (fscanf(fp, "%d %[^\n]%*c", &nextPos, string) == 2)
|
||||||
|
|
||||||
while (nextPos != -1)
|
|
||||||
{
|
{
|
||||||
fscanf(fp, "%[^\n]%*c", string);
|
|
||||||
|
|
||||||
y += nextPos;
|
y += nextPos;
|
||||||
textSurface(i, string, -1, y, FONT_WHITE);
|
textSurface(i, string, -1, y, FONT_WHITE);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
fscanf(fp, "%d ", &nextPos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
@ -645,7 +639,7 @@ void gameover()
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
void doCredits()
|
void doCredits(bool show_extro)
|
||||||
{
|
{
|
||||||
loadBackground("gfx/credits.jpg");
|
loadBackground("gfx/credits.jpg");
|
||||||
flushBuffer();
|
flushBuffer();
|
||||||
|
@ -655,12 +649,12 @@ void doCredits()
|
||||||
loadMusic("music/rise_of_spirit.ogg");
|
loadMusic("music/rise_of_spirit.ogg");
|
||||||
|
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int numberOfCredits = 0;
|
int lastCredit = -1;
|
||||||
int lastCredit = 0;
|
|
||||||
|
|
||||||
int yPos = 0;
|
int yPos = 0;
|
||||||
int yPos2 = screen->h;
|
int yPos2 = screen->h;
|
||||||
char text[255];
|
char text[255];
|
||||||
|
int i;
|
||||||
|
|
||||||
textObject *credit;
|
textObject *credit;
|
||||||
|
|
||||||
|
@ -670,43 +664,49 @@ void doCredits()
|
||||||
|
|
||||||
drawBackGround();
|
drawBackGround();
|
||||||
|
|
||||||
fp = fopen("data/credits.txt", "rb");
|
|
||||||
|
|
||||||
for (int i = 0 ; i < 4 ; i++)
|
|
||||||
{
|
|
||||||
fscanf(fp, "%[^\n]%*c", text);
|
|
||||||
drawString(text, -1, 240 + (i * 20), FONT_WHITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
fscanf(fp, "%d%*c", &numberOfCredits);
|
|
||||||
|
|
||||||
credit = (textObject*) malloc(sizeof(textObject) * numberOfCredits);
|
|
||||||
|
|
||||||
for (int i = 0 ; i < numberOfCredits ; i++)
|
|
||||||
{
|
|
||||||
fscanf(fp, "%d %[^\n]%*c", &yPos, text);
|
|
||||||
credit[i].image = textSurface(text, FONT_WHITE);
|
|
||||||
credit[i].x = (screen->w - credit[i].image->w) / 2;
|
|
||||||
yPos2 += yPos;
|
|
||||||
credit[i].y = yPos2;
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
if ((engine.useMusic) && (engine.useAudio))
|
if ((engine.useMusic) && (engine.useAudio))
|
||||||
{
|
{
|
||||||
Mix_VolumeMusic(100);
|
Mix_VolumeMusic(100);
|
||||||
Mix_PlayMusic(engine.music, 1);
|
Mix_PlayMusic(engine.music, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateScreen();
|
if (show_extro)
|
||||||
SDL_Delay(20000);
|
{
|
||||||
drawBackGround();
|
fp = fopen("data/extro.txt", "rb");
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (fscanf(fp, "%[^\n]%*c", text) == 1)
|
||||||
|
{
|
||||||
|
drawString(text, -1, 240 + (i * 20), FONT_WHITE);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
|
updateScreen();
|
||||||
|
SDL_Delay(20000);
|
||||||
|
drawBackGround();
|
||||||
|
}
|
||||||
|
|
||||||
|
fp = fopen("data/credits.txt", "rb");
|
||||||
|
// FIXME: It would be nice for the size of this array to be determined
|
||||||
|
// by the number of lines in the text file. I'm not sure how to do
|
||||||
|
// that at the moment, so just giving it a very large number for now.
|
||||||
|
credit = (textObject*) malloc(sizeof(textObject) * 300);
|
||||||
|
|
||||||
|
while (fscanf(fp, "%d %[^\n]%*c", &yPos, text) == 2)
|
||||||
|
{
|
||||||
|
lastCredit++;
|
||||||
|
credit[lastCredit].image = textSurface(text, FONT_WHITE);
|
||||||
|
credit[lastCredit].x = (screen->w - credit[lastCredit].image->w) / 2;
|
||||||
|
yPos2 += yPos;
|
||||||
|
credit[lastCredit].y = yPos2;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
|
||||||
engine.done = 0;
|
engine.done = 0;
|
||||||
|
|
||||||
lastCredit = numberOfCredits - 1;
|
|
||||||
|
|
||||||
engine.keyState[KEY_ESCAPE] = 0;
|
engine.keyState[KEY_ESCAPE] = 0;
|
||||||
flushInput();
|
flushInput();
|
||||||
|
|
||||||
|
@ -725,7 +725,7 @@ void doCredits()
|
||||||
else if(engine.keyState[KEY_UP])
|
else if(engine.keyState[KEY_UP])
|
||||||
speed = -2;
|
speed = -2;
|
||||||
|
|
||||||
for (int i = 0 ; i < numberOfCredits ; i++)
|
for (i = 0 ; i <= lastCredit ; i++)
|
||||||
{
|
{
|
||||||
if ((credit[i].y > -10) && (credit[i].y < (screen->h + 10)))
|
if ((credit[i].y > -10) && (credit[i].y < (screen->h + 10)))
|
||||||
blit(credit[i].image, (int)credit[i].x, (int)credit[i].y);
|
blit(credit[i].image, (int)credit[i].x, (int)credit[i].y);
|
||||||
|
@ -738,7 +738,7 @@ void doCredits()
|
||||||
delayFrame();
|
delayFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0 ; i < numberOfCredits ; i++)
|
for (i = 0 ; i <= lastCredit ; i++)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface(credit[i].image);
|
SDL_FreeSurface(credit[i].image);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
extern int doTitle();
|
extern int doTitle();
|
||||||
extern void showStory();
|
extern void showStory();
|
||||||
extern void gameover();
|
extern void gameover();
|
||||||
extern void doCredits();
|
extern void doCredits(bool show_extro);
|
||||||
|
|
Loading…
Reference in New Issue