Reorganized "misc.cpp".

Most functions have been placed into "info.cpp" and "radio.cpp",
while one has been placed into "engine.cpp".
This commit is contained in:
onpon4 2016-11-22 21:16:49 -05:00
parent 800d278f78
commit aec30bbc3d
17 changed files with 264 additions and 217 deletions

View File

@ -1,7 +1,7 @@
CXXFLAGS ?= -O2 -Wall -g CXXFLAGS ?= -O2 -Wall -g
CXXFLAGS += `pkg-config --cflags sdl2 SDL2_image SDL2_mixer` CXXFLAGS += `pkg-config --cflags sdl2 SDL2_image SDL2_mixer`
LIBS = `pkg-config --libs sdl2 SDL2_image SDL2_mixer` LIBS = `pkg-config --libs sdl2 SDL2_image SDL2_mixer`
OBJS = alien.o audio.o bullet.o cargo.o collectable.o colors.o cutscene.o engine.o event.o explosion.o game.o gfx.o intermission.o misc.o missions.o player.o renderer.o resources.o save.o screen.o ship.o shop.o Starfighter.o title.o weapons.o window.o OBJS = alien.o audio.o bullet.o cargo.o collectable.o colors.o cutscene.o engine.o event.o explosion.o game.o gfx.o info.o intermission.o missions.o player.o radio.o renderer.o resources.o save.o screen.o ship.o shop.o Starfighter.o title.o weapons.o window.o
VERSION = 1.7-dev VERSION = 1.7-dev
PROG = starfighter PROG = starfighter

View File

@ -49,7 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "gfx.h" #include "gfx.h"
#include "intermission.h" #include "intermission.h"
#include "save.h" #include "save.h"
#include "misc.h" #include "info.h"
#include "missions.h" #include "missions.h"
#include "player.h" #include "player.h"
#include "renderer.h" #include "renderer.h"

