From aec30bbc3dee84bd8293f7c050a1bbc7ff436137 Mon Sep 17 00:00:00 2001 From: onpon4 Date: Tue, 22 Nov 2016 21:16:49 -0500 Subject: [PATCH] Reorganized "misc.cpp". Most functions have been placed into "info.cpp" and "radio.cpp", while one has been placed into "engine.cpp". --- Makefile | 2 +- src/Starfighter.h | 2 +- src/alien.cpp | 25 +++---- src/cargo.cpp | 3 +- src/cutscene.cpp | 2 +- src/engine.cpp | 61 ++++++++++++++++- src/engine.h | 1 + src/event.cpp | 3 +- src/game.cpp | 33 ++++----- src/info.cpp | 67 ++++++++++++++++++ src/{misc.h => info.h} | 12 ++-- src/misc.cpp | 149 ----------------------------------------- src/missions.cpp | 49 +++++++------- src/radio.cpp | 41 ++++++++++++ src/radio.h | 25 +++++++ src/ship.cpp | 2 +- src/title.cpp | 4 +- 17 files changed, 264 insertions(+), 217 deletions(-) create mode 100644 src/info.cpp rename src/{misc.h => info.h} (75%) delete mode 100644 src/misc.cpp create mode 100644 src/radio.cpp create mode 100644 src/radio.h diff --git a/Makefile b/Makefile index b51a7fc..e329cf0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CXXFLAGS ?= -O2 -Wall -g CXXFLAGS += `pkg-config --cflags 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 PROG = starfighter diff --git a/src/Starfighter.h b/src/Starfighter.h index 9350ac0..5b6ce08 100644 --- a/src/Starfighter.h +++ b/src/Starfighter.h @@ -49,7 +49,7 @@ along with this program. If not, see . #include "gfx.h" #include "intermission.h" #include "save.h" -#include "misc.h" +#include "info.h" #include "missions.h" #include "player.h" #include "renderer.h" diff --git a/src/alien.cpp b/src/alien.cpp index c869fb2..e696a0a 100644 --- a/src/alien.cpp +++ b/src/alien.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "Starfighter.h" +#include "radio.h" object alien_defs[CD_MAX]; object aliens[ALIEN_MAX]; @@ -1423,7 +1424,7 @@ void alien_setKlineAttackMethod(object *alien) { 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[1] = W_MICRO_HOMING_MISSILES; alien->flags |= FL_CANCLOAK; @@ -1432,7 +1433,7 @@ void alien_setKlineAttackMethod(object *alien) } 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) { alien->weaponType[0] = W_DIRSHOCKMISSILE; @@ -1444,7 +1445,7 @@ void alien_setKlineAttackMethod(object *alien) } 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->chance[1] = 40; } @@ -1757,9 +1758,9 @@ void alien_destroy(object *alien, object *attacker) if (game.area != MISN_NEROD) { 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 - 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))) { r = rand() % nChrisKillMessage; - setRadioMessage(FS_CHRIS, chrisKillMessage[r], 0); + radio_setMessage(FS_CHRIS, chrisKillMessage[r], 0); } } else if (attacker->classDef == CD_PHOEBE) @@ -1782,7 +1783,7 @@ void alien_destroy(object *alien, object *attacker) (!(alien->flags & FL_NOBANTER))) { r = rand() % nPhoebeKillMessage; - setRadioMessage(FS_PHOEBE, phoebeKillMessage[r], 0); + radio_setMessage(FS_PHOEBE, phoebeKillMessage[r], 0); } } else if (attacker->classDef == CD_URSULA) @@ -1792,7 +1793,7 @@ void alien_destroy(object *alien, object *attacker) (!(alien->flags & FL_NOBANTER))) { r = rand() % nUrsulaKillMessage; - setRadioMessage(FS_URSULA, ursulaKillMessage[r], 0); + radio_setMessage(FS_URSULA, ursulaKillMessage[r], 0); } } else @@ -1828,11 +1829,11 @@ void alien_destroy(object *alien, object *attacker) } 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) { - 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->shield = -150; } @@ -1862,7 +1863,7 @@ void alien_hurt(object *alien, object *attacker, int damage, int ion) { alien->flags |= FL_LEAVESECTOR; 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) @@ -1872,7 +1873,7 @@ void alien_hurt(object *alien, object *attacker, int damage, int ion) { alien->flags |= FL_LEAVESECTOR; 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) diff --git a/src/cargo.cpp b/src/cargo.cpp index ad10d80..0906e92 100644 --- a/src/cargo.cpp +++ b/src/cargo.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "Starfighter.h" +#include "radio.h" object cargo[MAX_CARGO]; @@ -76,7 +77,7 @@ void cargo_becomeCollectable(int i) aliens[ALIEN_PHOEBE].active = 1; aliens[ALIEN_PHOEBE].x = cargo[i].x; 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; diff --git a/src/cutscene.cpp b/src/cutscene.cpp index e9d23e0..ac5a3ac 100644 --- a/src/cutscene.cpp +++ b/src/cutscene.cpp @@ -45,7 +45,7 @@ void cutscene_init(int scene) screen_flushBuffer(); gfx_free(); - resetLists(); + engine_resetLists(); loadGameGraphics(); for (int i = 0 ; i < ALIEN_MAX ; i++) diff --git a/src/engine.cpp b/src/engine.cpp index 7253445..c1e6b8b 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -248,6 +248,65 @@ void engine_setMode() 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 loaded and created during the game. This is called by @@ -258,7 +317,7 @@ void engine_cleanup() gfx_free(); SDL_FreeSurface(gfx_background); audio_free(); - resetLists(); + engine_resetLists(); delete(engine.bulletHead); delete(engine.explosionHead); delete(engine.collectableHead); diff --git a/src/engine.h b/src/engine.h index 30fc8b7..851ff05 100644 --- a/src/engine.h +++ b/src/engine.h @@ -109,6 +109,7 @@ void engine_init(); void engine_showError(int errorId, const char *name); void engine_setupConfigDirectory(); void engine_setMode(); +void engine_resetLists(); void engine_cleanup(); #endif diff --git a/src/event.cpp b/src/event.cpp index 940c181..31fd081 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "Starfighter.h" +#include "radio.h" static Event events[MAX_EVENTS]; static const char *klineGreeting[] = { @@ -338,7 +339,7 @@ void events_check() { 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) diff --git a/src/game.cpp b/src/game.cpp index 21a05c3..13ca9be 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "Starfighter.h" +#include "radio.h" Game game; @@ -489,7 +490,7 @@ static void game_doCollectables() collectable->active = 0; if (collectable->type != P_MINE) { - setInfoLine(temp, FONT_WHITE); + info_setLine(temp, FONT_WHITE); if (collectable->type == P_SHIELD) audio_playSound(SFX_SHIELDUP, player.x, player.y); else @@ -665,9 +666,9 @@ static void game_doBullets() { game.hits++; 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) - setRadioMessage(FS_URSULA, playerUrsulaHitMessage[rand() % nPlayerUrsulaHitMessage], 0); + radio_setMessage(FS_URSULA, playerUrsulaHitMessage[rand() % nPlayerUrsulaHitMessage], 0); } if (!(aliens[i].flags & FL_IMMORTAL)) @@ -726,7 +727,7 @@ static void game_doBullets() { if ((player.shield > 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; LIMIT(player.shield, 0, player.maxShield); @@ -737,11 +738,11 @@ static void game_doBullets() { 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) { - 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) { game.experimentalShield = aliens[i].shield; - setInfoLine("Experimental Fighter has fled", + info_setLine("Experimental Fighter has fled", FONT_CYAN); } @@ -1256,7 +1257,7 @@ static void game_doPlayer() if (player.ammo[1] >= 100) { 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) { - setInfoLine("Weapon set to Spread", FONT_WHITE); + info_setLine("Weapon set to Spread", FONT_WHITE); } 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 (game.area == MISN_VENUS) - setRadioMessage(FS_KLINE, klineVenusInsult[rand() % nKlineVenusInsult], 1); + radio_setMessage(FS_KLINE, klineVenusInsult[rand() % nKlineVenusInsult], 1); 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)) { - 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... @@ -1867,7 +1868,7 @@ static void game_doHud() { 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; } @@ -2069,7 +2070,7 @@ int game_collision(float x0, float y0, int w0, int h0, float x2, float y2, int w int game_mainLoop() { - resetLists(); + engine_resetLists(); setMission(game.area); missionBriefScreen(); @@ -2195,7 +2196,7 @@ int game_mainLoop() break; } - clearInfoLines(); + info_clearLines(); events_init(); diff --git a/src/info.cpp b/src/info.cpp new file mode 100644 index 0000000..0bbd156 --- /dev/null +++ b/src/info.cpp @@ -0,0 +1,67 @@ +/* +Copyright (C) 2003 Parallel Realities +Copyright (C) 2011, 2012, 2013 Guus Sliepen +Copyright (C) 2015, 2016 Julie Marchant + +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 . +*/ + +#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; +} diff --git a/src/misc.h b/src/info.h similarity index 75% rename from src/misc.h rename to src/info.h index 2d8206d..475bef7 100644 --- a/src/misc.h +++ b/src/info.h @@ -17,13 +17,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef MISC_H -#define MISC_H +#ifndef INFO_H +#define INFO_H -extern void clearInfoLines(); -void copyInfoLine(int a, int b); -extern void setInfoLine(const char *in, int color); -extern void setRadioMessage(int face, const char *in, int priority); -extern void resetLists(); +void info_clearLines(); +void info_copyLine(int a, int b); +void info_setLine(const char *in, int color); #endif diff --git a/src/misc.cpp b/src/misc.cpp deleted file mode 100644 index 2b26e83..0000000 --- a/src/misc.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* -Copyright (C) 2003 Parallel Realities -Copyright (C) 2011, 2012, 2013 Guus Sliepen -Copyright (C) 2015, 2016 Julie Marchant - -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 . -*/ - -#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; -} - - diff --git a/src/missions.cpp b/src/missions.cpp index bbadbc2..fe5b350 100644 --- a/src/missions.cpp +++ b/src/missions.cpp @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "Starfighter.h" +#include "radio.h" // XXX: Magic number Planet systemPlanet[10]; @@ -328,7 +329,7 @@ void checkTimer() currentMission.completed1[0] = OB_COMPLETED; mission_killAllEnemies(); 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; checkTimer(); 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 { @@ -376,12 +377,12 @@ static void evaluateRequirement(int type, int id, int *completed, int *targetVal case P_CARGO: sprintf(message, "Cargo pod destroyed!"); 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; case P_ESCAPEPOD: sprintf(message, "Escape Pod lost!"); if (game.area == MISN_ODEON) // Get lectured by Phoebe - setRadioMessage(FS_PHOEBE, "No... Ursula...", 1); + radio_setMessage(FS_PHOEBE, "No... Ursula...", 1); break; } break; @@ -392,13 +393,13 @@ static void evaluateRequirement(int type, int id, int *completed, int *targetVal switch (game.area) { 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; case MISN_ALLEZ: - setRadioMessage(FS_CREW, "Noooo! Hull bre...", 1); + radio_setMessage(FS_CREW, "Noooo! Hull bre...", 1); break; 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; } } @@ -418,7 +419,7 @@ static void evaluateRequirement(int type, int id, int *completed, int *targetVal } 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(!) 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; } @@ -482,22 +483,22 @@ void updateMissionRequirements(int type, int id, int value) { if (game.slavesRescued >= 250) { - setInfoLine("*** Slaves Rescued - Mission Completed ***", FONT_GREEN); + info_setLine("*** Slaves Rescued - Mission Completed ***", FONT_GREEN); systemPlanet[9].missionCompleted = 1; } else { 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)) { - setInfoLine("*** Experimental Fighter Destroyed - Mission Completed ***", FONT_GREEN); + info_setLine("*** Experimental Fighter Destroyed - Mission Completed ***", FONT_GREEN); 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; } } @@ -518,7 +519,7 @@ static int revealHiddenObjectives() { currentMission.completed1[i] = OB_INCOMPLETE; sprintf(string, "New Objective - %s", currentMission.primaryObjective[i]); - setInfoLine(string, FONT_CYAN); + info_setLine(string, FONT_CYAN); allDone = 0; } } @@ -575,22 +576,22 @@ int allMissionsCompleted() if (currentMission.remainingObjectives1 > 1) { if ((game.area != MISN_POSWIC) || (i != 1)) - setInfoLine("*** Primary Objective Completed ***", FONT_GREEN); + info_setLine("*** Primary Objective Completed ***", FONT_GREEN); else - setInfoLine(">>> Primary Objective Failed <<<", FONT_RED); + info_setLine(">>> Primary Objective Failed <<<", FONT_RED); currentMission.completed1[i] = OB_COMPLETED; } else { 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) - setInfoLine("*** All Primary Objectives Completed ***", FONT_GREEN); + info_setLine("*** All Primary Objectives Completed ***", FONT_GREEN); else - setInfoLine("*** Interception Destroyed ***", FONT_GREEN); + info_setLine("*** Interception Destroyed ***", FONT_GREEN); currentMission.completed1[i] = OB_COMPLETED; // do some area specific things @@ -607,7 +608,7 @@ int allMissionsCompleted() } 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) { - setInfoLine("*** Secondary Objective Completed ***", FONT_GREEN); + info_setLine("*** Secondary Objective Completed ***", FONT_GREEN); currentMission.completed2[i] = OB_COMPLETED; } else { - setInfoLine("*** All Secondary Objectives Completed ***", FONT_GREEN); + info_setLine("*** All Secondary Objectives Completed ***", FONT_GREEN); currentMission.completed2[i] = OB_COMPLETED; // do some area specific things @@ -635,13 +636,13 @@ int allMissionsCompleted() if (currentMission.completed1[i] == OB_JUST_FAILED) { - setInfoLine(">>> MISSION FAILED <<<", FONT_RED); + info_setLine(">>> MISSION FAILED <<<", FONT_RED); currentMission.completed1[i] = OB_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; } } diff --git a/src/radio.cpp b/src/radio.cpp new file mode 100644 index 0000000..f30b15a --- /dev/null +++ b/src/radio.cpp @@ -0,0 +1,41 @@ +/* +Copyright (C) 2003 Parallel Realities +Copyright (C) 2011, 2012, 2013 Guus Sliepen +Copyright (C) 2015, 2016 Julie Marchant + +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 . +*/ + +#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); +} diff --git a/src/radio.h b/src/radio.h new file mode 100644 index 0000000..7131f1c --- /dev/null +++ b/src/radio.h @@ -0,0 +1,25 @@ +/* +Copyright (C) 2003 Parallel Realities +Copyright (C) 2011 Guus Sliepen +Copyright (C) 2015, 2016 Julie Marchant + +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 . +*/ + +#ifndef RADIO_H +#define RADIO_H + +void radio_setMessage(int face, const char *in, int priority); + +#endif diff --git a/src/ship.cpp b/src/ship.cpp index 76f4eec..baacaf5 100644 --- a/src/ship.cpp +++ b/src/ship.cpp @@ -171,7 +171,7 @@ void ship_fireRay(object *ship) { if (player.shield - 1 <= engine.lowShield) { - setInfoLine("!!! WARNING: SHIELD LOW !!!", FONT_RED); + info_setLine("!!! WARNING: SHIELD LOW !!!", FONT_RED); } } player.shield--; diff --git a/src/title.cpp b/src/title.cpp index b5b1b6f..b3ffce1 100644 --- a/src/title.cpp +++ b/src/title.cpp @@ -215,7 +215,7 @@ int doTitle() screen_flushBuffer(); gfx_free(); - resetLists(); + engine_resetLists(); // required to stop the title screen crashing game.system = 0; @@ -578,7 +578,7 @@ int doTitle() engine.keyState[KEY_FIRE] = engine.keyState[KEY_ALTFIRE] = 0; - resetLists(); + engine_resetLists(); if (selectedOption == 1) {