OpenTTD Source: src/saveload/gamelog_sl.cpp Source File

OpenTTD Source 15.0-RC2

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
10#include "../stdafx.h"
11
12#include "saveload.h"
13#include "compat/gamelog_sl_compat.h"
14
15#include "../gamelog_internal.h"
16#include "../fios.h"
17#include "../string_func.h"
18
19#include "../safeguards.h"
20
21
22 class SlGamelogMode : public DefaultSaveLoadHandler<SlGamelogMode, LoggedChange> {
23public:
24 static inline const SaveLoad description[] = {
25 SLE_VARNAME(LoggedChangeMode, mode, "mode.mode", SLE_UINT8),
26 SLE_VARNAME(LoggedChangeMode, landscape, "mode.landscape", SLE_UINT8),
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 != GLCT_MODE) return;
33 SlObject(lc, this->GetDescription());
34 }
35
36 void Load(LoggedChange *lc) const override
37 {
38 if (lc->ct != GLCT_MODE) return;
39 SlObject(lc, this->GetLoadDescription());
40 }
41
42 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
43};
44
45 class SlGamelogRevision : public DefaultSaveLoadHandler<SlGamelogRevision, LoggedChange> {
46public:
47 static const size_t GAMELOG_REVISION_LENGTH = 15;
48 static char revision_text[GAMELOG_REVISION_LENGTH];
49
50 static inline const SaveLoad description[] = {
51 SLEG_CONDARR("revision.text", SlGamelogRevision::revision_text, SLE_UINT8, GAMELOG_REVISION_LENGTH, SL_MIN_VERSION, SLV_STRING_GAMELOG),
52 SLE_CONDSSTRNAME(LoggedChangeRevision, text, "revision.text", SLE_STR, SLV_STRING_GAMELOG, SL_MAX_VERSION),
53 SLE_VARNAME(LoggedChangeRevision, newgrf, "revision.newgrf", SLE_UINT32),
54 SLE_VARNAME(LoggedChangeRevision, slver, "revision.slver", SLE_UINT16),
55 SLE_VARNAME(LoggedChangeRevision, modified, "revision.modified", SLE_UINT8),
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 != GLCT_REVISION) return;
62 SlObject(lc, this->GetDescription());
63 }
64
65 void Load(LoggedChange *lc) const override
66 {
67 if (lc->ct != GLCT_REVISION) return;
68 SlObject(lc, this->GetLoadDescription());
69
70 if (IsSavegameVersionBefore(SLV_STRING_GAMELOG)) {
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
78/* static */ char SlGamelogRevision::revision_text[GAMELOG_REVISION_LENGTH];
79
80 class SlGamelogOldver : public DefaultSaveLoadHandler<SlGamelogOldver, LoggedChange> {
81public:
82 static inline const SaveLoad description[] = {
83 SLE_VARNAME(LoggedChangeOldVersion, type, "oldver.type", SLE_UINT32),
84 SLE_VARNAME(LoggedChangeOldVersion, version, "oldver.version", SLE_UINT32),
85 };
86 static inline const SaveLoadCompatTable compat_description = _gamelog_oldver_sl_compat;
87
88 void Save(LoggedChange *lc) const override
89 {
90 if (lc->ct != GLCT_OLDVER) return;
91 SlObject(lc, this->GetDescription());
92 }
93
94 void Load(LoggedChange *lc) const override
95 {
96 if (lc->ct != GLCT_OLDVER) return;
97 SlObject(lc, this->GetLoadDescription());
98 }
99
100 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
101};
102
103 class SlGamelogSetting : public DefaultSaveLoadHandler<SlGamelogSetting, LoggedChange> {
104public:
105 static inline const SaveLoad description[] = {
106 SLE_SSTRNAME(LoggedChangeSettingChanged, name, "setting.name", SLE_STR),
107 SLE_VARNAME(LoggedChangeSettingChanged, oldval, "setting.oldval", SLE_INT32),
108 SLE_VARNAME(LoggedChangeSettingChanged, newval, "setting.newval", SLE_INT32),
109 };
110 static inline const SaveLoadCompatTable compat_description = _gamelog_setting_sl_compat;
111
112 void Save(LoggedChange *lc) const override
113 {
114 if (lc->ct != GLCT_SETTING) return;
115 SlObject(lc, this->GetDescription());
116 }
117
118 void Load(LoggedChange *lc) const override
119 {
120 if (lc->ct != GLCT_SETTING) return;
121 SlObject(lc, this->GetLoadDescription());
122 }
123
124 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
125};
126
127 class SlGamelogGrfadd : public DefaultSaveLoadHandler<SlGamelogGrfadd, LoggedChange> {
128public:
129 static inline const SaveLoad description[] = {
130 SLE_VARNAME(LoggedChangeGRFAdd, grfid, "grfadd.grfid", SLE_UINT32 ),
131 SLE_ARRNAME(LoggedChangeGRFAdd, md5sum, "grfadd.md5sum", SLE_UINT8, 16),
132 };
133 static inline const SaveLoadCompatTable compat_description = _gamelog_grfadd_sl_compat;
134
135 void Save(LoggedChange *lc) const override
136 {
137 if (lc->ct != GLCT_GRFADD) return;
138 SlObject(lc, this->GetDescription());
139 }
140
141 void Load(LoggedChange *lc) const override
142 {
143 if (lc->ct != GLCT_GRFADD) return;
144 SlObject(lc, this->GetLoadDescription());
145 }
146
147 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
148};
149
150 class SlGamelogGrfrem : public DefaultSaveLoadHandler<SlGamelogGrfrem, LoggedChange> {
151public:
152 static inline const SaveLoad description[] = {
153 SLE_VARNAME(LoggedChangeGRFRemoved, grfid, "grfrem.grfid", SLE_UINT32),
154 };
155 static inline const SaveLoadCompatTable compat_description = _gamelog_grfrem_sl_compat;
156
157 void Save(LoggedChange *lc) const override
158 {
159 if (lc->ct != GLCT_GRFREM) return;
160 SlObject(lc, this->GetDescription());
161 }
162
163 void Load(LoggedChange *lc) const override
164 {
165 if (lc->ct != GLCT_GRFREM) return;
166 SlObject(lc, this->GetLoadDescription());
167 }
168
169 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
170};
171
172 class SlGamelogGrfcompat : public DefaultSaveLoadHandler<SlGamelogGrfcompat, LoggedChange> {
173public:
174 static inline const SaveLoad description[] = {
175 SLE_VARNAME(LoggedChangeGRFChanged, grfid, "grfcompat.grfid", SLE_UINT32 ),
176 SLE_ARRNAME(LoggedChangeGRFChanged, md5sum, "grfcompat.md5sum", SLE_UINT8, 16),
177 };
178 static inline const SaveLoadCompatTable compat_description = _gamelog_grfcompat_sl_compat;
179
180 void Save(LoggedChange *lc) const override
181 {
182 if (lc->ct != GLCT_GRFCOMPAT) return;
183 SlObject(lc, this->GetDescription());
184 }
185
186 void Load(LoggedChange *lc) const override
187 {
188 if (lc->ct != GLCT_GRFCOMPAT) return;
189 SlObject(lc, this->GetLoadDescription());
190 }
191
192 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
193};
194
195 class SlGamelogGrfparam : public DefaultSaveLoadHandler<SlGamelogGrfparam, LoggedChange> {
196public:
197 static inline const SaveLoad description[] = {
198 SLE_VARNAME(LoggedChangeGRFParameterChanged, grfid, "grfparam.grfid", SLE_UINT32),
199 };
200 static inline const SaveLoadCompatTable compat_description = _gamelog_grfparam_sl_compat;
201
202 void Save(LoggedChange *lc) const override
203 {
204 if (lc->ct != GLCT_GRFPARAM) return;
205 SlObject(lc, this->GetDescription());
206 }
207
208 void Load(LoggedChange *lc) const override
209 {
210 if (lc->ct != GLCT_GRFPARAM) return;
211 SlObject(lc, this->GetLoadDescription());
212 }
213
214 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
215};
216
217 class SlGamelogGrfmove : public DefaultSaveLoadHandler<SlGamelogGrfmove, LoggedChange> {
218public:
219 static inline const SaveLoad description[] = {
220 SLE_VARNAME(LoggedChangeGRFMoved, grfid, "grfmove.grfid", SLE_UINT32),
221 SLE_VARNAME(LoggedChangeGRFMoved, offset, "grfmove.offset", SLE_INT32),
222 };
223 static inline const SaveLoadCompatTable compat_description = _gamelog_grfmove_sl_compat;
224
225 void Save(LoggedChange *lc) const override
226 {
227 if (lc->ct != GLCT_GRFMOVE) return;
228 SlObject(lc, this->GetDescription());
229 }
230
231 void Load(LoggedChange *lc) const override
232 {
233 if (lc->ct != GLCT_GRFMOVE) return;
234 SlObject(lc, this->GetLoadDescription());
235 }
236
237 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
238};
239
240 class SlGamelogGrfbug : public DefaultSaveLoadHandler<SlGamelogGrfbug, LoggedChange> {
241public:
242 static inline const SaveLoad description[] = {
243 SLE_VARNAME(LoggedChangeGRFBug, data, "grfbug.data", SLE_UINT64),
244 SLE_VARNAME(LoggedChangeGRFBug, grfid, "grfbug.grfid", SLE_UINT32),
245 SLE_VARNAME(LoggedChangeGRFBug, bug, "grfbug.bug", SLE_UINT8),
246 };
247 static inline const SaveLoadCompatTable compat_description = _gamelog_grfbug_sl_compat;
248
249 void Save(LoggedChange *lc) const override
250 {
251 if (lc->ct != GLCT_GRFBUG) return;
252 SlObject(lc, this->GetDescription());
253 }
254
255 void Load(LoggedChange *lc) const override
256 {
257 if (lc->ct != GLCT_GRFBUG) return;
258 SlObject(lc, this->GetLoadDescription());
259 }
260
261 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
262};
263
264static bool _is_emergency_save = true;
265
266 class SlGamelogEmergency : public DefaultSaveLoadHandler<SlGamelogEmergency, LoggedChange> {
267public:
268 /* We need to store something, so store a "true" value. */
269 static inline const SaveLoad description[] = {
270 SLEG_CONDVAR("is_emergency_save", _is_emergency_save, SLE_BOOL, SLV_RIFF_TO_ARRAY, SL_MAX_VERSION),
271 };
272 static inline const SaveLoadCompatTable compat_description = _gamelog_emergency_sl_compat;
273
274 void Save(LoggedChange *lc) const override
275 {
276 if (lc->ct != GLCT_EMERGENCY) return;
277
278 _is_emergency_save = true;
279 SlObject(lc, this->GetDescription());
280 }
281
282 void Load(LoggedChange *lc) const override
283 {
284 if (lc->ct != GLCT_EMERGENCY) return;
285
286 SlObject(lc, this->GetLoadDescription());
287 }
288
289 void LoadCheck(LoggedChange *lc) const override { this->Load(lc); }
290};
291
292static std::unique_ptr<LoggedChange> MakeLoggedChange(GamelogChangeType type)
293{
294 switch (type) {
295 case GLCT_MODE: return std::make_unique<LoggedChangeMode>();
296 case GLCT_REVISION: return std::make_unique<LoggedChangeRevision>();
297 case GLCT_OLDVER: return std::make_unique<LoggedChangeOldVersion>();
298 case GLCT_SETTING: return std::make_unique<LoggedChangeSettingChanged>();
299 case GLCT_GRFADD: return std::make_unique<LoggedChangeGRFAdd>();
300 case GLCT_GRFREM: return std::make_unique<LoggedChangeGRFRemoved>();
301 case GLCT_GRFCOMPAT: return std::make_unique<LoggedChangeGRFChanged>();
302 case GLCT_GRFPARAM: return std::make_unique<LoggedChangeGRFParameterChanged>();
303 case GLCT_GRFMOVE: return std::make_unique<LoggedChangeGRFMoved>();
304 case GLCT_GRFBUG: return std::make_unique<LoggedChangeGRFBug>();
305 case GLCT_EMERGENCY: return std::make_unique<LoggedChangeEmergencySave>();
306 case GLCT_END:
307 case GLCT_NONE:
308 default:
309 SlErrorCorrupt("Invalid gamelog action type");
310 }
311}
312
313 class SlGamelogAction : public DefaultSaveLoadHandler<SlGamelogAction, LoggedAction> {
314public:
315 static inline const SaveLoad description[] = {
316 SLE_SAVEBYTE(LoggedChange, ct),
317 SLEG_STRUCT("mode", SlGamelogMode),
318 SLEG_STRUCT("revision", SlGamelogRevision),
319 SLEG_STRUCT("oldver", SlGamelogOldver),
320 SLEG_STRUCT("setting", SlGamelogSetting),
321 SLEG_STRUCT("grfadd", SlGamelogGrfadd),
322 SLEG_STRUCT("grfrem", SlGamelogGrfrem),
323 SLEG_STRUCT("grfcompat", SlGamelogGrfcompat),
324 SLEG_STRUCT("grfparam", SlGamelogGrfparam),
325 SLEG_STRUCT("grfmove", SlGamelogGrfmove),
326 SLEG_STRUCT("grfbug", SlGamelogGrfbug),
327 SLEG_STRUCT("emergency", SlGamelogEmergency),
328 };
329 static inline const SaveLoadCompatTable compat_description = _gamelog_action_sl_compat;
330
331 void Save(LoggedAction *la) const override
332 {
333 SlSetStructListLength(la->change.size());
334
335 for (auto &lc : la->change) {
336 assert(lc->ct < GLCT_END);
337 SlObject(lc.get(), this->GetDescription());
338 }
339 }
340
341 void LoadChange(LoggedAction *la, GamelogChangeType type) const
342 {
343 std::unique_ptr<LoggedChange> lc = MakeLoggedChange(type);
344 SlObject(lc.get(), this->GetLoadDescription());
345 la->change.push_back(std::move(lc));
346 }
347
348 void Load(LoggedAction *la) const override
349 {
350 if (IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY)) {
351 uint8_t type;
352 while ((type = SlReadByte()) != GLCT_NONE) {
353 if (type >= GLCT_END) SlErrorCorrupt("Invalid gamelog change type");
354 LoadChange(la, (GamelogChangeType)type);
355 }
356 return;
357 }
358
359 size_t length = SlGetStructListLength(UINT32_MAX);
360 la->change.reserve(length);
361
362 for (size_t i = 0; i < length; i++) {
363 LoadChange(la, (GamelogChangeType)SlReadByte());
364 }
365 }
366
367 void LoadCheck(LoggedAction *la) const override { this->Load(la); }
368};
369
370static const SaveLoad _gamelog_desc[] = {
371 SLE_CONDVAR(LoggedAction, at, SLE_UINT8, SLV_RIFF_TO_ARRAY, SL_MAX_VERSION),
372 SLE_CONDVAR(LoggedAction, tick, SLE_FILE_U16 | SLE_VAR_U64, SL_MIN_VERSION, SLV_U64_TICK_COUNTER),
373 SLE_CONDVAR(LoggedAction, tick, SLE_UINT64, SLV_U64_TICK_COUNTER, SL_MAX_VERSION),
374 SLEG_STRUCTLIST("action", SlGamelogAction),
375};
376
377 struct GLOGChunkHandler : ChunkHandler {
378 GLOGChunkHandler() : ChunkHandler('GLOG', CH_TABLE) {}
379
380 void LoadCommon(Gamelog &gamelog) const
381 {
382 assert(gamelog.data->action.empty());
383
384 const std::vector<SaveLoad> slt = SlCompatTableHeader(_gamelog_desc, _gamelog_sl_compat);
385
386 if (IsSavegameVersionBefore(SLV_RIFF_TO_ARRAY)) {
387 uint8_t type;
388 while ((type = SlReadByte()) != GLAT_NONE) {
389 if (type >= GLAT_END) SlErrorCorrupt("Invalid gamelog action type");
390
391 LoggedAction &la = gamelog.data->action.emplace_back();
392 la.at = (GamelogActionType)type;
393 SlObject(&la, slt);
394 }
395 return;
396 }
397
398 while (SlIterateArray() != -1) {
399 LoggedAction &la = gamelog.data->action.emplace_back();
400 SlObject(&la, slt);
401 }
402 }
403
404 void Save() const override
405 {
406 SlTableHeader(_gamelog_desc);
407
408 uint i = 0;
409 for (LoggedAction &la : _gamelog.data->action) {
410 SlSetArrayIndex(i++);
411 SlObject(&la, _gamelog_desc);
412 }
413 }
414
415 void Load() const override
416 {
417 this->LoadCommon(_gamelog);
418 }
419
420 void LoadCheck(size_t) const override
421 {
422 this->LoadCommon(_load_check_data.gamelog);
423 }
424};
425
426static const GLOGChunkHandler GLOG;
427static const ChunkHandlerRef gamelog_chunk_handlers[] = {
428 GLOG,
429};
430
431extern const ChunkHandlerTable _gamelog_chunk_handlers(gamelog_chunk_handlers);
DefaultSaveLoadHandler
Default handler for saving/loading an object to/from disk.
Definition saveload.h:596
DefaultSaveLoadHandler< SlGamelogMode, LoggedChange >::GetDescription
SaveLoadTable GetDescription() const override
Definition saveload.h:598
Gamelog
Definition gamelog.h:49
SaveLoadHandler::GetLoadDescription
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
Definition saveload.cpp:3444
SlGamelogAction
Definition gamelog_sl.cpp:313
SlGamelogEmergency
Definition gamelog_sl.cpp:266
SlGamelogGrfadd
Definition gamelog_sl.cpp:127
SlGamelogGrfbug
Definition gamelog_sl.cpp:240
SlGamelogGrfcompat
Definition gamelog_sl.cpp:172
SlGamelogGrfmove
Definition gamelog_sl.cpp:217
SlGamelogGrfparam
Definition gamelog_sl.cpp:195
SlGamelogGrfrem
Definition gamelog_sl.cpp:150
SlGamelogMode
Definition gamelog_sl.cpp:22
SlGamelogOldver
Definition gamelog_sl.cpp:80
SlGamelogRevision
Definition gamelog_sl.cpp:45
SlGamelogSetting
Definition gamelog_sl.cpp:103
_load_check_data
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
Definition fios_gui.cpp:41
_gamelog
Gamelog _gamelog
Gamelog instance.
Definition gamelog.cpp:31
GamelogChangeType
GamelogChangeType
Type of logged change.
Definition gamelog.h:29
GLCT_MODE
@ GLCT_MODE
Scenario editor x Game, different landscape.
Definition gamelog.h:30
GLCT_OLDVER
@ GLCT_OLDVER
Loaded from savegame without logged data.
Definition gamelog.h:32
GLCT_SETTING
@ GLCT_SETTING
Non-networksafe setting value changed.
Definition gamelog.h:33
GLCT_GRFCOMPAT
@ GLCT_GRFCOMPAT
Loading compatible GRF.
Definition gamelog.h:36
GLCT_GRFADD
@ GLCT_GRFADD
Removed GRF.
Definition gamelog.h:34
GLCT_END
@ GLCT_END
So we know how many GLCTs are there.
Definition gamelog.h:41
GLCT_EMERGENCY
@ GLCT_EMERGENCY
Emergency savegame.
Definition gamelog.h:40
GLCT_GRFPARAM
@ GLCT_GRFPARAM
GRF parameter changed.
Definition gamelog.h:37
GLCT_GRFMOVE
@ GLCT_GRFMOVE
GRF order changed.
Definition gamelog.h:38
GLCT_GRFREM
@ GLCT_GRFREM
Added GRF.
Definition gamelog.h:35
GLCT_GRFBUG
@ GLCT_GRFBUG
GRF bug triggered.
Definition gamelog.h:39
GLCT_REVISION
@ GLCT_REVISION
Changed game revision string.
Definition gamelog.h:31
GLCT_NONE
@ GLCT_NONE
In savegames, end of list.
Definition gamelog.h:42
GamelogActionType
GamelogActionType
The actions we log.
Definition gamelog.h:16
GLAT_NONE
@ GLAT_NONE
No logging active; in savegames, end of list.
Definition gamelog.h:25
GLAT_END
@ GLAT_END
So we know how many GLATs are there.
Definition gamelog.h:24
gamelog_sl_compat.h
Loading for gamelog chunks before table headers were added.
_gamelog_emergency_sl_compat
const SaveLoadCompat _gamelog_emergency_sl_compat[]
Original field order for SlGamelogEmergency.
Definition gamelog_sl_compat.h:78
_gamelog_mode_sl_compat
const SaveLoadCompat _gamelog_mode_sl_compat[]
Original field order for SlGamelogMode.
Definition gamelog_sl_compat.h:16
_gamelog_grfmove_sl_compat
const SaveLoadCompat _gamelog_grfmove_sl_compat[]
Original field order for SlGamelogGrfmove.
Definition gamelog_sl_compat.h:65
_gamelog_action_sl_compat
const SaveLoadCompat _gamelog_action_sl_compat[]
Original field order for SlGamelogAction.
Definition gamelog_sl_compat.h:83
_gamelog_oldver_sl_compat
const SaveLoadCompat _gamelog_oldver_sl_compat[]
Original field order for SlGamelogOldver.
Definition gamelog_sl_compat.h:30
_gamelog_revision_sl_compat
const SaveLoadCompat _gamelog_revision_sl_compat[]
Original field order for SlGamelogRevision.
Definition gamelog_sl_compat.h:22
_gamelog_sl_compat
const SaveLoadCompat _gamelog_sl_compat[]
Original field order for _gamelog_desc.
Definition gamelog_sl_compat.h:99
_gamelog_setting_sl_compat
const SaveLoadCompat _gamelog_setting_sl_compat[]
Original field order for SlGamelogSetting.
Definition gamelog_sl_compat.h:36
_gamelog_grfrem_sl_compat
const SaveLoadCompat _gamelog_grfrem_sl_compat[]
Original field order for SlGamelogGrfrem.
Definition gamelog_sl_compat.h:49
_gamelog_grfbug_sl_compat
const SaveLoadCompat _gamelog_grfbug_sl_compat[]
Original field order for SlGamelogGrfbug.
Definition gamelog_sl_compat.h:71
_gamelog_grfadd_sl_compat
const SaveLoadCompat _gamelog_grfadd_sl_compat[]
Original field order for SlGamelogGrfadd.
Definition gamelog_sl_compat.h:43
_gamelog_grfcompat_sl_compat
const SaveLoadCompat _gamelog_grfcompat_sl_compat[]
Original field order for SlGamelogGrfcompat.
Definition gamelog_sl_compat.h:54
_gamelog_grfparam_sl_compat
const SaveLoadCompat _gamelog_grfparam_sl_compat[]
Original field order for SlGamelogGrfparam.
Definition gamelog_sl_compat.h:60
SlCompatTableHeader
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
Definition saveload.cpp:2037
SlGetStructListLength
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
Definition saveload.cpp:1833
SlIterateArray
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition saveload.cpp:677
SlErrorCorrupt
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
Definition saveload.cpp:369
SlReadByte
uint8_t SlReadByte()
Wrapper for reading a byte from the buffer.
Definition saveload.cpp:410
SlObject
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
Definition saveload.cpp:1846
SlTableHeader
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
Definition saveload.cpp:1899
SlSetStructListLength
void SlSetStructListLength(size_t length)
Set the length of this list.
Definition saveload.cpp:1817
saveload.h
Functions/types related to saving and loading games.
SLEG_CONDARR
#define SLEG_CONDARR(name, variable, type, length, from, to)
Storage of a global fixed-size array of SL_VAR elements in some savegame versions.
Definition saveload.h:1145
SLEG_STRUCTLIST
#define SLEG_STRUCTLIST(name, handler)
Storage of a list of structs in every savegame version.
Definition saveload.h:1256
SLE_CONDSSTRNAME
#define SLE_CONDSSTRNAME(base, variable, name, type, from, to)
Storage of a std::string in some savegame versions.
Definition saveload.h:959
SLE_SSTRNAME
#define SLE_SSTRNAME(base, variable, name, type)
Storage of a std::string in every savegame version.
Definition saveload.h:1070
SLEG_CONDVAR
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
Definition saveload.h:1124
SLE_VARNAME
#define SLE_VARNAME(base, variable, name, type)
Storage of a variable in every version of a savegame.
Definition saveload.h:1026
ChunkHandlerRef
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
Definition saveload.h:524
SLE_ARRNAME
#define SLE_ARRNAME(base, variable, name, type, length)
Storage of fixed-size array of SL_VAR elements in every version of a savegame.
Definition saveload.h:1053
ChunkHandlerTable
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
Definition saveload.h:527
SLE_SAVEBYTE
#define SLE_SAVEBYTE(base, variable)
Only write byte during saving; never read it during loading.
Definition saveload.h:1098
SaveLoadCompatTable
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
Definition saveload.h:533
SLEG_STRUCT
#define SLEG_STRUCT(name, handler)
Storage of a structs in every savegame version.
Definition saveload.h:1233
SLE_CONDVAR
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition saveload.h:883
IsSavegameVersionBefore
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
Definition saveload.h:1278
SLV_RIFF_TO_ARRAY
@ SLV_RIFF_TO_ARRAY
294 PR#9375 Changed many CH_RIFF chunks to CH_ARRAY chunks.
Definition saveload.h:332
SL_MAX_VERSION
@ SL_MAX_VERSION
Highest possible saveload version.
Definition saveload.h:416
SL_MIN_VERSION
@ SL_MIN_VERSION
First savegame version.
Definition saveload.h:31
SLV_STRING_GAMELOG
@ SLV_STRING_GAMELOG
314 PR#10801 Use std::string in gamelog.
Definition saveload.h:356
SLV_U64_TICK_COUNTER
@ SLV_U64_TICK_COUNTER
300 PR#10035 Make tick counter 64bit to avoid wrapping.
Definition saveload.h:340
StrMakeValid
static void StrMakeValid(Builder &builder, StringConsumer &consumer, StringValidationSettings settings)
Copies the valid (UTF-8) characters from consumer to the builder.
Definition string.cpp:119
ChunkHandler
Handlers and description of chunk.
Definition saveload.h:478
ChunkHandler::type
ChunkType type
Type of the chunk.
Definition saveload.h:480
GLOGChunkHandler
Definition gamelog_sl.cpp:377
GLOGChunkHandler::LoadCheck
void LoadCheck(size_t) const override
Load the chunk for game preview.
Definition gamelog_sl.cpp:420
GLOGChunkHandler::Save
void Save() const override
Save the chunk.
Definition gamelog_sl.cpp:404
GLOGChunkHandler::Load
void Load() const override
Load the chunk.
Definition gamelog_sl.cpp:415
LoadCheckData::gamelog
Gamelog gamelog
Gamelog actions.
Definition fios.h:50
LoggedAction
Contains information about one logged action that caused at least one logged change.
Definition gamelog_internal.h:143
LoggedAction::change
std::vector< std::unique_ptr< LoggedChange > > change
Logged changes in this action.
Definition gamelog_internal.h:144
LoggedAction::at
GamelogActionType at
Type of action.
Definition gamelog_internal.h:145
LoggedChangeGRFAdd
Definition gamelog_internal.h:72
LoggedChangeGRFBug
Definition gamelog_internal.h:125
LoggedChangeGRFChanged
Definition gamelog_internal.h:88
LoggedChangeGRFMoved
Definition gamelog_internal.h:104
LoggedChangeGRFParameterChanged
Definition gamelog_internal.h:95
LoggedChangeGRFRemoved
Definition gamelog_internal.h:79
LoggedChangeMode
Definition gamelog_internal.h:40
LoggedChangeOldVersion
Definition gamelog_internal.h:62
LoggedChangeRevision
Definition gamelog_internal.h:50
LoggedChangeSettingChanged
Definition gamelog_internal.h:114
LoggedChange
Definition gamelog_internal.h:32
SaveLoad
SaveLoad type struct.
Definition saveload.h:732