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 
294 
296 };
297 
300  SL_OK = 0,
301  SL_ERROR = 1,
302  SL_REINIT = 2,
303 };
304 
310  char name[MAX_PATH];
311  char title[255];
312 
313  void SetMode(FiosType ft);
315  void SetName(const char *name);
316  void SetTitle(const char *title);
317 };
318 
326  SGT_INVALID = 0xFF,
327 };
328 
330 
331 void GenerateDefaultSaveName(char *buf, const char *last);
332 void SetSaveLoadError(StringID str);
333 const char *GetSaveLoadErrorString();
334 SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded = true);
335 void WaitTillSaved();
337 void DoExitSave();
338 
339 SaveOrLoadResult SaveWithFilter(struct SaveFilter *writer, bool threaded);
341 
342 typedef void ChunkSaveLoadProc();
343 typedef void AutolengthProc(void *arg);
344 
346 struct ChunkHandler {
347  uint32 id;
348  ChunkSaveLoadProc *save_proc;
349  ChunkSaveLoadProc *load_proc;
350  ChunkSaveLoadProc *ptrs_proc;
351  ChunkSaveLoadProc *load_check_proc;
352  uint32 flags;
353 };
354 
355 struct NullStruct {
356  byte null;
357 };
358 
360 enum SLRefType {
361  REF_ORDER = 0,
364  REF_TOWN = 3,
373 };
374 
376 enum ChunkType {
377  CH_RIFF = 0,
378  CH_ARRAY = 1,
379  CH_SPARSE_ARRAY = 2,
380  CH_TYPE_MASK = 3,
381  CH_LAST = 8,
382  CH_AUTO_LENGTH = 16,
383 };
384 
393 enum VarTypes {
394  /* 4 bits allocated a maximum of 16 types for NumberType */
395  SLE_FILE_I8 = 0,
396  SLE_FILE_U8 = 1,
397  SLE_FILE_I16 = 2,
398  SLE_FILE_U16 = 3,
399  SLE_FILE_I32 = 4,
400  SLE_FILE_U32 = 5,
401  SLE_FILE_I64 = 6,
402  SLE_FILE_U64 = 7,
404  SLE_FILE_STRING = 9,
405  /* 6 more possible file-primitives */
406 
407  /* 4 bits allocated a maximum of 16 types for NumberType */
408  SLE_VAR_BL = 0 << 4,
409  SLE_VAR_I8 = 1 << 4,
410  SLE_VAR_U8 = 2 << 4,
411  SLE_VAR_I16 = 3 << 4,
412  SLE_VAR_U16 = 4 << 4,
413  SLE_VAR_I32 = 5 << 4,
414  SLE_VAR_U32 = 6 << 4,
415  SLE_VAR_I64 = 7 << 4,
416  SLE_VAR_U64 = 8 << 4,
417  SLE_VAR_NULL = 9 << 4,
418  SLE_VAR_STRB = 10 << 4,
419  SLE_VAR_STRBQ = 11 << 4,
420  SLE_VAR_STR = 12 << 4,
421  SLE_VAR_STRQ = 13 << 4,
422  SLE_VAR_NAME = 14 << 4,
423  /* 1 more possible memory-primitives */
424 
425  /* Shortcut values */
426  SLE_VAR_CHAR = SLE_VAR_I8,
427 
428  /* Default combinations of variables. As savegames change, so can variables
429  * and thus it is possible that the saved value and internal size do not
430  * match and you need to specify custom combo. The defaults are listed here */
431  SLE_BOOL = SLE_FILE_I8 | SLE_VAR_BL,
432  SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8,
433  SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8,
434  SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16,
435  SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16,
436  SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32,
437  SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32,
438  SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64,
439  SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64,
440  SLE_CHAR = SLE_FILE_I8 | SLE_VAR_CHAR,
441  SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U32,
442  SLE_STRINGBUF = SLE_FILE_STRING | SLE_VAR_STRB,
443  SLE_STRINGBQUOTE = SLE_FILE_STRING | SLE_VAR_STRBQ,
444  SLE_STRING = SLE_FILE_STRING | SLE_VAR_STR,
445  SLE_STRINGQUOTE = SLE_FILE_STRING | SLE_VAR_STRQ,
446  SLE_NAME = SLE_FILE_STRINGID | SLE_VAR_NAME,
447 
448  /* Shortcut values */
449  SLE_UINT = SLE_UINT32,
450  SLE_INT = SLE_INT32,
451  SLE_STRB = SLE_STRINGBUF,
452  SLE_STRBQ = SLE_STRINGBQUOTE,
453  SLE_STR = SLE_STRING,
454  SLE_STRQ = SLE_STRINGQUOTE,
455 
456  /* 8 bits allocated for a maximum of 8 flags
457  * Flags directing saving/loading of a variable */
458  SLF_NOT_IN_SAVE = 1 << 8,
459  SLF_NOT_IN_CONFIG = 1 << 9,
461  SLF_ALLOW_CONTROL = 1 << 11,
462  SLF_ALLOW_NEWLINE = 1 << 12,
463  /* 3 more possible flags */
464 };
465 
466 typedef uint32 VarType;
467 
470  SL_VAR = 0,
471  SL_REF = 1,
472  SL_ARR = 2,
473  SL_STR = 3,
474  SL_LST = 4,
475  SL_DEQUE = 5,
476  /* non-normal save-load types */
477  SL_WRITEBYTE = 8,
478  SL_VEH_INCLUDE = 9,
479  SL_ST_INCLUDE = 10,
480  SL_END = 15
481 };
482 
483 typedef byte SaveLoadType;
484 
486 struct SaveLoad {
487  bool global;
489  VarType conv;
490  uint16 length;
493  /* NOTE: This element either denotes the address of the variable for a global
494  * variable, or the offset within a struct which is then bound to a variable
495  * during runtime. Decision on which one to use is controlled by the function
496  * that is called to save it. address: global=true, offset: global=false */
497  void *address;
498  size_t size;
499 };
500 
503 
514 #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)}
515 
524 #define SLE_CONDVAR(base, variable, type, from, to) SLE_GENERAL(SL_VAR, base, variable, type, 0, from, to)
525 
534 #define SLE_CONDREF(base, variable, type, from, to) SLE_GENERAL(SL_REF, base, variable, type, 0, from, to)
535 
545 #define SLE_CONDARR(base, variable, type, length, from, to) SLE_GENERAL(SL_ARR, base, variable, type, length, from, to)
546 
556 #define SLE_CONDSTR(base, variable, type, length, from, to) SLE_GENERAL(SL_STR, base, variable, type, length, from, to)
557 
566 #define SLE_CONDLST(base, variable, type, from, to) SLE_GENERAL(SL_LST, base, variable, type, 0, from, to)
567 
576 #define SLE_CONDDEQUE(base, variable, type, from, to) SLE_GENERAL(SL_DEQUE, base, variable, type, 0, from, to)
577 
584 #define SLE_VAR(base, variable, type) SLE_CONDVAR(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
585 
592 #define SLE_REF(base, variable, type) SLE_CONDREF(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
593 
601 #define SLE_ARR(base, variable, type, length) SLE_CONDARR(base, variable, type, length, SL_MIN_VERSION, SL_MAX_VERSION)
602 
610 #define SLE_STR(base, variable, type, length) SLE_CONDSTR(base, variable, type, length, SL_MIN_VERSION, SL_MAX_VERSION)
611 
618 #define SLE_LST(base, variable, type) SLE_CONDLST(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
619 
624 #define SLE_NULL(length) SLE_CONDNULL(length, SL_MIN_VERSION, SL_MAX_VERSION)
625 
632 #define SLE_CONDNULL(length, from, to) SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to)
633 
635 #define SLE_WRITEBYTE(base, variable) SLE_GENERAL(SL_WRITEBYTE, base, variable, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION)
636 
637 #define SLE_VEH_INCLUDE() {false, SL_VEH_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, NULL, 0}
638 #define SLE_ST_INCLUDE() {false, SL_ST_INCLUDE, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, NULL, 0}
639 
641 #define SLE_END() {false, SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, NULL, 0}
642 
652 #define SLEG_GENERAL(cmd, variable, type, length, from, to) {true, cmd, type, length, from, to, (void*)&variable, sizeof(variable)}
653 
661 #define SLEG_CONDVAR(variable, type, from, to) SLEG_GENERAL(SL_VAR, variable, type, 0, from, to)
662 
670 #define SLEG_CONDREF(variable, type, from, to) SLEG_GENERAL(SL_REF, variable, type, 0, from, to)
671 
680 #define SLEG_CONDARR(variable, type, length, from, to) SLEG_GENERAL(SL_ARR, variable, type, length, from, to)
681 
690 #define SLEG_CONDSTR(variable, type, length, from, to) SLEG_GENERAL(SL_STR, variable, type, length, from, to)
691 
699 #define SLEG_CONDLST(variable, type, from, to) SLEG_GENERAL(SL_LST, variable, type, 0, from, to)
700 
706 #define SLEG_VAR(variable, type) SLEG_CONDVAR(variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
707 
713 #define SLEG_REF(variable, type) SLEG_CONDREF(variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
714 
720 #define SLEG_ARR(variable, type) SLEG_CONDARR(variable, type, lengthof(variable), SL_MIN_VERSION, SL_MAX_VERSION)
721 
727 #define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, sizeof(variable), SL_MIN_VERSION, SL_MAX_VERSION)
728 
734 #define SLEG_LST(variable, type) SLEG_CONDLST(variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
735 
742 #define SLEG_CONDNULL(length, from, to) {true, SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_NOT_IN_CONFIG, length, from, to, (void*)NULL}
743 
745 #define SLEG_END() {true, SL_END, 0, 0, SL_MIN_VERSION, SL_MIN_VERSION, NULL, 0}
746 
753 static inline bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor = 0)
754 {
756  extern byte _sl_minor_version;
757  return _sl_version < major || (minor > 0 && _sl_version == major && _sl_minor_version < minor);
758 }
759 
767 static inline bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
768 {
769  extern const SaveLoadVersion SAVEGAME_VERSION;
770  if (SAVEGAME_VERSION < version_from || SAVEGAME_VERSION >= version_to) return false;
771 
772  return true;
773 }
774 
781 static inline VarType GetVarMemType(VarType type)
782 {
783  return type & 0xF0; // GB(type, 4, 4) << 4;
784 }
785 
792 static inline VarType GetVarFileType(VarType type)
793 {
794  return type & 0xF; // GB(type, 0, 4);
795 }
796 
802 static inline bool IsNumericType(VarType conv)
803 {
804  return GetVarMemType(conv) <= SLE_VAR_U64;
805 }
806 
813 static inline void *GetVariableAddress(const void *object, const SaveLoad *sld)
814 {
815  return const_cast<byte *>((const byte*)(sld->global ? NULL : object) + (ptrdiff_t)sld->address);
816 }
817 
818 int64 ReadValue(const void *ptr, VarType conv);
819 void WriteValue(void *ptr, VarType conv, int64 val);
820 
821 void SlSetArrayIndex(uint index);
822 int SlIterateArray();
823 
824 void SlAutolength(AutolengthProc *proc, void *arg);
825 size_t SlGetFieldLength();
826 void SlSetLength(size_t length);
827 size_t SlCalcObjMemberLength(const void *object, const SaveLoad *sld);
828 size_t SlCalcObjLength(const void *object, const SaveLoad *sld);
829 
830 byte SlReadByte();
831 void SlWriteByte(byte b);
832 
833 void SlGlobList(const SaveLoadGlobVarList *sldg);
834 void SlArray(void *array, size_t length, VarType conv);
835 void SlObject(void *object, const SaveLoad *sld);
836 bool SlObjectMember(void *object, const SaveLoad *sld);
837 void NORETURN SlError(StringID string, const char *extra_msg = NULL);
838 void NORETURN SlErrorCorrupt(const char *msg);
839 void NORETURN SlErrorCorruptFmt(const char *format, ...);
840 
842 
843 extern char _savegame_format[8];
844 extern bool _do_autosave;
845 
846 #endif /* SAVELOAD_H */
void ProcessAsyncSaveFinish()
Handle async save finishes.
Definition: saveload.cpp:392
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:2421
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:1561
149 20832
Definition: saveload.h:222
char _savegame_format[8]
how to compress savegames
Definition: saveload.cpp:64
static bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor=0)
Checks whether the savegame is below major.
Definition: saveload.h:753
129 18292
Definition: saveload.h:198
77 11172
Definition: saveload.h:136
Save/load a deque.
Definition: saveload.h:475
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:740
12.1 2046
Definition: saveload.h:56
SaveLoadVersion version_from
save/load the variable starting from this savegame version
Definition: saveload.h:491
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:418
uint32 flags
Flags of the chunk.
Definition: saveload.h:352
void SetName(const char *name)
Set the name of the file.
Definition: saveload.cpp:2879
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:348
51 8978
Definition: saveload.h:105
SaveLoadTypes
Type of data saved.
Definition: saveload.h:469
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:393
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:460
97 13256
Definition: saveload.h:160
120 16439
Definition: saveload.h:188
185 25620 Storybooks
Definition: saveload.h:266
uint32 id
Unique ID (4 letters).
Definition: saveload.h:347
103 14598
Definition: saveload.h:167
SaveOrLoadResult SaveWithFilter(struct SaveFilter *writer, bool threaded)
Save the game using a (writer) filter.
Definition: saveload.cpp:2546
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:62
char title[255]
Internal name of the game.
Definition: saveload.h:311
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:2721
25 4259
Definition: saveload.h:74
47 8735
Definition: saveload.h:100
121 16694
Definition: saveload.h:189
188 26169 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:372
175 24136
Definition: saveload.h:254
Load/save an old-style reference to a vehicle (for pre-4.4 savegames).
Definition: saveload.h:365
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:497
42 7573
Definition: saveload.h:94
118 16129
Definition: saveload.h:185
TTD savegame (can be detected incorrectly)
Definition: saveload.h:321
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:459
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:360
28 4987
Definition: saveload.h:77
Load/save a reference to a town.
Definition: saveload.h:364
105 14803
Definition: saveload.h:170
165 23304
Definition: saveload.h:242
SavegameType
Types of save games.
Definition: saveload.h:320
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:776
int64 ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
Definition: saveload.cpp:752
Deals with the type of the savegame, independent of extension.
Definition: saveload.h:306
size_t size
the sizeof size.
Definition: saveload.h:498
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:992
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
Save/load a reference.
Definition: saveload.h:471
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:1571
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:325
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:490
Load/save a reference to a bus/truck stop.
Definition: saveload.h:366
122 16855
Definition: saveload.h:190
Save/load a variable.
Definition: saveload.h:470
207 PR#7175 Cargo monitor data packing fix to support 64 cargotypes.
Definition: saveload.h:293
ChunkType
Flags of a chunk.
Definition: saveload.h:376
void NORETURN SlError(StringID string, const char *extra_msg=NULL)
Error handler.
Definition: saveload.cpp:320
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:487
Load/save a reference to an engine renewal (autoreplace).
Definition: saveload.h:367
void SetTitle(const char *title)
Set the title of the file.
Definition: saveload.cpp:2888
22 3726
Definition: saveload.h:70
void SlObject(void *object, const SaveLoad *sld)
Main SaveLoad function.
Definition: saveload.cpp:1543
68 10266
Definition: saveload.h:125
VarType conv
type of the variable to be saved, int
Definition: saveload.h:489
94 12816
Definition: saveload.h:156
byte SaveLoadType
Save/load type.
Definition: saveload.h:483
SLRefType
Type of reference (SLE_REF, SLE_CONDREF).
Definition: saveload.h:360
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:2816
allow new lines in the strings
Definition: saveload.h:462
Highest possible saveload version.
Definition: saveload.h:295
SaveOrLoadResult
Save or load result codes.
Definition: saveload.h:299
196 27778 v1.7
Definition: saveload.h:280
do not save with savegame, basically client-based
Definition: saveload.h:458
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:461
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:403
189 26450 Heirarchical vehicle subgroups
Definition: saveload.h:270
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:63
Save/load a list.
Definition: saveload.h:474
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:363
TTDP savegame in new format (data at SE border)
Definition: saveload.h:323
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
35 6602
Definition: saveload.h:86
Load/save a reference to an order.
Definition: saveload.h:361
byte SlReadByte()
Wrapper for reading a byte from the buffer.
Definition: saveload.cpp:411
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:792
54 9613
Definition: saveload.h:108
20 3403
Definition: saveload.h:68
const SaveLoadVersion SAVEGAME_VERSION
current savegame version
OTTD savegame.
Definition: saveload.h:324
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:2427
static VarType GetVarMemType(VarType type)
Get the NumberType of a setting.
Definition: saveload.h:781
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:802
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:2701
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:362
124 16993
Definition: saveload.h:192
Handlers and description of chunk.
Definition: saveload.h:346
Save/load an array.
Definition: saveload.h:472
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:419
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 persistant storages.
Definition: saveload.h:286
static void * GetVariableAddress(const void *object, const SaveLoad *sld)
Get the address of the variable.
Definition: saveload.h:813
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:368
139 19346
Definition: saveload.h:210
TTDP savegame ( -//- ) (data at NW border)
Definition: saveload.h:322
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:492
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:767
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:2806
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition: saveload.cpp:634
useful to write zeros in savegame.
Definition: saveload.h:417
string pointer enclosed in quotes
Definition: saveload.h:421
broken savegame (used internally)
Definition: saveload.h:326
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash? If so, were NewGRFs missing?
Definition: afterload.cpp:358
19 3396
Definition: saveload.h:66
138 18942 1.0.x
Definition: saveload.h:209
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
Definition: saveload.cpp:59
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:488
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:310
SaveLoadOperation file_op
File operation to perform.
Definition: saveload.h:307
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:420
AbstractFileType abstract_ftype
Abstract type of file (scenario, heightmap, etc).
Definition: saveload.h:309
void SlSetLength(size_t length)
Sets the length of either a RIFF object or the number of items in an array.
Definition: saveload.cpp:679
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:486
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:369
completed successfully
Definition: saveload.h:300
Load/save a reference to a link graph.
Definition: saveload.h:371
203 PR#7072 Add path cache for ships
Definition: saveload.h:288
78 11176
Definition: saveload.h:137
string pointer
Definition: saveload.h:420
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
Definition: saveload.h:610
178 24789
Definition: saveload.h:257
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:2850
99 13838
Definition: saveload.h:162
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
Definition: saveload.h:308
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
36 6624
Definition: saveload.h:87
172 23947
Definition: saveload.h:250
error that was caught before internal structures were modified
Definition: saveload.h:301
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:502
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:1377
old custom name to be converted to a char pointer
Definition: saveload.h:422
Last chunk in this array.
Definition: saveload.h:381
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:473
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:65
Load/save a reference to a persistent storage.
Definition: saveload.h:370
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:302