[Change] Just some C correctiveness.

This commit is contained in:
Allanis 2013-02-26 15:47:56 +00:00
parent f9c778358c
commit d2e952fb88
21 changed files with 52 additions and 53 deletions

View File

@ -9,11 +9,11 @@
// Max number of AI timers. // Max number of AI timers.
#define MAX_AI_TIMERS 2 #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. // Basic task.
typedef struct Task { typedef struct Task_ {
struct Task* next; struct Task_* next;
char* name; char* name;
TaskData dtype; TaskData dtype;
@ -24,7 +24,7 @@ typedef struct Task {
} Task; } Task;
// Ai profile. // Ai profile.
typedef struct { typedef struct AI_Profile_ {
char* name; char* name;
lua_State* L; lua_State* L;
} AI_Profile; } AI_Profile;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
// Colours. // Colours.
typedef struct { typedef struct glColour_ {
double r, g, b, a; double r, g, b, a;
} glColour; } glColour;

View File

@ -20,7 +20,7 @@ Faction* faction_stack = NULL;
int nfactions = 0; int nfactions = 0;
// Save alliance. // Save alliance.
typedef struct { typedef struct Alliance_ {
char* name; char* name;
Faction** factions; Faction** factions;
int nfactions; int nfactions;

View File

@ -1,11 +1,11 @@
#pragma once #pragma once
typedef struct Faction { typedef struct Faction_ {
char* name; char* name;
struct Faction** enemies; struct Factiona_** enemies;
int nenemies; int nenemies;
struct Faction** allies; struct Faction_** allies;
int nallies; int nallies;
} Faction; } Faction;

View File

@ -2,12 +2,13 @@
#include "opengl.h" #include "opengl.h"
// Font info. // Font info.
typedef struct { typedef struct glFont_ {
int h; // Height. int h; // Height.
int* w; int* w;
GLuint* textures; GLuint* textures;
GLuint list_base; GLuint list_base;
} glFont; } glFont;
extern glFont gl_defFont; // Default font. extern glFont gl_defFont; // Default font.
extern glFont gl_smallFont; // Small font. extern glFont gl_smallFont; // Small font.

View File

@ -10,7 +10,7 @@
#define KEY_RELEASE (-1.) #define KEY_RELEASE (-1.)
// Keybind structure. // Keybind structure.
typedef struct { typedef struct Keybind_ {
char* name; // Keybinding name, taken from keybindNames[] char* name; // Keybinding name, taken from keybindNames[]
KeybindType type; // type, defined in player.h. KeybindType type; // type, defined in player.h.
unsigned int key; // Key/axis/button event number. unsigned int key; // Key/axis/button event number.

View File

@ -24,7 +24,7 @@
extern SDL_mutex* sound_lock; extern SDL_mutex* sound_lock;
// Saves the music to ram in this structure. // Saves the music to ram in this structure.
typedef struct { typedef struct alMusic_ {
char name[32]; // Name. char name[32]; // Name.
Packfile file; Packfile file;
OggVorbis_File stream; OggVorbis_File stream;

View File

@ -25,7 +25,7 @@
#define OPENGL_AA_LINE (1<<3) #define OPENGL_AA_LINE (1<<3)
#define OPENGL_AA_POLYGON (1<<4) #define OPENGL_AA_POLYGON (1<<4)
#define gl_has(f) (gl_screen.flags & (f)) // Check for the flag. #define gl_has(f) (gl_screen.flags & (f)) // Check for the flag.
typedef struct { typedef struct glInfo_ {
int w, h; // Window dimensions. int w, h; // Window dimensions.
int depth; // Depth in bpp. int depth; // Depth in bpp.
int r, g, b, a; // Framebuffer values in bits. 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) #define COLOUR(x) glColor4d((x).r, (x).g, (x).b, (x).a)
// Spritesheet info. // Spritesheet info.
typedef struct { typedef struct glTexture_ {
double w, h; // Real size of the image (excluding POT buffer. double w, h; // Real size of the image (excluding POT buffer.
double rw, rh; // Size of POT surface. double rw, rh; // Size of POT surface.
double sx, sy; // Number of sprites on x and y axes. double sx, sy; // Number of sprites on x and y axes.

View File

@ -7,7 +7,7 @@
#define OUTFIT_PROP_WEAP_SECONDARY (1<<0) #define OUTFIT_PROP_WEAP_SECONDARY (1<<0)
// Outfit types. // Outfit types.
typedef enum { typedef enum OutfitType_ {
OUTFIT_TYPE_NULL = 0, OUTFIT_TYPE_NULL = 0,
OUTFIT_TYPE_BOLT = 1, OUTFIT_TYPE_BOLT = 1,
OUTFIT_TYPE_BEAM = 2, OUTFIT_TYPE_BEAM = 2,
@ -24,7 +24,7 @@ typedef enum {
} OutfitType; } OutfitType;
// An outfit depends a lot on the type. // An outfit depends a lot on the type.
typedef struct { typedef struct Outfit_ {
char* name; char* name;
// General specs. // General specs.

View File

@ -5,7 +5,7 @@
#endif #endif
#include <stdint.h> #include <stdint.h>
typedef struct { typedef struct Packfile_ {
#ifdef _POSIX_SOURCE #ifdef _POSIX_SOURCE
int fd; // File descriptor. int fd; // File descriptor.
#else #else

View File

@ -17,7 +17,7 @@
double angle_diff(const double ref, double a); double angle_diff(const double ref, double a);
// Base of 2D vectors. // Base of 2D vectors.
typedef struct { typedef struct Vec2_ {
double x, y; // Cartesian values. double x, y; // Cartesian values.
double mod, angle; // Polar values. double mod, angle; // Polar values.
} Vec2; } 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); void vect_cadd(Vec2* v, const double x, const double y);
// Describe any solid in 2D space. // Describe any solid in 2D space.
struct Solid { typedef struct Solid_ {
double mass, dir, dir_vel; // Properties. double mass, dir, dir_vel; // Properties.
Vec2 vel, pos, force; // Position/velocity vectors. Vec2 vel, pos, force; // Position/velocity vectors.
void(*update)(struct Solid*, const double); // Update method. void(*update)(struct Solid_*, const double); // Update method.
}; } Solid;
typedef struct Solid Solid;
// Solid manipulation. // Solid manipulation.
void solid_init(Solid* dest, const double mass, const double dir, void solid_init(Solid* dest, const double mass, const double dir,

View File

@ -36,14 +36,14 @@
#define pilot_isPlayer(p) ((p)->flags & PILOT_PLAYER) #define pilot_isPlayer(p) ((p)->flags & PILOT_PLAYER)
#define pilot_isDisabled(p) ((p)->flags & PILOT_DISABLED) #define pilot_isDisabled(p) ((p)->flags & PILOT_DISABLED)
typedef struct { typedef struct PilotOutfit_ {
Outfit* outfit; // Associated outfit. Outfit* outfit; // Associated outfit.
unsigned int quantity; // Number of outfits of this type that the pilot has. unsigned int quantity; // Number of outfits of this type that the pilot has.
unsigned int timer; // Used to store last used weapon time. unsigned int timer; // Used to store last used weapon time.
} PilotOutfit; } PilotOutfit;
// Primary pilot structure. // Primary pilot structure.
typedef struct Pilot { typedef struct Pilot_ {
unsigned int id; // Pilots id. unsigned int id; // Pilots id.
char* name; // Pilot's name (if unique). char* name; // Pilot's name (if unique).
@ -58,9 +58,9 @@ typedef struct Pilot {
double armour_max, shield_max, energy_max; double armour_max, shield_max, energy_max;
double fuel; // Used only for jumps. TODO: make it do something. double fuel; // Used only for jumps. TODO: make it do something.
void (*think)(struct Pilot*); // AI thinking for the pilot. void (*think)(struct Pilot_*); // AI thinking for the pilot.
void (*update)(struct Pilot*, const double); // Update the pilot. void (*update)(struct Pilot_*, const double); // Update the pilot.
void (*render)(struct Pilot*); // Rendering the pilot. void (*render)(struct Pilot_*); // Rendering the pilot.
// Outfit management. // Outfit management.
PilotOutfit* outfits; PilotOutfit* outfits;
@ -80,13 +80,13 @@ typedef struct Pilot {
} Pilot; } Pilot;
// Fleets. // Fleets.
typedef struct { typedef struct FleetPilot_ {
Ship* ship; // Ship that the pilot is flying. Ship* ship; // Ship that the pilot is flying.
char* name; // For special 'unique' names. char* name; // For special 'unique' names.
int chance; // Chance of this pilot appearing in the fleet. int chance; // Chance of this pilot appearing in the fleet.
} FleetPilot; } FleetPilot;
typedef struct { typedef struct Fleet_ {
char* name; // Fleet name, used as an identifier. char* name; // Fleet name, used as an identifier.
Faction* faction; // Faction of the fleet. Faction* faction; // Faction of the fleet.

View File

@ -53,7 +53,7 @@ extern int pilots;
extern StarSystem* systems; extern StarSystem* systems;
// GUI crap. // GUI crap.
typedef struct { typedef struct Radar_ {
double x,y; // Position. double x,y; // Position.
double w,h; // Dimensions. double w,h; // Dimensions.
RadarShape shape; RadarShape shape;
@ -66,12 +66,12 @@ typedef struct {
#define RADAR_RES_INTERVAL 10. #define RADAR_RES_INTERVAL 10.
#define RADAR_RES_DEFAULT 40. #define RADAR_RES_DEFAULT 40.
typedef struct { typedef struct Rect_ {
double x,y; double x,y;
double w,h; double w,h;
} Rect; } Rect;
typedef struct { typedef struct GUI_ {
// Graphics. // Graphics.
glTexture* gfx_frame; glTexture* gfx_frame;
glTexture* gfx_targetPilot, *gfx_targetPlanet; glTexture* gfx_targetPilot, *gfx_targetPlanet;
@ -98,7 +98,7 @@ double gui_yoff = 0.;
#define MSG_SIZE_MAX 80 #define MSG_SIZE_MAX 80
int msg_timeout = 5000; int msg_timeout = 5000;
int msg_max = 5; // Max messages on screen. int msg_max = 5; // Max messages on screen.
typedef struct { typedef struct Msg_ {
char str[MSG_SIZE_MAX]; char str[MSG_SIZE_MAX];
unsigned int t; unsigned int t;
} Msg; } Msg;

View File

@ -21,7 +21,7 @@ extern unsigned int player_flags;
extern unsigned int credits; extern unsigned int credits;
extern unsigned int combat_rating; 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. // Creation.
void player_new(void); void player_new(void);

View File

@ -7,7 +7,7 @@
#define SHIP_TARGET_W 128 #define SHIP_TARGET_W 128
#define SHIP_TARGET_H 96 #define SHIP_TARGET_H 96
typedef enum { typedef enum ShipClass_ {
SHIP_CLASS_NULL = 0, SHIP_CLASS_NULL = 0,
SHIP_CLASS_CIV_LIGHT = 1, SHIP_CLASS_CIV_LIGHT = 1,
SHIP_CLASS_CIV_MEDIUM = 2, SHIP_CLASS_CIV_MEDIUM = 2,
@ -15,15 +15,15 @@ typedef enum {
} ShipClass; } ShipClass;
// Small wrapper for the outfits. // Small wrapper for the outfits.
typedef struct ShipOutfit { typedef struct ShipOutfit_ {
struct ShipOutfit* next; // Linked list. struct ShipOutfit_* next; // Linked list.
Outfit* data; // Data itself. Outfit* data; // Data itself.
int quantity; int quantity;
} ShipOutfit; } ShipOutfit;
// Ship structure. // Ship structure.
typedef struct { typedef struct Ship_ {
char* name; // Ship name. char* name; // Ship name.
ShipClass class; // Ship class. ShipClass class; // Ship class.

View File

@ -22,7 +22,7 @@
#define SOUND_SUFFIX ".wav" #define SOUND_SUFFIX ".wav"
// Give the buffers a name. // Give the buffers a name.
typedef struct { typedef struct alSound_ {
char* name; // Buffers name. char* name; // Buffers name.
ALuint buffer; // Associated OpenAL buffer. ALuint buffer; // Associated OpenAL buffer.
} alSound; } alSound;

View File

@ -6,7 +6,7 @@
#define SOUND_MAX_DIST 1000. #define SOUND_MAX_DIST 1000.
// Virtual voice. // Virtual voice.
typedef struct { typedef struct alVoice_ {
ALuint source; // Source itself, 0 if not set. ALuint source; // Source itself, 0 if not set.
ALuint buffer; // Buffer. ALuint buffer; // Buffer.

View File

@ -44,7 +44,7 @@ char* stardate = "Stardate";
unsigned int date = 0; // time since epoch. unsigned int date = 0; // time since epoch.
#define STAR_BUF 100 // Area to leave around screen, more = less repitition. #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 x, y; // Position. It is simpler ligher to use two doubles than the physics.
double brightness; double brightness;
} Star; } Star;

View File

@ -7,7 +7,7 @@
#define MAX_HYPERSPACE_VEL 25 #define MAX_HYPERSPACE_VEL 25
// Planet types. I didn't take them from Star Trek, I promise. // Planet types. I didn't take them from Star Trek, I promise.
typedef enum { typedef enum PlanetClass_ {
PLANET_CLASS_NULL = 0, PLANET_CLASS_NULL = 0,
PLANET_CLASS_A, // Geothermal. PLANET_CLASS_A, // Geothermal.
PLANET_CLASS_B, // Geomorteus. PLANET_CLASS_B, // Geomorteus.
@ -41,7 +41,7 @@ typedef enum {
#define PLANET_SERVICE_SHIPYARD (1<<3) #define PLANET_SERVICE_SHIPYARD (1<<3)
#define planet_hasService(p,s) ((p)->services & s) #define planet_hasService(p,s) ((p)->services & s)
typedef struct { typedef struct Planet_ {
char* name; // Planet name char* name; // Planet name
Vec2 pos; // Position in star system. Vec2 pos; // Position in star system.
@ -56,12 +56,12 @@ typedef struct {
} Planet; } Planet;
// Star systems. // Star systems.
typedef struct { typedef struct SystemFleet_ {
Fleet* fleet; // Fleet to appear. Fleet* fleet; // Fleet to appear.
int chance; // Chance of fleet appearing in the system. int chance; // Chance of fleet appearing in the system.
} SystemFleet; } SystemFleet;
typedef struct { typedef struct StarSystem_ {
char* name; // Star system identifier. char* name; // Star system identifier.
Vec2 pos; // Position. Vec2 pos; // Position.
int stars, asteroids; // Un numero! int stars, asteroids; // Un numero!

View File

@ -3,7 +3,7 @@
#include "opengl.h" #include "opengl.h"
#include "toolkit.h" #include "toolkit.h"
typedef enum { typedef enum WidgetType_ {
WIDGET_NULL, WIDGET_NULL,
WIDGET_BUTTON, WIDGET_BUTTON,
WIDGET_TEXT, WIDGET_TEXT,
@ -11,13 +11,13 @@ typedef enum {
WIDGET_LIST WIDGET_LIST
} WidgetType; } WidgetType;
typedef enum { typedef enum WidgetStatus_ {
WIDGET_STATUS_NORMAL, WIDGET_STATUS_NORMAL,
WIDGET_STATUS_MOUSEOVER, WIDGET_STATUS_MOUSEOVER,
WIDGET_STATUS_MOUSEDOWN, WIDGET_STATUS_MOUSEDOWN,
} WidgetStatus; } WidgetStatus;
typedef struct { typedef struct Widget_ {
char* name; // Widget name. char* name; // Widget name.
WidgetType type; // type.. WidgetType type; // type..
@ -52,7 +52,7 @@ typedef struct {
}; };
} Widget; } Widget;
typedef struct { typedef struct Window_ {
unsigned int id; // Unique identifier. unsigned int id; // Unique identifier.
char* name; char* name;

View File

@ -24,7 +24,7 @@ extern int pilots;
// Ai stuff. // Ai stuff.
extern void ai_attacked(Pilot* attacked, const unsigned int attacker); extern void ai_attacked(Pilot* attacked, const unsigned int attacker);
typedef struct Weapon { typedef struct Weapon_ {
Solid* solid; // Actually has its own solid. :D Solid* solid; // Actually has its own solid. :D
unsigned int parent; // The pilot that just shot at you! unsigned int parent; // The pilot that just shot at you!
@ -35,8 +35,8 @@ typedef struct Weapon {
alVoice* voice; // Virtual voise. alVoice* voice; // Virtual voise.
// Update position and render. // Update position and render.
void(*update)(struct Weapon*, const double, WeaponLayer); // Position update and render. void(*update)(struct Weapon_*, const double, WeaponLayer); // Position update and render.
void(*think)(struct Weapon*); // Some missiles need to be inteligent. void(*think)(struct Weapon_*); // Some missiles need to be inteligent.
} Weapon; } Weapon;
// Behind Pilot layer. // Behind Pilot layer.