From 7fd06bd2654fe17c9d1be525f0a009b654e74b38 Mon Sep 17 00:00:00 2001 From: Allanis Date: Sat, 22 Jun 2013 21:48:25 +0100 Subject: [PATCH] [Fix] Doxygen comments. --- src/lephisto.c | 102 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 72 insertions(+), 30 deletions(-) diff --git a/src/lephisto.c b/src/lephisto.c index e22e869..5582522 100644 --- a/src/lephisto.c +++ b/src/lephisto.c @@ -64,12 +64,15 @@ static void data_name(void); /* Update. */ static void fps_control(void); static void update_all(void); +static void update_routine(double dt); static void render_all(void); -/* @brief The entry point of Lephisto. */ -/* @param[in] argc Number of arguments. */ -/* @param[in] argv Array of argc arguments. */ +/** @brief The entry point of Lephisto. + * @param[in] argc Number of arguments. + * @param[in] argv Array of argc arguments. + * @return EXIT_SUCCESS on success. + */ #ifdef WIN32 int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) { @@ -215,6 +218,9 @@ int main(int argc, char** argv) { exit(EXIT_SUCCESS); } +/** + * Load all the data, makes main() simpler. + */ void load_all(void) { /* Ordering of these is very important as they are interdependent. */ commodity_load(); @@ -227,7 +233,9 @@ void load_all(void) { space_load(); } -/* @brief Unloads all data, simplifies main(). */ +/** + * @brief Unloads all data, simplifies main(). + */ void unload_all(void) { /* Data unloading - order should not matter, but inverse load_all is good. */ fleet_free(); @@ -239,7 +247,9 @@ void unload_all(void) { commodity_free(); } -/* @brief Slip main loop from main() for secondary loop hack in toolkit.c. */ +/** + * @brief Split main loop from main() for secondary loop hack in toolkit.c. + */ void main_loop(void) { sound_update(); /* Do sound stuff. */ @@ -260,7 +270,9 @@ void main_loop(void) { static double fps_dt = 1.; static double dt = 0.; -/* @brief Controls the FPS. */ +/** + * @brief Controls the FPS. + */ static void fps_control(void) { unsigned int t; @@ -279,37 +291,61 @@ static void fps_control(void) { } } -/* @brief Updates the game itself (player flying around etc). */ +const double fps_min = 1./50.0; +/** + * @brief Updates the game itself (player flying around etc). + */ static void update_all(void) { -#if 0 - if(dt > 1./30.) { - /* Slow timers down and re-run calculations. */ + double tmpdt; + + if(dt > 1.) { /* Slow timers down and rerun calculations */ pause_delay((unsigned int)dt*1000.); return; } -#endif + /* We'll force a minimum of 50 FPS. */ + else if(dt > fps_min) { + tmpdt = dt - fps_min; + pause_delay((unsigned int)(tmpdt*1000)); + update_routine(fps_min); + + /* Run as many cycles of dt=fps_min as needed. */ + while(tmpdt > fps_min) { + pause_delay((unsigned int)(-fps_min*1000)); /* Increment counters */ + update_routine(fps_min); + tmpdt -= fps_min; + } + } + update_routine(dt); +} + +/** + * @brief Actually runs the update. + */ +static void update_routine(double dt) { space_update(dt); weapons_update(dt); spfx_update(dt); pilots_update(dt); } -/* @brief == Renders the game. =========================== */ -/* Blitting order. (layers) */ -/* */ -/* BG | Stars and planets. */ -/* | Background player stuff (planet targetting) */ -/* | Background particles. */ -/* | Back layer weapons. */ -/* X */ -/* N | NPC ships. */ -/* | Front layer weapons. */ -/* | Normal layer particles (above ships). */ -/* X */ -/* FG | Player. */ -/* | Foreground particles. */ -/* | Text and GUI. */ -/* ======================================================== */ +/** + * @brief Renders the game itself (player flying around etc. + * + * Blitting order. (layers) + * + * BG | Stars and planets. + * | Background player stuff (planet targetting) + * | Background particles. + * | Back layer weapons. + * X + * N | NPC ships. + * | Front layer weapons. + * | Normal layer particles (above ships). + * X + * FG | Player. + * | Foreground particles. + * | Text and GUI. + */ static void render_all(void) { /* Setup. */ spfx_start(dt); @@ -331,7 +367,9 @@ static void render_all(void) { static double fps = 0.; static double fps_cur = 0.; -/* @brief Displays FPS on the screen. */ +/** + * @brief Displays FPS on the screen. + */ static void display_fps(const double dt) { double x, y; fps_dt += dt; @@ -348,7 +386,9 @@ static void display_fps(const double dt) { gl_print(NULL, x, y, NULL, "%3.2f", fps); } -/* @brief Set the data module's name. */ +/* + * @brief Set the data module's name. + */ static void data_name(void) { uint32_t bufsize; char* buf; @@ -401,7 +441,9 @@ static void data_name(void) { xmlCleanupParser(); } -/* @brief Set the window caption. */ +/* + * @brief Set the window caption. + */ static void window_caption(void) { char tmp[DATA_NAME_LEN+10];