View File

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Starfighter.h" #include "Starfighter.h"
#include "radio.h"
object alien_defs[CD_MAX]; object alien_defs[CD_MAX];
object aliens[ALIEN_MAX]; object aliens[ALIEN_MAX];
@ -1423,7 +1424,7 @@ void alien_setKlineAttackMethod(object *alien)
{ {
if (alien->shield <= 500) if (alien->shield <= 500)
{ {
setRadioMessage(FS_KLINE, "ENOUGH! THIS ENDS NOW!", 1); radio_setMessage(FS_KLINE, "ENOUGH! THIS ENDS NOW!", 1);
alien->weaponType[0] = W_AIMED_SHOT; alien->weaponType[0] = W_AIMED_SHOT;
alien->weaponType[1] = W_MICRO_HOMING_MISSILES; alien->weaponType[1] = W_MICRO_HOMING_MISSILES;
alien->flags |= FL_CANCLOAK; alien->flags |= FL_CANCLOAK;
@ -1432,7 +1433,7 @@ void alien_setKlineAttackMethod(object *alien)
} }
else if (alien->shield <= 1000) else if (alien->shield <= 1000)
{ {
setRadioMessage(FS_KLINE, "Your ability to stay alive irritates me! Try dodging some of these!", 1); radio_setMessage(FS_KLINE, "Your ability to stay alive irritates me! Try dodging some of these!", 1);
if (game.difficulty == DIFFICULTY_ORIGINAL) if (game.difficulty == DIFFICULTY_ORIGINAL)
{ {
alien->weaponType[0] = W_DIRSHOCKMISSILE; alien->weaponType[0] = W_DIRSHOCKMISSILE;
@ -1444,7 +1445,7 @@ void alien_setKlineAttackMethod(object *alien)
} }
else else
{ {
setRadioMessage(FS_KLINE, "Very good, Bainfield. Now let's get a little more serious...", 1); radio_setMessage(FS_KLINE, "Very good, Bainfield. Now let's get a little more serious...", 1);
alien->weaponType[0] = W_SPREADSHOT; alien->weaponType[0] = W_SPREADSHOT;
alien->chance[1] = 40; alien->chance[1] = 40;
} }
@ -1757,9 +1758,9 @@ void alien_destroy(object *alien, object *attacker)
if (game.area != MISN_NEROD) if (game.area != MISN_NEROD)
{ {
if ((alien->classDef == CD_PHOEBE) || (alien->classDef == CD_URSULA)) if ((alien->classDef == CD_PHOEBE) || (alien->classDef == CD_URSULA))
setInfoLine(">> Ally has ejected! <<\n", FONT_RED); info_setLine(">> Ally has ejected! <<\n", FONT_RED);
else else
setInfoLine(">> Friendly craft has been destroyed! <<\n", FONT_RED); info_setLine(">> Friendly craft has been destroyed! <<\n", FONT_RED);
} }
} }
@ -1772,7 +1773,7 @@ void alien_destroy(object *alien, object *attacker)
(!(alien->flags & FL_NOBANTER))) (!(alien->flags & FL_NOBANTER)))
{ {
r = rand() % nChrisKillMessage; r = rand() % nChrisKillMessage;
setRadioMessage(FS_CHRIS, chrisKillMessage[r], 0); radio_setMessage(FS_CHRIS, chrisKillMessage[r], 0);
} }
} }
else if (attacker->classDef == CD_PHOEBE) else if (attacker->classDef == CD_PHOEBE)
@ -1782,7 +1783,7 @@ void alien_destroy(object *alien, object *attacker)
(!(alien->flags & FL_NOBANTER))) (!(alien->flags & FL_NOBANTER)))
{ {
r = rand() % nPhoebeKillMessage; r = rand() % nPhoebeKillMessage;
setRadioMessage(FS_PHOEBE, phoebeKillMessage[r], 0); radio_setMessage(FS_PHOEBE, phoebeKillMessage[r], 0);
} }
} }
else if (attacker->classDef == CD_URSULA) else if (attacker->classDef == CD_URSULA)
@ -1792,7 +1793,7 @@ void alien_destroy(object *alien, object *attacker)
(!(alien->flags & FL_NOBANTER))) (!(alien->flags & FL_NOBANTER)))
{ {
r = rand() % nUrsulaKillMessage; r = rand() % nUrsulaKillMessage;
setRadioMessage(FS_URSULA, ursulaKillMessage[r], 0); radio_setMessage(FS_URSULA, ursulaKillMessage[r], 0);
} }
} }
else else
@ -1828,11 +1829,11 @@ void alien_destroy(object *alien, object *attacker)
} }
if ((alien->classDef == CD_KRASS) && (attacker == &player)) if ((alien->classDef == CD_KRASS) && (attacker == &player))
setRadioMessage(FS_CHRIS, "The name's CHRIS, old-timer.", 1); radio_setMessage(FS_CHRIS, "The name's CHRIS, old-timer.", 1);
if (alien->classDef == CD_KLINE) if (alien->classDef == CD_KLINE)
{ {
setRadioMessage(FS_KLINE, "It was an honor... to have fought you...", 1); radio_setMessage(FS_KLINE, "It was an honor... to have fought you...", 1);
alien->dx = alien->dy = 0; alien->dx = alien->dy = 0;
alien->shield = -150; alien->shield = -150;
} }
@ -1862,7 +1863,7 @@ void alien_hurt(object *alien, object *attacker, int damage, int ion)
{ {
alien->flags |= FL_LEAVESECTOR; alien->flags |= FL_LEAVESECTOR;
alien->flags &= ~FL_CIRCLES; alien->flags &= ~FL_CIRCLES;
setRadioMessage(FS_KLINE, "Seems I underestimated you, Bainfield. We'll meet again!", 1); radio_setMessage(FS_KLINE, "Seems I underestimated you, Bainfield. We'll meet again!", 1);
} }
} }
else if (game.area == MISN_EARTH) else if (game.area == MISN_EARTH)
@ -1872,7 +1873,7 @@ void alien_hurt(object *alien, object *attacker, int damage, int ion)
{ {
alien->flags |= FL_LEAVESECTOR; alien->flags |= FL_LEAVESECTOR;
alien->flags &= ~FL_CIRCLES; alien->flags &= ~FL_CIRCLES;
setRadioMessage(FS_SID, "Chris, Kethlan is getting away!", 1); radio_setMessage(FS_SID, "Chris, Kethlan is getting away!", 1);
} }
} }
else if (game.area == MISN_VENUS) else if (game.area == MISN_VENUS)

View File

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Starfighter.h" #include "Starfighter.h"
#include "radio.h"
object cargo[MAX_CARGO]; object cargo[MAX_CARGO];
@ -76,7 +77,7 @@ void cargo_becomeCollectable(int i)
aliens[ALIEN_PHOEBE].active = 1; aliens[ALIEN_PHOEBE].active = 1;
aliens[ALIEN_PHOEBE].x = cargo[i].x; aliens[ALIEN_PHOEBE].x = cargo[i].x;
aliens[ALIEN_PHOEBE].y = cargo[i].y; aliens[ALIEN_PHOEBE].y = cargo[i].y;
setRadioMessage(FS_PHOEBE, "Thanks! Watch out, WEAPCO! Phoebe's loose and she's ANGRY!", 1); radio_setMessage(FS_PHOEBE, "Thanks! Watch out, WEAPCO! Phoebe's loose and she's ANGRY!", 1);
} }
cargo[i].active = 0; cargo[i].active = 0;

