OpenTTD
saveload.h
Go to the documentation of this file.
1 /* $Id$ */
2 
3 /*
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/>.
8  */
9 
12 #ifndef SAVELOAD_H
13 #define SAVELOAD_H
14 
15 #include "../fileio_type.h"
16 #include "../strings_type.h"
17 
31 enum SaveLoadVersion : uint16 {
33 
52 
59 
67 
73 
79 
85 
91 
97 
103 
109 
115 
121 
127 
133 
139 
145 
151 
157 
163 
169 
175 
181 
187 
193 
199 
205 
211 
217 
223 
229 
235 
241 
247 
253 
259 
265 
271 
274  SLV_192,
278 
284 
290 
296 
302 
306 
308 };
309 
312  SL_OK = 0,
313  SL_ERROR = 1,
314  SL_REINIT = 2,
315 };
316 
322  char name[MAX_PATH];
323  char title[255];
324 
325  void SetMode(FiosType ft);
327  void SetName(const char *name);
328  void SetTitle(const char *title);
329 };
330 
338  SGT_INVALID = 0xFF,
339 };
340 
342 
343 void GenerateDefaultSaveName(char *buf, const char *last);
344 void SetSaveLoadError(StringID str);
345 const char *GetSaveLoadErrorString();
346 SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded = true);
347 void WaitTillSaved();
349 void DoExitSave();
350 
351 SaveOrLoadResult SaveWithFilter(struct SaveFilter *writer, bool threaded);
353 
354 typedef void ChunkSaveLoadProc();
355 typedef void AutolengthProc(void *arg);
356 
358 struct ChunkHandler {
359  uint32 id;
360  ChunkSaveLoadProc *save_proc;
361  ChunkSaveLoadProc *load_proc;
362  ChunkSaveLoadProc *ptrs_proc;
363  ChunkSaveLoadProc *load_check_proc;
364  uint32 flags;
365 };
366 
367 struct NullStruct {
368  byte null;
369 };
370 
372 enum SLRefType {
373  REF_ORDER = 0,
376  REF_TOWN = 3,
385 };
386 
388 enum ChunkType {
389  CH_RIFF = 0,
390  CH_ARRAY = 1,
391  CH_SPARSE_ARRAY = 2,
392  CH_TYPE_MASK = 3,
393  CH_LAST = 8,
394  CH_AUTO_LENGTH = 16,
395 };
396 
405 enum VarTypes {
406  /* 4 bits allocated a maximum of 16 types for NumberType */
407  SLE_FILE_I8 = 0,
408  SLE_FILE_U8 = 1,
409  SLE_FILE_I16 = 2,
410  SLE_FILE_U16 = 3,
411  SLE_FILE_I32 = 4,
412  SLE_FILE_U32 = 5,
413  SLE_FILE_I64 = 6,
414  SLE_FILE_U64 = 7,
416  SLE_FILE_STRING = 9,
417  /* 6 more possible file-primitives */
418 
419  /* 4 bits allocated a maximum of 16 types for NumberType */
420  SLE_VAR_BL = 0 << 4,
421  SLE_VAR_I8 = 1 << 4,
422  SLE_VAR_U8 = 2 << 4,
423  SLE_VAR_I16 = 3 << 4,
424  SLE_VAR_U16 = 4 << 4,
425  SLE_VAR_I32 = 5 << 4,
426  SLE_VAR_U32 = 6 << 4,
427  SLE_VAR_I64 = 7 << 4,
428  SLE_VAR_U64 = 8 << 4,
429  SLE_VAR_NULL = 9 << 4,
430  SLE_VAR_STRB = 10 << 4,
431  SLE_VAR_STRBQ = 11 << 4,
432  SLE_VAR_STR = 12 << 4,
433  SLE_VAR_STRQ = 13 << 4,
434  SLE_VAR_NAME = 14 << 4,
435  /* 1 more possible memory-primitives */
436 
437  /* Shortcut values */
438  SLE_VAR_CHAR = SLE_VAR_I8,
439 
440  /* Default combinations of variables. As savegames change, so can variables
441  * and thus it is possible that the saved value and internal size do not
442  * match and you need to specify custom combo. The defaults are listed here */
443  SLE_BOOL = SLE_FILE_I8 | SLE_VAR_BL,
444  SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8,
445  SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8,
446  SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16,
447  SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16,
448  SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32,
449  SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32,
450  SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64,
451  SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64,
452  SLE_CHAR = SLE_FILE_I8 | SLE_VAR_CHAR,
453  SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U32,
454  SLE_STRINGBUF = SLE_FILE_STRING | SLE_VAR_STRB,
455  SLE_STRINGBQUOTE = SLE_FILE_STRING | SLE_VAR_STRBQ,
456  SLE_STRING = SLE_FILE_STRING | SLE_VAR_STR,
457  SLE_STRINGQUOTE = SLE_FILE_STRING | SLE_VAR_STRQ,
458  SLE_NAME = SLE_FILE_STRINGID | SLE_VAR_NAME,
459 
460  /* Shortcut values */
461  SLE_UINT = SLE_UINT32,
462  SLE_INT = SLE_INT32,
463  SLE_STRB = SLE_STRINGBUF,
464  SLE_STRBQ = SLE_STRINGBQUOTE,
465  SLE_STR = SLE_STRING,
466  SLE_STRQ = SLE_STRINGQUOTE,
467 
468  /* 8 bits allocated for a maximum of 8 flags
469  * Flags directing saving/loading of a variable */
470  SLF_NOT_IN_SAVE = 1 << 8,
471  SLF_NOT_IN_CONFIG = 1 << 9,
473  SLF_ALLOW_CONTROL = 1 << 11,
474  SLF_ALLOW_NEWLINE = 1 << 12,
475  /* 3 more possible flags */
476 };
477 
478 typedef uint32 VarType;
479 
482  SL_VAR = 0,
483  SL_REF = 1,
484  SL_ARR = 2,
485  SL_STR = 3,
486  SL_LST = 4,
487  SL_DEQUE = 5,
488  /* non-normal save-load types */
489  SL_WRITEBYTE = 8,
490  SL_VEH_INCLUDE = 9,
491  SL_ST_INCLUDE = 10,
492  SL_END = 15
493 };
494 
495 typedef byte SaveLoadType;
496 
498 struct SaveLoad {
499  bool global;
501  VarType conv;
502  uint16 length;
505  /* NOTE: This element either denotes the address of the variable for a global
506  * variable, or the offset within a struct which is then bound to a variable
507  * during runtime. Decision on which one to use is controlled by the function
508  * that is called to save it. address: global=true, offset: global=false */
509  void *address;
510  size_t size;
511 };
512 
515 
526 #define SLE_GENERAL(cmd, base, variable, type, length, from, to) {false, cmd, type, length, from, to, (void*)cpp_offsetof(base, variable), cpp_sizeof(base, variable)}
527 
536 #define SLE_CONDVAR(base, variable, type, from, to) SLE_GENERAL(SL_VAR, base, variable, type, 0, from, to)
537 
546 #define SLE_CONDREF(base, variable, type, from, to) SLE_GENERAL(SL_REF, base, variable, type, 0, from, to)
547 
557 #define SLE_CONDARR(base, variable, type, length, from, to) SLE_GENERAL(SL_ARR, base, variable, type, length, from, to)
558 
568 #define SLE_CONDSTR(base, variable, type, length, from, to) SLE_GENERAL(SL_STR, base, variable, type, length, from, to)
569 
578 #define SLE_CONDLST(base, variable, type, from, to) SLE_GENERAL(SL_LST, base, variable, type, 0, from, to)
579 
588 #define SLE_CONDDEQUE(base, variable, type, from, to) SLE_GENERAL(SL_DEQUE, base, variable, type, 0, from, to)
589 
596 #define SLE_VAR(base, variable, type) SLE_CONDVAR(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
597 
604 #define SLE_REF(base, variable, type) SLE_CONDREF(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
605 
613 #define SLE_ARR(base, variable, type, length) SLE_CONDARR(base, variable, type, length, SL_MIN_VERSION, SL_MAX_VERSION)
614 
622 #define SLE_STR(base, variable, type, length) SLE_CONDSTR(base, variable, type, length, SL_MIN_VERSION, SL_MAX_VERSION)
623 
630 #define SLE_LST(base, variable, type) SLE_CONDLST(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
631 
636 #define SLE_NULL(length) SLE_CONDNULL(length, SL_MIN_VERSION, SL_MAX_VERSION)
637 
644 #define SLE_CONDNULL(length, from, to) SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to)
645 
647 #define SLE_WRITEBYTE(base, variable) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION)
648 
649 #define SLE_VEH_INCLUDE() {false, SL_VEH_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0}
650 #define SLE_ST_INCLUDE() {false, SL_ST_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, nullptr, 0}
651 
653 #define SLE_END() {false, SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, nullptr, 0}
654 
664 #define SLEG_GENERAL(cmd, variable, type, length, from, to) {true, cmd, type, length, from, to, (void*)&variable, sizeof(variable)}
665 
673 #define SLEG_CONDVAR(variable, type, from, to) SLEG_GENERAL(SL_VAR, variable, type, 0, from, to)
674 
682 #define SLEG_CONDREF(variable, type, from, to) SLEG_GENERAL(SL_REF, variable, type, 0, from, to)
683 
692 #define SLEG_CONDARR(variable, type, length, from, to) SLEG_GENERAL(SL_ARR, variable, type, length, from, to)
693 
702 #define SLEG_CONDSTR(variable, type, length, from, to) SLEG_GENERAL(SL_STR, variable, type, length, from, to)
703 
711 #define SLEG_CONDLST(variable, type, from, to) SLEG_GENERAL(SL_LST, variable, type, 0, from, to)
712 
718 #define SLEG_VAR(variable, type) SLEG_CONDVAR(variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
719 
725 #define SLEG_REF(variable, type) SLEG_CONDREF(variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
726 
732 #define SLEG_ARR(variable, type) SLEG_CONDARR(variable, type, lengthof(variable), SL_MIN_VERSION, SL_MAX_VERSION)
733 
739 #define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, sizeof(variable), SL_MIN_VERSION, SL_MAX_VERSION)
740 
746 #define SLEG_LST(variable, type) SLEG_CONDLST(variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
747 
754 #define SLEG_CONDNULL(length, from, to) {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, (void*)nullptr}
755 
757 #define SLEG_END() {true, SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, nullptr, 0}
758 
765 static inline bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor = 0)
766 {
768  extern byte _sl_minor_version;
769  return _sl_version < major || (minor > 0 && _sl_version == major && _sl_minor_version < minor);
770 }
771 
779 static inline bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
780 {
781  extern const SaveLoadVersion SAVEGAME_VERSION;
782  if (SAVEGAME_VERSION < version_from || SAVEGAME_VERSION >= version_to) return false;
783 
784  return true;
785 }
786 
793 static inline VarType GetVarMemType(VarType type)
794 {
795  return type & 0xF0; // GB(type, 4, 4) << 4;
796 }
797 
804 static inline VarType GetVarFileType(VarType type)
805 {
806  return type & 0xF; // GB(type, 0, 4);
807 }
808 
814 static inline bool IsNumericType(VarType conv)
815 {
816  return GetVarMemType(conv) <= SLE_VAR_U64;
817 }
818 
825 static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
826 {
827  return const_cast<byte *>((const byte*)(sld->global ? nullptr : object) + (ptrdiff_t)sld->address);
828 }
829 
830 int64 ReadValue(const void *ptr, VarType conv);
831 void WriteValue(void *ptr, VarType conv, int64 val);
832 
833 void SlSetArrayIndex(uint index);
834 int SlIterateArray();
835 
836 void SlAutolength(AutolengthProc *proc, void *arg);
837 size_t SlGetFieldLength();
838 void SlSetLength(size_t length);
839 size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld);
840 size_t SlCalcObjLength(const void *object, const SaveLoad *sld);
841 
842 byte SlReadByte();
843 void SlWriteByte(byte b);
844 
845 void SlGlobList(const SaveLoadGlobVarList *sldg);
846 void SlArray(void *array, size_t length, VarType conv);
847 void SlObject(void *object, const SaveLoad *sld);
848 bool SlObjectMember(void *object, const SaveLoad *sld);
849 void NORETURN SlError(StringID string, const char *extra_msg = nullptr);
850 void NORETURN SlErrorCorrupt(const char *msg);
851 void NORETURN SlErrorCorruptFmt(const char *format, ...);
852 
854 
855 extern char _savegame_format[8];
856 extern bool _do_autosave;
857 
858 #endif /* SAVELOAD_H */
void ProcessAsyncSaveFinish()
Handle async save finishes.
Definition: saveload.cpp:400
FiosType
Elements of a file system that are recognized.
Definition: fileio_type.h:69
AbstractFileType
The different abstract types of files that the system knows about.
Definition: fileio_type.h:18
179 24810
Definition: saveload.h:258
193 26802
Definition: saveload.h:276
141 19799
Definition: saveload.h:213
127 17439
Definition: saveload.h:196
void SetSaveLoadError(StringID str)
Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friend...
Definition: saveload.cpp:2426
106 14919
Definition: saveload.h:171
44 8144
Definition: saveload.h:96
void SlGlobList(const SaveLoadGlobVarList *sldg)
Save or Load (a list of) global variables.
Definition: saveload.cpp:1566
149 20832
Definition: saveload.h:222
char _savegame_format[8]
how to compress savegames
Definition: saveload.cpp:65
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
Definition: saveload.h:765
129 18292
Definition: saveload.h:198
77 11172
Definition: saveload.h:136
Save/load a deque.
Definition: saveload.h:487
18 3227
Definition: saveload.h:65
117 16037
Definition: saveload.h:184
70 10541
Definition: saveload.h:128
size_t SlGetFieldLength()
Get the length of the current object.
Definition: saveload.cpp:745
12.1 2046
Definition: saveload.h:56
SaveLoadVersion version_from
save/load the variable starting from this savegame version
Definition: saveload.h:503
76 11139
Definition: saveload.h:135
204 PR#7065 Add extra rotation stages for ships.
Definition: saveload.h:289
79 11188
Definition: saveload.h:138
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition: fileio_type.h:110
135 18719
Definition: saveload.h:206
52 9066
Definition: saveload.h:106
151 20918
Definition: saveload.h:225
2.0 0.3.0 2.1 0.3.1, 0.3.2
Definition: saveload.h:35
61 9892
Definition: saveload.h:117
SaveLoadVersion
SaveLoad versions Previous savegame versions, the trunk revision where they were introduced and the r...
Definition: saveload.h:31
102 14332
Definition: saveload.h:166
157 21862
Definition: saveload.h:232
string (with pre-allocated buffer)
Definition: saveload.h:430
uint32 flags
Flags of the chunk.
Definition: saveload.h:364
void SetName(const char *name)
Set the name of the file.
Definition: saveload.cpp:2877
107 15027
Definition: saveload.h:172
108 15045
Definition: saveload.h:173
98 13375
Definition: saveload.h:161
void NORETURN SlErrorCorrupt(const char *msg)
Error handler for corrupt savegames.
Definition: saveload.cpp:356
51 8978
Definition: saveload.h:105
SaveLoadTypes
Type of data saved.
Definition: saveload.h:481
87 12129
Definition: saveload.h:148
VarTypes
VarTypes is the general bitmasked magic type that tells us certain characteristics about the variable...
Definition: saveload.h:405
26 4466
Definition: saveload.h:75
do not synchronize over network (but it is saved if SLF_NOT_IN_SAVE is not set)
Definition: saveload.h:472
97 13256
Definition: saveload.h:160
120 16439
Definition: saveload.h:188
210 PR#7234 Company stations can serve industries with attached neutral stations. ...
Definition: saveload.h:297
185 25620 Storybooks
Definition: saveload.h:266
uint32 id
Unique ID (4 letters).
Definition: saveload.h:359
103 14598
Definition: saveload.h:167
SaveOrLoadResult SaveWithFilter(struct SaveFilter *writer, bool threaded)
Save the game using a (writer) filter.
Definition: saveload.cpp:2544
145 20376
Definition: saveload.h:218
16.0 2817 16.1 3155
Definition: saveload.h:61
104 14735
Definition: saveload.h:168
71 10567
Definition: saveload.h:129
SaveLoadVersion _sl_version
the major savegame version identifier
Definition: saveload.cpp:63
char title[255]
Internal name of the game.
Definition: saveload.h:323
SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded=true)
Main Save or Load function where the high-level saveload functions are handled.
Definition: saveload.cpp:2719
25 4259
Definition: saveload.h:74
47 8735
Definition: saveload.h:100
121 16694
Definition: saveload.h:189
188 26169 v1.4 FS#5831 Unify RV travel time
Definition: saveload.h:269
85 11874
Definition: saveload.h:146
125 17113
Definition: saveload.h:194
113 15340
Definition: saveload.h:179
110 15148
Definition: saveload.h:176
37 7182
Definition: saveload.h:88
Load/save a reference to a link graph job.
Definition: saveload.h:384
175 24136
Definition: saveload.h:254
Load/save an old-style reference to a vehicle (for pre-4.4 savegames).
Definition: saveload.h:377
191 26636 FS#6026 Fix disaster vehicle storage (No bump) 191 26646 FS#6041 Linkgraph - store location...
Definition: saveload.h:273
void * address
address of variable OR offset of variable in the struct (max offset is 65536)
Definition: saveload.h:509
42 7573
Definition: saveload.h:94
118 16129
Definition: saveload.h:185
TTD savegame (can be detected incorrectly)
Definition: saveload.h:333
82 11410
Definition: saveload.h:142
101 14233
Definition: saveload.h:165
119 16242
Definition: saveload.h:186
114 15601
Definition: saveload.h:180
do not save to config file
Definition: saveload.h:471
13.1 2080 0.4.0, 0.4.0.1
Definition: saveload.h:57
void NORETURN SlErrorCorruptFmt(const char *format,...)
Issue an SlErrorCorrupt with a format string.
Definition: saveload.cpp:368
28 4987
Definition: saveload.h:77
Load/save a reference to a town.
Definition: saveload.h:376
105 14803
Definition: saveload.h:170
165 23304
Definition: saveload.h:242
SavegameType
Types of save games.
Definition: saveload.h:332
11.0 2033 11.1 2041
Definition: saveload.h:54
170 23826
Definition: saveload.h:248
134 18703
Definition: saveload.h:204
void WriteValue(void *ptr, VarType conv, int64 val)
Write the value of a setting.
Definition: saveload.cpp:781
int64 ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Definition: saveload.cpp:757
Deals with the type of the savegame, independent of extension.
Definition: saveload.h:318
size_t size
the sizeof size.
Definition: saveload.h:510
17.0 3212 17.1 3218
Definition: saveload.h:63
137 18912
Definition: saveload.h:208
59 9779
Definition: saveload.h:114
206 PR#7150 Ship/lock movement changes.
Definition: saveload.h:292
162 22713
Definition: saveload.h:238
void SlArray(void *array, size_t length, VarType conv)
Save/Load an array.
Definition: saveload.cpp:997
48 8935
Definition: saveload.h:101
96 13226
Definition: saveload.h:159
58 9762
Definition: saveload.h:113
15.0 2499
Definition: saveload.h:60
24 4150
Definition: saveload.h:72
57 9691
Definition: saveload.h:112
217 PR#7780 Configurable company trading age.
Definition: saveload.h:305
Save/load a reference.
Definition: saveload.h:483
72 10601
Definition: saveload.h:130
void SlAutolength(AutolengthProc *proc, void *arg)
Do something of which I have no idea what it is :P.
Definition: saveload.cpp:1576
21 3472 0.4.x
Definition: saveload.h:69
173 23967 1.2.0-RC1
Definition: saveload.h:251
116 15893 0.7.x
Definition: saveload.h:183
150 20857
Definition: saveload.h:224
177 24619
Definition: saveload.h:256
TTO savegame.
Definition: saveload.h:337
Interface for filtering a savegame till it is loaded.
uint16 length
(conditional) length of the variable (eg. arrays) (max array size is 65536 elements) ...
Definition: saveload.h:502
Load/save a reference to a bus/truck stop.
Definition: saveload.h:378
122 16855
Definition: saveload.h:190
215 PR#7516 Limit on AI/GS memory consumption.
Definition: saveload.h:303
Save/load a variable.
Definition: saveload.h:482
207 PR#7175 v1.9 Cargo monitor data packing fix to support 64 cargotypes.
Definition: saveload.h:293
ChunkType
Flags of a chunk.
Definition: saveload.h:388
180 24998 1.3.x
Definition: saveload.h:260
88 12134
Definition: saveload.h:149
bool global
should we load a global variable or a non-global one
Definition: saveload.h:499
Load/save a reference to an engine renewal (autoreplace).
Definition: saveload.h:379
void SetTitle(const char *title)
Set the title of the file.
Definition: saveload.cpp:2886
22 3726
Definition: saveload.h:70
void SlObject(void *object, const SaveLoad *sld)
Main SaveLoad function.
Definition: saveload.cpp:1548
68 10266
Definition: saveload.h:125
VarType conv
type of the variable to be saved, int
Definition: saveload.h:501
209 PR#7289 Configurable ship curve penalties.
Definition: saveload.h:295
94 12816
Definition: saveload.h:156
byte SaveLoadType
Save/load type.
Definition: saveload.h:495
SLRefType
Type of reference (SLE_REF, SLE_CONDREF).
Definition: saveload.h:372
43 7642
Definition: saveload.h:95
void GenerateDefaultSaveName(char *buf, const char *last)
Fill the buffer with the default name for a savegame or screenshot.
Definition: saveload.cpp:2814
allow new lines in the strings
Definition: saveload.h:474
Highest possible saveload version.
Definition: saveload.h:307
SaveOrLoadResult
Save or load result codes.
Definition: saveload.h:311
196 27778 v1.7
Definition: saveload.h:280
do not save with savegame, basically client-based
Definition: saveload.h:470
132 18522
Definition: saveload.h:202
205 PR#7108 Livery storage change and group liveries.
Definition: saveload.h:291
62 9905
Definition: saveload.h:118
allow control codes in the strings
Definition: saveload.h:473
38 7195
Definition: saveload.h:89
5.0 1429 5.1 1440 5.2 1525 0.3.6
Definition: saveload.h:44
171 23835
Definition: saveload.h:249
34 6455
Definition: saveload.h:84
First savegame version.
Definition: saveload.h:32
194 26881 v1.5
Definition: saveload.h:277
33 6440
Definition: saveload.h:83
StringID offset into strings-array.
Definition: saveload.h:415
189 26450 Hierarchical vehicle subgroups
Definition: saveload.h:270
212 PR#7245 Remove OPF.
Definition: saveload.h:299
143 20048
Definition: saveload.h:215
111 15190
Definition: saveload.h:177
byte _sl_minor_version
the minor savegame version, DO NOT USE!
Definition: saveload.cpp:64
Save/load a list.
Definition: saveload.h:486
202 PR#6867 Increase industry cargo slots to 16 in, 16 out
Definition: saveload.h:287
Load/save a reference to a station.
Definition: saveload.h:375
TTDP savegame in new format (data at SE border)
Definition: saveload.h:335
29 5070
Definition: saveload.h:78
158 21933
Definition: saveload.h:233
195 27572 v1.6.1
Definition: saveload.h:279
73 10903
Definition: saveload.h:131
211 PR#7261 Add path cache for road vehicles.
Definition: saveload.h:298
35 6602
Definition: saveload.h:86
Load/save a reference to an order.
Definition: saveload.h:373
byte SlReadByte()
Wrapper for reading a byte from the buffer.
Definition: saveload.cpp:416
55 9638
Definition: saveload.h:110
109 15075
Definition: saveload.h:174
static VarType GetVarFileType(VarType type)
Get the FileType of a setting.
Definition: saveload.h:804
54 9613
Definition: saveload.h:108
20 3403
Definition: saveload.h:68
const SaveLoadVersion SAVEGAME_VERSION
current savegame version
OTTD savegame.
Definition: saveload.h:336
146 20446
Definition: saveload.h:219
30 5946
Definition: saveload.h:80
84 11822
Definition: saveload.h:144
10.0 2030
Definition: saveload.h:53
183 25363 Cargodist
Definition: saveload.h:263
53 9316
Definition: saveload.h:107
const char * GetSaveLoadErrorString()
Get the string representation of the error message.
Definition: saveload.cpp:2432
static VarType GetVarMemType(VarType type)
Get the NumberType of a setting.
Definition: saveload.h:793
92 12381 0.6.x
Definition: saveload.h:154
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
6.0 1721 6.1 1768
Definition: saveload.h:47
static bool IsNumericType(VarType conv)
Check if the given saveload type is a numeric type.
Definition: saveload.h:814
123 16909
Definition: saveload.h:191
148 20659
Definition: saveload.h:221
83 11589
Definition: saveload.h:143
SaveOrLoadResult LoadWithFilter(struct LoadFilter *reader)
Load the game using a (reader) filter.
Definition: saveload.cpp:2699
164 23290
Definition: saveload.h:240
SaveLoadOperation
Operation performed on the file.
Definition: fileio_type.h:49
23 3915
Definition: saveload.h:71
Load/save a reference to a vehicle.
Definition: saveload.h:374
124 16993
Definition: saveload.h:192
Handlers and description of chunk.
Definition: saveload.h:358
Save/load an array.
Definition: saveload.h:484
91 12347
Definition: saveload.h:153
41 7348 0.5.x
Definition: saveload.h:93
string enclosed in quotes (with pre-allocated buffer)
Definition: saveload.h:431
115 15695
Definition: saveload.h:182
1.0 0.1.x, 0.2.x
Definition: saveload.h:34
163 22767
Definition: saveload.h:239
159 21962
Definition: saveload.h:234
174 23973 1.2.x
Definition: saveload.h:252
153 21263
Definition: saveload.h:227
201 PR#6885 Extend NewGRF persistent storages.
Definition: saveload.h:286
static void * GetVariableAddress(const void *object, const SaveLoad *sld)
Get the address of the variable.
Definition: saveload.h:825
112 15290
Definition: saveload.h:178
9.0 1909
Definition: saveload.h:51
3.x lost
Definition: saveload.h:37
89 12160
Definition: saveload.h:150
160 21974 1.1.x
Definition: saveload.h:236
7.0 1770
Definition: saveload.h:49
Load/save a reference to a cargo packet.
Definition: saveload.h:380
139 19346
Definition: saveload.h:210
TTDP savegame ( -//- ) (data at NW border)
Definition: saveload.h:334
186 25833 Objects storage
Definition: saveload.h:267
56 9667
Definition: saveload.h:111
144 20334
Definition: saveload.h:216
75 11107
Definition: saveload.h:134
SaveLoadVersion version_to
save/load the variable until this savegame version
Definition: saveload.h:504
169 23816
Definition: saveload.h:246
181 25012
Definition: saveload.h:261
130 18404
Definition: saveload.h:200
static bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
Checks if some version from/to combination falls within the range of the active savegame version...
Definition: saveload.h:779
66 10211
Definition: saveload.h:123
190 26547 Separate order travel and wait times
Definition: saveload.h:272
147 20621
Definition: saveload.h:220
14.0 2441
Definition: saveload.h:58
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
Definition: saveload.cpp:2804
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition: saveload.cpp:639
useful to write zeros in savegame.
Definition: saveload.h:429
string pointer enclosed in quotes
Definition: saveload.h:433
broken savegame (used internally)
Definition: saveload.h:338
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash? If so, were NewGRFs missing?
Definition: afterload.cpp:366
19 3396
Definition: saveload.h:66
138 18942 1.0.x
Definition: saveload.h:209
208 PR#6965 New algorithms for town building cargo generation.
Definition: saveload.h:294
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:60
93 12648
Definition: saveload.h:155
SaveLoadType cmd
the action to take with the saved/loaded type, All types need different action
Definition: saveload.h:500
155 21453
Definition: saveload.h:230
50 8973
Definition: saveload.h:104
39 7269
Definition: saveload.h:90
8.0 1786
Definition: saveload.h:50
184 25508 Unit localisation split
Definition: saveload.h:264
198 PR#6763 Switch town growth rate and counter to actual game ticks
Definition: saveload.h:282
char name[MAX_PATH]
Name of the file.
Definition: saveload.h:322
SaveLoadOperation file_op
File operation to perform.
Definition: saveload.h:319
214 PR#6811 NewGRF road types.
Definition: saveload.h:301
65 10210
Definition: saveload.h:122
49 8969
Definition: saveload.h:102
void SlWriteByte(byte b)
Wrapper for writing a byte to the dumper.
Definition: saveload.cpp:425
void NORETURN SlError(StringID string, const char *extra_msg=nullptr)
Error handler.
Definition: saveload.cpp:328
AbstractFileType abstract_ftype
Abstract type of file (scenario, heightmap, etc).
Definition: saveload.h:321
void SlSetLength(size_t length)
Sets the length of either a RIFF object or the number of items in an array.
Definition: saveload.cpp:684
63 9956
Definition: saveload.h:119
192 26700 FS#6066 Fix saving of order backups
Definition: saveload.h:275
156 21728
Definition: saveload.h:231
140 19382
Definition: saveload.h:212
SaveLoad type struct.
Definition: saveload.h:498
69 10319
Definition: saveload.h:126
32 6001
Definition: saveload.h:82
154 21426
Definition: saveload.h:228
45 8501
Definition: saveload.h:98
Load/save a reference to an orderlist.
Definition: saveload.h:381
completed successfully
Definition: saveload.h:312
Load/save a reference to a link graph.
Definition: saveload.h:383
203 PR#7072 Add path cache for ships
Definition: saveload.h:288
78 11176
Definition: saveload.h:137
string pointer
Definition: saveload.h:432
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
Definition: saveload.h:622
178 24789
Definition: saveload.h:257
216 PR#7380 Multiple docks per station.
Definition: saveload.h:304
142 20003
Definition: saveload.h:214
void SetMode(FiosType ft)
Set the mode and file type of the file to save or load based on the type of file entry at the file sy...
Definition: saveload.cpp:2848
99 13838
Definition: saveload.h:162
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
Definition: saveload.h:320
182 25115 FS#5492, r25259, r25296 Goal status
Definition: saveload.h:262
176 24446
Definition: saveload.h:255
74 11030
Definition: saveload.h:132
136 18764
Definition: saveload.h:207
152 21171
Definition: saveload.h:226
161 22567
Definition: saveload.h:237
128 18281
Definition: saveload.h:197
95 12924
Definition: saveload.h:158
80 11228
Definition: saveload.h:140
199 PR#6802 Extend cargotypes to 64
Definition: saveload.h:283
Interface for filtering a savegame till it is written.
187 25899 Linkgraph - restricted flows
Definition: saveload.h:268
126 17433
Definition: saveload.h:195
213 PR#7405 WaterClass update for tree tiles.
Definition: saveload.h:300
36 6624
Definition: saveload.h:87
172 23947
Definition: saveload.h:250
error that was caught before internal structures were modified
Definition: saveload.h:313
31 5999
Definition: saveload.h:81
133 18674
Definition: saveload.h:203
200 PR#6805 Extend railtypes to 64, adding uint16 to map array.
Definition: saveload.h:285
81 11244
Definition: saveload.h:141
64 10006
Definition: saveload.h:120
46 8705
Definition: saveload.h:99
100 13952
Definition: saveload.h:164
27 4757
Definition: saveload.h:76
DetailedFileType
Kinds of files in each AbstractFileType.
Definition: fileio_type.h:30
168 23637
Definition: saveload.h:245
SaveLoad SaveLoadGlobVarList
Same as SaveLoad but global variables are used (for better readability);.
Definition: saveload.h:514
197 27978 v1.8
Definition: saveload.h:281
40 7326
Definition: saveload.h:92
67 10236
Definition: saveload.h:124
131 18481
Definition: saveload.h:201
size_t SlCalcObjLength(const void *object, const SaveLoad *sld)
Calculate the size of an object.
Definition: saveload.cpp:1382
old custom name to be converted to a char pointer
Definition: saveload.h:434
Last chunk in this array.
Definition: saveload.h:393
4.0 1 4.1 122 0.3.3, 0.3.4 4.2 1222 0.3.5 4.3 1417 4.4 1426
Definition: saveload.h:38
60 9874
Definition: saveload.h:116
166 23415
Definition: saveload.h:243
Save/load a string.
Definition: saveload.h:485
90 12293
Definition: saveload.h:152
86 12042
Definition: saveload.h:147
bool _do_autosave
are we doing an autosave at the moment?
Definition: saveload.cpp:66
Load/save a reference to a persistent storage.
Definition: saveload.h:382
167 23504
Definition: saveload.h:244
error that was caught in the middle of updating game state, need to clear it. (can only happen during...
Definition: saveload.h:314