Ahem. Forgot headers. Apparently, all the source/header should be updated. Woops

This commit is contained in:
Steven Arnow 2013-06-22 22:17:28 +02:00
parent a2bb0df939
commit 858295b3f4
33 changed files with 465 additions and 465 deletions

View File

@ -5,32 +5,32 @@
#define MAX_DIR_ERR 0.5*M_PI/180. #define MAX_DIR_ERR 0.5*M_PI/180.
#define MIN_VEL_ERR 5.0 #define MIN_VEL_ERR 5.0
#define FACE_WVEL 0.1 // Weight of velocity compared to position to face. #define FACE_WVEL 0.1 /* Weight of velocity compared to position to face. */
// Max number of AI timers. /* Max number of AI timers. */
#define MAX_AI_TIMERS 2 #define MAX_AI_TIMERS 2
typedef enum TaskData_ { 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;
union { union {
void* target; // Vec2 etc. void* target; /* Vec2 etc. */
unsigned int ID; // Pilot ID etc. unsigned int ID; /* Pilot ID etc. */
} dat; } dat;
} Task; } Task;
// Ai profile. /* Ai profile. */
typedef struct AI_Profile_ { typedef struct AI_Profile_ {
char* name; char* name;
lua_State* L; lua_State* L;
} AI_Profile; } AI_Profile;
// Misc. /* Misc. */
AI_Profile* ai_getProfile(char* name); AI_Profile* ai_getProfile(char* name);
int ai_init(void); int ai_init(void);

View File

@ -1,17 +1,17 @@
#pragma once #pragma once
// Colours. /* Colours. */
typedef struct glColour_ { typedef struct glColour_ {
double r, g, b, a; double r, g, b, a;
} glColour; } glColour;
// Default colors. /* Default colors. */
// -- Greyscale. /* -- Greyscale. */
extern glColour cWhite; extern glColour cWhite;
#define cGrey cGrey70 #define cGrey cGrey70
extern glColour cBlack; extern glColour cBlack;
// Greys /* Greys */
extern glColour cGrey90; extern glColour cGrey90;
extern glColour cGrey80; extern glColour cGrey80;
extern glColour cGrey70; extern glColour cGrey70;
@ -30,21 +30,21 @@ extern glColour cDarkBlue;
extern glColour cBlue; extern glColour cBlue;
extern glColour cPurple; extern glColour cPurple;
// Game specific. /* Game specific. */
extern glColour cConsole; extern glColour cConsole;
extern glColour cDConsole; extern glColour cDConsole;
// Toolkit. /* Toolkit. */
extern glColour cHilight; extern glColour cHilight;
// Objects. /* Objects. */
extern glColour cInert; extern glColour cInert;
extern glColour cNeutral; extern glColour cNeutral;
extern glColour cFriend; extern glColour cFriend;
extern glColour cHostile; extern glColour cHostile;
// Radar. /* Radar. */
extern glColour cRadar_player; extern glColour cRadar_player;
extern glColour cRadar_targ; extern glColour cRadar_targ;
extern glColour cRadar_weap; extern glColour cRadar_weap;
// Health. /* Health. */
extern glColour cShield; extern glColour cShield;
extern glColour cArmour; extern glColour cArmour;
extern glColour cEnergy; extern glColour cEnergy;

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
// Loading. /* Loading. */
void conf_setDefaults(void); void conf_setDefaults(void);
int conf_loadConfig(const char* file); int conf_loadConfig(const char* file);
void conf_parseCLI(int argc, char** argv); void conf_parseCLI(int argc, char** argv);
// Saving. /* Saving. */
int conf_saveConfig(void); int conf_saveConfig(void);

View File

@ -3,14 +3,14 @@
typedef struct Commodity_ { typedef struct Commodity_ {
char* name; char* name;
char* description; char* description;
int low, medium, high; // Prices. int low, medium, high; /* Prices. */
} Commodity; } Commodity;
// Commidity stuff. /* Commidity stuff. */
Commodity* commodity_get(const char* name); Commodity* commodity_get(const char* name);
int commodity_load(void); int commodity_load(void);
void commodity_free(void); void commodity_free(void);
// Misc. /* Misc. */
void credits2str(char* str, unsigned int credits, int decimals); void credits2str(char* str, unsigned int credits, int decimals);

View File

@ -2,27 +2,27 @@
#define FACTION_PLAYER 0 #define FACTION_PLAYER 0
// Get stuff. /* Get stuff. */
int faction_get(const char* name); int faction_get(const char* name);
int faction_getAlliance(char* name); int faction_getAlliance(char* name);
char* faction_name(int f); char* faction_name(int f);
// Player stuff. /* Player stuff. */
void faction_modPlayer(int f, int mod); void faction_modPlayer(int f, int mod);
int faction_getPlayer(int f); int faction_getPlayer(int f);
// Works with only factions. /* Works with only factions. */
int areEnemies(int a, int b); int areEnemies(int a, int b);
int areAllies(int a, int b); int areAllies(int a, int b);
// Faction + Alliance. /* Faction + Alliance. */
int faction_ofAlliance(int f, int a); int faction_ofAlliance(int f, int a);
// Check. /* Check. */
int faction_isAlliance(int a); int faction_isAlliance(int a);
int faction_isFaction(int f); int faction_isFaction(int f);
// Load/Free. /* Load/Free. */
int factions_load(void); int factions_load(void);
void factions_free(void); void factions_free(void);

View File