View File

@ -45,7 +45,7 @@ void cutscene_init(int scene)
screen_flushBuffer(); screen_flushBuffer();
gfx_free(); gfx_free();
resetLists(); engine_resetLists();
loadGameGraphics(); loadGameGraphics();
for (int i = 0 ; i < ALIEN_MAX ; i++) for (int i = 0 ; i < ALIEN_MAX ; i++)

View File

@ -248,6 +248,65 @@ void engine_setMode()
SDL_JoystickOpen(0); SDL_JoystickOpen(0);
} }
void engine_resetLists()
{
object *ob, *ob2;
collectables *c1, *c2;
bRect *r1, *r2;
ob = engine.bulletHead->next;
while(ob != NULL)
{
ob2 = ob;
ob = ob->next;
delete ob2;
}
engine.bulletHead->next = NULL;
engine.bulletTail = engine.bulletHead;
ob = engine.explosionHead->next;
while(ob != NULL)
{
ob2 = ob;
ob = ob->next;
delete ob2;
}
engine.explosionHead->next = NULL;
engine.explosionTail = engine.explosionHead;
c1 = engine.collectableHead->next;
while (c1 != NULL)
{
c2 = c1;
c1 = c1->next;
delete c2;
}
engine.collectableHead->next = NULL;
engine.collectableTail = engine.collectableHead;
r1 = screen_bufferHead->next;
while (r1 != NULL)
{
r2 = r1;
r1 = r1->next;
delete r2;
}
screen_bufferHead->next = NULL;
screen_bufferTail = screen_bufferHead;
ob = engine.debrisHead->next;
while(ob != NULL)
{
ob2 = ob;
ob = ob->next;
delete ob2;
}
engine.debrisHead->next = NULL;
engine.debrisTail = engine.debrisHead;
}
/* /*
Removes [hopefully] all the resources that has been Removes [hopefully] all the resources that has been
loaded and created during the game. This is called by loaded and created during the game. This is called by
@ -258,7 +317,7 @@ void engine_cleanup()
gfx_free(); gfx_free();
SDL_FreeSurface(gfx_background); SDL_FreeSurface(gfx_background);
audio_free(); audio_free();
resetLists(); engine_resetLists();
delete(engine.bulletHead); delete(engine.bulletHead);
delete(engine.explosionHead); delete(engine.explosionHead);
delete(engine.collectableHead); delete(engine.collectableHead);

View File

@ -109,6 +109,7 @@ void engine_init();
void engine_showError(int errorId, const char *name); void engine_showError(int errorId, const char *name);
void engine_setupConfigDirectory(); void engine_setupConfigDirectory();
void engine_setMode(); void engine_setMode();
void engine_resetLists();
void engine_cleanup(); void engine_cleanup();
#endif #endif

View File

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Starfighter.h" #include "Starfighter.h"
#include "radio.h"
static Event events[MAX_EVENTS]; static Event events[MAX_EVENTS];
static const char *klineGreeting[] = { static const char *klineGreeting[] = {
@ -338,7 +339,7 @@ void events_check()
{ {
if (strcmp(events[i].message, "") != 0) if (strcmp(events[i].message, "") != 0)
{ {
setRadioMessage(events[i].face, events[i].message, 1); radio_setMessage(events[i].face, events[i].message, 1);
} }
if (events[i].entity > -1) if (events[i].entity > -1)

View File

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Starfighter.h" #include "Starfighter.h"
#include "radio.h"
Game game; Game game;
@ -489,7 +490,7 @@ static void game_doCollectables()
collectable->active = 0; collectable->active = 0;
if (collectable->type != P_MINE) if (collectable->type != P_MINE)
{ {
setInfoLine(temp, FONT_WHITE); info_setLine(temp, FONT_WHITE);
if (collectable->type == P_SHIELD) if (collectable->type == P_SHIELD)
audio_playSound(SFX_SHIELDUP, player.x, player.y); audio_playSound(SFX_SHIELDUP, player.x, player.y);
else else
@ -665,9 +666,9 @@ static void game_doBullets()
{ {
game.hits++; game.hits++;
if (aliens[i].classDef == CD_PHOEBE) if (aliens[i].classDef == CD_PHOEBE)
setRadioMessage(FS_PHOEBE, playerPhoebeHitMessage[rand() % nPlayerPhoebeHitMessage], 0); radio_setMessage(FS_PHOEBE, playerPhoebeHitMessage[rand() % nPlayerPhoebeHitMessage], 0);
else if (aliens[i].classDef == CD_URSULA) else if (aliens[i].classDef == CD_URSULA)
setRadioMessage(FS_URSULA, playerUrsulaHitMessage[rand() % nPlayerUrsulaHitMessage], 0); radio_setMessage(FS_URSULA, playerUrsulaHitMessage[rand() % nPlayerUrsulaHitMessage], 0);
} }
if (!(aliens[i].flags & FL_IMMORTAL)) if (!(aliens[i].flags & FL_IMMORTAL))
@ -726,7 +727,7 @@ static void game_doBullets()
{ {
if ((player.shield > engine.lowShield) && if ((player.shield > engine.lowShield) &&
(player.shield - bullet->damage <= engine.lowShield)) (player.shield - bullet->damage <= engine.lowShield))
setInfoLine("!!! WARNING: SHIELD LOW !!!", FONT_RED); info_setLine("!!! WARNING: SHIELD LOW !!!", FONT_RED);
player.shield -= bullet->damage; player.shield -= bullet->damage;
LIMIT(player.shield, 0, player.maxShield); LIMIT(player.shield, 0, player.maxShield);
@ -737,11 +738,11 @@ static void game_doBullets()
{ {
if (bullet->owner->classDef == CD_PHOEBE) if (bullet->owner->classDef == CD_PHOEBE)
{ {
setRadioMessage(FS_PHOEBE, phoebePlayerHitMessage[rand() % nPhoebePlayerHitMessage], 0); radio_setMessage(FS_PHOEBE, phoebePlayerHitMessage[rand() % nPhoebePlayerHitMessage], 0);
} }
else if (bullet->owner->classDef == CD_URSULA) else if (bullet->owner->classDef == CD_URSULA)
{ {
setRadioMessage(FS_URSULA, ursulaPlayerHitMessage[rand() % nUrsulaPlayerHitMessage], 0); radio_setMessage(FS_URSULA, ursulaPlayerHitMessage[rand() % nUrsulaPlayerHitMessage], 0);
} }
} }
@ -1014,7 +1015,7 @@ static void game_doAliens()
if (aliens[i].classDef == CD_CLOAKFIGHTER) if (aliens[i].classDef == CD_CLOAKFIGHTER)
{ {
game.experimentalShield = aliens[i].shield; game.experimentalShield = aliens[i].shield;
setInfoLine("Experimental Fighter has fled", info_setLine("Experimental Fighter has fled",
FONT_CYAN); FONT_CYAN);
} }
@ -1256,7 +1257,7 @@ static void game_doPlayer()
if (player.ammo[1] >= 100) if (player.ammo[1] >= 100)
{ {
player.ammo[1] = 200; player.ammo[1] = 200;
setInfoLine("Laser Overheat!", FONT_WHITE); info_setLine("Laser Overheat!", FONT_WHITE);
} }
} }
} }
@ -1309,11 +1310,11 @@ static void game_doPlayer()
if (weapon[W_PLAYER_WEAPON].flags & WF_SPREAD) if (weapon[W_PLAYER_WEAPON].flags & WF_SPREAD)
{ {
setInfoLine("Weapon set to Spread", FONT_WHITE); info_setLine("Weapon set to Spread", FONT_WHITE);
} }
else else
{ {
setInfoLine("Weapon set to Concentrate", FONT_WHITE); info_setLine("Weapon set to Concentrate", FONT_WHITE);
} }
} }
@ -1476,13 +1477,13 @@ static void game_doPlayer()
if (aliens[ALIEN_KLINE].active) if (aliens[ALIEN_KLINE].active)
{ {
if (game.area == MISN_VENUS) if (game.area == MISN_VENUS)
setRadioMessage(FS_KLINE, klineVenusInsult[rand() % nKlineVenusInsult], 1); radio_setMessage(FS_KLINE, klineVenusInsult[rand() % nKlineVenusInsult], 1);
else else
setRadioMessage(FS_KLINE, klineInsult[rand() % nKlineInsult], 1); radio_setMessage(FS_KLINE, klineInsult[rand() % nKlineInsult], 1);
} }
else if ((aliens[ALIEN_BOSS].active) && (aliens[ALIEN_BOSS].classDef == CD_KRASS)) else if ((aliens[ALIEN_BOSS].active) && (aliens[ALIEN_BOSS].classDef == CD_KRASS))
{ {
setRadioMessage(FS_KRASS, "That was the easiest $90,000,000 I've ever earned! Bwah! Ha! Ha! Ha!", 1); radio_setMessage(FS_KRASS, "That was the easiest $90,000,000 I've ever earned! Bwah! Ha! Ha! Ha!", 1);
} }
// Make it look like the ships are all still moving... // Make it look like the ships are all still moving...
@ -1867,7 +1868,7 @@ static void game_doHud()
{ {
for (int j = i ; j < MAX_INFOLINES - 1 ; j++) for (int j = i ; j < MAX_INFOLINES - 1 ; j++)
{ {
copyInfoLine(j + 1, j); info_copyLine(j + 1, j);
} }
gfx_textSprites[MAX_INFOLINES - 1].life = 0; gfx_textSprites[MAX_INFOLINES - 1].life = 0;
} }
@ -2069,7 +2070,7 @@ int game_collision(float x0, float y0, int w0, int h0, float x2, float y2, int w
int game_mainLoop() int game_mainLoop()
{ {
resetLists(); engine_resetLists();
setMission(game.area); setMission(game.area);
missionBriefScreen(); missionBriefScreen();
@ -2195,7 +2196,7 @@ int game_mainLoop()
break; break;
} }
clearInfoLines(); info_clearLines();
events_init(); events_init();

67
src/info.cpp Normal file
View File

@ -0,0 +1,67 @@
/*
Copyright (C) 2003 Parallel Realities
Copyright (C) 2011, 2012, 2013 Guus Sliepen
Copyright (C) 2015, 2016 Julie Marchant <onpon4@riseup.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Starfighter.h"
void info_clearLines()
{
for (int i = 0 ; i < MAX_INFOLINES ; i++)
{
gfx_textSprites[i].life = 0;
}
}
// from a to b
void info_copyLine(int a, int b)
{
gfx_createTextObject(b, gfx_textSprites[a].text, -1, 0, gfx_textSprites[a].fontColor);
gfx_textSprites[b].life = gfx_textSprites[a].life;
}
/*
Sets one of the three information lines on the screen. The accepts the
string and colors. It will set the information to the first free infoline
it finds (top to bottom). If it doesn't find any free ones, it will push
all the other info lines down one and add itself to the top.
*/
void info_setLine(const char *in, int color)
{
int index = -1;
for (int i = 0 ; i < MAX_INFOLINES ; i++)
{
if ((gfx_textSprites[i].life == 0) && (index == -1))
{
index = i;
}
}
// Bump down
if (index == -1)
{
index = MAX_INFOLINES - 1;
for (int i = 1 ; i < MAX_INFOLINES ; i++)
{
info_copyLine(i, i - 1);
}
}
gfx_createTextObject(index, in, -1, 0, color);
gfx_textSprites[index].life = 240;
}

