diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/client.cc | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/client/client.cc b/src/client/client.cc index 2079c71..c607c64 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -4,6 +4,12 @@ the terms and conditions of the GNU General Public License version 2 */ +#include <SDL/SDL.h> + +#include <iostream> +#include <cmath> +#include <iomanip> + #include "client/chat.h" #include "client/client.h" #include "client/video.h" @@ -13,13 +19,6 @@ #include "client/view.h" #include "core/core.h" -// SDL headers -#include <SDL/SDL.h> - -// C++ headers -#include <iostream> -#include <cmath> - namespace client { @@ -128,26 +127,27 @@ void Client::run() Uint32 client_framerate = (Uint32)(1000/120); Uint32 elapsed = 0; - + while (true) { - if (cl_framerate->value()) - client_framerate = (Uint32) (1000.0f / cl_framerate->value()); - Uint32 chrono = SDL_GetTicks(); core::Application::frame((float)elapsed / 1000.0f); video::frame((float)elapsed / 1000.0f); input::frame((float)elapsed / 1000.0f); - // sleep Uint32 current = SDL_GetTicks(); - elapsed = current - chrono; - if (elapsed < client_framerate) { - SDL_Delay(client_framerate - elapsed); - elapsed = client_framerate; - } + if (cl_framerate->value()) { + client_framerate = (Uint32) (1000.0f / cl_framerate->value()); + if (client_framerate && (elapsed < client_framerate)) { + SDL_Delay(client_framerate - elapsed); + elapsed = client_framerate; + } + }; + + //con_debug << "tick " << std::setw(8) << chrono << " " << std::setw(8) << current << " " << elapsed; + } } |