@ -1,39 +1,39 @@
#pragma once #pragma once
#include "opengl.h" #include "opengl.h"
// Font info. /* Font info. */
typedef struct glFont_ { 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. */
// glFont loading/freeing. /* glFont loading/freeing. */
// If font is NULL it uses the internal default font, same with gl_print /* If font is NULL it uses the internal default font, same with gl_print */
void gl_fontInit(glFont* font, const char* fname, const unsigned int h); void gl_fontInit(glFont* font, const char* fname, const unsigned int h);
void gl_freeFont(glFont* font); void gl_freeFont(glFont* font);
// Print text. /* Print text. */
void gl_print(const glFont* ft_font, const double x, const double y, void gl_print(const glFont* ft_font, const double x, const double y,
const glColour* c, const char* fmt, ...); const glColour* c, const char* fmt, ...);
// Print text to a max length. /* Print text to a max length. */
int gl_printMax(const glFont* ft_font, const int max, int gl_printMax(const glFont* ft_font, const int max,
const double x, const double y, const glColour* c, const char* fmt, ...); const double x, const double y, const glColour* c, const char* fmt, ...);
// Print text centered in width at x. /* Print text centered in width at x. */
int gl_printMid(const glFont* ft_font, const int width, int gl_printMid(const glFont* ft_font, const int width,
double x, const double y, const glColour* c, const char* fmt, ...); double x, const double y, const glColour* c, const char* fmt, ...);
// Respects \n -> bx, by is top left position. /* Respects \n -> bx, by is top left position. */
int gl_printText(const glFont* ft_font, const int width, const int height, int gl_printText(const glFont* ft_font, const int width, const int height,
double bx, double by, glColour* c, const char* fmt, ...); double bx, double by, glColour* c, const char* fmt, ...);
// Get the width of the text that you wish to print. /* Get the width of the text that you wish to print. */
int gl_printWidth(const glFont* ft_font, const char* fmt, ...); int gl_printWidth(const glFont* ft_font, const char* fmt, ...);
int gl_printHeight(const glFont* ft_font, const int width, int gl_printHeight(const glFont* ft_font, const int width,

View File

@ -1,25 +1,25 @@
#pragma once #pragma once
#include "mission.h" #include "mission.h"
// Add/Run hooks. /* Add/Run hooks. */
unsigned int hook_add(unsigned int parent, char* func, char* stack); unsigned int hook_add(unsigned int parent, char* func, char* stack);
void hook_rm(unsigned int id); void hook_rm(unsigned int id);
void hook_rmParent(unsigned int parent); void hook_rmParent(unsigned int parent);
// ======================================================== /* ======================================================== */
// Run Hooks: /* Run Hooks: */
// /* */
// Currently used: /* Currently used: */
// -- "land" - When landed. /* -- "land" - When landed. */
// -- "takeoff" - When taking off. /* -- "takeoff" - When taking off. */
// -- "jump" - When changing systems. /* -- "jump" - When changing systems. */
// -- "time" - When time is increment drastically /* -- "time" - When time is increment drastically */
// (hyperspace and taking off. /* (hyperspace and taking off. */
// ======================================================== /* ======================================================== */
int hooks_run(char* stack); int hooks_run(char* stack);
void hook_runID(unsigned int id); // Runs hook of specific id. void hook_runID(unsigned int id); /* Runs hook of specific id. */
// Destroy hook. /* Destroy hook. */
void hook_cleanup(void); void hook_cleanup(void);

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <SDL.h> #include <SDL.h>
// Input types. /* Input types. */
typedef enum { typedef enum {
KEYBIND_NULL, KEYBIND_NULL,
KEYBIND_KEYBOARD, KEYBIND_KEYBOARD,
@ -9,15 +9,15 @@ typedef enum {
KEYBIND_JBUTTON KEYBIND_JBUTTON
} KeybindType; } KeybindType;
// Set input. /* Set input. */
void input_setDefault(void); void input_setDefault(void);
void input_setKeybind(char* keybind, KeybindType type, int key, int reverse); void input_setKeybind(char* keybind, KeybindType type, int key, int reverse);
int input_getKeybind(char* keybind, KeybindType* type, int* reverse); int input_getKeybind(char* keybind, KeybindType* type, int* reverse);
// Handle the events. /* Handle the events. */
void input_handle(SDL_Event* event); void input_handle(SDL_Event* event);
// Init/Exit. /* Init/Exit. */
void input_init(void); void input_init(void);
void input_exit(void); void input_exit(void);

View File

@ -1,12 +1,12 @@
#pragma once #pragma once
// Get the joystick index number based on its name. /* Get the joystick index number based on its name. */
int joystick_get(char* namjoystick); int joystick_get(char* namjoystick);
// set the game to use the joystick of index indjoystick. /* set the game to use the joystick of index indjoystick. */
int joystick_use(int indjoystick); int joystick_use(int indjoystick);
// Exit functions. /* Exit functions. */
int joystick_init(void); int joystick_init(void);
void joystick_exit(void); void joystick_exit(void);

View File

@ -12,18 +12,18 @@
#define pow2(x) ((x)*(x)) #define pow2(x) ((x)*(x))
#define DATA_DEF "data" // Default data packfile. #define DATA_DEF "data" /* Default data packfile. */
extern char* data; // Modifiable datafile. extern char* data; /* Modifiable datafile. */
#define DATA data // Data file. #define DATA data /* Data file. */
#define DATA_NAME_LEN 32 // Max length of data name. #define DATA_NAME_LEN 32 /* Max length of data name. */
extern char dataname[DATA_NAME_LEN]; extern char dataname[DATA_NAME_LEN];
// Max filename path. /* Max filename path. */
#ifndef PATH_MAX #ifndef PATH_MAX
# define PATH_MAX 128 # define PATH_MAX 128
#endif #endif
#ifndef M_PI #ifndef M_PI
#define M_PI 3.14159265358979323846 // Pi. #define M_PI 3.14159265358979323846 /* Pi. */
#endif #endif

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
#include "lua.h" #include "lua.h"
// Individual libraries. /* Individual libraries. */
int lua_loadLephisto(lua_State* L); // Always read only. int lua_loadLephisto(lua_State* L); /* Always read only. */
int lua_loadSpace(lua_State* L, int readonly); int lua_loadSpace(lua_State* L, int readonly);
int lua_loadTime(lua_State* L, int readonly); int lua_loadTime(lua_State* L, int readonly);
int lua_loadRnd(lua_State* L); // Always read only. int lua_loadRnd(lua_State* L); /* Always read only. */
int lua_loadTk(lua_State* L); // Always read only. int lua_loadTk(lua_State* L); /* Always read only. */

View File

@ -4,7 +4,7 @@
#include "lauxlib.h" #include "lauxlib.h"
#include "lualib.h" #include "lualib.h"
// Debug stuff. /* Debug stuff. */
#define LLUA_DEBUG(str, args...) \ #define LLUA_DEBUG(str, args...) \
(fprintf(stdout, "Lua: "str"\n", ## args)) (fprintf(stdout, "Lua: "str"\n", ## args))
@ -19,7 +19,7 @@
return 0; \ return 0; \
} }
// Comfortability macros. /* Comfortability macros. */
#define luaL_dobuffer(L, b, n, s) \ #define luaL_dobuffer(L, b, n, s) \
(luaL_loadbuffer(L, b, n, s) || lua_pcall(L, 0, LUA_MULTRET, 0)) (luaL_loadbuffer(L, b, n, s) || lua_pcall(L, 0, LUA_MULTRET, 0))

View File

@ -1,13 +1,13 @@
#pragma once #pragma once
// How long a 'unit' of time is. /* How long a 'unit' of time is. */
#define LTIME_UNIT_LENGTH 1000 #define LTIME_UNIT_LENGTH 1000
// Get. /* Get. */
unsigned int ltime_get(void); unsigned int ltime_get(void);
char* ltime_pretty(unsigned int t); char* ltime_pretty(unsigned int t);
// Set. /* Set. */
void ltime_set(unsigned int t); void ltime_set(unsigned int t);
void ltime_inc(unsigned int t); void ltime_inc(unsigned int t);

View File

@ -1,9 +1,9 @@
#pragma once #pragma once
// Open the map window. /* Open the map window. */
void map_open(void); void map_open(void);
// Misc. /* Misc. */
void map_clear(void); void map_clear(void);
void map_jump(void); void map_jump(void);

View File

@ -2,15 +2,15 @@
#include "lua.h" #include "lua.h"
// Check if a flag exists on the variable stack. /* Check if a flag exists on the variable stack. */
int var_checkflag(char* str); int var_checkflag(char* str);
void var_cleanup(void); void var_cleanup(void);
// Load the libraries for a lua state. /* Load the libraries for a lua state. */
int misn_loadLibs(lua_State* L); int misn_loadLibs(lua_State* L);
int misn_loadCondLibs(lua_State* L); // Safe read only stuff. int misn_loadCondLibs(lua_State* L); /* Safe read only stuff. */
// Individual library stuff. /* Individual library stuff. */
int lua_loadMisn(lua_State* L); int lua_loadMisn(lua_State* L);
int lua_loadVar(lua_State* L, int readonly); int lua_loadVar(lua_State* L, int readonly);
int lua_loadPlayer(lua_State* L); int lua_loadPlayer(lua_State* L);

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include "misn_lua.h" #include "misn_lua.h"
// Availability by location. /* Availability by location. */
#define MIS_AVAIL_NONE 0 #define MIS_AVAIL_NONE 0
#define MIS_AVAIL_COMPUTER 1 #define MIS_AVAIL_COMPUTER 1
#define MIS_AVAIL_BAR 2 #define MIS_AVAIL_BAR 2
@ -9,73 +9,73 @@
#define MIS_AVAIL_SHIPYARD 4 #define MIS_AVAIL_SHIPYARD 4
#define MIS_AVAIL_LAND 5 #define MIS_AVAIL_LAND 5
// Flags. /* Flags. */
#define mis_isFlag(m,f) ((m)->flags & (f)) #define mis_isFlag(m,f) ((m)->flags & (f))
#define mis_setFlag(m,f) ((m)->flags |= (f)) #define mis_setFlag(m,f) ((m)->flags |= (f))
#define mis_rmFlag(m,f) ((m)->flags ^= (f)) #define mis_rmFlag(m,f) ((m)->flags ^= (f))
#define MISSION_UNIQUE 1 // Unique missions can't be repeated. #define MISSION_UNIQUE 1 /* Unique missions can't be repeated. */
// Static mission data. /* Static mission data. */
typedef struct MissionData_ { typedef struct MissionData_ {
char* name; // the name of the mission. char* name; /* the name of the mission. */
// Availability. /* Availability. */
struct { struct {
int loc; // Location. int loc; /* Location. */
int chance; // Chance of it appearing. int chance; /* Chance of it appearing. */
// For specific cases. /* For specific cases. */
char* planet; char* planet;
char* system; char* system;
// For generic cases. /* For generic cases. */
int* factions; int* factions;
int nfactions; int nfactions;
char* cond; // Conditional that must be met. char* cond; /* Conditional that must be met. */
} avail; } avail;
unsigned int flags; // Flags to store binary properties. unsigned int flags; /* Flags to store binary properties. */
char* lua; char* lua;
} MissionData; } MissionData;
// Active mission. /* Active mission. */
typedef struct Mission_ { typedef struct Mission_ {
MissionData* data; MissionData* data;
// Unique mission identifier, used for keeping track of hooks. /* Unique mission identifier, used for keeping track of hooks. */
unsigned int id; unsigned int id;
char* title; // Not to be confused with name.. char* title; /* Not to be confused with name.. */
char* desc; // Description of the mission. char* desc; /* Description of the mission. */
char* reward; // Rewards - in text. char* reward; /* Rewards - in text. */
// Mission cargo give to the player - Need to cleanup. /* Mission cargo give to the player - Need to cleanup. */
unsigned int* cargo; unsigned int* cargo;
int ncargo; int ncargo;
lua_State* L; // The state of the running lua code. lua_State* L; /* The state of the running lua code. */
} Mission; } Mission;
#define MISSION_MAX 6 // No sense in the player having unlimited missions.. #define MISSION_MAX 6 /* No sense in the player having unlimited missions.. */
extern Mission player_missions[MISSION_MAX]; extern Mission player_missions[MISSION_MAX];
// For mission computer. /* For mission computer. */
Mission* missions_computer(int* n, int faction, char* planet, char* system); Mission* missions_computer(int* n, int faction, char* planet, char* system);
// Player accepted mission - mission computer. /* Player accepted mission - mission computer. */
int mission_accept(Mission* mission); int mission_accept(Mission* mission);
void missions_bar(int faction, char* planet, char* system); void missions_bar(int faction, char* planet, char* system);
// Misc. /* Misc. */
int mission_getID(char* name); int mission_getID(char* name);
MissionData* mission_get(int id); MissionData* mission_get(int id);
// Cargo stuff. /* Cargo stuff. */
void mission_linkCargo(Mission* misn, unsigned int cargo_id); void mission_linkCargo(Mission* misn, unsigned int cargo_id);
void mission_unlinkCargo(Mission* misn, unsigned int cargo_id); void mission_unlinkCargo(Mission* misn, unsigned int cargo_id);
// Load/Quit. /* Load/Quit. */
int missions_load(void); int missions_load(void);
void mission_cleanup(Mission* misn); void mission_cleanup(Mission* misn);
void missions_free(void); void missions_free(void);

View File

@ -1,22 +1,22 @@
#pragma once #pragma once
#include "lua.h" #include "lua.h"
// Thread. /* Thread. */
int music_thread(void* unused); int music_thread(void* unused);
void music_kill(void); void music_kill(void);
// Init/Exit. /* Init/Exit. */
int music_init(void); int music_init(void);
int music_makeList(void); int music_makeList(void);
void music_exit(void); void music_exit(void);
// Music control. /* Music control. */
void music_volume(const double vol); void music_volume(const double vol);
void music_load(const char* name); void music_load(const char* name);
void music_play(void); void music_play(void);
void music_stop(void); void music_stop(void);
// Lua control. /* Lua control. */
int lua_loadMusic(lua_State* L, int read_only); int lua_loadMusic(lua_State* L, int read_only);
int music_choose(char* situation); int music_choose(char* situation);

View File

@ -5,7 +5,7 @@
#include "colour.h" #include "colour.h"
#include "physics.h" #include "physics.h"
// Recommended for compatibility bullshit. /* Recommended for compatibility bullshit. */
#if SDL_BYTEORDER == SDL_BIG_ENDIAN #if SDL_BYTEORDER == SDL_BIG_ENDIAN
# define RMASK 0xff000000 # define RMASK 0xff000000
# define GMASK 0x00ff0000 # define GMASK 0x00ff0000
@ -19,7 +19,7 @@
#endif #endif
#define RGBMASK RMASK,GMASK,BMASK,AMASK #define RGBMASK RMASK,GMASK,BMASK,AMASK
// Info about opengl screen. /* Info about opengl screen. */
#define OPENGL_FULLSCREEN (1<<0) #define OPENGL_FULLSCREEN (1<<0)
#define OPENGL_DOUBLEBUF (1<<1) #define OPENGL_DOUBLEBUF (1<<1)
#define OPENGL_AA_POINT (1<<2) #define OPENGL_AA_POINT (1<<2)
@ -27,15 +27,15 @@
#define OPENGL_AA_POLYGON (1<<4) #define OPENGL_AA_POLYGON (1<<4)
#define OPENGL_FRAG_SHADER (1<<5) #define OPENGL_FRAG_SHADER (1<<5)
#define OPENGL_VERT_SHADER (1<<6) #define OPENGL_VERT_SHADER (1<<6)
#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 glInfo_ { 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. */
int flags; // Store different properties. int flags; /* Store different properties. */
int tex_max; // Max texture size. int tex_max; /* Max texture size. */
} glInfo; } glInfo;
extern glInfo gl_screen; // Local structure set with gl_init etc. extern glInfo gl_screen; /* Local structure set with gl_init etc. */
#define SCREEN_W gl_screen.w #define SCREEN_W gl_screen.w
#define SCREEN_H gl_screen.h #define SCREEN_H gl_screen.h
@ -43,56 +43,56 @@ 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)
#define ACOLOUR(x,a) glColor4d((x).r, (x).g, (x).b, a) #define ACOLOUR(x,a) glColor4d((x).r, (x).g, (x).b, a)
// Spritesheet info. /* Spritesheet info. */
typedef struct glTexture_ { 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. */
double sw, sh; // Size of each sprite. double sw, sh; /* Size of each sprite. */
GLuint texture; // The opengl texture itself. GLuint texture; /* The opengl texture itself. */
uint8_t* trans; // Maps the transparency. uint8_t* trans; /* Maps the transparency. */
} glTexture; } glTexture;
// gl_texute loading/freeing. /* gl_texute loading/freeing. */
glTexture* gl_loadImage(SDL_Surface* surface); // Frees the surface. glTexture* gl_loadImage(SDL_Surface* surface); /* Frees the surface. */
glTexture* gl_newImage(const char* path); glTexture* gl_newImage(const char* path);
glTexture* gl_newSprite(const char* path, const int sx, const int sy); glTexture* gl_newSprite(const char* path, const int sx, const int sy);
void gl_freeTexture(glTexture* texture); void gl_freeTexture(glTexture* texture);
// Rendering. /* Rendering. */
// Blits a sprite, relative pos. /* Blits a sprite, relative pos. */
void gl_blitSprite(const glTexture* sprite, const double bx, const double by, void gl_blitSprite(const glTexture* sprite, const double bx, const double by,
const int sx, const int sy, const glColour* c); const int sx, const int sy, const glColour* c);
// Blits a texture rotated, relative pos. /* Blits a texture rotated, relative pos. */
void gl_blitRotate(const glTexture* texture, void gl_blitRotate(const glTexture* texture,
const double bx, const double by, const double bx, const double by,
const double dir, const glColour* c); const double dir, const glColour* c);
// Blit the entire image, absolute pos. /* Blit the entire image, absolute pos. */
void gl_blitStatic(const glTexture* texture, const double bx, const double by, void gl_blitStatic(const glTexture* texture, const double bx, const double by,
const glColour* c); const glColour* c);
// Bind the camera to a vector. /* Bind the camera to a vector. */
void gl_bindCamera(const Vec2* pos); void gl_bindCamera(const Vec2* pos);
// Circle drawing. /* Circle drawing. */
void gl_drawCircle(const double x, const double y, const double r); void gl_drawCircle(const double x, const double y, const double r);
void gl_drawCircleInRect(const double x, const double y, const double r, void gl_drawCircleInRect(const double x, const double y, const double r,
const double rc, const double ry, const double rw, const double rc, const double ry, const double rw,
const double rh); const double rh);
// Initialize/cleanup. /* Initialize/cleanup. */
int gl_init(void); int gl_init(void);
void gl_exit(void); void gl_exit(void);
// Misc. /* Misc. */
int gl_isTrans(const glTexture* t, const int x, const int y); int gl_isTrans(const glTexture* t, const int x, const int y);
void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir); void gl_getSpriteFromDir(int* x, int* y, const glTexture* t, const double dir);
void gl_screenshot(const char* filename); void gl_screenshot(const char* filename);
//#if DEBUG == 1 /*#if DEBUG == 1 */
void gl_checkErr(void); void gl_checkErr(void);
//#else /*#else */
//#define gl_checkErr() /*#define gl_checkErr() */
//#endif /*#endif */

