[Change] Just some C correctiveness.
This commit is contained in:
parent
f9c778358c
commit
d2e952fb88
8
src/ai.h
8
src/ai.h
@ -9,11 +9,11 @@
|
||||
// Max number of AI timers.
|
||||
#define MAX_AI_TIMERS 2
|
||||
|
||||
typedef enum { TYPE_NULL, TYPE_INT, TYPE_PTR } TaskData;
|
||||
typedef enum TaskData_ { TYPE_NULL, TYPE_INT, TYPE_PTR } TaskData;
|
||||
|
||||
// Basic task.
|
||||
typedef struct Task {
|
||||
struct Task* next;
|
||||
typedef struct Task_ {
|
||||
struct Task_* next;
|
||||
char* name;
|
||||
|
||||
TaskData dtype;
|
||||
@ -24,7 +24,7 @@ typedef struct Task {
|
||||
} Task;
|
||||
|
||||
// Ai profile.
|
||||
typedef struct {
|
||||
typedef struct AI_Profile_ {
|
||||
char* name;
|
||||
lua_State* L;
|
||||
} AI_Profile;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Colours.
|
||||
typedef struct {
|
||||
typedef struct glColour_ {
|
||||
double r, g, b, a;
|
||||
} glColour;
|
||||
|
||||
|
@ -20,7 +20,7 @@ Faction* faction_stack = NULL;
|
||||
int nfactions = 0;
|
||||
|
||||
// Save alliance.
|
||||
typedef struct {
|
||||
typedef struct Alliance_ {
|
||||
char* name;
|
||||
Faction** factions;
|
||||
int nfactions;
|
||||
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct Faction {
|
||||
typedef struct Faction_ {
|
||||
char* name;
|
||||
|
||||
struct Faction** enemies;
|
||||
struct Factiona_** enemies;
|
||||
int nenemies;
|
||||
struct Faction** allies;
|
||||
struct Faction_** allies;
|
||||
int nallies;
|
||||
} Faction;
|
||||
|
||||
|
@ -2,12 +2,13 @@
|
||||
#include "opengl.h"
|
||||
|
||||
// Font info.
|
||||
typedef struct {
|
||||
typedef struct glFont_ {
|
||||
int h; // Height.
|
||||
int* w;
|
||||
GLuint* textures;
|
||||
GLuint list_base;
|
||||
} glFont;
|
||||
|
||||
extern glFont gl_defFont; // Default font.
|
||||
extern glFont gl_smallFont; // Small font.
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define KEY_RELEASE (-1.)
|
||||
|
||||
// Keybind structure.
|
||||
typedef struct {
|
||||
typedef struct Keybind_ {
|
||||
char* name; // Keybinding name, taken from keybindNames[]
|
||||
KeybindType type; // type, defined in player.h.
|
||||
unsigned int key; // Key/axis/button event number.
|
||||
|
@ -24,7 +24,7 @@
|
||||
extern SDL_mutex* sound_lock;
|
||||
|
||||
// Saves the music to ram in this structure.
|
||||
typedef struct {
|
||||
typedef struct alMusic_ {
|
||||
char name[32]; // Name.
|
||||
Packfile file;
|
||||
OggVorbis_File stream;
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define OPENGL_AA_LINE (1<<3)
|
||||
#define OPENGL_AA_POLYGON (1<<4)
|
||||
#define gl_has(f) (gl_screen.flags & (f)) // Check for the flag.
|
||||
typedef struct {
|
||||
typedef struct glInfo_ {
|
||||
int w, h; // Window dimensions.
|
||||
int depth; // Depth in bpp.
|
||||
int r, g, b, a; // Framebuffer values in bits.
|
||||
@ -36,7 +36,7 @@ extern glInfo gl_screen; // Local structure set with gl_init etc.
|
||||
#define COLOUR(x) glColor4d((x).r, (x).g, (x).b, (x).a)
|
||||
|
||||
// Spritesheet info.
|
||||
typedef struct {
|
||||
typedef struct glTexture_ {
|
||||
double w, h; // Real size of the image (excluding POT buffer.
|
||||
double rw, rh; // Size of POT surface.
|
||||
double sx, sy; // Number of sprites on x and y axes.
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define OUTFIT_PROP_WEAP_SECONDARY (1<<0)
|
||||
|
||||
// Outfit types.
|
||||
typedef enum {
|
||||
typedef enum OutfitType_ {
|
||||
OUTFIT_TYPE_NULL = 0,
|
||||
OUTFIT_TYPE_BOLT = 1,
|
||||
OUTFIT_TYPE_BEAM = 2,
|
||||
@ -24,7 +24,7 @@ typedef enum {
|
||||
} OutfitType;
|
||||
|
||||
// An outfit depends a lot on the type.
|
||||
typedef struct {
|
||||
typedef struct Outfit_ {
|
||||
char* name;
|
||||
|
||||
// General specs.
|
||||
|
@ -5,7 +5,7 @@
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
typedef struct {
|
||||
typedef struct Packfile_ {
|
||||
#ifdef _POSIX_SOURCE
|
||||
int fd; // File descriptor.
|
||||
#else
|
||||
|
@ -17,7 +17,7 @@
|
||||
double angle_diff(const double ref, double a);
|
||||
|
||||
// Base of 2D vectors.
|
||||
typedef struct {
|
||||
typedef struct Vec2_ {
|
||||
double x, y; // Cartesian values.
|
||||
double mod, angle; // Polar values.
|
||||
} Vec2;
|
||||
@ -33,13 +33,11 @@ double vect_angle(const Vec2* ref, const Vec2* v);
|
||||
void vect_cadd(Vec2* v, const double x, const double y);
|
||||
|
||||
// Describe any solid in 2D space.
|
||||
struct Solid {
|
||||
typedef struct Solid_ {
|
||||
double mass, dir, dir_vel; // Properties.
|
||||
Vec2 vel, pos, force; // Position/velocity vectors.
|
||||
void(*update)(struct Solid*, const double); // Update method.
|
||||
};
|
||||
|
||||
typedef struct Solid Solid;
|
||||
void(*update)(struct Solid_*, const double); // Update method.
|
||||
} Solid;
|
||||
|
||||
// Solid manipulation.
|
||||
void solid_init(Solid* dest, const double mass, const double dir,
|
||||
|
14
src/pilot.h
14
src/pilot.h
@ -36,14 +36,14 @@
|
||||
#define pilot_isPlayer(p) ((p)->flags & PILOT_PLAYER)
|
||||
#define pilot_isDisabled(p) ((p)->flags & PILOT_DISABLED)
|
||||
|
||||
typedef struct {
|
||||
typedef struct PilotOutfit_ {
|
||||
Outfit* outfit; // Associated outfit.
|
||||
unsigned int quantity; // Number of outfits of this type that the pilot has.
|
||||
unsigned int timer; // Used to store last used weapon time.
|
||||
} PilotOutfit;
|
||||
|
||||
// Primary pilot structure.
|
||||
typedef struct Pilot {
|
||||
typedef struct Pilot_ {
|
||||
unsigned int id; // Pilots id.
|
||||
char* name; // Pilot's name (if unique).
|
||||
|
||||
@ -58,9 +58,9 @@ typedef struct Pilot {
|
||||
double armour_max, shield_max, energy_max;
|
||||
double fuel; // Used only for jumps. TODO: make it do something.
|
||||
|
||||
void (*think)(struct Pilot*); // AI thinking for the pilot.
|
||||
void (*update)(struct Pilot*, const double); // Update the pilot.
|
||||
void (*render)(struct Pilot*); // Rendering the pilot.
|
||||
void (*think)(struct Pilot_*); // AI thinking for the pilot.
|
||||
void (*update)(struct Pilot_*, const double); // Update the pilot.
|
||||
void (*render)(struct Pilot_*); // Rendering the pilot.
|
||||
|
||||
// Outfit management.
|
||||
PilotOutfit* outfits;
|
||||
@ -80,13 +80,13 @@ typedef struct Pilot {
|
||||
} Pilot;
|
||||
|
||||
// Fleets.
|
||||
typedef struct {
|
||||
typedef struct FleetPilot_ {
|
||||
Ship* ship; // Ship that the pilot is flying.
|
||||
char* name; // For special 'unique' names.
|
||||
int chance; // Chance of this pilot appearing in the fleet.
|
||||
} FleetPilot;
|
||||
|
||||
typedef struct {
|
||||
typedef struct Fleet_ {
|
||||
char* name; // Fleet name, used as an identifier.
|
||||
Faction* faction; // Faction of the fleet.
|
||||
|
||||
|
@ -53,7 +53,7 @@ extern int pilots;
|
||||
extern StarSystem* systems;
|
||||
|
||||
// GUI crap.
|
||||
typedef struct {
|
||||
typedef struct Radar_ {
|
||||
double x,y; // Position.
|
||||
double w,h; // Dimensions.
|
||||
RadarShape shape;
|
||||
@ -66,12 +66,12 @@ typedef struct {
|
||||
#define RADAR_RES_INTERVAL 10.
|
||||
#define RADAR_RES_DEFAULT 40.
|
||||
|
||||
typedef struct {
|
||||
typedef struct Rect_ {
|
||||
double x,y;
|
||||
double w,h;
|
||||
} Rect;
|
||||
|
||||
typedef struct {
|
||||
typedef struct GUI_ {
|
||||
// Graphics.
|
||||
glTexture* gfx_frame;
|
||||
glTexture* gfx_targetPilot, *gfx_targetPlanet;
|
||||
@ -98,7 +98,7 @@ double gui_yoff = 0.;
|
||||
#define MSG_SIZE_MAX 80
|
||||
int msg_timeout = 5000;
|
||||
int msg_max = 5; // Max messages on screen.
|
||||
typedef struct {
|
||||
typedef struct Msg_ {
|
||||
char str[MSG_SIZE_MAX];
|
||||
unsigned int t;
|
||||
} Msg;
|
||||
|
@ -21,7 +21,7 @@ extern unsigned int player_flags;
|
||||
extern unsigned int credits;
|
||||
extern unsigned int combat_rating;
|
||||
|
||||
typedef enum { RADAR_RECT, RADAR_CIRCLE } RadarShape; // For render functions.
|
||||
typedef enum RadarShape_ { RADAR_RECT, RADAR_CIRCLE } RadarShape; // For render functions.
|
||||
|
||||
// Creation.
|
||||
void player_new(void);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define SHIP_TARGET_W 128
|
||||
#define SHIP_TARGET_H 96
|
||||
|
||||
typedef enum {
|
||||
typedef enum ShipClass_ {
|
||||
SHIP_CLASS_NULL = 0,
|
||||
SHIP_CLASS_CIV_LIGHT = 1,
|
||||
SHIP_CLASS_CIV_MEDIUM = 2,
|
||||
@ -15,15 +15,15 @@ typedef enum {
|
||||
} ShipClass;
|
||||
|
||||
// Small wrapper for the outfits.
|
||||
typedef struct ShipOutfit {
|
||||
struct ShipOutfit* next; // Linked list.
|
||||
typedef struct ShipOutfit_ {
|
||||
struct ShipOutfit_* next; // Linked list.
|
||||
Outfit* data; // Data itself.
|
||||
int quantity;
|
||||
} ShipOutfit;
|
||||
|
||||
|
||||
// Ship structure.
|
||||
typedef struct {
|
||||
typedef struct Ship_ {
|
||||
char* name; // Ship name.
|
||||
ShipClass class; // Ship class.
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#define SOUND_SUFFIX ".wav"
|
||||
|
||||
// Give the buffers a name.
|
||||
typedef struct {
|
||||
typedef struct alSound_ {
|
||||
char* name; // Buffers name.
|
||||
ALuint buffer; // Associated OpenAL buffer.
|
||||
} alSound;
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define SOUND_MAX_DIST 1000.
|
||||
|
||||
// Virtual voice.
|
||||
typedef struct {
|
||||
typedef struct alVoice_ {
|
||||
ALuint source; // Source itself, 0 if not set.
|
||||
ALuint buffer; // Buffer.
|
||||
|
||||
|
@ -44,7 +44,7 @@ char* stardate = "Stardate";
|
||||
unsigned int date = 0; // time since epoch.
|
||||
|
||||
#define STAR_BUF 100 // Area to leave around screen, more = less repitition.
|
||||
typedef struct {
|
||||
typedef struct Star_ {
|
||||
double x, y; // Position. It is simpler ligher to use two doubles than the physics.
|
||||
double brightness;
|
||||
} Star;
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define MAX_HYPERSPACE_VEL 25
|
||||
|
||||
// Planet types. I didn't take them from Star Trek, I promise.
|
||||
typedef enum {
|
||||
typedef enum PlanetClass_ {
|
||||
PLANET_CLASS_NULL = 0,
|
||||
PLANET_CLASS_A, // Geothermal.
|
||||
PLANET_CLASS_B, // Geomorteus.
|
||||
@ -41,7 +41,7 @@ typedef enum {
|
||||
#define PLANET_SERVICE_SHIPYARD (1<<3)
|
||||
#define planet_hasService(p,s) ((p)->services & s)
|
||||
|
||||
typedef struct {
|
||||
typedef struct Planet_ {
|
||||
char* name; // Planet name
|
||||
Vec2 pos; // Position in star system.
|
||||
|
||||
@ -56,12 +56,12 @@ typedef struct {
|
||||
} Planet;
|
||||
|
||||
// Star systems.
|
||||
typedef struct {
|
||||
typedef struct SystemFleet_ {
|
||||
Fleet* fleet; // Fleet to appear.
|
||||
int chance; // Chance of fleet appearing in the system.
|
||||
} SystemFleet;
|
||||
|
||||
typedef struct {
|
||||
typedef struct StarSystem_ {
|
||||
char* name; // Star system identifier.
|
||||
Vec2 pos; // Position.
|
||||
int stars, asteroids; // Un numero!
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "opengl.h"
|
||||
#include "toolkit.h"
|
||||
|
||||
typedef enum {
|
||||
typedef enum WidgetType_ {
|
||||
WIDGET_NULL,
|
||||
WIDGET_BUTTON,
|
||||
WIDGET_TEXT,
|
||||
@ -11,13 +11,13 @@ typedef enum {
|
||||
WIDGET_LIST
|
||||
} WidgetType;
|
||||
|
||||
typedef enum {
|
||||
typedef enum WidgetStatus_ {
|
||||
WIDGET_STATUS_NORMAL,
|
||||
WIDGET_STATUS_MOUSEOVER,
|
||||
WIDGET_STATUS_MOUSEDOWN,
|
||||
} WidgetStatus;
|
||||
|
||||
typedef struct {
|
||||
typedef struct Widget_ {
|
||||
char* name; // Widget name.
|
||||
WidgetType type; // type..
|
||||
|
||||
@ -52,7 +52,7 @@ typedef struct {
|
||||
};
|
||||
} Widget;
|
||||
|
||||
typedef struct {
|
||||
typedef struct Window_ {
|
||||
unsigned int id; // Unique identifier.
|
||||
char* name;
|
||||
|
||||
|
@ -24,7 +24,7 @@ extern int pilots;
|
||||
// Ai stuff.
|
||||
extern void ai_attacked(Pilot* attacked, const unsigned int attacker);
|
||||
|
||||
typedef struct Weapon {
|
||||
typedef struct Weapon_ {
|
||||
Solid* solid; // Actually has its own solid. :D
|
||||
|
||||
unsigned int parent; // The pilot that just shot at you!
|
||||
@ -35,8 +35,8 @@ typedef struct Weapon {
|
||||
alVoice* voice; // Virtual voise.
|
||||
|
||||
// Update position and render.
|
||||
void(*update)(struct Weapon*, const double, WeaponLayer); // Position update and render.
|
||||
void(*think)(struct Weapon*); // Some missiles need to be inteligent.
|
||||
void(*update)(struct Weapon_*, const double, WeaponLayer); // Position update and render.
|
||||
void(*think)(struct Weapon_*); // Some missiles need to be inteligent.
|
||||
} Weapon;
|
||||
|
||||
// Behind Pilot layer.
|
||||
|
Loading…
Reference in New Issue
Block a user