[Add] More doxygen along with some slight code cleaup.
This commit is contained in:
parent
833283add0
commit
673b83ea6a
7
src/ai.c
7
src/ai.c
@ -791,8 +791,7 @@ static int ai_face(lua_State* L) {
|
|||||||
if(n >= 0) {
|
if(n >= 0) {
|
||||||
p = pilot_get(n);
|
p = pilot_get(n);
|
||||||
if(p == NULL) return 0; /* Make sure pilot is valid. */
|
if(p == NULL) return 0; /* Make sure pilot is valid. */
|
||||||
vect_cset(&tv, VX(p->solid->pos) + FACE_WVEL*VX(p->solid->vel),
|
vect_cset(&tv, VX(p->solid->pos), VY(p->solid->pos));
|
||||||
VY(p->solid->pos) + FACE_WVEL*VY(p->solid->vel));
|
|
||||||
v = NULL;
|
v = NULL;
|
||||||
}
|
}
|
||||||
else if(lua_islightuserdata(L,1)) v = (Vec2*)lua_topointer(L,1);
|
else if(lua_islightuserdata(L,1)) v = (Vec2*)lua_topointer(L,1);
|
||||||
@ -800,8 +799,8 @@ static int ai_face(lua_State* L) {
|
|||||||
mod = 10;
|
mod = 10;
|
||||||
if(lua_gettop(L) > 1 && lua_isnumber(L,2)) invert = (int)lua_tonumber(L,2);
|
if(lua_gettop(L) > 1 && lua_isnumber(L,2)) invert = (int)lua_tonumber(L,2);
|
||||||
if(invert) mod *= -1;
|
if(invert) mod *= -1;
|
||||||
vect_cset(&sv, VX(cur_pilot->solid->pos) + FACE_WVEL*VX(cur_pilot->solid->vel),
|
|
||||||
VY(cur_pilot->solid->pos) + FACE_WVEL*VY(cur_pilot->solid->vel));
|
vect_cset(&sv, VX(cur_pilot->solid->pos), VY(cur_pilot->solid->pos));
|
||||||
|
|
||||||
if(v == NULL)
|
if(v == NULL)
|
||||||
/* Target is dynamic. */
|
/* Target is dynamic. */
|
||||||
|
@ -152,7 +152,7 @@ static void board_stealCargo(char* str) {
|
|||||||
|
|
||||||
if(board_fail()) return;
|
if(board_fail()) return;
|
||||||
|
|
||||||
/* Steal as much as possible until full - TODO: Allow the player to choose. */
|
/** Steal as much as possible until full - @todo: Allow the player to choose. */
|
||||||
q = 1;
|
q = 1;
|
||||||
while((p->ncommodities > 0) && (q != 0)) {
|
while((p->ncommodities > 0) && (q != 0)) {
|
||||||
q = pilot_addCargo(player, p->commodities[0].commodity,
|
q = pilot_addCargo(player, p->commodities[0].commodity,
|
||||||
|
@ -279,7 +279,7 @@ void conf_parseCLI(int argc, char** argv) {
|
|||||||
|
|
||||||
/* Saves the current configuration. */
|
/* Saves the current configuration. */
|
||||||
int conf_saveConfig(void) {
|
int conf_saveConfig(void) {
|
||||||
/* TODO: save conf. */
|
/** @todo save conf. */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
28
src/font.c
28
src/font.c
@ -1,3 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* @file font.c
|
||||||
|
*
|
||||||
|
* @brief OpenGL font rendering routines.
|
||||||
|
*
|
||||||
|
* Use a displaylist to store ASCII chars rendered with freefont.
|
||||||
|
* There are several drawing methods depending on whether you want
|
||||||
|
* to print it all, print to a max width, print centered or print a
|
||||||
|
* block of text.
|
||||||
|
*
|
||||||
|
* There are hardcoded size limits. 256 characters for all routines
|
||||||
|
* except gl_printText which has a 1024 limit.
|
||||||
|
*
|
||||||
|
* @todo Check if length is too long.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "font.h"
|
#include "font.h"
|
||||||
|
|
||||||
#include "ft2build.h"
|
#include "ft2build.h"
|
||||||
@ -10,18 +26,6 @@
|
|||||||
|
|
||||||
#define FONT_DEF "../dat/font.ttf"
|
#define FONT_DEF "../dat/font.ttf"
|
||||||
|
|
||||||
/* == Font render routines.================================ */
|
|
||||||
/* Use a display list to store ASCII chars rendered with */
|
|
||||||
/* freefont. There are several drawing methods depending */
|
|
||||||
/* on whether you want to print it all, to a max width, */
|
|
||||||
/* print centered or print a block of text. */
|
|
||||||
/* */
|
|
||||||
/* There are hardcoded size limits. 256 characters for all */
|
|
||||||
/* routines exept gl_printText which has a 1024 limit. */
|
|
||||||
/* */
|
|
||||||
/* TODO: Check if length is too long. */
|
|
||||||
/* ======================================================== */
|
|
||||||
|
|
||||||
/* Default font. */
|
/* Default font. */
|
||||||
glFont gl_defFont;
|
glFont gl_defFont;
|
||||||
glFont gl_smallFont;
|
glFont gl_smallFont;
|
||||||
|
@ -167,7 +167,7 @@ static void commodity_exchange_open(void) {
|
|||||||
commodity_update(NULL);
|
commodity_update(NULL);
|
||||||
|
|
||||||
if(!has_visited(VISITED_COMMODITY)) {
|
if(!has_visited(VISITED_COMMODITY)) {
|
||||||
/* TODO: mission check. */
|
/* @todo Mission check. */
|
||||||
visited(VISITED_COMMODITY);
|
visited(VISITED_COMMODITY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ static void outfits_open(void) {
|
|||||||
outfits_update(NULL);
|
outfits_update(NULL);
|
||||||
|
|
||||||
if(!has_visited(VISITED_OUTFITS)) {
|
if(!has_visited(VISITED_OUTFITS)) {
|
||||||
/* TODO: mission check. */
|
/* @todo mission check. */
|
||||||
visited(VISITED_OUTFITS);
|
visited(VISITED_OUTFITS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -585,7 +585,7 @@ static void shipyard_open(void) {
|
|||||||
shipyard_update(NULL);
|
shipyard_update(NULL);
|
||||||
|
|
||||||
if(!has_visited(VISITED_SHIPYARD)) {
|
if(!has_visited(VISITED_SHIPYARD)) {
|
||||||
/* TODO: mission check. */
|
/* @todo mission check. */
|
||||||
visited(VISITED_SHIPYARD);
|
visited(VISITED_SHIPYARD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1189,7 +1189,7 @@ void land(Planet* p) {
|
|||||||
land_planet->faction, land_planet->name, cur_system->name);
|
land_planet->faction, land_planet->name, cur_system->name);
|
||||||
|
|
||||||
if(!has_visited(VISITED_LAND)) {
|
if(!has_visited(VISITED_LAND)) {
|
||||||
/* TODO: mission check. */
|
/* @todo mission check. */
|
||||||
visited(VISITED_LAND);
|
visited(VISITED_LAND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
src/llua.c
12
src/llua.c
@ -74,11 +74,17 @@ int llua_load(lua_State* L, lua_CFunction f) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load specially modified basic stuff. */
|
/**
|
||||||
|
* @fn int llua_loadBasic(lua_State* L)
|
||||||
|
*
|
||||||
|
* @brief Load specially modified basic stuff.
|
||||||
|
* @param L Lua state to load the basic stuff into.
|
||||||
|
* @return 0 on success.
|
||||||
|
*/
|
||||||
int llua_loadBasic(lua_State* L) {
|
int llua_loadBasic(lua_State* L) {
|
||||||
int i;
|
int i;
|
||||||
/* Unsafe functions. */
|
/* Unsafe functions. */
|
||||||
char* override[] = {
|
const char* override[] = {
|
||||||
"collectgarbage",
|
"collectgarbage",
|
||||||
"dofile",
|
"dofile",
|
||||||
"getfenv",
|
"getfenv",
|
||||||
@ -163,7 +169,7 @@ int lua_loadTk(lua_State* L) {
|
|||||||
|
|
||||||
/* -- Lephisto. -- */
|
/* -- Lephisto. -- */
|
||||||
static int lephisto_lang(lua_State* L) {
|
static int lephisto_lang(lua_State* L) {
|
||||||
/* TODO: multilanguage stuff. */
|
/* @todo Multilanguage stuff. */
|
||||||
lua_pushstring(L, "en");
|
lua_pushstring(L, "en");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ static void map_update(void) {
|
|||||||
}
|
}
|
||||||
else if(f != sys->planets[i].faction &&
|
else if(f != sys->planets[i].faction &&
|
||||||
(sys->planets[i].faction>0)) {
|
(sys->planets[i].faction>0)) {
|
||||||
/* TODO: more verbosity. */
|
/* @todo More verbosity. */
|
||||||
snprintf(buf, 100, "Multiple");
|
snprintf(buf, 100, "Multiple");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ static void menu_small_exit(char* str) {
|
|||||||
/* Edit the options. */
|
/* Edit the options. */
|
||||||
static void edit_options(char* str) {
|
static void edit_options(char* str) {
|
||||||
(void)str;
|
(void)str;
|
||||||
/* TODO */
|
/* @todo Make options menu */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Exit the game. */
|
/* Exit the game. */
|
||||||
|
@ -899,7 +899,7 @@ void pilot_calcStats(Pilot* pilot) {
|
|||||||
pilot->afterburner = &pilot->outfits[i]; /* Set afterburner. */
|
pilot->afterburner = &pilot->outfits[i]; /* Set afterburner. */
|
||||||
else if(outfit_isJammer(o)) { /* Jammer. */
|
else if(outfit_isJammer(o)) { /* Jammer. */
|
||||||
if(pilot->jam_chance < o->u.jam.chance) { /* Substitude. */
|
if(pilot->jam_chance < o->u.jam.chance) { /* Substitude. */
|
||||||
/* TODO: Make more jammers improve overall. */
|
/* @todo Make more jammers improve overall. */
|
||||||
pilot->jam_range = o->u.jam.range;
|
pilot->jam_range = o->u.jam.range;
|
||||||
pilot->jam_chance = o->u.jam.chance;
|
pilot->jam_chance = o->u.jam.chance;
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ void pilots_free(void);
|
|||||||
void pilots_clean(void);
|
void pilots_clean(void);
|
||||||
void pilots_cleanAll(void);
|
void pilots_cleanAll(void);
|
||||||
void pilot_free(Pilot* p);
|
void pilot_free(Pilot* p);
|
||||||
int fleet_load(void); /* TODO */
|
int fleet_load(void);
|
||||||
void fleet_free(void);
|
void fleet_free(void);
|
||||||
|
|
||||||
/* Update. */
|
/* Update. */
|
||||||
|
@ -284,7 +284,7 @@ static void player_newMake(void) {
|
|||||||
else if(xml_isNode(cur, "system")) {
|
else if(xml_isNode(cur, "system")) {
|
||||||
tmp = cur->children;
|
tmp = cur->children;
|
||||||
do {
|
do {
|
||||||
/* System name. TODO: Chance based on percentage. */
|
/* System name. @todo Chance based on percentage. */
|
||||||
if(xml_isNode(tmp, "name"))
|
if(xml_isNode(tmp, "name"))
|
||||||
sysname = strdup(xml_get(tmp));
|
sysname = strdup(xml_get(tmp));
|
||||||
/* Position. */
|
/* Position. */
|
||||||
@ -1737,7 +1737,7 @@ double player_faceHyperspace(void) {
|
|||||||
* @brief Activate the afterburner.
|
* @brief Activate the afterburner.
|
||||||
*/
|
*/
|
||||||
void player_afterburn(void) {
|
void player_afterburn(void) {
|
||||||
/* TODO: Fancy effects. */
|
/* @todo Fancy effects. */
|
||||||
if((player != NULL) && (player->afterburner != NULL)) {
|
if((player != NULL) && (player->afterburner != NULL)) {
|
||||||
player_setFlag(PLAYER_AFTERBURNER);
|
player_setFlag(PLAYER_AFTERBURNER);
|
||||||
pilot_setFlag(player, PILOT_AFTERBURNER);
|
pilot_setFlag(player, PILOT_AFTERBURNER);
|
||||||
|
@ -797,7 +797,7 @@ static StarSystem* system_parse(const xmlNodePtr parent) {
|
|||||||
|
|
||||||
/* Post processing. */
|
/* Post processing. */
|
||||||
if(tmp->nplanets > 0)
|
if(tmp->nplanets > 0)
|
||||||
/* TODO: Make dependant on overall planet faction. */
|
/**< @todo Make dependant on overall planet faction. */
|
||||||
tmp->faction = tmp->planets[0].faction;
|
tmp->faction = tmp->planets[0].faction;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "pilot.h"
|
#include "pilot.h"
|
||||||
|
|
||||||
#define MIN_HYPERSPACE_DIST 1500 /**< Minimum distance to initiate hyperspace. */
|
#define MIN_HYPERSPACE_DIST 1500 /**< Minimum distance to initiate hyperspace. */
|
||||||
#define MAX_HYPERSPACE_VEL 25 /**< Velocity. */
|
#define MAX_HYPERSPACE_VEL 25 /**< Speed to brake to before jumping. */
|
||||||
|
|
||||||
#define PLANET_TECH_MAX 8 /**< Amount of special techs a planet can have. */
|
#define PLANET_TECH_MAX 8 /**< Amount of special techs a planet can have. */
|
||||||
|
|
||||||
|
68
src/spfx.c
68
src/spfx.c
@ -1,3 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* @file spfx.c
|
||||||
|
*
|
||||||
|
* @brief Handle the specific effects.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
|
|
||||||
#include "lephisto.h"
|
#include "lephisto.h"
|
||||||
@ -9,48 +15,58 @@
|
|||||||
#include "rng.h"
|
#include "rng.h"
|
||||||
#include "spfx.h"
|
#include "spfx.h"
|
||||||
|
|
||||||
#define SPFX_GFX "../gfx/spfx/" /* Graphics location. */
|
#define SPFX_GFX "../gfx/spfx/" /**< Graphics location. */
|
||||||
#define SPFX_CHUNK 32 /* Chunk to allocate when needed. */
|
#define SPFX_CHUNK 32 /**< Chunk to allocate when needed. */
|
||||||
#define SHAKE_VEL_MOD 0.0012
|
#define SHAKE_VEL_MOD 0.0012 /**< Shake modifier. */
|
||||||
#define SHAKE_MOD_FACTOR 0.2
|
#define SHAKE_MOD_FACTOR 0.2 /**< Shake modifier factor. */
|
||||||
|
|
||||||
/* Special hardcoded effects.. */
|
/* Special hardcoded effects.. */
|
||||||
|
|
||||||
/* Shake, AKA RUMBLE! */
|
/* Shake, AKA RUMBLE! */
|
||||||
static double shake_rad = 0.;
|
static double shake_rad = 0.; /**< Current shake radius (0 = no shake). */
|
||||||
Vec2 shake_pos = { .x = 0., .y = 0. }; /* Used in nebulae.c */
|
Vec2 shake_pos = { .x = 0., .y = 0. }; /**< Current shake pos. Used in nebulae.c */
|
||||||
static Vec2 shake_vel = { .x = 0., .y = 0. };
|
static Vec2 shake_vel = { .x = 0., .y = 0. }; /**< Current shake vel. */
|
||||||
static int shake_off = 1;
|
static int shake_off = 1; /**< 1 if shake is not active. */
|
||||||
|
|
||||||
/* Generic SPFX template. */
|
/**
|
||||||
|
* @struct SPFX_Base
|
||||||
|
*
|
||||||
|
* @brief Generic special effect.
|
||||||
|
*/
|
||||||
typedef struct SPFX_Base_ {
|
typedef struct SPFX_Base_ {
|
||||||
char* name;
|
char* name; /**< Name of the special effect. */
|
||||||
|
|
||||||
double ttl; /* Time to live. */
|
double ttl; /**< Time to live. */
|
||||||
double anim; /* Total duration in ms. */
|
double anim; /**< Total duration in ms. */
|
||||||
|
|
||||||
glTexture* gfx; /* Will use each sprite as a frame. */
|
glTexture* gfx; /**< Will use each sprite as a frame. */
|
||||||
} SPFX_Base;
|
} SPFX_Base;
|
||||||
|
|
||||||
static SPFX_Base* spfx_effects = NULL;
|
static SPFX_Base* spfx_effects = NULL; /**< Total special effects. */
|
||||||
static int spfx_neffects = 0;
|
static int spfx_neffects = 0; /**< Total number of special effects. */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @struct SPFX
|
||||||
|
*
|
||||||
|
* @brief An actual in-game active special effect.
|
||||||
|
*/
|
||||||
typedef struct SPFX_ {
|
typedef struct SPFX_ {
|
||||||
Vec2 pos, vel; /* They don't accelerate. */
|
Vec2 pos; /**< Current position. */
|
||||||
|
Vec2 vel; /**< Current velocity. */
|
||||||
|
|
||||||
int lastframe; /* Need when pausing. */
|
int lastframe; /**< Need when pausing. */
|
||||||
int effect; /* Actual effect. */
|
int effect; /**< Actual effect. */
|
||||||
double timer; /* Time left. */
|
double timer; /**M Time left. */
|
||||||
} SPFX;
|
} SPFX;
|
||||||
|
|
||||||
/* Front stack is for effects on player. */
|
/* Front stack is for effects on player. */
|
||||||
/* Back is for everything else. */
|
/* Back is for everything else. */
|
||||||
static SPFX* spfx_stack_front = NULL;
|
static SPFX* spfx_stack_front = NULL; /**< Frontal special effect layer. */
|
||||||
static int spfx_nstack_front = 0;
|
static int spfx_nstack_front = 0; /**< Number of special effects in front. */
|
||||||
static int spfx_mstack_front = 0;
|
static int spfx_mstack_front = 0; /**< Memory allocated for frontal special effects. */
|
||||||
static SPFX* spfx_stack_back = NULL;
|
static SPFX* spfx_stack_back = NULL; /**< Back special effect layer. */
|
||||||
static int spfx_nstack_back = 0;
|
static int spfx_nstack_back = 0; /**< Number of special effects in the back. */
|
||||||
static int spfx_mstack_back = 0;
|
static int spfx_mstack_back = 0; /**< Memory allocated for special effects in back. */
|
||||||
|
|
||||||
static int spfx_base_load(char* name, int ttl, int anim, char* gfx, int sx, int sy);
|
static int spfx_base_load(char* name, int ttl, int anim, char* gfx, int sx, int sy);
|
||||||
static void spfx_base_free(SPFX_Base* effect);
|
static void spfx_base_free(SPFX_Base* effect);
|
||||||
@ -91,7 +107,7 @@ int spfx_get(char* name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Load/Unload.
|
/* Load/Unload.
|
||||||
* TODO: make it customizable?
|
* @todo Make it customizable?
|
||||||
*/
|
*/
|
||||||
int spfx_load(void) {
|
int spfx_load(void) {
|
||||||
/* Standard explosion effects. */
|
/* Standard explosion effects. */
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
#include "physics.h"
|
#include "physics.h"
|
||||||
#include "opengl.h"
|
#include "opengl.h"
|
||||||
|
|
||||||
#define SPFX_LAYER_FRONT 0
|
#define SPFX_LAYER_FRONT 0 /* Front spfx layer. */
|
||||||
#define SPFX_LAYER_BACK 1
|
#define SPFX_LAYER_BACK 1 /* Back spfx layer. */
|
||||||
|
|
||||||
#define SHAKE_DECAY 300. /* Decay parameter. */
|
#define SHAKE_DECAY 300. /**< Rumble decay parameter. */
|
||||||
#define SHAKE_MAX 75.*SCREEN_W*SCREEN_H/1024./768. /* Max parameter. */
|
#define SHAKE_MAX 75.*SCREEN_W*SCREEN_H/1024./768. /**< Rubmle max parameter. */
|
||||||
|
|
||||||
/* Stack manipulation. */
|
/* Stack manipulation. */
|
||||||
int spfx_get(char* name);
|
int spfx_get(char* name);
|
||||||
|
Loading…
Reference in New Issue
Block a user