View File

@ -3,10 +3,10 @@
#include "sound.h" #include "sound.h"
#define outfit_isProp(o,p) ((o)->properties & p) #define outfit_isProp(o,p) ((o)->properties & p)
// Property flags. /* Property flags. */
#define OUTFIT_PROP_WEAP_SECONDARY (1<<0) #define OUTFIT_PROP_WEAP_SECONDARY (1<<0)
// Outfit types. /* Outfit types. */
typedef enum OutfitType_ { typedef enum OutfitType_ {
OUTFIT_TYPE_NULL = 0, OUTFIT_TYPE_NULL = 0,
OUTFIT_TYPE_BOLT = 1, OUTFIT_TYPE_BOLT = 1,
@ -33,94 +33,94 @@ typedef enum DamageType_ {
DAMAGE_TYPE_KINETIC = 2 DAMAGE_TYPE_KINETIC = 2
} DamageType; } DamageType;
// An outfit depends a lot on the type. /* An outfit depends a lot on the type. */
typedef struct Outfit_ { typedef struct Outfit_ {
char* name; char* name;
// General specs. /* General specs. */
int max; int max;
int tech; int tech;
int mass; int mass;
// Store stuff. /* Store stuff. */
unsigned int price; unsigned int price;
char* description; char* description;
glTexture* gfx_store; // Store graphic. glTexture* gfx_store; /* Store graphic. */
int properties; // Properties stored bitwise. int properties; /* Properties stored bitwise. */
// Type dependant. /* Type dependant. */
OutfitType type; OutfitType type;
union { union {
struct { // Bolt. struct { /* Bolt. */
unsigned int delay; // Delay between shots. unsigned int delay; /* Delay between shots. */
double speed; // Speed of shot. (not applicable to beam. double speed; /* Speed of shot. (not applicable to beam. */
double range; double range;
double accuracy; // Desviation accuracy. double accuracy; /* Desviation accuracy. */
double energy; // Energy usage. double energy; /* Energy usage. */
DamageType dtype; // Damage type. DamageType dtype; /* Damage type. */
double damage; // Damage. double damage; /* Damage. */
glTexture* gfx_space; glTexture* gfx_space;
ALuint sound; // Sound to play. ALuint sound; /* Sound to play. */
int spfx; // Special effect on hit. int spfx; /* Special effect on hit. */
} blt; } blt;
struct { // Beam. struct { /* Beam. */
double range; // Distance it travels. double range; /* Distance it travels. */
glColour colour; // Beam colour. glColour colour; /* Beam colour. */
double energy; // Energy drained. double energy; /* Energy drained. */
double damage_armour, damage_shield; // Damage. double damage_armour, damage_shield; /* Damage. */
} bem; } bem;
struct { // Launcher. struct { /* Launcher. */
unsigned int delay; // Delay between shots. unsigned int delay; /* Delay between shots. */
char* ammo; char* ammo;
} lau; } lau;
struct { // Ammo. struct { /* Ammo. */
unsigned int duration; // Duration. unsigned int duration; /* Duration. */
double speed; // Max speed. double speed; /* Max speed. */
double turn; // Turn vel. double turn; /* Turn vel. */
double thrust; // Acceleration. double thrust; /* Acceleration. */
double energy; // Energy usage. double energy; /* Energy usage. */
DamageType dtype; // Damage type. DamageType dtype; /* Damage type. */
double damage; // Damage. double damage; /* Damage. */
glTexture* gfx_space; glTexture* gfx_space;
ALuint sound; // Sound to play. ALuint sound; /* Sound to play. */
int spfx; // Special effect on hit. int spfx; /* Special effect on hit. */
unsigned int lockon; // Time taken to lock on the target. unsigned int lockon; /* Time taken to lock on the target. */
} amm; } amm;
struct { // Modification. struct { /* Modification. */
// Movement. /* Movement. */
double thrust, turn, speed; double thrust, turn, speed;
// Health. /* Health. */
double armour, armour_regen; double armour, armour_regen;
double shield, shield_regen; double shield, shield_regen;
double energy, energy_regen; double energy, energy_regen;
double fuel; double fuel;
// Misc. /* Misc. */
int cargo; // Cargo space to add. int cargo; /* Cargo space to add. */
} mod; } mod;
struct { // Afterburner. struct { /* Afterburner. */
double rumble; // Percent of rumble. double rumble; /* Percent of rumble. */
ALuint sound; // Sound of the afterburner. ALuint sound; /* Sound of the afterburner. */
double thrust_perc, thrust_abs; // Percent and absolute thrust bonus. double thrust_perc, thrust_abs; /* Percent and absolute thrust bonus. */
double speed_perc, speed_abs; // Percent and absolute speed bonus. double speed_perc, speed_abs; /* Percent and absolute speed bonus. */
double energy; // Energy used while active. double energy; /* Energy used while active. */
} afb; } afb;
} u; } u;
} Outfit; } Outfit;
// Misc. /* Misc. */
void outfit_calcDamage(double* dshield, double* darmour, void outfit_calcDamage(double* dshield, double* darmour,
DamageType dtype, double dmg); DamageType dtype, double dmg);
// Get. /* Get. */
Outfit* outfit_get(const char* name); Outfit* outfit_get(const char* name);
char** outfit_getTech(int* n, const int* tech, const int techmax); char** outfit_getTech(int* n, const int* tech, const int techmax);
// Outfit types. /* Outfit types. */
int outfit_isWeapon(const Outfit* o); int outfit_isWeapon(const Outfit* o);
int outfit_isLauncher(const Outfit* o); int outfit_isLauncher(const Outfit* o);
int outfit_isAmmo(const Outfit* o); int outfit_isAmmo(const Outfit* o);
@ -130,7 +130,7 @@ int outfit_isAfterburner(const Outfit* o);
const char* outfit_getType(const Outfit* o); const char* outfit_getType(const Outfit* o);
const char* outfit_getTypeBroad(const Outfit* o); const char* outfit_getTypeBroad(const Outfit* o);
// Get data from outfit. /* Get data from outfit. */
glTexture* outfit_gfx(const Outfit* o); glTexture* outfit_gfx(const Outfit* o);
int outfit_spfx(const Outfit* o); int outfit_spfx(const Outfit* o);
double outfit_damage(const Outfit* o); double outfit_damage(const Outfit* o);
@ -138,7 +138,7 @@ DamageType outfit_damageType(const Outfit* o);
int outfit_delay(const Outfit* o); int outfit_delay(const Outfit* o);
double outfit_energy(const Outfit* o); double outfit_energy(const Outfit* o);
// Load/free outfit stack. /* Load/free outfit stack. */
int outfit_load(void); int outfit_load(void);
void outfit_free(void); void outfit_free(void);

