Ahem. Forgot headers. Apparently, all the source/header should be updated. Woops
This commit is contained in:
		
							parent
							
								
									a2bb0df939
								
							
						
					
					
						commit
						858295b3f4
					
				
							
								
								
									
										14
									
								
								src/ai.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/ai.h
									
									
									
									
									
								
							@ -5,32 +5,32 @@
 | 
			
		||||
#define MAX_DIR_ERR 0.5*M_PI/180.
 | 
			
		||||
#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
 | 
			
		||||
 | 
			
		||||
typedef enum TaskData_ { TYPE_NULL, TYPE_INT, TYPE_PTR } TaskData;
 | 
			
		||||
 | 
			
		||||
// Basic task.
 | 
			
		||||
/* Basic task. */
 | 
			
		||||
typedef struct Task_ {
 | 
			
		||||
  struct Task_* next;
 | 
			
		||||
  char* name;
 | 
			
		||||
 | 
			
		||||
  TaskData dtype;
 | 
			
		||||
  union {
 | 
			
		||||
    void* target; // Vec2 etc.
 | 
			
		||||
    unsigned int ID; // Pilot ID etc.
 | 
			
		||||
    void* target; /* Vec2 etc. */
 | 
			
		||||
    unsigned int ID; /* Pilot ID etc. */
 | 
			
		||||
  } dat;
 | 
			
		||||
} Task;
 | 
			
		||||
 | 
			
		||||
// Ai profile.
 | 
			
		||||
/* Ai profile. */
 | 
			
		||||
typedef struct AI_Profile_ {
 | 
			
		||||
  char* name;
 | 
			
		||||
  lua_State* L;
 | 
			
		||||
} AI_Profile;
 | 
			
		||||
 | 
			
		||||
// Misc.
 | 
			
		||||
/* Misc. */
 | 
			
		||||
AI_Profile* ai_getProfile(char* name);
 | 
			
		||||
 | 
			
		||||
int ai_init(void);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								src/colour.h
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/colour.h
									
									
									
									
									
								
							@ -1,17 +1,17 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
// Colours.
 | 
			
		||||
/* Colours. */
 | 
			
		||||
typedef struct glColour_ {
 | 
			
		||||
  double r, g, b, a;
 | 
			
		||||
} glColour;
 | 
			
		||||
 | 
			
		||||
// Default colors.
 | 
			
		||||
// -- Greyscale.
 | 
			
		||||
/* Default colors. */
 | 
			
		||||
/* -- Greyscale. */
 | 
			
		||||
extern glColour cWhite;
 | 
			
		||||
#define cGrey   cGrey70
 | 
			
		||||
extern glColour cBlack;
 | 
			
		||||
 | 
			
		||||
// Greys
 | 
			
		||||
/* Greys */
 | 
			
		||||
extern glColour cGrey90;
 | 
			
		||||
extern glColour cGrey80;
 | 
			
		||||
extern glColour cGrey70;
 | 
			
		||||
@ -30,21 +30,21 @@ extern glColour cDarkBlue;
 | 
			
		||||
extern glColour cBlue;
 | 
			
		||||
extern glColour cPurple;
 | 
			
		||||
 | 
			
		||||
// Game specific.
 | 
			
		||||
/* Game specific. */
 | 
			
		||||
extern glColour cConsole;
 | 
			
		||||
extern glColour cDConsole;
 | 
			
		||||
// Toolkit.
 | 
			
		||||
/* Toolkit. */
 | 
			
		||||
extern glColour cHilight;
 | 
			
		||||
// Objects.
 | 
			
		||||
/* Objects. */
 | 
			
		||||
extern glColour cInert;
 | 
			
		||||
extern glColour cNeutral;
 | 
			
		||||
extern glColour cFriend;
 | 
			
		||||
extern glColour cHostile;
 | 
			
		||||
// Radar.
 | 
			
		||||
/* Radar. */
 | 
			
		||||
extern glColour cRadar_player;
 | 
			
		||||
extern glColour cRadar_targ;
 | 
			
		||||
extern glColour cRadar_weap;
 | 
			
		||||
// Health.
 | 
			
		||||
/* Health. */
 | 
			
		||||
extern glColour cShield;
 | 
			
		||||
extern glColour cArmour;
 | 
			
		||||
extern glColour cEnergy;
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
// Loading.
 | 
			
		||||
/* Loading. */
 | 
			
		||||
void conf_setDefaults(void);
 | 
			
		||||
int conf_loadConfig(const char* file);
 | 
			
		||||
void conf_parseCLI(int argc, char** argv);
 | 
			
		||||
 | 
			
		||||
// Saving.
 | 
			
		||||
/* Saving. */
 | 
			
		||||
