From 673b83ea6acfa07cc6a579369c57b6de977ee420 Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Fri, 11 Oct 2013 23:02:39 +0100
Subject: [PATCH] [Add] More doxygen along with some slight code cleaup.

---
 src/ai.c     |  7 +++---
 src/board.c  |  2 +-
 src/conf.c   |  2 +-
 src/font.c   | 28 ++++++++++++----------
 src/land.c   |  8 +++----
 src/llua.c   | 12 +++++++---
 src/map.c    |  2 +-
 src/menu.c   |  2 +-
 src/pilot.c  |  2 +-
 src/pilot.h  |  2 +-
 src/player.c |  4 ++--
 src/space.c  |  2 +-
 src/space.h  |  2 +-
 src/spfx.c   | 68 ++++++++++++++++++++++++++++++++--------------------
 src/spfx.h   |  8 +++----
 15 files changed, 88 insertions(+), 63 deletions(-)

diff --git a/src/ai.c b/src/ai.c
index 3c2e082..7f90af5 100644
--- a/src/ai.c
+++ b/src/ai.c
@@ -791,8 +791,7 @@ static int ai_face(lua_State* L) {
   if(n >= 0) {
     p = pilot_get(n);
     if(p == NULL) return 0; /* Make sure pilot is valid. */
-    vect_cset(&tv, VX(p->solid->pos) + FACE_WVEL*VX(p->solid->vel),
-              VY(p->solid->pos) + FACE_WVEL*VY(p->solid->vel));
+    vect_cset(&tv, VX(p->solid->pos), VY(p->solid->pos));
     v = NULL;
   }
   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;
   if(lua_gettop(L) > 1 && lua_isnumber(L,2)) invert = (int)lua_tonumber(L,2);
   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)
     /* Target is dynamic. */