View File

@ -1,23 +1,23 @@
#pragma once #pragma once
#include <fcntl.h> #include <fcntl.h>
#ifndef _POSIX_SOURCE // No posix. #ifndef _POSIX_SOURCE /* No posix. */
#include <stdio.h> #include <stdio.h>
#endif #endif
#include <stdint.h> #include <stdint.h>
typedef struct Packfile_ { typedef struct Packfile_ {
#ifdef _POSIX_SOURCE #ifdef _POSIX_SOURCE
int fd; // File descriptor. int fd; /* File descriptor. */
#else #else
FILE* fp; FILE* fp;
#endif #endif
uint32_t pos; // position. uint32_t pos; /* position. */
uint32_t start, end; // file limits. uint32_t start, end; /* file limits. */
} Packfile; } Packfile;
// Packfile manipulation. Automatically allocated and freed (with open and close). /* Packfile manipulation. Automatically allocated and freed (with open and close). */
// Basic. /* Basic. */
int pack_check(const char* filename); int pack_check(const char* filename);
int pack_files(const char* outfile, const char** infiles, const uint32_t nfiles); int pack_files(const char* outfile, const char** infiles, const uint32_t nfiles);
int pack_open(Packfile* file, const char* packfile, const char* filename); int pack_open(Packfile* file, const char* packfile, const char* filename);
@ -26,7 +26,7 @@ off_t pack_seek(Packfile* file, off_t offset, int whence);
long pack_tell(Packfile* file); long pack_tell(Packfile* file);
int pack_close(Packfile* file); int pack_close(Packfile* file);
// Fancy stuff. /* Fancy stuff. */
void* pack_readfile(const char* packfile, const char* filename, uint32_t* filesize); void* pack_readfile(const char* packfile, const char* filename, uint32_t* filesize);
char** pack_listfiles(const char* packfile, uint32_t* nfiles); char** pack_listfiles(const char* packfile, uint32_t* nfiles);

View File

