mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-07 03:12:36 +01:00
Replace sf::Clock with std::chrono::steady_clock
This commit is contained in:
parent
a35d3d81b8
commit
572f61e076
@ -297,8 +297,8 @@ PlayerController *RWGame::getPlayer()
|
||||
|
||||
int RWGame::run()
|
||||
{
|
||||
clock.restart();
|
||||
|
||||
last_clock_time = clock.now();
|
||||
|
||||
// Loop until the window is closed or we run out of state.
|
||||
while (window.isOpen() && StateManager::get().states.size()) {
|
||||
State* state = StateManager::get().states.back();
|
||||
@ -334,7 +334,9 @@ int RWGame::run()
|
||||
break;
|
||||
}
|
||||
|
||||
float timer = clock.restart().asSeconds();
|
||||
auto now = clock.now();
|
||||
float timer = std::chrono::duration<float>(now - last_clock_time).count();
|
||||
last_clock_time = now;
|
||||
accum += timer * timescale;
|
||||
|
||||
RW_PROFILE_BEGIN("Update");
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <engine/GameWorld.hpp>
|
||||
#include <render/GameRenderer.hpp>
|
||||
#include <script/ScriptMachine.hpp>
|
||||
#include <chrono>
|
||||
#include "game.hpp"
|
||||
|
||||
#include "GameConfig.hpp"
|
||||
@ -31,7 +32,9 @@ class RWGame
|
||||
HttpServer* httpserver = nullptr;
|
||||
std::thread* httpserver_thread = nullptr;
|
||||
sf::RenderWindow window;
|
||||
sf::Clock clock;
|
||||
std::chrono::steady_clock clock;
|
||||
std::chrono::steady_clock::time_point last_clock_time;
|
||||
|
||||
bool inFocus;
|
||||
ViewCamera lastCam, nextCam;
|
||||
bool showDebugStats;
|
||||
|
Loading…
Reference in New Issue
Block a user