tbftss/src/structs.h

612 lines
11 KiB
C
Raw Normal View History

2015-10-20 13:51:49 +02:00
/*
Copyright (C) 2015-2019,2022 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.
*/
2022-07-31 11:43:20 +02:00
typedef struct Texture Texture;
typedef struct Lookup Lookup;
typedef struct Weapon Weapon;
typedef struct Quadtree Quadtree;
typedef struct Entity Entity;
typedef struct Bullet Bullet;
typedef struct Debris Debris;
typedef struct Effect Effect;
typedef struct Spawner Spawner;
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;
2022-07-31 11:43:20 +02:00
typedef struct Location Location;
typedef struct Bucket Bucket;
typedef struct Trophy Trophy;
typedef struct Tuple Tuple;
typedef struct Credit Credit;
typedef struct AtlasImage AtlasImage;
typedef struct Font Font;
typedef struct
{
int debug;
int takeScreenshots;
char *screenshotFolder;
2022-07-31 11:43:20 +02:00
int noAIWeapons;
int showFPS;
int playerImmortal;
int playerUnlimitedMissiles;
int noEntityActions;
int allImmortal;
int fps;
2015-12-18 11:12:37 +01:00
} Dev;
2022-07-31 11:43:20 +02:00
typedef struct
{
2015-10-20 13:51:49 +02:00
float x;
float y;
} PointF;
2022-07-31 11:43:20 +02:00
struct Texture
{
char name[MAX_DESCRIPTION_LENGTH];
long hash;
long ttl;
SDL_Texture *texture;
2022-07-31 11:43:20 +02:00
Texture *next;
2015-10-20 13:51:49 +02:00
};
2022-07-31 11:43:20 +02:00
struct AtlasImage
{
char filename[MAX_FILENAME_LENGTH];
SDL_Rect rect;
2018-12-06 09:37:19 +01:00
SDL_Texture *texture;
2022-07-31 11:43:20 +02:00
AtlasImage *next;
2018-12-06 09:37:19 +01:00
};
2022-07-31 11:43:20 +02:00
typedef struct
{
2015-10-20 13:51:49 +02:00
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;
2022-07-31 11:43:20 +02:00
typedef struct
{
int type;
2016-02-23 08:19:31 +01:00
char message[MAX_DESCRIPTION_LENGTH];
} ModalDialog;
2022-07-31 11:43:20 +02:00
struct Lookup
{
char name[MAX_NAME_LENGTH];
long value;
2015-10-20 13:51:49 +02:00
Lookup *next;
};
2022-07-31 11:43:20 +02:00
struct Weapon
{
2015-10-20 13:51:49 +02:00
int type;
int ammo;
int maxAmmo;
int x;
int y;
};
2022-07-31 11:43:20 +02:00
struct Entity
{
int type;
char name[MAX_NAME_LENGTH];
char defName[MAX_NAME_LENGTH];
char groupName[MAX_NAME_LENGTH];
char *description;
char affiliation[MAX_NAME_LENGTH];
int active;
int spawned;
int id;
int side;
float x;
float y;
int offsetX;
int offsetY;
int w;
int h;
float dx;
float dy;
float thrust;
float speed;
float angle;
int alive;
int health;
int maxHealth;
int shield;
int maxShield;
int reload;
int reloadTime;
int selectedGunType;
int combinedGuns;
int shieldRecharge;
int shieldRechargeRate;
int systemPower;
int armourHit;
int shieldHit;
int systemHit;
int thinkTime;
int aiActionTime;
int aiAggression;
int aiDamagePerSec;
int aiDamageTimer;
int aiEvadeTimer;
int separationRadius;
int deathType;
Weapon guns[MAX_FIGHTER_GUNS];
int missiles;
long flags;
long aiFlags;
SDL_Point targetLocation;
2022-07-31 11:43:20 +02:00
Entity *towing;
Entity *target;
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;
2022-07-31 11:43:20 +02:00
Entity *next;
2015-10-20 13:51:49 +02:00
};
2022-07-31 11:43:20 +02:00
struct Bullet
{
int type;
float x;
float y;
int w;
int h;
float dx;
float dy;
int sound;
int life;
int damage;
int angle;
long flags;
2018-12-06 09:37:19 +01:00
AtlasImage *texture;
2022-07-31 11:43:20 +02:00
Entity *owner;
Entity *target;
Bullet *next;
2015-10-20 13:51:49 +02:00
};
2022-07-31 11:43:20 +02: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;
2022-07-31 11:43:20 +02:00
Debris *next;
2015-12-13 15:50:54 +01:00
};
2022-07-31 11:43:20 +02:00
typedef struct
{
2015-10-20 13:51:49 +02:00
float x;
float y;
float speed;
} Star;
2022-07-31 11:43:20 +02:00
struct Pulse
{
int x;
int y;
float size;
int life;
int r, g, b;
2015-10-20 13:51:49 +02:00
Pulse *next;
};
2022-07-31 11:43:20 +02:00
struct Effect
{
int type;
float x;
float y;
float dx;
float dy;
float health;
float size;
float scaleAmount;
int r;
int g;
int b;
int a;
2018-12-06 09:37:19 +01:00
AtlasImage *texture;
2022-07-31 11:43:20 +02:00
Effect *next;
2015-10-20 13:51:49 +02:00
};
2022-07-31 11:43:20 +02:00
struct Location
{
int active;
char name[MAX_NAME_LENGTH];
int x;
int y;
int size;
Location *next;
};
2022-07-31 11:43:20 +02:00
struct Objective
{
int active;
char id[MAX_DESCRIPTION_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
char targetName[MAX_NAME_LENGTH];
int targetType;
int currentValue;
int targetValue;
int status;
int isCondition;
int isEliminateAll;
int hideNumbers;
2015-10-20 13:51:49 +02:00
Objective *next;
};
2022-07-31 11:43:20 +02:00
struct Challenge
{
int type;
int value;
int passed;
2015-10-20 13:51:49 +02:00
Challenge *next;
};
2022-07-31 11:43:20 +02:00
typedef struct
{
int isChallenge;
int timeLimit;
int killLimit;
int lossLimit;
int itemLimit;
int playerItemLimit;
int escapeLimit;
int waypointLimit;
int rescueLimit;
int disableLimit;
int surrenderLimit;
int noMissiles;
int noBoost;
int noECM;
int noGuns;
int allowPlayerDeath;
int clearWaypointEnemies;
int eliminateThreats;
int isDeathMatch;
Challenge *challenges[MAX_CHALLENGES];
} ChallengeData;
2022-07-31 11:43:20 +02:00
struct Mission
{
2015-10-20 13:51:49 +02:00
char name[MAX_NAME_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
char filename[MAX_DESCRIPTION_LENGTH];
int requires;
2022-07-31 11:43:20 +02:00
int requiresOptional;
int expires;
char pilot[MAX_NAME_LENGTH];
char squadron[MAX_NAME_LENGTH];
char craft[MAX_NAME_LENGTH];
int available;
int completed;
int completedChallenges;
int totalChallenges;
int epic;
int isOptional;
ChallengeData challengeData;
2022-07-31 11:43:20 +02:00
SDL_Rect rect;
Mission *next;
2015-10-20 13:51:49 +02:00
};
2022-07-31 11:43:20 +02:00
struct StarSystem
{
char name[MAX_NAME_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
int side;
int x;
int y;
int completedMissions;
int totalMissions;
int availableMissions;
int fallsToPandorans;
int type;
Mission *activeMission;
Mission missionHead;
2015-10-20 13:51:49 +02:00
StarSystem *next;
};
2022-07-31 11:43:20 +02:00
struct Quadtree
{
int depth;
int x, y, w, h;
Entity **ents;
int capacity;
int numEnts;
int addedTo;
2016-02-21 08:48:22 +01:00
Quadtree *node[4];
2015-11-01 23:19:39 +01:00
};
2022-07-31 11:43:20 +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;
};
2022-07-31 11:43:20 +02:00
typedef struct
{
SDL_Point camera;
int numAllies;
int numEnemies;
int numInitialEnemies;
int status;
int isEpic;
int unlimitedEnemies;
int epicFighterLimit;
int epicLives;
int epicKills;
int playerSelect;
int manualComplete;
int unwinnable;
int waypointAutoAdvance;
int missionFinishedTimer;
int boostTimer;
int ecmTimer;
int radarRange;
int numPlayerGuns;
int numObjectivesComplete, numObjectivesTotal, numConditions;
int scriptedEnd;
int hasThreats;
int hasSuspicionLevel;
int suspicionLevel;
int suspicionCoolOff;
int zackariaSuspicionLevel;
int incomingMissile;
int destroyTorelli;
float torelliFireStormAlpha;
int campaignFinished;
Entity *missionTarget;
Entity *jumpgate;
Entity *messageSpeaker;
Entity *lastKilledPlayer;
SDL_Texture *background;
AtlasImage *planetTexture, *fireStormTexture;
PointF planet;
int planetWidth, planetHeight;
Entity entityHead, *entityTail;
Bullet bulletHead, *bulletTail;
Debris debrisHead, *debrisTail;
Effect effectHead, *effectTail;
Objective objectiveHead, *objectiveTail;
Location locationHead, *locationTail;
Spawner spawnerHead, *spawnerTail;
struct cJSON *missionJSON;
2022-07-31 11:43:20 +02:00
unsigned int stats[STAT_MAX];
Quadtree quadtree;
2015-10-20 13:51:49 +02:00
} Battle;
2022-07-31 11:43:20 +02:00
struct ScriptRunner
{
struct cJSON *line;
2022-07-31 11:43:20 +02:00
long delay;
int waitForMessageBox;
ScriptRunner *next;
};
2022-07-31 11:43:20 +02:00
struct Trophy
{
char id[MAX_NAME_LENGTH];
char title[MAX_DESCRIPTION_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
char awardDateStr[MAX_NAME_LENGTH];
int value;
int hidden;
int stat;
int statValue;
int awarded;
2016-03-03 19:03:07 +01:00
unsigned long awardDate;
2022-07-31 11:43:20 +02:00
int notify;
Trophy *next;
2016-03-03 19:03:07 +01:00
};
2022-07-31 11:43:20 +02:00
typedef struct
{
2016-05-15 09:19:26 +02:00
int friendlyFire;
int autoSwitchPlayerTarget;
int missileReTarget;
int healthBars;
} Gameplay;
2022-07-31 11:43:20 +02:00
struct Tuple
{
char key[MAX_NAME_LENGTH];
int value;
2016-05-17 20:02:58 +02:00
Tuple *next;
};
2022-07-31 11:43:20 +02:00
typedef struct
{
StarSystem starSystemHead;
Mission challengeMissionHead;
Mission *currentMission;
char selectedStarSystem[MAX_NAME_LENGTH];
int completedMissions;
int availableMissions;
int totalMissions;
int completedChallenges;
int totalChallenges;
unsigned int stats[STAT_MAX];
2022-07-31 11:43:20 +02:00
Trophy trophyHead;
Tuple fighterStatHead;
2015-10-20 13:51:49 +02:00
} Game;
2022-07-31 11:43:20 +02:00
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;
int isModal;
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;
};
2022-07-31 11:43:20 +02:00
struct HudMessage
{
char message[MAX_DESCRIPTION_LENGTH];
SDL_Color color;
int life;
2015-10-20 13:51:49 +02:00
HudMessage *next;
};
2022-07-31 11:43:20 +02:00
struct MessageBox
{
char title[MAX_NAME_LENGTH];
char body[MAX_DESCRIPTION_LENGTH];
int time;
int height;
int type;
MessageBox *next;
};
2022-07-31 11:43:20 +02:00
typedef struct
{
2015-11-23 15:52:11 +01:00
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;
2022-07-31 11:43:20 +02:00
typedef struct
{
char saveDir[MAX_FILENAME_LENGTH];
int saveGame;
int winWidth;
int winHeight;
SDL_Point uiOffset;
int fullscreen;
int musicVolume;
int soundVolume;
int vSync;
int doTrophyAlerts;
int hideMouse;
Gameplay gameplay;
Mouse mouse;
PointF uiMouse;
int keyboard[MAX_KEYBOARD_KEYS];
SDL_Texture *backBuffer;
SDL_Texture *uiBuffer;
2015-10-20 13:51:49 +02:00
SDL_Renderer *renderer;
2022-07-31 11:43:20 +02:00
SDL_Window *window;
Delegate delegate;
ModalDialog modalDialog;
int awaitingWidgetInput;
int lastKeyPressed;
int lastButtonPressed;
int keyControls[CONTROL_MAX];
int mouseControls[CONTROL_MAX];
int textWidth;
2015-10-20 13:51:49 +02:00
} App;
2022-07-31 11:43:20 +02:00
typedef struct
{
2015-10-20 13:51:49 +02:00
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
2022-07-31 11:43:20 +02:00
struct Credit
{
char *text;
float y;
int size;
int h;
2016-05-29 10:38:05 +02:00
Credit *next;
};
2022-07-31 11:43:20 +02:00
struct Font
{
char name[MAX_NAME_LENGTH];
2018-12-06 09:37:19 +01:00
SDL_Texture *texture;
2022-07-31 11:43:20 +02:00
SDL_Rect glyphs[MAX_GLYPHS];
Font *next;
2018-12-06 09:37:19 +01:00
};
2022-07-31 11:43:20 +02:00
struct Bucket
{
char *key, *value;
2016-02-27 13:14:05 +01:00
Bucket *next;
};
2022-07-31 11:43:20 +02:00
typedef struct
{
2016-02-27 13:14:05 +01:00
Bucket **bucket;
2022-07-31 11:43:20 +02:00
int *bucketCount;
2016-02-27 13:14:05 +01:00
} HashTable;
2022-07-31 11:43:20 +02:00
typedef struct
{
2016-02-27 13:14:05 +01:00
int32_t magicNumber, version, stringCount;
int32_t originalOffset, translationOffset;
} MOHeader;
2022-07-31 11:43:20 +02:00
typedef struct
{
2016-02-27 13:14:05 +01:00
int32_t length, offset;
} MOEntry;