OpenTTD Source  20240919-master-gdf0233f4c2
TimerGameRealtime Class Reference

Timer that represents real time for game-related purposes. More...

#include <timer_game_realtime.h>

Data Structures

struct  TPeriod
 
struct  TStorage
 

Public Types

enum  PeriodFlags { ALWAYS, UNPAUSED, AUTOSAVE }
 
using TElapsed = std::chrono::milliseconds
 

Detailed Description

Timer that represents real time for game-related purposes.

For pausing, there are several modes:

  • Continue to tick during pause (PeriodFlags::ALWAYS).
  • Stop ticking when paused (PeriodFlags::UNPAUSED).
  • Only tick when unpaused or when there was a Command executed recently (recently: since last autosave) (PeriodFlags::AUTOSAVE).
Note
The lowest possible interval is 1ms, although realistic the lowest interval is 27ms. This timer is only updated when the game-thread makes a tick, which happens every 27ms.
Callbacks are executed in the game-thread.

Definition at line 28 of file timer_game_realtime.h.

Member Enumeration Documentation

◆ PeriodFlags

Enumerator
ALWAYS 

Always run, even when paused.

UNPAUSED 

Only run when not paused.

AUTOSAVE 

Only run when not paused or there was a Command executed recently.

Definition at line 30 of file timer_game_realtime.h.


The documentation for this class was generated from the following file: