tbftss/src/structs.h

474 lines
8.3 KiB
C
Raw Normal View History

2015-10-20 13:51:49 +02:00
/*
2016-02-21 16:50:27 +01:00
Copyright (C) 2015-2016 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;
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;
2015-11-01 23:19:39 +01:00
typedef struct GridCell GridCell;
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;
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;
};
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];
int active;
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;
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);
SDL_Texture *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;
SDL_Texture *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;
SDL_Texture *texture;
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;
SDL_Texture *texture;
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;
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;
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;
int escapeLimit;
2016-03-04 23:59:16 +01:00
int waypointLimit;
2016-03-02 23:19:26 +01:00
int noMissiles;
int noBoost;
int noECM;
int noGuns;
int scriptedEnd;
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;
2015-10-20 13:51:49 +02:00
char pilot[MAX_NAME_LENGTH];
char squadron[MAX_NAME_LENGTH];
char craft[MAX_NAME_LENGTH];
2016-03-03 19:03:07 +01:00
char trophyId[MAX_NAME_LENGTH];
2015-10-20 13:51:49 +02:00
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;
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 isSol;
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;
Quadtree *node[4];
2015-11-01 23:19:39 +01:00
};
2015-10-20 13:51:49 +02:00
typedef struct {
int entId;
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 epicFighterLimit;
int playerSelect;
int manualComplete;
int unwinnable;
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;
2015-10-20 13:51:49 +02:00
int numObjectivesComplete, numObjectivesTotal;
Entity *missionTarget;
Entity *jumpgate;
2015-10-20 13:51:49 +02:00
SDL_Texture *background, *planetTexture;
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;
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];
int value;
2016-03-06 18:13:34 +01:00
int hidden;
2016-03-03 19:03:07 +01:00
int awarded;
unsigned long awardDate;
int notify;
Trophy *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;
unsigned int stats[STAT_MAX];
2016-03-03 19:03:07 +01:00
Trophy trophyHead;
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 currentOption;
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;
2015-11-26 09:16:29 +01:00
SDL_Texture *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;
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];
int winWidth;
int winHeight;
float scaleX;
float scaleY;
int fullscreen;
int musicVolume;
int soundVolume;
2015-11-23 15:52:11 +01:00
Mouse mouse;
2015-10-20 13:51:49 +02:00
int keyboard[MAX_KEYBOARD_KEYS];
SDL_Texture *backBuffer;
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];
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
struct Bucket
{
char *key, *value;
Bucket *next;
};
typedef struct
2016-02-27 13:14:05 +01:00
{
Bucket **bucket;
int *bucketCount;
} HashTable;
typedef struct
2016-02-27 13:14:05 +01:00
{
int32_t magicNumber, version, stringCount;
int32_t originalOffset, translationOffset;
} MOHeader;
typedef struct
2016-02-27 13:14:05 +01:00
{
int32_t length, offset;
} MOEntry;