Bring sanity to the header files.

Most .h files were not used to declare the externally visible variables
and functions of the .cpp files, but only to #include things and declare
things that were needed by that .cpp file itself. This resulted in a lot
of duplication.

Now the .h files only declare what is externally visible from the
corresponding .cpp files. Starfighter.h includes all the other .h files,
and all .cpp files only #include "Starfighter.h". Functions and
variables that were not used outside the .cpp file that contained them
were marked static. Variables defined in .h files were moved to the
appropriate .cpp files.
This commit is contained in:
Guus Sliepen 2011-08-26 21:29:04 +02:00
parent 8b34e90bcf
commit 6ea4744832
54 changed files with 273 additions and 753 deletions

View File

@ -20,7 +20,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "version.h"
#include "Starfighter.h"
int main(int argc, char *argv[])

View File

@ -18,8 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __STARFIGHTER_H__
#define __STARFIGHTER_H__
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
@ -29,42 +37,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "structs.h"
#include "classes.h"
extern void initSystem();
extern void loadGameGraphics();
extern void loadSound();
extern void initWeapons();
extern void initMissions();
extern void initVars();
extern void showStory();
extern int doTitle();
extern void defineAliens();
extern void loadFont();
extern int galaxyMap();
extern void defineGlobals();
extern void cleanUp();
extern int mainGameLoop();
extern void setAllyMessages();
extern void newGame();
extern void doCredits();
extern void getPlayerInput();
extern void initPlanetMissions(signed char system);
extern void updateSystemStatus();
extern void doCutscene(int scene);
#include "ai.h"
#include "aliens.h"
#include "audio.h"
#include "bullets.h"
#include "cargo.h"
#include "collectable.h"
#include "comms.h"
#include "debris.h"
#include "events.h"
#include "explosions.h"
#include "game.h"
#include "globals.h"
#include "graphics.h"
#include "init.h"
#include "intermission.h"
#include "loadSave.h"
#include "messages.h"
#include "misc.h"
#include "missions.h"
#include "player.h"
#include "resources.h"
#include "script.h"
#include "shop.h"
#include "title.h"
#include "unpack.h"
#include "version.h"
#include "weapons.h"
globalEngineVariables engine;
devVariables dev;
Game currentGame;
object player;
mission currentMission;
Graphics graphics;
object enemy[MAX_ALIENS];
Star star[200];
Planet systemPlanet[10];
mission missions[MAX_MISSIONS];
ShopItem shopItems[MAX_SHOPITEMS];
Mix_Chunk *sound[MAX_SOUNDS];
object weapon[MAX_WEAPONS];
object cargo[MAX_CARGO];
event gameEvent[10];
cutMsg cutMessage[10];
#endif

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "ai.h"
#include "Starfighter.h"
/*
Some very simple artificial intelligence routines for the aliens.

View File

@ -18,20 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void setRadioMessage(signed char face, const char *in, int priority);
extern object enemy[MAX_ALIENS];
extern object player;
extern Game currentGame;
extern void setEnemyAI(object *theEnemy);
extern void setKlineAttackMethod(object *theEnemy);
extern void setKlineAI(object *theEnemy);

View File

@ -18,9 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "aliens.h"
#include "Starfighter.h"
bool placeAlien(object *theEnemy)
object defEnemy[MAX_DEFALIENS];
object enemy[MAX_ALIENS];
static bool placeAlien(object *theEnemy)
{
if (rand() % 2 == 0)
theEnemy->x = Math::rrand(800, 1600);
@ -55,7 +58,7 @@ This simply pulls back an alien from the array that is
"dead" (no shield) and returns the index number so we can have
a new one.
*/
int getAlien()
static int getAlien()
{
for (int i = 0 ; i < engine.maxAliens ; i++)
{
@ -68,7 +71,7 @@ int getAlien()
return -1;
}
void addDrone(object *host)
static void addDrone(object *host)
{
int index = getAlien();
@ -89,7 +92,7 @@ void addDrone(object *host)
enemy[index].y = host->y + rand() % 50;
}
void addSmallAsteroid(object *host)
static void addSmallAsteroid(object *host)
{
if (engine.missionCompleteTimer != 0)
return;
@ -280,7 +283,7 @@ bool addAlien()
return true;
}
void getPreDefinedAliens()
static void getPreDefinedAliens()
{
FILE *fp;
char string[255];
@ -460,7 +463,7 @@ void getPreDefinedAliens()
}
}
void addFriendly(int type)
static void addFriendly(int type)
{
if (type != FR_SID)
enemy[type] = defEnemy[CD_FRIEND];
@ -649,7 +652,7 @@ void initAliens()
"Looks" for an enemy by picking a randomly active enemy and using them
as a target. If the target is too far away, it will be ignored.
*/
void searchForTarget(object *theEnemy)
static void searchForTarget(object *theEnemy)
{
int i;
@ -708,7 +711,7 @@ void searchForTarget(object *theEnemy)
theEnemy->target = targetEnemy;
}
int traceTarget(object *theEnemy)
static int traceTarget(object *theEnemy)
{
// Do various checks to see if the alien can fire at
// the target. Start with the most obvious checks.
@ -751,7 +754,7 @@ int traceTarget(object *theEnemy)
Currently only used for the allies. Whilst flying around, the allies will fire on
any enemy craft that enter their line of sight.
*/
int traceView(object *theEnemy)
static int traceView(object *theEnemy)
{
object *anEnemy = enemy;
@ -774,7 +777,7 @@ int traceView(object *theEnemy)
return 0;
}
void moveAndSeparate(object *theEnemy)
static void moveAndSeparate(object *theEnemy)
{
bool checkCollisions = true;
bool hasCollided = false;
@ -1258,7 +1261,7 @@ void setAlienShapes()
#if USEPACK
void loadAliens()
static void loadAliens()
{
int dataLocation = locateDataInPak("data/aliens.dat", 1);
int def, ai, speed, shield, max, image1, image2, weapon1, weapon2, chance1, chance2, score;
@ -1313,7 +1316,7 @@ void defineAliens(){loadAliens();}
#else
void saveAliens()
static void saveAliens()
{
FILE *fp;

View File

@ -18,41 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void setEnemyAI(object *theEnemy);
extern void setKlineAI(object *theEnemy);
extern void fireBullet(object *attacker, int weaponType);
extern void addExplosion(float x, float y, int type);
extern void addEngine(object *craft);
extern void fireRay(object *attacker);
extern void addDebris(int x, int y, int amount);
extern void playSound(int sid);
extern int locateDataInPak(const char *file, bool required);
extern object *addCargo(object *owner, int cargoType);
extern void addCollectable(float x, float y, int type, int value, int life);
extern void updateMissionRequirements(int type, int id, int value);
extern void setInfoLine(const char *in, int color);
extern void addBullet(object *theWeapon, object *attacker, int y, int dy);
extern void showErrorAndExit(int errorId, const char *name);
extern globalEngineVariables engine;
extern devVariables dev;
extern Game currentGame;
extern object player;
extern object defEnemy[MAX_DEFALIENS];
extern object enemy[MAX_ALIENS];
extern Graphics graphics;
extern mission currentMission;
extern object weapon[MAX_WEAPONS];
object defEnemy[MAX_DEFALIENS]; // A predefined enemy
extern bool addAlien();
extern void setTarget(int index);
extern void initAliens();
extern void killAllAliens();
extern void doAliens();
extern void setAlienShapes();
extern void defineAliens();

View File

@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "audio.h"
#include "Starfighter.h"
Mix_Chunk *sound[MAX_SOUNDS];
void playSound(int sid)
{

View File

@ -18,19 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
extern void unpack(const char *file, signed char fileType);
extern void freePackBuffer();
extern globalEngineVariables engine;
extern Game currentGame;
extern Mix_Chunk *sound[MAX_SOUNDS];
extern void playSound(int sid);
extern Mix_Chunk *loadSound(const char *filename);
extern void loadMusic(const char *filename);
extern void playRandomTrack();

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "bullets.h"
#include "Starfighter.h"
void addBullet(object *theWeapon, object *attacker, int y, int dy)
{
@ -252,7 +252,7 @@ one attempt per call (one call per frame) to find a suitable target. If the targ
it picks is dead or outside the screen range, then it returns NULL. A suitable
target will be returned as the object address.
*/
object *getRandomEnemy(object *bullet)
static object *getRandomEnemy(object *bullet)
{
int i;
@ -287,7 +287,7 @@ object *getRandomEnemy(object *bullet)
/*
Fill in later...
*/
void destroyAlien(object *bullet, object *theEnemy)
static void destroyAlien(object *bullet, object *theEnemy)
{
playSound(SFX_EXPLOSION);

View File

@ -18,37 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void playSound(int sid);
extern void updateMissionRequirements(int type, int id, int value);
extern void addCollectable(float x, float y, int type, int value, int life);
extern void addExplosion(float x, float y, int type);
extern void generateShockWave(object *bullet);
extern void setInfoLine(const char *in, int color);
extern void getKillMessage(object *ally);
extern void getMissFireMessage(object *ally);
extern void getPlayerHitMessage(object *ally);
extern void checkMineBulletCollisions(object *bullet);
extern void setKlineAttackMethod(object *theEnemy);
extern void setRadioMessage(signed char face, const char *in, int priority);
extern globalEngineVariables engine;
extern devVariables dev;
extern object weapon[MAX_WEAPONS];
extern object player;
extern mission currentMission;
extern object enemy[MAX_ALIENS];
extern object cargo[20];
extern Game currentGame;
extern Graphics graphics;
extern void addBullet(object *theWeapon, object *attacker, int y, int dy);
extern void fireBullet(object *attacker, int weaponType);
extern char checkPlayerShockDamage(float x, float y);
extern void fireRay(object *attacker);
extern void doBullets();

View File

@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "cargo.h"
#include "Starfighter.h"
object cargo[MAX_CARGO];
void initCargo()
{
@ -32,7 +34,7 @@ void initCargo()
/*
* I think you all know what this does by now! ;)
*/
int getCargo()
static int getCargo()
{
for (int i = 0 ; i < MAX_CARGO ; i++)
{
@ -64,7 +66,7 @@ object *addCargo(object *owner, int cargoType)
return &cargo[index];
}
void becomeCollectable(int i)
static void becomeCollectable(int i)
{
if (cargo[i].collectType != P_PHOEBE)
{

View File

@ -18,23 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void addCollectable(float x, float y, int type, int value, int life);
extern void setRadioMessage(signed char face, const char *in, int priority);
extern globalEngineVariables engine;
extern Game currentGame;
extern Graphics graphics;
extern object enemy[MAX_ALIENS];
extern object player;
extern object cargo[MAX_CARGO];
extern void initCargo();
extern object *addCargo(object *owner, int cargoType);
extern void doCargo();

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "collectable.h"
#include "Starfighter.h"
/*
Create a new collectable item based on supplied arguments.
@ -161,7 +161,7 @@ void addCollectable(float x, float y, int type, int value, int life)
engine.collectableTail = collectable;
}
void explodeMine(collectables *collectable)
static void explodeMine(collectables *collectable)
{
if ((collectable->x >= 0) && (collectable->x <= 800) && (collectable->y >= 0) && (collectable->y <= 600))
playSound(SFX_EXPLOSION);

View File

@ -18,26 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void updateMissionRequirements(int type, int id, int value);
extern void setInfoLine(const char *in, int color);
extern object *addCargo(object *owner, int cargoType);
extern void addExplosion(float x, float y, int type);
extern void playSound(int sid);
extern char checkPlayerShockDamage(float x, float y);
extern globalEngineVariables engine;
extern object player;
extern Game currentGame;
extern object weapon[MAX_WEAPONS];
extern Graphics graphics;
extern void addCollectable(float x, float y, int type, int value, int life);
extern void checkMineBulletCollisions(object *bullet);
extern void doCollectables();

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "comms.h"
#include "Starfighter.h"
void updateCommsSurface(SDL_Surface *comms)
{
@ -60,7 +60,7 @@ void createCommsSurface(SDL_Surface *comms)
updateCommsSurface(comms);
}
void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
static void createMissionDetailSurface(SDL_Surface *comms, int missionSlot)
{
char name[50];
char string[2000];

View File

@ -18,21 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern int locateDataInPak(const char *file, bool required);
extern int getFace(const char *face);
extern globalEngineVariables engine;
extern Game currentGame;
extern Graphics graphics;
extern Planet systemPlanet[10];
extern void updateCommsSurface(SDL_Surface *comms);
extern void createCommsSurface(SDL_Surface *comms);
extern void doComms(SDL_Surface *comms);

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "debris.h"
#include "Starfighter.h"
void addDebris(int x, int y, int amount)
{

View File

@ -18,19 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void addExplosion(float x, float y, int type);
extern void playSound(int sid);
extern globalEngineVariables engine;
extern Graphics graphics;
extern void addDebris(int x, int y, int amount);
extern void doDebris();

View File

@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "events.h"
#include "Starfighter.h"
static char lastKeyEvents[] = " ";
/*
Checked during the main game loop. When the game is paused
@ -46,7 +48,7 @@ bool checkPauseRequest()
return false;
}
void compareLastKeyInputs()
static void compareLastKeyInputs()
{
if (strstr(lastKeyEvents, "humansdoitbetter") != NULL)
{engine.cheat = true; memset(lastKeyEvents, ' ', 25);}

View File

@ -18,20 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "structs.h"
extern void getPlayerInput();
extern globalEngineVariables engine;
extern object player;
extern Game currentGame;
extern devVariables dev;
char lastKeyEvents[] = " ";
extern bool checkPauseRequest();
extern void addKeyEvent(const char *keyName);

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "explosions.h"
#include "Starfighter.h"
/*
Create a new explosion based on supplied parameters.

View File

@ -18,20 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern int isOnScreen(int x, int y, int w, int h);
extern globalEngineVariables engine;
extern devVariables dev;
extern object enemy[MAX_ALIENS];
extern Graphics graphics;
extern void addExplosion(float x, float y, int type);
extern void addEngine(object *craft);
extern void doExplosions();

View File

@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "game.h"
#include "Starfighter.h"
Game currentGame;
void newGame()
{

View File

@ -18,58 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void resetLists();
extern void setMission(int mission);
extern void missionBriefScreen();
extern void initPlayer();
extern void initAliens();
extern signed char allMissionsCompleted();
extern void getPlayerInput();
extern void leaveSector();
extern void doStarfield();
extern void doCollectables();
extern void doCargo();
extern void doBullets();
extern void doAliens();
extern void doPlayer();
extern void doExplosions();
extern void doDebris();
extern void doInfo();
extern signed char allMissionsCompleted();
extern signed char checkPauseRequest();
extern signed char addAlien();
extern void missionFinishedScreen();
extern void gameover();
extern void clearInfoLines();
extern signed char missionFailed();
extern void playSound(int sid);
extern void loadScriptEvents();
extern void doCutscene(int scene);
extern void addCollectable(float x, float y, int type, int value, int life);
extern void doCredits();
extern void updateSystemStatus();
extern void saveGame(int slot);
extern void flushInput();
extern void initWeapons();
extern void initMissions();
extern void initCargo();
extern void initPlanetMissions(signed char system);
extern globalEngineVariables engine;
extern object player;
extern object enemy[MAX_ALIENS];
extern mission currentMission;
extern Game currentGame;
extern Graphics graphics;
extern void newGame();
extern int mainGameLoop();

View File

@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "globals.h"
#include "Starfighter.h"
devVariables dev;
globalEngineVariables engine;
void defineGlobals()
{

View File

@ -18,16 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
extern globalEngineVariables engine;
extern devVariables dev;
extern globalEngineVariables engine;
extern void defineGlobals();

View File

@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "graphics.h"
#include "Starfighter.h"
Graphics graphics;
Star star[200];
SDL_Surface *loadImage(const char *filename)
{

View File

@ -18,20 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void unpack(const char *file, signed char fileType);
extern void showErrorAndExit(int errorId, const char *name);
extern Star star[200];
extern globalEngineVariables engine;
extern Graphics graphics;
extern Star star[200];
extern SDL_Surface *loadImage(const char *filename);
extern void doStarfield();
extern int isOnScreen(int x, int y, int w, int h);

View File

@ -18,7 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "init.h"
#include "Starfighter.h"
#if LINUX
#include <sys/stat.h>
#include <pwd.h>
#include <unistd.h>
#include <errno.h>
#endif
/*
Initalises a whole load of variables
@ -105,7 +112,7 @@ home directory, then creates the .parallelrealities and .parallelrealities/starf
directories so that saves and temporary data files can be written there. Good, eh? :)
*/
#if LINUX
void setupUserHomeDirectory()
static void setupUserHomeDirectory()
{
char *userHome;

View File

@ -18,32 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <time.h>
#if LINUX
#include <sys/stat.h>
#include <pwd.h>
#include <unistd.h>
#include <errno.h>
#endif
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void freeSound();
extern void resetLists();
extern void getPlayerInput();
extern void drawString(const char *in, int x, int y, int fontColor);
extern SDL_Surface *loadImage(const char *filename);
extern globalEngineVariables engine;
extern Game currentGame;
extern Graphics graphics;
extern Star star[200];
extern void initVars();
extern void showErrorAndExit(int errorId, const char *name);
extern void initSystem();
extern void cleanUp();

View File

@ -18,12 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "intermission.h"
#include "Starfighter.h"
/*
Drives the cursor. Is used by some other screens too
*/
void doCursor()
static void doCursor()
{
getPlayerInput();
@ -37,7 +37,7 @@ Sets the player's current status information lines. These are the lines
that are scrolled up the screen when the player clicks on Current Status
These are set only once.
*/
void setStatusLines()
static void setStatusLines()
{
char string[50];
@ -167,7 +167,7 @@ void setStatusLines()
Sets the names and stats of the planets within the current system.
This will later be placed into a data file.
*/
void setSystemPlanets()
static void setSystemPlanets()
{
FILE *fp;
@ -239,7 +239,7 @@ Spins the planets around the sun, spaced according to their Y value
as defined in setSystemPlanets(). Moving the cursor over the planet
will show their name and their current status
*/
bool showSystem(float x, float y)
static bool showSystem(float x, float y)
{
SDL_Rect r;
signed char planet = 0;
@ -303,7 +303,7 @@ the specified status line reaches a certain Y value, the entire
list is reset and the information lines begin again from the bottom
(in other words, they loop around).
*/
void showStatus(SDL_Surface *infoSurface)
static void showStatus(SDL_Surface *infoSurface)
{
graphics.blit(infoSurface, 100, 80);
@ -334,7 +334,7 @@ void showStatus(SDL_Surface *infoSurface)
graphics.blitText(27);
}
void createOptions(SDL_Surface *optionsSurface)
static void createOptions(SDL_Surface *optionsSurface)
{
SDL_FillRect(optionsSurface, NULL, graphics.black);
@ -391,7 +391,7 @@ void createOptions(SDL_Surface *optionsSurface)
graphics.drawString("AUTOSAVE SLOT", 30, 200, FONT_WHITE, optionsSurface);
}
void showOptions(SDL_Surface *optionsSurface)
static void showOptions(SDL_Surface *optionsSurface)
{
if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL]))
{

View File

@ -18,39 +18,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern SDL_Surface *loadImage(const char *filename);
extern void doStarfield();
extern void getPlayerInput();
extern void showShop();
extern void initShop();
extern int initSaveSlots();
extern int showSaveSlots(SDL_Surface *savesSurface, signed char saveSlot);
extern void saveGame(int slot);
extern void loadMusic(const char *filename);
extern void loadBackground(const char *filename);
extern void createCommsSurface(SDL_Surface *comms);
extern void updateCommsSurface(SDL_Surface *comms);
extern void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot);
extern void checkForBossMission();
extern void doComms(SDL_Surface *comms);
extern int locateDataInPak(const char *file, bool required);
extern int getFace(const char *face);
extern void flushInput();
extern globalEngineVariables engine;
extern object player;
extern Game currentGame;
extern Graphics graphics;
extern Planet systemPlanet[10];
extern int galaxyMap();

View File

@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "loadSave.h"
#include "Starfighter.h"
static char saveSlot[10][25];
/*
Reads in each save game that it finds and gives it an appropriate

View File

@ -18,27 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
char saveSlot[10][25];
extern void getPlayerInput();
extern void initPlanetMissions(signed char system);
extern globalEngineVariables engine;
extern object player;
extern object weapon[MAX_WEAPONS];
extern Game currentGame;
extern Graphics graphics;
extern Planet systemPlanet[10];
extern int initSaveSlots();
extern bool loadGame(int slot);
extern void saveGame(int slot);
extern void createSavesSurface(SDL_Surface *savesSurface, signed char clickedSlot);
extern int showSaveSlots(SDL_Surface *savesSurface, signed char saveSlot);

View File

@ -18,9 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "messages.h"
#include "Starfighter.h"
void setKillMessages()
static char deathMessage[6][50];
static char killMessage[10][50];
static char missFireMessage[5][50];
static char playerHitMessage[3][50];
static void setKillMessages()
{
strcpy(killMessage[0], "Chalk another one up for me!");
strcpy(killMessage[1], "That'll teach you!");
@ -37,7 +42,7 @@ void setKillMessages()
strcpy(killMessage[9], "Number One, Baby!");
}
void setPlayerDeadMessages()
static void setPlayerDeadMessages()
{
strcpy(deathMessage[0], "Oh my God... No!");
strcpy(deathMessage[1], "NOOOOOOOOOOOOOOOOOOOOOOOOOOO!!!!");
@ -47,7 +52,7 @@ void setPlayerDeadMessages()
strcpy(deathMessage[5], "Chriiiiiiiiiiiiiiiiiiiiiiiiiiis!!!!");
}
void setMissFireMessages()
static void setMissFireMessages()
{
strcpy(missFireMessage[0], "I am NOT your enemy!");
strcpy(missFireMessage[1], "Hey! Watch it!");
@ -56,7 +61,7 @@ void setMissFireMessages()
strcpy(missFireMessage[4], "Open your eyes!!");
}
void setHitPlayerMessages()
static void setHitPlayerMessages()
{
strcpy(playerHitMessage[0], "Oops! Sorry!");
strcpy(playerHitMessage[1], "Get out of the way!");

View File

@ -18,23 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
extern void setRadioMessage(signed char face, const char *in, int priority);
char killMessage[10][50];
char deathMessage[6][50];
char missFireMessage[5][50];
char playerHitMessage[3][50];
extern object enemy[MAX_ALIENS];
extern Game currentGame;
extern void setAllyMessages();
extern void getKillMessage(object *ally);
extern const char *getKlineInsult();
extern void getPlayerDeathMessage();
extern void getMissFireMessage(object *ally);
extern void getPlayerHitMessage(object *ally);

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "misc.h"
#include "Starfighter.h"
void clearInfoLines()
{
@ -29,7 +29,7 @@ void clearInfoLines()
}
// from a to b
void copyInfoLine(int a, int b)
static void copyInfoLine(int a, int b)
{
graphics.textSurface(b, graphics.textShape[a].text, -1, 0, graphics.textShape[a].fontColor);
graphics.textShape[b].life = graphics.textShape[a].life;
@ -85,7 +85,7 @@ void setRadioMessage(signed char face, const char *in, int priority)
graphics.createMessageBox(faceShape, in, 1);
}
void doTargetArrow()
static void doTargetArrow()
{
if ((engine.targetArrowTimer == 0) || (enemy[engine.targetIndex].shield < 1))
return;

View File

@ -18,27 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern signed char allMissionsCompleted();
extern void playSound(int sid);
extern void checkTimer();
extern void checkScriptEvents();
extern globalEngineVariables engine;
extern devVariables dev;
extern object player;
extern object enemy[MAX_ALIENS];
extern object weapon[MAX_WEAPONS];
extern mission currentMission;
extern Game currentGame;
extern Graphics graphics;
extern void clearInfoLines();
extern void setInfoLine(const char *in, int color);
extern void setRadioMessage(signed char face, const char *in, int priority);
extern void doInfo();
extern int getFace(const char *face);
extern void resetLists();

View File

@ -18,10 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "missions.h"
#include "Starfighter.h"
// God, I hate this file! :((
Planet systemPlanet[10];
mission currentMission;
static mission missions[MAX_MISSIONS];
void initPlanetMissions(signed char system)
{
for (int i = 0 ; i < 10 ; i++)
@ -202,7 +206,7 @@ Timer Variable:
-1 : Time up
-2 : No timer
*/
void clearAllMissions()
static void clearAllMissions()
{
for (int m = 0 ; m < MAX_MISSIONS ; m++)
{
@ -303,7 +307,7 @@ void checkTimer()
}
}
void evaluteRequirement(int type, int id, int *completed, int *targetValue, int fontColor)
static void evaluateRequirement(int type, int id, int *completed, int *targetValue, int fontColor)
{
char message[25];
@ -417,7 +421,7 @@ void updateMissionRequirements(int type, int id, int value)
{
matched = 1;
currentMission.targetValue1[i] -= value;
evaluteRequirement(type, id, &currentMission.completed1[i], &currentMission.targetValue1[i], FONT_CYAN);
evaluateRequirement(type, id, &currentMission.completed1[i], &currentMission.targetValue1[i], FONT_CYAN);
}
}
}
@ -433,7 +437,7 @@ void updateMissionRequirements(int type, int id, int value)
if ((currentMission.secondaryType[i] == type) && ((currentMission.target2[i] == id) || (currentMission.target2[i] == CD_ANY)))
{
currentMission.targetValue2[i] -= value;
evaluteRequirement(type, id, &currentMission.completed2[i], &currentMission.targetValue2[i], FONT_YELLOW);
evaluateRequirement(type, id, &currentMission.completed2[i], &currentMission.targetValue2[i], FONT_YELLOW);
return;
}
}
@ -473,7 +477,7 @@ void updateMissionRequirements(int type, int id, int value)
This is only used as few times in the game.
Missions 11 and 23 to be exact!
*/
char revealHiddenObjectives()
static char revealHiddenObjectives()
{
char allDone = 1;
char string[255];
@ -665,7 +669,7 @@ bool missionFailed()
return false;
}
void drawBriefScreen()
static void drawBriefScreen()
{
SDL_Rect r = {0, 0, 800, 2};
@ -903,7 +907,7 @@ void missionFinishedScreen()
#if USEPACK
void loadMissions()
static void loadMissions()
{
clearAllMissions();
@ -974,7 +978,7 @@ void initMissions(){loadMissions();}
#else
void saveMissions()
static void saveMissions()
{
FILE *fp;
char filename[65];

View File

@ -18,35 +18,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern SDL_Surface *loadImage(const char *file_name);
extern void playRandomTrack();
extern void getPlayerInput();
extern void setInfoLine(const char *in, int color);
extern void loadGameGraphics();
extern void killAllAliens();
extern int locateDataInPak(const char *file, bool required);
extern void setRadioMessage(signed char face, const char *in, int priority);
extern void syncScriptEvents();
extern void loadMusic(const char *filename);
extern void setTarget(int index);
extern void flushInput();
extern globalEngineVariables engine;
extern object player;
extern object enemy[MAX_ALIENS];
extern mission currentMission;
extern Game currentGame;
extern Graphics graphics;
extern Planet systemPlanet[10];
extern mission missions[MAX_MISSIONS];
extern mission currentMission;
extern void initPlanetMissions(signed char system);
extern void checkForBossMission();
extern void updateSystemStatus();
extern void setMission(int mission);
extern void checkTimer();
extern void updateMissionRequirements(int type, int id, int value);
extern bool allMissionsCompleted();
extern bool missionFailed();
extern void missionBriefScreen();
extern void missionFinishedScreen();
extern void initMissions();

View File

@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "player.h"
#include "Starfighter.h"
object player;
/*
Initialises the player for a new game.

View File

@ -18,33 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void fireBullet(object *attacker, int weaponType);
extern void addExplosion(float x, float y, int type);
extern void playSound(int sid);
extern void addEngine(object *craft);
extern void addKeyEvent(const char *keyName);
extern void addDebris(int x, int y, int amount);
extern void setRadioMessage(signed char face, const char *in, int priority);
extern void setInfoLine(const char *in, int color);
extern void getPlayerDeathMessage();
extern void playSound(int sid);
extern void setTarget(int index);
extern globalEngineVariables engine;
extern object player;
extern mission currentMission;
extern Game currentGame;
extern object weapon[MAX_WEAPONS];
extern object enemy[MAX_ALIENS];
extern Graphics graphics;
extern void initPlayer();
extern void doPlayer();
extern void flushInput();
extern void getPlayerInput();
extern void leaveSector();

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "resources.h"
#include "Starfighter.h"
void loadBackground(const char *filename)
{
@ -155,7 +155,7 @@ void freeSound()
}
void setFontColor(SDL_Surface *image, int red, int green, int blue)
static void setFontColor(SDL_Surface *image, int red, int green, int blue)
{
SDL_Color colors[256];
colors[0].r = 0;

View File

@ -18,28 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void unpack(const char *file, signed char fileType);
extern SDL_Surface *loadImage(const char *filename);
extern Mix_Chunk *loadSound(const char *filename);
extern int locateDataInPak(const char *file, bool required);
extern void setAlienShapes();
extern void setWeaponShapes();
extern void loadBackground(const char *filename);
extern void loadGameGraphics();
extern globalEngineVariables engine;
extern object weapon[MAX_WEAPONS];
extern Mix_Chunk *sound[MAX_SOUNDS];
extern object enemy[MAX_ALIENS];
extern Graphics graphics;
extern Game currentGame;
extern void loadSound();
extern void freeSound();
extern void loadFont();

View File

@ -18,9 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "script.h"
#include "Starfighter.h"
void setKlineGreeting()
static cutMsg cutMessage[10];
static event gameEvent[10];
static void setKlineGreeting()
{
char greet[][50] = {
"How nice to see you again, Bainfield!",
@ -133,7 +136,7 @@ void syncScriptEvents()
}
}
void setScene(int scene)
static void setScene(int scene)
{
FILE *fp;
char string[255], face[255];

View File

@ -18,35 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern void doStarfield();
extern void getPlayerInput();
extern void loadGameGraphics();
extern void loadBackground(const char *filename);
extern void setRadioMessage(signed char face, const char *in, int priority);
extern void doExplosions();
extern void addEngine(object *craft);
extern void doExplosions();
extern void resetLists();
extern int getFace(const char *face);
extern int locateDataInPak(const char *file, bool required);
extern void flushInput();
extern Game currentGame;
extern object enemy[MAX_ALIENS];
extern object player;
extern object defEnemy[MAX_DEFALIENS];
extern globalEngineVariables engine;
extern Graphics graphics;
extern event gameEvent[10];
extern cutMsg cutMessage[10];
extern void loadScriptEvents();
extern void checkScriptEvents();
extern void syncScriptEvents();
extern void doCutscene(int scene);

View File

@ -18,9 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "shop.h"
#include "Starfighter.h"
void drawSecondaryWeaponSurface()
static ShopItem shopItems[MAX_SHOPITEMS];
static signed char shopSelectedItem;
static void drawSecondaryWeaponSurface()
{
char description[50];
strcpy(description, "");
@ -66,7 +69,7 @@ void drawSecondaryWeaponSurface()
}
}
void adjustShopPrices()
static void adjustShopPrices()
{
shopItems[0].price = (500 * currentGame.maxPlasmaOutput);
shopItems[1].price = (500 * currentGame.maxPlasmaDamage);
@ -98,7 +101,7 @@ void adjustShopPrices()
shopItems[7].price = 0;
}
void drawShop()
static void drawShop()
{
adjustShopPrices();
@ -260,7 +263,7 @@ void drawShop()
#if USEPACK
void loadShop()
static void loadShop()
{
char name[255], description[255];
int price, image, x, y;
@ -307,7 +310,7 @@ void initShop(){loadShop();}
#else
void saveShop()
static void saveShop()
{
FILE *fp;
@ -475,7 +478,7 @@ void initShop()
#endif
void buy(int i)
static void buy(int i)
{
if ((currentGame.cash < shopItems[i].price) && (!engine.cheatCash))
{
@ -605,7 +608,7 @@ void buy(int i)
currentGame.cash -= shopItems[i].price;
}
void sell(int i)
static void sell(int i)
{
switch (i)
{

View File

@ -18,26 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern int locateDataInPak(const char *file, bool required);
extern object player;
extern globalEngineVariables engine;
extern object weapon[MAX_WEAPONS];
extern Game currentGame;
extern Graphics graphics;
extern devVariables dev;
extern ShopItem shopItems[MAX_SHOPITEMS];
signed char shopSelectedItem;
extern void initShop();
extern void showShop();

View File

@ -18,10 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "version.h"
#include "title.h"
#include "Starfighter.h"
signed char showGameMenu(signed char continueSaveSlot)
static signed char showGameMenu(signed char continueSaveSlot)
{
graphics.blitText(2);
if (continueSaveSlot != 0)
@ -47,7 +46,7 @@ signed char showGameMenu(signed char continueSaveSlot)
return 5;
}
signed char showLoadMenu()
static signed char showLoadMenu()
{
signed char rtn = 1;
@ -65,7 +64,7 @@ signed char showLoadMenu()
return rtn;
}
void createOptionsMenu()
static void createOptionsMenu()
{
if (currentGame.useSound)
graphics.textSurface(8, "SOUND - ON", -1, 350, FONT_WHITE);
@ -89,7 +88,7 @@ void createOptionsMenu()
graphics.textSurface(11, string, -1, 410, FONT_WHITE);
}
signed char showOptionsMenu()
static signed char showOptionsMenu()
{
graphics.textShape[12].y = 450;
@ -102,7 +101,7 @@ signed char showOptionsMenu()
return 5;
}
void createCheatMenu()
static void createCheatMenu()
{
if (engine.cheatShield)
graphics.textSurface(18, "UNLIMITED SHIELD - ON", -1, 350, FONT_WHITE);
@ -125,7 +124,7 @@ void createCheatMenu()
graphics.textSurface(21, "UNLIMITED TIME - OFF", -1, 410, FONT_WHITE);
}
signed char showCheatMenu()
static signed char showCheatMenu()
{
graphics.textShape[12].y = 450;

View File

@ -18,37 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern SDL_Surface *loadImage(const char *filename);
extern void unpack(const char *file);
extern void loadMusic(const char *filename);
extern void doStarfield();
extern void doExplosions();
extern void addEngine(object *craft);
extern void getPlayerInput();
extern void resetLists();
extern signed char loadGame(int slot);
extern int initSaveSlots();
extern void newGame();
extern void loadGameGraphics();
extern void loadBackground(const char *filename);
extern int doTitle();
extern void showStory();
extern void gameover();
extern void doCredits();
extern int locateDataInPak(const char *file, bool required);
extern void flushInput();
extern globalEngineVariables engine;
extern devVariables dev;
extern object defEnemy[MAX_DEFALIENS];
extern object enemy[MAX_ALIENS];
extern Game currentGame;
extern Graphics graphics;

View File

@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "unpack.h"
#include "Starfighter.h"
/*
Searches the pak file for the required data. When

View File

@ -18,18 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include <SDL/SDL_endian.h>
#include "defs.h"
#include "structs.h"
extern void showErrorAndExit(int errorId, const char *name);
extern globalEngineVariables engine;
extern void unpack(const char *file, signed char fileType);
extern int locateDataInPak(const char *file, bool required);

View File

@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "weapons.h"
#include "Starfighter.h"
object weapon[MAX_WEAPONS];
void setWeaponShapes()
{
@ -31,7 +33,7 @@ void setWeaponShapes()
#if USEPACK
void loadWeapons()
static void loadWeapons()
{
int dataLocation = locateDataInPak("data/weapons.dat", 1);
int id, ammo, damage, reload, speed, image1, image2, flags;
@ -69,7 +71,7 @@ void initWeapons() {loadWeapons();}
#else
void saveWeapons()
static void saveWeapons()
{
FILE *fp;

View File

@ -18,19 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include <SDL/SDL_mixer.h>
#include "defs.h"
#include "structs.h"
#include "classes.h"
extern int locateDataInPak(const char *file, bool required);
extern Graphics graphics;
extern object weapon[MAX_WEAPONS];
extern void setWeaponShapes();
extern void initWeapons();