View File

@ -17,13 +17,11 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef MISC_H #ifndef INFO_H
#define MISC_H #define INFO_H
extern void clearInfoLines(); void info_clearLines();
void copyInfoLine(int a, int b); void info_copyLine(int a, int b);
extern void setInfoLine(const char *in, int color); void info_setLine(const char *in, int color);
extern void setRadioMessage(int face, const char *in, int priority);
extern void resetLists();
#endif #endif

View File

@ -1,149 +0,0 @@
/*
Copyright (C) 2003 Parallel Realities
Copyright (C) 2011, 2012, 2013 Guus Sliepen
Copyright (C) 2015, 2016 Julie Marchant <onpon4@riseup.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Starfighter.h"
void clearInfoLines()
{
for (int i = 0 ; i < 4 ; i++)
{
gfx_textSprites[i].life = 0;
}
}
// from a to b
void copyInfoLine(int a, int b)
{
gfx_createTextObject(b, gfx_textSprites[a].text, -1, 0, gfx_textSprites[a].fontColor);
gfx_textSprites[b].life = gfx_textSprites[a].life;
}
/*
Sets one of the three information lines on the screen. The accepts the
string and colors. It will set the information to the first free infoline
it finds (top to bottom). If it doesn't find any free ones, it will push
all the other info lines down one and add itself to the top.
*/
void setInfoLine(const char *in, int color)
{
int index = -1;
for (int i = 0 ; i < MAX_INFOLINES ; i++)
{
if ((gfx_textSprites[i].life == 0) && (index == -1))
{
index = i;
}
}
// Bump down
if (index == -1)
{
index = MAX_INFOLINES - 1;
for (int i = 1 ; i < MAX_INFOLINES ; i++)
{
copyInfoLine(i, i - 1);
}
}
gfx_createTextObject(index, in, -1, 0, color);
gfx_textSprites[index].life = 240;
}
/*
Sets a radio message that appears at the top of the screen. Used for
script events, etc. We send a message priority too, since we don't want
Phoebe or Ursula's banter to interrupt an important message
*/
void setRadioMessage(int face, const char *in, int priority)
{
SDL_Surface *faceShape = NULL;
if ((gfx_textSprites[TS_RADIO].life > 0) && (priority == 0))
return;
gfx_createTextObject(TS_RADIO, in, -1, 50, FONT_WHITE);
gfx_textSprites[TS_RADIO].life = 240;
if (face > -1)
faceShape = gfx_faceSprites[face];
gfx_createMessageBox(faceShape, in, 1);
}
void resetLists()
{
object *ob, *ob2;
collectables *c1, *c2;
bRect *r1, *r2;
ob = engine.bulletHead->next;
while(ob != NULL)
{
ob2 = ob;
ob = ob->next;
delete ob2;
}
engine.bulletHead->next = NULL;
engine.bulletTail = engine.bulletHead;
ob = engine.explosionHead->next;
while(ob != NULL)
{
ob2 = ob;
ob = ob->next;
delete ob2;
}
engine.explosionHead->next = NULL;
engine.explosionTail = engine.explosionHead;
c1 = engine.collectableHead->next;
while (c1 != NULL)
{
c2 = c1;
c1 = c1->next;
delete c2;
}
engine.collectableHead->next = NULL;
engine.collectableTail = engine.collectableHead;
r1 = screen_bufferHead->next;
while (r1 != NULL)
{
r2 = r1;
r1 = r1->next;
delete r2;
}
screen_bufferHead->next = NULL;
screen_bufferTail = screen_bufferHead;
ob = engine.debrisHead->next;
while(ob != NULL)
{
ob2 = ob;
ob = ob->next;
delete ob2;
}
engine.debrisHead->next = NULL;
engine.debrisTail = engine.debrisHead;
}

