diff options
-rw-r--r-- | src/game.cpp | 92 | ||||
-rw-r--r-- | src/gui/char_server.cpp | 3 | ||||
-rw-r--r-- | src/log.cpp | 2 |
3 files changed, 46 insertions, 51 deletions
diff --git a/src/game.cpp b/src/game.cpp index 73439947..1c9b37a7 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -47,67 +47,67 @@ unsigned int player_x, player_y; bool refresh_beings = false; unsigned char keyb_state; volatile int tick_time; -volatile bool refresh = false, action_time = false; +volatile bool action_time = false; int current_npc, server_tick; extern unsigned char screen_mode; +int fps = 0, frame = 0; Setup *setup = NULL; StatsWindow *stats = NULL; #define MAX_TIME 10000 -/** Finite states machine to keep track - of player walking status (2 steps linear - prediction) - 0 = Standing - 1 = Walking without confirm packet - 2 = Walking with confirm */ +/** + * Finite states machine to keep track of player walking status (2 steps + * linear prediction) + * + * 0 = Standing + * 1 = Walking without confirm packet + * 2 = Walking with confirm + */ char walk_status = 0; void refresh_time(void) { - tick_time++; - if(tick_time==MAX_TIME)tick_time = 0; + tick_time++; + if (tick_time == MAX_TIME) tick_time = 0; } END_OF_FUNCTION(refresh_frame); -void refresh_screen(void) { - refresh = true; -} -END_OF_FUNCTION(refresh_screen); - -int fps = 0, frame = 0; -/** lets u only trigger an action every other second - tmp. counts fps*/ +/** + * Lets u only trigger an action every other second + * tmp. counts fps + */ void second(void) { - action_time = true; - fps = (fps + frame)/2; - frame = 0; + action_time = true; + fps = (fps + frame) / 2; + frame = 0; } END_OF_FUNCTION(second); -/** Return elapsed time (Warning: very unsafe - function. It supposes the delay is always < 10s) */ +/** + * Return elapsed time (Warning: very unsafe function. It supposes the delay + * is always < MAX_TIME ms) + */ short get_elapsed_time(short start_time) { - if(start_time<=tick_time) - return tick_time-start_time; - else - return tick_time+(MAX_TIME-start_time); + if (start_time <= tick_time) { + return tick_time - start_time; + } + else { + return tick_time + (MAX_TIME - start_time); + } } -/** Main game loop */ +/** + * Main game loop + */ void game() { - status("INIT"); do_init(); GraphicEngine *graphicEngine = new GraphicEngine(); while (state != EXIT) { - status("INPUT"); do_input(); - status("GRAPHIC"); graphicEngine->refresh(); - status("PARSE"); do_parse(); - status("FLUSH"); flush(); } @@ -115,7 +115,9 @@ void game() { close_session(); } -/** Initialize game engine */ +/** + * Initialize game engine + */ void do_init() { if (!load_map(map_path)) { error("Could not find map file"); @@ -127,20 +129,10 @@ void do_init() { // Initialize timers tick_time = 0; - refresh = false; LOCK_VARIABLE(tick_time); - LOCK_VARIABLE(refresh); install_int_ex(refresh_time, MSEC_TO_TIMER(1)); - install_int_ex(refresh_screen, /*MSEC_TO_TIMER(2000)*/BPS_TO_TIMER(200)); // Set max refresh rate to 75 fps install_int_ex(second, BPS_TO_TIMER(1)); - // Interrupt drawing while in background - #ifdef WIN32 - set_display_switch_mode(SWITCH_AMNESIA); - #else - set_display_switch_mode(SWITCH_PAUSE); - #endif - // Initialize beings empty(); player_node = new NODE(); @@ -324,14 +316,18 @@ bool handle_key(int unicode, int scancode) return false; } -/** Calculate packet length */ +/** + * Calculate packet length + */ int get_packet_length(short id) { - int len = get_length(id); - if(len==-1)len = RFIFOW(2); - return len; + int len = get_length(id); + if (len == -1)len = RFIFOW(2); + return len; } -/** Parse data received from map server into input buffer */ +/** + * Parse data received from map server into input buffer + */ void do_parse() { unsigned short id; char *temp; diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp index ef45fbcc..6fcb98d1 100644 --- a/src/gui/char_server.cpp +++ b/src/gui/char_server.cpp @@ -26,6 +26,7 @@ #include "button.h" #include "window.h" #include "scrollarea.h" +#include "listbox.h" char server[30]; int showServerList = 1; @@ -35,7 +36,7 @@ ServerSelectDialog::ServerSelectDialog(gcn::Container *parent): Window(parent, "Select Server") { serverListModel = new ServerListModel(); - serverList = new gcn::ListBox(serverListModel); + serverList = new ListBox(serverListModel); scrollArea = new ScrollArea(serverList); okButton = new Button("OK"); cancelButton = new Button("Cancel"); diff --git a/src/log.cpp b/src/log.cpp index d9eb0bda..7b155d51 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -101,7 +101,5 @@ void warning(const char *warning_text) { * Shortcut to log a status update, will only really be logged in debug mode. */ void status(const char *status_text) { -#ifdef DEBUG log("Status", status_text); -#endif } |