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