OpenTTD Source  20241108-master-g80f628063a
timer_game_realtime.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #ifndef TIMER_GAME_REALTIME_H
11 #define TIMER_GAME_REALTIME_H
12 
13 #include <chrono>
14 
29 public:
30  enum PeriodFlags {
34  };
35 
36  struct TPeriod {
37  std::chrono::milliseconds period;
38  PeriodFlags flag;
39 
40  TPeriod(std::chrono::milliseconds period, PeriodFlags flag) : period(period), flag(flag) {}
41 
42  bool operator < (const TPeriod &other) const
43  {
44  if (this->flag != other.flag) return this->flag < other.flag;
45  return this->period < other.period;
46  }
47 
48  bool operator == (const TPeriod &other) const
49  {
50  return this->flag == other.flag && this->period == other.period;
51  }
52  };
53  using TElapsed = std::chrono::milliseconds;
54  struct TStorage {
55  std::chrono::milliseconds elapsed;
56  };
57 };
58 
59 #endif /* TIMER_GAME_REALTIME_H */
Timer that represents real time for game-related purposes.
@ UNPAUSED
Only run when not paused.
@ ALWAYS
Always run, even when paused.
@ AUTOSAVE
Only run when not paused or there was a Command executed recently.