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