OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
10 #include "../stdafx.h"
12 #include "../core/random_func.hpp"
13 #include "../network/network.h"
14 #include "../gfx_func.h"
15 #include "../progress.h"
16 #include "../thread.h"
17 #include "../window_func.h"
22 auto cur_ticks = std::chrono::steady_clock::now();
24 if (cur_ticks >= this->next_game_tick) {
25 this->next_game_tick += this->GetGameInterval();
27 if (this->next_game_tick < cur_ticks - ALLOWED_DRIFT * this->GetGameInterval()) this->next_game_tick = cur_ticks;
39 this->next_draw_tick = this->next_game_tick;
45 this->next_draw_tick += this->GetDrawInterval();
47 if (this->next_draw_tick < cur_ticks - ALLOWED_DRIFT * this->GetDrawInterval()) this->next_draw_tick = cur_ticks;
58 ChangeGameSpeed(
true);
61 ChangeGameSpeed(
false);
78 auto next_tick = std::min(this->next_draw_tick, this->next_game_tick);
79 auto now = std::chrono::steady_clock::now();
81 if (next_tick > now) {
83 std::this_thread::sleep_for(next_tick - now);
bool Tick()
Run the game for a single tick, processing boththe game-tick and draw-tick.
virtual void CheckPaletteAnim()
Process any pending palette animation.
virtual bool HasGUI() const
Whether the driver has a graphical user interface with the end user.
void UpdateWindows()
Update the continuously changing contents of the windows, such as the viewports.
virtual void InputLoop()
Handle input logic, is CTRL pressed, should we fast-forward, etc.
bool _networking
are we in networking mode?
virtual void UnlockVideoBuffer()
Unlock a previously locked video buffer.
SwitchMode _switch_mode
The next mainloop command.
bool fast_forward_via_key
The fast-forward was enabled by key press.
void SleepTillNextTick()
Sleep till the next tick is about to happen.
bool fast_forward_key_pressed
The fast-forward key is being pressed.
virtual bool LockVideoBuffer()
Make sure the video buffer is ready for drawing.
static bool HasModalProgress()
Check if we are currently in a modal progress state.
virtual bool PollEvent()
Process a single system event.