blobwarsAttrition/src/structs.h

524 lines
9.4 KiB
C
Raw Normal View History

2018-01-21 10:31:38 +01:00
/*
Copyright (C) 2018 Parallel Realities
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;
2018-01-21 12:31:53 +01:00
typedef struct Quadtree Quadtree;
2018-01-21 13:19:07 +01:00
typedef struct Objective Objective;
typedef struct Trigger Trigger;
2018-01-22 19:15:33 +01:00
typedef struct Marker Marker;
2018-01-23 08:42:13 +01:00
typedef struct Particle Particle;
typedef struct Sprite Sprite;
2018-01-24 08:16:52 +01:00
typedef struct Tuple Tuple;
typedef struct HubMission HubMission;
2018-01-24 09:14:11 +01:00
typedef struct Widget Widget;
2018-01-24 09:43:08 +01:00
typedef struct Atlas Atlas;
2018-01-28 17:33:37 +01:00
typedef struct Bucket Bucket;
2018-01-29 23:12:18 +01:00
typedef struct EntityDef EntityDef;
2018-02-14 20:12:29 +01:00
typedef struct Trophy Trophy;
2018-01-30 23:47:40 +01:00
typedef struct cJSON cJSON;
typedef struct Entity Entity;
typedef struct EntityExt EntityExt;
typedef struct Bob Bob;
typedef struct Boss Boss;
2018-01-27 09:13:50 +01:00
typedef struct Bullet Bullet;
typedef struct Decoration Decoration;
typedef struct Item Item;
typedef struct MIA MIA;
typedef struct Structure Structure;
typedef struct Trap Trap;
typedef struct Unit Unit;
2018-01-21 10:31:38 +01:00
typedef struct {
int debug;
int takeScreenshots;
char *screenshotFolder;
int showFPS;
2018-01-24 08:16:52 +01:00
int cheatHealth;
int cheatPower;
int cheatOxygen;
int cheatKeys;
int cheatLevels;
int cheatReload;
int cheatBlind;
2018-02-02 20:10:12 +01:00
int cheatNoEnemies;
int cheatStatic;
2018-01-21 10:31:38 +01:00
int fps;
} Dev;
struct Texture {
char name[MAX_DESCRIPTION_LENGTH];
long hash;
long ttl;
SDL_Texture *texture;
Texture *next;
};
typedef struct {
float x;
float y;
} PointF;
2018-01-21 10:31:38 +01:00
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;
struct Lookup {
char name[MAX_NAME_LENGTH];
long value;
Lookup *next;
};
2018-01-29 23:12:18 +01:00
struct EntityDef {
char name[MAX_NAME_LENGTH];
Entity *(*initFunc)(void);
EntityDef *next;
};
2018-01-21 10:31:38 +01: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;
struct Entity {
2018-01-24 20:04:36 +01:00
unsigned long uniqueId;
2018-01-21 13:57:01 +01:00
int type;
char name[MAX_NAME_LENGTH];
float x, y;
int w, h;
int tx, ty;
float dx, dy;
int health, healthMax;
2018-01-21 13:57:01 +01:00
int alive;
int active;
int environment;
int thinkTime;
2018-01-21 17:50:14 +01:00
int facing;
2018-01-30 00:00:14 +01:00
Sprite *sprite[3];
2018-01-31 23:54:14 +01:00
int spriteTime;
int spriteFrame;
int plane;
2018-01-21 17:50:14 +01:00
int isSolid;
2018-01-24 20:04:36 +01:00
int isStatic;
int isOnGround;
2018-02-06 08:32:08 +01:00
int isVisible;
2018-01-24 20:04:36 +01:00
int isMissionTarget;
2018-02-02 20:10:12 +01:00
int observationTime;
2018-02-03 09:44:02 +01:00
Entity *riding;
Entity *owner;
unsigned long flags;
void (*init)(void);
void (*action)(void);
void (*touch)(Entity *other);
void (*tick)(void);
void (*reset)(void);
void (*die)(void);
void (*animate)(void);
void (*walk)(void);
float (*bounce)(float x);
void (*teleport)(float tx, float ty);
void (*activate)(int active);
void (*applyDamage)(int amount);
void (*changeEnvironment)(void);
SDL_Rect *(*getCurrentSprite)(void);
2018-01-30 23:47:40 +01:00
void (*load)(cJSON *root);
void (*save)(cJSON *root);
Entity *next;
};
struct EntityExt {
struct Entity;
char spriteName[MAX_NAME_LENGTH];
Item *carriedItem;
};
struct Unit {
struct EntityExt;
2018-01-31 09:08:50 +01:00
char *unitType;
int weaponType;
2018-01-24 23:15:24 +01:00
int canCarryItem;
int reload;
int shotsToFire;
int maxShotsToFire;
2018-01-24 23:15:24 +01:00
int spawnedInTimer;
int oxygen;
int spawnedIn;
2018-01-29 23:12:18 +01:00
int returnToStartTimer;
int startX, startY;
2018-01-29 23:12:18 +01:00
void (*preFire)(void);
void (*attack)(void);
int (*canFire)(Entity *target);
};
struct MIA {
struct Unit;
2018-01-25 08:41:10 +01:00
int shudderTimer;
int starTimer;
int teleportTimer;
};
struct Boss {
struct Unit;
int weakAgainst;
int teleportTimer;
int stunTimer;
};
struct Item {
struct EntityExt;
int startX, startY;
2018-01-26 20:14:18 +01:00
int power;
int value;
int weaponType;
int provided;
2018-01-26 20:14:18 +01:00
int collected;
int canBeCarried;
int canBePickedUp;
};
struct Bob {
struct Unit;
int checkpointTimer;
int outTimer;
int stunTimer;
int immuneTimer;
2018-02-04 09:20:49 +01:00
float power, powerMax;
int jpEffectTimer;
PointF checkpoints[MAX_CHECKPOINTS];
Item *items[MAX_ITEMS];
};
struct Structure {
struct EntityExt;
2018-01-27 09:53:08 +01:00
int bobTouching;
2018-01-27 11:47:53 +01:00
char requiredItem[MAX_NAME_LENGTH];
char targetNames[MAX_DESCRIPTION_LENGTH];
char message[MAX_DESCRIPTION_LENGTH];
2018-01-27 11:21:45 +01:00
int state;
2018-01-27 11:58:47 +01:00
int waitTime;
int startX, startY;
int closedX, closedY;
int isLocked;
int speed;
int requiredPower;
2018-01-27 12:22:29 +01:00
int isWeighted;
int weightApplied;
float sinVal;
};
struct Decoration {
struct Entity;
int effectType;
int bleedTime;
};
struct Trap {
struct EntityExt;
2018-01-27 12:55:15 +01:00
int onTime;
int offTime;
2018-01-21 10:31:38 +01:00
};
2018-01-21 13:19:07 +01:00
struct Objective {
char id[MAX_NAME_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
char targetName[MAX_NAME_LENGTH];
int currentValue;
int targetValue;
int totalValue;
int required;
Objective *next;
};
/* How you going, Dave? */
struct Trigger {
char name[MAX_NAME_LENGTH];
char message[MAX_DESCRIPTION_LENGTH];
char targetNames[MAX_DESCRIPTION_LENGTH];
int x;
int y;
int w;
int h;
Trigger *next;
};
2018-01-24 08:16:52 +01:00
struct HubMission {
char id[MAX_NAME_LENGTH];
char name[MAX_NAME_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
2018-01-28 17:33:37 +01:00
int x;
int y;
2018-01-24 08:16:52 +01:00
int status;
int unlockCount;
float distance;
HubMission *next;
};
struct Tuple {
char key[MAX_NAME_LENGTH];
union {
char s[MAX_NAME_LENGTH];
int i;
float f;
} value;
Tuple *next;
};
2018-02-15 22:38:26 +01: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;
unsigned long awardDate;
int notify;
Trophy *next;
};
2018-01-21 12:12:49 +01:00
typedef struct {
float shakeAmount;
int x;
int y;
} Camera;
2018-01-21 10:31:38 +01:00
typedef struct {
int x;
int y;
int w;
int h;
int dx;
int dy;
int button[MAX_MOUSE_BUTTONS];
int dragging;
} Mouse;
2018-02-08 22:53:32 +01:00
typedef struct {
int fullscreen;
int soundVolume;
int musicVolume;
int keyControls[CONTROL_MAX];
int joypadControls[CONTROL_MAX];
2018-02-12 23:40:15 +01:00
int hudInventory;
int blood;
2018-02-08 22:53:32 +01:00
} Config;
2018-01-21 10:31:38 +01:00
typedef struct {
char saveDir[MAX_FILENAME_LENGTH];
int winWidth;
int winHeight;
float scaleX;
float scaleY;
Mouse mouse;
2018-02-07 19:27:42 +01:00
SDL_Joystick *joypad;
2018-01-21 10:31:38 +01:00
int keyboard[MAX_KEYBOARD_KEYS];
2018-02-06 23:26:05 +01:00
int joypadButton[SDL_CONTROLLER_BUTTON_MAX];
2018-02-07 20:20:36 +01:00
int joypadAxis[JOYPAD_AXIS_MAX];
2018-01-21 10:31:38 +01:00
SDL_Texture *backBuffer;
SDL_Renderer *renderer;
SDL_Window *window;
Delegate delegate;
int awaitingWidgetInput;
int lastKeyPressed;
int lastButtonPressed;
2018-02-08 22:53:32 +01:00
Config config;
2018-01-21 10:31:38 +01:00
} App;
2018-01-24 08:16:52 +01:00
typedef struct {
int cells;
int hearts;
int totalMIAs;
int totalTargets;
int totalCells;
int totalHearts;
int totalKeys;
2018-02-13 22:36:42 +01:00
unsigned int stats[STAT_MAX];
2018-01-24 08:16:52 +01:00
char worldId[MAX_NAME_LENGTH];
int isComplete;
2018-02-05 23:08:35 +01:00
Tuple keys[MAX_KEY_TYPES];
2018-01-24 08:16:52 +01:00
Tuple missionStatusHead, *missionStatusTail;
2018-02-15 22:38:26 +01:00
Trophy trophyHead, *trophyTail;
2018-01-21 10:31:38 +01:00
} Game;
2018-01-21 12:12:49 +01:00
2018-01-22 19:15:33 +01:00
struct Marker {
2018-01-30 00:00:14 +01:00
Sprite *sprite;
2018-02-12 23:40:15 +01:00
float x, y;
2018-01-22 19:15:33 +01:00
float value;
2018-02-12 23:40:15 +01:00
int angle;
int visible;
int type;
2018-01-22 19:15:33 +01:00
Marker *next;
};
2018-01-21 12:12:49 +01:00
typedef struct {
int data[MAP_WIDTH][MAP_HEIGHT];
int decal[MAP_WIDTH][MAP_HEIGHT];
SDL_Rect bounds;
} Map;
2018-01-21 12:31:53 +01:00
struct Quadtree {
int depth;
int x, y, w, h;
Entity **ents;
int capacity;
int numEnts;
int addedTo;
Quadtree *node[4];
};
2018-01-23 08:42:13 +01:00
struct Sprite {
2018-01-24 08:44:45 +01:00
char name[MAX_NAME_LENGTH];
2018-01-28 18:23:49 +01:00
int *times;
char **filenames;
2018-01-31 22:50:49 +01:00
Atlas **frames;
2018-01-24 08:44:45 +01:00
int currentFrame;
float currentTime;
int w;
int h;
2018-01-23 08:42:13 +01:00
int numFrames;
2018-01-24 08:44:45 +01:00
Sprite *next;
2018-01-23 08:42:13 +01:00
};
struct Particle {
int type;
int plane;
float health;
float x;
float y;
float dx;
float dy;
int size;
2018-02-04 17:14:14 +01:00
int r;
int g;
int b;
Sprite *sprite;
2018-01-30 00:00:14 +01:00
float spriteTime;
2018-01-23 08:42:13 +01:00
int spriteFrame;
int destroyAfterAnim;
int onScreen;
Particle *next;
};
2018-01-27 09:13:50 +01:00
struct Bullet {
struct Entity;
2018-01-27 09:13:50 +01:00
int damage;
int weaponType;
};
2018-01-21 12:12:49 +01:00
typedef struct {
2018-01-26 20:14:18 +01:00
char id[MAX_NAME_LENGTH];
2018-01-29 09:34:39 +01:00
char name[MAX_NAME_LENGTH];
int numEnemyTypes;
char **enemyTypes;
char tileset[MAX_NAME_LENGTH];
char music[MAX_FILENAME_LENGTH];
char background[MAX_FILENAME_LENGTH];
2018-01-27 09:03:26 +01:00
int state;
2018-01-29 09:34:39 +01:00
int minEnemySpawnTime, maxEnemySpawnTime;
unsigned long entityCounter;
2018-02-02 20:10:12 +01:00
int entityChaseTimer;
2018-01-21 13:57:01 +01:00
int allObjectivesComplete;
2018-01-24 23:15:24 +01:00
int frameCounter;
2018-01-21 13:57:01 +01:00
int currentStatus;
int missionType;
int isBossActive;
2018-01-27 11:32:17 +01:00
int isReturnVisit;
int missionCompleteTimer;
2018-02-02 20:10:12 +01:00
int observationTimer;
int gameOverTimer;
int betweenTimer;
2018-02-02 09:00:27 +01:00
int mapAnimTimer;
2018-02-02 20:10:12 +01:00
int enemySpawnTimer;
int helperItemTimer;
int spawnInterval;
int numToSpawn;
Bob *bob;
Boss *boss;
Entity *entityToTrack;
2018-02-03 09:44:02 +01:00
Entity *entitiesToObserve[MAX_ENTS_TO_OBSERVE];
2018-02-02 20:10:12 +01:00
Map map;
2018-01-21 12:31:53 +01:00
Quadtree quadtree;
2018-01-27 09:13:50 +01:00
Entity entityHead, *entityTail;
Particle particleHead, *particleTail;
2018-01-21 13:57:01 +01:00
Objective objectiveHead, *objectiveTail;
2018-01-21 13:19:07 +01:00
Trigger triggerHead, *triggerTail;
2018-01-21 12:12:49 +01:00
} World;
2018-01-24 09:14:11 +01:00
struct Widget {
2018-02-14 20:12:29 +01:00
char name[MAX_NAME_LENGTH];
char group[MAX_NAME_LENGTH];
char label[MAX_NAME_LENGTH];
2018-01-24 09:14:11 +01:00
int type;
int x;
int y;
2018-02-14 23:32:03 +01:00
int w;
int h;
2018-02-15 22:38:26 +01:00
int value;
int minValue;
int maxValue;
2018-01-24 09:14:11 +01:00
int visible;
int enabled;
2018-02-06 23:26:05 +01:00
int numOptions;
char **options;
2018-02-15 22:38:26 +01:00
void (*action)(void);
2018-01-24 09:14:11 +01:00
};
2018-01-24 09:43:08 +01:00
struct Atlas {
char filename[MAX_FILENAME_LENGTH];
SDL_Rect rect;
Atlas *next;
};
2018-01-28 17:33:37 +01:00
/* ===== i18n stuff ==== */
struct Bucket {
char *key, *value;
Bucket *next;
};
typedef struct {
Bucket **bucket;
int *bucketCount;
} HashTable;
typedef struct {
int32_t magicNumber, version, stringCount;
int32_t originalOffset, translationOffset;
} MOHeader;
typedef struct {
int32_t length, offset;
} MOEntry;