OpenTTD Source 20260721-master-g25ec12c62d
gamelog_sl.cpp
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#include "../stdafx.h"
11
12#include "saveload.h"
14
15#include "../gamelog_internal.h"
16#include "../fios.h"
17#include "../string_func.h"
18
19#include "../safeguards.h"
20
21
22class SlGamelogMode : public DefaultSaveLoadHandler<SlGamelogMode, LoggedChange> {
23public:
24 static inline const SaveLoad description[] = {
25 SLE_VARNAME(LoggedChangeMode, mode, "mode.mode", VarTypes::U8),
26 SLE_VARNAME(LoggedChangeMode, landscape, "mode.landscape", VarTypes::U8),
27 };
28 static inline const SaveLoadCompatTable compat_description = _gamelog_mode_sl_compat;
29
30 void Save(LoggedChange *lc) const override
31 {
32 if (lc->ct != GamelogChangeType::Mode) return;
33 SlObject(lc, this->GetDescription());
34 }
35
36 void Load(LoggedChange *lc) const override
37 {
38 if (lc->ct != GamelogChangeType::Mode) return;
39 SlObject(lc, this->GetLoadDescription());
40 }
41
42 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
43};
44
45class SlGamelogRevision : public DefaultSaveLoadHandler<SlGamelogRevision, LoggedChange> {
46public:
47 static const size_t GAMELOG_REVISION_LENGTH = 15;
48 static inline std::array<char, GAMELOG_REVISION_LENGTH> revision_text;
49
50 static inline const SaveLoad description[] = {
53 SLE_VARNAME(LoggedChangeRevision, newgrf, "revision.newgrf", VarTypes::U32),
54 SLE_VARNAME(LoggedChangeRevision, slver, "revision.slver", VarTypes::U16),
55 SLE_VARNAME(LoggedChangeRevision, modified, "revision.modified", VarTypes::U8),
56 };
57 static inline const SaveLoadCompatTable compat_description = _gamelog_revision_sl_compat;
58
59 void Save(LoggedChange *lc) const override
60 {
61 if (lc->ct != GamelogChangeType::Revision) return;
62 SlObject(lc, this->GetDescription());
63 }
64
65 void Load(LoggedChange *lc) const override
66 {
67 if (lc->ct != GamelogChangeType::Revision) return;
68 SlObject(lc, this->GetLoadDescription());
69
71 static_cast<LoggedChangeRevision *>(lc)->text = StrMakeValid(std::string_view(std::begin(SlGamelogRevision::revision_text), std::end(SlGamelogRevision::revision_text)));
72 }
73 }
74
75 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
76};
77
78class SlGamelogOldver : public DefaultSaveLoadHandler<SlGamelogOldver, LoggedChange> {
79public:
80 static inline const SaveLoad description[] = {
82 SLE_VARNAME(LoggedChangeOldVersion, version, "oldver.version", VarTypes::U32),
83 };
84 static inline const SaveLoadCompatTable compat_description = _gamelog_oldver_sl_compat;
85
86 void Save(LoggedChange *lc) const override
87 {
88 if (lc->ct != GamelogChangeType::OldVer) return;
89 SlObject(lc, this->GetDescription());
90 }
91
92 void Load(LoggedChange *lc) const override
93 {
94 if (lc->ct != GamelogChangeType::OldVer) return;
95 SlObject(lc, this->GetLoadDescription());
96 }
97
98 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
99};
100
101class SlGamelogSetting : public DefaultSaveLoadHandler<SlGamelogSetting, LoggedChange> {
102public:
103 static inline const SaveLoad description[] = {
105 SLE_VARNAME(LoggedChangeSettingChanged, oldval, "setting.oldval", VarTypes::I32),
106 SLE_VARNAME(LoggedChangeSettingChanged, newval, "setting.newval", VarTypes::I32),
107 };
108 static inline const SaveLoadCompatTable compat_description = _gamelog_setting_sl_compat;
109
110 void Save(LoggedChange *lc) const override
111 {
112 if (lc->ct != GamelogChangeType::Setting) return;
113 SlObject(lc, this->GetDescription());
114 }
115
116 void Load(LoggedChange *lc) const override
117 {
118 if (lc->ct != GamelogChangeType::Setting) return;
119 SlObject(lc, this->GetLoadDescription());
120 }
121
122 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
123};
124
125class SlGamelogGrfadd : public DefaultSaveLoadHandler<SlGamelogGrfadd, LoggedChange> {
126public:
127 static inline const SaveLoad description[] = {
129 SLE_ARRNAME(LoggedChangeGRFAdd, md5sum, "grfadd.md5sum", VarTypes::U8, 16),
130 };
131 static inline const SaveLoadCompatTable compat_description = _gamelog_grfadd_sl_compat;
132
133 void Save(LoggedChange *lc) const override
134 {
135 if (lc->ct != GamelogChangeType::GRFAdd) return;
136 SlObject(lc, this->GetDescription());
137 }
138
139 void Load(LoggedChange *lc) const override
140 {
141 if (lc->ct != GamelogChangeType::GRFAdd) return;
142 SlObject(lc, this->GetLoadDescription());
143 }
144
145 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
146};
147
148class SlGamelogGrfrem : public DefaultSaveLoadHandler<SlGamelogGrfrem, LoggedChange> {
149public:
150 static inline const SaveLoad description[] = {
152 };
153 static inline const SaveLoadCompatTable compat_description = _gamelog_grfrem_sl_compat;
154
155 void Save(LoggedChange *lc) const override
156 {
157 if (lc->ct != GamelogChangeType::GRFRem) return;
158 SlObject(lc, this->GetDescription());
159 }
160
161 void Load(LoggedChange *lc) const override
162 {
163 if (lc->ct != GamelogChangeType::GRFRem) return;
164 SlObject(lc, this->GetLoadDescription());
165 }
166
167 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
168};
169
170class SlGamelogGrfcompat : public DefaultSaveLoadHandler<SlGamelogGrfcompat, LoggedChange> {
171public:
172 static inline const SaveLoad description[] = {
174 SLE_ARRNAME(LoggedChangeGRFChanged, md5sum, "grfcompat.md5sum", VarTypes::U8, 16),
175 };
176 static inline const SaveLoadCompatTable compat_description = _gamelog_grfcompat_sl_compat;
177
178 void Save(LoggedChange *lc) const override
179 {
180 if (lc->ct != GamelogChangeType::GRFCompat) return;
181 SlObject(lc, this->GetDescription());
182 }
183
184 void Load(LoggedChange *lc) const override
185 {
186 if (lc->ct != GamelogChangeType::GRFCompat) return;
187 SlObject(lc, this->GetLoadDescription());
188 }
189
190 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
191};
192
193class SlGamelogGrfparam : public DefaultSaveLoadHandler<SlGamelogGrfparam, LoggedChange> {
194public:
195 static inline const SaveLoad description[] = {
197 };
198 static inline const SaveLoadCompatTable compat_description = _gamelog_grfparam_sl_compat;
199
200 void Save(LoggedChange *lc) const override
201 {
202 if (lc->ct != GamelogChangeType::GRFParam) return;
203 SlObject(lc, this->GetDescription());
204 }
205
206 void Load(LoggedChange *lc) const override
207 {
208 if (lc->ct != GamelogChangeType::GRFParam) return;
209 SlObject(lc, this->GetLoadDescription());
210 }
211
212 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
213};
214
215class SlGamelogGrfmove : public DefaultSaveLoadHandler<SlGamelogGrfmove, LoggedChange> {
216public:
217 static inline const SaveLoad description[] = {
219 SLE_VARNAME(LoggedChangeGRFMoved, offset, "grfmove.offset", VarTypes::I32),
220 };
221 static inline const SaveLoadCompatTable compat_description = _gamelog_grfmove_sl_compat;
222
223 void Save(LoggedChange *lc) const override
224 {
225 if (lc->ct != GamelogChangeType::GRFMove) return;
226 SlObject(lc, this->GetDescription());
227 }
228
229 void Load(LoggedChange *lc) const override
230 {
231 if (lc->ct != GamelogChangeType::GRFMove) return;
232 SlObject(lc, this->GetLoadDescription());
233 }
234
235 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
236};
237
238class SlGamelogGrfbug : public DefaultSaveLoadHandler<SlGamelogGrfbug, LoggedChange> {
239public:
240 static inline const SaveLoad description[] = {
241 SLE_VARNAME(LoggedChangeGRFBug, data, "grfbug.data", VarTypes::U64),
243 SLE_VARNAME(LoggedChangeGRFBug, bug, "grfbug.bug", VarTypes::U8),
244 };
245 static inline const SaveLoadCompatTable compat_description = _gamelog_grfbug_sl_compat;
246
247 void Save(LoggedChange *lc) const override
248 {
249 if (lc->ct != GamelogChangeType::GRFBug) return;
250 SlObject(lc, this->GetDescription());
251 }
252
253 void Load(LoggedChange *lc) const override
254 {
255 if (lc->ct != GamelogChangeType::GRFBug) return;
256 SlObject(lc, this->GetLoadDescription());
257 }
258
259 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
260};
261
262static bool _is_emergency_save = true;
263
264class SlGamelogEmergency : public DefaultSaveLoadHandler<SlGamelogEmergency, LoggedChange> {
265public:
267 static inline const SaveLoad description[] = {
269 };
270 static inline const SaveLoadCompatTable compat_description = _gamelog_emergency_sl_compat;
271
272 void Save(LoggedChange *lc) const override
273 {
274 if (lc->ct != GamelogChangeType::Emergency) return;
275
276 _is_emergency_save = true;
277 SlObject(lc, this->GetDescription());
278 }
279
280 void Load(LoggedChange *lc) const override
281 {
282 if (lc->ct != GamelogChangeType::Emergency) return;
283
284 SlObject(lc, this->GetLoadDescription());
285 }
286
287 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
288};
289
290static std::unique_ptr<LoggedChange> MakeLoggedChange(GamelogChangeType type)
291{
292 switch (type) {
293 case GamelogChangeType::Mode: return std::make_unique<LoggedChangeMode>();
294 case GamelogChangeType::Revision: return std::make_unique<LoggedChangeRevision>();
295 case GamelogChangeType::OldVer: return std::make_unique<LoggedChangeOldVersion>();
296 case GamelogChangeType::Setting: return std::make_unique<LoggedChangeSettingChanged>();
297 case GamelogChangeType::GRFAdd: return std::make_unique<LoggedChangeGRFAdd>();
298 case GamelogChangeType::GRFRem: return std::make_unique<LoggedChangeGRFRemoved>();
299 case GamelogChangeType::GRFCompat: return std::make_unique<LoggedChangeGRFChanged>();
300 case GamelogChangeType::GRFParam: return std::make_unique<LoggedChangeGRFParameterChanged>();
301 case GamelogChangeType::GRFMove: return std::make_unique<LoggedChangeGRFMoved>();
302 case GamelogChangeType::GRFBug: return std::make_unique<LoggedChangeGRFBug>();
303 case GamelogChangeType::Emergency: return std::make_unique<LoggedChangeEmergencySave>();
306 default:
307 SlErrorCorrupt("Invalid gamelog action type");
308 }
309}
310
311class SlGamelogAction : public DefaultSaveLoadHandler<SlGamelogAction, LoggedAction> {
312public:
313 static inline const SaveLoad description[] = {
315 SLEG_STRUCT("mode", SlGamelogMode),
316 SLEG_STRUCT("revision", SlGamelogRevision),
317 SLEG_STRUCT("oldver", SlGamelogOldver),
318 SLEG_STRUCT("setting", SlGamelogSetting),
319 SLEG_STRUCT("grfadd", SlGamelogGrfadd),
320 SLEG_STRUCT("grfrem", SlGamelogGrfrem),
321 SLEG_STRUCT("grfcompat", SlGamelogGrfcompat),
322 SLEG_STRUCT("grfparam", SlGamelogGrfparam),
323 SLEG_STRUCT("grfmove", SlGamelogGrfmove),
324 SLEG_STRUCT("grfbug", SlGamelogGrfbug),
325 SLEG_STRUCT("emergency", SlGamelogEmergency),
326 };
327 static inline const SaveLoadCompatTable compat_description = _gamelog_action_sl_compat;
328
329 void Save(LoggedAction *la) const override
330 {
331 SlSetStructListLength(la->change.size());
332
333 for (auto &lc : la->change) {
334 assert(lc->ct < GamelogChangeType::End);
335 SlObject(lc.get(), this->GetDescription());
336 }
337 }
338
339 void LoadChange(LoggedAction *la, GamelogChangeType type) const
340 {
341 std::unique_ptr<LoggedChange> lc = MakeLoggedChange(type);
342 SlObject(lc.get(), this->GetLoadDescription());
343 la->change.push_back(std::move(lc));
344 }
345
346 void Load(LoggedAction *la) const override
347 {
350 while ((type = static_cast<GamelogChangeType>(SlReadByte())) != GamelogChangeType::None) {
351 if (type >= GamelogChangeType::End) SlErrorCorrupt("Invalid gamelog change type");
352 LoadChange(la, (GamelogChangeType)type);
353 }
354 return;
355 }
356
357 size_t length = SlGetStructListLength(UINT32_MAX);
358 la->change.reserve(length);
359
360 for (size_t i = 0; i < length; i++) {
361 LoadChange(la, (GamelogChangeType)SlReadByte());
362 }
363 }
364
365 void LoadCheck(LoggedAction *la) const override { this->Load(la); }
366};
367
368static const SaveLoad _gamelog_desc[] = {
373};
374
375struct GLOGChunkHandler : ChunkHandler {
376 GLOGChunkHandler() : ChunkHandler("GLOG", ChunkType::Table) {}
377
378 void LoadCommon(Gamelog &gamelog) const
379 {
380 assert(gamelog.data->action.empty());
381
382 const std::vector<SaveLoad> slt = SlCompatTableHeader(_gamelog_desc, _gamelog_sl_compat);
383
386 while ((type = static_cast<GamelogActionType>(SlReadByte())) != GamelogActionType::None) {
387 if (type >= GamelogActionType::End) SlErrorCorrupt("Invalid gamelog action type");
388
389 LoggedAction &la = gamelog.data->action.emplace_back();
391 SlObject(&la, slt);
392 }
393 return;
394 }
395
396 while (SlIterateArray() != -1) {
397 LoggedAction &la = gamelog.data->action.emplace_back();
398 SlObject(&la, slt);
399 }
400 }
401
402 void Save() const override
403 {
404 SlTableHeader(_gamelog_desc);
405
406 uint i = 0;
407 for (LoggedAction &la : _gamelog.data->action) {
408 SlSetArrayIndex(i++);
409 SlObject(&la, _gamelog_desc);
410 }
411 }
412
413 void Load() const override
414 {
415 this->LoadCommon(_gamelog);
416 }
417
418 void LoadCheck(size_t) const override
419 {
420 this->LoadCommon(_load_check_data.gamelog);
421 }
422};
423
424static const GLOGChunkHandler GLOG;
425static const ChunkHandlerRef gamelog_chunk_handlers[] = {
426 GLOG,
427};
428
429extern const ChunkHandlerTable _gamelog_chunk_handlers(gamelog_chunk_handlers);
Default handler for saving/loading an object to/from disk.
Definition saveload.h:581
SaveLoadTable GetDescription() const override
Definition saveload.h:583
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
void Save(LoggedAction *la) const override
Save the object to disk.
void Load(LoggedAction *la) const override
Load the object from disk.
void LoadCheck(LoggedAction *la) const override
Similar to load, but used only to validate savegames.
static const SaveLoad description[]
We need to store something, so store a "true" value.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void Load(LoggedChange *lc) const override
Load the object from disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Save(LoggedChange *lc) const override
Save the object to disk.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Load(LoggedChange *lc) const override
Load the object from disk.
static std::array< char, GAMELOG_REVISION_LENGTH > revision_text
Temporary location to store the old revision text.
static const size_t GAMELOG_REVISION_LENGTH
Length of the old revision text length.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
void Load(LoggedChange *lc) const override
Load the object from disk.
void Save(LoggedChange *lc) const override
Save the object to disk.
void LoadCheck(LoggedChange *lc) const override
Similar to load, but used only to validate savegames.
Declarations for savegames operations.
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
Definition fios_gui.cpp:41
Gamelog _gamelog
Gamelog instance.
Definition gamelog.cpp:31
GamelogChangeType
Type of logged change.
Definition gamelog.h:30
@ GRFCompat
Loading compatible GRF.
Definition gamelog.h:37
@ GRFAdd
Removed GRF.
Definition gamelog.h:35
@ Revision
Changed game revision string.
Definition gamelog.h:32
@ GRFParam
GRF parameter changed.
Definition gamelog.h:38
@ Setting
Non-networksafe setting value changed.
Definition gamelog.h:34
@ GRFRem
Added GRF.
Definition gamelog.h:36
@ GRFMove
GRF order changed.
Definition gamelog.h:39
@ Mode
Scenario editor x Game, different landscape.
Definition gamelog.h:31
@ None
In savegames, end of list.
Definition gamelog.h:43
@ End
End marker.
Definition gamelog.h:42
@ Emergency
Emergency savegame.
Definition gamelog.h:41
@ GRFBug
GRF bug triggered.
Definition gamelog.h:40
@ OldVer
Loaded from savegame without logged data.
Definition gamelog.h:33
GamelogActionType
The actions we log.
Definition gamelog.h:17
@ None
No logging active; in savegames, end of list.
Definition gamelog.h:26
@ End
End marker.
Definition gamelog.h:25
Declaration shared among gamelog.cpp and saveload/gamelog_sl.cpp.
Loading for gamelog chunks before table headers were added.
const SaveLoadCompat _gamelog_emergency_sl_compat[]
Original field order for SlGamelogEmergency.
const SaveLoadCompat _gamelog_mode_sl_compat[]
Original field order for SlGamelogMode.
const SaveLoadCompat _gamelog_grfmove_sl_compat[]
Original field order for SlGamelogGrfmove.
const SaveLoadCompat _gamelog_action_sl_compat[]
Original field order for SlGamelogAction.
const SaveLoadCompat _gamelog_oldver_sl_compat[]
Original field order for SlGamelogOldver.
const SaveLoadCompat _gamelog_revision_sl_compat[]
Original field order for SlGamelogRevision.
const SaveLoadCompat _gamelog_sl_compat[]
Original field order for _gamelog_desc.
const SaveLoadCompat _gamelog_setting_sl_compat[]
Original field order for SlGamelogSetting.
const SaveLoadCompat _gamelog_grfrem_sl_compat[]
Original field order for SlGamelogGrfrem.
const SaveLoadCompat _gamelog_grfbug_sl_compat[]
Original field order for SlGamelogGrfbug.
const SaveLoadCompat _gamelog_grfadd_sl_compat[]
Original field order for SlGamelogGrfadd.
const SaveLoadCompat _gamelog_grfcompat_sl_compat[]
Original field order for SlGamelogGrfcompat.
const SaveLoadCompat _gamelog_grfparam_sl_compat[]
Original field order for SlGamelogGrfparam.
A number of safeguards to prevent using unsafe methods.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition saveload.cpp:747
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
Definition saveload.cpp:369
uint8_t SlReadByte()
Wrapper for reading a byte from the buffer.
Definition saveload.cpp:410
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
void SlSetStructListLength(size_t length)
Set the length of this list.
Functions/types related to saving and loading games.
@ U64
A 64 bit unsigned int.
Definition saveload.h:660
#define SLEG_CONDARR(name, variable, type, length, from, to)
Storage of a global fixed-size array of SaveLoadType::Variable elements in some savegame versions.
Definition saveload.h:1125
@ U16
A 16 bit unsigned int.
Definition saveload.h:639
#define SLEG_STRUCTLIST(name, handler)
Storage of a list of structs in every savegame version.
Definition saveload.h:1236
#define SLE_CONDSSTRNAME(base, variable, name, type, from, to)
Storage of a std::string in some savegame versions.
Definition saveload.h:949
#define SLE_SSTRNAME(base, variable, name, type)
Storage of a std::string in every savegame version.
Definition saveload.h:1050
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
Definition saveload.h:1104
#define SLE_VARNAME(base, variable, name, type)
Storage of a variable in every version of a savegame.
Definition saveload.h:1006
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
Definition saveload.h:508
#define SLE_ARRNAME(base, variable, name, type, length)
Storage of fixed-size array of SaveLoadType::Variable elements in every version of a savegame.
Definition saveload.h:1033
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
Definition saveload.h:511
#define SLE_SAVEBYTE(base, variable)
Only write byte during saving; never read it during loading.
Definition saveload.h:1078
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
Definition saveload.h:514
#define SLEG_STRUCT(name, handler)
Storage of a structs in every savegame version.
Definition saveload.h:1213
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition saveload.h:884
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
Definition saveload.h:1258
@ StringGamelog
Saveload version: 314, GitHub pull request: 10801 Use std::string in gamelog.
Definition saveload.h:359
@ U64TickCounter
Saveload version: 300, GitHub pull request: 10035 Make tick counter 64bit to avoid wrapping.
Definition saveload.h:343
@ MinVersion
First savegame version.
Definition saveload.h:34
@ MaxVersion
Highest possible saveload version.
Definition saveload.h:424
@ RiffToArray
Saveload version: 294, GitHub pull request: 9375 Changed many ChunkType::Riff chunks to ChunkType::A...
Definition saveload.h:335
@ Table
An Array with a header describing the elements.
Definition saveload.h:445
Definition of base types and functions in a cross-platform compatible way.
static void StrMakeValid(Builder &builder, StringConsumer &consumer, StringValidationSettings settings)
Copies the valid (UTF-8) characters from consumer to the builder.
Definition string.cpp:119
Functions related to low-level strings.
ChunkType type
Type of the chunk.
Definition saveload.h:458
ChunkHandler(ChunkId id, ChunkType type)
Create this ChunkHandler.
Definition saveload.h:465
void LoadCheck(size_t) const override
Load the chunk for game preview.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
Contains information about one logged action that caused at least one logged change.
std::vector< std::unique_ptr< LoggedChange > > change
Logged changes in this action.
GamelogActionType at
Type of action.
A log entry for a NewGRF that was added.
A log entry for a NewGRF bug.
A log entry for a NewGRF that was changed.
A log entry for a NewGRF that was moved.
A log entry for a NewGRF for which a parameter was changed.
A log entry for a NewGRF that was removed.
Log element for the change of the game mode and landscape.
A log entry for loading a really old savegame.
A log entry for a change in OpenTTD version.
A log entry for changing a setting.
Container for any change that we deem needs to be logged.
GamelogChangeType ct
The type of change.
SaveLoad type struct.
Definition saveload.h:764
static constexpr VarType U16
Store a 16 bits unsigned int.
Definition saveload.h:729
static constexpr VarType U8
Store a 8 bits unsigned int.
Definition saveload.h:727
static constexpr VarType STR
Store string.
Definition saveload.h:735
static constexpr VarType LABEL_REVERSE
Store a Label in reverse.
Definition saveload.h:738
static constexpr VarType U64
Store a 64 bits unsigned int.
Definition saveload.h:733
static constexpr VarType U32
Store a 32 bits unsigned int.
Definition saveload.h:731
static constexpr VarType I32
Store a 32 bits signed int.
Definition saveload.h:730
static constexpr VarType BOOL
Store a boolean (as int8).
Definition saveload.h:725