@ -14,19 +14,19 @@
#define vect_odist(v) MOD((v)->x, (v)->y) #define vect_odist(v) MOD((v)->x, (v)->y)
// Base of 2D vectors. /* Base of 2D vectors. */
typedef struct Vec2_ { 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;
// Misc /* Misc */
double angle_diff(const double ref, double a); double angle_diff(const double ref, double a);
void limit_speed(Vec2* vel, const double speed, const double dt); void limit_speed(Vec2* vel, const double speed, const double dt);
// Vector manupulation. /* Vector manupulation. */
void vect_cset(Vec2* v, const double x, const double y); void vect_cset(Vec2* v, const double x, const double y);
// Doesn't set mod nor angle. /* Doesn't set mod nor angle. */
void vect_csetmin(Vec2* v, const double x, const double y); void vect_csetmin(Vec2* v, const double x, const double y);
void vect_pset(Vec2* v, const double mod, const double angle); void vect_pset(Vec2* v, const double mod, const double angle);
void vectcpy(Vec2* dest, const Vec2* src); void vectcpy(Vec2* dest, const Vec2* src);
@ -34,14 +34,14 @@ void vectnull(Vec2* v);
double vect_angle(const Vec2* ref, const Vec2* v); 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. */
typedef 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; } 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,
const Vec2* pos, const Vec2* vel); const Vec2* pos, const Vec2* vel);
Solid* solid_create(const double mass, const double dir, Solid* solid_create(const double mass, const double dir,

View File

@ -9,139 +9,139 @@
#define PLAYER_ID 1 #define PLAYER_ID 1
#define HYPERSPACE_ENGINE_DELAY 3000 // Warm up the engines. #define HYPERSPACE_ENGINE_DELAY 3000 /* Warm up the engines. */
#define HYPERSPACE_FLY_DELAY 5000 // Time taken to hyperspace. #define HYPERSPACE_FLY_DELAY 5000 /* Time taken to hyperspace. */
#define HYPERSPACE_STARS_BLUR 2000 // Time stars blur. #define HYPERSPACE_STARS_BLUR 2000 /* Time stars blur. */
#define HYPERSPACE_STARS_LENGTH 1000 // Length the stars blur to at max. #define HYPERSPACE_STARS_LENGTH 1000 /* Length the stars blur to at max. */
#define HYPERSPACE_FADEOUT 1000 // Time fadeout. #define HYPERSPACE_FADEOUT 1000 /* Time fadeout. */
#define HYPERSPACE_FUEL 100 // Amount of fuel taken. #define HYPERSPACE_FUEL 100 /* Amount of fuel taken. */
// Aproximation for pilot size. /* Aproximation for pilot size. */
#define PILOT_SIZE_APROX 0.8 #define PILOT_SIZE_APROX 0.8
#define PILOT_DISABLED_ARMOUR 0.3 // Based on armour percentage. #define PILOT_DISABLED_ARMOUR 0.3 /* Based on armour percentage. */
// Hooks. /* Hooks. */
#define PILOT_HOOK_NONE 0 // No hook. #define PILOT_HOOK_NONE 0 /* No hook. */
#define PILOT_HOOK_DEATH 1 // Pilot died. #define PILOT_HOOK_DEATH 1 /* Pilot died. */
// Flags. /* Flags. */
#define pilot_isFlag(p,f) (p->flags & (f)) #define pilot_isFlag(p,f) (p->flags & (f))
#define pilot_setFlag(p,f) (p->flags |= (f)) #define pilot_setFlag(p,f) (p->flags |= (f))
#define pilot_rmFlag(p,f) (p->flags ^= (f)) #define pilot_rmFlag(p,f) (p->flags ^= (f))
// Creation. /* Creation. */
#define PILOT_PLAYER (1<<0) // Pilot is a player. #define PILOT_PLAYER (1<<0) /* Pilot is a player. */
#define PILOT_HASTURRET (1<<20) // Pilot has turrets. #define PILOT_HASTURRET (1<<20) /* Pilot has turrets. */
#define PILOT_NO_OUTFITS (1<<21) // Do not create the pilot with outfits. #define PILOT_NO_OUTFITS (1<<21) /* Do not create the pilot with outfits. */
#define PILOT_EMPTY (1<<22) // Do not add pilot to stack. #define PILOT_EMPTY (1<<22) /* Do not add pilot to stack. */
// Dynamic. /* Dynamic. */
#define PILOT_HOSTILE (1<<1) // Pilot is hostile to the player. #define PILOT_HOSTILE (1<<1) /* Pilot is hostile to the player. */
#define PILOT_COMBAT (1<<2) // Pilot is engaged in combat. #define PILOT_COMBAT (1<<2) /* Pilot is engaged in combat. */
#define PILOT_AFTERBURNER (1<<3) // Pilot has her afterburner activated. #define PILOT_AFTERBURNER (1<<3) /* Pilot has her afterburner activated. */
#define PILOT_HYP_PREP (1<<5) // Pilot is getting ready for hyperspace. #define PILOT_HYP_PREP (1<<5) /* Pilot is getting ready for hyperspace. */
#define PILOT_HYP_BEGIN (1<<6) // Pilot is starting engines. #define PILOT_HYP_BEGIN (1<<6) /* Pilot is starting engines. */
#define PILOT_HYPERSPACE (1<<7) // Pilot is in hyperspace. #define PILOT_HYPERSPACE (1<<7) /* Pilot is in hyperspace. */
#define PILOT_BOARDED (1<<8) // Pilot has been boarded already! #define PILOT_BOARDED (1<<8) /* Pilot has been boarded already! */
#define PILOT_DISABLED (1<<9) // Pilot is disabled. #define PILOT_DISABLED (1<<9) /* Pilot is disabled. */
#define PILOT_DEAD (1<<10) // Pilot is on it's death bed. #define PILOT_DEAD (1<<10) /* Pilot is on it's death bed. */
#define PILOT_EXPLODED (1<<11) // Pilot did final death explosion. #define PILOT_EXPLODED (1<<11) /* Pilot did final death explosion. */
#define PILOT_DELETE (1<<15) // Pilot will get delete asap. #define PILOT_DELETE (1<<15) /* Pilot will get delete asap. */
// Just makes life simpler. /* Just makes life simpler. */
#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 PilotOutfit_ { typedef struct PilotOutfit_ {
Outfit* outfit; // Associated outfit. Outfit* outfit; /* Associated outfit. */
int quantity; // Number of outfits of this type that the pilot has. 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;
// Pilot commodity. /* Pilot commodity. */
typedef struct PilotCommodity_ { typedef struct PilotCommodity_ {
Commodity* commodity; Commodity* commodity;
int quantity; int quantity;
unsigned int id; // Special mission id for cargo. unsigned int id; /* Special mission id for cargo. */
} PilotCommodity; } PilotCommodity;
// 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). */
char* title; // Title - Usuall indicating special properties - TODO. char* title; /* Title - Usuall indicating special properties - TODO. */
int faction; int faction;
// Object characteristics. /* Object characteristics. */
Ship* ship; // Pilots ship. Ship* ship; /* Pilots ship. */
Solid* solid; // Associated solid (physics). Solid* solid; /* Associated solid (physics). */
int tsx, tsy; // Current sprite, calculated on update. int tsx, tsy; /* Current sprite, calculated on update. */
double thrust, turn, speed; double thrust, turn, speed;
// Current health. /* Current health. */
double armour, shield, energy, fuel; double armour, shield, energy, fuel;
double armour_max, shield_max, energy_max, fuel_max; double armour_max, shield_max, energy_max, fuel_max;
double armour_regen, shield_regen, energy_regen; double armour_regen, shield_regen, energy_regen;
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;
int noutfits; int noutfits;
PilotOutfit* secondary; // Secondary weapon. PilotOutfit* secondary; /* Secondary weapon. */
PilotOutfit* ammo; // Secondary ammo (if needed). PilotOutfit* ammo; /* Secondary ammo (if needed). */
PilotOutfit* afterburner; // Ze afterburner. PilotOutfit* afterburner; /* Ze afterburner. */
// Cargo. /* Cargo. */
int credits; // Moniez the pilot has. int credits; /* Moniez the pilot has. */
PilotCommodity* commodities; // Commodity and quantity. PilotCommodity* commodities; /* Commodity and quantity. */
int ncommodities; int ncommodities;
int cargo_free; int cargo_free;
// Misc. /* Misc. */
uint32_t flags; // Used for AI etc. uint32_t flags; /* Used for AI etc. */
unsigned int ptimer; // Generic timer for internal pilot use. unsigned int ptimer; /* Generic timer for internal pilot use. */
// Hook attached to the pilot. /* Hook attached to the pilot. */
int hook_type; int hook_type;
int hook; int hook;
// AI. /* AI. */
AI_Profile* ai; // Ai personality profile. AI_Profile* ai; /* Ai personality profile. */
unsigned int tcontrol; // Timer for control tick. unsigned int tcontrol; /* Timer for control tick. */
unsigned int timer[MAX_AI_TIMERS]; // Timers for AI. unsigned int timer[MAX_AI_TIMERS]; /* Timers for AI. */
Task* task; // Current action. Task* task; /* Current action. */
} Pilot; } Pilot;
// Fleets. /* Fleets. */
typedef struct FleetPilot_ { 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 Fleet_ { typedef struct Fleet_ {
char* name; // Fleet name, used as an identifier. char* name; /* Fleet name, used as an identifier. */
int faction; // Faction of the fleet. int faction; /* Faction of the fleet. */
AI_Profile* ai; // A useable profile. AI_Profile* ai; /* A useable profile. */
FleetPilot* pilots; // The pilots in the fleet. FleetPilot* pilots; /* The pilots in the fleet. */
int npilots; // Total number of pilots. int npilots; /* Total number of pilots. */
} Fleet; } Fleet;
// Grabing pilot crap. /* Grabing pilot crap. */
extern Pilot* player; // The player. extern Pilot* player; /* The player. */
Pilot* pilot_get(unsigned int id); Pilot* pilot_get(unsigned int id);
unsigned int pilot_getNext(const unsigned int id); unsigned int pilot_getNext(const unsigned int id);
unsigned int pilot_getNearest(const Pilot* p); unsigned int pilot_getNearest(const Pilot* p);
unsigned int pilot_getHostile(void); // Only for the player. unsigned int pilot_getHostile(void); /* Only for the player. */
Fleet* fleet_get(const char* name); Fleet* fleet_get(const char* name);
int pilot_getJumps(const Pilot* p); int pilot_getJumps(const Pilot* p);
// MISC. /* MISC. */
void pilot_shoot(Pilot* p, const unsigned int target, const int secondary); void pilot_shoot(Pilot* p, const unsigned int target, const int secondary);
void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter, void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter,
const DamageType dtype, const double damage); const DamageType dtype, const double damage);
@ -149,23 +149,23 @@ void pilot_setSecondary(Pilot* p, const char* secondary);
void pilot_setAmmo(Pilot* p); void pilot_setAmmo(Pilot* p);
void pilot_setAfterburner(Pilot* p); void pilot_setAfterburner(Pilot* p);
double pilot_face(Pilot* p, const float dir); double pilot_face(Pilot* p, const float dir);
// Outfits. /* Outfits. */
int pilot_freeSpace(Pilot* p); // Pilot space. int pilot_freeSpace(Pilot* p); /* Pilot space. */
int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity); int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity);
int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity); int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity);
char* pilot_getOutfits(Pilot* pilot); char* pilot_getOutfits(Pilot* pilot);
void pilot_calcStats(Pilot* pilot); void pilot_calcStats(Pilot* pilot);
// Normal cargo. /* Normal cargo. */
int pilot_cagoUsed(Pilot* pilot); // Get amount of cargo onboard. int pilot_cagoUsed(Pilot* pilot); /* Get amount of cargo onboard. */
int pilot_cargoFree(Pilot* p); // Cargo space. int pilot_cargoFree(Pilot* p); /* Cargo space. */
int pilot_addCargo(Pilot* pilot, Commodity* cargo, int quantity); int pilot_addCargo(Pilot* pilot, Commodity* cargo, int quantity);
int pilot_rmCargo(Pilot* pilot, Commodity* cargo, int quantity); int pilot_rmCargo(Pilot* pilot, Commodity* cargo, int quantity);
// Mission cargo - Not to be confused with normal cargo. /* Mission cargo - Not to be confused with normal cargo. */
unsigned int pilot_addMissionCargo(Pilot* pilot, Commodity* cargo, int quantity); unsigned int pilot_addMissionCargo(Pilot* pilot, Commodity* cargo, int quantity);
int pilot_rmMissionCargo(Pilot* pilot, unsigned int cargo_id); int pilot_rmMissionCargo(Pilot* pilot, unsigned int cargo_id);
// Creation. /* Creation. */
void pilot_init(Pilot* dest, Ship* ship, char* name, int faction, void pilot_init(Pilot* dest, Ship* ship, char* name, int faction,
AI_Profile* ai, const double dir, const Vec2* pos, AI_Profile* ai, const double dir, const Vec2* pos,
const Vec2* vel, const int flags); const Vec2* vel, const int flags);
@ -179,16 +179,16 @@ Pilot* pilot_createEmpty(Ship* ship, char* name,
Pilot* pilot_copy(Pilot* src); Pilot* pilot_copy(Pilot* src);
// Init/Cleanup. /* Init/Cleanup. */
void pilot_destroy(Pilot* p); void pilot_destroy(Pilot* p);
void pilots_free(void); void pilots_free(void);
void pilots_clean(void); void pilots_clean(void);
void pilots_cleanAll(void); void pilots_cleanAll(void);
void pilot_free(Pilot* p); void pilot_free(Pilot* p);
int fleet_load(void); // TODO int fleet_load(void); /* TODO */
void fleet_free(void); void fleet_free(void);
// Update. /* Update. */
void pilots_update(double dt); void pilots_update(double dt);
void pilots_render(void); void pilots_render(void);

View File

@ -1,58 +1,58 @@
#pragma once #pragma once
#include "pilot.h" #include "pilot.h"
// Flag definitions. /* Flag definitions. */
#define PLAYER_TURN_LEFT (1<<0) // Player is turning left. #define PLAYER_TURN_LEFT (1<<0) /* Player is turning left. */
#define PLAYER_TURN_RIGHT (1<<1) // Player is turning right. #define PLAYER_TURN_RIGHT (1<<1) /* Player is turning right. */
#define PLAYER_REVERSE (1<<2) // Player is facint opposite vel. #define PLAYER_REVERSE (1<<2) /* Player is facint opposite vel. */
#define PLAYER_AFTERBURNER (1<<3) // Player is burning it up. #define PLAYER_AFTERBURNER (1<<3) /* Player is burning it up. */
#define PLAYER_DESTROYED (1<<9) // Player goes BOOM! #define PLAYER_DESTROYED (1<<9) /* Player goes BOOM! */
#define PLAYER_FACE (1<<10) // Player is facing target. #define PLAYER_FACE (1<<10) /* Player is facing target. */
#define PLAYER_PRIMARY (1<<11) // Player is shooting primary weapon. #define PLAYER_PRIMARY (1<<11) /* Player is shooting primary weapon. */
#define PLAYER_SECONDARY (1<<12) // Player is shooting secondary weapon. #define PLAYER_SECONDARY (1<<12) /* Player is shooting secondary weapon. */
#define PLAYER_LANDACK (1<<13) // Player has permission to land. #define PLAYER_LANDACK (1<<13) /* Player has permission to land. */
#define PLAYER_CREATING (1<<14) // Player is being created. #define PLAYER_CREATING (1<<14) /* Player is being created. */
// Flag functions. /* Flag functions. */
#define player_isFlag(f) (player_flags & f) #define player_isFlag(f) (player_flags & f)
#define player_setFlag(f) if(!player_isFlag(f)) (player_flags |= f) #define player_setFlag(f) if(!player_isFlag(f)) (player_flags |= f)
#define player_rmFlag(f) if(player_isFlag(f)) (player_flags ^= f) #define player_rmFlag(f) if(player_isFlag(f)) (player_flags ^= f)
// The player. /* The player. */
extern Pilot* pilot; extern Pilot* pilot;
extern char* player_name; extern char* player_name;
extern unsigned int player_flags; extern unsigned int player_flags;
extern int combat_crating; extern int combat_crating;
// Enums. /* Enums. */
// For render functions. /* For render functions. */
typedef enum RadarShape_ { RADAR_RECT, RADAR_CIRCLE } RadarShape; typedef enum RadarShape_ { RADAR_RECT, RADAR_CIRCLE } RadarShape;
// Creation/Cleanup. /* Creation/Cleanup. */
void player_new(void); 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); int gui_load(const char* name);
// Render. /* Render. */
int gui_init(void); int gui_init(void);
void gui_free(void); void gui_free(void);
void player_render(void); void player_render(void);
void player_renderBG(void); // Render BG layer. void player_renderBG(void); /* Render BG layer. */
// Misc. /* Misc. */
void player_message(const char* fmt, ...); void player_message(const char* fmt, ...);
void player_clear(void); void player_clear(void);
void player_warp(const double x, const double y); void player_warp(const double x, const double y);
const char* player_rating(void); const char* player_rating(void);
// Cargo. /* Cargo. */
int player_outfitOwned(const char* outfitname); int player_outfitOwned(const char* outfitname);
int player_cargoOwned(const char* commodityname); int player_cargoOwned(const char* commodityname);
void player_rmMissionCargo(unsigned int cargo_id); void player_rmMissionCargo(unsigned int cargo_id);
// Pilot ships. /* Pilot ships. */
char** player_ships(int* nships); char** player_ships(int* nships);
int player_nships(void); int player_nships(void);
Pilot* player_getShip(char* shipname); Pilot* player_getShip(char* shipname);
@ -60,11 +60,11 @@ char* player_getLoc(char* shipname);
void player_setLoc(char* shipname, char* loc); void player_setLoc(char* shipname, char* loc);
void player_swapShip(char* shipname); void player_swapShip(char* shipname);
// Player missions. /* Player missions. */
void player_missionFinished(int id); void player_missionFinished(int id);
int player_missionAlreadyDone(int id); int player_missionAlreadyDone(int id);
// Keybind actions. /* Keybind actions. */
void player_setRadarRel(int mod); void player_setRadarRel(int mod);
void player_secondaryNext(void); void player_secondaryNext(void);
void player_targetPlanet(void); void player_targetPlanet(void);

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#define RNG(L,H) ((int)L + (int)((double)(H-L+1) * randfp())) // L <= RNG <= H #define RNG(L,H) ((int)L + (int)((double)(H-L+1) * randfp())) /* L <= RNG <= H */
#define RNGF() (randfp()) #define RNGF() (randfp())
void rng_init(void); void rng_init(void);

