[Change] Added a few nazi flags, and fixed code up a little.

This commit is contained in:
Allanis 2013-06-11 22:50:04 +01:00
parent 56d0b46b14
commit 16baff189e
12 changed files with 39 additions and 19 deletions

View File

@ -24,9 +24,10 @@ CTTF = $(shell freetype-config --cflags)
CAL = -lopenal $(shell freealut-config --cflags) CAL = -lopenal $(shell freealut-config --cflags)
CVORBIS = CVORBIS =
CGL = CGL =
CFLAGS = $(CLUA) $(CPLUTO) $(CSDL) $(CXML) $(CTTF) $(CGL) $(CAL) $(CVORBIS) $(VERSION) -D$(OS) -fgnu89-inline CFLAGS = $(CLUA) $(CPLUTO) $(CSDL) $(CXML) $(CTTF) $(CGL) $(CAL) $(CVORBIS) $(VERSION) -D$(OS)
ifdef DEBUG ifdef DEBUG
CFLAGS += -W -Wall -Wextra -g3 -DDEBUG -DLUA_USE_APICHECK -std=c99 CFLAGS += -W -Wall -Wextra -Wmissing-prototypes -Winline -Wcast-align \
-Wmissing-declarations -fno-inline -g3 -DDEBUG -DLUA_USE_APICHECK -std=c99
else else
CFLAGS += -O2 -funroll-loops -pipe -std=c99 CFLAGS += -O2 -funroll-loops -pipe -std=c99
endif endif

View File

@ -85,6 +85,9 @@ static void ai_freetask(Task* t);
// External C routines. // External C routines.
void ai_attacked(Pilot* attacked, const unsigned int attacker); // weapon.c void ai_attacked(Pilot* attacked, const unsigned int attacker); // weapon.c
void ai_create(Pilot* pilot); void ai_create(Pilot* pilot);
// C routines made external.
void ai_destroy(Pilot* p);
void ai_think(Pilot* pilot);
// Ai routines for Lua. // Ai routines for Lua.
// Tasks. // Tasks.

View File