int conf_saveConfig(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -3,14 +3,14 @@
 | 
			
		||||
typedef struct Commodity_ {
 | 
			
		||||
  char* name;
 | 
			
		||||
  char* description;
 | 
			
		||||
  int low, medium, high; // Prices.
 | 
			
		||||
  int low, medium, high; /* Prices. */
 | 
			
		||||
} Commodity;
 | 
			
		||||
 | 
			
		||||
// Commidity stuff.
 | 
			
		||||
/* Commidity stuff. */
 | 
			
		||||
Commodity* commodity_get(const char* name);
 | 
			
		||||
int commodity_load(void);
 | 
			
		||||
void commodity_free(void);
 | 
			
		||||
 | 
			
		||||
// Misc.
 | 
			
		||||
/* Misc. */
 | 
			
		||||
void credits2str(char* str, unsigned int credits, int decimals);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,27 +2,27 @@
 | 
			
		||||
 | 
			
		||||
#define FACTION_PLAYER 0
 | 
			
		||||
 | 
			
		||||
// Get stuff.
 | 
			
		||||
/* Get stuff. */
 | 
			
		||||
int faction_get(const char* name);
 | 
			
		||||
int faction_getAlliance(char* name);
 | 
			
		||||
char* faction_name(int f);
 | 
			
		||||
 | 
			
		||||
// Player stuff.
 | 
			
		||||
/* Player stuff. */
 | 
			
		||||
void faction_modPlayer(int f, int mod);
 | 
			
		||||
int faction_getPlayer(int f);
 | 
			
		||||
 | 
			
		||||
// Works with only factions.
 | 
			
		||||
/* Works with only factions. */
 | 
			
		||||
int areEnemies(int a, int b);
 | 
			
		||||
int areAllies(int a, int b);
 | 
			
		||||
 | 
			
		||||
// Faction + Alliance.
 | 
			
		||||
/* Faction + Alliance. */
 | 
			
		||||
int faction_ofAlliance(int f, int a);
 | 
			
		||||
 | 
			
		||||
// Check.
 | 
			
		||||
/* Check. */
 | 
			
		||||
int faction_isAlliance(int a);
 | 
			
		||||
int faction_isFaction(int f);
 | 
			
		||||
 | 
			
		||||
// Load/Free.
 | 
			
		||||
/* Load/Free. */
 | 
			
		||||
int factions_load(void);
 | 
			
		||||
void factions_free(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										22
									
								
								src/font.h
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/font.h
									
									
									
									
									
								
							@ -1,39 +1,39 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "opengl.h"
 | 
			
		||||
 | 
			
		||||
// Font info.
 | 
			
		||||
/* Font info. */
 | 
			
		||||
typedef struct glFont_ {
 | 
			
		||||
  int h; // Height.
 | 
			
		||||
  int h; /* Height. */
 | 
			
		||||
  int* w;
 | 
			
		||||
  GLuint* textures;
 | 
			
		||||
  GLuint list_base;
 | 
			
		||||
} glFont;
 | 
			
		||||
 | 
			
		||||
extern glFont gl_defFont; // Default font.
 | 
			
		||||
extern glFont gl_smallFont; // Small font.
 | 
			
		||||
extern glFont gl_defFont; /* Default font. */
 | 
			
		||||
extern glFont gl_smallFont; /* Small font. */
 | 
			
		||||
 | 
			
		||||
// glFont loading/freeing.
 | 
			
		||||
// If font is NULL it uses the internal default font, same with gl_print
 | 
			
		||||
/* glFont loading/freeing. */
 | 
			
		||||
/* 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_freeFont(glFont* font);
 | 
			
		||||
 | 
			
		||||
// Print text.
 | 
			
		||||
/* Print text. */
 | 
			
		||||
void gl_print(const glFont* ft_font, const double x, const double y,
 | 
			
		||||
              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,
 | 
			
		||||
                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,
 | 
			
		||||
                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,
 | 
			
		||||
                 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_printHeight(const glFont* ft_font, const int width,
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										26
									
								
								src/hook.h
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								src/hook.h
									
									
									
									
									
								
							@ -1,25 +1,25 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "mission.h"
 | 
			
		||||
 | 
			
		||||
// Add/Run hooks.
 | 
			
		||||
/* Add/Run hooks. */
 | 
			
		||||
unsigned int hook_add(unsigned int parent, char* func, char* stack);
 | 
			
		||||
void hook_rm(unsigned int id);
 | 
			
		||||
void hook_rmParent(unsigned int parent);
 | 
			
		||||
 | 
			
		||||
// ========================================================
 | 
			
		||||
// Run Hooks:
 | 
			
		||||
//
 | 
			
		||||
// Currently used:
 | 
			
		||||
//    -- "land"     - When landed.
 | 
			
		||||
//    -- "takeoff"  - When taking off.
 | 
			
		||||
//    -- "jump"     - When changing systems.
 | 
			
		||||
//    -- "time"     - When time is increment drastically 
 | 
			
		||||
//                    (hyperspace and taking off.
 | 
			
		||||
// ========================================================
 | 
			
		||||
/* ======================================================== */
 | 
			
		||||
/* Run Hooks: */
 | 
			
		||||
/* */
 | 
			
		||||
/* Currently used: */
 | 
			
		||||
/*    -- "land"     - When landed. */
 | 
			
		||||
/*    -- "takeoff"  - When taking off. */
 | 
			
		||||
/*    -- "jump"     - When changing systems. */
 | 
			
		||||
/*    -- "time"     - When time is increment drastically  */
 | 
			
		||||
/*                    (hyperspace and taking off. */
 | 
			
		||||
/* ======================================================== */
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <SDL.h>
 | 
			
		||||
 | 
			
		||||
// Input types.
 | 
			
		||||
/* Input types. */
 | 
			
		||||
typedef enum {
 | 
			
		||||
  KEYBIND_NULL,
 | 
			
		||||
  KEYBIND_KEYBOARD,
 | 
			
		||||
@ -9,15 +9,15 @@ typedef enum {
 | 
			
		||||
  KEYBIND_JBUTTON
 | 
			
		||||
} KeybindType;
 | 
			
		||||
 | 
			
		||||
// Set input.
 | 
			
		||||
/* Set input. */
 | 
			
		||||
void input_setDefault(void);
 | 
			
		||||
void input_setKeybind(char* keybind, KeybindType type, int key, int reverse);
 | 
			
		||||
int  input_getKeybind(char* keybind, KeybindType* type, int* reverse);
 | 
			
		||||
 | 
			
		||||
// Handle the events.
 | 
			
		||||
/* Handle the events. */
 | 
			
		||||
void input_handle(SDL_Event* event);
 | 
			
		||||
 | 
			
		||||
// Init/Exit.
 | 
			
		||||
/* Init/Exit. */
 | 
			
		||||
void input_init(void);
 | 
			
		||||
void input_exit(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,12 +1,12 @@
 | 
			
		||||
#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);
 | 
			
		||||
 | 
			
		||||
// 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);
 | 
			
		||||
 | 
			
		||||
// Exit functions.
 | 
			
		||||
/* Exit functions. */
 | 
			
		||||
int joystick_init(void);
 | 
			
		||||
void joystick_exit(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -12,18 +12,18 @@
 | 
			
		||||
 | 
			
		||||
#define pow2(x)  ((x)*(x))
 | 
			
		||||
 | 
			
		||||
#define DATA_DEF    "data"  // Default data packfile.
 | 
			
		||||
extern char* data;          // Modifiable datafile.
 | 
			
		||||
#define DATA        data    // Data file.
 | 
			
		||||
#define DATA_NAME_LEN 32    // Max length of data name.
 | 
			
		||||
#define DATA_DEF    "data"  /* Default data packfile. */
 | 
			
		||||
extern char* data;          /* Modifiable datafile. */
 | 
			
		||||
#define DATA        data    /* Data file. */
 | 
			
		||||
#define DATA_NAME_LEN 32    /* Max length of data name. */
 | 
			
		||||
extern char dataname[DATA_NAME_LEN];
 | 
			
		||||
 | 
			
		||||
// Max filename path.
 | 
			
		||||
/* Max filename path. */
 | 
			
		||||
#ifndef PATH_MAX
 | 
			
		||||
#  define PATH_MAX 128
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef M_PI
 | 
			
		||||
#define M_PI 3.14159265358979323846 // Pi.
 | 
			
		||||
#define M_PI 3.14159265358979323846 /* Pi. */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "lua.h"
 | 
			
		||||
 | 
			
		||||
// Individual libraries.
 | 
			
		||||
int lua_loadLephisto(lua_State* L);   // Always read only.
 | 
			
		||||
/* Individual libraries. */
 | 
			
		||||
int lua_loadLephisto(lua_State* L);   /* Always read only. */
 | 
			
		||||
int lua_loadSpace(lua_State* L, int readonly);
 | 
			
		||||
int lua_loadTime(lua_State* L, int readonly);
 | 
			
		||||
int lua_loadRnd(lua_State* L);        // Always read only.
 | 
			
		||||
int lua_loadTk(lua_State* L);         // Always read only.
 | 
			
		||||
int lua_loadRnd(lua_State* L);        /* Always read only. */
 | 
			
		||||
int lua_loadTk(lua_State* L);         /* Always read only. */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,7 @@
 | 
			
		||||
#include "lauxlib.h"
 | 
			
		||||
#include "lualib.h"
 | 
			
		||||
 | 
			
		||||
// Debug stuff.
 | 
			
		||||
/* Debug stuff. */
 | 
			
		||||
#define LLUA_DEBUG(str, args...) \
 | 
			
		||||
  (fprintf(stdout, "Lua: "str"\n", ## args))
 | 
			
		||||
 | 
			
		||||
@ -19,7 +19,7 @@
 | 
			
		||||
    return 0; \
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
// Comfortability macros.
 | 
			
		||||
/* Comfortability macros. */
 | 
			
		||||
#define luaL_dobuffer(L, b, n, s) \
 | 
			
		||||
  (luaL_loadbuffer(L, b, n, s) || lua_pcall(L, 0, LUA_MULTRET, 0))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,13 +1,13 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
// How long a 'unit' of time is.
 | 
			
		||||
/* How long a 'unit' of time is. */
 | 
			
		||||
#define LTIME_UNIT_LENGTH 1000
 | 
			
		||||
 | 
			
		||||
// Get.
 | 
			
		||||
/* Get. */
 | 
			
		||||
unsigned int ltime_get(void);
 | 
			
		||||
char* ltime_pretty(unsigned int t);
 | 
			
		||||
 | 
			
		||||
// Set.
 | 
			
		||||
/* Set. */
 | 
			
		||||
void ltime_set(unsigned int t);
 | 
			
		||||
void ltime_inc(unsigned int t);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,9 +1,9 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
// Open the map window.
 | 
			
		||||
/* Open the map window. */
 | 
			
		||||
void map_open(void);
 | 
			
		||||
 | 
			
		||||
// Misc.
 | 
			
		||||
/* Misc. */
 | 
			
		||||
void map_clear(void);
 | 
			
		||||
void map_jump(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,15 +2,15 @@
 | 
			
		||||
 | 
			
		||||
#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);
 | 
			
		||||
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_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_loadVar(lua_State* L, int readonly);
 | 
			
		||||
int lua_loadPlayer(lua_State* L);
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,7 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "misn_lua.h"
 | 
			
		||||
 | 
			
		||||
// Availability by location.
 | 
			
		||||
/* Availability by location. */
 | 
			
		||||
#define MIS_AVAIL_NONE        0
 | 
			
		||||
#define MIS_AVAIL_COMPUTER    1
 | 
			
		||||
#define MIS_AVAIL_BAR         2
 | 
			
		||||
@ -9,73 +9,73 @@
 | 
			
		||||
#define MIS_AVAIL_SHIPYARD    4
 | 
			
		||||
#define MIS_AVAIL_LAND        5
 | 
			
		||||
 | 
			
		||||
// Flags.
 | 
			
		||||
/* Flags. */
 | 
			
		||||
#define mis_isFlag(m,f)   ((m)->flags  & (f))
 | 
			
		||||
#define mis_setFlag(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_ {
 | 
			
		||||
  char* name; // the name of the mission.
 | 
			
		||||
  char* name; /* the name of the mission. */
 | 
			
		||||
 | 
			
		||||
  // Availability.
 | 
			
		||||
  /* Availability. */
 | 
			
		||||
  struct {
 | 
			
		||||
    int loc;      // Location.
 | 
			
		||||
    int chance;   // Chance of it appearing.
 | 
			
		||||
    int loc;      /* Location. */
 | 
			
		||||
    int chance;   /* Chance of it appearing. */
 | 
			
		||||
 | 
			
		||||
    // For specific cases.
 | 
			
		||||
    /* For specific cases. */
 | 
			
		||||
    char* planet;
 | 
			
		||||
    char* system;
 | 
			
		||||
 | 
			
		||||
    // For generic cases.
 | 
			
		||||
    /* For generic cases. */
 | 
			
		||||
    int* factions;
 | 
			
		||||
    int nfactions;
 | 
			
		||||
 | 
			
		||||
    char* cond;   // Conditional that must be met.
 | 
			
		||||
    char* cond;   /* Conditional that must be met. */
 | 
			
		||||
  } avail;
 | 
			
		||||
 | 
			
		||||
  unsigned int flags; // Flags to store binary properties.
 | 
			
		||||
  unsigned int flags; /* Flags to store binary properties. */
 | 
			
		||||
 | 
			
		||||
  char* lua;
 | 
			
		||||
} MissionData;
 | 
			
		||||
 | 
			
		||||
// Active mission.
 | 
			
		||||
/* Active mission. */
 | 
			
		||||
typedef struct Mission_ {
 | 
			
		||||
  MissionData* data;
 | 
			
		||||
  // Unique mission identifier, used for keeping track of hooks.
 | 
			
		||||
  /* Unique mission identifier, used for keeping track of hooks. */
 | 
			
		||||
  unsigned int id;
 | 
			
		||||
 | 
			
		||||
  char* title;  // Not to be confused with name..
 | 
			
		||||
  char* desc;   // Description of the mission.
 | 
			
		||||
  char* reward; // Rewards - in text.
 | 
			
		||||
  char* title;  /* Not to be confused with name.. */
 | 
			
		||||
  char* desc;   /* Description of the mission. */
 | 
			
		||||
  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;
 | 
			
		||||
  int ncargo;
 | 
			
		||||
 | 
			
		||||
  lua_State* L; // The state of the running lua code.
 | 
			
		||||
  lua_State* L; /* The state of the running lua code. */
 | 
			
		||||
} 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];
 | 
			
		||||
 | 
			
		||||
// For mission computer.
 | 
			
		||||
/* For mission computer. */
 | 
			
		||||
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);
 | 
			
		||||
void missions_bar(int faction, char* planet, char* system);
 | 
			
		||||
 | 
			
		||||
// Misc.
 | 
			
		||||
/* Misc. */
 | 
			
		||||
int mission_getID(char* name);
 | 
			
		||||
MissionData* mission_get(int id);
 | 
			
		||||
 | 
			
		||||
// Cargo stuff.
 | 
			
		||||
/* Cargo stuff. */
 | 
			
		||||
void mission_linkCargo(Mission* misn, unsigned int cargo_id);
 | 
			
		||||
void mission_unlinkCargo(Mission* misn, unsigned int cargo_id);
 | 
			
		||||
 | 
			
		||||
// Load/Quit.
 | 
			
		||||
/* Load/Quit. */
 | 
			
		||||
int missions_load(void);
 | 
			
		||||
void mission_cleanup(Mission* misn);
 | 
			
		||||
void missions_free(void);
 | 
			
		||||
 | 
			
		||||
@ -1,22 +1,22 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "lua.h"
 | 
			
		||||
 | 
			
		||||
// Thread.
 | 
			
		||||
/* Thread. */
 | 
			
		||||
int music_thread(void* unused);
 | 
			
		||||
void music_kill(void);
 | 
			
		||||
 | 
			
		||||
// Init/Exit.
 | 
			
		||||
/* Init/Exit. */
 | 
			
		||||
int music_init(void);
 | 
			
		||||
int music_makeList(void);
 | 
			
		||||
void music_exit(void);
 | 
			
		||||
 | 
			
		||||
// Music control.
 | 
			
		||||
/* Music control. */
 | 
			
		||||
void music_volume(const double vol);
 | 
			
		||||
void music_load(const char* name);
 | 
			
		||||
void music_play(void);
 | 
			
		||||
void music_stop(void);
 | 
			
		||||
 | 
			
		||||
// Lua control.
 | 
			
		||||
/* Lua control. */
 | 
			
		||||
int lua_loadMusic(lua_State* L, int read_only);
 | 
			
		||||
int music_choose(char* situation);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										60
									
								
								src/opengl.h
									
									
									
									
									
								
							
							
						
						
									
										60
									
								
								src/opengl.h
									
									
									
									
									
								
							@ -5,7 +5,7 @@
 | 
			
		||||
#include "colour.h"
 | 
			
		||||
#include "physics.h"
 | 
			
		||||
 | 
			
		||||
// Recommended for compatibility bullshit.
 | 
			
		||||
/* Recommended for compatibility bullshit. */
 | 
			
		||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
 | 
			
		||||
#  define RMASK 0xff000000
 | 
			
		||||
#  define GMASK 0x00ff0000
 | 
			
		||||
@ -19,7 +19,7 @@
 | 
			
		||||
#endif
 | 
			
		||||
#define RGBMASK RMASK,GMASK,BMASK,AMASK
 | 
			
		||||
 | 
			
		||||
// Info about opengl screen.
 | 
			
		||||
/* Info about opengl screen. */
 | 
			
		||||
#define OPENGL_FULLSCREEN   (1<<0)
 | 
			
		||||
#define OPENGL_DOUBLEBUF    (1<<1)
 | 
			
		||||
#define OPENGL_AA_POINT     (1<<2)
 | 
			
		||||
@ -27,15 +27,15 @@
 | 
			
		||||
#define OPENGL_AA_POLYGON   (1<<4)
 | 
			
		||||
#define OPENGL_FRAG_SHADER  (1<<5)
 | 
			
		||||
#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_ {
 | 
			
		||||
  int w, h;         // Window dimensions.
 | 
			
		||||
  int depth;        // Depth in bpp.
 | 
			
		||||
  int r, g, b, a;   // Framebuffer values in bits.
 | 
			
		||||
  int flags;        // Store different properties.
 | 
			
		||||
  int tex_max;      // Max texture size.
 | 
			
		||||
  int w, h;         /* Window dimensions. */
 | 
			
		||||
  int depth;        /* Depth in bpp. */
 | 
			
		||||
  int r, g, b, a;   /* Framebuffer values in bits. */
 | 
			
		||||
  int flags;        /* Store different properties. */
 | 
			
		||||
  int tex_max;      /* Max texture size. */
 | 
			
		||||
} 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_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 ACOLOUR(x,a) glColor4d((x).r, (x).g, (x).b, a)
 | 
			
		||||
 | 
			
		||||
// Spritesheet info.
 | 
			
		||||
/* Spritesheet info. */
 | 
			
		||||
typedef struct glTexture_ {
 | 
			
		||||
  double w, h;        // Real size of the image (excluding POT buffer.
 | 
			
		||||
  double rw, rh;      // Size of POT surface.
 | 
			
		||||
  double sx, sy;      // Number of sprites on x and y axes.
 | 
			
		||||
  double sw, sh;      // Size of each sprite.
 | 
			
		||||
  GLuint texture;     // The opengl texture itself.
 | 
			
		||||
  uint8_t* trans;     // Maps the transparency.
 | 
			
		||||
  double w, h;        /* Real size of the image (excluding POT buffer. */
 | 
			
		||||
  double rw, rh;      /* Size of POT surface. */
 | 
			
		||||
  double sx, sy;      /* Number of sprites on x and y axes. */
 | 
			
		||||
  double sw, sh;      /* Size of each sprite. */
 | 
			
		||||
  GLuint texture;     /* The opengl texture itself. */
 | 
			
		||||
  uint8_t* trans;     /* Maps the transparency. */
 | 
			
		||||
} glTexture;
 | 
			
		||||
 | 
			
		||||
// gl_texute loading/freeing.
 | 
			
		||||
glTexture* gl_loadImage(SDL_Surface* surface); // Frees the surface.
 | 
			
		||||
/* gl_texute loading/freeing. */
 | 
			
		||||
glTexture* gl_loadImage(SDL_Surface* surface); /* Frees the surface. */
 | 
			
		||||
glTexture* gl_newImage(const char* path);
 | 
			
		||||
glTexture* gl_newSprite(const char* path, const int sx, const int sy);
 | 
			
		||||
void gl_freeTexture(glTexture* texture);
 | 
			
		||||
 | 
			
		||||
// Rendering.
 | 
			
		||||
// Blits a sprite, relative pos.
 | 
			
		||||
/* Rendering. */
 | 
			
		||||
/* Blits a sprite, relative pos. */
 | 
			
		||||
void gl_blitSprite(const glTexture* sprite, const double bx, const double by,
 | 
			
		||||
                   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,
 | 
			
		||||
    const double bx, const double by,
 | 
			
		||||
    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,
 | 
			
		||||
                   const glColour* c);
 | 
			
		||||
 | 
			
		||||
// Bind the camera to a vector.
 | 
			
		||||
/* Bind the camera to a vector. */
 | 
			
		||||
void gl_bindCamera(const Vec2* pos);
 | 
			
		||||
 | 
			
		||||
// Circle drawing.
 | 
			
		||||
/* Circle drawing. */
 | 
			
		||||
void gl_drawCircle(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 rh);
 | 
			
		||||
 | 
			
		||||
// Initialize/cleanup.
 | 
			
		||||
/* Initialize/cleanup. */
 | 
			
		||||
int gl_init(void);
 | 
			
		||||
void gl_exit(void);
 | 
			
		||||
 | 
			
		||||
// Misc.
 | 
			
		||||
/* Misc. */
 | 
			
		||||
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_screenshot(const char* filename);
 | 
			
		||||
//#if DEBUG == 1
 | 
			
		||||
/*#if DEBUG == 1 */
 | 
			
		||||
void gl_checkErr(void);
 | 
			
		||||
//#else
 | 
			
		||||
//#define gl_checkErr()
 | 
			
		||||
//#endif
 | 
			
		||||
/*#else */
 | 
			
		||||
/*#define gl_checkErr() */
 | 
			
		||||
/*#endif */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										102
									
								
								src/outfit.h
									
									
									
									
									
								
							
							
						
						
									
										102
									
								
								src/outfit.h
									
									
									
									
									
								
							@ -3,10 +3,10 @@
 | 
			
		||||
#include "sound.h"
 | 
			
		||||
 | 
			
		||||
#define outfit_isProp(o,p)  ((o)->properties & p)
 | 
			
		||||
// Property flags.
 | 
			
		||||
/* Property flags. */
 | 
			
		||||
#define OUTFIT_PROP_WEAP_SECONDARY (1<<0)
 | 
			
		||||
 | 
			
		||||
// Outfit types.
 | 
			
		||||
/* Outfit types. */
 | 
			
		||||
typedef enum OutfitType_ {
 | 
			
		||||
  OUTFIT_TYPE_NULL                      = 0,
 | 
			
		||||
  OUTFIT_TYPE_BOLT                      = 1,
 | 
			
		||||
@ -33,94 +33,94 @@ typedef enum DamageType_ {
 | 
			
		||||
  DAMAGE_TYPE_KINETIC = 2
 | 
			
		||||
} DamageType;
 | 
			
		||||
 | 
			
		||||
// An outfit depends a lot on the type.
 | 
			
		||||
/* An outfit depends a lot on the type. */
 | 
			
		||||
typedef struct Outfit_ {
 | 
			
		||||
  char* name;
 | 
			
		||||
 | 
			
		||||
  // General specs.
 | 
			
		||||
  /* General specs. */
 | 
			
		||||
  int max;
 | 
			
		||||
  int tech;
 | 
			
		||||
  int mass;
 | 
			
		||||
 | 
			
		||||
  // Store stuff.
 | 
			
		||||
  /* Store stuff. */
 | 
			
		||||
  unsigned int price;
 | 
			
		||||
  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;
 | 
			
		||||
  union {
 | 
			
		||||
    struct { // Bolt.
 | 
			
		||||
      unsigned int delay; // Delay between shots.
 | 
			
		||||
      double speed;       // Speed of shot. (not applicable to beam.
 | 
			
		||||
    struct { /* Bolt. */
 | 
			
		||||
      unsigned int delay; /* Delay between shots. */
 | 
			
		||||
      double speed;       /* Speed of shot. (not applicable to beam. */
 | 
			
		||||
      double range;
 | 
			
		||||
      double accuracy;    // Desviation accuracy.
 | 
			
		||||
      double energy;      // Energy usage.
 | 
			
		||||
      DamageType dtype;   // Damage type.
 | 
			
		||||
      double damage;      // Damage.
 | 
			
		||||
      double accuracy;    /* Desviation accuracy. */
 | 
			
		||||
      double energy;      /* Energy usage. */
 | 
			
		||||
      DamageType dtype;   /* Damage type. */
 | 
			
		||||
      double damage;      /* Damage. */
 | 
			
		||||
 | 
			
		||||
      glTexture* gfx_space;
 | 
			
		||||
      ALuint sound; // Sound to play.
 | 
			
		||||
      int spfx;     // Special effect on hit.
 | 
			
		||||
      ALuint sound; /* Sound to play. */
 | 
			
		||||
      int spfx;     /* Special effect on hit. */
 | 
			
		||||
    } blt;
 | 
			
		||||
    struct { // Beam.
 | 
			
		||||
      double range;     // Distance it travels.
 | 
			
		||||
      glColour colour;  // Beam colour.
 | 
			
		||||
      double energy;    // Energy drained.
 | 
			
		||||
      double damage_armour, damage_shield; // Damage.
 | 
			
		||||
    struct { /* Beam. */
 | 
			
		||||
      double range;     /* Distance it travels. */
 | 
			
		||||
      glColour colour;  /* Beam colour. */
 | 
			
		||||
      double energy;    /* Energy drained. */
 | 
			
		||||
      double damage_armour, damage_shield; /* Damage. */
 | 
			
		||||
    } bem;
 | 
			
		||||
    struct { // Launcher.
 | 
			
		||||
      unsigned int delay; // Delay between shots.
 | 
			
		||||
    struct { /* Launcher. */
 | 
			
		||||
      unsigned int delay; /* Delay between shots. */
 | 
			
		||||
      char* ammo;
 | 
			
		||||
    } lau;
 | 
			
		||||
    struct { // Ammo.
 | 
			
		||||
      unsigned int duration;  // Duration.
 | 
			
		||||
      double speed;           // Max speed.
 | 
			
		||||
      double turn;            // Turn vel.
 | 
			
		||||
      double thrust;          // Acceleration.
 | 
			
		||||
      double energy;          // Energy usage.
 | 
			
		||||
      DamageType dtype;       // Damage type.
 | 
			
		||||
      double damage;          // Damage.
 | 
			
		||||
    struct { /* Ammo. */
 | 
			
		||||
      unsigned int duration;  /* Duration. */
 | 
			
		||||
      double speed;           /* Max speed. */
 | 
			
		||||
      double turn;            /* Turn vel. */
 | 
			
		||||
      double thrust;          /* Acceleration. */
 | 
			
		||||
      double energy;          /* Energy usage. */
 | 
			
		||||
      DamageType dtype;       /* Damage type. */
 | 
			
		||||
      double damage;          /* Damage. */
 | 
			
		||||
 | 
			
		||||
      glTexture* gfx_space;
 | 
			
		||||
      ALuint sound;         // Sound to play.
 | 
			
		||||
      int spfx;             // Special effect on hit.
 | 
			
		||||
      unsigned int lockon;  // Time taken to lock on the target.
 | 
			
		||||
      ALuint sound;         /* Sound to play. */
 | 
			
		||||
      int spfx;             /* Special effect on hit. */
 | 
			
		||||
      unsigned int lockon;  /* Time taken to lock on the target. */
 | 
			
		||||
    } amm;
 | 
			
		||||
    struct { // Modification.
 | 
			
		||||
      // Movement.
 | 
			
		||||
    struct { /* Modification. */
 | 
			
		||||
      /* Movement. */
 | 
			
		||||
      double thrust, turn, speed;
 | 
			
		||||
 | 
			
		||||
      // Health.
 | 
			
		||||
      /* Health. */
 | 
			
		||||
      double armour, armour_regen;
 | 
			
		||||
      double shield, shield_regen;
 | 
			
		||||
      double energy, energy_regen;
 | 
			
		||||
      double fuel;
 | 
			
		||||
 | 
			
		||||
      // Misc.
 | 
			
		||||
      int cargo; // Cargo space to add.
 | 
			
		||||
      /* Misc. */
 | 
			
		||||
      int cargo; /* Cargo space to add. */
 | 
			
		||||
    } mod;
 | 
			
		||||
    struct { // Afterburner.
 | 
			
		||||
      double rumble;                    // Percent of rumble.
 | 
			
		||||
      ALuint sound;                     // Sound of the afterburner.
 | 
			
		||||
      double thrust_perc, thrust_abs;   // Percent and absolute thrust bonus.
 | 
			
		||||
      double speed_perc, speed_abs;     // Percent and absolute speed bonus.
 | 
			
		||||
      double energy;                    // Energy used while active.
 | 
			
		||||
    struct { /* Afterburner. */
 | 
			
		||||
      double rumble;                    /* Percent of rumble. */
 | 
			
		||||
      ALuint sound;                     /* Sound of the afterburner. */
 | 
			
		||||
      double thrust_perc, thrust_abs;   /* Percent and absolute thrust bonus. */
 | 
			
		||||
      double speed_perc, speed_abs;     /* Percent and absolute speed bonus. */
 | 
			
		||||
      double energy;                    /* Energy used while active. */
 | 
			
		||||
    } afb;
 | 
			
		||||
  } u;
 | 
			
		||||
} Outfit;
 | 
			
		||||
 | 
			
		||||
// Misc.
 | 
			
		||||
/* Misc. */
 | 
			
		||||
void outfit_calcDamage(double* dshield, double* darmour,
 | 
			
		||||
    DamageType dtype, double dmg);
 | 
			
		||||
 | 
			
		||||
// Get.
 | 
			
		||||
/* Get. */
 | 
			
		||||
Outfit* outfit_get(const char* name);
 | 
			
		||||
char** outfit_getTech(int* n, const int* tech, const int techmax);
 | 
			
		||||
// Outfit types.
 | 
			
		||||
/* Outfit types. */
 | 
			
		||||
int outfit_isWeapon(const Outfit* o);
 | 
			
		||||
int outfit_isLauncher(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_getTypeBroad(const Outfit* o);
 | 
			
		||||
 | 
			
		||||
// Get data from outfit.
 | 
			
		||||
/* Get data from outfit. */
 | 
			
		||||
glTexture* outfit_gfx(const Outfit* o);
 | 
			
		||||
int outfit_spfx(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);
 | 
			
		||||
double outfit_energy(const Outfit* o);
 | 
			
		||||
 | 
			
		||||
// Load/free outfit stack.
 | 
			
		||||
/* Load/free outfit stack. */
 | 
			
		||||
int outfit_load(void);
 | 
			
		||||
void outfit_free(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								src/pack.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/pack.h
									
									
									
									
									
								
							@ -1,23 +1,23 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include <fcntl.h>
 | 
			
		||||
#ifndef _POSIX_SOURCE // No posix.
 | 
			
		||||
#ifndef _POSIX_SOURCE /* No posix. */
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#endif
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
typedef struct Packfile_ {
 | 
			
		||||
#ifdef _POSIX_SOURCE
 | 
			
		||||
  int fd; // File descriptor.
 | 
			
		||||
  int fd; /* File descriptor. */
 | 
			
		||||
#else
 | 
			
		||||
  FILE* fp;
 | 
			
		||||
#endif
 | 
			
		||||
  uint32_t pos; // position.
 | 
			
		||||
  uint32_t start, end; // file limits.
 | 
			
		||||
  uint32_t pos; /* position. */
 | 
			
		||||
  uint32_t start, end; /* file limits. */
 | 
			
		||||
} 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_files(const char* outfile, const char** infiles, const uint32_t nfiles);
 | 
			
		||||
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);
 | 
			
		||||
int pack_close(Packfile* file);
 | 
			
		||||
 | 
			
		||||
// Fancy stuff.
 | 
			
		||||
/* Fancy stuff. */
 | 
			
		||||
void* pack_readfile(const char* packfile, const char* filename, uint32_t* filesize);
 | 
			
		||||
char** pack_listfiles(const char* packfile, uint32_t* nfiles);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -14,19 +14,19 @@
 | 
			
		||||
#define vect_odist(v)   MOD((v)->x, (v)->y)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Base of 2D vectors.
 | 
			
		||||
/* Base of 2D vectors. */
 | 
			
		||||
typedef struct Vec2_ {
 | 
			
		||||
  double x, y; // Cartesian values.
 | 
			
		||||
  double mod, angle; // Polar values.
 | 
			
		||||
  double x, y; /* Cartesian values. */
 | 
			
		||||
  double mod, angle; /* Polar values. */
 | 
			
		||||
} Vec2;
 | 
			
		||||
 | 
			
		||||
// Misc
 | 
			
		||||
/* Misc */
 | 
			
		||||
double angle_diff(const double ref, double a);
 | 
			
		||||
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);
 | 
			
		||||
// 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_pset(Vec2* v, const double mod, const double angle);
 | 
			
		||||
void vectcpy(Vec2* dest, const Vec2* src);
 | 
			
		||||
@ -34,14 +34,14 @@ void vectnull(Vec2* v);
 | 
			
		||||
double vect_angle(const Vec2* ref, const Vec2* v);
 | 
			
		||||
void vect_cadd(Vec2* v, const double x, const double y);
 | 
			
		||||
 | 
			
		||||
// Describe any solid in 2D space.
 | 
			
		||||
/* Describe any solid in 2D space. */
 | 
			
		||||
typedef struct Solid_ {
 | 
			
		||||
  double mass, dir, dir_vel; // Properties.
 | 
			
		||||
  Vec2 vel, pos, force; // Position/velocity vectors.
 | 
			
		||||
  void(*update)(struct Solid_*, const double); // Update method.
 | 
			
		||||
  double mass, dir, dir_vel; /* Properties. */
 | 
			
		||||
  Vec2 vel, pos, force; /* Position/velocity vectors. */
 | 
			
		||||
  void(*update)(struct Solid_*, const double); /* Update method. */
 | 
			
		||||
} Solid;
 | 
			
		||||
 | 
			
		||||
// Solid manipulation.
 | 
			
		||||
/* Solid manipulation. */
 | 
			
		||||
void solid_init(Solid* dest, const double mass, const double dir,
 | 
			
		||||
                const Vec2* pos, const Vec2* vel);
 | 
			
		||||
Solid* solid_create(const double mass, const double dir,
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										172
									
								
								src/pilot.h
									
									
									
									
									
								
							
							
						
						
									
										172
									
								
								src/pilot.h
									
									
									
									
									
								
							@ -9,139 +9,139 @@
 | 
			
		||||
 | 
			
		||||
#define PLAYER_ID 1
 | 
			
		||||
 | 
			
		||||
#define HYPERSPACE_ENGINE_DELAY   3000  // Warm up the engines.
 | 
			
		||||
#define HYPERSPACE_FLY_DELAY      5000  // Time taken to hyperspace.
 | 
			
		||||
#define HYPERSPACE_STARS_BLUR     2000  // Time stars blur.
 | 
			
		||||
#define HYPERSPACE_STARS_LENGTH   1000  // Length the stars blur to at max.
 | 
			
		||||
#define HYPERSPACE_FADEOUT        1000  // Time fadeout.
 | 
			
		||||
#define HYPERSPACE_FUEL           100   // Amount of fuel taken.
 | 
			
		||||
#define HYPERSPACE_ENGINE_DELAY   3000  /* Warm up the engines. */
 | 
			
		||||
#define HYPERSPACE_FLY_DELAY      5000  /* Time taken to hyperspace. */
 | 
			
		||||
#define HYPERSPACE_STARS_BLUR     2000  /* Time stars blur. */
 | 
			
		||||
#define HYPERSPACE_STARS_LENGTH   1000  /* Length the stars blur to at max. */
 | 
			
		||||
#define HYPERSPACE_FADEOUT        1000  /* Time fadeout. */
 | 
			
		||||
#define HYPERSPACE_FUEL           100   /* Amount of fuel taken. */
 | 
			
		||||
 | 
			
		||||
// Aproximation for pilot size.
 | 
			
		||||
/* Aproximation for pilot size. */
 | 
			
		||||
#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.
 | 
			
		||||
#define PILOT_HOOK_NONE           0     // No hook.
 | 
			
		||||
#define PILOT_HOOK_DEATH          1     // Pilot died.
 | 
			
		||||
/* Hooks. */
 | 
			
		||||
#define PILOT_HOOK_NONE           0     /* No hook. */
 | 
			
		||||
#define PILOT_HOOK_DEATH          1     /* Pilot died. */
 | 
			
		||||
 | 
			
		||||
// Flags.
 | 
			
		||||
/* Flags. */
 | 
			
		||||
#define pilot_isFlag(p,f)   (p->flags & (f))
 | 
			
		||||
#define pilot_setFlag(p,f)  (p->flags |= (f))
 | 
			
		||||
#define pilot_rmFlag(p,f)   (p->flags ^= (f))
 | 
			
		||||
// Creation.
 | 
			
		||||
#define PILOT_PLAYER        (1<<0)  // Pilot is a player.
 | 
			
		||||
#define PILOT_HASTURRET     (1<<20) // Pilot has turrets.
 | 
			
		||||
#define PILOT_NO_OUTFITS    (1<<21) // Do not create the pilot with outfits.
 | 
			
		||||
#define PILOT_EMPTY         (1<<22) // Do not add pilot to stack.
 | 
			
		||||
// Dynamic.
 | 
			
		||||
#define PILOT_HOSTILE       (1<<1)  // Pilot is hostile to the player.
 | 
			
		||||
#define PILOT_COMBAT        (1<<2)  // Pilot is engaged in combat.
 | 
			
		||||
#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_BEGIN     (1<<6)  // Pilot is starting engines.
 | 
			
		||||
#define PILOT_HYPERSPACE    (1<<7)  // Pilot is in hyperspace.
 | 
			
		||||
#define PILOT_BOARDED       (1<<8)  // Pilot has been boarded already!
 | 
			
		||||
#define PILOT_DISABLED      (1<<9)  // Pilot is disabled.
 | 
			
		||||
#define PILOT_DEAD          (1<<10) // Pilot is on it's death bed.
 | 
			
		||||
#define PILOT_EXPLODED      (1<<11) // Pilot did final death explosion.
 | 
			
		||||
#define PILOT_DELETE        (1<<15) // Pilot will get delete asap.
 | 
			
		||||
/* Creation. */
 | 
			
		||||
#define PILOT_PLAYER        (1<<0)  /* Pilot is a player. */
 | 
			
		||||
#define PILOT_HASTURRET     (1<<20) /* Pilot has turrets. */
 | 
			
		||||
#define PILOT_NO_OUTFITS    (1<<21) /* Do not create the pilot with outfits. */
 | 
			
		||||
#define PILOT_EMPTY         (1<<22) /* Do not add pilot to stack. */
 | 
			
		||||
/* Dynamic. */
 | 
			
		||||
#define PILOT_HOSTILE       (1<<1)  /* Pilot is hostile to the player. */
 | 
			
		||||
#define PILOT_COMBAT        (1<<2)  /* Pilot is engaged in combat. */
 | 
			
		||||
#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_BEGIN     (1<<6)  /* Pilot is starting engines. */
 | 
			
		||||
#define PILOT_HYPERSPACE    (1<<7)  /* Pilot is in hyperspace. */
 | 
			
		||||
#define PILOT_BOARDED       (1<<8)  /* Pilot has been boarded already! */
 | 
			
		||||
#define PILOT_DISABLED      (1<<9)  /* Pilot is disabled. */
 | 
			
		||||
#define PILOT_DEAD          (1<<10) /* Pilot is on it's death bed. */
 | 
			
		||||
#define PILOT_EXPLODED      (1<<11) /* Pilot did final death explosion. */
 | 
			
		||||
#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_isDisabled(p) ((p)->flags & PILOT_DISABLED)
 | 
			
		||||
 | 
			
		||||
typedef struct PilotOutfit_ {
 | 
			
		||||
  Outfit* outfit;     // Associated outfit.
 | 
			
		||||
  int quantity;       // Number of outfits of this type that the pilot has.
 | 
			
		||||
  unsigned int timer; // Used to store last used weapon time.
 | 
			
		||||
  Outfit* outfit;     /* Associated outfit. */
 | 
			
		||||
  int quantity;       /* Number of outfits of this type that the pilot has. */
 | 
			
		||||
  unsigned int timer; /* Used to store last used weapon time. */
 | 
			
		||||
} PilotOutfit;
 | 
			
		||||
 | 
			
		||||
// Pilot commodity.
 | 
			
		||||
/* Pilot commodity. */
 | 
			
		||||
typedef struct PilotCommodity_ {
 | 
			
		||||
  Commodity* commodity;
 | 
			
		||||
  int quantity;
 | 
			
		||||
  unsigned int id;  // Special mission id for cargo.
 | 
			
		||||
  unsigned int id;  /* Special mission id for cargo. */
 | 
			
		||||
} PilotCommodity;
 | 
			
		||||
 | 
			
		||||
// Primary pilot structure.
 | 
			
		||||
/* Primary pilot structure. */
 | 
			
		||||
typedef struct Pilot_ {
 | 
			
		||||
  unsigned int id;  // Pilots id.
 | 
			
		||||
  char* name;       // Pilot's name (if unique).
 | 
			
		||||
  char* title;      // Title - Usuall indicating special properties - TODO.
 | 
			
		||||
  unsigned int id;  /* Pilots id. */
 | 
			
		||||
  char* name;       /* Pilot's name (if unique). */
 | 
			
		||||
  char* title;      /* Title - Usuall indicating special properties - TODO. */
 | 
			
		||||
 | 
			
		||||
  int faction;
 | 
			
		||||
 | 
			
		||||
  // Object characteristics.
 | 
			
		||||
  Ship* ship;     // Pilots ship.
 | 
			
		||||
  Solid* solid;   // Associated solid (physics).
 | 
			
		||||
  int tsx, tsy;   // Current sprite, calculated on update.
 | 
			
		||||
  /* Object characteristics. */
 | 
			
		||||
  Ship* ship;     /* Pilots ship. */
 | 
			
		||||
  Solid* solid;   /* Associated solid (physics). */
 | 
			
		||||
  int tsx, tsy;   /* Current sprite, calculated on update. */
 | 
			
		||||
 | 
			
		||||
  double thrust, turn, speed;
 | 
			
		||||
 | 
			
		||||
  // Current health.
 | 
			
		||||
  /* Current health. */
 | 
			
		||||
  double armour, shield, energy, fuel;
 | 
			
		||||
  double armour_max, shield_max, energy_max, fuel_max;
 | 
			
		||||
  double armour_regen, shield_regen, energy_regen;
 | 
			
		||||
 | 
			
		||||
  void (*think)(struct Pilot_*); // AI thinking for the pilot.
 | 
			
		||||
  void (*update)(struct Pilot_*, const double); // Update the pilot.
 | 
			
		||||
  void (*render)(struct Pilot_*); // Rendering the pilot.
 | 
			
		||||
  void (*think)(struct Pilot_*); /* AI thinking for the pilot. */
 | 
			
		||||
  void (*update)(struct Pilot_*, const double); /* Update the pilot. */
 | 
			
		||||
  void (*render)(struct Pilot_*); /* Rendering the pilot. */
 | 
			
		||||
 | 
			
		||||
  // Outfit management.
 | 
			
		||||
  /* Outfit management. */
 | 
			
		||||
  PilotOutfit* outfits;
 | 
			
		||||
  int noutfits;
 | 
			
		||||
  PilotOutfit* secondary;   // Secondary weapon.
 | 
			
		||||
  PilotOutfit* ammo;        // Secondary ammo (if needed).
 | 
			
		||||
  PilotOutfit* afterburner; // Ze afterburner.
 | 
			
		||||
  PilotOutfit* secondary;   /* Secondary weapon. */
 | 
			
		||||
  PilotOutfit* ammo;        /* Secondary ammo (if needed). */
 | 
			
		||||
  PilotOutfit* afterburner; /* Ze afterburner. */
 | 
			
		||||
 | 
			
		||||
  // Cargo.
 | 
			
		||||
  int credits; // Moniez the pilot has.
 | 
			
		||||
  PilotCommodity* commodities; // Commodity and quantity.
 | 
			
		||||
  /* Cargo. */
 | 
			
		||||
  int credits; /* Moniez the pilot has. */
 | 
			
		||||
  PilotCommodity* commodities; /* Commodity and quantity. */
 | 
			
		||||
  int ncommodities;
 | 
			
		||||
  int cargo_free;
 | 
			
		||||
 | 
			
		||||
  // Misc.
 | 
			
		||||
  uint32_t flags; // Used for AI etc.
 | 
			
		||||
  unsigned int ptimer;  // Generic timer for internal pilot use.
 | 
			
		||||
  /* Misc. */
 | 
			
		||||
  uint32_t flags; /* Used for AI etc. */
 | 
			
		||||
  unsigned int ptimer;  /* Generic timer for internal pilot use. */
 | 
			
		||||
 | 
			
		||||
  // Hook attached to the pilot.
 | 
			
		||||
  /* Hook attached to the pilot. */
 | 
			
		||||
  int hook_type;
 | 
			
		||||
  int hook;
 | 
			
		||||
 | 
			
		||||
  // AI.
 | 
			
		||||
  AI_Profile* ai; // Ai personality profile.
 | 
			
		||||
  unsigned int tcontrol; // Timer for control tick.
 | 
			
		||||
  unsigned int timer[MAX_AI_TIMERS]; // Timers for AI.
 | 
			
		||||
  Task* task; // Current action.
 | 
			
		||||
  /* AI. */
 | 
			
		||||
  AI_Profile* ai; /* Ai personality profile. */
 | 
			
		||||
  unsigned int tcontrol; /* Timer for control tick. */
 | 
			
		||||
  unsigned int timer[MAX_AI_TIMERS]; /* Timers for AI. */
 | 
			
		||||
  Task* task; /* Current action. */
 | 
			
		||||
} Pilot;
 | 
			
		||||
 | 
			
		||||
// Fleets.
 | 
			
		||||
/* Fleets. */
 | 
			
		||||
typedef struct FleetPilot_ {
 | 
			
		||||
  Ship* ship; // Ship that the pilot is flying.
 | 
			
		||||
  char* name; // For special 'unique' names.
 | 
			
		||||
  int chance; // Chance of this pilot appearing in the fleet.
 | 
			
		||||
  Ship* ship; /* Ship that the pilot is flying. */
 | 
			
		||||
  char* name; /* For special 'unique' names. */
 | 
			
		||||
  int chance; /* Chance of this pilot appearing in the fleet. */
 | 
			
		||||
} FleetPilot;
 | 
			
		||||
 | 
			
		||||
typedef struct Fleet_ {
 | 
			
		||||
  char* name;   // Fleet name, used as an identifier.
 | 
			
		||||
  int faction;  // Faction of the fleet.
 | 
			
		||||
  char* name;   /* Fleet name, used as an identifier. */
 | 
			
		||||
  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.
 | 
			
		||||
  int npilots; // Total number of pilots.
 | 
			
		||||
  FleetPilot* pilots; /* The pilots in the fleet. */
 | 
			
		||||
  int npilots; /* Total number of pilots. */
 | 
			
		||||
} Fleet;
 | 
			
		||||
 | 
			
		||||
// Grabing pilot crap.
 | 
			
		||||
extern Pilot* player; // The player.
 | 
			
		||||
/* Grabing pilot crap. */
 | 
			
		||||
extern Pilot* player; /* The player. */
 | 
			
		||||
Pilot* pilot_get(unsigned int id);
 | 
			
		||||
unsigned int pilot_getNext(const unsigned int id);
 | 
			
		||||
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);
 | 
			
		||||
int pilot_getJumps(const Pilot* p);
 | 
			
		||||
 | 
			
		||||
// MISC.
 | 
			
		||||
/* MISC. */
 | 
			
		||||
void pilot_shoot(Pilot* p, const unsigned int target, const int secondary);
 | 
			
		||||
void pilot_hit(Pilot* p, const Solid* w, const unsigned int shooter,
 | 
			
		||||
    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_setAfterburner(Pilot* p);
 | 
			
		||||
double pilot_face(Pilot* p, const float dir);
 | 
			
		||||
// Outfits.
 | 
			
		||||
int pilot_freeSpace(Pilot* p); // Pilot space.
 | 
			
		||||
/* Outfits. */
 | 
			
		||||
int pilot_freeSpace(Pilot* p); /* Pilot space. */
 | 
			
		||||
int pilot_addOutfit(Pilot* pilot, Outfit* outfit, int quantity);
 | 
			
		||||
int pilot_rmOutfit(Pilot* pilot, Outfit* outfit, int quantity);
 | 
			
		||||
char* pilot_getOutfits(Pilot* pilot);
 | 
			
		||||
void pilot_calcStats(Pilot* pilot);
 | 
			
		||||
// Normal cargo.
 | 
			
		||||
int pilot_cagoUsed(Pilot* pilot);   // Get amount of cargo onboard.
 | 
			
		||||
int pilot_cargoFree(Pilot* p);      // Cargo space.
 | 
			
		||||
/* Normal cargo. */
 | 
			
		||||
int pilot_cagoUsed(Pilot* pilot);   /* Get amount of cargo onboard. */
 | 
			
		||||
int pilot_cargoFree(Pilot* p);      /* Cargo space. */
 | 
			
		||||
int pilot_addCargo(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);
 | 
			
		||||
int pilot_rmMissionCargo(Pilot* pilot, unsigned int cargo_id);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Creation.
 | 
			
		||||
/* Creation. */
 | 
			
		||||
void pilot_init(Pilot* dest, Ship* ship, char* name, int faction,
 | 
			
		||||
                AI_Profile* ai, const double dir, const Vec2* pos,
 | 
			
		||||
                const Vec2* vel, const int flags);
 | 
			
		||||
@ -179,16 +179,16 @@ Pilot* pilot_createEmpty(Ship* ship, char* name,
 | 
			
		||||
 | 
			
		||||
Pilot* pilot_copy(Pilot* src);
 | 
			
		||||
 | 
			
		||||
// Init/Cleanup.
 | 
			
		||||
/* Init/Cleanup. */
 | 
			
		||||
void pilot_destroy(Pilot* p);
 | 
			
		||||
void pilots_free(void);
 | 
			
		||||
void pilots_clean(void);
 | 
			
		||||
void pilots_cleanAll(void);
 | 
			
		||||
void pilot_free(Pilot* p);
 | 
			
		||||
int fleet_load(void); // TODO
 | 
			
		||||
int fleet_load(void); /* TODO */
 | 
			
		||||
void fleet_free(void);
 | 
			
		||||
 | 
			
		||||
// Update.
 | 
			
		||||
/* Update. */
 | 
			
		||||
void pilots_update(double dt);
 | 
			
		||||
void pilots_render(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										46
									
								
								src/player.h
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								src/player.h
									
									
									
									
									
								
							@ -1,58 +1,58 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "pilot.h"
 | 
			
		||||
 | 
			
		||||
// Flag definitions.
 | 
			
		||||
#define PLAYER_TURN_LEFT    (1<<0)    // Player is turning left.
 | 
			
		||||
#define PLAYER_TURN_RIGHT   (1<<1)    // Player is turning right.
 | 
			
		||||
#define PLAYER_REVERSE      (1<<2)    // Player is facint opposite vel.
 | 
			
		||||
#define PLAYER_AFTERBURNER  (1<<3)    // Player is burning it up.
 | 
			
		||||
#define PLAYER_DESTROYED    (1<<9)    // Player goes BOOM!
 | 
			
		||||
#define PLAYER_FACE         (1<<10)   // Player is facing target.
 | 
			
		||||
#define PLAYER_PRIMARY      (1<<11)   // Player is shooting primary weapon.
 | 
			
		||||
#define PLAYER_SECONDARY    (1<<12)   // Player is shooting secondary weapon.
 | 
			
		||||
#define PLAYER_LANDACK      (1<<13)   // Player has permission to land.
 | 
			
		||||
#define PLAYER_CREATING     (1<<14)   // Player is being created.
 | 
			
		||||
/* Flag definitions. */
 | 
			
		||||
#define PLAYER_TURN_LEFT    (1<<0)    /* Player is turning left. */
 | 
			
		||||
#define PLAYER_TURN_RIGHT   (1<<1)    /* Player is turning right. */
 | 
			
		||||
#define PLAYER_REVERSE      (1<<2)    /* Player is facint opposite vel. */
 | 
			
		||||
#define PLAYER_AFTERBURNER  (1<<3)    /* Player is burning it up. */
 | 
			
		||||
#define PLAYER_DESTROYED    (1<<9)    /* Player goes BOOM! */
 | 
			
		||||
#define PLAYER_FACE         (1<<10)   /* Player is facing target. */
 | 
			
		||||
#define PLAYER_PRIMARY      (1<<11)   /* Player is shooting primary weapon. */
 | 
			
		||||
#define PLAYER_SECONDARY    (1<<12)   /* Player is shooting secondary weapon. */
 | 
			
		||||
#define PLAYER_LANDACK      (1<<13)   /* Player has permission to land. */
 | 
			
		||||
#define PLAYER_CREATING     (1<<14)   /* Player is being created. */
 | 
			
		||||
 | 
			
		||||
// Flag functions.
 | 
			
		||||
/* Flag functions. */
 | 
			
		||||
#define 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)
 | 
			
		||||
 | 
			
		||||
// The player.
 | 
			
		||||
/* The player. */
 | 
			
		||||
extern Pilot* pilot;
 | 
			
		||||
extern char* player_name;
 | 
			
		||||
extern unsigned int player_flags;
 | 
			
		||||
extern int combat_crating;
 | 
			
		||||
 | 
			
		||||
// Enums.
 | 
			
		||||
/* Enums. */
 | 
			
		||||
 | 
			
		||||
// For render functions.
 | 
			
		||||
/* For render functions. */
 | 
			
		||||
typedef enum RadarShape_ { RADAR_RECT, RADAR_CIRCLE } RadarShape;
 | 
			
		||||
 | 
			
		||||
// Creation/Cleanup.
 | 
			
		||||
/* Creation/Cleanup. */
 | 
			
		||||
void player_new(void);
 | 
			
		||||
void player_newShip(Ship* ship, double px, double py,
 | 
			
		||||
                    double vx, double vy, double dir);
 | 
			
		||||
void player_cleanup(void);
 | 
			
		||||
int gui_load(const char* name);
 | 
			
		||||
 | 
			
		||||
// Render.
 | 
			
		||||
/* Render. */
 | 
			
		||||
int gui_init(void);
 | 
			
		||||
void gui_free(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_clear(void);
 | 
			
		||||
void player_warp(const double x, const double y);
 | 
			
		||||
const char* player_rating(void);
 | 
			
		||||
// Cargo.
 | 
			
		||||
/* Cargo. */
 | 
			
		||||
int player_outfitOwned(const char* outfitname);
 | 
			
		||||
int player_cargoOwned(const char* commodityname);
 | 
			
		||||
void player_rmMissionCargo(unsigned int cargo_id);
 | 
			
		||||
 | 
			
		||||
// Pilot ships.
 | 
			
		||||
/* Pilot ships. */
 | 
			
		||||
char** player_ships(int* nships);
 | 
			
		||||
int    player_nships(void);
 | 
			
		||||
Pilot* player_getShip(char* shipname);
 | 
			
		||||
@ -60,11 +60,11 @@ char*  player_getLoc(char* shipname);
 | 
			
		||||
void   player_setLoc(char* shipname, char* loc);
 | 
			
		||||
void   player_swapShip(char* shipname);
 | 
			
		||||
 | 
			
		||||
// Player missions.
 | 
			
		||||
/* Player missions. */
 | 
			
		||||
void player_missionFinished(int id);
 | 
			
		||||
int player_missionAlreadyDone(int id);
 | 
			
		||||
 | 
			
		||||
// Keybind actions.
 | 
			
		||||
/* Keybind actions. */
 | 
			
		||||
void player_setRadarRel(int mod);
 | 
			
		||||
void player_secondaryNext(void);
 | 
			
		||||
void player_targetPlanet(void);
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
#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())
 | 
			
		||||
 | 
			
		||||
void rng_init(void);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										46
									
								
								src/ship.h
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								src/ship.h
									
									
									
									
									
								
							@ -3,7 +3,7 @@
 | 
			
		||||
#include "outfit.h"
 | 
			
		||||
#include "sound.h"
 | 
			
		||||
 | 
			
		||||
// Target gfx dimensions.
 | 
			
		||||
/* Target gfx dimensions. */
 | 
			
		||||
#define SHIP_TARGET_W 128
 | 
			
		||||
#define SHIP_TARGET_H 96
 | 
			
		||||
 | 
			
		||||
@ -23,63 +23,63 @@ typedef enum ShipClass_ {
 | 
			
		||||
  SHIP_CLASS_HYB_HEAVY  = 12
 | 
			
		||||
} ShipClass;
 | 
			
		||||
 | 
			
		||||
// Small wrapper for the outfits.
 | 
			
		||||
/* Small wrapper for the outfits. */
 | 
			
		||||
typedef struct ShipOutfit_ {
 | 
			
		||||
  struct ShipOutfit_* next; // Linked list.
 | 
			
		||||
  Outfit* data; // Data itself.
 | 
			
		||||
  struct ShipOutfit_* next; /* Linked list. */
 | 
			
		||||
  Outfit* data; /* Data itself. */
 | 
			
		||||
  int quantity;
 | 
			
		||||
} ShipOutfit;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Ship structure.
 | 
			
		||||
/* Ship structure. */
 | 
			
		||||
typedef struct Ship_ {
 | 
			
		||||
  char* name; // Ship name.
 | 
			
		||||
  ShipClass class; // Ship class.
 | 
			
		||||
  char* name; /* Ship name. */
 | 
			
		||||
  ShipClass class; /* Ship class. */
 | 
			
		||||
 | 
			
		||||
  // Store stuff.
 | 
			
		||||
  int price;      // Price!
 | 
			
		||||
  /* Store stuff. */
 | 
			
		||||
  int price;      /* Price! */
 | 
			
		||||
  int tech;
 | 
			
		||||
  char* fabricator;  // Manufacturer.
 | 
			
		||||
  char* description; // Sales pitch.
 | 
			
		||||
  char* fabricator;  /* Manufacturer. */
 | 
			
		||||
  char* description; /* Sales pitch. */
 | 
			
		||||
 | 
			
		||||
  // Movement.
 | 
			
		||||
  /* Movement. */
 | 
			
		||||
  double thrust, turn, speed;
 | 
			
		||||
 | 
			
		||||
  // Graphics.
 | 
			
		||||
  /* Graphics. */
 | 
			
		||||
  glTexture* gfx_space, *gfx_target;
 | 
			
		||||
 | 
			
		||||
  // GUI interface.
 | 
			
		||||
  /* GUI interface. */
 | 
			
		||||
  char* gui;
 | 
			
		||||
 | 
			
		||||
  // Sound.
 | 
			
		||||
  /* Sound. */
 | 
			
		||||
  ALuint sound;
 | 
			
		||||
 | 
			
		||||
  // Characteristics.
 | 
			
		||||
  /* Characteristics. */
 | 
			
		||||
  int crew;
 | 
			
		||||
  int mass;
 | 
			
		||||
  int fuel; // How many jumps by default.
 | 
			
		||||
  int fuel; /* How many jumps by default. */
 | 
			
		||||
 | 
			
		||||
  // Health.
 | 
			
		||||
  /* Health. */
 | 
			
		||||
  double armour, armour_regen;
 | 
			
		||||
  double shield, shield_regen;
 | 
			
		||||
  double energy, energy_regen;
 | 
			
		||||
 | 
			
		||||
  // Capacity.
 | 
			
		||||
  /* Capacity. */
 | 
			
		||||
  int cap_cargo, cap_weapon;
 | 
			
		||||
 | 
			
		||||
  // Outfits
 | 
			
		||||
  /* Outfits */
 | 
			
		||||
  ShipOutfit* outfit;
 | 
			
		||||
} Ship;
 | 
			
		||||
 | 
			
		||||
// Get.
 | 
			
		||||
/* Get. */
 | 
			
		||||
Ship* ship_get(const char* name);
 | 
			
		||||
char** ship_getTech(int* n, const int* tech, const int techmax);
 | 
			
		||||
char* ship_class(Ship* p);
 | 
			
		||||
 | 
			
		||||
// Load/quit.
 | 
			
		||||
/* Load/quit. */
 | 
			
		||||
int ships_load(void);
 | 
			
		||||
void ships_free(void);
 | 
			
		||||
 | 
			
		||||
// Toolkit.
 | 
			
		||||
/* Toolkit. */
 | 
			
		||||
void ship_view(char* shipname);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										14
									
								
								src/sound.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								src/sound.h
									
									
									
									
									
								
							@ -2,31 +2,31 @@
 | 
			
		||||
#include <AL/al.h>
 | 
			
		||||
#include "physics.h"
 | 
			
		||||
 | 
			
		||||
#define VOICE_LOOPING   (1<<10) // Voice loops.
 | 
			
		||||
#define VOICE_STATIC    (1<<11) // Voice isn't relative.
 | 
			
		||||
#define VOICE_LOOPING   (1<<10) /* Voice loops. */
 | 
			
		||||
#define VOICE_STATIC    (1<<11) /* Voice isn't relative. */
 | 
			
		||||
 | 
			
		||||
struct alVoice;
 | 
			
		||||
typedef struct alVoice alVoice;
 | 
			
		||||
 | 
			
		||||
// Sound subsystem.
 | 
			
		||||
/* Sound subsystem. */
 | 
			
		||||
int sound_init(void);
 | 
			
		||||
void sound_exit(void);
 | 
			
		||||
void sound_update(void);
 | 
			
		||||
 | 
			
		||||
// Sound manupulation functions.
 | 
			
		||||
/* Sound manupulation functions. */
 | 
			
		||||
ALuint sound_get(char* name);
 | 
			
		||||
void sound_volume(const double vol);
 | 
			
		||||
 | 
			
		||||
// Voice manipulation function.
 | 
			
		||||
/* Voice manipulation function. */
 | 
			
		||||
alVoice* sound_addVoice(int priority, double px, double py,
 | 
			
		||||
    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_buffer(alVoice* voice, const ALuint buffer, const unsigned int flags);
 | 
			
		||||
void voice_stop(alVoice* voice);
 | 
			
		||||
 | 
			
		||||
// Listener manipulation.
 | 
			
		||||
/* Listener manipulation. */
 | 
			
		||||
void sound_listener(double dir, double px, double py, double vx, double vy);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										128
									
								
								src/space.h
									
									
									
									
									
								
							
							
						
						
									
										128
									
								
								src/space.h
									
									
									
									
									
								
							@ -9,110 +9,110 @@
 | 
			
		||||
 | 
			
		||||
#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_ {
 | 
			
		||||
  PLANET_CLASS_NULL = 0,
 | 
			
		||||
  PLANET_CLASS_A,   // Geothermal.
 | 
			
		||||
  PLANET_CLASS_B,   // Geomorteus.
 | 
			
		||||
  PLANET_CLASS_C,   // Geoinactive.
 | 
			
		||||
  PLANET_CLASS_D,   // Asteroid/Moon.
 | 
			
		||||
  PLANET_CLASS_E,   // Geoplastic.
 | 
			
		||||
  PLANET_CLASS_F,   // Geometallic.
 | 
			
		||||
  PLANET_CLASS_G,   // GroCrystaline.
 | 
			
		||||
  PLANET_CLASS_H,   // Desert.
 | 
			
		||||
  PLANET_CLASS_I,   // Gas Supergiant.
 | 
			
		||||
  PLANET_CLASS_J,   // Gas Giant.
 | 
			
		||||
  PLANET_CLASS_K,   // Adaptable.
 | 
			
		||||
  PLANET_CLASS_L,   // Marginal.
 | 
			
		||||
  PLANET_CLASS_M,   // Terrestrial.
 | 
			
		||||
  PLANET_CLASS_N,   // Reducing.
 | 
			
		||||
  PLANET_CLASS_O,   // Pelagic.
 | 
			
		||||
  PLANET_CLASS_P,   // Glaciated.
 | 
			
		||||
  PLANET_CLASS_Q,   // Variable.
 | 
			
		||||
  PLANET_CLASS_R,   // Rogue.
 | 
			
		||||
  PLANET_CLASS_S,   // Ultragiant.
 | 
			
		||||
  PLANET_CLASS_T,   // Ultragiant.
 | 
			
		||||
  PLANET_CLASS_X,   // Demon.
 | 
			
		||||
  PLANET_CLASS_Y,   // Demon.
 | 
			
		||||
  PLANET_CLASS_Z,   // Demon.
 | 
			
		||||
  STATION_CLASS_A,  // Civilian station.
 | 
			
		||||
  STATION_CLASS_B,  // Military station.
 | 
			
		||||
  STATION_CLASS_C,  // Interfactional station.
 | 
			
		||||
  STATION_CLASS_D,  // Robotoc station.
 | 
			
		||||
  PLANET_CLASS_A,   /* Geothermal. */
 | 
			
		||||
  PLANET_CLASS_B,   /* Geomorteus. */
 | 
			
		||||
  PLANET_CLASS_C,   /* Geoinactive. */
 | 
			
		||||
  PLANET_CLASS_D,   /* Asteroid/Moon. */
 | 
			
		||||
  PLANET_CLASS_E,   /* Geoplastic. */
 | 
			
		||||
  PLANET_CLASS_F,   /* Geometallic. */
 | 
			
		||||
  PLANET_CLASS_G,   /* GroCrystaline. */
 | 
			
		||||
  PLANET_CLASS_H,   /* Desert. */
 | 
			
		||||
  PLANET_CLASS_I,   /* Gas Supergiant. */
 | 
			
		||||
  PLANET_CLASS_J,   /* Gas Giant. */
 | 
			
		||||
  PLANET_CLASS_K,   /* Adaptable. */
 | 
			
		||||
  PLANET_CLASS_L,   /* Marginal. */
 | 
			
		||||
  PLANET_CLASS_M,   /* Terrestrial. */
 | 
			
		||||
  PLANET_CLASS_N,   /* Reducing. */
 | 
			
		||||
  PLANET_CLASS_O,   /* Pelagic. */
 | 
			
		||||
  PLANET_CLASS_P,   /* Glaciated. */
 | 
			
		||||
  PLANET_CLASS_Q,   /* Variable. */
 | 
			
		||||
  PLANET_CLASS_R,   /* Rogue. */
 | 
			
		||||
  PLANET_CLASS_S,   /* Ultragiant. */
 | 
			
		||||
  PLANET_CLASS_T,   /* Ultragiant. */
 | 
			
		||||
  PLANET_CLASS_X,   /* Demon. */
 | 
			
		||||
  PLANET_CLASS_Y,   /* Demon. */
 | 
			
		||||
  PLANET_CLASS_Z,   /* Demon. */
 | 
			
		||||
  STATION_CLASS_A,  /* Civilian station. */
 | 
			
		||||
  STATION_CLASS_B,  /* Military station. */
 | 
			
		||||
  STATION_CLASS_C,  /* Interfactional station. */
 | 
			
		||||
  STATION_CLASS_D,  /* Robotoc station. */
 | 
			
		||||
} PlanetClass;
 | 
			
		||||
 | 
			
		||||
// Planet services.
 | 
			
		||||
#define PLANET_SERVICE_LAND       (1<<0) // Can we land?
 | 
			
		||||
#define PLANET_SERVICE_BASIC      (1<<1) // Refueling, spaceport bar, new.
 | 
			
		||||
/* Planet services. */
 | 
			
		||||
#define PLANET_SERVICE_LAND       (1<<0) /* Can we land? */
 | 
			
		||||
#define PLANET_SERVICE_BASIC      (1<<1) /* Refueling, spaceport bar, new. */
 | 
			
		||||
#define PLANET_SERVICE_COMMODITY  (1<<2)
 | 
			
		||||
#define PLANET_SERVICE_OUTFITS    (1<<3)
 | 
			
		||||
#define PLANET_SERVICE_SHIPYARD   (1<<4)
 | 
			
		||||
#define planet_hasService(p,s)    ((p)->services & s)
 | 
			
		||||
 | 
			
		||||
typedef struct Planet_ {
 | 
			
		||||
  char* name;               // Planet name
 | 
			
		||||
  Vec2 pos;                 // Position in star system.
 | 
			
		||||
  char* name;               /* Planet name */
 | 
			
		||||
  Vec2 pos;                 /* Position in star system. */
 | 
			
		||||
 | 
			
		||||
  PlanetClass class;        // Planet type.
 | 
			
		||||
  int faction;              // Planet faction.
 | 
			
		||||
  PlanetClass class;        /* Planet type. */
 | 
			
		||||
  int faction;              /* Planet faction. */
 | 
			
		||||
 | 
			
		||||
  char* description;        // Planet description.
 | 
			
		||||
  char* bar_description;    // Spaceport bar description.
 | 
			
		||||
  unsigned int services;    // Offered services.
 | 
			
		||||
  Commodity** commodities;  // Commodities sold.
 | 
			
		||||
  int ncommodities;         // Amount in stock.
 | 
			
		||||
  char* description;        /* Planet description. */
 | 
			
		||||
  char* bar_description;    /* Spaceport bar description. */
 | 
			
		||||
  unsigned int services;    /* Offered services. */
 | 
			
		||||
  Commodity** commodities;  /* Commodities sold. */
 | 
			
		||||
  int ncommodities;         /* Amount in stock. */
 | 
			
		||||
 | 
			
		||||
  // tech[0] stores global tech level (everything that and below) while
 | 
			
		||||
  // tech[1-PLANET_TECH_MAX] stores the unique tech levels.
 | 
			
		||||
  /* tech[0] stores global tech level (everything that and below) while */
 | 
			
		||||
  /* tech[1-PLANET_TECH_MAX] stores the unique tech levels. */
 | 
			
		||||
  int tech[PLANET_TECH_MAX];
 | 
			
		||||
 | 
			
		||||
  glTexture* gfx_space;     // Graphics in space.
 | 
			
		||||
  glTexture* gfx_exterior;  // Graphics in the exterior.
 | 
			
		||||
  glTexture* gfx_space;     /* Graphics in space. */
 | 
			
		||||
  glTexture* gfx_exterior;  /* Graphics in the exterior. */
 | 
			
		||||
} Planet;
 | 
			
		||||
 | 
			
		||||
// Star systems.
 | 
			
		||||
/* Star systems. */
 | 
			
		||||
typedef struct SystemFleet_ {
 | 
			
		||||
  Fleet* fleet;         // Fleet to appear.
 | 
			
		||||
  int chance;           // Chance of fleet appearing in the system.
 | 
			
		||||
  Fleet* fleet;         /* Fleet to appear. */
 | 
			
		||||
  int chance;           /* Chance of fleet appearing in the system. */
 | 
			
		||||
} SystemFleet;
 | 
			
		||||
 | 
			
		||||
typedef struct StarSystem_ {
 | 
			
		||||
  char* name;           // Star system identifier.
 | 
			
		||||
  Vec2 pos;             // Position.
 | 
			
		||||
  int stars, asteroids; // Un numero!
 | 
			
		||||
  double interference;  // Un uh.. Percentage.
 | 
			
		||||
  char* name;           /* Star system identifier. */
 | 
			
		||||
  Vec2 pos;             /* Position. */
 | 
			
		||||
  int stars, asteroids; /* Un numero! */
 | 
			
		||||
  double interference;  /* Un uh.. Percentage. */
 | 
			
		||||
 | 
			
		||||
  int faction;          // Overall faction.
 | 
			
		||||
  int faction;          /* Overall faction. */
 | 
			
		||||
 | 
			
		||||
  Planet* planets;      // Planets.
 | 
			
		||||
  int nplanets;         // Total number of planets.
 | 
			
		||||
  Planet* planets;      /* Planets. */
 | 
			
		||||
  int nplanets;         /* Total number of planets. */
 | 
			
		||||
 | 
			
		||||
  SystemFleet* fleets;  // Fleets that can appear in the current system.
 | 
			
		||||
  int nfleets;          // Total number of fleets.
 | 
			
		||||
  SystemFleet* fleets;  /* Fleets that can appear in the current system. */
 | 
			
		||||
  int nfleets;          /* Total number of fleets. */
 | 
			
		||||
 | 
			
		||||
  int* jumps;           // Adjacent star system index number.
 | 
			
		||||
  int njumps;           // Number of adjacent jumps.
 | 
			
		||||
  int* jumps;           /* Adjacent star system index number. */
 | 
			
		||||
  int njumps;           /* Number of adjacent jumps. */
 | 
			
		||||
} 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);
 | 
			
		||||
int space_load(void);
 | 
			
		||||
void space_exit(void);
 | 
			
		||||
 | 
			
		||||
// Planet stuff.
 | 
			
		||||
/* Planet stuff. */
 | 
			
		||||
char* planet_getSystem(char* planetname);
 | 
			
		||||
Planet* planet_get(char* planetname);
 | 
			
		||||
 | 
			
		||||
// Render.
 | 
			
		||||
/* Render. */
 | 
			
		||||
void space_render(double dt);
 | 
			
		||||
void planets_render(void);
 | 
			
		||||
 | 
			
		||||
// Update.
 | 
			
		||||
/* Update. */
 | 
			
		||||
void space_update(const double dt);
 | 
			
		||||
 | 
			
		||||
// Misc.
 | 
			
		||||
/* Misc. */
 | 
			
		||||
StarSystem** system_getJumpPath(int* njumps, char* sysstart, char* sysend);
 | 
			
		||||
int space_canHyperspace(Pilot* p);
 | 
			
		||||
int space_hyperspace(Pilot* p);
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								src/spfx.h
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/spfx.h
									
									
									
									
									
								
							@ -5,33 +5,33 @@
 | 
			
		||||
#define SPFX_LAYER_FRONT  0
 | 
			
		||||
#define SPFX_LAYER_BACK  1
 | 
			
		||||
 | 
			
		||||
#define SHAKE_DECAY 50. // Decay parameter.
 | 
			
		||||
#define SHAKE_MAX   50.*SCREEN_W*SCREEN_H/1024./768. // Max parameter.
 | 
			
		||||
#define SHAKE_DECAY 50. /* Decay parameter. */
 | 
			
		||||
#define SHAKE_MAX   50.*SCREEN_W*SCREEN_H/1024./768. /* Max parameter. */
 | 
			
		||||
 | 
			
		||||
// Stack manipulation.
 | 
			
		||||
/* Stack manipulation. */
 | 
			
		||||
int spfx_get(char* name);
 | 
			
		||||
void spfx_add(const int effect,
 | 
			
		||||
              const double px, const double py,
 | 
			
		||||
              const double vx, const double vy,
 | 
			
		||||
              const int layer);
 | 
			
		||||
 | 
			
		||||
// Stack mass manipulation functions.
 | 
			
		||||
/* Stack mass manipulation functions. */
 | 
			
		||||
void spfx_update(const double dt);
 | 
			
		||||
void spfx_render(const int layer);
 | 
			
		||||
void spfx_clear(void);
 | 
			
		||||
 | 
			
		||||
// Get ready to rumble!
 | 
			
		||||
/* Get ready to rumble! */
 | 
			
		||||
void spfx_start(double dt);
 | 
			
		||||
void spfx_shake(double mod);
 | 
			
		||||
 | 
			
		||||
// Other effects.
 | 
			
		||||
/* Other effects. */
 | 
			
		||||
void spfx_cinematic(void);
 | 
			
		||||
 | 
			
		||||
// Load/free.
 | 
			
		||||
/* Load/free. */
 | 
			
		||||
int spfx_load(void);
 | 
			
		||||
void spfx_free(void);
 | 
			
		||||
 | 
			
		||||
// Pause/Unpause routines.
 | 
			
		||||
/* Pause/Unpause routines. */
 | 
			
		||||
void spfx_pause(void);
 | 
			
		||||
void spfx_unpause(void);
 | 
			
		||||
void spfx_delay(unsigned int delay);
 | 
			
		||||
 | 
			
		||||
@ -5,7 +5,7 @@
 | 
			
		||||
 | 
			
		||||
extern int toolkit;
 | 
			
		||||
 | 
			
		||||
// Creation.
 | 
			
		||||
/* Creation. */
 | 
			
		||||
unsigned int window_create(char* name, const int x, const int y,
 | 
			
		||||
                           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);
 | 
			
		||||
 | 
			
		||||
void window_addList(const unsigned int wid,
 | 
			
		||||
                    const int x, const int y, // Position.
 | 
			
		||||
                    const int w, const int h, // Size.
 | 
			
		||||
                    const int x, const int y, /* Position. */
 | 
			
		||||
                    const int w, const int h, /* Size. */
 | 
			
		||||
                    char* name, char** items, int nitems, int defitem,
 | 
			
		||||
                    void(*call)(char*));
 | 
			
		||||
 | 
			
		||||
void window_addRect(const unsigned int wid,
 | 
			
		||||
                    const int x, const int y, // Position.
 | 
			
		||||
                    const int w, const int h, // size.
 | 
			
		||||
                    char* name, glColour* colour, int border); // Properties.
 | 
			
		||||
                    const int x, const int y, /* Position. */
 | 
			
		||||
                    const int w, const int h, /* size. */
 | 
			
		||||
                    char* name, glColour* colour, int border); /* Properties. */
 | 
			
		||||
 | 
			
		||||
void window_addCust(const unsigned int wid,
 | 
			
		||||
                    const int x, const int y, // Position.
 | 
			
		||||
                    const int w, const int h, // Size.
 | 
			
		||||
                    const int x, const int y, /* Position. */
 | 
			
		||||
                    const int w, const int h, /* Size. */
 | 
			
		||||
                    char* name, const int border,
 | 
			
		||||
                    void(*render) (double x, double y, double w, double h),
 | 
			
		||||
                    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,
 | 
			
		||||
                     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_msg(char* caption, const char* fmt, ...);
 | 
			
		||||
// Yes = 1, No = 0.
 | 
			
		||||
/* Yes = 1, No = 0. */
 | 
			
		||||
int   dialogue_YesNo(char* caption, 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*));
 | 
			
		||||
// Text.
 | 
			
		||||
/* Text. */
 | 
			
		||||
void window_modifyText(const unsigned int wid, char* name, char* newstring);
 | 
			
		||||
// Button.
 | 
			
		||||
/* Button. */
 | 
			
		||||
void window_disableButton(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_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);
 | 
			
		||||
unsigned int window_get(const char* wdwname);
 | 
			
		||||
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);
 | 
			
		||||
char* window_getInput(const unsigned int wid, char* name);
 | 
			
		||||
 | 
			
		||||
// Destroy window.
 | 
			
		||||
/* Destroy window. */
 | 
			
		||||
void window_destroy(const unsigned int wid);
 | 
			
		||||
void window_destroyWidget(unsigned wid, const char* wgtname);
 | 
			
		||||
 | 
			
		||||
// Render.
 | 
			
		||||
/* Render. */
 | 
			
		||||
void toolkit_render(void);
 | 
			
		||||
 | 
			
		||||
// Input.
 | 
			
		||||
/* Input. */
 | 
			
		||||
int toolkit_input(SDL_Event* event);
 | 
			
		||||
void toolkit_update(void);
 | 
			
		||||
 | 
			
		||||
// Init/Exit.
 | 
			
		||||
/* Init/Exit. */
 | 
			
		||||
int toolkit_init(void);
 | 
			
		||||
void toolkit_exit(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -8,16 +8,16 @@ void weapon_add(const Outfit* outfit, const double dir, const Vec2* pos,
 | 
			
		||||
                const Vec2* vel, unsigned int parent,
 | 
			
		||||
                const unsigned int target);
 | 
			
		||||
 | 
			
		||||
// Pausing.
 | 
			
		||||
/* Pausing. */
 | 
			
		||||
void weapons_pause(void);
 | 
			
		||||
void weapons_unpause(void);
 | 
			
		||||
void weapons_delay(unsigned int delay);
 | 
			
		||||
 | 
			
		||||
// Update.
 | 
			
		||||
/* Update. */
 | 
			
		||||
void weapons_update(const double dt);
 | 
			
		||||
void weapons_render(const WeaponLayer layer);
 | 
			
		||||
 | 
			
		||||
// Clean.
 | 
			
		||||
/* Clean. */
 | 
			
		||||
void weapon_clear(void);
 | 
			
		||||
void weapon_exit(void);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										18
									
								
								src/xml.h
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								src/xml.h
									
									
									
									
									
								
							@ -8,24 +8,24 @@
 | 
			
		||||
#define XML_NODE_START  1
 | 
			
		||||
#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) && \
 | 
			
		||||
  (strcmp((char*)(n)->name, s)==0))
 | 
			
		||||
 | 
			
		||||
// Get the next node.
 | 
			
		||||
/* Get the next node. */
 | 
			
		||||
#define xml_nextNode(n) \
 | 
			
		||||
  ((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)
 | 
			
		||||
 | 
			
		||||
// Get data different ways.
 | 
			
		||||
/* Get data different ways. */
 | 
			
		||||
#define xml_get(n)      ((char*)(n)->children->content)
 | 
			
		||||
#define xml_getInt(n)   (atoi((char*)(n)->children->content))
 | 
			
		||||
#define xml_getLong(n)  (atoi((char*)(n)->children->content))
 | 
			
		||||
#define xml_getFloat(n) (atof((char*)(n)->children->content))
 | 
			
		||||
 | 
			
		||||
// Reader crap.
 | 
			
		||||
/* Reader crap. */
 | 
			
		||||
#define xmlr_int(n,s,i) \
 | 
			
		||||
  if(xml_isNode(n,s)) { i = xml_getInt(n);    continue; }
 | 
			
		||||
#define xmlr_long(n,s,l) \
 | 
			
		||||
@ -39,9 +39,9 @@
 | 
			
		||||
#define xmlr_attr(n,s,a) \
 | 
			
		||||
  a = xml_nodeProp(n,s)
 | 
			
		||||
 | 
			
		||||
// Writer crap.
 | 
			
		||||
/* Writer crap. */
 | 
			
		||||
 | 
			
		||||
// Encompassing element.
 | 
			
		||||
/* Encompassing element. */
 | 
			
		||||
#define xmlw_startElem(w, str) \
 | 
			
		||||
  if(xmlTextWriterStartElement(w, (xmlChar*)str) < 0) { \
 | 
			
		||||
    ERR("xmlw: Unable to create start element"); return -1; }
 | 
			
		||||
@ -50,7 +50,7 @@
 | 
			
		||||
  if(xmlTextWriterEndElement(w) < 0) { \
 | 
			
		||||
    ERR("xmlw: Unable to create end element"); return -1; }
 | 
			
		||||
 | 
			
		||||
// Other stuff.
 | 
			
		||||
/* Other stuff. */
 | 
			
		||||
#define xmlw_elem(w, n, str, args...) \
 | 
			
		||||
  if(xmlTextWriterWriteFormatElement(w, (xmlChar*)n, str, ## args) < 0) { \
 | 
			
		||||
    ERR("xmlw: Unable to write format element"); return -1; }
 | 
			
		||||
@ -67,7 +67,7 @@
 | 
			
		||||
  if(xmlTextWriterWriteFormatString(w, str, ## val) < 0) { \
 | 
			
		||||
    ERR("xmlw: Unable to write element data"); return -1; }
 | 
			
		||||
 | 
			
		||||
// Document level.
 | 
			
		||||
/* Document level. */
 | 
			
		||||
#define xmlw_start(w) \
 | 
			
		||||
  if(xmlTextWriterStartDocument(writer, NULL, "UTF-8", NULL) < 0) { \
 | 
			
		||||
    ERR("xmlw: Unable to start document"); return -1; }
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,7 @@
 | 
			
		||||
#endif
 | 
			
		||||
#define RGBAMASK RMASK, GMASK, BMASK, AMASK
 | 
			
		||||
 | 
			
		||||
// Logging macros.
 | 
			
		||||
/* Logging macros. */
 | 
			
		||||
#define LOG(str, args...)(fprintf(stdout, str"\n", ## args))
 | 
			
		||||
#define WARN(str, args...)(fprintf(stderr, "Warning: "str"\n", ## args))
 | 
			
		||||
#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_Rect r;
 | 
			
		||||
 | 
			
		||||
  // Init variables.
 | 
			
		||||
  /* Init variables. */
 | 
			
		||||
  r.w = r.h = 0;
 | 
			
		||||
 | 
			
		||||
  if(argc == 2) {
 | 
			
		||||
@ -55,22 +55,22 @@ int main(int argc, char* argv[]) {
 | 
			
		||||
  tmp   = NULL;
 | 
			
		||||
  final = NULL;
 | 
			
		||||
 | 
			
		||||
  // Init SDL.
 | 
			
		||||
  /* Init SDL. */
 | 
			
		||||
  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);
 | 
			
		||||
  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));
 | 
			
		||||
  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++) {
 | 
			
		||||
    // 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);
 | 
			
		||||
 | 
			
		||||
    // Load the image properly.
 | 
			
		||||
    /* Load the image properly. */
 | 
			
		||||
    tmp  = IMG_Load(file);
 | 
			
		||||
    if(tmp == NULL) ERR("Problem loading file '%s': %s", file, IMG_GetError());
 | 
			
		||||
    sflags = tmp->flags & (SDL_SRCALPHA | SDL_SRCCOLORKEY);
 | 
			
		||||
@ -82,7 +82,7 @@ int main(int argc, char* argv[]) {
 | 
			
		||||
 | 
			
		||||
    load[i] = tmp;
 | 
			
		||||
 | 
			
		||||
    // Check if size has changed.
 | 
			
		||||
    /* Check if size has changed. */
 | 
			
		||||
    if(r.w == 0 && r.h == 0) {
 | 
			
		||||
      r.w = load[i]->w;
 | 
			
		||||
      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))
 | 
			
		||||
      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) {
 | 
			
		||||
      final = SDL_CreateRGBSurface(SDL_SWSURFACE | SDL_SRCALPHA, ws*r.w, hs*r.h,
 | 
			
		||||
            load[i]->format->BitsPerPixel, RGBAMASK);
 | 
			
		||||
      if(!final) ERR("Problem creating RGB Surface: %s", SDL_GetError());
 | 
			
		||||
      tmp = final;
 | 
			
		||||
    }
 | 
			
		||||
    // New position.
 | 
			
		||||
    /* New position. */
 | 
			
		||||
    r.y = r.h * (i/ws);
 | 
			
		||||
    r.x = r.w * (i%ws);
 | 
			
		||||
    if(SDL_BlitSurface(load[i], NULL, final, &r))
 | 
			
		||||
      ERR("Problem blitting surface '%s' to final surface: %s", file, SDL_GetError());
 | 
			
		||||
    SDL_FreeSurface(load[i]);
 | 
			
		||||
  }
 | 
			
		||||
  // Draw the result and cleanup.
 | 
			
		||||
  /* Draw the result and cleanup. */
 | 
			
		||||
  save_png(final, "sprite.png");
 | 
			
		||||
  SDL_FreeSurface(final);
 | 
			
		||||
  free(load);
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
  argv += 2;
 | 
			
		||||
 | 
			
		||||
  if(nfiles == 0) {
 | 
			
		||||
    // No files, list what it has.
 | 
			
		||||
    /* No files, list what it has. */
 | 
			
		||||
    list = pack_listfiles(packfile, &nlist);
 | 
			
		||||
    fprintf(stdout, "Packfile '%s' contains:\n", packfile);
 | 
			
		||||
    for(i = 0; i < nlist; i++) {
 | 
			
		||||
@ -31,7 +31,7 @@ int main(int argc, char** argv) {
 | 
			
		||||
      free(list[i]);
 | 
			
		||||
    }
 | 
			
		||||
    free(list);
 | 
			
		||||
  } else { // Create a packfile.
 | 
			
		||||
  } else { /* Create a packfile. */
 | 
			
		||||
    pack_files(packfile, (const char**)argv, nfiles);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user