View File

@ -3,7 +3,7 @@
#include "outfit.h" #include "outfit.h"
#include "sound.h" #include "sound.h"
// Target gfx dimensions. /* Target gfx dimensions. */
#define SHIP_TARGET_W 128 #define SHIP_TARGET_W 128
#define SHIP_TARGET_H 96 #define SHIP_TARGET_H 96
@ -23,63 +23,63 @@ typedef enum ShipClass_ {
SHIP_CLASS_HYB_HEAVY = 12 SHIP_CLASS_HYB_HEAVY = 12
} 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 Ship_ { typedef struct Ship_ {
char* name; // Ship name. char* name; /* Ship name. */
ShipClass class; // Ship class. ShipClass class; /* Ship class. */
// Store stuff. /* Store stuff. */
int price; // Price! int price; /* Price! */
int tech; int tech;
char* fabricator; // Manufacturer. char* fabricator; /* Manufacturer. */
char* description; // Sales pitch. char* description; /* Sales pitch. */
// Movement. /* Movement. */
double thrust, turn, speed; double thrust, turn, speed;
// Graphics. /* Graphics. */
glTexture* gfx_space, *gfx_target; glTexture* gfx_space, *gfx_target;
// GUI interface. /* GUI interface. */
char* gui; char* gui;
// Sound. /* Sound. */
ALuint sound; ALuint sound;
// Characteristics. /* Characteristics. */
int crew; int crew;
int mass; int mass;
int fuel; // How many jumps by default. int fuel; /* How many jumps by default. */
// Health. /* Health. */
double armour, armour_regen; double armour, armour_regen;
double shield, shield_regen; double shield, shield_regen;
double energy, energy_regen; double energy, energy_regen;
// Capacity. /* Capacity. */
int cap_cargo, cap_weapon; int cap_cargo, cap_weapon;
// Outfits /* Outfits */
ShipOutfit* outfit; ShipOutfit* outfit;
} Ship; } Ship;
// Get. /* Get. */
Ship* ship_get(const char* name); Ship* ship_get(const char* name);
char** ship_getTech(int* n, const int* tech, const int techmax); char** ship_getTech(int* n, const int* tech, const int techmax);
char* ship_class(Ship* p); char* ship_class(Ship* p);
// Load/quit. /* Load/quit. */
int ships_load(void); int ships_load(void);
void ships_free(void); void ships_free(void);
// Toolkit. /* Toolkit. */
void ship_view(char* shipname); void ship_view(char* shipname);

View File

@ -2,31 +2,31 @@
#include <AL/al.h> #include <AL/al.h>
#include "physics.h" #include "physics.h"
#define VOICE_LOOPING (1<<10) // Voice loops. #define VOICE_LOOPING (1<<10) /* Voice loops. */
#define VOICE_STATIC (1<<11) // Voice isn't relative. #define VOICE_STATIC (1<<11) /* Voice isn't relative. */
struct alVoice; struct alVoice;
typedef struct alVoice alVoice; typedef struct alVoice alVoice;
// Sound subsystem. /* Sound subsystem. */
int sound_init(void); int sound_init(void);
void sound_exit(void); void sound_exit(void);
void sound_update(void); void sound_update(void);
// Sound manupulation functions. /* Sound manupulation functions. */
ALuint sound_get(char* name); ALuint sound_get(char* name);
void sound_volume(const double vol); void sound_volume(const double vol);
// Voice manipulation function. /* Voice manipulation function. */
alVoice* sound_addVoice(int priority, double px, double py, alVoice* sound_addVoice(int priority, double px, double py,
double vx, double vy, const ALuint buffer, const unsigned int flags); double vx, double vy, const ALuint buffer, const unsigned int flags);
void sound_delVoice(alVoice* voice); // Delete voice. void sound_delVoice(alVoice* voice); /* Delete voice. */
void voice_update(alVoice* voice, double px, double py, double vx, double vy); void voice_update(alVoice* voice, double px, double py, double vx, double vy);
void voice_buffer(alVoice* voice, const ALuint buffer, const unsigned int flags); void voice_buffer(alVoice* voice, const ALuint buffer, const unsigned int flags);
void voice_stop(alVoice* voice); void voice_stop(alVoice* voice);
// Listener manipulation. /* Listener manipulation. */
void sound_listener(double dir, double px, double py, double vx, double vy); void sound_listener(double dir, double px, double py, double vx, double vy);

View File

@ -9,110 +9,110 @@
#define PLANET_TECH_MAX 8 #define PLANET_TECH_MAX 8
// 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 PlanetClass_ { 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. */
PLANET_CLASS_C, // Geoinactive. PLANET_CLASS_C, /* Geoinactive. */
PLANET_CLASS_D, // Asteroid/Moon. PLANET_CLASS_D, /* Asteroid/Moon. */
PLANET_CLASS_E, // Geoplastic. PLANET_CLASS_E, /* Geoplastic. */
PLANET_CLASS_F, // Geometallic. PLANET_CLASS_F, /* Geometallic. */
PLANET_CLASS_G, // GroCrystaline. PLANET_CLASS_G, /* GroCrystaline. */
PLANET_CLASS_H, // Desert. PLANET_CLASS_H, /* Desert. */
PLANET_CLASS_I, // Gas Supergiant. PLANET_CLASS_I, /* Gas Supergiant. */
PLANET_CLASS_J, // Gas Giant. PLANET_CLASS_J, /* Gas Giant. */
PLANET_CLASS_K, // Adaptable. PLANET_CLASS_K, /* Adaptable. */
PLANET_CLASS_L, // Marginal. PLANET_CLASS_L, /* Marginal. */
PLANET_CLASS_M, // Terrestrial. PLANET_CLASS_M, /* Terrestrial. */
PLANET_CLASS_N, // Reducing. PLANET_CLASS_N, /* Reducing. */
PLANET_CLASS_O, // Pelagic. PLANET_CLASS_O, /* Pelagic. */
PLANET_CLASS_P, // Glaciated. PLANET_CLASS_P, /* Glaciated. */
PLANET_CLASS_Q, // Variable. PLANET_CLASS_Q, /* Variable. */
PLANET_CLASS_R, // Rogue. PLANET_CLASS_R, /* Rogue. */
PLANET_CLASS_S, // Ultragiant. PLANET_CLASS_S, /* Ultragiant. */
PLANET_CLASS_T, // Ultragiant. PLANET_CLASS_T, /* Ultragiant. */
PLANET_CLASS_X, // Demon. PLANET_CLASS_X, /* Demon. */
PLANET_CLASS_Y, // Demon. PLANET_CLASS_Y, /* Demon. */
PLANET_CLASS_Z, // Demon. PLANET_CLASS_Z, /* Demon. */
STATION_CLASS_A, // Civilian station. STATION_CLASS_A, /* Civilian station. */
STATION_CLASS_B, // Military station. STATION_CLASS_B, /* Military station. */
STATION_CLASS_C, // Interfactional station. STATION_CLASS_C, /* Interfactional station. */
STATION_CLASS_D, // Robotoc station. STATION_CLASS_D, /* Robotoc station. */
} PlanetClass; } PlanetClass;
// Planet services. /* Planet services. */
#define PLANET_SERVICE_LAND (1<<0) // Can we land? #define PLANET_SERVICE_LAND (1<<0) /* Can we land? */
#define PLANET_SERVICE_BASIC (1<<1) // Refueling, spaceport bar, new. #define PLANET_SERVICE_BASIC (1<<1) /* Refueling, spaceport bar, new. */
#define PLANET_SERVICE_COMMODITY (1<<2) #define PLANET_SERVICE_COMMODITY (1<<2)
#define PLANET_SERVICE_OUTFITS (1<<3) #define PLANET_SERVICE_OUTFITS (1<<3)
#define PLANET_SERVICE_SHIPYARD (1<<4) #define PLANET_SERVICE_SHIPYARD (1<<4)
#define planet_hasService(p,s) ((p)->services & s) #define planet_hasService(p,s) ((p)->services & s)
typedef struct Planet_ { typedef struct Planet_ {
char* name; // Planet name char* name; /* Planet name */
Vec2 pos; // Position in star system. Vec2 pos; /* Position in star system. */
PlanetClass class; // Planet type. PlanetClass class; /* Planet type. */
int faction; // Planet faction. int faction; /* Planet faction. */
char* description; // Planet description. char* description; /* Planet description. */
char* bar_description; // Spaceport bar description. char* bar_description; /* Spaceport bar description. */
unsigned int services; // Offered services. unsigned int services; /* Offered services. */
Commodity** commodities; // Commodities sold. Commodity** commodities; /* Commodities sold. */
int ncommodities; // Amount in stock. int ncommodities; /* Amount in stock. */
// tech[0] stores global tech level (everything that and below) while /* tech[0] stores global tech level (everything that and below) while */
// tech[1-PLANET_TECH_MAX] stores the unique tech levels. /* tech[1-PLANET_TECH_MAX] stores the unique tech levels. */
int tech[PLANET_TECH_MAX]; int tech[PLANET_TECH_MAX];
glTexture* gfx_space; // Graphics in space. glTexture* gfx_space; /* Graphics in space. */
glTexture* gfx_exterior; // Graphics in the exterior. glTexture* gfx_exterior; /* Graphics in the exterior. */
} Planet; } Planet;
// Star systems. /* Star systems. */
typedef struct SystemFleet_ { 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 StarSystem_ { 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! */
double interference; // Un uh.. Percentage. double interference; /* Un uh.. Percentage. */
int faction; // Overall faction. int faction; /* Overall faction. */
Planet* planets; // Planets. Planet* planets; /* Planets. */
int nplanets; // Total number of planets. int nplanets; /* Total number of planets. */
SystemFleet* fleets; // Fleets that can appear in the current system. SystemFleet* fleets; /* Fleets that can appear in the current system. */
int nfleets; // Total number of fleets. int nfleets; /* Total number of fleets. */
int* jumps; // Adjacent star system index number. int* jumps; /* Adjacent star system index number. */
int njumps; // Number of adjacent jumps. int njumps; /* Number of adjacent jumps. */
} StarSystem; } StarSystem;
extern StarSystem* cur_system; // Current star system. extern StarSystem* cur_system; /* Current star system. */
// Load/Exit. /* Load/Exit. */
void space_init(const char* sysname); void space_init(const char* sysname);
int space_load(void); int space_load(void);
void space_exit(void); void space_exit(void);
// Planet stuff. /* Planet stuff. */
char* planet_getSystem(char* planetname); char* planet_getSystem(char* planetname);
Planet* planet_get(char* planetname); Planet* planet_get(char* planetname);
// Render. /* Render. */
void space_render(double dt); void space_render(double dt);
void planets_render(void); void planets_render(void);
// Update. /* Update. */
void space_update(const double dt); void space_update(const double dt);
// Misc. /* Misc. */
StarSystem** system_getJumpPath(int* njumps, char* sysstart, char* sysend); StarSystem** system_getJumpPath(int* njumps, char* sysstart, char* sysend);
int space_canHyperspace(Pilot* p); int space_canHyperspace(Pilot* p);
int space_hyperspace(Pilot* p); int space_hyperspace(Pilot* p);

