tbftss/src/structs.h

579 lines
10 KiB
C
Raw Normal View History

2015-10-20 13:51:49 +02:00
/*
2019-01-01 17:14:11 +01:00
Copyright (C) 2015-2019 Parallel Realities
2015-10-20 13:51:49 +02:00
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
typedef struct Texture Texture;
typedef struct Lookup Lookup;
typedef struct Weapon Weapon;
2016-02-21 08:48:22 +01:00
typedef struct Quadtree Quadtree;
2015-10-26 18:27:43 +01:00
typedef struct Entity Entity;
2015-10-20 13:51:49 +02:00
typedef struct Bullet Bullet;
2015-12-13 15:50:54 +01:00
typedef struct Debris Debris;
2015-10-20 13:51:49 +02:00
typedef struct Effect Effect;
2016-03-27 12:21:23 +02:00
typedef struct Spawner Spawner;
2015-10-20 13:51:49 +02:00
typedef struct Objective Objective;
typedef struct StarSystem StarSystem;
typedef struct Challenge Challenge;
typedef struct Mission Mission;
typedef struct Pulse Pulse;
typedef struct Widget Widget;
typedef struct HudMessage HudMessage;
typedef struct MessageBox MessageBox;
typedef struct ScriptRunner ScriptRunner;
typedef struct Location Location;
2016-02-27 13:14:05 +01:00
typedef struct Bucket Bucket;
2016-03-03 19:03:07 +01:00
typedef struct Trophy Trophy;
2016-05-17 20:02:58 +02:00
typedef struct Tuple Tuple;
2016-05-29 10:38:05 +02:00
typedef struct Credit Credit;
2018-12-06 09:37:19 +01:00
typedef struct AtlasImage AtlasImage;
typedef struct Font Font;
2018-12-08 20:07:15 +01:00
typedef struct Glyph Glyph;
2015-10-20 13:51:49 +02:00
2015-12-18 11:12:37 +01:00
typedef struct {
2015-12-20 13:25:20 +01:00
int debug;
2015-12-18 11:12:37 +01:00
int takeScreenshots;
char *screenshotFolder;
2015-12-18 11:12:37 +01:00
int noAIWeapons;
int showFPS;
int playerImmortal;
int playerUnlimitedMissiles;
int noEntityActions;
int allImmortal;
int fps;
} Dev;
2015-10-20 13:51:49 +02:00
typedef struct {
float x;
float y;
} PointF;
struct Texture {
2015-11-22 17:52:27 +01:00
char name[MAX_DESCRIPTION_LENGTH];
2015-10-20 13:51:49 +02:00
long hash;
2015-12-20 17:13:35 +01:00
long ttl;
SDL_Texture *texture;
2015-10-20 13:51:49 +02:00
Texture *next;
};
2018-12-06 09:37:19 +01:00
struct AtlasImage {
char filename[MAX_FILENAME_LENGTH];
SDL_Rect rect;
SDL_Texture *texture;
AtlasImage *next;
};
2015-10-20 13:51:49 +02:00
typedef struct {
void (*logic)(void);
void (*draw)(void);
void (*handleClick)(int x, int y, int btn);
void (*handleDrag)(int x, int y, int dx, int dy, int cx, int cy);
void (*handleMouseUp)(int x, int y, int btn);
} Delegate;
2016-02-23 08:19:31 +01:00
typedef struct {
int type;
char message[MAX_DESCRIPTION_LENGTH];
} ModalDialog;
2015-10-20 13:51:49 +02:00
struct Lookup {
char name[MAX_NAME_LENGTH];
long value;
Lookup *next;
};
struct Weapon {
int type;
int ammo;
int maxAmmo;
int x;
int y;
};
2015-10-26 18:27:43 +01:00
struct Entity {
int type;
2015-10-20 13:51:49 +02:00
char name[MAX_NAME_LENGTH];
char defName[MAX_NAME_LENGTH];
char groupName[MAX_NAME_LENGTH];
2018-12-06 09:37:19 +01:00
char *description;
2017-08-10 09:44:19 +02:00
char affiliation[MAX_NAME_LENGTH];
int active;
2016-03-27 12:21:23 +02:00
int spawned;
int id;
2015-10-20 13:51:49 +02:00
int side;
float x;
float y;
2015-12-07 20:19:14 +01:00
int offsetX;
int offsetY;
2015-11-01 23:19:39 +01:00
int w;
int h;
2015-10-20 13:51:49 +02:00
float dx;
float dy;
float thrust;
2015-10-21 20:21:45 +02:00
float speed;
float angle;
2015-10-20 13:51:49 +02:00
int alive;
int health;
int maxHealth;
int shield;
int maxShield;
int reload;
int reloadTime;
int selectedGunType;
int combinedGuns;
2015-10-20 13:51:49 +02:00
int shieldRecharge;
int shieldRechargeRate;
2015-10-21 20:21:45 +02:00
int systemPower;
2015-10-20 13:51:49 +02:00
int armourHit;
int shieldHit;
2015-10-21 20:21:45 +02:00
int systemHit;
2015-10-20 13:51:49 +02:00
int thinkTime;
int aiActionTime;
int aiAggression;
int aiDamagePerSec;
int aiDamageTimer;
int aiEvadeTimer;
2015-10-20 13:51:49 +02:00
int separationRadius;
int deathType;
2015-10-20 13:51:49 +02:00
Weapon guns[MAX_FIGHTER_GUNS];
int missiles;
2015-10-20 13:51:49 +02:00
long flags;
long aiFlags;
SDL_Point targetLocation;
Entity *towing;
Entity *target;
2015-12-18 13:02:01 +01:00
Entity *leader;
Entity *owner;
Entity *killedBy;
2015-10-20 13:51:49 +02:00
void (*action)(void);
void (*draw)(void);
2015-10-20 13:51:49 +02:00
void (*die)(void);
2018-12-06 09:37:19 +01:00
AtlasImage *texture;
Entity *next;
2015-10-20 13:51:49 +02:00
};
struct Bullet {
int type;
float x;
float y;
int w;
int h;
2015-10-20 13:51:49 +02:00
float dx;
float dy;
int sound;
int life;
int damage;
int angle;
long flags;
2018-12-06 09:37:19 +01:00
AtlasImage *texture;
Entity *owner;
Entity *target;
2015-10-20 13:51:49 +02:00
Bullet *next;
};
2015-12-13 15:50:54 +01:00
struct Debris {
float x;
float y;
float dx;
float dy;
int health;
int thinkTime;
float angle;
2018-12-06 09:37:19 +01:00
AtlasImage *texture;
2015-12-13 15:50:54 +01:00
Debris *next;
};
2015-10-20 13:51:49 +02:00
typedef struct {
float x;
float y;
float speed;
} Star;
struct Pulse {
int x;
int y;
float size;
int life;
int r, g, b;
Pulse *next;
};
struct Effect {
int type;
float x;
float y;
float dx;
float dy;
float health;
2015-11-29 09:34:25 +01:00
float size;
float scaleAmount;
2015-10-20 13:51:49 +02:00
int r;
int g;
int b;
int a;
2018-12-06 09:37:19 +01:00
AtlasImage *texture;
2015-10-20 13:51:49 +02:00
Effect *next;
};
struct Location {
int active;
char name[MAX_NAME_LENGTH];
int x;
int y;
int size;
Location *next;
};
2015-10-20 13:51:49 +02:00
struct Objective {
2015-10-29 12:08:47 +01:00
int active;
2016-03-27 12:21:23 +02:00
char id[MAX_DESCRIPTION_LENGTH];
2015-10-20 13:51:49 +02:00
char description[MAX_DESCRIPTION_LENGTH];
char targetName[MAX_NAME_LENGTH];
int targetType;
2015-10-20 13:51:49 +02:00
int currentValue;
int targetValue;
int status;
int isCondition;
int isEliminateAll;
2016-03-27 12:21:23 +02:00
int hideNumbers;
2015-10-20 13:51:49 +02:00
Objective *next;
};
struct Challenge {
int type;
2016-02-27 17:16:21 +01:00
int value;
2015-10-20 13:51:49 +02:00
int passed;
Challenge *next;
};
typedef struct {
int isChallenge;
int timeLimit;
int killLimit;
int lossLimit;
int itemLimit;
2016-05-15 09:19:26 +02:00
int playerItemLimit;
int escapeLimit;
2016-03-04 23:59:16 +01:00
int waypointLimit;
2016-03-12 19:22:48 +01:00
int rescueLimit;
2016-05-15 09:19:26 +02:00
int disableLimit;
2016-05-25 13:25:13 +02:00
int surrenderLimit;
2016-03-02 23:19:26 +01:00
int noMissiles;
int noBoost;
int noECM;
int noGuns;
int allowPlayerDeath;
2016-05-15 09:19:26 +02:00
int clearWaypointEnemies;
int eliminateThreats;
int isDeathMatch;
Challenge *challenges[MAX_CHALLENGES];
} ChallengeData;
2015-10-20 13:51:49 +02:00
struct Mission {
char name[MAX_NAME_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
char filename[MAX_DESCRIPTION_LENGTH];
int requires;
int requiresOptional;
2016-06-03 15:10:22 +02:00
int expires;
2015-10-20 13:51:49 +02:00
char pilot[MAX_NAME_LENGTH];
char squadron[MAX_NAME_LENGTH];
char craft[MAX_NAME_LENGTH];
int available;
int completed;
2016-02-27 17:16:21 +01:00
int completedChallenges;
int totalChallenges;
2016-02-28 14:02:57 +01:00
int epic;
int isOptional;
ChallengeData challengeData;
2016-02-28 14:02:57 +01:00
SDL_Rect rect;
2015-10-20 13:51:49 +02:00
Mission *next;
};
struct StarSystem {
char name[MAX_NAME_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
int side;
int x;
int y;
int completedMissions;
int totalMissions;
2016-02-21 17:55:11 +01:00
int availableMissions;
int fallsToPandorans;
int type;
2016-06-07 10:24:09 +02:00
Mission *activeMission;
2016-02-27 17:16:21 +01:00
Mission missionHead;
2015-10-20 13:51:49 +02:00
StarSystem *next;
};
2016-02-21 08:48:22 +01:00
struct Quadtree {
int depth;
int x, y, w, h;
Entity **ents;
int capacity;
2016-02-21 08:48:22 +01:00
int numEnts;
int addedTo;
2016-02-21 08:48:22 +01:00
Quadtree *node[4];
2015-11-01 23:19:39 +01:00
};
2016-03-27 12:21:23 +02:00
struct Spawner {
char name[MAX_NAME_LENGTH];
char **types;
int numTypes;
int side;
int time;
int interval;
int total;
int step;
int offscreen;
int active;
char flags[MAX_DESCRIPTION_LENGTH];
char aiFlags[MAX_DESCRIPTION_LENGTH];
2016-03-27 12:21:23 +02:00
Spawner *next;
};
2015-10-20 13:51:49 +02:00
typedef struct {
SDL_Point camera;
2015-10-20 13:51:49 +02:00
int numAllies;
int numEnemies;
2015-11-22 14:06:19 +01:00
int numInitialEnemies;
2015-10-20 13:51:49 +02:00
int status;
2016-02-28 14:02:57 +01:00
int isEpic;
int unlimitedEnemies;
int epicFighterLimit;
int epicLives;
int epicKills;
int playerSelect;
int manualComplete;
int unwinnable;
int waypointAutoAdvance;
2015-10-20 13:51:49 +02:00
int missionFinishedTimer;
int boostTimer;
int ecmTimer;
2015-11-26 11:54:40 +01:00
int radarRange;
int numPlayerGuns;
int numObjectivesComplete, numObjectivesTotal, numConditions;
2016-05-15 09:19:26 +02:00
int scriptedEnd;
int hasThreats;
int hasSuspicionLevel;
int suspicionLevel;
int suspicionCoolOff;
2016-05-20 10:51:34 +02:00
int zackariaSuspicionLevel;
int incomingMissile;
2016-05-30 12:58:16 +02:00
int destroyTorelli;
float torelliFireStormAlpha;
int campaignFinished;
Entity *missionTarget;
Entity *jumpgate;
2016-05-15 09:19:26 +02:00
Entity *messageSpeaker;
Entity *lastKilledPlayer;
2018-12-06 09:37:19 +01:00
SDL_Texture *background;
AtlasImage *planetTexture, *fireStormTexture;
2015-10-20 13:51:49 +02:00
PointF planet;
2016-02-21 14:47:10 +01:00
int planetWidth, planetHeight;
2015-10-26 18:27:43 +01:00
Entity entityHead, *entityTail;
2015-10-20 13:51:49 +02:00
Bullet bulletHead, *bulletTail;
2015-12-13 15:50:54 +01:00
Debris debrisHead, *debrisTail;
2015-10-20 13:51:49 +02:00
Effect effectHead, *effectTail;
Objective objectiveHead, *objectiveTail;
Location locationHead, *locationTail;
2016-03-27 12:21:23 +02:00
Spawner spawnerHead, *spawnerTail;
struct cJSON *missionJSON;
unsigned int stats[STAT_MAX];
2016-02-21 08:48:22 +01:00
Quadtree quadtree;
2015-10-20 13:51:49 +02:00
} Battle;
struct ScriptRunner {
struct cJSON *line;
long delay;
int waitForMessageBox;
ScriptRunner *next;
};
2016-03-03 19:03:07 +01:00
struct Trophy {
char id[MAX_NAME_LENGTH];
char title[MAX_DESCRIPTION_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
2016-05-15 09:19:26 +02:00
char awardDateStr[MAX_NAME_LENGTH];
2016-03-03 19:03:07 +01:00
int value;
2016-03-06 18:13:34 +01:00
int hidden;
2016-03-09 13:31:33 +01:00
int stat;
int statValue;
2016-03-03 19:03:07 +01:00
int awarded;
unsigned long awardDate;
int notify;
Trophy *next;
};
2016-05-15 09:19:26 +02:00
typedef struct {
int friendlyFire;
int autoSwitchPlayerTarget;
int missileReTarget;
int healthBars;
} Gameplay;
2016-05-17 20:02:58 +02:00
struct Tuple {
char key[MAX_NAME_LENGTH];
int value;
Tuple *next;
};
2015-10-20 13:51:49 +02:00
typedef struct {
2016-02-27 13:14:05 +01:00
StarSystem starSystemHead;
Mission challengeMissionHead;
2015-10-20 13:51:49 +02:00
Mission *currentMission;
char selectedStarSystem[MAX_NAME_LENGTH];
int completedMissions;
2016-02-21 17:55:11 +01:00
int availableMissions;
int totalMissions;
int completedChallenges;
int totalChallenges;
unsigned int stats[STAT_MAX];
2016-03-03 19:03:07 +01:00
Trophy trophyHead;
2016-05-17 20:02:58 +02:00
Tuple fighterStatHead;
2015-10-20 13:51:49 +02:00
} Game;
struct Widget {
char name[MAX_NAME_LENGTH];
char group[MAX_NAME_LENGTH];
int type;
int value;
char text[MAX_NAME_LENGTH];
char **options;
int numOptions;
int visible;
int enabled;
2016-02-23 23:20:07 +01:00
int isModal;
2015-10-20 13:51:49 +02:00
SDL_Rect rect;
2018-12-06 09:37:19 +01:00
AtlasImage *texture;
2015-10-20 13:51:49 +02:00
void (*action)(void);
void (*onChange)(char *value);
2015-11-26 09:16:29 +01:00
Widget *parent;
2015-10-20 13:51:49 +02:00
Widget *next;
};
struct HudMessage {
char message[MAX_DESCRIPTION_LENGTH];
SDL_Color color;
int life;
HudMessage *next;
};
struct MessageBox {
char title[MAX_NAME_LENGTH];
char body[MAX_DESCRIPTION_LENGTH];
int time;
int height;
int type;
MessageBox *next;
};
2015-11-23 15:52:11 +01:00
typedef struct {
int x;
int y;
int w;
int h;
int dx;
int dy;
2015-11-23 15:52:11 +01:00
int button[MAX_MOUSE_BUTTONS];
} Mouse;
2015-10-20 13:51:49 +02:00
typedef struct {
char saveDir[MAX_FILENAME_LENGTH];
2016-05-15 09:19:26 +02:00
int saveGame;
2015-10-20 13:51:49 +02:00
int winWidth;
int winHeight;
2018-12-17 09:30:47 +01:00
SDL_Point uiOffset;
2015-10-20 13:51:49 +02:00
int fullscreen;
int musicVolume;
int soundVolume;
2017-05-26 08:48:10 +02:00
int vSync;
int doTrophyAlerts;
2016-06-01 10:55:44 +02:00
int hideMouse;
2016-05-15 09:19:26 +02:00
Gameplay gameplay;
2015-11-23 15:52:11 +01:00
Mouse mouse;
2018-12-12 09:32:32 +01:00
PointF uiMouse;
2015-10-20 13:51:49 +02:00
int keyboard[MAX_KEYBOARD_KEYS];
SDL_Texture *backBuffer;
2018-12-12 09:32:32 +01:00
SDL_Texture *uiBuffer;
2015-10-20 13:51:49 +02:00
SDL_Renderer *renderer;
SDL_Window *window;
Delegate delegate;
2016-02-23 08:19:31 +01:00
ModalDialog modalDialog;
int awaitingWidgetInput;
int lastKeyPressed;
int lastButtonPressed;
2016-03-03 19:03:07 +01:00
int keyControls[CONTROL_MAX];
int mouseControls[CONTROL_MAX];
2018-12-06 09:37:19 +01:00
int textWidth;
2015-10-20 13:51:49 +02:00
} App;
typedef struct {
SDL_Color red;
SDL_Color orange;
SDL_Color yellow;
SDL_Color green;
SDL_Color blue;
SDL_Color cyan;
SDL_Color purple;
SDL_Color white;
SDL_Color black;
SDL_Color lightGrey;
SDL_Color darkGrey;
} Colors;
2016-02-27 13:14:05 +01:00
2016-05-29 10:38:05 +02:00
struct Credit {
char *text;
float y;
int size;
int h;
Credit *next;
};
2018-12-08 20:07:15 +01:00
struct Glyph {
char character[MAX_NAME_LENGTH];
SDL_Rect rect;
Glyph *next;
};
2018-12-06 09:37:19 +01:00
struct Font {
char name[MAX_NAME_LENGTH];
SDL_Texture *texture;
2018-12-08 20:07:15 +01:00
Glyph glyphHead[NUM_GLYPH_BUCKETS];
2018-12-06 09:37:19 +01:00
Font *next;
};
2016-04-12 09:41:13 +02:00
struct Bucket {
2016-02-27 13:14:05 +01:00
char *key, *value;
Bucket *next;
};
2016-04-12 09:41:13 +02:00
typedef struct {
2016-02-27 13:14:05 +01:00
Bucket **bucket;
int *bucketCount;
} HashTable;
2016-04-12 09:41:13 +02:00
typedef struct {
2016-02-27 13:14:05 +01:00
int32_t magicNumber, version, stringCount;
int32_t originalOffset, translationOffset;
} MOHeader;
2016-04-12 09:41:13 +02:00
typedef struct {
2016-02-27 13:14:05 +01:00
int32_t length, offset;
} MOEntry;