View File

@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "Starfighter.h" #include "Starfighter.h"
#include "radio.h"
// XXX: Magic number // XXX: Magic number
Planet systemPlanet[10]; Planet systemPlanet[10];
@ -328,7 +329,7 @@ void checkTimer()
currentMission.completed1[0] = OB_COMPLETED; currentMission.completed1[0] = OB_COMPLETED;
mission_killAllEnemies(); mission_killAllEnemies();
engine.addAliens = -1; engine.addAliens = -1;
setInfoLine("*** All Primary Objectives Completed ***", FONT_GREEN); info_setLine("*** All Primary Objectives Completed ***", FONT_GREEN);
} }
} }
@ -342,7 +343,7 @@ static void evaluateRequirement(int type, int id, int *completed, int *targetVal
*completed = OB_JUST_COMPLETED; *completed = OB_JUST_COMPLETED;
checkTimer(); checkTimer();
if ((game.area == MISN_URUSOR) && (type == M_DISABLE_TARGET)) if ((game.area == MISN_URUSOR) && (type == M_DISABLE_TARGET))
setRadioMessage(FS_SID, "All vessels disabled!", 1); radio_setMessage(FS_SID, "All vessels disabled!", 1);
} }
else else
{ {
@ -376,12 +377,12 @@ static void evaluateRequirement(int type, int id, int *completed, int *targetVal
case P_CARGO: case P_CARGO:
sprintf(message, "Cargo pod destroyed!"); sprintf(message, "Cargo pod destroyed!");
if (game.area == MISN_CERADSE) // Get lectured by Sid if (game.area == MISN_CERADSE) // Get lectured by Sid
setRadioMessage(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!"); sprintf(message, "Escape Pod lost!");
if (game.area == MISN_ODEON) // Get lectured by Phoebe if (game.area == MISN_ODEON) // Get lectured by Phoebe
setRadioMessage(FS_PHOEBE, "No... Ursula...", 1); radio_setMessage(FS_PHOEBE, "No... Ursula...", 1);
break; break;
} }
break; break;
@ -392,13 +393,13 @@ static void evaluateRequirement(int type, int id, int *completed, int *targetVal
switch (game.area) switch (game.area)
{ {
case MISN_NEROD: case MISN_NEROD:
setRadioMessage(FS_SID, "Dammit, Chris! We just lost her!", 1); radio_setMessage(FS_SID, "Dammit, Chris! We just lost her!", 1);
break; break;
case MISN_ALLEZ: case MISN_ALLEZ:
setRadioMessage(FS_CREW, "Noooo! Hull bre...", 1); radio_setMessage(FS_CREW, "Noooo! Hull bre...", 1);
break; break;
case MISN_URUSOR: case MISN_URUSOR:
setRadioMessage(FS_SID, "Chris, we've got to disable them, not destroy them!!", 1); radio_setMessage(FS_SID, "Chris, we've got to disable them, not destroy them!!", 1);
break; break;
} }
} }
@ -418,7 +419,7 @@ static void evaluateRequirement(int type, int id, int *completed, int *targetVal
} }
if (strcmp(message, "") != 0) if (strcmp(message, "") != 0)
setInfoLine(message, fontColor); info_setLine(message, fontColor);
} }
} }
@ -435,7 +436,7 @@ void updateMissionRequirements(int type, int id, int value)
// you will automatically fail the mission(!) // you will automatically fail the mission(!)
if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_SID)) if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_SID))
{ {
setInfoLine("Sid has been killed!", FONT_RED); info_setLine("Sid has been killed!", FONT_RED);
currentMission.completed1[0] = OB_JUST_FAILED; currentMission.completed1[0] = OB_JUST_FAILED;
} }
@ -482,22 +483,22 @@ void updateMissionRequirements(int type, int id, int value)
{ {
if (game.slavesRescued >= 250) if (game.slavesRescued >= 250)
{ {
setInfoLine("*** Slaves Rescued - Mission Completed ***", FONT_GREEN); info_setLine("*** Slaves Rescued - Mission Completed ***", FONT_GREEN);
systemPlanet[9].missionCompleted = 1; systemPlanet[9].missionCompleted = 1;
} }
else else
{ {
sprintf(message, "Rescue %d more...", 250 - game.slavesRescued); sprintf(message, "Rescue %d more...", 250 - game.slavesRescued);
setInfoLine(message, FONT_CYAN); info_setLine(message, FONT_CYAN);
} }
} }
} }
if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_CLOAKFIGHTER)) if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_CLOAKFIGHTER))
{ {
setInfoLine("*** Experimental Fighter Destroyed - Mission Completed ***", FONT_GREEN); info_setLine("*** Experimental Fighter Destroyed - Mission Completed ***", FONT_GREEN);
systemPlanet[9].missionCompleted = 1; systemPlanet[9].missionCompleted = 1;
setRadioMessage(FS_CHRIS, "That's one less suprise that WEAPCO can spring on us!", 1); radio_setMessage(FS_CHRIS, "That's one less suprise that WEAPCO can spring on us!", 1);
game.experimentalShield = 0; game.experimentalShield = 0;
} }
} }
@ -518,7 +519,7 @@ static int revealHiddenObjectives()
{ {
currentMission.completed1[i] = OB_INCOMPLETE; currentMission.completed1[i] = OB_INCOMPLETE;
sprintf(string, "New Objective - %s", currentMission.primaryObjective[i]); sprintf(string, "New Objective - %s", currentMission.primaryObjective[i]);
setInfoLine(string, FONT_CYAN); info_setLine(string, FONT_CYAN);
allDone = 0; allDone = 0;
} }
} }
@ -575,22 +576,22 @@ int allMissionsCompleted()
if (currentMission.remainingObjectives1 > 1) if (currentMission.remainingObjectives1 > 1)
{ {
if ((game.area != MISN_POSWIC) || (i != 1)) if ((game.area != MISN_POSWIC) || (i != 1))
setInfoLine("*** Primary Objective Completed ***", FONT_GREEN); info_setLine("*** Primary Objective Completed ***", FONT_GREEN);
else else
setInfoLine(">>> Primary Objective Failed <<<", FONT_RED); info_setLine(">>> Primary Objective Failed <<<", FONT_RED);
currentMission.completed1[i] = OB_COMPLETED; currentMission.completed1[i] = OB_COMPLETED;
} }
else else
{ {
if (currentMission.remainingObjectives2 > 0) if (currentMission.remainingObjectives2 > 0)
{ {
setInfoLine("Emergency warp drive activated. Press button to engage.", FONT_CYAN); info_setLine("Emergency warp drive activated. Press button to engage.", FONT_CYAN);
} }
if (game.area != MISN_INTERCEPTION) if (game.area != MISN_INTERCEPTION)
setInfoLine("*** All Primary Objectives Completed ***", FONT_GREEN); info_setLine("*** All Primary Objectives Completed ***", FONT_GREEN);
else else
setInfoLine("*** Interception Destroyed ***", FONT_GREEN); info_setLine("*** Interception Destroyed ***", FONT_GREEN);
currentMission.completed1[i] = OB_COMPLETED; currentMission.completed1[i] = OB_COMPLETED;
// do some area specific things // do some area specific things
@ -607,7 +608,7 @@ int allMissionsCompleted()
} }
if (game.area == MISN_EARTH) if (game.area == MISN_EARTH)
setRadioMessage(FS_CHRIS, "You guys stay here and keep things under control. I'm going after Kethlan!", 1); radio_setMessage(FS_CHRIS, "You guys stay here and keep things under control. I'm going after Kethlan!", 1);
} }
} }
@ -615,12 +616,12 @@ int allMissionsCompleted()
{ {
if (currentMission.remainingObjectives2 > 1) if (currentMission.remainingObjectives2 > 1)
{ {
setInfoLine("*** Secondary Objective Completed ***", FONT_GREEN); info_setLine("*** Secondary Objective Completed ***", FONT_GREEN);
currentMission.completed2[i] = OB_COMPLETED; currentMission.completed2[i] = OB_COMPLETED;
} }
else else
{ {
setInfoLine("*** All Secondary Objectives Completed ***", FONT_GREEN); info_setLine("*** All Secondary Objectives Completed ***", FONT_GREEN);
currentMission.completed2[i] = OB_COMPLETED; currentMission.completed2[i] = OB_COMPLETED;
// do some area specific things // do some area specific things
@ -635,13 +636,13 @@ int allMissionsCompleted()
if (currentMission.completed1[i] == OB_JUST_FAILED) if (currentMission.completed1[i] == OB_JUST_FAILED)
{ {
setInfoLine(">>> MISSION FAILED <<<", FONT_RED); info_setLine(">>> MISSION FAILED <<<", FONT_RED);
currentMission.completed1[i] = OB_FAILED; currentMission.completed1[i] = OB_FAILED;
} }
if (currentMission.completed2[i] == OB_JUST_FAILED) if (currentMission.completed2[i] == OB_JUST_FAILED)
{ {
setInfoLine(">>> Secondary Objective Failed <<<", FONT_RED); info_setLine(">>> Secondary Objective Failed <<<", FONT_RED);
currentMission.completed2[i] = OB_FAILED; currentMission.completed2[i] = OB_FAILED;
} }
} }

41
src/radio.cpp Normal file
View File

@ -0,0 +1,41 @@
/*
Copyright (C) 2003 Parallel Realities
Copyright (C) 2011, 2012, 2013 Guus Sliepen
Copyright (C) 2015, 2016 Julie Marchant <onpon4@riseup.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Starfighter.h"
/*
Sets a radio message that appears at the top of the screen. Used for
script events, etc. We send a message priority too, since we don't want
Phoebe or Ursula's banter to interrupt an important message
*/
void radio_setMessage(int face, const char *in, int priority)
{
SDL_Surface *faceShape = NULL;
if ((gfx_textSprites[TS_RADIO].life > 0) && (priority == 0))
return;
gfx_createTextObject(TS_RADIO, in, -1, 50, FONT_WHITE);
gfx_textSprites[TS_RADIO].life = 240;
if (face > -1)
faceShape = gfx_faceSprites[face];
gfx_createMessageBox(faceShape, in, 1);
}

25
src/radio.h Normal file
View File

@ -0,0 +1,25 @@
/*
Copyright (C) 2003 Parallel Realities
Copyright (C) 2011 Guus Sliepen
Copyright (C) 2015, 2016 Julie Marchant <onpon4@riseup.net>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 3
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RADIO_H
#define RADIO_H
void radio_setMessage(int face, const char *in, int priority);
#endif

View File

@ -171,7 +171,7 @@ void ship_fireRay(object *ship)
{ {
if (player.shield - 1 <= engine.lowShield) if (player.shield - 1 <= engine.lowShield)
{ {
setInfoLine("!!! WARNING: SHIELD LOW !!!", FONT_RED); info_setLine("!!! WARNING: SHIELD LOW !!!", FONT_RED);
} }
} }
player.shield--; player.shield--;

View File

@ -215,7 +215,7 @@ int doTitle()
screen_flushBuffer(); screen_flushBuffer();
gfx_free(); gfx_free();
resetLists(); engine_resetLists();
// required to stop the title screen crashing // required to stop the title screen crashing
game.system = 0; game.system = 0;
@ -578,7 +578,7 @@ int doTitle()
engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0; engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0;
resetLists(); engine_resetLists();
if (selectedOption == 1) if (selectedOption == 1)
{ {