View File

@ -5,33 +5,33 @@
#define SPFX_LAYER_FRONT 0 #define SPFX_LAYER_FRONT 0
#define SPFX_LAYER_BACK 1 #define SPFX_LAYER_BACK 1
#define SHAKE_DECAY 50. // Decay parameter. #define SHAKE_DECAY 50. /* Decay parameter. */
#define SHAKE_MAX 50.*SCREEN_W*SCREEN_H/1024./768. // Max parameter. #define SHAKE_MAX 50.*SCREEN_W*SCREEN_H/1024./768. /* Max parameter. */
// Stack manipulation. /* Stack manipulation. */
int spfx_get(char* name); int spfx_get(char* name);
void spfx_add(const int effect, void spfx_add(const int effect,
const double px, const double py, const double px, const double py,
const double vx, const double vy, const double vx, const double vy,
const int layer); const int layer);
// Stack mass manipulation functions. /* Stack mass manipulation functions. */
void spfx_update(const double dt); void spfx_update(const double dt);
void spfx_render(const int layer); void spfx_render(const int layer);
void spfx_clear(void); void spfx_clear(void);
// Get ready to rumble! /* Get ready to rumble! */
void spfx_start(double dt); void spfx_start(double dt);
void spfx_shake(double mod); void spfx_shake(double mod);
// Other effects. /* Other effects. */
void spfx_cinematic(void); void spfx_cinematic(void);
// Load/free. /* Load/free. */
int spfx_load(void); int spfx_load(void);
void spfx_free(void); void spfx_free(void);
// Pause/Unpause routines. /* Pause/Unpause routines. */
void spfx_pause(void); void spfx_pause(void);
void spfx_unpause(void); void spfx_unpause(void);
void spfx_delay(unsigned int delay); void spfx_delay(unsigned int delay);

View File

@ -5,7 +5,7 @@
extern int toolkit; extern int toolkit;
// Creation. /* Creation. */
unsigned int window_create(char* name, const int x, const int y, unsigned int window_create(char* name, const int x, const int y,
const int w, const int h); const int w, const int h);
@ -21,19 +21,19 @@ void window_addImage(const unsigned int wid, const int x, const int y,
char* name, glTexture* image, int border); char* name, glTexture* image, int border);
void window_addList(const unsigned int wid, void window_addList(const unsigned int wid,
const int x, const int y, // Position. const int x, const int y, /* Position. */
const int w, const int h, // Size. const int w, const int h, /* Size. */
char* name, char** items, int nitems, int defitem, char* name, char** items, int nitems, int defitem,
void(*call)(char*)); void(*call)(char*));
void window_addRect(const unsigned int wid, void window_addRect(const unsigned int wid,
const int x, const int y, // Position. const int x, const int y, /* Position. */
const int w, const int h, // size. const int w, const int h, /* size. */
char* name, glColour* colour, int border); // Properties. char* name, glColour* colour, int border); /* Properties. */
void window_addCust(const unsigned int wid, void window_addCust(const unsigned int wid,
const int x, const int y, // Position. const int x, const int y, /* Position. */
const int w, const int h, // Size. const int w, const int h, /* Size. */
char* name, const int border, char* name, const int border,
void(*render) (double x, double y, double w, double h), void(*render) (double x, double y, double w, double h),
void(*mouse) (SDL_Event* event, double x, double y)); void(*mouse) (SDL_Event* event, double x, double y));
@ -43,27 +43,27 @@ void window_addInput(const unsigned int wid,
const int w, const int h, const int w, const int h,
char* name, const int max, const int oneline); char* name, const int max, const int oneline);
// Popups and alerts. /* Popups and alerts. */
// Does not pause execution. /* Does not pause execution. */
void dialogue_alert(const char* fmt, ...); void dialogue_alert(const char* fmt, ...);
void dialogue_msg(char* caption, const char* fmt, ...); void dialogue_msg(char* caption, const char* fmt, ...);
// Yes = 1, No = 0. /* Yes = 1, No = 0. */
int dialogue_YesNo(char* caption, const char* fmt, ...); int dialogue_YesNo(char* caption, const char* fmt, ...);
char* dialogue_input(char* title, int min, int max, const char* fmt, ...); char* dialogue_input(char* title, int min, int max, const char* fmt, ...);
// Modification. /* Modification. */
void window_setFptr(const unsigned int wid, void(*fptr)(char*)); void window_setFptr(const unsigned int wid, void(*fptr)(char*));
// Text. /* Text. */
void window_modifyText(const unsigned int wid, char* name, char* newstring); void window_modifyText(const unsigned int wid, char* name, char* newstring);
// Button. /* Button. */
void window_disableButton(const unsigned int wid, char* name); void window_disableButton(const unsigned int wid, char* name);
void window_enableButton(const unsigned int wid, char* name); void window_enableButton(const unsigned int wid, char* name);
// Image. /* Image. */
void window_modifyImage(const unsigned int wid, char* name, glTexture* image); void window_modifyImage(const unsigned int wid, char* name, glTexture* image);
void window_imgColour(const unsigned int wid, char* name, glColour* colour); void window_imgColour(const unsigned int wid, char* name, glColour* colour);
// Get the window by name. /* Get the window by name. */
int window_exists(const char* wdwname); int window_exists(const char* wdwname);
unsigned int window_get(const char* wdwname); unsigned int window_get(const char* wdwname);
char* toolkit_getList(const unsigned int wid, char* name); char* toolkit_getList(const unsigned int wid, char* name);
@ -71,18 +71,18 @@ int toolkit_getListPos(const unsigned int wid, char* name);
glTexture* window_getImage(const unsigned int wid, char* name); glTexture* window_getImage(const unsigned int wid, char* name);
char* window_getInput(const unsigned int wid, char* name); char* window_getInput(const unsigned int wid, char* name);
// Destroy window. /* Destroy window. */
void window_destroy(const unsigned int wid); void window_destroy(const unsigned int wid);
void window_destroyWidget(unsigned wid, const char* wgtname); void window_destroyWidget(unsigned wid, const char* wgtname);
// Render. /* Render. */
void toolkit_render(void); void toolkit_render(void);
// Input. /* Input. */
int toolkit_input(SDL_Event* event); int toolkit_input(SDL_Event* event);
void toolkit_update(void); void toolkit_update(void);
// Init/Exit. /* Init/Exit. */
int toolkit_init(void); int toolkit_init(void);
void toolkit_exit(void); void toolkit_exit(void);

View File

@ -8,16 +8,16 @@ void weapon_add(const Outfit* outfit, const double dir, const Vec2* pos,
const Vec2* vel, unsigned int parent, const Vec2* vel, unsigned int parent,
const unsigned int target); const unsigned int target);
// Pausing. /* Pausing. */
void weapons_pause(void); void weapons_pause(void);
void weapons_unpause(void); void weapons_unpause(void);
void weapons_delay(unsigned int delay); void weapons_delay(unsigned int delay);
// Update. /* Update. */
void weapons_update(const double dt); void weapons_update(const double dt);
void weapons_render(const WeaponLayer layer); void weapons_render(const WeaponLayer layer);
// Clean. /* Clean. */
void weapon_clear(void); void weapon_clear(void);
void weapon_exit(void); void weapon_exit(void);

