Fix #10490: Allow ships to exit depots if another is not moving at the exit point...
[openttd-github.git] / src / gamelog.h
blob919ef9b5ba88d11f16541b3d7d8cd58b702df070
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 */
8 /** @file gamelog.h Functions to be called to log fundamental changes to the game */
10 #ifndef GAMELOG_H
11 #define GAMELOG_H
13 #include "newgrf_config.h"
15 /** The actions we log. */
16 enum GamelogActionType : uint8_t {
17 GLAT_START, ///< Game created
18 GLAT_LOAD, ///< Game loaded
19 GLAT_GRF, ///< GRF changed
20 GLAT_CHEAT, ///< Cheat was used
21 GLAT_SETTING, ///< Setting changed
22 GLAT_GRFBUG, ///< GRF bug was triggered
23 GLAT_EMERGENCY, ///< Emergency savegame
24 GLAT_END, ///< So we know how many GLATs are there
25 GLAT_NONE = 0xFF, ///< No logging active; in savegames, end of list
28 /** Type of logged change */
29 enum GamelogChangeType : uint8_t {
30 GLCT_MODE, ///< Scenario editor x Game, different landscape
31 GLCT_REVISION, ///< Changed game revision string
32 GLCT_OLDVER, ///< Loaded from savegame without logged data
33 GLCT_SETTING, ///< Non-networksafe setting value changed
34 GLCT_GRFADD, ///< Removed GRF
35 GLCT_GRFREM, ///< Added GRF
36 GLCT_GRFCOMPAT, ///< Loading compatible GRF
37 GLCT_GRFPARAM, ///< GRF parameter changed
38 GLCT_GRFMOVE, ///< GRF order changed
39 GLCT_GRFBUG, ///< GRF bug triggered
40 GLCT_EMERGENCY, ///< Emergency savegame
41 GLCT_END, ///< So we know how many GLCTs are there
42 GLCT_NONE = 0xFF, ///< In savegames, end of list
45 struct LoggedChange;
46 struct LoggedAction;
47 struct GamelogInternalData;
49 class Gamelog {
50 private:
51 std::unique_ptr<GamelogInternalData> data;
52 GamelogActionType action_type;
53 struct LoggedAction *current_action;
55 void Change(std::unique_ptr<LoggedChange> &&change);
57 public:
58 Gamelog();
59 ~Gamelog();
61 void StartAction(GamelogActionType at);
62 void StopAction();
63 void StopAnyAction();
65 void Reset();
67 void Print(std::function<void(const std::string &)> proc);
68 void PrintDebug(int level);
69 void PrintConsole();
71 void Emergency();
72 bool TestEmergency();
74 void Revision();
75 void Mode();
76 void Oldver();
77 void Setting(const std::string &name, int32_t oldval, int32_t newval);
79 void GRFUpdate(const GRFConfig *oldg, const GRFConfig *newg);
80 void GRFAddList(const GRFConfig *newg);
81 void GRFRemove(uint32_t grfid);
82 void GRFAdd(const GRFConfig *newg);
83 void GRFBug(uint32_t grfid, byte bug, uint64_t data);
84 bool GRFBugReverse(uint32_t grfid, uint16_t internal_id);
85 void GRFCompatible(const GRFIdentifier *newg);
86 void GRFMove(uint32_t grfid, int32_t offset);
87 void GRFParameters(uint32_t grfid);
89 void TestRevision();
90 void TestMode();
92 void Info(uint32_t *last_ottd_rev, byte *ever_modified, bool *removed_newgrfs);
93 const GRFIdentifier *GetOverriddenIdentifier(const GRFConfig *c);
95 /* Saveload handler for gamelog needs access to internal data. */
96 friend struct GLOGChunkHandler;
99 extern Gamelog _gamelog;
101 #endif /* GAMELOG_H */