OpenTTD Source  1.10.0-RC1
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 
305 
307 };
308 
311  SL_OK = 0,
312  SL_ERROR = 1,
313  SL_REINIT = 2,
314 };
315 
321  char name[MAX_PATH];
322  char title[255];
323 
324  void SetMode(FiosType ft);
326  void SetName(const char *name);
327  void SetTitle(const char *title);
328 };
329 
337  SGT_INVALID = 0xFF,
338 };
339 
341 
342 void GenerateDefaultSaveName(char *buf, const char *last);
343 void SetSaveLoadError(StringID str);
344 const char *GetSaveLoadErrorString();
345 SaveOrLoadResult SaveOrLoad(const char *filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded = true);
346 void WaitTillSaved();
348 void DoExitSave();
349 
350 SaveOrLoadResult SaveWithFilter(struct SaveFilter *writer, bool threaded);
352 
353 typedef void ChunkSaveLoadProc();
354 typedef void AutolengthProc(void *arg);
355 
357 struct ChunkHandler {
358  uint32 id;
359  ChunkSaveLoadProc *save_proc;
360  ChunkSaveLoadProc *load_proc;
361  ChunkSaveLoadProc *ptrs_proc;
362  ChunkSaveLoadProc *load_check_proc;
363  uint32 flags;
364 };
365 
366 struct NullStruct {
367  byte null;
368 };
369 
371 enum SLRefType {
372  REF_ORDER = 0,
375  REF_TOWN = 3,
384 };
385 
387 enum ChunkType {
388  CH_RIFF = 0,
389  CH_ARRAY = 1,
390  CH_SPARSE_ARRAY = 2,
391  CH_TYPE_MASK = 3,
392  CH_LAST = 8,
393  CH_AUTO_LENGTH = 16,
394 };
395 
404 enum VarTypes {
405  /* 4 bits allocated a maximum of 16 types for NumberType */
406  SLE_FILE_I8 = 0,
407  SLE_FILE_U8 = 1,
408  SLE_FILE_I16 = 2,
409  SLE_FILE_U16 = 3,
410  SLE_FILE_I32 = 4,
411  SLE_FILE_U32 = 5,
412  SLE_FILE_I64 = 6,
413  SLE_FILE_U64 = 7,
415  SLE_FILE_STRING = 9,
416  /* 6 more possible file-primitives */
417 
418  /* 4 bits allocated a maximum of 16 types for NumberType */
419  SLE_VAR_BL = 0 << 4,
420  SLE_VAR_I8 = 1 << 4,
421  SLE_VAR_U8 = 2 << 4,
422  SLE_VAR_I16 = 3 << 4,
423  SLE_VAR_U16 = 4 << 4,
424  SLE_VAR_I32 = 5 << 4,
425  SLE_VAR_U32 = 6 << 4,
426  SLE_VAR_I64 = 7 << 4,
427  SLE_VAR_U64 = 8 << 4,
428  SLE_VAR_NULL = 9 << 4,
429  SLE_VAR_STRB = 10 << 4,
430  SLE_VAR_STRBQ = 11 << 4,
431  SLE_VAR_STR = 12 << 4,
432  SLE_VAR_STRQ = 13 << 4,
433  SLE_VAR_NAME = 14 << 4,
434  /* 1 more possible memory-primitives */
435 
436  /* Shortcut values */
437  SLE_VAR_CHAR = SLE_VAR_I8,
438 
439  /* Default combinations of variables. As savegames change, so can variables
440  * and thus it is possible that the saved value and internal size do not
441  * match and you need to specify custom combo. The defaults are listed here */
442  SLE_BOOL = SLE_FILE_I8 | SLE_VAR_BL,
443  SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8,
444  SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8,
445  SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16,
446  SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16,
447  SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32,
448  SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32,
449  SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64,
450  SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64,
451  SLE_CHAR = SLE_FILE_I8 | SLE_VAR_CHAR,
452  SLE_STRINGID = SLE_FILE_STRINGID | SLE_VAR_U32,
453  SLE_STRINGBUF = SLE_FILE_STRING | SLE_VAR_STRB,
454  SLE_STRINGBQUOTE = SLE_FILE_STRING | SLE_VAR_STRBQ,
455  SLE_STRING = SLE_FILE_STRING | SLE_VAR_STR,
456  SLE_STRINGQUOTE = SLE_FILE_STRING | SLE_VAR_STRQ,
457  SLE_NAME = SLE_FILE_STRINGID | SLE_VAR_NAME,
458 
459  /* Shortcut values */
460  SLE_UINT = SLE_UINT32,
461  SLE_INT = SLE_INT32,
462  SLE_STRB = SLE_STRINGBUF,
463  SLE_STRBQ = SLE_STRINGBQUOTE,
464  SLE_STR = SLE_STRING,
465  SLE_STRQ = SLE_STRINGQUOTE,
466 
467  /* 8 bits allocated for a maximum of 8 flags
468  * Flags directing saving/loading of a variable */
469  SLF_NOT_IN_SAVE = 1 << 8,
470  SLF_NOT_IN_CONFIG = 1 << 9,
472  SLF_ALLOW_CONTROL = 1 << 11,
473  SLF_ALLOW_NEWLINE = 1 << 12,
474  SLF_HEX = 1 << 13,
475  /* 2 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: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:2434
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:765
129 18292
Definition: saveload.h:196
77 11172
Definition: saveload.h:134
Save/load a deque.
Definition: saveload.h:487
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:503
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:429
uint32 flags
Flags of the chunk.
Definition: saveload.h:363
void SetName(const char *name)
Set the name of the file.
Definition: saveload.cpp:2888
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:481
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:404
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:471
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:358
103 14598
Definition: saveload.h:165
SaveOrLoadResult SaveWithFilter(struct SaveFilter *writer, bool threaded)
Save the game using a (writer) filter.
Definition: saveload.cpp:2552
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:322
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:2729
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
218 PR#7747 Configurable ending year.
Definition: saveload.h:304
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:383
175 24136
Definition: saveload.h:252
Load/save an old-style reference to a vehicle (for pre-4.4 savegames).
Definition: saveload.h:376
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:509
42 7573
Definition: saveload.h:92
118 16129
Definition: saveload.h:183
TTD savegame (can be detected incorrectly)
Definition: saveload.h:332
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:470
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:375
105 14803
Definition: saveload.h:168
165 23304
Definition: saveload.h:240
SavegameType
Types of save games.
Definition: saveload.h:331
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:317
size_t size
the sizeof size.
Definition: saveload.h:510
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:483
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:336
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:377
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:482
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:387
print numbers as hex in the config file (only useful for unsigned)
Definition: saveload.h:474
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:499
Load/save a reference to an engine renewal (autoreplace).
Definition: saveload.h:378
void SetTitle(const char *title)
Set the title of the file.
Definition: saveload.cpp:2897
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:501
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:495
SLRefType
Type of reference (SLE_REF, SLE_CONDREF).
Definition: saveload.h:371
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:2826
allow new lines in the strings
Definition: saveload.h:473
Highest possible saveload version.
Definition: saveload.h:306
SaveOrLoadResult
Save or load result codes.
Definition: saveload.h:310
196 27778 v1.7
Definition: saveload.h:278
do not save with savegame, basically client-based
Definition: saveload.h:469
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:472
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:414
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:486
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:374
TTDP savegame in new format (data at SE border)
Definition: saveload.h:334
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:372
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:804
54 9613
Definition: saveload.h:106
20 3403
Definition: saveload.h:66
const SaveLoadVersion SAVEGAME_VERSION
current savegame version
OTTD savegame.
Definition: saveload.h:335
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:2440
static VarType GetVarMemType(VarType type)
Get the NumberType of a setting.
Definition: saveload.h:793
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:814
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:2709
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:373
124 16993
Definition: saveload.h:190
Handlers and description of chunk.
Definition: saveload.h:357
Save/load an array.
Definition: saveload.h:484
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:430
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:825
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:379
139 19346
Definition: saveload.h:208
TTDP savegame ( -//- ) (data at NW border)
Definition: saveload.h:333
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:504
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:779
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:2816
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:428
string pointer enclosed in quotes
Definition: saveload.h:432
broken savegame (used internally)
Definition: saveload.h:337
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash? If so, were NewGRFs missing?
Definition: afterload.cpp:364
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:500
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:321
SaveLoadOperation file_op
File operation to perform.
Definition: saveload.h:318
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:320
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:498
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:380
completed successfully
Definition: saveload.h:311
Load/save a reference to a link graph.
Definition: saveload.h:382
203 PR#7072 Add path cache for ships
Definition: saveload.h:286
78 11176
Definition: saveload.h:135
string pointer
Definition: saveload.h:431
#define SLE_STR(base, variable, type, length)
Storage of a string in every savegame version.
Definition: saveload.h:622
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:2859
99 13838
Definition: saveload.h:160
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
Definition: saveload.h:319
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:312
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:514
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:433
Last chunk in this array.
Definition: saveload.h:392
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:485
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:381
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:313