From e132c6a9f75918978051e8eb23092f5d05c7c3fc Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 14 Apr 2018 15:40:24 +0200 Subject: Redo frequency counters. --- src/game/game.cpp | 12 ++++++++++-- src/game/interface.cpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'src/game') diff --git a/src/game/game.cpp b/src/game/game.cpp index bc8d3c7..185e2d1 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -307,7 +307,7 @@ void state_t::resume(void) } #define TIME_DELTA ((ntime_t)1000000000 / 100) -#define TIME_LIMIT ((ntime_t)1000000000 / 10) +#define TIME_LIMIT ((ntime_t)1000000000 / 20) void state_t::tick(ntime_t time_) { @@ -344,7 +344,15 @@ void state_t::tick(ntime_t time_) fc_game.tick(); if (nclock() - time_ > TIME_LIMIT) { - frames_behind += target - frames_since_t0; + size_t left; + + left = target - frames_since_t0; + t0 = nclock(); + frames_since_t0 = 0; + frames_behind++; + + interface->print("(Lag: " + std::to_string(left) + ")"); + break; } } diff --git a/src/game/interface.cpp b/src/game/interface.cpp index 5b2d7b8..5872d17 100644 --- a/src/game/interface.cpp +++ b/src/game/interface.cpp @@ -381,7 +381,7 @@ void state_t::render_to(render::state_t *render) x[1] -= em; ss.str(std::string()); ss << std::fixed << std::setprecision(1); - ss << "FPS: " << fc_render.freq_ma() << ", " << fc_game.freq_ma() << " Hz"; + ss << "FPS: " << fc_render.read(SEC(1)) << ", " << fc_game.read(SEC(1)) << " Hz"; render->render_text(x, em, ss.str(), render::ALIGN_LEFT_TOP, sf::Color::White); x[1] -= em; -- cgit