4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
10 /** @file gamelog_entries.h Declaration of gamelog entries, for use in saveload/gamelog_sl.cpp */
12 #ifndef GAMELOG_ENTRIES_H
13 #define GAMELOG_ENTRIES_H
17 #include "date_func.h"
18 #include "settings_type.h"
19 #include "network/core/config.h"
20 #include "saveload/saveload_data.h"
24 extern const uint16 SAVEGAME_VERSION
; ///< current savegame version
26 /** Gamelog entry base class for entries with tick information. */
27 struct GamelogEntryTimed
: GamelogEntry
{
30 GamelogEntryTimed(GamelogEntryType t
) : GamelogEntry(t
), tick(_tick_counter
) { }
32 void PrependTick(GamelogPrintBuffer
*buf
);
35 /** Gamelog entry for game start */
36 struct GamelogEntryStart
: GamelogEntryTimed
{
37 GamelogEntryStart() : GamelogEntryTimed(GLOG_START
) { }
39 void Print(GamelogPrintBuffer
*buf
);
42 /** Gamelog entry after game start */
43 struct GamelogEntryStarted
: GamelogEntry
{
44 GamelogEntryStarted() : GamelogEntry(GLOG_STARTED
) { }
46 void Print(GamelogPrintBuffer
*buf
);
49 /** Gamelog entry for game load */
50 struct GamelogEntryLoad
: GamelogEntryTimed
{
51 GamelogEntryLoad() : GamelogEntryTimed(GLOG_LOAD
) { }
53 void Print(GamelogPrintBuffer
*buf
);
56 /** Gamelog entry after game load */
57 struct GamelogEntryLoaded
: GamelogEntry
{
58 GamelogEntryLoaded() : GamelogEntry(GLOG_LOADED
) { }
60 void Print(GamelogPrintBuffer
*buf
);
63 /** Gamelog entry for mode switch between scenario editor and game */
64 struct GamelogEntryMode
: GamelogEntry
{
65 byte mode
; ///< new game mode (editor or game)
66 byte landscape
; ///< landscape (temperate, arctic, ...)
68 GamelogEntryMode() : GamelogEntry(GLOG_MODE
), mode(_game_mode
),
69 landscape(_settings_game
.game_creation
.landscape
) { }
71 void Print(GamelogPrintBuffer
*buf
);
74 /** Gamelog entry for game revision string */
75 struct GamelogEntryRevision
: GamelogEntry
{
76 char text
[NETWORK_REVISION_LENGTH
]; ///< revision string,
77 uint32 newgrf
; ///< newgrf version
78 uint16 slver
; ///< savegame version
79 byte modified
; ///< modified flag
81 GamelogEntryRevision() : GamelogEntry(GLOG_REVISION
),
82 newgrf(_openttd_newgrf_version
),
83 slver(SAVEGAME_VERSION
),
84 modified(_openttd_revision_modified
) {
85 memset(this->text
, 0, sizeof(this->text
));
86 bstrcpy (this->text
, _openttd_revision
);
89 void Print(GamelogPrintBuffer
*buf
);
92 /** Gamelog entry for game revision string (legacy) */
93 struct GamelogEntryLegacyRev
: GamelogEntry
{
94 char text
[NETWORK_REVISION_LENGTH
]; ///< revision string,
95 uint32 newgrf
; ///< openttd newgrf version
96 uint16 slver
; ///< openttd savegame version
97 byte modified
; ///< modified flag
99 /* This entry should only be generated from savegames. */
100 GamelogEntryLegacyRev() : GamelogEntry(GLOG_LEGACYREV
),
101 newgrf(), slver(), modified() { }
103 void Print(GamelogPrintBuffer
*buf
);
106 /** Gamelog entry for savegames without log */
107 struct GamelogEntryOldVer
: GamelogEntry
{
108 uint32 savetype
; ///< type of savegame
109 uint32 version
; ///< combined ottd or ttdp version
111 GamelogEntryOldVer() : GamelogEntry(GLOG_OLDVER
), savetype(), version() { }
113 GamelogEntryOldVer(const SavegameTypeVersion
*stv
) :
114 GamelogEntry(GLOG_OLDVER
) {
115 switch (this->savetype
= stv
->type
) {
117 case SGT_TTDP2
: this->version
= stv
->ttdp
.version
; break;
118 case SGT_OTTD
: this->version
= (stv
->ottd
.version
<< 8) || (stv
->ottd
.minor_version
& 0xFF); break;
119 default: this->version
= 0; break;
123 void Print(GamelogPrintBuffer
*buf
);
126 /** Gamelog entry for emergency savegames. */
127 struct GamelogEntryEmergency
: GamelogEntryTimed
{
128 GamelogEntryEmergency() : GamelogEntryTimed(GLOG_EMERGENCY
) { }
130 void Print(GamelogPrintBuffer
*buf
);
133 /** Gamelog entry for settings change */
134 struct GamelogEntrySetting
: GamelogEntryTimed
{
135 char *name
; ///< name of the setting
136 int32 oldval
; ///< old value
137 int32 newval
; ///< new value
139 GamelogEntrySetting() : GamelogEntryTimed(GLOG_SETTING
),
140 name(NULL
), oldval(), newval() { }
142 GamelogEntrySetting(const char *name
, int32 oldval
, int32 newval
) :
143 GamelogEntryTimed(GLOG_SETTING
),
144 name(xstrdup(name
)), oldval(oldval
), newval(newval
) { }
146 ~GamelogEntrySetting() {
150 void Print(GamelogPrintBuffer
*buf
);
153 /** Gamelog entry for cheating */
154 struct GamelogEntryCheat
: GamelogEntryTimed
{
155 GamelogEntryCheat() : GamelogEntryTimed(GLOG_CHEAT
) { }
157 void Print(GamelogPrintBuffer
*buf
);
160 /** Gamelog entry for GRF config change begin */
161 struct GamelogEntryGRFBegin
: GamelogEntryTimed
{
162 GamelogEntryGRFBegin() : GamelogEntryTimed(GLOG_GRFBEGIN
) { }
164 void Print(GamelogPrintBuffer
*buf
);
167 /** Gamelog entry for GRF config change end */
168 struct GamelogEntryGRFEnd
: GamelogEntry
{
169 GamelogEntryGRFEnd() : GamelogEntry(GLOG_GRFEND
) { }
171 void Print(GamelogPrintBuffer
*buf
);
174 /** Gamelog entry for GRF addition */
175 struct GamelogEntryGRFAdd
: GamelogEntry
{
176 GRFIdentifier grf
; ///< ID and md5sum of added GRF
178 GamelogEntryGRFAdd() : GamelogEntry(GLOG_GRFADD
), grf() { }
180 GamelogEntryGRFAdd(const GRFIdentifier
*ident
) :
181 GamelogEntry(GLOG_GRFADD
), grf(*ident
) { }
183 void Print(GamelogPrintBuffer
*buf
);
186 /** Gamelog entry for GRF removal */
187 struct GamelogEntryGRFRemove
: GamelogEntry
{
188 uint32 grfid
; ///< ID of removed GRF
190 GamelogEntryGRFRemove(uint32 grfid
= 0) :
191 GamelogEntry(GLOG_GRFREM
), grfid(grfid
) { }
193 void Print(GamelogPrintBuffer
*buf
);
196 /** Gamelog entry for compatible GRF load */
197 struct GamelogEntryGRFCompat
: GamelogEntry
{
198 GRFIdentifier grf
; ///< ID and new md5sum of changed GRF
200 GamelogEntryGRFCompat() : GamelogEntry(GLOG_GRFCOMPAT
), grf() { }
202 GamelogEntryGRFCompat(const GRFIdentifier
*ident
) :
203 GamelogEntry(GLOG_GRFCOMPAT
), grf(*ident
) { }
205 void Print(GamelogPrintBuffer
*buf
);
208 /** Gamelog entry for GRF parameter changes */
209 struct GamelogEntryGRFParam
: GamelogEntry
{
210 uint32 grfid
; ///< ID of GRF with changed parameters
212 GamelogEntryGRFParam(uint32 grfid
= 0) :
213 GamelogEntry(GLOG_GRFPARAM
), grfid(grfid
) { }
215 void Print(GamelogPrintBuffer
*buf
);
218 /** Gamelog entry for GRF order change */
219 struct GamelogEntryGRFMove
: GamelogEntry
{
220 uint32 grfid
; ///< ID of moved GRF
221 int32 offset
; ///< offset, positive = move down
223 GamelogEntryGRFMove() : GamelogEntry(GLOG_GRFMOVE
), grfid(), offset() { }
225 GamelogEntryGRFMove(uint32 grfid
, int32 offset
) :
226 GamelogEntry(GLOG_GRFMOVE
), grfid(grfid
), offset(offset
) { }
228 void Print(GamelogPrintBuffer
*buf
);
231 /** Gamelog entry for GRF bugs */
232 struct GamelogEntryGRFBug
: GamelogEntryTimed
{
233 uint64 data
; ///< additional data
234 uint32 grfid
; ///< ID of problematic GRF
235 byte bug
; ///< type of bug, @see enum GRFBugs
237 GamelogEntryGRFBug() : GamelogEntryTimed(GLOG_GRFBUG
),
238 data(), grfid(), bug() { }
240 GamelogEntryGRFBug(uint32 grfid
, byte bug
, uint64 data
) :
241 GamelogEntryTimed(GLOG_GRFBUG
),
242 data(data
), grfid(grfid
), bug(bug
) { }
244 void Print(GamelogPrintBuffer
*buf
);
247 /** Get a new GamelogEntry by type (when loading a savegame) */
248 GamelogEntry
*GamelogEntryByType(uint type
);
250 #endif /* GAMELOG_ENTRIES_H */