13#include "saveload_error.hpp"
14#include "../fileio_type.h"
448typedef void AutolengthProc(
int);
475 virtual void Save()
const { NOT_REACHED(); }
496 virtual void LoadCheck(
size_t len = 0)
const;
498 std::string GetName()
const
501 +
static_cast<char>(this->
id >> 24)
502 +
static_cast<char>(this->
id >> 16)
503 +
static_cast<char>(this->
id >> 8)
504 +
static_cast<char>(this->
id);
523 std::optional<std::vector<SaveLoad>> load_description;
531 virtual void Save([[maybe_unused]]
void *
object)
const {}
537 virtual void Load([[maybe_unused]]
void *
object)
const {}
543 virtual void LoadCheck([[maybe_unused]]
void *
object)
const {}
580template <
class TImpl,
class TObject>
586 virtual void Save([[maybe_unused]] TObject *
object)
const {}
587 void Save(
void *
object)
const override { this->
Save(
static_cast<TObject *
>(
object)); }
589 virtual void Load([[maybe_unused]] TObject *
object)
const {}
590 void Load(
void *
object)
const override { this->
Load(
static_cast<TObject *
>(
object)); }
592 virtual void LoadCheck([[maybe_unused]] TObject *
object)
const {}
595 virtual void FixPointers([[maybe_unused]] TObject *
object)
const {}
636 SLE_FILE_STRING = 10,
637 SLE_FILE_STRUCT = 11,
647 SLE_VAR_I16 = 3 << 4,
648 SLE_VAR_U16 = 4 << 4,
649 SLE_VAR_I32 = 5 << 4,
650 SLE_VAR_U32 = 6 << 4,
651 SLE_VAR_I64 = 7 << 4,
652 SLE_VAR_U64 = 8 << 4,
660 SLE_VAR_CHAR = SLE_VAR_I8,
665 SLE_BOOL = SLE_FILE_I8 | SLE_VAR_BL,
666 SLE_INT8 = SLE_FILE_I8 | SLE_VAR_I8,
667 SLE_UINT8 = SLE_FILE_U8 | SLE_VAR_U8,
668 SLE_INT16 = SLE_FILE_I16 | SLE_VAR_I16,
669 SLE_UINT16 = SLE_FILE_U16 | SLE_VAR_U16,
670 SLE_INT32 = SLE_FILE_I32 | SLE_VAR_I32,
671 SLE_UINT32 = SLE_FILE_U32 | SLE_VAR_U32,
672 SLE_INT64 = SLE_FILE_I64 | SLE_VAR_I64,
673 SLE_UINT64 = SLE_FILE_U64 | SLE_VAR_U64,
674 SLE_CHAR = SLE_FILE_I8 | SLE_VAR_CHAR,
681 SLE_UINT = SLE_UINT32,
683 SLE_STR = SLE_STRING,
684 SLE_STRQ = SLE_STRINGQUOTE,
692typedef uint32_t VarType;
714typedef void *SaveLoadAddrProc(
void *base,
size_t extra);
753 return GB(type, 4, 4) << 4;
764 return GB(type, 0, 4);
785 case SLE_VAR_BL:
return sizeof(bool);
786 case SLE_VAR_I8:
return sizeof(int8_t);
787 case SLE_VAR_U8:
return sizeof(uint8_t);
788 case SLE_VAR_I16:
return sizeof(int16_t);
789 case SLE_VAR_U16:
return sizeof(uint16_t);
790 case SLE_VAR_I32:
return sizeof(int32_t);
791 case SLE_VAR_U32:
return sizeof(uint32_t);
792 case SLE_VAR_I64:
return sizeof(int64_t);
793 case SLE_VAR_U64:
return sizeof(uint64_t);
798 default: NOT_REACHED();
814 case SL_REF:
return sizeof(
void *) == size;
817 case SL_DEQUE:
return sizeof(std::deque<void *>) == size;
818 case SL_VECTOR:
return sizeof(std::vector<void *>) == size;
819 case SL_REFLIST:
return sizeof(std::list<void *>) == size;
820 case SL_REFVECTOR:
return sizeof(std::vector<void *>) == size;
822 default: NOT_REACHED();
839#define SLE_GENERAL_NAME(cmd, name, base, variable, type, length, from, to, extra) \
840 SaveLoad {name, cmd, type, length, from, to, [] (void *b, size_t) -> void * { \
841 static_assert(SlCheckVarSize(cmd, type, length, sizeof(static_cast<base *>(b)->variable))); \
842 assert(b != nullptr); \
843 return const_cast<void *>(static_cast<const void *>(std::addressof(static_cast<base *>(b)->variable))); \
858#define SLE_GENERAL(cmd, base, variable, type, length, from, to, extra) SLE_GENERAL_NAME(cmd, #variable, base, variable, type, length, from, to, extra)
868#define SLE_CONDVAR(base, variable, type, from, to) SLE_GENERAL(SL_VAR, base, variable, type, 0, from, to, 0)
879#define SLE_CONDVARNAME(base, variable, name, type, from, to) SLE_GENERAL_NAME(SL_VAR, name, base, variable, type, 0, from, to, 0)
889#define SLE_CONDREF(base, variable, type, from, to) SLE_GENERAL(SL_REF, base, variable, type, 0, from, to, 0)
900#define SLE_CONDARR(base, variable, type, length, from, to) SLE_GENERAL(SL_ARR, base, variable, type, length, from, to, 0)
912#define SLE_CONDARRNAME(base, variable, name, type, length, from, to) SLE_GENERAL_NAME(SL_ARR, name, base, variable, type, length, from, to, 0)
923#define SLE_CONDSTR(base, variable, type, length, from, to) SLE_GENERAL(SL_STR, base, variable, type, length, from, to, 0)
933#define SLE_CONDSSTR(base, variable, type, from, to) SLE_GENERAL(SL_STDSTR, base, variable, type, 0, from, to, 0)
944#define SLE_CONDSSTRNAME(base, variable, name, type, from, to) SLE_GENERAL_NAME(SL_STDSTR, name, base, variable, type, 0, from, to, 0)
954#define SLE_CONDREFLIST(base, variable, type, from, to) SLE_GENERAL(SL_REFLIST, base, variable, type, 0, from, to, 0)
964#define SLE_CONDREFVECTOR(base, variable, type, from, to) SLE_GENERAL(SL_REFVECTOR, base, variable, type, 0, from, to, 0)
974#define SLE_CONDVECTOR(base, variable, type, from, to) SLE_GENERAL(SL_VECTOR, base, variable, type, 0, from, to, 0)
984#define SLE_CONDDEQUE(base, variable, type, from, to) SLE_GENERAL(SL_DEQUE, base, variable, type, 0, from, to, 0)
994#define SLE_CONDVECTOR(base, variable, type, from, to) SLE_GENERAL(SL_VECTOR, base, variable, type, 0, from, to, 0)
1002#define SLE_VAR(base, variable, type) SLE_CONDVAR(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1011#define SLE_VARNAME(base, variable, name, type) SLE_CONDVARNAME(base, variable, name, type, SL_MIN_VERSION, SL_MAX_VERSION)
1019#define SLE_REF(base, variable, type) SLE_CONDREF(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1028#define SLE_ARR(base, variable, type, length) SLE_CONDARR(base, variable, type, length, SL_MIN_VERSION, SL_MAX_VERSION)
1038#define SLE_ARRNAME(base, variable, name, type, length) SLE_CONDARRNAME(base, variable, name, type, length, SL_MIN_VERSION, SL_MAX_VERSION)
1046#define SLE_SSTR(base, variable, type) SLE_CONDSSTR(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1055#define SLE_SSTRNAME(base, variable, name, type) SLE_CONDSSTRNAME(base, variable, name, type, SL_MIN_VERSION, SL_MAX_VERSION)
1063#define SLE_REFLIST(base, variable, type) SLE_CONDREFLIST(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1071#define SLE_REFVECTOR(base, variable, type) SLE_CONDREFVECTOR(base, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1083#define SLE_SAVEBYTE(base, variable) SLE_GENERAL(SL_SAVEBYTE, base, variable, 0, 0, SL_MIN_VERSION, SL_MAX_VERSION, 0)
1096#define SLEG_GENERAL(name, cmd, variable, type, length, from, to, extra) \
1097 SaveLoad {name, cmd, type, length, from, to, [] (void *, size_t) -> void * { \
1098 static_assert(SlCheckVarSize(cmd, type, length, sizeof(variable))); \
1099 return static_cast<void *>(std::addressof(variable)); }, extra, nullptr}
1109#define SLEG_CONDVAR(name, variable, type, from, to) SLEG_GENERAL(name, SL_VAR, variable, type, 0, from, to, 0)
1119#define SLEG_CONDREF(name, variable, type, from, to) SLEG_GENERAL(name, SL_REF, variable, type, 0, from, to, 0)
1130#define SLEG_CONDARR(name, variable, type, length, from, to) SLEG_GENERAL(name, SL_ARR, variable, type, length, from, to, 0)
1140#define SLEG_CONDSSTR(name, variable, type, from, to) SLEG_GENERAL(name, SL_STDSTR, variable, type, 0, from, to, 0)
1149#define SLEG_CONDSTRUCT(name, handler, from, to) SaveLoad {name, SL_STRUCT, 0, 0, from, to, nullptr, 0, std::make_shared<handler>()}
1159#define SLEG_CONDREFLIST(name, variable, type, from, to) SLEG_GENERAL(name, SL_REFLIST, variable, type, 0, from, to, 0)
1169#define SLEG_CONDVECTOR(name, variable, type, from, to) SLEG_GENERAL(name, SL_VECTOR, variable, type, 0, from, to, 0)
1178#define SLEG_CONDSTRUCTLIST(name, handler, from, to) SaveLoad {name, SL_STRUCTLIST, 0, 0, from, to, nullptr, 0, std::make_shared<handler>()}
1186#define SLEG_VAR(name, variable, type) SLEG_CONDVAR(name, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1194#define SLEG_REF(name, variable, type) SLEG_CONDREF(name, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1203#define SLEG_ARR(name, variable, type, length) SLEG_CONDARR(name, variable, type, length, SL_MIN_VERSION, SL_MAX_VERSION)
1211#define SLEG_SSTR(name, variable, type) SLEG_CONDSSTR(name, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1218#define SLEG_STRUCT(name, handler) SLEG_CONDSTRUCT(name, handler, SL_MIN_VERSION, SL_MAX_VERSION)
1226#define SLEG_REFLIST(name, variable, type) SLEG_CONDREFLIST(name, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1234#define SLEG_VECTOR(name, variable, type) SLEG_CONDVECTOR(name, variable, type, SL_MIN_VERSION, SL_MAX_VERSION)
1241#define SLEG_STRUCTLIST(name, handler) SLEG_CONDSTRUCTLIST(name, handler, SL_MIN_VERSION, SL_MAX_VERSION)
1247#define SLC_VAR(name) {name, SLE_FILE_U8, 0, SL_MIN_VERSION, SL_MAX_VERSION}
1255#define SLC_NULL(length, from, to) {{}, SLE_FILE_U8, length, from, to}
1314int64_t
ReadValue(
const void *ptr, VarType conv);
1315void WriteValue(
void *ptr, VarType conv, int64_t val);
1317void SlSetArrayIndex(uint index);
1326size_t SlCalcObjMemberLength(
const void *
object,
const SaveLoad &sld);
1333void SlCopy(
void *
object,
size_t length, VarType conv);
1364template <
class TImpl,
class TObject,
class TElementType,
size_t MAX_LENGTH = UINT32_MAX>
1372 virtual std::vector<TElementType> &
GetVector(TObject *
object)
const = 0;
1381 void Save(TObject *
object)
const override
1386 for (
auto &item : vector) {
1391 void Load(TObject *
object)
const override
1396 vector.reserve(count);
1397 while (count-- > 0) {
1398 auto &item = vector.emplace_back();
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Default handler for saving/loading an object to/from disk.
void FixPointers(void *object) const override
A post-load callback to fix SL_REF integers into pointers.
void Save(void *object) const override
Save the object to disk.
SaveLoadTable GetDescription() const override
Get the description of the fields in the savegame.
void LoadCheck(void *object) const override
Similar to load, but used only to validate savegames.
SaveLoadCompatTable GetCompatDescription() const override
Get the pre-header description of the fields in the savegame.
void Load(void *object) const override
Load the object from disk.
Handler for saving/loading an object to/from disk.
virtual SaveLoadTable GetDescription() const =0
Get the description of the fields in the savegame.
virtual void Load(void *object) const
Load the object from disk.
virtual SaveLoadCompatTable GetCompatDescription() const =0
Get the pre-header description of the fields in the savegame.
virtual void FixPointers(void *object) const
A post-load callback to fix SL_REF integers into pointers.
virtual void Save(void *object) const
Save the object to disk.
SaveLoadTable GetLoadDescription() const
Get the description for how to load the chunk.
virtual void LoadCheck(void *object) const
Similar to load, but used only to validate savegames.
Default handler for saving/loading a vector to/from disk.
virtual std::vector< TElementType > & GetVector(TObject *object) const =0
Get instance of vector to load/save.
virtual size_t GetLength() const
Get number of elements to load into vector.
AbstractFileType
The different abstract types of files that the system knows about.
FiosType
Elements of a file system that are recognized.
SaveLoadOperation
Operation performed on the file.
DetailedFileType
Kinds of files in each AbstractFileType.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
SaveLoadVersion _sl_version
the major savegame version identifier
uint8_t _sl_minor_version
the minor savegame version, DO NOT USE!
const SaveLoadVersion SAVEGAME_VERSION
current savegame version
SaveOrLoadResult LoadWithFilter(std::shared_ptr< LoadFilter > reader)
Load the game using a (reader) filter.
SaveOrLoadResult SaveWithFilter(std::shared_ptr< SaveFilter > writer, bool threaded)
Save the game using a (writer) filter.
SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded=true)
Main Save or Load function where the high-level saveload functions are handled.
void ProcessAsyncSaveFinish()
Handle async save finishes.
std::string _savegame_format
how to compress savegames
StringID GetSaveLoadErrorMessage()
Return the description of the error.
constexpr bool IsNumericType(VarType conv)
Check if the given saveload type is a numeric type.
VarTypes
VarTypes is the general bitmasked magic type that tells us certain characteristics about the variable...
@ SLE_VAR_NULL
useful to write zeros in savegame.
@ SLE_FILE_END
Used to mark end-of-header in tables.
@ SLE_FILE_TYPE_MASK
Mask to get the file-type (and not any flags).
@ SLE_FILE_HAS_LENGTH_FIELD
Bit stored in savegame to indicate field has a length field for each entry.
@ SLF_ALLOW_NEWLINE
Allow new lines in the strings.
@ SLF_ALLOW_CONTROL
Allow control codes in the strings.
@ SLE_VAR_STR
string pointer
@ SLE_VAR_NAME
old custom name to be converted to a char pointer
@ SLE_VAR_STRQ
string pointer enclosed in quotes
@ SLE_FILE_STRINGID
StringID offset into strings-array.
bool _do_autosave
are we doing an autosave at the moment?
StringID GetSaveLoadErrorType()
Return the appropriate initial string for an error depending on whether we are saving or loading.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
void SlWriteByte(uint8_t b)
Wrapper for writing a byte to the dumper.
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
SaveOrLoadResult
Save or load result codes.
@ SL_ERROR
error that was caught before internal structures were modified
@ SL_OK
completed successfully
@ SL_REINIT
error that was caught in the middle of updating game state, need to clear it. (can only happen during...
void WriteValue(void *ptr, VarType conv, int64_t val)
Write the value of a setting.
ChunkType
Type of a chunk.
@ CH_TYPE_MASK
All ChunkType values have to be within this mask.
@ CH_READONLY
Chunk is never saved.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void SlSkipBytes(size_t length)
Read in bytes from the file/data structure but don't do anything with them, discarding them in effect...
SavegameType
Types of save games.
@ SGT_TTD
TTD savegame (can be detected incorrectly)
@ SGT_INVALID
broken savegame (used internally)
@ SGT_TTDP2
TTDP savegame in new format (data at SE border)
@ SGT_TTDP1
TTDP savegame ( -//- ) (data at NW border)
constexpr size_t SlVarSize(VarType type)
Return expect size in bytes of a VarType.
void SetSaveLoadError(StringID str)
Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friend...
void SlCopy(void *object, size_t length, VarType conv)
Copy a list of SL_VARs to/from a savegame.
size_t SlGetFieldLength()
Get the length of the current object.
void DoAutoOrNetsave(FiosNumberedSaveName &counter)
Create an autosave or netsave.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
constexpr VarType GetVarFileType(VarType type)
Get the FileType of a setting.
void * GetVariableAddress(const void *object, const SaveLoad &sld)
Get the address of the variable.
constexpr bool SlCheckVarSize(SaveLoadType cmd, VarType type, size_t length, size_t size)
Check if a saveload cmd/type/length entry matches the size of the variable.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
Checks if some version from/to combination falls within the range of the active savegame version.
SaveLoadType
Type of data saved.
@ SL_NULL
Save null-bytes and load to nowhere.
@ SL_STRUCTLIST
Save/load a list of structs.
@ SL_STDSTR
Save/load a std::string.
@ SL_REF
Save/load a reference.
@ SL_SAVEBYTE
Save (but not load) a byte.
@ SL_DEQUE
Save/load a deque of SL_VAR elements.
@ SL_STRUCT
Save/load a struct.
@ SL_VECTOR
Save/load a vector of SL_VAR elements.
@ SL_REFVECTOR
Save/load a vector of SL_REF elements.
@ SL_REFLIST
Save/load a list of SL_REF elements.
@ SL_ARR
Save/load a fixed-size array of SL_VAR elements.
@ SL_VAR
Save/load a variable.
bool SaveloadCrashWithMissingNewGRFs()
Did loading the savegame cause a crash? If so, were NewGRFs missing?
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
FileToSaveLoad _file_to_saveload
File to save or load in the openttd loop.
void SlSetLength(size_t length)
Sets the length of either a RIFF object or the number of items in an array.
uint8_t SlReadByte()
Wrapper for reading a byte from the buffer.
void DoExitSave()
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
constexpr VarType GetVarMemType(VarType type)
Get the NumberType of a setting.
size_t SlCalcObjLength(const void *object, const SaveLoadTable &slt)
Calculate the size of an object.
void SlObject(void *object, const SaveLoadTable &slt)
Main SaveLoad function.
SaveLoadVersion
SaveLoad versions Previous savegame versions, the trunk revision where they were introduced and the r...
@ SLV_AI_START_DATE
309 PR#10653 Removal of individual AI start dates and added a generic one.
@ SLV_190
190 26547 Separate order travel and wait times
@ SLV_ECONOMY_MODE_TIMEKEEPING_UNITS
327 PR#11341 Mode to display economy measurements in wallclock units.
@ SLV_CUSTOM_SUBSIDY_DURATION
292 PR#9081 Configurable subsidy duration.
@ SLV_182
182 25115 FS#5492, r25259, r25296 Goal status
@ SLV_186
186 25833 Objects storage
@ SLV_INDUSTRY_TEXT
289 PR#8576 v1.11.0-RC1 Additional GS text for industries.
@ SLV_16
16.0 2817 16.1 3155
@ SLV_SERVE_NEUTRAL_INDUSTRIES
210 PR#7234 Company stations can serve industries with attached neutral stations.
@ SLV_188
188 26169 v1.4 FS#5831 Unify RV travel time
@ SLV_FIX_CARGO_MONITOR
207 PR#7175 v1.9 Cargo monitor data packing fix to support 64 cargotypes.
@ SLV_198
198 PR#6763 Switch town growth rate and counter to actual game ticks
@ SLV_EXTEND_RAILTYPES
200 PR#6805 Extend railtypes to 64, adding uint16_t to map array.
@ SLV_SCRIPT_INT64
296 PR#9415 SQInteger is 64bit but was saved as 32bit.
@ SLV_ROAD_WAYPOINTS
338 PR#12572 Road waypoints
@ SLV_17
17.0 3212 17.1 3218
@ SLV_SHIP_CURVE_PENALTY
209 PR#7289 Configurable ship curve penalties.
@ SLV_EXTEND_INDUSTRY_CARGO_SLOTS
202 PR#6867 Increase industry cargo slots to 16 in, 16 out
@ SLV_GROUP_REPLACE_WAGON_REMOVAL
291 PR#7441 Per-group wagon removal flag.
@ SLV_VELOCITY_NAUTICAL
305 PR#10594 Separation of land and nautical velocity (knots!)
@ SLV_VEHICLE_ECONOMY_AGE
334 PR#12141 v14.0 Add vehicle age in economy year, for profit stats minimum age
@ SLV_4
4.0 1 4.1 122 0.3.3, 0.3.4 4.2 1222 0.3.5 4.3 1417 4.4 1426
@ SLV_AI_LOCAL_CONFIG
332 PR#12003 Config of running AI is stored inside Company.
@ SLV_TOWN_CARGOGEN
208 PR#6965 New algorithms for town building cargo generation.
@ SLV_ROADVEH_PATH_CACHE
211 PR#7261 Add path cache for road vehicles.
@ SLV_LINKGRAPH_SECONDS
308 PR#10610 Store linkgraph update intervals in seconds instead of days.
@ SLV_EXTEND_CARGOTYPES
199 PR#6802 Extend cargotypes to 64
@ SLV_SAVELOAD_LIST_LENGTH
293 PR#9374 Consistency in list length with SL_STRUCT / SL_STRUCTLIST / SL_DEQUE / SL_REFLIST.
@ SLV_SAVEGAME_ID
313 PR#10719 Add an unique ID to every savegame (used to deduplicate surveys).
@ SLV_11
11.0 2033 11.1 2041
@ SLV_CALENDAR_SUB_DATE_FRACT
328 PR#11428 Add sub_date_fract to measure calendar days.
@ SLV_DISASTER_VEH_STATE
312 PR#10798 Explicit storage of disaster vehicle state.
@ SLV_TIMETABLE_START_TICKS
321 PR#11468 Convert timetable start from a date to ticks.
@ SLV_195
195 27572 v1.6.1
@ SLV_START_PATCHPACKS
220 First known patchpack to use a version just above ours.
@ SLV_173
173 23967 1.2.0-RC1
@ SLV_SHIP_ROTATION
204 PR#7065 Add extra rotation stages for ships.
@ SLV_ENDING_YEAR
218 PR#7747 v1.10 Configurable ending year.
@ SLV_191
191 26636 FS#6026 Fix disaster vehicle storage (No bump) 191 26646 FS#6041 Linkgraph - store location...
@ SLV_DOCK_DOCKINGTILES
298 PR#9578 All tiles around docks may be docking tiles.
@ SLV_SHIP_PATH_CACHE
203 PR#7072 Add path cache for ships
@ SLV_RIFF_TO_ARRAY
294 PR#9375 Changed many CH_RIFF chunks to CH_ARRAY chunks.
@ SLV_PATH_CACHE_FORMAT
346 PR#12345 Vehicle path cache format changed.
@ SLV_WATER_TILE_TYPE
342 PR#13030 Simplify water tile type.
@ SLV_13
13.1 2080 0.4.0, 0.4.0.1
@ SLV_ANIMATED_TILE_STATE_IN_MAP
347 PR#13082 Animated tile state saved for improved performance.
@ SLV_MULTITILE_DOCKS
216 PR#7380 Multiple docks per station.
@ SLV_ROAD_TYPES
214 PR#6811 NewGRF road types.
@ SLV_LINKGRAPH_EDGES
304 PR#10314 Explicitly store link graph edges destination, PR#10471 int64_t instead of uint64_t leag...
@ SL_MAX_VERSION
Highest possible saveload version.
@ SLV_GS_INDUSTRY_CONTROL
287 PR#7912 and PR#8115 GS industry control.
@ SL_MIN_VERSION
First savegame version.
@ SLV_VEH_MOTION_COUNTER
288 PR#8591 Desync safe motion counter
@ SLV_EXTEND_VEHICLE_RANDOM
310 PR#10701 Extend vehicle random bits.
@ SLV_TRADING_AGE
217 PR#7780 Configurable company trading age.
@ SLV_CARGO_TRAVELLED
319 PR#11283 CargoPacket now tracks how far it travelled inside a vehicle.
@ SLV_PRODUCTION_HISTORY
343 PR#10541 Industry production history.
@ SLV_NEWGRF_ROAD_STOPS
303 PR#10144 NewGRF road stops.
@ SLV_2
2.0 0.3.0 2.1 0.3.1, 0.3.2
@ SLV_INCREASE_HOUSE_LIMIT
348 PR#12288 Increase house limit to 4096.
@ SLV_EXTEND_PERSISTENT_STORAGE
201 PR#6885 Extend NewGRF persistent storages.
@ SLV_187
187 25899 Linkgraph - restricted flows
@ SLV_END_PATCHPACKS
286 Last known patchpack to use a version just above ours.
@ SLV_LAST_LOADING_TICK
301 PR#9693 Store tick of last loading for vehicles.
@ SLV_GROUP_LIVERIES
205 PR#7108 Livery storage change and group liveries.
@ SLV_SCRIPT_RANDOMIZER
333 PR#12063 v14.0-RC1 Save script randomizers.
@ SLV_COMPANY_INAUGURATED_PERIOD
339 PR#12798 Companies show the period inaugurated in wallclock mode.
@ SLV_DEPOT_UNBUNCHING
331 PR#11945 Allow unbunching shared order vehicles at a depot.
@ SLV_COMPANY_ALLOW_LIST_V2
341 PR#12908 Fixed savegame format for saving of list of client keys that are allowed to join this co...
@ SLV_SHIP_ACCELERATION
329 PR#10734 Start using Vehicle's acceleration field for ships too.
@ SLV_REMOVE_OPF
212 PR#7245 Remove OPF.
@ SLV_MULTITRACK_LEVEL_CROSSINGS
302 PR#9931 v13.0 Multi-track level crossings.
@ SLV_192
192 26700 FS#6066 Fix saving of order backups
@ SLV_COMPANY_ALLOW_LIST
335 PR#12337 Saving of list of client keys that are allowed to join this company.
@ SLV_ECONOMY_DATE
326 PR#10700 Split calendar and economy timers and dates.
@ SLV_TIMETABLE_START_TICKS_FIX
322 PR#11557 Fix for missing convert timetable start from a date to ticks.
@ SLV_189
189 26450 Hierarchical vehicle subgroups
@ SLV_TIMETABLE_TICKS_TYPE
323 PR#11435 Convert timetable current order time to ticks.
@ SLV_185
185 25620 Storybooks
@ SLV_LINKGRAPH_TRAVEL_TIME
297 PR#9457 v12.0-RC1 Store travel time in the linkgraph.
@ SLV_GROUP_NUMBERS
336 PR#12297 Add per-company group numbers.
@ SLV_5
5.0 1429 5.1 1440 5.2 1525 0.3.6
@ SLV_NEWGRF_LAST_SERVICE
317 PR#11124 Added stable date_of_last_service to avoid NewGRF trouble.
@ SLV_STATION_RATING_CHEAT
320 PR#11346 Add cheat to fix station ratings at 100%.
@ SLV_184
184 25508 Unit localisation split
@ SLV_INDUSTRY_CARGO_REORGANISE
315 PR#10853 Industry accepts/produced data reorganised.
@ SLV_INCREASE_STATION_TYPE_FIELD_SIZE
337 PR#12572 Increase size of StationType field in map array
@ SLV_WATER_REGIONS
324 PR#10543 Water Regions for ship pathfinder.
@ SLV_NONFLOODING_WATER_TILES
345 PR#13013 Store water tile non-flooding state.
@ SLV_MAPGEN_SETTINGS_REVAMP
290 PR#8891 v1.11 Revamp of some mapgen settings (snow coverage, desert coverage, heightmap height,...
@ SLV_ROAD_TYPE_LABEL_MAP
344 PR#13021 Add road type label map to allow upgrade/conversion of road types.
@ SLV_STRING_GAMELOG
314 PR#10801 Use std::string in gamelog.
@ SLV_PERIODS_IN_TRANSIT_RENAME
316 PR#11112 Rename days in transit to (cargo) periods in transit.
@ SLV_TABLE_CHUNKS
295 PR#9322 Introduction of CH_TABLE and CH_SPARSE_TABLE.
@ SLV_MORE_CARGO_AGE
307 PR#10596 Track cargo age for a longer period.
@ SLV_TREES_WATER_CLASS
213 PR#7405 WaterClass update for tree tiles.
@ SLV_REMOVE_LOADED_AT_XY
318 PR#11276 Remove loaded_at_xy variable from CargoPacket.
@ SLV_SHIPS_STOP_IN_LOCKS
206 PR#7150 Ship/lock movement changes.
@ SLV_REMOVE_TOWN_CARGO_CACHE
219 PR#8258 Remove town cargo acceptance and production caches.
@ SLV_183
183 25363 Cargodist
@ SLV_REPAIR_OBJECT_DOCKING_TILES
299 PR#9594 v12.0 Fixing issue with docking tiles overlapping objects.
@ SLV_CONSISTENT_PARTIAL_Z
306 PR#10570 Conversion from an inconsistent partial Z calculation for slopes, to one that is (more) ...
@ SLV_EXTEND_ENTITY_MAPPING
311 PR#10672 Extend entity mapping range.
@ SLV_SCRIPT_MEMLIMIT
215 PR#7516 Limit on AI/GS memory consumption.
@ SLV_WATER_REGION_EVAL_SIMPLIFIED
325 PR#11750 Simplified Water Region evaluation.
@ SLV_MAX_LOAN_FOR_COMPANY
330 PR#11224 Separate max loan for each company.
@ SLV_ROAD_STOP_TILE_DATA
340 PR#12883 Move storage of road stop tile data, also save for road waypoints.
@ SLV_U64_TICK_COUNTER
300 PR#10035 Make tick counter 64bit to avoid wrapping.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
int64_t ReadValue(const void *ptr, VarType conv)
Return a signed-long version of the value of a setting.
bool IsSavegameVersionBeforeOrAt(SaveLoadVersion major)
Checks whether the savegame is below or at major.
SLRefType
Type of reference (SLE_REF, SLE_CONDREF).
@ REF_VEHICLE_OLD
Load/save an old-style reference to a vehicle (for pre-4.4 savegames).
@ REF_LINK_GRAPH_JOB
Load/save a reference to a link graph job.
@ REF_TOWN
Load/save a reference to a town.
@ REF_LINK_GRAPH
Load/save a reference to a link graph.
@ REF_CARGO_PACKET
Load/save a reference to a cargo packet.
@ REF_ENGINE_RENEWS
Load/save a reference to an engine renewal (autoreplace).
@ REF_STATION
Load/save a reference to a station.
@ REF_ORDER
Load/save a reference to an order.
@ REF_ORDERLIST
Load/save a reference to an orderlist.
@ REF_STORAGE
Load/save a reference to a persistent storage.
@ REF_VEHICLE
Load/save a reference to a vehicle.
@ REF_ROADSTOPS
Load/save a reference to a bus/truck stop.
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
void SlGlobList(const SaveLoadTable &slt)
Save or Load (a list of) global variables.
std::string GenerateDefaultSaveName()
Get the default name for a savegame or screenshot.
void SlAutolength(AutolengthProc *proc, int arg)
Do something of which I have no idea what it is :P.
void SlSetStructListLength(size_t length)
Set the length of this list.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Handlers and description of chunk.
virtual void FixPointers() const
Fix the pointers.
ChunkType type
Type of the chunk.
virtual void LoadCheck(size_t len=0) const
Load the chunk for game preview.
virtual void Load() const =0
Load the chunk.
uint32_t id
Unique ID (4 letters).
virtual void Save() const
Save the chunk.
Deals with the type of the savegame, independent of extension.
AbstractFileType abstract_ftype
Abstract type of file (scenario, heightmap, etc).
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...
DetailedFileType detail_ftype
Concrete file type (PNG, BMP, old save, etc).
std::string title
Internal name of the game.
SaveLoadOperation file_op
File operation to perform.
std::string name
Name of the file.
void Set(const FiosItem &item)
Set the title of the file.
Deals with finding savegames.
A savegame name automatically numbered.
SaveLoad information for backwards compatibility.
VarTypes null_type
The type associated with the NULL field; defaults to SLE_FILE_U8 to just count bytes.
std::string name
Name of the field.
SaveLoadVersion version_to
Save/load the variable before this savegame version.
SaveLoadVersion version_from
Save/load the variable starting from this savegame version.
uint16_t null_length
Length of the NULL field.
uint16_t length
(Conditional) length of the variable (eg. arrays) (max array size is 65536 elements).
std::shared_ptr< SaveLoadHandler > handler
Custom handler for Save/Load procs.
SaveLoadAddrProc * address_proc
Callback proc the get the actual variable address in memory.
SaveLoadVersion version_to
Save/load the variable before this savegame version.
SaveLoadType cmd
The action to take with the saved/loaded type, All types need different action.
std::string name
Name of this field (optional, used for tables).
VarType conv
Type of the variable to be saved; this field combines both FileVarType and MemVarType.
size_t extra_data
Extra data for the callback proc.
SaveLoadVersion version_from
Save/load the variable starting from this savegame version.