diff --git a/src/board.c b/src/board.c
index b5a448f..662d0c4 100644
--- a/src/board.c
+++ b/src/board.c
@@ -152,7 +152,7 @@ static void board_stealCargo(char* str) {
 
   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;
   while((p->ncommodities > 0) && (q != 0)) {
     q = pilot_addCargo(player, p->commodities[0].commodity,
diff --git a/src/conf.c b/src/conf.c
index 60e232d..ee363c6 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -279,7 +279,7 @@ void conf_parseCLI(int argc, char** argv) {
 
 /* Saves the current configuration. */
 int conf_saveConfig(void) {
-  /* TODO: save conf. */
+  /** @todo save conf. */
   return 0;
 }
 
diff --git a/src/font.c b/src/font.c
index 5d72c60..52e133a 100644
--- a/src/font.c
+++ b/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 "ft2build.h"
@@ -10,18 +26,6 @@
 
 #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. */
 glFont gl_defFont;
 glFont gl_smallFont;
diff --git a/src/land.c b/src/land.c
index 4e39b5d..4ec7fd6 100644
--- a/src/land.c
+++ b/src/land.c
@@ -167,7 +167,7 @@ static void commodity_exchange_open(void) {
   commodity_update(NULL);
 
   if(!has_visited(VISITED_COMMODITY)) {
-    /* TODO: mission check. */
+    /* @todo Mission check. */
     visited(VISITED_COMMODITY);
   }
 }
@@ -310,7 +310,7 @@ static void outfits_open(void) {
   outfits_update(NULL);
 
   if(!has_visited(VISITED_OUTFITS)) {
-    /* TODO: mission check. */
+    /* @todo mission check. */
     visited(VISITED_OUTFITS);
   }
 }
@@ -585,7 +585,7 @@ static void shipyard_open(void) {
   shipyard_update(NULL);
 
   if(!has_visited(VISITED_SHIPYARD)) {
-    /* TODO: mission check. */
+    /* @todo mission check. */
     visited(VISITED_SHIPYARD);
   }
 }
@@ -1189,7 +1189,7 @@ void land(Planet* p) {
       land_planet->faction, land_planet->name, cur_system->name);
 
   if(!has_visited(VISITED_LAND)) {
-    /* TODO: mission check. */
+    /* @todo mission check. */
     visited(VISITED_LAND);
   }
 }
diff --git a/src/llua.c b/src/llua.c
index c1e2a2b..c3860b8 100644
--- a/src/llua.c
+++ b/src/llua.c
@@ -74,11 +74,17 @@ int llua_load(lua_State* L, lua_CFunction f) {
   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 i;
   /* Unsafe functions. */
-  char* override[] = {
+  const char* override[] = {
     "collectgarbage",
     "dofile",
     "getfenv",
@@ -163,7 +169,7 @@ int lua_loadTk(lua_State* L) {
 
 /* -- Lephisto. -- */
 static int lephisto_lang(lua_State* L) {
-  /* TODO: multilanguage stuff. */
+  /* @todo Multilanguage stuff. */
   lua_pushstring(L, "en");
   return 1;
 }
diff --git a/src/map.c b/src/map.c
index 6346b73..a36eeb4 100644
--- a/src/map.c
+++ b/src/map.c
@@ -204,7 +204,7 @@ static void map_update(void) {
       }
       else if(f != sys->planets[i].faction &&
           (sys->planets[i].faction>0)) {
-        /* TODO: more verbosity. */
+        /* @todo More verbosity. */
         snprintf(buf, 100, "Multiple");
         break;
       }
diff --git a/src/menu.c b/src/menu.c
index 94e23e6..e5ff326 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -194,7 +194,7 @@ static void menu_small_exit(char* str) {
 /* Edit the options. */
 static void edit_options(char* str) {
   (void)str;
-  /* TODO */
+  /* @todo Make options menu */
 }
 
 /* Exit the game. */
diff --git a/src/pilot.c b/src/pilot.c
index e599be1..bf5221e 100644
--- a/src/pilot.c
+++ b/src/pilot.c
@@ -899,7 +899,7 @@ void pilot_calcStats(Pilot* pilot) {
       pilot->afterburner = &pilot->outfits[i]; /* Set afterburner. */
     else if(outfit_isJammer(o)) { /* Jammer. */
       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_chance = o->u.jam.chance;
       }
diff --git a/src/pilot.h b/src/pilot.h
index 36b7159..61ac066 100644
--- a/src/pilot.h
+++ b/src/pilot.h
@@ -258,7 +258,7 @@ 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);
 void fleet_free(void);
 
 /* Update. */
diff --git a/src/player.c b/src/player.c
index 6d1b9c5..fa27161 100644
--- a/src/player.c
+++ b/src/player.c
@@ -284,7 +284,7 @@ static void player_newMake(void) {
         else if(xml_isNode(cur, "system")) {
           tmp = cur->children;
           do {
-            /* System name. TODO: Chance based on percentage. */
+            /* System name. @todo Chance based on percentage. */
             if(xml_isNode(tmp, "name"))
               sysname = strdup(xml_get(tmp));
             /* Position. */
@@ -1737,7 +1737,7 @@ double player_faceHyperspace(void) {
  * @brief Activate the afterburner.
  */
 void player_afterburn(void) {
-  /* TODO: Fancy effects. */
+  /* @todo Fancy effects. */
   if((player != NULL) && (player->afterburner != NULL)) {
     player_setFlag(PLAYER_AFTERBURNER);
     pilot_setFlag(player, PILOT_AFTERBURNER);
diff --git a/src/space.c b/src/space.c
index ef84100..e64acd7 100644
--- a/src/space.c
+++ b/src/space.c
@@ -797,7 +797,7 @@ static StarSystem* system_parse(const xmlNodePtr parent) {
 
   /* Post processing. */
   if(tmp->nplanets > 0)
-    /* TODO: Make dependant on overall planet faction. */
+    /**< @todo Make dependant on overall planet faction. */
     tmp->faction = tmp->planets[0].faction;
   return tmp;
 }
diff --git a/src/space.h b/src/space.h
index 9abb686..f0b89eb 100644
--- a/src/space.h
+++ b/src/space.h
@@ -5,7 +5,7 @@
 #include "pilot.h"
 
 #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. */
 
diff --git a/src/spfx.c b/src/spfx.c
index be25dc7..5317ad1 100644
--- a/src/spfx.c
+++ b/src/spfx.c
@@ -1,3 +1,9 @@
+/**
+ * @file spfx.c
+ *
+ * @brief Handle the specific effects.
+ */
+
 #include <SDL.h>
 
 #include "lephisto.h"
@@ -9,48 +15,58 @@
 #include "rng.h"
 #include "spfx.h"
 
-#define SPFX_GFX          "../gfx/spfx/"  /* Graphics location. */
-#define SPFX_CHUNK        32              /* Chunk to allocate when needed. */
-#define SHAKE_VEL_MOD     0.0012
-#define SHAKE_MOD_FACTOR  0.2
+#define SPFX_GFX          "../gfx/spfx/"  /**< Graphics location. */
+#define SPFX_CHUNK        32              /**< Chunk to allocate when needed. */
+#define SHAKE_VEL_MOD     0.0012          /**< Shake modifier. */
+#define SHAKE_MOD_FACTOR  0.2             /**< Shake modifier factor. */
 
 /* Special hardcoded effects.. */
 
 /* Shake, AKA RUMBLE! */
-static double shake_rad = 0.;
-Vec2 shake_pos = { .x = 0., .y = 0. }; /* Used in nebulae.c */
-static Vec2 shake_vel = { .x = 0., .y = 0. };
-static int shake_off = 1;
+static double shake_rad = 0.;             /**< Current shake radius (0 = no shake). */
+Vec2 shake_pos = { .x = 0., .y = 0. };    /**< Current shake pos. Used in nebulae.c */
+static Vec2 shake_vel = { .x = 0., .y = 0. }; /**< Current shake vel. */
+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_ {
-  char* name;
+  char* name;     /**< Name of the special effect. */
 
-  double ttl;     /* Time to live. */
-  double anim;    /* Total duration in ms. */
+  double ttl;     /**< Time to live. */
+  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;
 
-static SPFX_Base* spfx_effects = NULL;
-static int spfx_neffects = 0;
+static SPFX_Base* spfx_effects = NULL;  /**< Total special effects. */
+static int spfx_neffects = 0;           /**< Total number of special effects. */
 
+/**
+ * @struct SPFX
+ *
+ * @brief An actual in-game active special effect.
+ */
 typedef struct SPFX_ {
-  Vec2 pos, vel;  /* They don't accelerate. */
+  Vec2 pos;       /**< Current position. */
+  Vec2 vel;       /**< Current velocity. */
 
-  int lastframe;  /* Need when pausing. */
-  int effect;     /* Actual effect. */
-  double timer;   /* Time left. */
+  int lastframe;  /**< Need when pausing. */
+  int effect;     /**< Actual effect. */
+  double timer;   /**M Time left. */
 } SPFX;
 
 /* Front stack is for effects on player. */
 /* Back is for everything else. */
-static SPFX*  spfx_stack_front   = NULL;
-static int   spfx_nstack_front  = 0;
-static int   spfx_mstack_front  = 0;
-static SPFX* spfx_stack_back   = NULL;
-static int   spfx_nstack_back  = 0;
-static int   spfx_mstack_back  = 0;
+static SPFX*  spfx_stack_front   = NULL;  /**< Frontal special effect layer. */
+static int   spfx_nstack_front  = 0;      /**< Number of special effects in front. */
+static int   spfx_mstack_front  = 0;      /**< Memory allocated for frontal special effects. */
+static SPFX* spfx_stack_back   = NULL;    /**< Back special effect layer. */
+static int   spfx_nstack_back  = 0;       /**< Number of special effects in the back. */
+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 void spfx_base_free(SPFX_Base* effect);
@@ -91,7 +107,7 @@ int spfx_get(char* name) {
 }
 
 /* Load/Unload. 
- * TODO: make it customizable?
+ * @todo Make it customizable?
  */
 int spfx_load(void) {
   /* Standard explosion effects. */
diff --git a/src/spfx.h b/src/spfx.h
index d2189da..f47e503 100644
--- a/src/spfx.h
+++ b/src/spfx.h
@@ -2,11 +2,11 @@
 #include "physics.h"
 #include "opengl.h"
 
-#define SPFX_LAYER_FRONT  0
-#define SPFX_LAYER_BACK  1
+#define SPFX_LAYER_FRONT  0 /* Front spfx layer. */
+#define SPFX_LAYER_BACK   1 /* Back spfx layer. */
 
-#define SHAKE_DECAY 300. /* Decay parameter. */
-#define SHAKE_MAX   75.*SCREEN_W*SCREEN_H/1024./768. /* Max parameter. */
+#define SHAKE_DECAY 300. /**< Rumble decay parameter. */
+#define SHAKE_MAX   75.*SCREEN_W*SCREEN_H/1024./768. /**< Rubmle max parameter. */
 
 /* Stack manipulation. */
 int spfx_get(char* name);