@ -189,15 +189,8 @@ char* base64_encode(size_t* len, char* src, size_t sz) {
} }
// Decode the buffer, same syntax as base64_encode. // Decode the buffer, same syntax as base64_encode.
static inline int dec_valid(char inp) { #define dec_valid(inp) (cd64[(int)inp] == -1) ? 0 : 1
if(cd64[(int)inp] == -1) #define dec_ch(inp) cd64[(int)inp]
return 0;
return 1;
}
static inline char dec_ch(char inp) {
return cd64[(int)inp];
}
char* base64_decode(size_t* len, char* src, size_t sz) { char* base64_decode(size_t* len, char* src, size_t sz) {
char* r, *dat, pad; char* r, *dat, pad;

View File

@ -45,10 +45,14 @@ typedef struct Alliance_ {
static Alliance* alliances = NULL; static Alliance* alliances = NULL;
static int nalliances = 0; static int nalliances = 0;
// Static.
static Faction* faction_parse(xmlNodePtr parent); static Faction* faction_parse(xmlNodePtr parent);
static void alliance_parse(xmlNodePtr parent); static void alliance_parse(xmlNodePtr parent);
static void enemies_parse(xmlNodePtr parent); static void enemies_parse(xmlNodePtr parent);
static Alliance* alliance_get(char* name); static Alliance* alliance_get(char* name);
// Extern.
int pfaction_save(xmlTextWriterPtr writer);
int pfaction_load(xmlNodePtr parent);
// Return the faction of name "name". // Return the faction of name "name".
int faction_get(const char* name) { int faction_get(const char* name) {

View File

@ -30,6 +30,9 @@ static int hook_run(Hook* hook);
static void hook_free(Hook* h); static void hook_free(Hook* h);
static int hook_needSave(Hook* h); static int hook_needSave(Hook* h);
static int hook_parse(xmlNodePtr base); static int hook_parse(xmlNodePtr base);
// Extern.
int hook_save(xmlTextWriterPtr writer);
int hook_load(xmlNodePtr parent);
static int hook_run(Hook* hook) { static int hook_run(Hook* hook) {
int i; int i;

View File

@ -46,9 +46,14 @@ static int var_mstack = 0;
static Mission* cur_mission = NULL; static Mission* cur_mission = NULL;
static int misn_delete = 0; // If 1 delete current mission. static int misn_delete = 0; // If 1 delete current mission.
// Static.
static int var_add(misn_var* var); static int var_add(misn_var* var);
static void var_free(misn_var* var); static void var_free(misn_var* var);
static unsigned int hook_generic(lua_State* L, char* stack); static unsigned int hook_generic(lua_State* L, char* stack);
// Extern.
int misn_run(Mission* misn, char* func);
int var_save(xmlTextWriterPtr writer);
int var_load(xmlNodePtr parent);
// -- Libraries. -- // -- Libraries. --

View File

@ -44,6 +44,9 @@ static MissionData* mission_parse(const xmlNodePtr parent);
static int missions_parseActive(xmlNodePtr parent); static int missions_parseActive(xmlNodePtr parent);
static int mission_persistData(lua_State* L, xmlTextWriterPtr writer); static int mission_persistData(lua_State* L, xmlTextWriterPtr writer);
static int mission_unpersistData(lua_State* L, xmlNodePtr parent); static int mission_unpersistData(lua_State* L, xmlNodePtr parent);
// Extern.
int missions_saveActive(xmlTextWriterPtr writer);
int missions_loadActive(xmlNodePtr parent);
// Generate a new id for the mission. // Generate a new id for the mission.
static unsigned int mission_genID(void) { static unsigned int mission_genID(void) {

View File

@ -163,6 +163,9 @@ void player_dead(void);
void player_destroyed(void); void player_destroyed(void);
int player_save(xmlTextWriterPtr writer); int player_save(xmlTextWriterPtr writer);
int player_load(xmlNodePtr parent); int player_load(xmlNodePtr parent);
void player_think(Pilot* player);
void player_brokeHyperspace(void);
double player_faceHyperspace(void);
// Prompt player name. // Prompt player name.
void player_new(void) { void player_new(void) {

View File

@ -34,6 +34,7 @@ void player_new(void);
void player_newShip(Ship* ship, double px, double py, void player_newShip(Ship* ship, double px, double py,
double vx, double vy, double dir); double vx, double vy, double dir);
void player_cleanup(void); void player_cleanup(void);
int gui_load(const char* name);
// Render. // Render.
int gui_init(void); int gui_init(void);

View File

@ -90,7 +90,7 @@ static int source_nstack = 0;
struct alVoice { struct alVoice {
alVoice* next; // Yes it's a linked list. alVoice* next; // Yes it's a linked list.
//ALuint id; // Unique id for the voice. //ALuint id; // Unique id for the voice.
ALuint source; // Source itself, 0 if not set. ALuint source; // Source itself, 0 if not set.
ALuint buffer; // Buffer. ALuint buffer; // Buffer.
@ -98,7 +98,7 @@ struct alVoice {
int priority; // Base priority. int priority; // Base priority.
double px, py; // Position. double px, py; // Position.
//double vx, vy; // Velocity. //double vx, vy; // Velocity.
unsigned int start; // time started in ms. unsigned int start; // time started in ms.
unsigned int flags; // Flags to set properties. unsigned int flags; // Flags to set properties.

View File

@ -78,13 +78,15 @@ static void system_parseJumps(const xmlNodePtr parent);
static PlanetClass planetclass_get(const char a); static PlanetClass planetclass_get(const char a);
// Extern. // Extern.
extern void player_message(const char* fmt, ...); extern void player_message(const char* fmt, ...);
void planets_minimap(const double res, const double w,
const double h, const RadarShape shape);
// Draw the planet. Used in planet.c // Draw the planet. Used in planet.c
// Matrix mode is already displaced to center of the minimap. // Matrix mode is already displaced to center of the minimap.
#define PIXEL(x,y) if((shape == RADAR_RECT && ABS(x)<w/2. && ABS(y)<h/2.) || \ #define PIXEL(x,y) if((shape == RADAR_RECT && ABS(x)<w/2. && ABS(y)<h/2.) || \
(shape == RADAR_CIRCLE && (((x)*(x)+(y)*(y)) < rc))) glVertex2i((x),(y)) (shape == RADAR_CIRCLE && (((x)*(x)+(y)*(y)) < rc))) glVertex2i((x),(y))
void planets_minimap(const double res, void planets_minimap(const double res, const double w,
const double w, const double h, const RadarShape shape) { const double h, const RadarShape shape) {
int i; int i;
int cx, cy, x, y, r, rc; int cx, cy, x, y, r, rc;
double p; double p;
@ -333,8 +335,6 @@ StarSystem** system_getJumpPath(int* njumps, char* sysstart, char* sysend) {
} }
// Free the linked list. // Free the linked list.
//A_freeList(open);
//A_freeList(closed);
A_freeList(A_gc); A_freeList(A_gc);
return res; return res;
} }

View File

@ -58,6 +58,7 @@ static Weapon** wfrontLayer = NULL; // Behind pilots.
static int nwfrontLayer = 0; // Number of elements. static int nwfrontLayer = 0; // Number of elements.
static int mwfrontLayer = 0; // Allocated memory size. static int mwfrontLayer = 0; // Allocated memory size.
// Static.
static Weapon* weapon_create(const Outfit* outfit, const double dir, static Weapon* weapon_create(const Outfit* outfit, const double dir,
const Vec2* pos, const Vec2* vel, const Vec2* pos, const Vec2* vel,
const unsigned int parent, const unsigned int parent,
@ -72,12 +73,15 @@ static void weapon_free(Weapon* w);
// Think. // Think.
static void think_seeker(Weapon* w, const double dt); static void think_seeker(Weapon* w, const double dt);
static void think_smart(Weapon* w, const double dt); static void think_smart(Weapon* w, const double dt);
// Extern.
void weapon_minimap(const double res, const double w,
const double h, const RadarShape shape);
// Draw the minimap weapons (player.c). // Draw the minimap weapons (player.c).
#define PIXEL(x,y) if((shape == RADAR_RECT && ABS(x) < w/2. && ABS(y)<h/2.) || \ #define PIXEL(x,y) if((shape == RADAR_RECT && ABS(x) < w/2. && ABS(y)<h/2.) || \
(shape == RADAR_CIRCLE && (((x)*(x)+(y)*(y))<rc))) glVertex2i((x),(y)) (shape == RADAR_CIRCLE && (((x)*(x)+(y)*(y))<rc))) glVertex2i((x),(y))
void weapon_minimap(const double res, void weapon_minimap(const double res, const double w,
const double w, const double h, const RadarShape shape) { const double h, const RadarShape shape) {
int i, rc; int i, rc;
double x, y; double x, y;