View File

@ -8,24 +8,24 @@
#define XML_NODE_START 1 #define XML_NODE_START 1
#define XML_NODE_TEXT 3 #define XML_NODE_TEXT 3
// Check if node n is of name s. /* Check if node n is of name s. */
#define xml_isNode(n,s) (((n)->type == XML_NODE_START) && \ #define xml_isNode(n,s) (((n)->type == XML_NODE_START) && \
(strcmp((char*)(n)->name, s)==0)) (strcmp((char*)(n)->name, s)==0))
// Get the next node. /* Get the next node. */
#define xml_nextNode(n) \ #define xml_nextNode(n) \
((n!=NULL) && ((n = n->next) != NULL)) ((n!=NULL) && ((n = n->next) != NULL))
// Get the property s of node n. This mallocs. /* Get the property s of node n. This mallocs. */
#define xml_nodeProp(n,s) (char*)xmlGetProp(n, (xmlChar*)s) #define xml_nodeProp(n,s) (char*)xmlGetProp(n, (xmlChar*)s)
// Get data different ways. /* Get data different ways. */
#define xml_get(n) ((char*)(n)->children->content) #define xml_get(n) ((char*)(n)->children->content)
#define xml_getInt(n) (atoi((char*)(n)->children->content)) #define xml_getInt(n) (atoi((char*)(n)->children->content))
#define xml_getLong(n) (atoi((char*)(n)->children->content)) #define xml_getLong(n) (atoi((char*)(n)->children->content))
#define xml_getFloat(n) (atof((char*)(n)->children->content)) #define xml_getFloat(n) (atof((char*)(n)->children->content))
// Reader crap. /* Reader crap. */
#define xmlr_int(n,s,i) \ #define xmlr_int(n,s,i) \
if(xml_isNode(n,s)) { i = xml_getInt(n); continue; } if(xml_isNode(n,s)) { i = xml_getInt(n); continue; }
#define xmlr_long(n,s,l) \ #define xmlr_long(n,s,l) \
@ -39,9 +39,9 @@
#define xmlr_attr(n,s,a) \ #define xmlr_attr(n,s,a) \
a = xml_nodeProp(n,s) a = xml_nodeProp(n,s)
// Writer crap. /* Writer crap. */
// Encompassing element. /* Encompassing element. */
#define xmlw_startElem(w, str) \ #define xmlw_startElem(w, str) \
if(xmlTextWriterStartElement(w, (xmlChar*)str) < 0) { \ if(xmlTextWriterStartElement(w, (xmlChar*)str) < 0) { \
ERR("xmlw: Unable to create start element"); return -1; } ERR("xmlw: Unable to create start element"); return -1; }
@ -50,7 +50,7 @@
if(xmlTextWriterEndElement(w) < 0) { \ if(xmlTextWriterEndElement(w) < 0) { \
ERR("xmlw: Unable to create end element"); return -1; } ERR("xmlw: Unable to create end element"); return -1; }
// Other stuff. /* Other stuff. */
#define xmlw_elem(w, n, str, args...) \ #define xmlw_elem(w, n, str, args...) \
if(xmlTextWriterWriteFormatElement(w, (xmlChar*)n, str, ## args) < 0) { \ if(xmlTextWriterWriteFormatElement(w, (xmlChar*)n, str, ## args) < 0) { \
ERR("xmlw: Unable to write format element"); return -1; } ERR("xmlw: Unable to write format element"); return -1; }
@ -67,7 +67,7 @@
if(xmlTextWriterWriteFormatString(w, str, ## val) < 0) { \ if(xmlTextWriterWriteFormatString(w, str, ## val) < 0) { \
ERR("xmlw: Unable to write element data"); return -1; } ERR("xmlw: Unable to write element data"); return -1; }
// Document level. /* Document level. */
#define xmlw_start(w) \ #define xmlw_start(w) \
if(xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL) < 0) { \ if(xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL) < 0) { \
ERR("xmlw: Unable to start document"); return -1; } ERR("xmlw: Unable to start document"); return -1; }

View File

@ -18,7 +18,7 @@
#endif #endif
#define RGBAMASK RMASK, GMASK, BMASK, AMASK #define RGBAMASK RMASK, GMASK, BMASK, AMASK
// Logging macros. /* Logging macros. */
#define LOG(str, args...)(fprintf(stdout, str"\n", ## args)) #define LOG(str, args...)(fprintf(stdout, str"\n", ## args))
#define WARN(str, args...)(fprintf(stderr, "Warning: "str"\n", ## args)) #define WARN(str, args...)(fprintf(stderr, "Warning: "str"\n", ## args))
#define ERR(str, args...) { fprintf(stderr, "ERROR %s:%d: "str"\n", \ #define ERR(str, args...) { fprintf(stderr, "ERROR %s:%d: "str"\n", \
@ -37,7 +37,7 @@ int main(int argc, char* argv[]) {
SDL_Surface* final, *tmp, **load; SDL_Surface* final, *tmp, **load;
SDL_Rect r; SDL_Rect r;
// Init variables. /* Init variables. */
r.w = r.h = 0; r.w = r.h = 0;
if(argc == 2) { if(argc == 2) {
@ -55,22 +55,22 @@ int main(int argc, char* argv[]) {
tmp = NULL; tmp = NULL;
final = NULL; final = NULL;
// Init SDL. /* Init SDL. */
if(SDL_Init(SDL_INIT_VIDEO)) ERR("Initializing SDL: %s", SDL_GetError()); if(SDL_Init(SDL_INIT_VIDEO)) ERR("Initializing SDL: %s", SDL_GetError());
// Create the window. /* Create the window. */
tmp = SDL_SetVideoMode(320, 240, 0, SDL_NOFRAME); tmp = SDL_SetVideoMode(320, 240, 0, SDL_NOFRAME);
if(tmp == NULL) ERR("Initializing video surface: %s", SDL_GetError()); if(tmp == NULL) ERR("Initializing video surface: %s", SDL_GetError());
// Open RAM for the images. /* Open RAM for the images. */
load = malloc(sizeof(SDL_Surface*)*(ws*hs)); load = malloc(sizeof(SDL_Surface*)*(ws*hs));
if(load == NULL) ERR("Out of RAM"); if(load == NULL) ERR("Out of RAM");
// Load all the images to RAM. /* Load all the images to RAM. */
for(i = 0; i < (ws*hs); i++) { for(i = 0; i < (ws*hs); i++) {
// Filenames will be in the sequence of: 000.png, 001.png, ..., 045.png, etc. /* Filenames will be in the sequence of: 000.png, 001.png, ..., 045.png, etc. */
sprintf(file, "%d%d%d.png", i/100, (i%100)/10, i%10); sprintf(file, "%d%d%d.png", i/100, (i%100)/10, i%10);
// Load the image properly. /* Load the image properly. */
tmp = IMG_Load(file); tmp = IMG_Load(file);
if(tmp == NULL) ERR("Problem loading file '%s': %s", file, IMG_GetError()); if(tmp == NULL) ERR("Problem loading file '%s': %s", file, IMG_GetError());
sflags = tmp->flags & (SDL_SRCALPHA | SDL_SRCCOLORKEY); sflags = tmp->flags & (SDL_SRCALPHA | SDL_SRCCOLORKEY);
@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {
load[i] = tmp; load[i] = tmp;
// Check if size has changed. /* Check if size has changed. */
if(r.w == 0 && r.h == 0) { if(r.w == 0 && r.h == 0) {
r.w = load[i]->w; r.w = load[i]->w;
r.h = load[i]->h; r.h = load[i]->h;
@ -90,21 +90,21 @@ int main(int argc, char* argv[]) {
else if((r.w != load[i]->w) || (r.h != load[i]->h)) else if((r.w != load[i]->w) || (r.h != load[i]->h))
ERR("File '%s' is not of the same dimensions as the files before!", file); ERR("File '%s' is not of the same dimensions as the files before!", file);
// Create the suface if it hasn't been created already. /* Create the suface if it hasn't been created already. */
if(!final) { if(!final) {
final = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, ws*r.w, hs*r.h, final = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, ws*r.w, hs*r.h,
load[i]->format->BitsPerPixel, RGBAMASK); load[i]->format->BitsPerPixel, RGBAMASK);
if(!final) ERR("Problem creating RGB Surface: %s", SDL_GetError()); if(!final) ERR("Problem creating RGB Surface: %s", SDL_GetError());
tmp = final; tmp = final;
} }
// New position. /* New position. */
r.y = r.h * (i/ws); r.y = r.h * (i/ws);
r.x = r.w * (i%ws); r.x = r.w * (i%ws);
if(SDL_BlitSurface(load[i], NULL, final, &r)) if(SDL_BlitSurface(load[i], NULL, final, &r))
ERR("Problem blitting surface '%s' to final surface: %s", file, SDL_GetError()); ERR("Problem blitting surface '%s' to final surface: %s", file, SDL_GetError());
SDL_FreeSurface(load[i]); SDL_FreeSurface(load[i]);
} }
// Draw the result and cleanup. /* Draw the result and cleanup. */
save_png(final, "sprite.png"); save_png(final, "sprite.png");
SDL_FreeSurface(final); SDL_FreeSurface(final);
free(load); free(load);

View File

@ -23,7 +23,7 @@ int main(int argc, char** argv) {
argv += 2; argv += 2;
if(nfiles == 0) { if(nfiles == 0) {
// No files, list what it has. /* No files, list what it has. */
list = pack_listfiles(packfile, &nlist); list = pack_listfiles(packfile, &nlist);
fprintf(stdout, "Packfile '%s' contains:\n", packfile); fprintf(stdout, "Packfile '%s' contains:\n", packfile);
for(i = 0; i < nlist; i++) { for(i = 0; i < nlist; i++) {
@ -31,7 +31,7 @@ int main(int argc, char** argv) {
free(list[i]); free(list[i]);
} }
free(list); free(list);
} else { // Create a packfile. } else { /* Create a packfile. */
pack_files(packfile, (const char**)argv, nfiles); pack_files(packfile, (const char**)argv, nfiles);
} }