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/>.
8 /** @file gamelog.h Functions to be called to log fundamental changes to the game */
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
47 struct GamelogInternalData
;
51 std::unique_ptr
<GamelogInternalData
> data
;
52 GamelogActionType action_type
;
53 struct LoggedAction
*current_action
;
55 void Change(std::unique_ptr
<LoggedChange
> &&change
);
61 void StartAction(GamelogActionType at
);
67 void Print(std::function
<void(const std::string
&)> proc
);
68 void PrintDebug(int level
);
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
);
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 */