From 5e82c957cd8a2450b4f79ff7b990c649ddc49571 Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 30 Jul 2022 16:10:02 +0100 Subject: [PATCH] Moved #includes, #defines, enums into c files, from h files. --- src/battle/ai.c | 22 ++++++++- src/battle/ai.h | 31 ++----------- src/battle/battle.c | 46 ++++++++++++++++++- src/battle/battle.h | 81 ++-------------------------------- src/battle/bullets.c | 23 +++++++++- src/battle/bullets.h | 45 +++++-------------- src/battle/capitalShips.c | 25 ++++++++++- src/battle/capitalShips.h | 44 +++--------------- src/battle/debris.c | 13 +++++- src/battle/debris.h | 22 +++------ src/battle/effects.c | 12 ++++- src/battle/effects.h | 33 +++++++------- src/battle/entities.c | 22 ++++++++- src/battle/entities.h | 42 ++++++------------ src/battle/fighters.c | 27 +++++++++++- src/battle/fighters.h | 54 ++++++----------------- src/battle/hud.c | 18 +++++++- src/battle/hud.h | 30 +++---------- src/battle/items.c | 18 +++++++- src/battle/items.h | 27 +++--------- src/battle/jumpgate.c | 18 +++++++- src/battle/jumpgate.h | 23 ++-------- src/battle/locations.c | 11 ++++- src/battle/locations.h | 18 +++----- src/battle/messageBox.c | 12 ++++- src/battle/messageBox.h | 21 +++------ src/battle/mine.c | 21 ++++++++- src/battle/mine.h | 23 +--------- src/battle/missionInfo.c | 15 ++++++- src/battle/missionInfo.h | 18 ++------ src/battle/objectives.c | 14 +++++- src/battle/objectives.h | 26 +++++------ src/battle/player.c | 26 ++++++++++- src/battle/player.h | 44 +++--------------- src/battle/quadtree.c | 9 +++- src/battle/quadtree.h | 16 +++---- src/battle/radar.c | 12 ++++- src/battle/radar.h | 17 ++----- src/battle/rope.c | 16 ++++++- src/battle/rope.h | 22 +++------ src/battle/script.c | 18 +++++++- src/battle/script.h | 33 +++----------- src/battle/spawners.c | 10 ++++- src/battle/spawners.h | 19 +++----- src/battle/starfield.c | 6 ++- src/battle/starfield.h | 10 ++--- src/battle/waypoints.c | 17 ++++++- src/battle/waypoints.h | 20 ++------- src/challenges/challengeHome.c | 42 ++++++++++++++++-- src/challenges/challengeHome.h | 58 +----------------------- src/challenges/challenges.c | 18 +++++++- src/challenges/challenges.h | 28 +++--------- src/common.h | 2 +- src/defs.h | 2 +- src/galaxy/galacticMap.c | 36 ++++++++++++++- src/galaxy/galacticMap.h | 60 ++----------------------- src/galaxy/mission.c | 54 +++++++++++++++-------- src/galaxy/mission.h | 63 ++++---------------------- src/galaxy/starSystems.c | 10 ++++- src/galaxy/starSystems.h | 18 +++----- src/game/credits.c | 18 +++++++- src/game/credits.h | 24 ++-------- src/game/fighterDatabase.c | 12 ++++- src/game/fighterDatabase.h | 19 +++----- src/game/game.c | 5 ++- src/game/game.h | 7 ++- src/game/load.c | 13 +++++- src/game/load.h | 18 +------- src/game/options.c | 16 ++++++- src/game/options.h | 25 ++--------- src/game/save.c | 8 +++- src/game/save.h | 12 +---- src/game/stats.c | 13 +++++- src/game/stats.h | 19 +++----- src/game/title.c | 37 +++++++++++++++- src/game/title.h | 56 +---------------------- src/game/trophies.c | 22 ++++++++- src/game/trophies.h | 45 ++++++------------- src/json/cJSON.h | 1 - src/main.c | 27 +++++++++++- src/main.h | 41 +---------------- src/plat/unix/unixInit.c | 10 ++++- src/plat/unix/unixInit.h | 13 ++---- src/plat/win32/win32Init.c | 9 +++- src/plat/win32/win32Init.h | 12 ++--- src/structs.h | 2 +- src/system/atlas.c | 9 +++- src/system/atlas.h | 13 +++--- src/system/controls.c | 11 ++++- src/system/controls.h | 24 +++++----- src/system/dev.c | 8 +++- src/system/dev.h | 10 +---- src/system/draw.c | 11 ++++- src/system/draw.h | 23 +++++----- src/system/i18n.c | 14 +++--- src/system/i18n.h | 15 ++----- src/system/init.c | 43 ++++++++++++++++-- src/system/init.h | 67 +++------------------------- src/system/input.c | 8 +++- src/system/input.h | 21 +++++---- src/system/io.c | 8 +++- src/system/io.h | 16 +++---- src/system/lookup.c | 4 +- src/system/lookup.h | 8 +++- src/system/modalDialog.c | 9 +++- src/system/modalDialog.h | 18 +++----- src/system/resources.c | 5 ++- src/system/resources.h | 11 ++--- src/system/sound.c | 13 +++++- src/system/sound.h | 21 ++++----- src/system/text.c | 15 +++++-- src/system/text.h | 25 +++-------- src/system/textures.c | 8 +++- src/system/textures.h | 12 ++--- src/system/transition.c | 5 ++- src/system/transition.h | 9 ++-- src/system/util.c | 7 ++- src/system/util.h | 18 ++++++-- src/system/widgets.c | 17 ++++++- src/system/widgets.h | 31 ++++--------- src/test/testMission.c | 8 +++- src/test/testMission.h | 12 +---- 122 files changed, 1241 insertions(+), 1341 deletions(-) diff --git a/src/battle/ai.c b/src/battle/ai.c index 2d324e0..7dc3095 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "ai.h" +#include "../battle/mine.h" +#include "../system/util.h" +#include "../battle/fighters.h" +#include "../battle/quadtree.h" +#include "../battle/bullets.h" +#include "../battle/hud.h" +#include "../battle/script.h" + +#define AI_EVADE 0 +#define AI_FALLBACK 1 +#define AI_HUNT 2 +#define TURN_SPEED 4 +#define TURN_THRESHOLD 2 + +extern Battle battle; +extern Colors colors; +extern Dev dev; +extern Entity *player; +extern Entity *self; static void faceTarget(Entity *e); static int isInFOV(Entity *e, int fov); diff --git a/src/battle/ai.h b/src/battle/ai.h index 4cab502..d29dcaf 100644 --- a/src/battle/ai.h +++ b/src/battle/ai.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,29 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define AI_EVADE 0 -#define AI_FALLBACK 1 -#define AI_HUNT 2 -#define TURN_SPEED 4 -#define TURN_THRESHOLD 2 - -extern void addHudMessage(SDL_Color c, char *format, ...); -extern void applyFighterBrakes(void); -extern void applyFighterThrust(void); -extern void fireGuns(Entity *owner); -extern void fireMissile(Entity *owner); -extern void fireRocket(Entity *owner); -extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore); -extern float getAngle(int x1, int y1, int x2, int y2); -extern int getDistance(int x1, int y1, int x2, int y2); -extern float mod(float n, float x); -extern void runScriptFunction(char *format, ...); -extern Entity *spawnMine(int type); - -extern Battle battle; -extern Colors colors; -extern Dev dev; -extern Entity *player; -extern Entity *self; +void checkZackariaSuspicionLevel(void); +void checkSuspicionLevel(void); +void doAI(void); diff --git a/src/battle/battle.c b/src/battle/battle.c index c9f695d..cff1848 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,13 +18,55 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "battle.h" +#include "../json/cJSON.h" +#include "../game/credits.h" +#include "../battle/locations.h" +#include "../system/widgets.h" +#include "../galaxy/mission.h" +#include "../battle/bullets.h" +#include "../galaxy/galacticMap.h" +#include "../battle/effects.h" +#include "../system/draw.h" +#include "../battle/starfield.h" +#include "../battle/player.h" +#include "../system/sound.h" +#include "../battle/messageBox.h" +#include "../battle/spawners.h" +#include "../battle/waypoints.h" +#include "../battle/radar.h" +#include "../battle/objectives.h" +#include "../battle/script.h" +#include "../battle/quadtree.h" +#include "../challenges/challenges.h" +#include "../challenges/challengeHome.h" +#include "../system/modalDialog.h" +#include "../game/options.h" +#include "../battle/hud.h" +#include "../battle/missionInfo.h" +#include "../system/atlas.h" +#include "../system/input.h" +#include "../game/stats.h" +#include "../battle/debris.h" +#include "../game/trophies.h" +#include "../battle/entities.h" + +#define SHOW_BATTLE 0 +#define SHOW_MENU 1 +#define SHOW_OBJECTIVES 2 +#define SHOW_OPTIONS 3 + +extern App app; +extern Battle battle; +extern Dev dev; +extern Entity *player; +extern Game game; static void logic(void); static void draw(void); static void handleKeyboard(void); static void postBattle(void); -void destroyBattle(void); static void doBattle(void); static void optQuitBattle(void); static void quitBattle(void); diff --git a/src/battle/battle.h b/src/battle/battle.h index 7ccfdf6..fb62b60 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,80 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -#define SHOW_BATTLE 0 -#define SHOW_MENU 1 -#define SHOW_OBJECTIVES 2 -#define SHOW_OPTIONS 3 - -extern void awardTrophy(char *id); -extern void blitScaled(AtlasImage *atlasImage, int x, int y, int w, int h, int center); -extern void cancelScript(void); -extern void clearInput(void); -extern void destroyBullets(void); -extern void destroyDebris(void); -extern void destroyEffects(void); -extern void destroyEntities(void); -extern void destroyQuadtree(void); -extern void destroyScript(void); -extern void doBullets(void); -extern void doChallenges(void); -extern void doDebris(void); -extern void doEffects(void); -extern void doEntities(void); -extern void doHud(void); -extern void doLocations(void); -extern void doMessageBox(void); -extern void doObjectives(void); -extern void doPlayer(void); -extern void doPlayerSelect(void); -extern void doScript(void); -extern void doSpawners(void); -extern void doStars(float dx, float dy); -extern void doWidgets(void); -extern void drawBackground(SDL_Texture *texture); -extern void drawBullets(void); -extern void drawDebris(void); -extern void drawEffects(void); -extern void drawEntities(void); -extern void drawHud(void); -extern void drawLocations(void); -extern void drawMessageBox(void); -extern void drawMissionInfo(void); -extern void drawOptions(void); -extern void drawStars(void); -extern void drawWidgets(char *groupName); -extern Widget *getWidget(const char *name, const char *group); -extern void initBullets(void); -extern void initChallengeHome(void); -extern void initCredits(void); -extern void initDebris(void); -extern void initEffects(void); -extern void initEntities(void); -extern void initGalacticMap(void); -extern void initHud(void); -extern void initMessageBox(void); -extern void initOptions(void (*returnFromOptions)(void)); -extern void initQuadtree(Quadtree *root); -extern void initRadar(void); -extern void initStars(void); -extern void loadMission(char *filename); -extern void playSound(int id); -extern void resetHud(void); -extern void resetMessageBox(void); -extern void resetWaypoints(void); -extern void runScriptFunction(const char *format, ...); -extern void scrollBackground(float x, float y); -extern void selectWidget(const char *name, const char *group); -extern void setAtlasColor(int r, int g, int b, int a); -extern void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void), const char *format, ...); -extern void updateAccuracyStats(unsigned int *stats); - -extern App app; -extern Battle battle; -extern Dev dev; -extern Entity *player; -extern Game game; +void destroyBattle(void); +void initBattle(void); diff --git a/src/battle/bullets.c b/src/battle/bullets.c index c6b3bee..876b4a5 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "bullets.h" +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../system/atlas.h" +#include "../system/util.h" +#include "../battle/fighters.h" +#include "../battle/quadtree.h" +#include "../game/trophies.h" +#include "../battle/effects.h" +#include "../system/draw.h" +#include "../system/io.h" +#include "../system/sound.h" + +#define INITIAL_BULLET_DRAW_CAPACITY 32 +#define MISSILE_LIFE (FPS * 30) +#define TURN_SPEED 2 +#define TURN_THRESHOLD 3 + +extern App app; +extern Battle battle; +extern Entity *player; static void huntTarget(Bullet *b); static void checkCollisions(Bullet *b); diff --git a/src/battle/bullets.h b/src/battle/bullets.h index f403988..9f349b4 100644 --- a/src/battle/bullets.h +++ b/src/battle/bullets.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,37 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -#define INITIAL_BULLET_DRAW_CAPACITY 32 -#define MISSILE_LIFE (FPS * 30) -#define TURN_SPEED 2 -#define TURN_THRESHOLD 3 - -extern void addBulletHitEffect(int x, int y, int r, int g, int b); -extern void addMissileEngineEffect(Bullet *b); -extern void addMissileExplosion(Bullet *b); -extern void awardTrophy(char *id); -extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); -extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); -extern void damageFighter(Entity *e, int damage, long flags); -extern long flagsToLong(char *flags, int *add); -extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore); -extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore); -extern float getAngle(int x1, int y1, int x2, int y2); -extern AtlasImage *getAtlasImage(char *filename); -extern int getDistance(int x1, int y1, int x2, int y2); -extern int isOnBattleScreen(int x, int y, int w, int h); -extern long lookup(char *name); -extern float mod(float n, float x); -extern void playBattleSound(int id, int x, int y); -extern void playSound(int id); -extern char *readFile(char *filename); -extern void *resize(void *array, int oldSize, int newSize); -extern void setAtlasColor(int r, int g, int b, int a); - -extern App app; -extern Battle battle; -extern Entity *player; +void destroyBullets(void); +void destroyBulletDefs(void); +void fireMissile(Entity *owner); +void fireRocket(Entity *owner); +void fireGuns(Entity *owner); +void drawBullets(void); +void doBullets(void); +void initBulletDefs(void); +void initBullets(void); diff --git a/src/battle/capitalShips.c b/src/battle/capitalShips.c index 0ffa5da..ede8aa6 100644 --- a/src/battle/capitalShips.c +++ b/src/battle/capitalShips.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "capitalShips.h" +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../system/sound.h" +#include "../system/util.h" +#include "../battle/ai.h" +#include "../battle/fighters.h" +#include "../battle/quadtree.h" +#include "../battle/debris.h" +#include "../battle/messageBox.h" +#include "../battle/script.h" +#include "../battle/effects.h" +#include "../battle/objectives.h" +#include "../system/atlas.h" +#include "../system/io.h" +#include "../battle/entities.h" + +#define TURN_SPEED 0.1 +#define TURN_THRESHOLD 2 + +extern Battle battle; +extern Entity *player; +extern Entity *self; static int steer(void); static void think(void); diff --git a/src/battle/capitalShips.h b/src/battle/capitalShips.h index fdd8534..4c33a9a 100644 --- a/src/battle/capitalShips.h +++ b/src/battle/capitalShips.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,39 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include "../common.h" - -#include "../json/cJSON.h" - -#define TURN_SPEED 0.1 -#define TURN_THRESHOLD 2 - -extern void addDebris(int x, int y, int amount); -extern void addLargeEngineEffect(void); -extern void addLargeExplosion(void); -extern void addMessageBox(char *title, char *body, int type); -extern void addSmallExplosion(void); -extern void applyFighterThrust(void); -extern void doAI(void); -extern long flagsToLong(char *flags, int *add); -extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore); -extern float getAngle(int x1, int y1, int x2, int y2); -extern AtlasImage *getAtlasImage(char *filename); -extern int getDistance(int x1, int y1, int x2, int y2); -extern char **getFileList(char *dir, int *count); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern char *getJSONValueStr(cJSON *node, char *name, char *defValue); -extern long lookup(char *name); -extern float mod(float n, float x); -extern void playBattleSound(int id, int x, int y); -extern char *readFile(char *filename); -extern void runScriptFunction(char *format, ...); -extern Entity *spawnEntity(void); -extern char **toTypeArray(char *types, int *numTypes); -extern void updateCondition(char *name, int type); -extern void updateObjective(char *name, int type); - -extern Battle battle; -extern Entity *player; -extern Entity *self; +void destroyCapitalShipDefs(void); +void loadCapitalShips(struct cJSON *node); +void updateCapitalShipComponentProperties(Entity *parent, long flags); +void loadCapitalShipDefs(void); +void doCapitalShip(void); +Entity *spawnCapitalShip(char *name, int x, int y, int side); diff --git a/src/battle/debris.c b/src/battle/debris.c index 03252d6..c53e40e 100644 --- a/src/battle/debris.c +++ b/src/battle/debris.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "debris.h" +#include "../json/cJSON.h" +#include "../system/atlas.h" +#include "../system/draw.h" +#include "../system/util.h" +#include "../battle/effects.h" + +#define INITIAL_DEBRIS_DRAW_CAPACITY 32 +#define MAX_DEBRIS_TEXTURES 6 + +extern Battle battle; static void changeCourse(Debris *d); static void resizeDrawList(void); diff --git a/src/battle/debris.h b/src/battle/debris.h index 61526cd..cfa7f54 100644 --- a/src/battle/debris.h +++ b/src/battle/debris.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,18 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -#define INITIAL_DEBRIS_DRAW_CAPACITY 32 -#define MAX_DEBRIS_TEXTURES 6 - -extern void addDebrisFire(int x, int y); -extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); -extern AtlasImage *getAtlasImage(char *filename); -extern int isOnBattleScreen(int x, int y, int w, int h); -extern float mod(float n, float x); -extern void *resize(void *array, int oldSize, int newSize); - -extern Battle battle; +void destroyDebris(void); +void drawDebris(void); +void doDebris(void); +void addDebris(int x, int y, int amount); +void initDebris(void); diff --git a/src/battle/effects.c b/src/battle/effects.c index ed7ff53..f419c02 100644 --- a/src/battle/effects.c +++ b/src/battle/effects.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "effects.h" +#include "../system/atlas.h" +#include "../system/draw.h" +#include "../system/util.h" + +#define INITIAL_EFFECT_DRAW_CAPACITY 128 + +extern App app; +extern Battle battle; +extern Entity *self; static void setRandomFlameHue(Effect *e); static void setRandomShieldHue(Effect *e); diff --git a/src/battle/effects.h b/src/battle/effects.h index 3a7309a..c0294b4 100644 --- a/src/battle/effects.h +++ b/src/battle/effects.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,17 +18,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define INITIAL_EFFECT_DRAW_CAPACITY 128 - -extern void blitScaled(AtlasImage *atlasImage, int x, int y, int w, int h, int center); -extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); -extern AtlasImage *getAtlasImage(char *name); -extern int isOnBattleScreen(int x, int y, int w, int h); -extern void *resize(void *array, int oldSize, int newSize); -extern void setAtlasColor(int r, int g, int b, int a); - -extern App app; -extern Battle battle; -extern Entity *self; +void destroyEffects(void); +void addECMEffect(Entity *ent); +void addShieldSplinterEffect(Entity *ent); +void addMissileEngineEffect(Bullet *b); +void addLargeEngineEffect(void); +void addEngineEffect(void); +void addMissileExplosion(Bullet *b); +void addLargeExplosion(void); +void addMineExplosion(void); +void addSmallExplosion(void); +void addDebrisFire(int x, int y); +void addSmallFighterExplosion(void); +void addBulletHitEffect(int x, int y, int r, int g, int b); +void drawShieldHitEffect(Entity *e); +void drawEffects(void); +void doEffects(void); +void initEffects(void); diff --git a/src/battle/entities.c b/src/battle/entities.c index f04ae0b..bed31d1 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "entities.h" +#include "../system/lookup.h" +#include "../battle/capitalShips.h" +#include "../battle/fighters.h" +#include "../battle/quadtree.h" +#include "../battle/rope.h" +#include "../system/atlas.h" +#include "../game/trophies.h" +#include "../battle/effects.h" +#include "../system/draw.h" + +#define DISABLED_GLOW_MAX 255 +#define DISABLED_GLOW_MIN 128 +#define DISABLED_GLOW_SPEED 3 + +extern App app; +extern Battle battle; +extern Dev dev; +extern Entity *player; +extern Entity *self; static void drawEntity(Entity *e); static void doEntity(void); diff --git a/src/battle/entities.h b/src/battle/entities.h index 03ffce1..cfdabf4 100644 --- a/src/battle/entities.h +++ b/src/battle/entities.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,31 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define DISABLED_GLOW_MAX 255 -#define DISABLED_GLOW_MIN 128 -#define DISABLED_GLOW_SPEED 3 - -extern void addToQuadtree(Entity *e, Quadtree *root); -extern void awardTrophy(char *id); -extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); -extern void cutRope(Entity *e); -extern void doCapitalShip(void); -extern void doFighter(void); -extern void doRope(Entity *e); -extern void drawRope(Entity *e); -extern void drawShieldHitEffect(Entity *e); -extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore); -extern int isOnBattleScreen(int x, int y, int w, int h); -extern long lookup(char *name); -extern void removeFromQuadtree(Entity *e, Quadtree *root); -extern void resetFighter(Entity *e); -extern void setAtlasColor(int r, int g, int b, int a); -extern void updateCapitalShipComponentProperties(Entity *parent, long flags); - -extern App app; -extern Battle battle; -extern Dev dev; -extern Entity *player; -extern Entity *self; +void destroyEntities(void); +void awardPandoranCraftTrophy(void); +void updateEntitySide(char *sideStr, char *name); +void killEntity(char *name); +void addAllToQuadtree(void); +void countNumEnemies(void); +void activateEntityGroups(char *groupNames); +void activateEntities(char *names); +void drawEntities(void); +void doEntities(void); +Entity *spawnEntity(void); +void initEntities(void); diff --git a/src/battle/fighters.c b/src/battle/fighters.c index 8bac2e5..626403b 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "fighters.h" +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../system/atlas.h" +#include "../system/util.h" +#include "../battle/ai.h" +#include "../battle/quadtree.h" +#include "../battle/debris.h" +#include "../battle/rope.h" +#include "../galaxy/mission.h" +#include "../battle/hud.h" +#include "../battle/objectives.h" +#include "../battle/script.h" +#include "../battle/effects.h" +#include "../battle/items.h" +#include "../system/io.h" +#include "../system/sound.h" +#include "../battle/entities.h" + +extern Battle battle; +extern Colors colors; +extern Entity *player; +extern Entity *self; +extern Game game; static void separate(void); static void die(void); @@ -172,7 +196,6 @@ static void randomizeDartGuns(Entity *dart) dart->guns[2].y = -10; break; - /* Plasma / Laser cannons */ case 3: dart->guns[0].type = BT_PLASMA; diff --git a/src/battle/fighters.h b/src/battle/fighters.h index 9763e13..9b38918 100644 --- a/src/battle/fighters.h +++ b/src/battle/fighters.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,42 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern void addDebris(int x, int y, int amount); -extern void addEngineEffect(void); -extern void addHudMessage(SDL_Color c, char *format, ...); -extern void addRandomItem(int x, int y); -extern void addShieldSplinterEffect(Entity *ent); -extern void addSmallExplosion(void); -extern void addSmallFighterExplosion(void); -extern void adjustObjectiveTargetValue(char *name, int type, int amount); -extern void attachRope(void); -extern void checkSuspicionLevel(void); -extern void checkZackariaSuspicionLevel(void); -extern void completeMission(void); -extern void doAI(void); -extern long flagsToLong(char *flags, int *add); -extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore); -extern float getAngle(int x1, int y1, int x2, int y2); -extern AtlasImage *getAtlasImage(char *filename); -extern int getDistance(int x1, int y1, int x2, int y2); -extern char **getFileList(char *dir, int *count); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern char *getJSONValueStr(cJSON *node, char *name, char *defValue); -extern long lookup(char *name); -extern void playBattleSound(int id, int x, int y); -extern char *readFile(char *filename); -extern void runScriptFunction(char *format, ...); -extern Entity *spawnEntity(void); -extern char **toTypeArray(char *types, int *numTypes); -extern void updateCondition(char *name, int type); -extern void updateObjective(char *name, int type); - -extern Battle battle; -extern Colors colors; -extern Entity *player; -extern Entity *self; -extern Game game; +void destroyFighterStats(void); +void destroyFighterDefs(void); +void loadFighters(struct cJSON *node); +void loadFighterDefs(void); +Entity **getDBFighters(int *num); +void retreatAllies(void); +void retreatEnemies(void); +void damageFighter(Entity *e, int amount, long flags); +void applyFighterBrakes(void); +void applyFighterThrust(void); +void doFighter(void); +void resetFighter(Entity *fighter); +Entity *spawnFighter(char *name, int x, int y, int side); diff --git a/src/battle/hud.c b/src/battle/hud.c index 49752a5..2664478 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "hud.h" +#include "../system/atlas.h" +#include "../system/util.h" +#include "../battle/player.h" +#include "../system/text.h" +#include "../battle/radar.h" +#include "../system/draw.h" +#include "../battle/jumpgate.h" + +#define MAX_HUD_MESSAGES 6 + +extern App app; +extern Battle battle; +extern Colors colors; +extern Entity *player; +extern Game game; static void drawPlayerTargeter(void); static void drawNumFighters(void); diff --git a/src/battle/hud.h b/src/battle/hud.h index c513db0..d7a757d 100644 --- a/src/battle/hud.h +++ b/src/battle/hud.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,26 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define MAX_HUD_MESSAGES 6 - -extern void blit(AtlasImage *atlasImage, int x, int y, int center); -extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); -extern void drawRadar(void); -extern void drawRadarRangeWarning(void); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern float getAngle(int x1, int y1, int x2, int y2); -extern AtlasImage *getAtlasImage(char *filename); -extern int getDistance(int x1, int y1, int x2, int y2); -extern int getPercent(float current, float total); -extern int jumpgateEnabled(void); -extern int playerHasGun(int type); -extern void setAtlasColor(int r, int g, int b, int a); -extern char *timeToString(long millis, int showHours); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Entity *player; -extern Game game; +void resetHud(void); +void drawHud(void); +void addHudMessage(SDL_Color c, char *format, ...); +void doHud(void); +void initHud(void); diff --git a/src/battle/items.c b/src/battle/items.c index e25dd44..96854a2 100644 --- a/src/battle/items.c +++ b/src/battle/items.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "items.h" +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../system/sound.h" +#include "../system/util.h" +#include "../battle/quadtree.h" +#include "../battle/hud.h" +#include "../battle/objectives.h" +#include "../system/io.h" +#include "../system/atlas.h" +#include "../battle/entities.h" + +extern Battle battle; +extern Colors colors; +extern Entity *player; +extern Entity *self; static void action(void); static Entity *getItemDef(char *name); diff --git a/src/battle/items.h b/src/battle/items.h index 830fcae..dcf9846 100644 --- a/src/battle/items.h +++ b/src/battle/items.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,23 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern void addHudMessage(SDL_Color c, char *format, ...); -extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); -extern long flagsToLong(char *flags, int *add); -extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore); -extern AtlasImage *getAtlasImage(char *filename); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern char *getJSONValueStr(cJSON *node, char *name, char *defValue); -extern void playBattleSound(int id, int x, int y); -extern char *readFile(char *filename); -extern Entity *spawnEntity(void); -extern void updateObjective(char *name, int type); - -extern Battle battle; -extern Colors colors; -extern Entity *player; -extern Entity *self; +void destroyItemDefs(void); +void loadItems(struct cJSON *node); +void addRandomItem(int x, int y); +Entity *spawnItem(char *name); +void loadItemDefs(void); diff --git a/src/battle/jumpgate.c b/src/battle/jumpgate.c index f9195b9..75d4eaf 100644 --- a/src/battle/jumpgate.c +++ b/src/battle/jumpgate.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "jumpgate.h" +#include "../system/draw.h" +#include "../system/util.h" +#include "../battle/quadtree.h" +#include "../battle/debris.h" +#include "../battle/objectives.h" +#include "../battle/script.h" +#include "../battle/effects.h" +#include "../system/atlas.h" +#include "../system/sound.h" +#include "../battle/entities.h" + +#define ESCAPE_DISTANCE 256 + +extern Battle battle; +extern Entity *self; static void think(void); static void draw(void); diff --git a/src/battle/jumpgate.h b/src/battle/jumpgate.h index b2e966f..4cd6937 100644 --- a/src/battle/jumpgate.h +++ b/src/battle/jumpgate.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,21 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define ESCAPE_DISTANCE 256 - -extern void addDebris(int x, int y, int amount); -extern void addSmallExplosion(void); -extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); -extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore); -extern AtlasImage *getAtlasImage(char *filename); -extern int getDistance(int x1, int y1, int x2, int y2); -extern void playBattleSound(int id, int x, int y); -extern void runScriptFunction(char *format, ...); -extern Entity *spawnEntity(void); -extern void updateCondition(char *name, int type); -extern void updateObjective(char *name, int type); - -extern Battle battle; -extern Entity *self; +void activateJumpgate(int activate); +int jumpgateEnabled(void); +Entity *spawnJumpgate(int side, long flags); diff --git a/src/battle/locations.c b/src/battle/locations.c index f0fe64a..4f6680b 100644 --- a/src/battle/locations.c +++ b/src/battle/locations.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "locations.h" +#include "../json/cJSON.h" +#include "../system/draw.h" +#include "../system/util.h" +#include "../battle/script.h" + +extern Battle battle; +extern Entity *player; void doLocations(void) { @@ -131,7 +139,6 @@ void loadLocations(cJSON *node) l->x += (SCREEN_WIDTH / 2); l->y += (SCREEN_HEIGHT / 2); - node = node->next; } } diff --git a/src/battle/locations.h b/src/battle/locations.h index 4817922..162b6fa 100644 --- a/src/battle/locations.h +++ b/src/battle/locations.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,14 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a); -extern int getDistance(int x1, int y1, int x2, int y2); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern void runScriptFunction(char *format, ...); - -extern Battle battle; -extern Entity *player; +void loadLocations(struct cJSON *node); +void createChristabelLocation(void); +void activateLocations(char *locations); +void drawLocations(void); +void doLocations(void); diff --git a/src/battle/messageBox.c b/src/battle/messageBox.c index 0648fbb..0976144 100644 --- a/src/battle/messageBox.c +++ b/src/battle/messageBox.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "messageBox.h" +#include "../system/text.h" +#include "../system/sound.h" + +#define MSG_BOX_TEXT_WIDTH 600 + +extern App app; +extern Battle battle; +extern Colors colors; +extern Entity *player; static void calculateMessageBoxHeight(MessageBox *msg); static void nextMessage(void); diff --git a/src/battle/messageBox.h b/src/battle/messageBox.h index 3815ea8..d5cbdcf 100644 --- a/src/battle/messageBox.h +++ b/src/battle/messageBox.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,16 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define MSG_BOX_TEXT_WIDTH 600 - -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern int getWrappedTextHeight(char *text, int size); -extern void playSound(int sound); -extern void useFont(char *name); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Entity *player; +void resetMessageBox(void); +void drawMessageBox(void); +int showingMessageBoxes(void); +void doMessageBox(void); +void addMessageBox(char *title, char *body, int type); +void initMessageBox(void); diff --git a/src/battle/mine.c b/src/battle/mine.c index 0fcda79..b64df6f 100644 --- a/src/battle/mine.c +++ b/src/battle/mine.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,26 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "mine.h" +#include "../system/sound.h" +#include "../system/util.h" +#include "../battle/fighters.h" +#include "../battle/quadtree.h" +#include "../game/trophies.h" +#include "../battle/objectives.h" +#include "../battle/script.h" +#include "../battle/effects.h" +#include "../system/atlas.h" +#include "../battle/entities.h" + +#define DAMAGE_RANGE 250 +#define SYSTEM_POWER 50 +#define TRIGGER_RANGE 150 + +extern Battle battle; +extern Entity *player; +extern Entity *self; static void think(void); static void die(void); diff --git a/src/battle/mine.h b/src/battle/mine.h index d88306d..30a5529 100644 --- a/src/battle/mine.h +++ b/src/battle/mine.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,23 +18,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define DAMAGE_RANGE 250 -#define SYSTEM_POWER 50 -#define TRIGGER_RANGE 150 - -extern void addMineExplosion(void); -extern void awardTrophy(char *id); -extern void damageFighter(Entity *e, int amount, long flags); -extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore); -extern AtlasImage *getAtlasImage(char *filename); -extern int getDistance(int x1, int y1, int x2, int y2); -extern void playBattleSound(int id, int x, int y); -extern void runScriptFunction(const char *format, ...); -extern Entity *spawnEntity(void); -extern void updateObjective(char *name, int type); - -extern Battle battle; -extern Entity *player; -extern Entity *self; +Entity *spawnMine(int type); diff --git a/src/battle/missionInfo.c b/src/battle/missionInfo.c index 71e60f2..16a0675 100644 --- a/src/battle/missionInfo.c +++ b/src/battle/missionInfo.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "missionInfo.h" +#include "../system/draw.h" +#include "../system/util.h" +#include "../challenges/challenges.h" +#include "../system/widgets.h" +#include "../system/text.h" +#include "../system/atlas.h" + +extern App app; +extern Battle battle; +extern Colors colors; +extern Game game; static void drawMissionSummary(AtlasImage *title); static void drawObjectives(void); @@ -224,4 +236,3 @@ static void drawChallenges(void) } } } - diff --git a/src/battle/missionInfo.h b/src/battle/missionInfo.h index 22af64e..b989a1a 100644 --- a/src/battle/missionInfo.h +++ b/src/battle/missionInfo.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,17 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern void blit(AtlasImage *atlasImage, int x, int y, int center); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawWidgets(char *groupName); -extern AtlasImage *getAtlasImage(char *filename); -extern char *getChallengeDescription(Challenge *c); -extern void setAtlasColor(int r, int g, int b, int a); -extern char *timeToString(long millis, int showHours); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Game game; +void drawMissionInfo(void); +void initMissionInfo(void); diff --git a/src/battle/objectives.c b/src/battle/objectives.c index c628656..94a0066 100644 --- a/src/battle/objectives.c +++ b/src/battle/objectives.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "objectives.h" +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../system/util.h" +#include "../system/sound.h" +#include "../galaxy/mission.h" +#include "../battle/hud.h" +#include "../battle/script.h" + +extern Battle battle; +extern Colors colors; static int fireObjectivesComplete; @@ -238,7 +249,6 @@ void completeConditions(void) } } - void failIncompleteObjectives(void) { Objective *o; diff --git a/src/battle/objectives.h b/src/battle/objectives.h index 2cfd89f..d0afb71 100644 --- a/src/battle/objectives.h +++ b/src/battle/objectives.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,16 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" -#include "../json/cJSON.h" - -extern void addHudMessage(SDL_Color c, char *format, ...); -extern void completeMission(void); -extern void failMission(void); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern long lookup(char *name); -extern void playSound(int id); -extern void runScriptFunction(char *format, ...); - -extern Battle battle; -extern Colors colors; +void addEpicKillsObjective(void); +void addEpicLivesObjective(void); +void loadObjectives(struct cJSON *node); +void activateObjectives(char *objectives); +void failIncompleteObjectives(void); +void completeConditions(void); +void completeAllObjectives(void); +void updateCondition(char *name, int type); +void adjustObjectiveTargetValue(char *name, int type, int amount); +void updateObjective(char *name, int type); +void doObjectives(void); diff --git a/src/battle/player.c b/src/battle/player.c index b4d8b78..68a7c00 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "player.h" +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../system/util.h" +#include "../system/controls.h" +#include "../battle/fighters.h" +#include "../system/sound.h" +#include "../galaxy/mission.h" +#include "../game/trophies.h" +#include "../battle/hud.h" +#include "../battle/objectives.h" +#include "../battle/bullets.h" +#include "../battle/effects.h" + +#define MAX_SELECTABLE_PLAYERS 8 +#define MAX_SELECTABLE_TARGETS 8 + +extern App app; +extern Battle battle; +extern Colors colors; +extern Dev dev; +extern Entity *player; +extern Entity *self; +extern Game game; static void selectTarget(void); static void switchGuns(void); diff --git a/src/battle/player.h b/src/battle/player.h index 22bf895..32e0631 100644 --- a/src/battle/player.h +++ b/src/battle/player.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,39 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" -#include "../json/cJSON.h" - -#define MAX_SELECTABLE_PLAYERS 8 -#define MAX_SELECTABLE_TARGETS 8 - -extern void addECMEffect(Entity *ent); -extern void addHudMessage(SDL_Color c, char *format, ...); -extern void applyFighterBrakes(void); -extern void applyFighterThrust(void); -extern void awardTrophy(char *id); -extern void clearControl(int type); -extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); -extern void failMission(void); -extern void fireGuns(Entity *owner); -extern void fireMissile(Entity *owner); -extern void fireRocket(Entity *owner); -extern long flagsToLong(char *flags, int *add); -extern float getAngle(int x1, int y1, int x2, int y2); -extern int getDistance(int x1, int y1, int x2, int y2); -extern int isAcceptControl(void); -extern int isControl(int type); -extern long lookup(char *name); -extern float mod(float n, float x); -extern void playSound(int id); -extern void resetAcceptControls(void); -extern Entity *spawnFighter(char *name, int x, int y, int side); -extern void updateCondition(char *name, int type); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Dev dev; -extern Entity *player; -extern Entity *self; -extern Game game; +void loadPlayer(struct cJSON *node); +int playerHasGun(int type); +void setInitialPlayerAngle(void); +void doPlayerSelect(void); +void doPlayer(void); +void initPlayer(void); diff --git a/src/battle/quadtree.c b/src/battle/quadtree.c index 605175c..e5621e2 100644 --- a/src/battle/quadtree.c +++ b/src/battle/quadtree.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "quadtree.h" +#include "../system/util.h" + +#define QT_INITIAL_CAPACITY 8 +#define QT_MAX_DEPTH 5 + +extern Battle battle; static Entity **candidates; static int cIndex; diff --git a/src/battle/quadtree.h b/src/battle/quadtree.h index ffc108e..4689490 100644 --- a/src/battle/quadtree.h +++ b/src/battle/quadtree.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,11 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define QT_INITIAL_CAPACITY 8 -#define QT_MAX_DEPTH 5 - -extern void *resize(void *array, int oldSize, int newSize); - -extern Battle battle; +void destroyQuadtree(void); +Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore); +Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore); +void removeFromQuadtree(Entity *e, Quadtree *root); +void addToQuadtree(Entity *e, Quadtree *root); +void initQuadtree(Quadtree *root); diff --git a/src/battle/radar.c b/src/battle/radar.c index 96f9f11..48bb07c 100644 --- a/src/battle/radar.c +++ b/src/battle/radar.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "radar.h" +#include "../system/text.h" +#include "../system/atlas.h" +#include "../system/draw.h" +#include "../system/util.h" + +extern App app; +extern Battle battle; +extern Colors colors; +extern Entity *player; static AtlasImage *radarTexture; static AtlasImage *radarWarningTexture; diff --git a/src/battle/radar.h b/src/battle/radar.h index 6ff0522..fabaa8f 100644 --- a/src/battle/radar.h +++ b/src/battle/radar.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,15 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern void blit(AtlasImage *atlasImage, int x, int y, int center); -extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern AtlasImage *getAtlasImage(char *filename); -extern int getDistance(int x1, int y1, int x2, int y2); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Entity *player; +void drawRadarRangeWarning(void); +void drawRadar(void); +void initRadar(void); diff --git a/src/battle/rope.c b/src/battle/rope.c index 02d2853..28088fa 100644 --- a/src/battle/rope.c +++ b/src/battle/rope.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "rope.h" +#include "../battle/hud.h" +#include "../battle/quadtree.h" +#include "../system/util.h" +#include "../system/sound.h" +#include "../battle/script.h" + +#define ROPE_DISTANCE 128 + +extern App app; +extern Battle battle; +extern Colors colors; +extern Entity *player; +extern Entity *self; void attachRope(void) { diff --git a/src/battle/rope.h b/src/battle/rope.h index 5db16fb..b974de7 100644 --- a/src/battle/rope.h +++ b/src/battle/rope.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,19 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define ROPE_DISTANCE 128 - -extern void addHudMessage(SDL_Color c, char *format, ...); -extern Entity **getAllEntsInRadius(int x, int y, int radius, Entity *ignore); -extern float getAngle(int x1, int y1, int x2, int y2); -extern int getDistance(int x1, int y1, int x2, int y2); -extern void playBattleSound(int id, int x, int y); -extern void runScriptFunction(char *format, ...); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Entity *player; -extern Entity *self; +void cutRope(Entity *e); +void drawRope(Entity *e); +void doRope(Entity *owner); +void attachRope(void); diff --git a/src/battle/script.c b/src/battle/script.c index 9658b27..e445d15 100644 --- a/src/battle/script.c +++ b/src/battle/script.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,10 +18,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "script.h" +#include "../json/cJSON.h" +#include "../battle/locations.h" +#include "../battle/fighters.h" +#include "../galaxy/mission.h" +#include "../battle/hud.h" +#include "../battle/objectives.h" +#include "../battle/spawners.h" +#include "../battle/waypoints.h" +#include "../battle/messageBox.h" +#include "../battle/entities.h" +#include "../battle/jumpgate.h" + +extern Battle battle; +extern Colors colors; static void executeNextLine(ScriptRunner *runner); -void destroyScript(void); static cJSON *scriptJSON, *rootJSON; static ScriptRunner head; diff --git a/src/battle/script.h b/src/battle/script.h index 70ee50c..43fc257 100644 --- a/src/battle/script.h +++ b/src/battle/script.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,29 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern void activateEntities(char *name); -extern void activateEntityGroups(char *groupName); -extern void activateJumpgate(int activate); -extern void activateLocations(char *locations); -extern void activateNextWaypoint(void); -extern void activateObjectives(char *objectives); -extern void activateSpawner(char *name, int active); -extern void activateTrespasserSpawner(void); -extern void addHudMessage(SDL_Color c, char *format, ...); -extern void addMessageBox(char *title, char *body, int type); -extern void completeAllObjectives(void); -extern void completeMission(void); -extern void createChristabelLocation(void); -extern void failMission(void); -extern void killEntity(char *name); -extern void retreatAllies(void); -extern void retreatEnemies(void); -extern int showingMessageBoxes(void); -extern void updateEntitySide(char *side, char *entity); - -extern Battle battle; -extern Colors colors; +void destroyScript(void); +void cancelScript(void); +void runScriptFunction(const char *format, ...); +void doScript(void); +void initScript(struct cJSON *root); diff --git a/src/battle/spawners.c b/src/battle/spawners.c index 758cf4d..ef30868 100644 --- a/src/battle/spawners.c +++ b/src/battle/spawners.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "spawners.h" +#include "../json/cJSON.h" +#include "../battle/fighters.h" +#include "../system/lookup.h" +#include "../system/util.h" + +extern Battle battle; +extern Entity *player; void doSpawners(void) { diff --git a/src/battle/spawners.h b/src/battle/spawners.h index d48edd3..601b5d1 100644 --- a/src/battle/spawners.h +++ b/src/battle/spawners.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,16 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern long flagsToLong(char *flags, int *add); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern char *getJSONValueStr(cJSON *node, char *name, char *defValue); -extern long lookup(char *name); -extern Entity *spawnFighter(char *name, int x, int y, int side); -extern char **toTypeArray(char *types, int *numTypes); - -extern Battle battle; -extern Entity *player; +void loadSpawners(struct cJSON *node); +void activateTrespasserSpawner(void); +void activateSpawner(char *name, int active); +void doSpawners(void); diff --git a/src/battle/starfield.c b/src/battle/starfield.c index 961c17a..1a81190 100644 --- a/src/battle/starfield.c +++ b/src/battle/starfield.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "starfield.h" +#include "../system/util.h" + +extern App app; static Star stars[MAX_STARS]; diff --git a/src/battle/starfield.h b/src/battle/starfield.h index f09db17..c7dab03 100644 --- a/src/battle/starfield.h +++ b/src/battle/starfield.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,8 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern float mod(float n, float x); - -extern App app; +void drawStars(void); +void doStars(float dx, float dy); +void initStars(void); diff --git a/src/battle/waypoints.c b/src/battle/waypoints.c index e30dc56..26344f1 100644 --- a/src/battle/waypoints.c +++ b/src/battle/waypoints.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,12 +18,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "waypoints.h" +#include "../system/util.h" +#include "../system/sound.h" +#include "../battle/hud.h" +#include "../battle/objectives.h" +#include "../battle/script.h" +#include "../system/atlas.h" +#include "../battle/entities.h" + +extern Battle battle; +extern Colors colors; +extern Entity *player; +extern Entity *self; +extern Game game; static void think(void); static int teamMatesClose(void); static int isCurrentObjective(void); -void activateNextWaypoint(void); static int waypointId; static int currentWaypointId; diff --git a/src/battle/waypoints.h b/src/battle/waypoints.h index f62c883..05c6f5a 100644 --- a/src/battle/waypoints.h +++ b/src/battle/waypoints.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,18 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern void addHudMessage(SDL_Color c, char *format, ...); -extern AtlasImage *getAtlasImage(char *filename); -extern int getDistance(int x1, int y1, int x2, int y2); -extern void playSound(int id); -extern void runScriptFunction(char *format, ...); -extern Entity *spawnEntity(void); -extern void updateObjective(char *name, int type); - -extern Battle battle; -extern Colors colors; -extern Entity *player; -extern Entity *self; -extern Game game; +void activateNextWaypoint(void); +Entity *spawnWaypoint(void); +void resetWaypoints(void); diff --git a/src/challenges/challengeHome.c b/src/challenges/challengeHome.c index 045ebab..92688b7 100644 --- a/src/challenges/challengeHome.c +++ b/src/challenges/challengeHome.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,13 +18,47 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "challengeHome.h" +#include "../battle/starfield.h" +#include "../system/util.h" +#include "../system/input.h" +#include "../game/title.h" +#include "../game/stats.h" +#include "../system/sound.h" +#include "../system/widgets.h" +#include "../galaxy/mission.h" +#include "../game/trophies.h" +#include "../game/options.h" +#include "../system/atlas.h" +#include "../game/fighterDatabase.h" +#include "../system/transition.h" +#include "../challenges/challenges.h" +#include "../system/text.h" +#include "../system/draw.h" +#include "../battle/battle.h" +#include "../system/resources.h" +#include "../system/textures.h" + +#define CHALLENGES_PER_PAGE 14 +#define SHOW_CHALLENGES 0 +#define SHOW_FIGHTER_DB 5 +#define SHOW_MENU 1 +#define SHOW_OPTIONS 2 +#define SHOW_STATS 3 +#define SHOW_TROPHIES 4 + +extern App app; +extern Battle battle; +extern Colors colors; +extern Dev dev; +extern Game game; static void logic(void); static void draw(void); static void handleKeyboard(void); static void drawChallenges(void); -static void doChallenges(void); +static void doChallengeList(void); static void startChallengeMission(void); static void drawMenu(void); static void resume(void); @@ -209,7 +243,7 @@ static void logic(void) switch (show) { case SHOW_CHALLENGES: - doChallenges(); + doChallengeList(); break; case SHOW_MENU: @@ -232,7 +266,7 @@ static void logic(void) app.doTrophyAlerts = 1; } -static void doChallenges(void) +static void doChallengeList(void) { Mission *c; int i, startIndex, end; diff --git a/src/challenges/challengeHome.h b/src/challenges/challengeHome.h index 29cb5e4..8a80aa6 100644 --- a/src/challenges/challengeHome.h +++ b/src/challenges/challengeHome.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,58 +18,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define CHALLENGES_PER_PAGE 14 -#define SHOW_CHALLENGES 0 -#define SHOW_FIGHTER_DB 5 -#define SHOW_MENU 1 -#define SHOW_OPTIONS 2 -#define SHOW_STATS 3 -#define SHOW_TROPHIES 4 - -extern void autoSizeWidgetButtons(char *group, int recenter); -extern void awardChallengeTrophies(void); -extern void awardStatsTrophies(void); -extern void blit(AtlasImage *atlasImage, int x, int y, int centered); -extern void clearInput(void); -extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); -extern void doFighterDatabase(void); -extern void doStars(float dx, float dy); -extern void doWidgets(void); -extern void drawBackground(SDL_Texture *texture); -extern void drawFighterDatabase(void); -extern void drawOptions(void); -extern void drawStars(void); -extern void drawStats(void); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawTrophies(void); -extern void drawWidgets(char *groupName); -extern void endSectionTransition(void); -extern AtlasImage *getAtlasImage(const char *filename); -extern char *getBackgroundTextureName(int n); -extern char *getChallengeDescription(Challenge *c); -extern char *getPlanetTextureName(int n); -extern SDL_Texture *getTexture(char *filename); -extern Widget *getWidget(const char *name, const char *group); -extern void initBattle(void); -extern void initFighterDatabaseDisplay(void); -extern void initOptions(void (*returnFromOptions)(void)); -extern void initStatsDisplay(void); -extern void initTitle(void); -extern void initTrophiesDisplay(void); -extern void loadMission(char *filename); -extern void playMusic(char *filename, int loop); -extern void playSound(int sound); -extern void scrollBackground(float x, float y); -extern void selectWidget(const char *name, const char *group); -extern void startSectionTransition(void); -extern void stopMusic(void); -extern char *timeToString(long millis, int showHours); -extern void updateAllMissions(void); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Dev dev; -extern Game game; +void initChallengeHome(void); diff --git a/src/challenges/challenges.c b/src/challenges/challenges.c index 9be3a79..466506f 100644 --- a/src/challenges/challenges.c +++ b/src/challenges/challenges.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "challenges.h" +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../system/util.h" +#include "../battle/fighters.h" +#include "../system/widgets.h" +#include "../galaxy/mission.h" +#include "../game/trophies.h" +#include "../game/stats.h" +#include "../system/io.h" + +extern Battle battle; +extern Dev dev; +extern Entity *player; +extern Game game; static void updateTimeChallenge(Challenge *c); static void updateSurvivalChallenge(Challenge *c); @@ -35,7 +50,6 @@ static void completeChallenge(void); static void failChallenge(void); static int updateChallenges(void); static char *getFormattedChallengeDescription(const char *format, ...); -char *getChallengeDescription(Challenge *c); static int challengeFinished(void); static int alreadyPassed(void); static void printStats(void); diff --git a/src/challenges/challenges.h b/src/challenges/challenges.h index d3e9985..788e8ef 100644 --- a/src/challenges/challenges.h +++ b/src/challenges/challenges.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,23 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" -#include "../json/cJSON.h" - -extern void awardCraftTrophy(void); -extern void awardStatsTrophies(void); -extern char **getFileList(char *dir, int *count); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern char *getLookupName(char *prefix, long num); -extern Mission *loadMissionMeta(char *filename); -extern long lookup(char *name); -extern void retreatAllies(void); -extern void retreatEnemies(void); -extern void selectWidget(const char *name, const char *group); -extern char *timeToString(long millis, int showHours); -extern void updateAccuracyStats(unsigned int *stats); - -extern Battle battle; -extern Dev dev; -extern Entity *player; -extern Game game; +void updateChallengeMissions(void); +Challenge *getChallenge(Mission *mission, int type, int value); +char *getChallengeDescription(Challenge *c); +void doChallenges(void); +void loadChallenge(Mission *mission, struct cJSON *node); +void initChallenges(void); diff --git a/src/common.h b/src/common.h index 1372816..16fe61c 100644 --- a/src/common.h +++ b/src/common.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/defs.h b/src/defs.h index 03ab380..ccc5d3d 100644 --- a/src/defs.h +++ b/src/defs.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index d216dde..26f1fb9 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,40 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "galacticMap.h" +#include "../battle/starfield.h" +#include "../system/util.h" +#include "../system/input.h" +#include "../game/title.h" +#include "../game/stats.h" +#include "../system/widgets.h" +#include "../galaxy/mission.h" +#include "../game/trophies.h" +#include "../system/modalDialog.h" +#include "../game/options.h" +#include "../system/atlas.h" +#include "../game/fighterDatabase.h" +#include "../system/transition.h" +#include "../system/text.h" +#include "../galaxy/starSystems.h" +#include "../system/draw.h" +#include "../battle/battle.h" +#include "../system/sound.h" +#include "../system/textures.h" + +#define MAX_LISTED_MISSIONS 9 +#define SHOW_FIGHTER_DB 6 +#define SHOW_GALAXY 0 +#define SHOW_MENU 2 +#define SHOW_OPTIONS 3 +#define SHOW_STAR_SYSTEM 1 +#define SHOW_STATS 4 +#define SHOW_TROPHIES 5 + +extern App app; +extern Colors colors; +extern Game game; static void logic(void); static void draw(void); @@ -30,7 +63,6 @@ static void selectStarSystem(void); static void drawGalaxy(void); static void centerOnSelectedStarSystem(void); static void doStarSystems(void); -void destroyGalacticMap(void); static void drawPulses(void); static void drawInfoBars(void); static void doPulses(void); diff --git a/src/galaxy/galacticMap.h b/src/galaxy/galacticMap.h index 1462d9c..29b2c4b 100644 --- a/src/galaxy/galacticMap.h +++ b/src/galaxy/galacticMap.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,59 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define MAX_LISTED_MISSIONS 9 -#define SHOW_FIGHTER_DB 6 -#define SHOW_GALAXY 0 -#define SHOW_MENU 2 -#define SHOW_OPTIONS 3 -#define SHOW_STAR_SYSTEM 1 -#define SHOW_STATS 4 -#define SHOW_TROPHIES 5 - -extern void autoSizeWidgetButtons(char *group, int recenter); -extern void awardCampaignTrophies(void); -extern void awardStatsTrophies(void); -extern void blit(AtlasImage *atlasImage, int x, int y, int centered); -extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); -extern void clearInput(void); -extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); -extern void doFighterDatabase(void); -extern void doStars(float dx, float dy); -extern void doWidgets(void); -extern void drawBackground(SDL_Texture *texture); -extern void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a); -extern void drawFighterDatabase(void); -extern void drawOptions(void); -extern void drawStars(void); -extern void drawStats(void); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawTrophies(void); -extern void drawWidgets(char *groupName); -extern void endSectionTransition(void); -extern AtlasImage *getAtlasImage(char *filename); -extern StarSystem *getStarSystem(char *name); -extern SDL_Texture *getTexture(char *filename); -extern Widget *getWidget(const char *name, const char *group); -extern void initBattle(void); -extern void initFighterDatabaseDisplay(void); -extern void initOptions(void (*returnFromOptions)(void)); -extern void initStatsDisplay(void); -extern void initTitle(void); -extern void initTrophiesDisplay(void); -extern void loadMission(char *filename); -extern void playMusic(char *filename, int loop); -extern void playSound(int id); -extern void scrollBackground(float x, float y); -extern void selectWidget(const char *name, const char *group); -extern void setAtlasColor(int r, int g, int b, int a); -extern void setMouseCursor(int isDrag); -extern void showOKDialog(void (*callback)(void), const char *format, ...); -extern void startSectionTransition(void); -extern void stopMusic(void); -extern void updateAllMissions(void); - -extern App app; -extern Colors colors; -extern Game game; +void destroyGalacticMap(void); +void initGalacticMap(void); diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 9f699ca..4015414 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,10 +18,43 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "mission.h" +#include +#include "../json/cJSON.h" +#include "../battle/locations.h" +#include "../system/widgets.h" +#include "../system/io.h" +#include "../galaxy/starSystems.h" +#include "../battle/jumpgate.h" +#include "../battle/missionInfo.h" +#include "../system/util.h" +#include "../battle/player.h" +#include "../system/sound.h" +#include "../system/transition.h" +#include "../battle/objectives.h" +#include "../battle/script.h" +#include "../battle/waypoints.h" +#include "../battle/spawners.h" +#include "../system/lookup.h" +#include "../battle/mine.h" +#include "../challenges/challenges.h" +#include "../battle/fighters.h" +#include "../system/atlas.h" +#include "../system/resources.h" +#include "../battle/capitalShips.h" +#include "../game/trophies.h" +#include "../system/textures.h" +#include "../battle/items.h" +#include "../battle/entities.h" + +extern App app; +extern Battle battle; +extern Dev dev; +extern Entity *player; +extern Game game; static void loadEntities(cJSON *node); -static unsigned long hashcode(const char *str); static void loadEpicData(cJSON *node); static char *getAutoBackground(char *filename); static char *getAutoPlanet(char *filename); @@ -496,20 +529,3 @@ int isMissionAvailable(Mission *mission, Mission *prev) ) || dev.debug; } } - -static unsigned long hashcode(const char *str) -{ - unsigned long hash = 5381; - int c; - - c = *str; - - while (c) - { - hash = ((hash << 5) + hash) + c; - - c = *str++; - } - - return hash; -} diff --git a/src/galaxy/mission.h b/src/galaxy/mission.h index 4e214ae..91ca295 100644 --- a/src/galaxy/mission.h +++ b/src/galaxy/mission.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,57 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" -#include "../json/cJSON.h" - -#include "time.h" - -extern void activateNextWaypoint(void); -extern void addAllToQuadtree(void); -extern void addEpicKillsObjective(void); -extern void addEpicLivesObjective(void); -extern void awardCraftTrophy(void); -extern void awardPostMissionTrophies(void); -extern void awardStatsTrophies(void); -extern void completeConditions(void); -extern void countNumEnemies(void); -extern void endSectionTransition(void); -extern void failIncompleteObjectives(void); -extern long flagsToLong(char *flags, int *add); -extern AtlasImage *getAtlasImage(char *filename); -extern char *getBackgroundTextureName(unsigned long n); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern char *getJSONValueStr(cJSON *node, char *name, char *defValue); -extern char *getMusicFilename(unsigned long n); -extern char *getPlanetTextureName(unsigned long n); -extern SDL_Texture *getTexture(char *filename); -extern void initMissionInfo(void); -extern void initPlayer(void); -extern void initScript(cJSON *missionJSON); -extern void loadCapitalShips(cJSON *node); -extern void loadChallenge(Mission *mission, cJSON *node); -extern void loadFighters(cJSON *node); -extern void loadItems(cJSON *node); -extern void loadLocations(cJSON *node); -extern void loadObjectives(cJSON *node); -extern void loadPlayer(cJSON *node); -extern void loadSpawners(cJSON *node); -extern long lookup(char *name); -extern void playMusic(char *filename, int loop); -extern char *readFile(char *filename); -extern void retreatEnemies(void); -extern void selectWidget(const char *name, const char *group); -extern void setInitialPlayerAngle(void); -extern Entity *spawnJumpgate(int side, long flags); -extern Entity *spawnMine(int type); -extern Entity *spawnWaypoint(void); -extern void startSectionTransition(void); -extern void stopMusic(void); -extern void updateChallengeMissions(void); -extern void updateStarSystemMissions(void); - -extern App app; -extern Battle battle; -extern Dev dev; -extern Entity *player; -extern Game game; +int isMissionAvailable(Mission *mission, Mission *prev); +void updateAllMissions(void); +Mission *getMission(char *filename); +void failMission(void); +void completeMission(void); +void loadMission(char *filename); +Mission *loadMissionMeta(char *filename); diff --git a/src/galaxy/starSystems.c b/src/galaxy/starSystems.c index a8d4999..18dd60c 100644 --- a/src/galaxy/starSystems.c +++ b/src/galaxy/starSystems.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "starSystems.h" +#include "../json/cJSON.h" +#include "../galaxy/mission.h" +#include "../system/lookup.h" +#include "../system/util.h" +#include "../system/io.h" + +extern Game game; static void loadMissions(StarSystem *starSystem); static StarSystem *loadStarSystem(cJSON *starSystemJSON); diff --git a/src/galaxy/starSystems.h b/src/galaxy/starSystems.h index 043f846..45c20d8 100644 --- a/src/galaxy/starSystems.h +++ b/src/galaxy/starSystems.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,15 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern char **getFileList(char *dir, int *count); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern int isMissionAvailable(Mission *mission, Mission *prev); -extern Mission *loadMissionMeta(char *filename); -extern long lookup(char *name); -extern char *readFile(char *filename); - -extern Game game; +void destroyStarSystems(void); +void updateStarSystemMissions(void); +StarSystem *getStarSystem(char *name); +void initStarSystems(void); diff --git a/src/game/credits.c b/src/game/credits.c index 4480382..0189ea6 100644 --- a/src/game/credits.c +++ b/src/game/credits.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,13 +18,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "credits.h" +#include "../json/cJSON.h" +#include "../system/draw.h" +#include "../game/title.h" +#include "../system/sound.h" +#include "../system/transition.h" +#include "../system/textures.h" +#include "../system/io.h" +#include "../system/text.h" +#include "../system/atlas.h" + +#define CREDIT_LINE_LIMIT (UI_WIDTH - 300) + +extern App app; +extern Colors colors; static void loadCredits(void); static void logic(void); static void draw(void); static void handleKeyboard(void); -void destroyCredits(void); static SDL_Texture *background; static AtlasImage *earthTexture; diff --git a/src/game/credits.h b/src/game/credits.h index fd3d886..1a81627 100644 --- a/src/game/credits.h +++ b/src/game/credits.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,23 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" -#include "../json/cJSON.h" - -#define CREDIT_LINE_LIMIT (UI_WIDTH - 300) - -extern void blit(AtlasImage *atlasImage, int x, int y, int centered); -extern void drawBackground(SDL_Texture *texture); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void endSectionTransition(void); -extern AtlasImage *getAtlasImage(const char *filename); -extern SDL_Texture *getTexture(const char *filename); -extern int getWrappedTextHeight(char *text, int size); -extern void initTitle(void); -extern void playMusic(char *filename, int loop); -extern char *readFile(char *filename); -extern void startSectionTransition(void); -extern void stopMusic(void); - -extern App app; -extern Colors colors; +void destroyCredits(void); +void initCredits(void); diff --git a/src/game/fighterDatabase.c b/src/game/fighterDatabase.c index 836c955..46572f9 100644 --- a/src/game/fighterDatabase.c +++ b/src/game/fighterDatabase.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "fighterDatabase.h" +#include "../system/text.h" +#include "../battle/fighters.h" +#include "../system/draw.h" +#include "../system/widgets.h" +#include "../system/util.h" + +extern App app; +extern Colors colors; +extern Game game; static void prevFighter(void); static void nextFighter(void); diff --git a/src/game/fighterDatabase.h b/src/game/fighterDatabase.h index 6211974..2d1c720 100644 --- a/src/game/fighterDatabase.h +++ b/src/game/fighterDatabase.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,15 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawWidgets(char *groupName); -extern Entity **getDBFighters(int *num); -extern Widget *getWidget(const char *name, const char *group); -extern float mod(float n, float x); - -extern App app; -extern Colors colors; -extern Game game; +void drawFighterDatabase(void); +void doFighterDatabase(void); +void initFighterDatabaseDisplay(void); +void destroyFighterDatabase(void); +void initFighterDatabase(void); diff --git a/src/game/game.c b/src/game/game.c index d105ab5..43c2a2a 100644 --- a/src/game/game.c +++ b/src/game/game.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,8 +18,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "game.h" +extern Game game; + void initGame(void) { memset(&game, 0, sizeof(Game)); diff --git a/src/game/game.h b/src/game/game.h index 9909921..30bebe2 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,6 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern Game game; +void destroyGame(void); +void initGame(void); diff --git a/src/game/load.c b/src/game/load.c index db7b5af..d597025 100644 --- a/src/game/load.c +++ b/src/game/load.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "load.h" +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../challenges/challenges.h" +#include "../battle/fighters.h" +#include "../galaxy/mission.h" +#include "../game/trophies.h" +#include "../system/io.h" +#include "../galaxy/starSystems.h" + +extern Game game; static void loadStats(cJSON *statsJSON); static void loadStarSystems(cJSON *starSystemsJSON); diff --git a/src/game/load.h b/src/game/load.h index 990c2e3..737c192 100644 --- a/src/game/load.h +++ b/src/game/load.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,18 +18,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern void destroyFighterStats(void); -extern Challenge *getChallenge(Mission *mission, int type, int value); -extern char *getLookupName(char *prefix, long num); -extern Mission *getMission(char *filename); -extern char *getSaveFilePath(char *filename); -extern StarSystem *getStarSystem(char *name); -extern Trophy *getTrophy(char *id); -extern int lookup(char *lookup); -extern char *readFile(char *filename); - -extern Game game; +void loadGame(void); diff --git a/src/game/options.c b/src/game/options.c index dddde72..912edf1 100644 --- a/src/game/options.c +++ b/src/game/options.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "options.h" +#include +#include "../battle/starfield.h" +#include "../system/controls.h" +#include "../system/widgets.h" +#include "../system/init.h" +#include "../system/text.h" +#include "../system/draw.h" + +#define SHOW_CONTROLS 1 +#define SHOW_MAIN 0 + +extern App app; +extern Colors colors; static void changeWindowSize(char *value); static void changeSoundVolume(char *value); diff --git a/src/game/options.h b/src/game/options.h index b67044a..1cfc8ed 100644 --- a/src/game/options.h +++ b/src/game/options.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,23 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "SDL2/SDL_mixer.h" - -#define SHOW_CONTROLS 1 -#define SHOW_MAIN 0 - -extern void drawControls(void); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawWidgets(char *groupName); -extern Widget *getWidget(const char *name, const char *group); -extern void initControlsDisplay(void); -extern void initGraphics(void); -extern void initStars(void); -extern void saveConfig(void); -extern void selectWidget(const char *name, const char *group); -extern void setWidgetOption(const char *name, const char *group, const char *value); - -extern App app; -extern Colors colors; +void updateCustomResolutionOption(void); +void drawOptions(void); +void initOptions(void (*rtn)(void)); diff --git a/src/game/save.c b/src/game/save.c index 53d7fc0..18efd79 100644 --- a/src/game/save.c +++ b/src/game/save.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "save.h" +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../system/io.h" + +extern Game game; static void saveStarSystems(cJSON *gameJSON); static void saveChallenges(cJSON *gameJSON); diff --git a/src/game/save.h b/src/game/save.h index 8434ab1..b07a9c9 100644 --- a/src/game/save.h +++ b/src/game/save.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,12 +18,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern char *getLookupName(char *prefix, long num); -extern char *getSaveFilePath(char *filename); -extern int writeFile(char *filename, char *data); - -extern Game game; +void saveGame(void); diff --git a/src/game/stats.c b/src/game/stats.c index 078495f..c6ef5ab 100644 --- a/src/game/stats.c +++ b/src/game/stats.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,12 +18,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "stats.h" +#include "../system/text.h" +#include "../system/widgets.h" +#include "../system/util.h" + +#define STATS_PER_PAGE 9 + +extern App app; +extern Colors colors; +extern Game game; static void prevPage(void); static void nextPage(void); static void calculatePercentComplete(void); -void updateAccuracyStats(unsigned int *stats); static char *statDescription[STAT_MAX]; static int page; diff --git a/src/game/stats.h b/src/game/stats.h index ac0ade9..45d7963 100644 --- a/src/game/stats.h +++ b/src/game/stats.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,16 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define STATS_PER_PAGE 9 - -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawWidgets(char *groupName); -extern int getPercent(float current, float total); -extern Widget *getWidget(const char *name, const char *group); -extern char *timeToString(long millis, int showHours); - -extern App app; -extern Colors colors; -extern Game game; +void updateAccuracyStats(unsigned int *stats); +void drawStats(void); +void initStatsDisplay(void); +void initStats(void); diff --git a/src/game/title.c b/src/game/title.c index a409ef7..e059b9d 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,40 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "title.h" +#include "../galaxy/mission.h" +#include "../system/transition.h" +#include "../battle/starfield.h" +#include "../game/credits.h" +#include "../system/input.h" +#include "../game/stats.h" +#include "../system/widgets.h" +#include "../challenges/challengeHome.h" +#include "../battle/battle.h" +#include "../galaxy/galacticMap.h" +#include "../game/options.h" +#include "../system/atlas.h" +#include "../game/fighterDatabase.h" +#include "../game/trophies.h" +#include "../battle/effects.h" +#include "../system/text.h" +#include "../system/draw.h" +#include "../system/sound.h" +#include "../system/textures.h" + +#define NUM_FIGHTERS 12 +#define SHOW_FIGHTER_DB 4 +#define SHOW_OPTIONS 2 +#define SHOW_STATS 1 +#define SHOW_TITLE 0 +#define SHOW_TROPHIES 3 + +extern App app; +extern Battle battle; +extern Colors colors; +extern Entity *self; +extern Game game; static void logic(void); static void draw(void); @@ -195,7 +228,7 @@ static void draw(void) blit(pandoranWar, app.winWidth / 2, 110, 1); - drawText(10, app.winHeight - 25, 14, TA_LEFT, colors.white, "Copyright Parallel Realities, 2015-2019"); + drawText(10, app.winHeight - 25, 14, TA_LEFT, colors.white, "Copyright,2022 Parallel Realities, 2015-2019,2022"); drawText(app.winWidth - 10, app.winHeight - 25, 14, TA_RIGHT, colors.white, "Version %.2f.%d", VERSION, REVISION); switch (show) diff --git a/src/game/title.h b/src/game/title.h index e750a5c..36a07aa 100644 --- a/src/game/title.h +++ b/src/game/title.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,56 +18,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#define NUM_FIGHTERS 12 -#define SHOW_FIGHTER_DB 4 -#define SHOW_OPTIONS 2 -#define SHOW_STATS 1 -#define SHOW_TITLE 0 -#define SHOW_TROPHIES 3 - -extern void addEngineEffect(void); -extern void autoSizeWidgetButtons(char *group, int recenter); -extern void blit(AtlasImage *atlasImage, int x, int y, int centered); -extern void clearInput(void); -extern void destroyBattle(void); -extern void doEffects(void); -extern void doFighterDatabase(void); -extern void doStars(float dx, float dy); -extern void doWidgets(void); -extern void drawBackground(SDL_Texture *texture); -extern void drawEffects(void); -extern void drawFighterDatabase(void); -extern void drawOptions(void); -extern void drawStars(void); -extern void drawStats(void); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawTrophies(void); -extern void drawWidgets(char *groupName); -extern void endSectionTransition(void); -extern AtlasImage *getAtlasImage(const char *filename); -extern SDL_Texture *getTexture(const char *filename); -extern Widget *getWidget(const char *name, const char *group); -extern void initChallengeHome(void); -extern void initCredits(void); -extern void initEffects(void); -extern void initFighterDatabaseDisplay(void); -extern void initGalacticMap(void); -extern void initOptions(void (*returnFromOptions)(void)); -extern void initStatsDisplay(void); -extern void initTrophiesDisplay(void); -extern void playMusic(char *filename, int loop); -extern void playSound(int id); -extern void scrollBackground(float x, float y); -extern void selectWidget(const char *name, const char *group); -extern void setAtlasColor(int r, int g, int b, int a); -extern void startSectionTransition(void); -extern void stopMusic(void); -extern void updateAllMissions(void); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Entity *self; -extern Game game; +void initTitle(void); diff --git a/src/game/trophies.c b/src/game/trophies.c index 33e5363..dc545c7 100644 --- a/src/game/trophies.c +++ b/src/game/trophies.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "trophies.h" +#include +#include "../json/cJSON.h" +#include "../system/lookup.h" +#include "../system/draw.h" +#include "../system/util.h" +#include "../system/widgets.h" +#include "../system/io.h" +#include "../system/text.h" +#include "../system/atlas.h" +#include "../system/sound.h" +#include "../battle/entities.h" + +#define TROPHIES_PER_PAGE 4 + +extern App app; +extern Battle battle; +extern Colors colors; +extern Entity *player; +extern Game game; static void prevPage(void); static void nextPage(void); diff --git a/src/game/trophies.h b/src/game/trophies.h index ac61eb7..2798195 100644 --- a/src/game/trophies.h +++ b/src/game/trophies.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,34 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include "../common.h" -#include "../json/cJSON.h" - -#include "time.h" - -#define TROPHIES_PER_PAGE 4 - -extern void awardPandoranCraftTrophy(void); -extern void blit(AtlasImage *atlasImage, int x, int y, int centered); -extern void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); -extern void blitScaled(AtlasImage *atlasImage, int x, int y, int w, int h, int center); -extern void calcTextDimensions(char *text, int size, int *w, int *h); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawWidgets(char *groupName); -extern AtlasImage *getAtlasImage(char *filename); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern int getPercent(float current, float total); -extern Widget *getWidget(const char *name, const char *group); -extern long lookup(char *name); -extern float mod(float n, float x); -extern void playSound(int id); -extern char *readFile(char *filename); -extern void setAtlasColor(int r, int g, int b, int a); -extern char *timeToDate(long millis); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Entity *player; -extern Game game; +void awardCraftTrophy(void); +void awardPostMissionTrophies(void); +void awardChallengeTrophies(void); +void awardCampaignTrophies(void); +void awardStatsTrophies(void); +Trophy *getTrophy(char *id); +void drawTrophyAlert(void); +void doTrophyAlerts(void); +void awardTrophy(char *id); +void drawTrophies(void); +void initTrophiesDisplay(void); +void initTrophies(void); diff --git a/src/json/cJSON.h b/src/json/cJSON.h index aba9337..a36e80a 100644 --- a/src/json/cJSON.h +++ b/src/json/cJSON.h @@ -62,7 +62,6 @@ typedef struct cJSON_Hooks { /* Supply malloc, realloc and free functions to cJSON */ extern void cJSON_InitHooks(cJSON_Hooks* hooks); - /* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */ extern cJSON *cJSON_Parse(const char *value); /* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */ diff --git a/src/main.c b/src/main.c index eea9296..f8df6ea 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,32 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "common.h" #include "main.h" +#include +#include "game/load.h" +#include "system/lookup.h" +#include "system/draw.h" +#include "game/credits.h" +#include "system/input.h" +#include "system/controls.h" +#include "game/title.h" +#include "game/trophies.h" +#include "system/modalDialog.h" +#include "test/testMission.h" +#include "game/save.h" +#include "system/io.h" +#include "system/dev.h" +#include "system/init.h" +#include "plat/win32/win32Init.h" + +App app; +Battle battle; +Colors colors; +Dev dev; +Entity *player; +Entity *self; +Game game; static void handleMissionArgs(int argc, char *argv[]); static void handleLoggingArgs(int argc, char *argv[]); diff --git a/src/main.h b/src/main.h index 917a22a..c577759 100644 --- a/src/main.h +++ b/src/main.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,41 +18,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "SDL2/SDL.h" -#include "time.h" - -#include "defs.h" -#include "structs.h" - -extern void cleanup(void); -extern void clearControl(int type); -extern void createScreenshotFolder(void); -extern void doDevKeys(void); -extern void doInput(void); -extern void doModalDialog(void); -extern void doTrophyAlerts(void); -extern void drawModalDialog(void); -extern void drawTrophyAlert(void); -extern int fileExists(char *filename); -extern char *getSaveFilePath(char *filename); -extern void init18N(int argc, char *argv[]); -extern void initCredits(void); -extern void initGameSystem(void); -extern void initLookups(void); -extern void initSDL(int argc, char *argv[]); -extern void initTitle(void); -extern int isControl(int type); -extern void loadGame(void); -extern void loadTestMission(char *filename); -extern void prepareScene(void); -extern void presentScene(void); -extern void saveGame(void); -extern void saveScreenshot(void); - -App app; -Battle battle; -Colors colors; -Dev dev; -Entity *player; -Entity *self; -Game game; +int main(int argc, char *argv[]); diff --git a/src/plat/unix/unixInit.c b/src/plat/unix/unixInit.c index b7e372e..aba1834 100644 --- a/src/plat/unix/unixInit.c +++ b/src/plat/unix/unixInit.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../../common.h" #include "unixInit.h" +#include +#include +#include +#include + +extern App app; +extern Dev dev; void createSaveFolder(void) { diff --git a/src/plat/unix/unixInit.h b/src/plat/unix/unixInit.h index e45618c..19aa6a9 100644 --- a/src/plat/unix/unixInit.h +++ b/src/plat/unix/unixInit.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,12 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include -#include - -#include "../../common.h" - -extern App app; -extern Dev dev; +void createScreenshotFolder(void); +void createSaveFolder(void); diff --git a/src/plat/win32/win32Init.c b/src/plat/win32/win32Init.c index d640985..305f1ba 100644 --- a/src/plat/win32/win32Init.c +++ b/src/plat/win32/win32Init.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../../common.h" #include "win32Init.h" +#include +#include +#include + +extern App app; +extern Dev dev; void createSaveFolder(void) { diff --git a/src/plat/win32/win32Init.h b/src/plat/win32/win32Init.h index 9dfa785..19aa6a9 100644 --- a/src/plat/win32/win32Init.h +++ b/src/plat/win32/win32Init.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,11 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include - -#include "../../common.h" - -extern App app; -extern Dev dev; +void createScreenshotFolder(void); +void createSaveFolder(void); diff --git a/src/structs.h b/src/structs.h index 43810d9..8c81851 100644 --- a/src/structs.h +++ b/src/structs.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License diff --git a/src/system/atlas.c b/src/system/atlas.c index 102e8f3..d027bdb 100644 --- a/src/system/atlas.c +++ b/src/system/atlas.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018-2019 Parallel Realities +Copyright (C) 2018-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "atlas.h" +#include "../json/cJSON.h" +#include "../system/io.h" +#include "../system/textures.h" +#include "../system/util.h" static void loadAtlasData(void); @@ -40,7 +45,7 @@ void setAtlasColor(int r, int g, int b, int a) SDL_SetTextureAlphaMod(atlasTexture, a); } -AtlasImage *getAtlasImage(char *filename) +AtlasImage *getAtlasImage(const char *filename) { AtlasImage *a; unsigned long i; diff --git a/src/system/atlas.h b/src/system/atlas.h index 969abe6..ec1a0ec 100644 --- a/src/system/atlas.h +++ b/src/system/atlas.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018-2019 Parallel Realities +Copyright (C) 2018-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,10 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" -#include "../json/cJSON.h" - -extern SDL_Texture *getTexture(const char *filename); -extern unsigned long hashcode(const char *str); -extern char *readFile(const char *filename); -extern int stringComparator(const void *a, const void *b); +char **getAtlasFileList(char *dir, int *count); +AtlasImage *getAtlasImage(const char *filename); +void setAtlasColor(int r, int g, int b, int a); +void initAtlas(void); diff --git a/src/system/controls.c b/src/system/controls.c index 2c671df..1b526cd 100644 --- a/src/system/controls.c +++ b/src/system/controls.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "controls.h" +#include "../json/cJSON.h" +#include "../system/text.h" +#include "../system/lookup.h" +#include "../system/widgets.h" +#include "../system/io.h" + +extern App app; +extern Colors colors; static void restoreDefaults(void); diff --git a/src/system/controls.h b/src/system/controls.h index 6ccadb4..6ce732c 100644 --- a/src/system/controls.h +++ b/src/system/controls.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,15 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" -#include "../json/cJSON.h" - -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawWidgets(char *groupName); -extern char *getLookupName(char *prefix, long num); -extern Widget *getWidget(const char *name, const char *group); -extern long lookup(char *name); -extern char *readFile(char *filename); - -extern App app; -extern Colors colors; +void drawControls(void); +void clearControlConfig(char *name); +void updateControlButton(char *name); +void updateControlKey(char *name); +void resetAcceptControls(void); +void clearControl(int type); +int isAcceptControl(void); +int isControl(int type); +void initControlsDisplay(void); +void initControls(void); diff --git a/src/system/dev.c b/src/system/dev.c index 9c04023..c8122df 100644 --- a/src/system/dev.c +++ b/src/system/dev.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "dev.h" +#include "../galaxy/mission.h" + +extern App app; +extern Battle battle; +extern Dev dev; void doDevKeys(void) { diff --git a/src/system/dev.h b/src/system/dev.h index 4c3a8c6..ad1b3fc 100644 --- a/src/system/dev.h +++ b/src/system/dev.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,10 +18,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern void completeMission(void); - -extern App app; -extern Battle battle; -extern Dev dev; +void doDevKeys(void); diff --git a/src/system/draw.c b/src/system/draw.c index e3a0a67..4e70c46 100644 --- a/src/system/draw.c +++ b/src/system/draw.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "draw.h" +#include "../system/text.h" +#include "../system/util.h" +#include "../system/input.h" + +extern App app; +extern Battle battle; +extern Colors colors; +extern Dev dev; static void initColor(SDL_Color *c, int r, int g, int b); diff --git a/src/system/draw.h b/src/system/draw.h index 4fcb0b8..1bbf6ec 100644 --- a/src/system/draw.h +++ b/src/system/draw.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,13 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); -extern void drawMouse(void); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); - -extern App app; -extern Battle battle; -extern Colors colors; -extern Dev dev; +void saveScreenshot(void); +int isOnBattleScreen(int x, int y, int w, int h); +void drawBackground(SDL_Texture *texture); +void scrollBackground(float x, float y); +void drawCircle(int cx, int cy, int radius, int r, int g, int b, int a); +void blitRotated(AtlasImage *atlasImage, int x, int y, float angle); +void blitScaled(AtlasImage *atlasImage, int x, int y, int w, int h, int center); +void blit(AtlasImage *atlasImage, int x, int y, int center); +void presentScene(void); +void prepareScene(void); +void initGraphics(void); diff --git a/src/system/i18n.c b/src/system/i18n.c index 235897e..eb6a636 100644 --- a/src/system/i18n.c +++ b/src/system/i18n.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2009-2016 Parallel Realities +Copyright (C) 2009-2016,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -17,11 +17,15 @@ along with this program; if not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. */ +#include "../common.h" #include "i18n.h" +#include "../system/io.h" +#ifdef _WIN32 + #include +#endif + +#define TABLE_SIZE 255 -char *getTranslatedString(char *); -void setLanguage(char *, char *); -void cleanupLanguage(void); static int hashCode(char *); static void put(char *, char *); static void initTable(void); @@ -363,7 +367,7 @@ char *getTranslatedString(char *key) return key; } -void cleanupLanguage() +void cleanupLanguage(void) { int i; Bucket *bucket, *p, *q; diff --git a/src/system/i18n.h b/src/system/i18n.h index 7fe037f..8b6bc8d 100644 --- a/src/system/i18n.h +++ b/src/system/i18n.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2009-2016 Parallel Realities +Copyright (C) 2009-2016,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -17,15 +17,6 @@ along with this program; if not, write to the Free Software Foundation, 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. */ -#include "../common.h" - -#ifdef _WIN32 - #include -#endif - -#define TABLE_SIZE 255 - -char *getTranslatedString(char *); -void setLanguage(char *, char *); void cleanupLanguage(void); -extern int fileExists(char *filename); +char *getTranslatedString(char *key); +void setLanguage(char *applicationName, char *languageCode); diff --git a/src/system/init.c b/src/system/init.c index 19d62f5..d9ceb90 100644 --- a/src/system/init.c +++ b/src/system/init.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,11 +18,48 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "init.h" +#include +#include "../json/cJSON.h" +#include +#include +#include "../game/credits.h" +#include "../system/widgets.h" +#include "../battle/bullets.h" +#include "../system/modalDialog.h" +#include "../system/io.h" +#include "../galaxy/starSystems.h" +#include "../system/draw.h" +#include "../battle/starfield.h" +#include "../system/util.h" +#include "../system/sound.h" +#include "../system/lookup.h" +#include "../challenges/challenges.h" +#include "../system/controls.h" +#include "../battle/fighters.h" +#include "../game/game.h" +#include "../battle/battle.h" +#include "../game/options.h" +#include "../system/text.h" +#include "../system/i18n.h" +#include "../system/atlas.h" +#include "../system/resources.h" +#include "../battle/capitalShips.h" +#include "../system/input.h" +#include "../game/stats.h" +#include "../galaxy/galacticMap.h" +#include "../game/trophies.h" +#include "../game/fighterDatabase.h" +#include "../system/textures.h" +#include "../battle/items.h" +#include "../plat/win32/win32Init.h" +#include "locale.h" + +extern App app; static void loadConfig(int argc, char *argv[]); static void loadConfigFile(char *filename); -void saveConfig(void); static void showLoadingStep(float step, float maxSteps); static void handleCommandLineConfig(int argc, char *argv[]); @@ -88,7 +125,7 @@ void initSDL(int argc, char *argv[]) if (Mix_OpenAudio(AUDIO_FREQUENCY, MIX_DEFAULT_FORMAT, AUDIO_CHANNELS, AUDIO_CHUNKSIZE) == -1) { - printf("Couldn't initialize SDL Mixer\n"); + printf("Couldn't initialize SDL Mixer\n"); exit(1); } diff --git a/src/system/init.h b/src/system/init.h index 13a689d..d66aa65 100644 --- a/src/system/init.h +++ b/src/system/init.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,63 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -#include "locale.h" - -#include "SDL2/SDL_image.h" -#include "SDL2/SDL_mixer.h" -#include "SDL2/SDL_ttf.h" - -extern void createSaveFolder(void); -extern void destroyBattle(void); -extern void destroyBulletDefs(void); -extern void destroyCapitalShipDefs(void); -extern void destroyCredits(void); -extern void destroyFighterDatabase(void); -extern void destroyFighterDefs(void); -extern void destroyFighterStats(void); -extern void destroyGalacticMap(void); -extern void destroyGame(void); -extern void destroyItemDefs(void); -extern void destroyLookups(void); -extern void destroyResources(void); -extern void destroySounds(void); -extern void destroyStarSystems(void); -extern void destroyTextures(void); -extern void destroyWidgets(void); -extern int fileExists(char *filename); -extern int getJSONValue(cJSON *node, char *name, int defValue); -extern char *getLookupName(char *prefix, long num); -extern char *getSaveFilePath(char *filename); -extern void initAtlas(void); -extern void initBulletDefs(void); -extern void initChallenges(void); -extern void initControls(void); -extern void initFighterDatabase(void); -extern void initFonts(void); -extern void initGame(void); -extern void initGraphics(void); -extern void initInput(void); -extern void initModalDialog(void); -extern void initResources(void); -extern void initSounds(void); -extern void initStarSystems(void); -extern void initStars(void); -extern void initStats(void); -extern void initTrophies(void); -extern void initWidgets(void); -extern void loadCapitalShipDefs(void); -extern void loadFighterDefs(void); -extern void loadItemDefs(void); -extern long lookup(char *name); -extern void prepareScene(void); -extern void presentScene(void); -extern char *readFile(char *filename); -extern void setLanguage(char *applicationName, char *languageCode); -extern void updateCustomResolutionOption(void); -extern int writeFile(char *filename, char *data); - -extern App app; +void cleanup(void); +void saveConfig(void); +void initGameSystem(void); +void initSDL(int argc, char *argv[]); +void init18N(int argc, char *argv[]); diff --git a/src/system/input.c b/src/system/input.c index 7c10683..03626b3 100644 --- a/src/system/input.c +++ b/src/system/input.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "input.h" +#include "../system/atlas.h" +#include "../system/draw.h" +#include "../system/sound.h" + +extern App app; static AtlasImage *mousePointer; static AtlasImage *mousePointerNormal; diff --git a/src/system/input.h b/src/system/input.h index 28e302b..8a920bc 100644 --- a/src/system/input.h +++ b/src/system/input.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,11 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern void blit(AtlasImage *atlasImage, int x, int y, int centered); -extern AtlasImage *getAtlasImage(char *filename); -extern void musicSetPlaying(int playing); -extern void setAtlasColor(int r, int g, int b, int a); - -extern App app; +void clearInput(void); +void doInput(void); +void drawMouse(void); +void setMouseCursor(int isDrag); +void doMouseMotion(SDL_MouseMotionEvent *event); +void doMouseWheel(SDL_MouseWheelEvent *event); +void doMouseUp(SDL_MouseButtonEvent *event); +void doMouseDown(SDL_MouseButtonEvent *event); +void doKeyUp(SDL_KeyboardEvent *event); +void doKeyDown(SDL_KeyboardEvent *event); +void initInput(void); diff --git a/src/system/io.c b/src/system/io.c index dfd6ab4..7bfb8dd 100644 --- a/src/system/io.c +++ b/src/system/io.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "io.h" +#include +#include "dirent.h" +#include "../system/util.h" + +extern App app; int fileExists(char *filename) { diff --git a/src/system/io.h b/src/system/io.h index ba35f9d..f49b33c 100644 --- a/src/system/io.h +++ b/src/system/io.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,11 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "sys/stat.h" -#include "dirent.h" - -extern int stringComparator(const void *a, const void *b); - -extern App app; +char **getFileList(char *dir, int *count); +char *getSaveFilePath(char *filename); +int writeFile(char *filename, char *data); +char *readFile(char *filename); +char *getFileLocation(char *filename); +int fileExists(char *filename); diff --git a/src/system/lookup.c b/src/system/lookup.c index cdb13f3..747ae07 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "lookup.h" +#include static Lookup head; static Lookup *tail; diff --git a/src/system/lookup.h b/src/system/lookup.h index 369c2a9..5e11ea1 100644 --- a/src/system/lookup.h +++ b/src/system/lookup.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,4 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" +void destroyLookups(void); +long flagsToLong(char *in, int *add); +char *getLookupName(char *prefix, long num); +long lookup(char *name); +void initLookups(void); diff --git a/src/system/modalDialog.c b/src/system/modalDialog.c index 0178da4..fc4b685 100644 --- a/src/system/modalDialog.c +++ b/src/system/modalDialog.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "modalDialog.h" +#include "../system/text.h" +#include "../system/widgets.h" +#include "../system/input.h" + +extern App app; +extern Colors colors; static int enableTimer; static Widget *ok; diff --git a/src/system/modalDialog.h b/src/system/modalDialog.h index 315b9c7..ceea484 100644 --- a/src/system/modalDialog.h +++ b/src/system/modalDialog.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,14 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern void clearInput(void); -extern void doWidgets(void); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern void drawWidgets(char *groupName); -extern Widget *getWidget(const char *name, const char *group); -extern int getWrappedTextHeight(char *text, int size); - -extern App app; -extern Colors colors; +void drawModalDialog(void); +void doModalDialog(void); +void showOKCancelDialog(void (*okCallback)(void), void (*cancelCallback)(void), const char *format, ...); +void showOKDialog(void (*callback)(void), const char *format, ...); +void initModalDialog(void); diff --git a/src/system/resources.c b/src/system/resources.c index f5ba79d..32fc986 100644 --- a/src/system/resources.c +++ b/src/system/resources.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "resources.h" +#include "../system/atlas.h" +#include "../system/io.h" char **backgrounds; char **planets; diff --git a/src/system/resources.h b/src/system/resources.h index 7cee331..c2c69da 100644 --- a/src/system/resources.h +++ b/src/system/resources.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern char **getAtlasFileList(char *dir, int *count); -extern char **getFileList(char *dir, int *count); +void destroyResources(void); +char *getMusicFilename(unsigned long i); +char *getPlanetTextureName(unsigned long i); +char *getBackgroundTextureName(unsigned long i); +void initResources(void); diff --git a/src/system/sound.c b/src/system/sound.c index 7717463..6a41f04 100644 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "sound.h" +#include +#include "../system/util.h" +#include "../system/io.h" + +#define MAX_BATTLE_SOUND_DISTANCE 1500 +#define MIN_BATTLE_SOUND_DISTANCE 100 + +extern Entity *player; static void loadSounds(void); @@ -48,7 +57,7 @@ void playMusic(char *filename, int loop) music = Mix_LoadMUS(getFileLocation(filename)); - Mix_PlayMusic(music, (loop) ? -1 : 0); + Mix_PlayMusic(music, (loop) ? -1 : 0); } void stopMusic(void) diff --git a/src/system/sound.h b/src/system/sound.h index 28530f8..53d27d8 100644 --- a/src/system/sound.h +++ b/src/system/sound.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,15 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "SDL2/SDL_mixer.h" - -#define MAX_BATTLE_SOUND_DISTANCE 1500 -#define MIN_BATTLE_SOUND_DISTANCE 100 - -extern float getAngle(int x1, int y1, int x2, int y2); -extern int getDistance(int x1, int y1, int x2, int y2); -extern char *getFileLocation(char *filename); - -extern Entity *player; +void destroySounds(void); +void playBattleSound(int id, int x, int y); +void playSound(int id); +void musicSetPlaying(int playing); +void stopMusic(void); +void playMusic(char *filename, int loop); +void initSounds(void); diff --git a/src/system/text.c b/src/system/text.c index bd12f5c..0675c56 100644 --- a/src/system/text.c +++ b/src/system/text.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2018-2019 Parallel Realities +Copyright (C) 2018-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,14 +18,23 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "text.h" +#include +#include "../system/textures.h" +#include "../system/io.h" + +#define FONT_SIZE 32 +#define FONT_TEXTURE_SIZE 512 +#define MAX_WORD_LENGTH 128 +#define MAX_GLYPH_SIZE 8 + +extern App app; static void initFont(char *name, char *filename, char *characters); static void drawWord(char *word, int *x, int *y, int startX); static void drawTextLines(int x, int y, int size, int align); static void drawTextLine(int x, int y, int size, int align, const char *line); -void calcTextDimensions(const char *text, int size, int *w, int *h); -void useFont(char *name); static int nextGlyph(const char *str, int *i, char *glyphBuffer); static char drawTextBuffer[1024]; diff --git a/src/system/text.h b/src/system/text.h index a1cd4d3..6fa534b 100644 --- a/src/system/text.h +++ b/src/system/text.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2018-2019 Parallel Realities +Copyright (C) 2018-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,21 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "stdlib.h" -#include "string.h" - -#include "SDL2/SDL_image.h" -#include "SDL2/SDL_ttf.h" - -#include "../common.h" - -#define FONT_SIZE 32 -#define FONT_TEXTURE_SIZE 512 -#define MAX_WORD_LENGTH 128 -#define MAX_GLYPH_SIZE 8 - -extern char *getFileLocation(char *filename); -extern char *readFile(char *filename); -extern SDL_Texture *toTexture(SDL_Surface *surface, int destroySurface); - -extern App app; +int getWrappedTextHeight(char *text, int size); +void calcTextDimensions(const char *text, int size, int *w, int *h); +void useFont(char *name); +void drawText(int x, int y, int size, int align, SDL_Color color, const char *format, ...); +void initFonts(void); diff --git a/src/system/textures.c b/src/system/textures.c index 81e4013..67cfb9d 100644 --- a/src/system/textures.c +++ b/src/system/textures.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,12 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "textures.h" +#include +#include "../system/io.h" + +extern App app; static Texture textures[NUM_TEXTURE_BUCKETS]; static void addTextureToCache(char *name, SDL_Texture *texture); -SDL_Texture *getTexture(char *name); static void addTextureToCache(char *name, SDL_Texture *texture) { diff --git a/src/system/textures.h b/src/system/textures.h index 6713702..334cfb6 100644 --- a/src/system/textures.h +++ b/src/system/textures.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,10 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "SDL2/SDL_image.h" - -extern char *getFileLocation(char *filename); - -extern App app; +void destroyTextures(void); +SDL_Texture *toTexture(SDL_Surface *surface, int destroySurface); +SDL_Texture *getTexture(char *filename); diff --git a/src/system/transition.c b/src/system/transition.c index 2483e77..3daa74e 100644 --- a/src/system/transition.c +++ b/src/system/transition.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "transition.h" +#include "../system/draw.h" +#include "../system/input.h" static long transitionStartTime; diff --git a/src/system/transition.h b/src/system/transition.h index b0d84ea..2642df3 100644 --- a/src/system/transition.h +++ b/src/system/transition.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,8 +18,5 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -extern void clearInput(void); -extern void prepareScene(void); -extern void presentScene(void); +void endSectionTransition(void); +void startSectionTransition(void); diff --git a/src/system/util.c b/src/system/util.c index b69b651..554b4e1 100644 --- a/src/system/util.c +++ b/src/system/util.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "util.h" +#include +#include "../json/cJSON.h" float mod(float n, float x) { @@ -194,5 +197,5 @@ int stringComparator(const void *a, const void *b) { char **s1 = (char **)a; char **s2 = (char **)b; - return strcmp(*s1, *s2); + return strcmp(*s1, *s2); } diff --git a/src/system/util.h b/src/system/util.h index d13fb8b..fdbbdcc 100644 --- a/src/system/util.h +++ b/src/system/util.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,6 +18,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" -#include "../json/cJSON.h" -#include "time.h" +int stringComparator(const void *a, const void *b); +unsigned long hashcode(const char *str); +void *resize(void *array, int oldSize, int newSize); +int getJSONValue(struct cJSON *node, char *name, int defValue); +char *getJSONValueStr(struct cJSON *node, char *name, char *defValue); +char *timeToDate(long millis); +char *timeToString(long millis, int showHours); +char **toTypeArray(char *types, int *numTypes); +int getDistance(int x1, int y1, int x2, int y2); +float getAngle(int x1, int y1, int x2, int y2); +int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); +int getPercent(float current, float total); +float mod(float n, float x); diff --git a/src/system/widgets.c b/src/system/widgets.c index 9efb373..5c52c2d 100644 --- a/src/system/widgets.c +++ b/src/system/widgets.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,22 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "widgets.h" +#include "../json/cJSON.h" +#include +#include "../system/lookup.h" +#include "../system/draw.h" +#include "../system/util.h" +#include "../system/input.h" +#include "../system/controls.h" +#include "../system/sound.h" +#include "../system/io.h" +#include "../system/text.h" +#include "../system/atlas.h" + +extern App app; +extern Colors colors; static void loadWidgets(void); static void loadWidgetSet(char *filename); diff --git a/src/system/widgets.h b/src/system/widgets.h index f4d7e6a..f381301 100644 --- a/src/system/widgets.h +++ b/src/system/widgets.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,24 +18,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern void blit(AtlasImage *atlasImage, int x, int y, int centered); -extern void calcTextDimensions(char *text, int size, int *w, int *h); -extern void clearControlConfig(char *name); -extern void clearInput(void); -extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2); -extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...); -extern AtlasImage *getAtlasImage(char *filename); -extern char **getFileList(char *dir, int *count); -extern long lookup(char *name); -extern void playSound(int id); -extern char *readFile(char *filename); -extern void setAtlasColor(int r, int g, int b, int a); -extern void updateControlButton(char *name); -extern void updateControlKey(char *name); - -extern App app; -extern Colors colors; +void destroyWidgets(void); +void autoSizeWidgetButtons(char *group, int recenter); +void setWidgetOption(const char *name, const char *group, const char *value); +void drawWidgets(const char *group); +void selectWidget(const char *name, const char *group); +Widget *getWidget(const char *name, const char *group); +void doWidgets(void); +void initWidgets(void); diff --git a/src/test/testMission.c b/src/test/testMission.c index 276aa34..a7d3439 100644 --- a/src/test/testMission.c +++ b/src/test/testMission.c @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,7 +18,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "../common.h" #include "testMission.h" +#include "../json/cJSON.h" +#include "../galaxy/mission.h" +#include "../battle/battle.h" + +extern Game game; void loadTestMission(char *filename) { diff --git a/src/test/testMission.h b/src/test/testMission.h index e3283b2..175f3f1 100644 --- a/src/test/testMission.h +++ b/src/test/testMission.h @@ -1,5 +1,5 @@ /* -Copyright (C) 2015-2019 Parallel Realities +Copyright (C) 2015-2019,2022 Parallel Realities This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -18,12 +18,4 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "../common.h" - -#include "../json/cJSON.h" - -extern void initBattle(void); -extern void loadMission(char *filename); -extern Mission *loadMissionMeta(char *filename); - -extern Game game; +void loadTestMission(char *filename);