OpenTTD Source 20261112-master-gbcbec5e63f
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef SAVELOAD_H
11#define SAVELOAD_H
12
13#include "saveload_type.h"
15#include "../autoreplace_base.h"
16#include "../cargopacket.h"
19#include "../string_type.h"
20#include "../town.h"
21
35enum class SaveLoadVersion : uint16_t {
37
48
57
64
72
78
84
90
96
102
108
114
120
126
132
138
144
150
156
162
168
174
180
186
192
198
204
210
216
222
228
234
240
242 PersistentStoragePool,
246
252
258
264
270
276
282
288
292 ShipPathCache,
294
300
306
312
313 /* Patchpacks for a while considered it a good idea to jump a few versions
314 * above our version for their savegames. But as time continued, this gap
315 * has been closing, up to the point we would start to reuse versions from
316 * their patchpacks. This is not a problem from our perspective: the
317 * savegame will simply fail to load because they all contain chunks we
318 * cannot digest. But, this gives for ugly errors. As we have plenty of
319 * versions anyway, we simply skip the versions we know belong to
320 * patchpacks. This way we can present the user with a clean error
321 * indicate they are loading a savegame from a patchpack.
322 * For future patchpack creators: please follow a system like JGRPP, where
323 * the version is masked with 0x8000, and the true version is stored in
324 * its own chunk with feature toggles.
325 */
328
332
338
344
350
356
362
368
374
380
386
392
398
404
410
416
422
427
429};
430
440void SetSaveLoadError(StringID str);
441
442typedef void AutolengthProc(int);
443
445enum class ChunkType : uint8_t {
446 Riff = 0,
447 Array = 1,
449 Table = 3,
451
454};
455
458
463
470
472 virtual ~ChunkHandler() = default;
473
478 virtual void Save() const { NOT_REACHED(); }
479
484 virtual void Load() const = 0;
485
492 virtual void FixPointers() const {}
493
499 virtual void LoadCheck(size_t len = 0) const;
500
505 std::string GetName() const
506 {
507 return this->id.AsString();
508 }
509};
510
512using ChunkHandlerRef = std::reference_wrapper<const ChunkHandler>;
513
515using ChunkHandlerTable = std::span<const ChunkHandlerRef>;
516
518using SaveLoadCompatTable = std::span<const struct SaveLoadCompat>;
519
522public:
523 std::optional<std::vector<SaveLoad>> load_description;
524
526 virtual ~SaveLoadHandler() = default;
527
532 virtual void Save([[maybe_unused]] void *object) const {}
533
538 virtual void Load([[maybe_unused]] void *object) const {}
539
544 virtual void LoadCheck([[maybe_unused]] void *object) const {}
545
550 virtual void FixPointers([[maybe_unused]] void *object) const {}
551
556 virtual SaveLoadTable GetDescription() const = 0;
557
563
571};
572
584template <class TImpl, class TObject>
586public:
587 SaveLoadTable GetDescription() const override { return static_cast<const TImpl *>(this)->description; }
588
589 SaveLoadCompatTable GetCompatDescription() const override { return static_cast<const TImpl *>(this)->compat_description; }
590
595 virtual void Save([[maybe_unused]] TObject *object) const {}
596 void Save(void *object) const override { this->Save(static_cast<TObject *>(object)); }
597
602 virtual void Load([[maybe_unused]] TObject *object) const {}
603 void Load(void *object) const override { this->Load(static_cast<TObject *>(object)); }
604
609 virtual void LoadCheck([[maybe_unused]] TObject *object) const {}
610 void LoadCheck(void *object) const override { this->LoadCheck(static_cast<TObject *>(object)); }
611
616 virtual void FixPointers([[maybe_unused]] TObject *object) const {}
617 void FixPointers(void *object) const override { this->FixPointers(static_cast<TObject *>(object)); }
618};
619
634
636enum class VarFileType : uint8_t {
637 /* 4 bits allocated a maximum of 16 types for NumberType.
638 * NOTE: the SLE_FILE_NNN values are stored in the savegame! */
639 /* Value 0 is used to mark end-of-header in tables. Do not use here! */
640 I8 = 1,
642 U8 = 2,
643 I16 = 3,
644 U16 = 4,
645 I32 = 5,
646 U32 = 6,
648 I64 = 7,
649 U64 = 8,
651 String = 10,
652 Struct = 11,
653 /* 4 more possible file-primitives */
654};
655
657enum class VarMemType : uint8_t {
658 Bool = 0,
659 I8 = 1,
660 U8 = 2,
661 I16 = 3,
662 U16 = 4,
663 I32 = 5,
664 U32 = 6,
665 I64 = 7,
666 U64 = 8,
667 Null = 9,
668 Str = 12,
669 Name = 14,
670 Label = 15,
671};
672
710
727
729enum class SaveLoadType : uint8_t {
732 Struct = 2,
733
734 String = 4,
735
736 Array = 5,
737 Vector = 7,
740
741 SaveByte = 10,
742 Null = 11,
743
745};
746
753#define SLE_OBJECT_ADDRESS(base, variable) +[] (const void *b, size_t) -> const auto * { return std::addressof(static_cast<const base *>(b)->variable); }
754
760#define SLE_GLOBAL_ADDRESS(variable) +[] (const void *, size_t) -> const auto * { return std::addressof(variable); }
761
763struct SaveLoad {
772 template <typename R = void>
773 using AddressFunction = const R *(*)(const void *base, size_t extra);
774
775 std::string name;
778 uint16_t length{};
782 size_t extra_data = 0;
783 std::shared_ptr<SaveLoadHandler> handler{};
784
790 static constexpr bool IsIntegralFileType(VarFileType file_type)
791 {
792 switch (file_type) {
793 case VarFileType::I8:
794 case VarFileType::U8:
795 case VarFileType::I16:
796 case VarFileType::U16:
797 case VarFileType::I32:
798 case VarFileType::U32:
799 case VarFileType::I64:
800 case VarFileType::U64:
801 return true;
802
803 default:
804 return false;
805 }
806 }
807
816 template <typename T, VarFileType file_type>
817 static constexpr VarMemType DetermineMemType()
818 {
819 if constexpr (std::is_base_of_v<BaseLabel, T>) {
820 static_assert(file_type == VarFileType::Label);
821 return VarMemType::Label;
822 } else if constexpr (std::is_same_v<StringID, T>) {
823 static_assert(file_type == VarFileType::StringID);
824 static_assert(sizeof(T) == sizeof(uint32_t));
825 return VarMemType::U32;
826 } else if constexpr (std::is_same_v<bool, T>) {
827 static_assert(file_type == VarFileType::Bool);
828 return VarMemType::Bool;
829 } else if constexpr (std::is_same_v<int8_t, T>) {
830 static_assert(IsIntegralFileType(file_type));
831 return VarMemType::I8;
832 } else if constexpr (std::is_same_v<uint8_t, T> || std::is_same_v<char, T>) {
833 static_assert(IsIntegralFileType(file_type));
834 return VarMemType::U8;
835 } else if constexpr (std::is_same_v<int16_t, T>) {
836 static_assert(IsIntegralFileType(file_type));
837 return VarMemType::I16;
838 } else if constexpr (std::is_same_v<uint16_t, T>) {
839 static_assert(IsIntegralFileType(file_type));
840 return VarMemType::U16;
841 } else if constexpr (std::is_same_v<int32_t, T>) {
842 static_assert(IsIntegralFileType(file_type));
843 return VarMemType::I32;
844 } else if constexpr (std::is_same_v<uint32_t, T>) {
845 static_assert(IsIntegralFileType(file_type));
846 return VarMemType::U32;
847 } else if constexpr (std::is_same_v<int64_t, T>) {
848 static_assert(IsIntegralFileType(file_type));
849 return VarMemType::I64;
850 } else if constexpr (std::is_same_v<uint64_t, T>) {
851 static_assert(IsIntegralFileType(file_type));
852 return VarMemType::U64;
853 } else if constexpr (std::is_same_v<std::string, T>) {
854 if constexpr (file_type == VarFileType::StringID) {
855 return VarMemType::Name; // Special transitional case for migrating from StringID to std::string.
856 } else {
857 static_assert(file_type == VarFileType::String);
858 return VarMemType::Str;
859 }
860 } else if constexpr (std::is_enum_v<T>) {
862 } else if constexpr (requires { typename T::value_type; }) {
864 } else {
865 /* If in the following assert bare false is used the compilation fails on gcc 12.2.0. */
866 static_assert(ConvertibleThroughBase<T>, "The given type is not supported");
868 }
869 }
870
877 template <typename T>
878 static constexpr bool IsValidRefType(SLRefType ref_type)
879 {
880 switch (ref_type) {
881 case SLRefType::OldVehicle: // Old vehicles we save as new ones
882 case SLRefType::Vehicle: return std::is_base_of_v<Vehicle, T>;
883 case SLRefType::Station: return std::is_base_of_v<BaseStation, T>;
884 case SLRefType::Town: return std::is_same_v<Town, T>;
885 case SLRefType::RoadStop: return std::is_same_v<RoadStop, T>;
886 case SLRefType::EngineRenew: return std::is_same_v<EngineRenew, T>;
887 case SLRefType::CargoPacket: return std::is_same_v<CargoPacket, T>;
888 case SLRefType::OrderList: return std::is_same_v<OrderList, T>;
889 case SLRefType::Storage: return std::is_same_v<PersistentStorage, T>;
890 case SLRefType::LinkGraph: return std::is_same_v<LinkGraph, T>;
891 case SLRefType::LinkGraphJob: return std::is_same_v<LinkGraphJob, T>;
892 default: NOT_REACHED(); // Add a check for the new reference type above here.
893 }
894 }
895
904 template <typename T>
906 {
907 /* The reinterpret_cast is nasty, but we are only casting away the type of the return. */
908 static_assert(std::is_same_v<AddressFunction<>, decltype(ToAddressFunction<void>(nullptr))>);
909 return reinterpret_cast<AddressFunction<>>(address_func);
910 }
911
912
924 template <VarFileType file_type, typename T>
927 {
928 return SaveLoad{
929 .name = std::move(name),
931 .conv = {file_type, DetermineMemType<T, file_type>()},
932 .version_from = from,
933 .version_to = to,
934 .address_func = ToAddressFunction(address_func),
935 .extra_data = extra,
936 };
937 }
938
949 template <SLRefType type, typename T>
952 {
953 static_assert(requires { typename std::remove_pointer_t<T>::Pool; });
954 return SaveLoad{
955 .name = std::move(name),
957 .conv = type,
958 .version_from = from,
959 .version_to = to,
960 .address_func = ToAddressFunction(address_func),
961 };
962 }
963
975 template <typename T>
976 static SaveLoad String(std::string name, AddressFunction<T> address_func, StringValidationSettings string_validation_settings = {},
978 {
979 static_assert(std::is_same_v<std::string, T> || std::is_same_v<EncodedString, T>);
980 return SaveLoad{
981 .name = std::move(name),
983 .conv = string_validation_settings,
984 .version_from = from,
985 .version_to = to,
986 .address_func = ToAddressFunction(address_func),
987 .extra_data = extra,
988 };
989 }
990
999 template <typename T> requires std::is_base_of_v<SaveLoadHandler, T>
1000 static SaveLoad Struct(std::string name,
1002 {
1003 return SaveLoad{
1004 .name = std::move(name),
1005 .cmd = SaveLoadType::Struct,
1006 .version_from = from,
1007 .version_to = to,
1008 .handler = std::make_shared<T>(),
1009 };
1010 }
1011
1024 template <VarFileType file_type, uint16_t length, typename T>
1027 {
1028 static_assert(SlVarSize(DetermineMemType<T, file_type>()) * length <= sizeof(T)); // Partial setting/filling of an array is permitted.
1029 return SaveLoad{
1030 .name = std::move(name),
1031 .cmd = SaveLoadType::Array,
1032 .conv = {file_type, DetermineMemType<T, file_type>()},
1033 .length = length,
1034 .version_from = from,
1035 .version_to = to,
1036 .address_func = ToAddressFunction(address_func),
1037 .extra_data = extra,
1038 };
1039 }
1040
1051 template <VarFileType file_type, typename T>
1054 {
1055 static_assert(std::is_base_of_v<std::vector<typename T::value_type>, T>);
1056 return SaveLoad{
1057 .name = std::move(name),
1058 .cmd = SaveLoadType::Vector,
1060 .version_from = from,
1061 .version_to = to,
1062 .address_func = ToAddressFunction(address_func),
1063 };
1064 }
1065
1076 template <SLRefType type, typename T>
1079 {
1080 static_assert(std::is_base_of_v<std::list<typename T::value_type>, T>);
1081 static_assert(requires { typename std::remove_pointer_t<typename T::value_type>::Pool; });
1083 return SaveLoad{
1084 .name = std::move(name),
1086 .conv = type,
1087 .version_from = from,
1088 .version_to = to,
1089 .address_func = ToAddressFunction(address_func),
1090 };
1091 }
1092
1101 template <typename T> requires std::is_base_of_v<SaveLoadHandler, T>
1102 static SaveLoad StructList(std::string name,
1104 {
1105 return SaveLoad{
1106 .name = std::move(name),
1108 .version_from = from,
1109 .version_to = to,
1110 .handler = std::make_shared<T>(),
1111 };
1112 }
1113
1123 template <typename T>
1126 {
1127 return SaveLoad{
1128 .name = std::move(name),
1131 .version_from = from,
1132 .version_to = to,
1133 .address_func = ToAddressFunction(address_func),
1134 };
1135 }
1136
1147 template <SLRefType type, typename T>
1150 {
1151 static_assert(std::is_base_of_v<std::vector<typename T::value_type>, T>);
1152 static_assert(requires { typename std::remove_pointer_t<typename T::value_type>::Pool; });
1154 return SaveLoad{
1155 .name = std::move(name),
1157 .conv = type,
1158 .version_from = from,
1159 .version_to = to,
1160 .address_func = ToAddressFunction(address_func),
1161 };
1162 }
1163};
1164
1179
1185constexpr size_t SlVarSize(VarMemType type)
1186{
1187 switch (type) {
1188 case VarMemType::Bool: return sizeof(bool);
1189 case VarMemType::I8: return sizeof(int8_t);
1190 case VarMemType::U8: return sizeof(uint8_t);
1191 case VarMemType::I16: return sizeof(int16_t);
1192 case VarMemType::U16: return sizeof(uint16_t);
1193 case VarMemType::I32: return sizeof(int32_t);
1194 case VarMemType::U32: return sizeof(uint32_t);
1195 case VarMemType::I64: return sizeof(int64_t);
1196 case VarMemType::U64: return sizeof(uint64_t);
1197 case VarMemType::Null: return sizeof(void *);
1198 case VarMemType::Str: return sizeof(std::string);
1199 case VarMemType::Name: return sizeof(std::string);
1200 case VarMemType::Label: return sizeof(BaseLabel);
1201 default: NOT_REACHED();
1202 }
1203}
1204
1209#define SLC_VAR(name) {name, 0, SaveLoadVersion::MinVersion, SaveLoadVersion::MaxVersion}
1210
1217#define SLC_NULL(length, from, to) {{}, length, from, to}
1218
1225inline bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor = 0)
1226{
1228 extern uint8_t _sl_minor_version;
1229 return _sl_version < major || (minor > 0 && _sl_version == major && _sl_minor_version < minor);
1230}
1231
1240{
1242 return _sl_version <= major;
1243}
1244
1252inline bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
1253{
1254 extern const SaveLoadVersion SAVEGAME_VERSION;
1255 return version_from <= SAVEGAME_VERSION && SAVEGAME_VERSION < version_to;
1256}
1257
1266inline void *GetVariableAddress(const void *object, const SaveLoad &sld)
1267{
1268 /* Entry is a null-variable, mostly used to read old savegames etc. */
1269 if (sld.conv.mem == VarMemType::Null) {
1270 assert(sld.address_func == nullptr);
1271 return nullptr;
1272 }
1273
1274 /* Everything else should be a non-null pointer. */
1275 assert(sld.address_func != nullptr);
1276 return const_cast<void *>(sld.address_func(object, sld.extra_data));
1277}
1278
1279int64_t ReadValue(const void *ptr, VarMemType conv);
1280void WriteValue(void *ptr, VarMemType conv, int64_t val);
1281
1282void SlSetArrayIndex(uint index);
1283static void SlSetArrayIndex(const ConvertibleThroughBase auto &index) { SlSetArrayIndex(index.base()); }
1284int SlIterateArray();
1285
1286void SlSetStructListLength(size_t length);
1287size_t SlGetStructListLength(size_t limit);
1288
1289void SlAutolength(AutolengthProc *proc, int arg);
1290size_t SlGetFieldLength();
1291void SlSetLength(size_t length);
1292size_t SlCalcObjMemberLength(const void *object, const SaveLoad &sld);
1293size_t SlCalcObjLength(const void *object, const SaveLoadTable &slt);
1294
1295uint8_t SlReadByte();
1296void SlReadString(std::string &str, size_t length);
1297void SlWriteByte(uint8_t b);
1298
1299void SlGlobList(const SaveLoadTable &slt);
1300void SlCopy(void *object, size_t length, VarType conv);
1301std::vector<SaveLoad> SlTableHeader(const SaveLoadTable &slt);
1302std::vector<SaveLoad> SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct);
1303void SlObject(void *object, const SaveLoadTable &slt);
1304
1311template <VarFileType file_type, typename T>
1312static inline void SlCopy(T &collection)
1313{
1314 std::span span{collection}; // Let std::span worry about what is passed being a contiguous container.
1315 SlCopy(span.data(), span.size(), {file_type, SaveLoad::DetermineMemType<std::remove_const_t<typename T::value_type>, file_type>()});
1316}
1317
1323inline void SlSkipBytes(size_t length)
1324{
1325 for (; length != 0; length--) SlReadByte();
1326}
1327
1339template <class TImpl, class TObject, class TElementType, size_t MAX_LENGTH = UINT32_MAX>
1340class VectorSaveLoadHandler : public DefaultSaveLoadHandler<TImpl, TObject> {
1341public:
1347 virtual std::vector<TElementType> &GetVector(TObject *object) const = 0;
1348
1354 virtual size_t GetLength() const { return SlGetStructListLength(MAX_LENGTH); }
1355
1356 void Save(TObject *object) const override
1357 {
1358 auto &vector = this->GetVector(object);
1359 SlSetStructListLength(vector.size());
1360
1361 for (auto &item : vector) {
1362 SlObject(&item, this->GetDescription());
1363 }
1364 }
1365
1366 void Load(TObject *object) const override
1367 {
1368 auto &vector = this->GetVector(object);
1369 size_t count = this->GetLength();
1370
1371 vector.reserve(count);
1372 while (count-- > 0) {
1373 auto &item = vector.emplace_back();
1374 SlObject(&item, this->GetLoadDescription());
1375 }
1376 }
1377};
1378
1379#endif /* SAVELOAD_H */
Base class for autoreplaces/autorenews.
Pool< EngineRenew, EngineRenewID, 16 > EngineRenewPool
Memory pool for engine renew elements.
Base class for cargo packets.
Action of reserving cargo from a station to be loaded onto a vehicle.
Default handler for saving/loading an object to/from disk.
Definition saveload.h:585
void FixPointers(void *object) const override
A post-load callback to fix SaveLoadType::Reference integers into pointers.
Definition saveload.h:617
virtual void Load(TObject *object) const
Load the object from disk.
Definition saveload.h:602
void Save(void *object) const override
Save the object to disk.
Definition saveload.h:596
virtual void FixPointers(TObject *object) const
A post-load callback to fix SaveLoadType::Reference integers into pointers.
Definition saveload.h:616
SaveLoadTable GetDescription() const override
Get the description of the fields in the savegame.
Definition saveload.h:587
void LoadCheck(void *object) const override
Similar to load, but used only to validate savegames.
Definition saveload.h:610
SaveLoadCompatTable GetCompatDescription() const override
Get the pre-header description of the fields in the savegame.
Definition saveload.h:589
virtual void LoadCheck(TObject *object) const
Similar to load, but used only to validate savegames.
Definition saveload.h:609
void Load(void *object) const override
Load the object from disk.
Definition saveload.h:603
virtual void Save(TObject *object) const
Save the object to disk.
Definition saveload.h:595
Class for calculation jobs to be run on link graphs.
A connected component of a link graph.
Definition linkgraph.h:35
Handler for saving/loading an object to/from disk.
Definition saveload.h:521
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.
Definition saveload.h:538
virtual SaveLoadCompatTable GetCompatDescription() const =0
Get the pre-header description of the fields in the savegame.
std::optional< std::vector< SaveLoad > > load_description
Description derived from savegame being loaded.
Definition saveload.h:523
virtual void FixPointers(void *object) const
A post-load callback to fix SaveLoadType::Reference integers into pointers.
Definition saveload.h:550
virtual void Save(void *object) const
Save the object to disk.
Definition saveload.h:532
virtual ~SaveLoadHandler()=default
Ensure the destructor of the sub classes are called as well.
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.
Definition saveload.h:544
Default handler for saving/loading a vector to/from disk.
Definition saveload.h:1340
virtual std::vector< TElementType > & GetVector(TObject *object) const =0
Get instance of vector to load/save.
void Load(TObject *object) const override
Load the object from disk.
Definition saveload.h:1366
void Save(TObject *object) const override
Save the object to disk.
Definition saveload.h:1356
virtual size_t GetLength() const
Get number of elements to load into vector.
Definition saveload.h:1354
A type is considered 'convertible through base()' when it has a 'base()' function that returns someth...
#define T
Climate temperate.
Definition engines.h:91
SaveLoadVersion _sl_version
the major savegame version identifier
Definition saveload.cpp:84
uint8_t _sl_minor_version
the minor savegame version, DO NOT USE!
Definition saveload.cpp:85
const SaveLoadVersion SAVEGAME_VERSION
current savegame version
A type for 4 character labels/tags/ids in files that should be read/shown as is.
Declaration of link graph classes used for cargo distribution.
Declaration of link graph job classes used for cargo distribution.
EnumBitSet< PauseMode, uint8_t > PauseModes
Bitset of PauseMode elements.
Definition openttd.h:83
EnumBitSet< RoadType, uint64_t > RoadTypes
Bitset of RoadType elements.
Definition road_type.h:33
VarMemType
The types/structures of data we have in memory.
Definition saveload.h:657
@ U64
A 64 bit unsigned int.
Definition saveload.h:666
@ Name
old custom name to be converted to a string pointer
Definition saveload.h:669
@ I8
A 8 bit signed int.
Definition saveload.h:659
@ U8
A 8 bit unsigned int.
Definition saveload.h:660
@ Label
A 4 character Label, stored as-is.
Definition saveload.h:670
@ Null
useful to write zeros in savegame.
Definition saveload.h:667
@ I16
A 16 bit signed int.
Definition saveload.h:661
@ Bool
A boolean value.
Definition saveload.h:658
@ U32
A 32 bit unsigned int.
Definition saveload.h:664
@ I32
A 32 bit signed int.
Definition saveload.h:663
@ I64
A 64 bit signed int.
Definition saveload.h:665
@ Str
string pointer
Definition saveload.h:668
@ U16
A 16 bit unsigned int.
Definition saveload.h:662
VarFileType
The types/structures of data that can be stored in the file.
Definition saveload.h:636
@ String
A string.
Definition saveload.h:651
@ U64
A 64 bit unsigned int.
Definition saveload.h:649
@ I8
A 8 bit signed int.
Definition saveload.h:640
@ U8
A 8 bit unsigned int.
Definition saveload.h:642
@ Struct
An arbitrary structure.
Definition saveload.h:652
@ Label
A label is stored in an 32 bit unsigned integer field.
Definition saveload.h:647
@ I16
A 16 bit signed int.
Definition saveload.h:643
@ Bool
A bool is stored in an 8 bit signed integer field.
Definition saveload.h:641
@ U32
A 32 bit unsigned int.
Definition saveload.h:646
@ StringID
StringID offset into strings-array.
Definition saveload.h:650
@ I32
A 32 bit signed int.
Definition saveload.h:645
@ I64
A 64 bit signed int.
Definition saveload.h:648
@ U16
A 16 bit unsigned int.
Definition saveload.h:644
SavegameType
Types of save games.
Definition saveload.h:432
@ TTDP1
TTDP savegame ( -//- ) (data at NW border).
Definition saveload.h:434
@ TTO
TTO savegame.
Definition saveload.h:437
@ TTD
TTD savegame (can be detected incorrectly).
Definition saveload.h:433
@ TTDP2
TTDP savegame in new format (data at SE border).
Definition saveload.h:435
@ Invalid
broken savegame (used internally)
Definition saveload.h:438
@ OTTD
OTTD savegame.
Definition saveload.h:436
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.
Definition saveload.cpp:422
size_t SlGetStructListLength(size_t limit)
Get the length of this list; if it exceeds the limit, error out.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
Definition saveload.cpp:748
void SlSkipBytes(size_t length)
Read in bytes from the file/data structure but don't do anything with them, discarding them in effect...
Definition saveload.h:1323
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 SaveLoadType::Variables to/from a savegame.
size_t SlGetFieldLength()
Get the length of the current object.
Definition saveload.cpp:874
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
Definition saveload.h:512
SLRefType
Type of reference (SaveLoad::Reference, SaveLoad::ReferenceList, SaveLoad::ReferenceVector).
Definition saveload.h:621
@ LinkGraph
Load/save a reference to a link graph.
Definition saveload.h:631
@ CargoPacket
Load/save a reference to a cargo packet.
Definition saveload.h:628
@ OrderList
Load/save a reference to an orderlist.
Definition saveload.h:629
@ Station
Load/save a reference to a station.
Definition saveload.h:623
@ OldVehicle
Load/save an old-style reference to a vehicle (for pre-4.4 savegames).
Definition saveload.h:625
@ Storage
Load/save a reference to a persistent storage.
Definition saveload.h:630
@ EngineRenew
Load/save a reference to an engine renewal (autoreplace).
Definition saveload.h:627
@ Town
Load/save a reference to a town.
Definition saveload.h:624
@ LinkGraphJob
Load/save a reference to a link graph job.
Definition saveload.h:632
@ Vehicle
Load/save a reference to a vehicle.
Definition saveload.h:622
@ RoadStop
Load/save a reference to a bus/truck stop.
Definition saveload.h:626
void * GetVariableAddress(const void *object, const SaveLoad &sld)
Get the address of the variable.
Definition saveload.h:1266
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
Definition saveload.h:515
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:1252
SaveLoadType
Type of data saved.
Definition saveload.h:729
@ ReferenceList
Save/load a list of SaveLoadType::Reference elements.
Definition saveload.h:738
@ String
Save/load a std::string.
Definition saveload.h:734
@ Array
Save/load a fixed-size array of SaveLoadType::Variable elements.
Definition saveload.h:736
@ Variable
Save/load a variable.
Definition saveload.h:730
@ Vector
Save/load a vector of SaveLoadType::Variable elements.
Definition saveload.h:737
@ Reference
Save/load a reference.
Definition saveload.h:731
@ StructList
Save/load a list of structs.
Definition saveload.h:739
@ Struct
Save/load a struct.
Definition saveload.h:732
@ SaveByte
Save (but not load) a byte.
Definition saveload.h:741
@ ReferenceVector
Save/load a vector of SaveLoadType::Reference elements.
Definition saveload.h:744
void WriteValue(void *ptr, VarMemType conv, int64_t val)
Write the value of a setting.
Definition saveload.cpp:910
std::span< const struct SaveLoadCompat > SaveLoadCompatTable
A table of SaveLoadCompat entries.
Definition saveload.h:518
void SlSetLength(size_t length)
Sets the length of either a RIFF object or the number of items in an array.
Definition saveload.cpp:802
uint8_t SlReadByte()
Wrapper for reading a byte from the buffer.
Definition saveload.cpp:413
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
Definition saveload.h:1225
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...
Definition saveload.h:35
@ LastLoadingTick
Saveload version: 301, GitHub pull request: 9693 Store tick of last loading for vehicles.
Definition saveload.h:346
@ LargerTownCargoStatistics
Saveload version: 9.0, SVN revision: 1909 Increase size of passenger/mail production of this and pre...
Definition saveload.h:56
@ BigDates
Saveload version: 31, SVN revision: 5999 Change date from 1920 - 2090 to 0 - 5 000 000.
Definition saveload.h:86
@ IncreaseHouseLimit
Saveload version: 348, GitHub pull request: 12288 Increase house limit to 4096.
Definition saveload.h:402
@ BackupOrderState
Saveload version: 176, SVN revision: 24446 Put more of the state of a vehicle's orders (like latenes...
Definition saveload.h:260
@ CargoTravelled
Saveload version: 319, GitHub pull request: 11283 CargoPacket now tracks how far it travelled inside...
Definition saveload.h:367
@ CustomSeaLevel
Saveload version: 149, SVN revision: 20832 Setting to influence the sea level (amount of water).
Definition saveload.h:227
@ StoreIndustryCargo
Saveload version: 78, SVN revision: 11176 Store an industry's cargo, so it can be customised upon bu...
Definition saveload.h:142
@ StationRatingCheat
Saveload version: 320, GitHub pull request: 11346 Add cheat to fix station ratings at 100%.
Definition saveload.h:369
@ MoreEngineTypes
Saveload version: 95, SVN revision: 12924 Allow more than the original 255 engine types.
Definition saveload.h:163
@ OrdersOwnedByOrderlist
Saveload version: 354, GitHub pull request: 13948 Orders stored in OrderList, pool removed.
Definition saveload.h:409
@ ExtendCargotypes
Saveload version: 199, GitHub pull request: 6802 Extend cargotypes to 64.
Definition saveload.h:287
@ TrainSlopeSteepness
Saveload version: 133, SVN revision: 18674 Setting to increase steepness of slopes for trains under ...
Definition saveload.h:208
@ FractionProfitRunningTicks
Saveload version: 88, SVN revision: 12134 Store vehicle profits as a (fixed point) fraction,...
Definition saveload.h:154
@ UnifyWaypointAndStation
Saveload version: 123, SVN revision: 16909 Unify stations and waypoints.
Definition saveload.h:196
@ InfrastructureMaintenanceCosts
Saveload version: 166, SVN revision: 23415 Infrastructure can now cost some periodic fee.
Definition saveload.h:248
@ VehicleEconomyAge
Saveload version: 334, GitHub pull request: 12141, release: 14.0 Add vehicle age in economy year,...
Definition saveload.h:385
@ GroupReplaceWagonRemoval
Saveload version: 291, GitHub pull request: 7441 Per-group wagon removal flag.
Definition saveload.h:334
@ ImproveMultistop
Saveload version: 25, SVN revision: 4259 Improve the behaviour of RVs going to road stops.
Definition saveload.h:79
@ MonthlyBankruptcyCheck
Saveload version: 177, SVN revision: 24619 Check for bankruptcy on a monthly cycle.
Definition saveload.h:261
@ CompanyInauguratedPeriodV2
Saveload version: 349, GitHub pull request: 13448 Fix savegame storage for company inaugurated year ...
Definition saveload.h:403
@ DigitGroupSeparator
Saveload version: 118, SVN revision: 16129 Configurable digit group separator.
Definition saveload.h:190
@ GoalProgressPlaneAcceleration
Saveload version: 182, SVN revision: 25115, r25259, r25296 Goal status and plane acceleration fixes.
Definition saveload.h:267
@ BigCurrency
Saveload version: 1.0, releases: 0.1.x, 0.2.x Change currency from 32 to 64 bits.
Definition saveload.h:38
@ LiveryRefit
Saveload version: 35, SVN revision: 6602 NewGRF livery refits.
Definition saveload.h:91
@ MergeOptsPats
Saveload version: 97, SVN revision: 13256 Merge the OPTS and PATS chunks, i.e. all settings in one c...
Definition saveload.h:165
@ StringGamelog
Saveload version: 314, GitHub pull request: 10801 Use std::string in gamelog.
Definition saveload.h:361
@ GroupHierarchy
Saveload version: 189, SVN revision: 26450 Hierarchical vehicle subgroups.
Definition saveload.h:275
@ CountPaidForCargo
Saveload version: 45, SVN revision: 8501 Count the amount of cargo that was paid for.
Definition saveload.h:103
@ UnifyCurrency
Saveload version: 65, SVN revision: 10210 Make all variables related to currency 64 bits.
Definition saveload.h:127
@ DisasterVehState
Saveload version: 312, GitHub pull request: 10798 Explicit storage of disaster vehicle state.
Definition saveload.h:359
@ EndingYear
Saveload version: 218, GitHub pull request: 7747, release: 1.10 Configurable ending year.
Definition saveload.h:310
@ LinkgraphRestrictedFlow
Saveload version: 187, SVN revision: 25899 Linkgraph - restricted flows.
Definition saveload.h:273
@ FreightWeight
Saveload version: 39, SVN revision: 7269 Setting to increase the weight of cargo on freight trains.
Definition saveload.h:95
@ FifoLoading
Saveload version: 57, SVN revision: 9691 First-in-first-out loading of vehicles.
Definition saveload.h:117
@ LargerTownIterator
Saveload version: 11.0, SVN revision: 2033 Increase size of the town iterator.
Definition saveload.h:59
@ EndPatchpacks
Saveload version: 286 Last known patchpack to use a version just above ours.
Definition saveload.h:327
@ TimetableStartTicksFix
Saveload version: 322, GitHub pull request: 11557 Fix for missing convert timetable start from a dat...
Definition saveload.h:371
@ MoveSccEncoded
Saveload version: 169, SVN revision: 23816 Move SCC_ENCODED to the first StringControlCode.
Definition saveload.h:251
@ LinkgraphEdges
Saveload version: 304, GitHub pull request: 10314 Explicitly store link graph edges destination,...
Definition saveload.h:349
@ FairPlaySettings
Saveload version: 79, SVN revision: 11188 Add setting to disable exclusive rights in a town and givi...
Definition saveload.h:143
@ DockDockingtiles
Saveload version: 298, GitHub pull request: 9578 All tiles around docks may be docking tiles.
Definition saveload.h:342
@ FreeformEdges
Saveload version: 111, SVN revision: 15190 Allow terraforming along the edge of the map.
Definition saveload.h:182
@ LabelOrientationUnification
Saveload version: 367, GitHub pull request: 15888 Unify the orientation in which labels are written.
Definition saveload.h:425
@ RoadWaypoints
Saveload version: 338, GitHub pull request: 12572 Road waypoints.
Definition saveload.h:390
@ UnifyAnimationState
Saveload version: 43, SVN revision: 7642 Put all animation state information in same map bits.
Definition saveload.h:100
@ LargerUnitNumber
Saveload version: 8.0, SVN revision: 1786 Increase size of (vehicle) unit numbers.
Definition saveload.h:55
@ MoveSemaphoreBits
Saveload version: 15.0, SVN revision: 2499 Move rail signal bit for semaphores.
Definition saveload.h:65
@ ReplaceCustomNameArray
Saveload version: 84, SVN revision: 11822 Replace single fixed size array of custom names,...
Definition saveload.h:149
@ RemoveMinorVersion
Saveload version: 18, SVN revision: 3227 Remove the minor versions from savegames.
Definition saveload.h:70
@ IncreaseStationTypeFieldSize
Saveload version: 337, GitHub pull request: 12572 Increase size of StationType field in map array.
Definition saveload.h:389
@ LastVehicleType
Saveload version: 26, SVN revision: 4466 Store the last vehicle type at stations instead of the vehi...
Definition saveload.h:80
@ SavePatches
Saveload version: 22, SVN revision: 3726 Save state of patches (precursor of settings) in the savega...
Definition saveload.h:75
@ RoadLayoutPerTown
Saveload version: 113, SVN revision: 15340 Allow for different road layouts for each of the towns.
Definition saveload.h:184
@ SplitStationTypeFromGfxid
Saveload version: 72, SVN revision: 10601 Splits the encoding of station type from the graphics iden...
Definition saveload.h:135
@ NewGRFSuppliedStationName
Saveload version: 103, SVN revision: 14598 NewGRF industry supplying default names for nearby statio...
Definition saveload.h:172
@ PathCacheFormat
Saveload version: 346, GitHub pull request: 12345 Vehicle path cache format changed.
Definition saveload.h:400
@ IndustryText
Saveload version: 289, GitHub pull request: 8576, release: 1.11.0-RC1 Additional GS text for industr...
Definition saveload.h:331
@ Yapf
Saveload version: 28, SVN revision: 4987 Yet another path finder.
Definition saveload.h:82
@ MaxLengthAndReverseSignals
Saveload version: 159, SVN revision: 21962 Settings for reversing at signals, and maximum train,...
Definition saveload.h:239
@ ObjectTypeToPool
Saveload version: 186, SVN revision: 25833 Move object type from map to pool object.
Definition saveload.h:272
@ MultipleSignalTypes
Saveload version: 64, SVN revision: 10006 Multiple different signal types on the same (diagonal) til...
Definition saveload.h:125
@ PeriodsInTransitRename
Saveload version: 316, GitHub pull request: 11112 Rename days in transit to (cargo) periods in trans...
Definition saveload.h:364
@ SimplifyPlayerFace
Saveload version: 49, SVN revision: 8969 Simplify the storage of player face information.
Definition saveload.h:107
@ VehicleCurrencyStationChanges
Saveload version: 2.0, release: 0.3.0 Adding vehicle state, larger currency size for statistics,...
Definition saveload.h:39
@ TownTolerancePauseMode
Saveload version: 4.0, SVN revision: 1 Town council tolerance and pause mode.
Definition saveload.h:43
@ AircraftSpeedHolding
Saveload version: 50, SVN revision: 8973 Aircraft speed in km-ish/h and reduced speed in holding pat...
Definition saveload.h:109
@ SignTextColours
Saveload version: 363, GitHub pull request: 14743 Configurable sign text colors in scenario editor.
Definition saveload.h:420
@ DoubleEndedShips
Saveload version: 368, GitHub pull request: 16002 Double-ended (NewGRF-only) ships can reverse witho...
Definition saveload.h:426
@ CountIndividualCargoes
Saveload version: 170, SVN revision: 23826 Store the count of individual cargo delivery for a period...
Definition saveload.h:253
@ MaxLoanForCompany
Saveload version: 330, GitHub pull request: 11224 Separate max loan for each company.
Definition saveload.h:381
@ TrackRealAndAutoOrders
Saveload version: 158, SVN revision: 21933 Track which real and auto order is the current order.
Definition saveload.h:238
@ VehicleCentreAndZPos
Saveload version: 164, SVN revision: 23290 Vehicle centres are not fixed at 4/8 of the vehicle; chan...
Definition saveload.h:245
@ VirtualFeederSharePayment
Saveload version: 134, SVN revision: 18703 Pay a part of the virtual profit during a transfer to the...
Definition saveload.h:209
@ MaglevMonorailPaxWagonLivery
Saveload version: 85, SVN revision: 11874 Add livery for maglev/monorail passenger wagons.
Definition saveload.h:151
@ ShipCurvePenalty
Saveload version: 209, GitHub pull request: 7289 Configurable ship curve penalties.
Definition saveload.h:299
@ ScriptMemlimit
Saveload version: 215, GitHub pull request: 7516 Limit on AI/GS memory consumption.
Definition saveload.h:307
@ SimplifyPathfinderSettings
Saveload version: 87, SVN revision: 12129 Make it easier to select the pathfinder to use.
Definition saveload.h:153
@ RoadStopOccupancyPenalty
Saveload version: 130, SVN revision: 18404 Add configurable pathfinder penalty for an occupied road ...
Definition saveload.h:205
@ RemoveTownCargoCache
Saveload version: 219, GitHub pull request: 8258 Remove town cargo acceptance and production caches.
Definition saveload.h:311
@ NewGRFTownNames
Saveload version: 66, SVN revision: 10211 NewGRF provided town names.
Definition saveload.h:128
@ EconomyModeTimekeepingUnits
Saveload version: 327, GitHub pull request: 11341 Mode to display economy measurements in wallclock ...
Definition saveload.h:377
@ BigMap
Saveload version: 5.0, SVN revision: 1429 Making maps a different size than 256x256.
Definition saveload.h:49
@ DriveBackwards
Saveload version: 365, GitHub pull request: 15379 Trains can drive backwards.
Definition saveload.h:423
@ ProductionHistory
Saveload version: 343, GitHub pull request: 10541 Industry production history.
Definition saveload.h:396
@ MultipleRoadTypes
Saveload version: 61, SVN revision: 9892 Multiple road types for the same tile.
Definition saveload.h:122
@ MultitileDocks
Saveload version: 216, GitHub pull request: 7380 Multiple docks per station.
Definition saveload.h:308
@ LargerCargoSource
Saveload version: 7.0, SVN revision: 1770 With more stations, the size of the cargo source needed to...
Definition saveload.h:54
@ RailTrackTypeUnification
Saveload version: 48, SVN revision: 8935 Put all the rail track type information in same map bits.
Definition saveload.h:106
@ AnimatedTileStateInMap
Saveload version: 347, GitHub pull request: 13082 Animated tile state saved for improved performance...
Definition saveload.h:401
@ NewGRFIndustryRandomTriggers
Saveload version: 82, SVN revision: 11410 NewGRF random triggers for industries.
Definition saveload.h:147
@ NewGRFLastService
Saveload version: 317, GitHub pull request: 11124 Added stable date_of_last_service to avoid NewGRF ...
Definition saveload.h:365
@ LinkgraphSeconds
Saveload version: 308, GitHub pull request: 10610 Store linkgraph update intervals in seconds instea...
Definition saveload.h:354
@ GroupLiveries
Saveload version: 205, GitHub pull request: 7108 Livery storage change and group liveries.
Definition saveload.h:295
@ DisableTownLevelCrossing
Saveload version: 143, SVN revision: 20048 Setting to be able to disable building rail/road crossing...
Definition saveload.h:220
@ ShipAcceleration
Saveload version: 329, GitHub pull request: 10734 Start using Vehicle's acceleration field for ships...
Definition saveload.h:379
@ MaximumDepotPenalty
Saveload version: 131, SVN revision: 18481 Add configurable maximum pathfinder penalty for finding a...
Definition saveload.h:206
@ GamelogEmergency
Saveload version: 116, SVN revision: 15893, release: 0.7.x Gamelog event for emergency/crash saves.
Definition saveload.h:188
@ NewGRFPersistentStorage
Saveload version: 76, SVN revision: 11139 Persistently store some state of NewGRF objects/entities.
Definition saveload.h:140
@ SaveYapfSettings
Saveload version: 33, SVN revision: 6440 Some YAPF settings were not saved properly.
Definition saveload.h:88
@ TownAcceptance
Saveload version: 127, SVN revision: 17439 Store mask of cargos accepted by town houses and head qua...
Definition saveload.h:201
@ Distinguish16
Saveload version: 195, SVN revision: 27572, release: 1.6.1 Convenience bump to distinguish 1....
Definition saveload.h:283
@ MoreCargoPackets
Saveload version: 69, SVN revision: 10319 Allow more than ~65k cargo packets.
Definition saveload.h:131
@ LinkgraphLocationDisasterStore
Saveload version: 191, SVN revision: 26636, 26646 Fix disaster vehicle storage, Linkgraph - store lo...
Definition saveload.h:278
@ FixTreeGround
Saveload version: 81, SVN revision: 11244 Various fixes to improve the visuals of the ground under t...
Definition saveload.h:146
@ DriveThroughRoadStops
Saveload version: 47, SVN revision: 8735 Drive through road stops.
Definition saveload.h:105
@ U64TickCounter
Saveload version: 300, GitHub pull request: 10035 Make tick counter 64bit to avoid wrapping.
Definition saveload.h:345
@ MoreWaypointsPerTown
Saveload version: 89, SVN revision: 12160 Support more than 64 waypoints per town.
Definition saveload.h:155
@ TownGrowthControl
Saveload version: 54, SVN revision: 9613 Give the player control over the town growth.
Definition saveload.h:113
@ TransferOrder
Saveload version: 14.0, SVN revision: 2441 Transfer orders for feeder systems.
Definition saveload.h:63
@ SeparateOrderTravelWaitTime
Saveload version: 190, SVN revision: 26547 Separate order travel and wait times.
Definition saveload.h:277
@ RobustEnginePreview
Saveload version: 179, SVN revision: 24810 Make engine preview offers robust when company ranking ch...
Definition saveload.h:263
@ EncodedStringFormat
Saveload version: 350, GitHub pull request: 13499 Encoded String format changed.
Definition saveload.h:405
@ CleanupUnconnectedRoads
Saveload version: 77, SVN revision: 11172 Option to remove unconnected roads during a town's road re...
Definition saveload.h:141
@ AirportAnimationFrames
Saveload version: 137, SVN revision: 18912 Use animation frames instead of many airport tile ids for...
Definition saveload.h:213
@ IndustryManagement
Saveload version: 152, SVN revision: 21171 Manage the amount of industries that ought to be spawned ...
Definition saveload.h:231
@ FractionalCargoDelivery
Saveload version: 150, SVN revision: 20857 When spreading cargo over stations, spread fractional amo...
Definition saveload.h:229
@ RemoveAutosaveInterval
Saveload version: 23, SVN revision: 3915 Store autosave interval locally, instead of in savegame.
Definition saveload.h:76
@ RoadvehPathCache
Saveload version: 211, GitHub pull request: 7261 Add path cache for road vehicles.
Definition saveload.h:302
@ LinkWaypointToTown
Saveload version: 12.1, SVN revision: 2046 Link waypoints to towns and remove some bit stuffing.
Definition saveload.h:61
@ RemoveHouseCount
Saveload version: 92, SVN revision: 12381, release 0.6.x Remove number of houses in a town from the ...
Definition saveload.h:159
@ NewGRFHouses
Saveload version: 53, SVN revision: 9316 NewGRF controlled houses.
Definition saveload.h:112
@ FoundTown
Saveload version: 128, SVN revision: 18281 Founding of new towns.
Definition saveload.h:202
@ NonfloodingWaterTiles
Saveload version: 345, GitHub pull request: 13013 Store water tile non-flooding state.
Definition saveload.h:399
@ FixSccEncodedNegative
Saveload version: 353, GitHub pull request: 14049 Fix encoding of negative parameters.
Definition saveload.h:408
@ RefitOrders
Saveload version: 36, SVN revision: 6624 Vehicles can be refitted as part of an order.
Definition saveload.h:92
@ NewGRFRoadStops
Saveload version: 303, GitHub pull request: 10144 NewGRF road stops.
Definition saveload.h:348
@ RemoveOldPathfinder
Saveload version: 212, GitHub pull request: 7245 Remove OPF.
Definition saveload.h:303
@ ExtendIndustryCargoSlots
Saveload version: 202, GitHub pull request: 6867 Increase industry cargo slots to 16 in,...
Definition saveload.h:291
@ Rivers
Saveload version: 163, SVN revision: 22767 Rivers.
Definition saveload.h:244
@ UnifyGroundVehicles
Saveload version: 157, SVN revision: 21862 Unify the way ground vehicles are handled (articulated pa...
Definition saveload.h:237
@ RemoveSubsidyStationBinding
Saveload version: 125, SVN revision: 17113 Awarded subsidies are not bound to stations,...
Definition saveload.h:199
@ Autoslope
Saveload version: 75, SVN revision: 11107 Terraforming under buildings/track/anything that supports ...
Definition saveload.h:139
@ ImprovedOrders
Saveload version: 93, SVN revision: 12648 Orders support all full load/non stop types at the same ti...
Definition saveload.h:160
@ CargoSourceTile
Saveload version: 44, SVN revision: 8144 Store the source tile of the cargo, so accurate payment can...
Definition saveload.h:101
@ UngroupedVehicles
Saveload version: 71, SVN revision: 10567 Add a group with vehicles that aren't in any other group.
Definition saveload.h:134
@ Utf8
Saveload version: 37, SVN revision: 7182 UTF-8 strings.
Definition saveload.h:93
@ DisableElrailSetting
Saveload version: 38, SVN revision: 7195 Add setting to disable electrified rails.
Definition saveload.h:94
@ VehMotionCounter
Saveload version: 288, GitHub pull request: 8591 Desync safe motion counter.
Definition saveload.h:330
@ TimetableStartTicks
Saveload version: 321, GitHub pull request: 11468 Convert timetable start from a date to ticks.
Definition saveload.h:370
@ AIStartDate
Saveload version: 309, GitHub pull request: 10653 Removal of individual AI start dates and added a g...
Definition saveload.h:355
@ StoreAirportSize
Saveload version: 140, SVN revision: 19382 Store the size of the airport in the station.
Definition saveload.h:217
@ DepotsUnderBridges
Saveload version: 366, GitHub pull request: 15836 Allow depots under bridges.
Definition saveload.h:424
@ ExtendEntityMapping
Saveload version: 311, GitHub pull request: 10672 Extend entity mapping range.
Definition saveload.h:358
@ StoreWaypointIdInMap
Saveload version: 17.0, SVN revision: 3212 Store the ID of waypoints in m2 of the map.
Definition saveload.h:68
@ BuoysAt0_0
Saveload version: 364, GitHub pull request: 14983 Allow to build buoys at (0x0).
Definition saveload.h:421
@ PlatformStopLocation
Saveload version: 117, SVN revision: 16037 Set the platform stop location via train orders.
Definition saveload.h:189
@ CurrentOrderMaxSpeed
Saveload version: 174, SVN revision: 23973, release: 1.2.x Save maximum speed of current order.
Definition saveload.h:257
@ Distinguish17
Saveload version: 196, SVN revision: 27778, release: 1.7 Convenience bump to distinguish 1....
Definition saveload.h:284
@ SeparateRoadOwners
Saveload version: 114, SVN revision: 15601 Separate owners for road bits, tram bits and the road sto...
Definition saveload.h:185
@ TableChunks
Saveload version: 295, GitHub pull request: 9322 Introduction of ChunkType::Table and ChunkType::Spa...
Definition saveload.h:339
@ MoreCompanies
Saveload version: 104, SVN revision: 14735 Increase maximum number of companies to 15.
Definition saveload.h:173
@ NewGRFPalette
Saveload version: 101, SVN revision: 14233 Store palette used by each of the NewGRFs.
Definition saveload.h:170
@ MultipleRoadStops
Saveload version: 6.0, SVN revision: 1721 Multi tile road stops, and some map size related fixes.
Definition saveload.h:52
@ MoreCargoAge
Saveload version: 307, GitHub pull request: 10596 Track cargo age for a longer period.
Definition saveload.h:353
@ SavegameId
Saveload version: 313, GitHub pull request: 10719 Add an unique ID to every savegame (used to dedupl...
Definition saveload.h:360
@ VehicleGroups
Saveload version: 60, SVN revision: 9874 Arbitrary grouping, by the player, of vehicles.
Definition saveload.h:121
@ UnifyAnimationFrame
Saveload version: 147, SVN revision: 20621 Unify location of animation frame.
Definition saveload.h:225
@ ServiceIntervalPercent
Saveload version: 180, SVN revision: 24998, release: 1.3.x Service interval in percent or days store...
Definition saveload.h:265
@ AutoreplaceWhenOldTreeLimit
Saveload version: 175, SVN revision: 24136 Autoreplace vehicle only when they are old,...
Definition saveload.h:259
@ CargoPayments
Saveload version: 121, SVN revision: 16694 Perform payment of cargo after unloading.
Definition saveload.h:194
@ MultitrackLevelCrossings
Saveload version: 302, GitHub pull request: 9931, release: 13.0 Multi-track level crossings.
Definition saveload.h:347
@ CompanyAllowListV2
Saveload version: 341, GitHub pull request: 12908 Fixed savegame format for saving of list of client...
Definition saveload.h:394
@ PlaneSpeedFactor
Saveload version: 90, SVN revision: 12293 Setting to increase aircraft speed to be on par with the o...
Definition saveload.h:157
@ AILocalConfig
Saveload version: 332, GitHub pull request: 12003 Config of running AI is stored inside Company.
Definition saveload.h:383
@ StationsUnderBridges
Saveload version: 359, GitHub pull request: 14477 Allow stations under bridges.
Definition saveload.h:415
@ DisallowTreeBuilding
Saveload version: 132, SVN revision: 18522 Setting to partially disable building of trees.
Definition saveload.h:207
@ CumulatedInflation
Saveload version: 126, SVN revision: 17433 Store cumulated inflation, and recalculate prices/payment...
Definition saveload.h:200
@ TownCargogen
Saveload version: 208, GitHub pull request: 6965 New algorithms for town building cargo generation.
Definition saveload.h:298
@ NewGRFCustomCargoAging
Saveload version: 162, SVN revision: 22713 NewGRF influence on aging of cargo in vehicles.
Definition saveload.h:243
@ DisallowRoadReconstruction
Saveload version: 160, SVN revision: 21974, release: 1.1.x Setting to disallow road reconstruction.
Definition saveload.h:241
@ NextCompetitorStartOverflow
Saveload version: 109, SVN revision: 15075 Prevent overflow in the next competitor start counter.
Definition saveload.h:179
@ TimetableTicksType
Saveload version: 323, GitHub pull request: 11435 Convert timetable current order time to ticks.
Definition saveload.h:372
@ NewGRFAircraftRange
Saveload version: 167, SVN revision: 23504 NewGRF provided maximum aircraft range.
Definition saveload.h:249
@ LargerTownCounter
Saveload version: 10.0, SVN revision: 2030 Increase size of the town counter.
Definition saveload.h:58
@ LinkgraphTravelTime
Saveload version: 297, GitHub pull request: 9457, release: 12.0-RC1 Store travel time in the linkgra...
Definition saveload.h:341
@ Cargodist
Saveload version: 183, SVN revision: 25363 Cargodist.
Definition saveload.h:268
@ Elrail
Saveload version: 24, SVN revision: 4150 Electrified railways.
Definition saveload.h:77
@ TownSupplyHistory
Saveload version: 358, GitHub pull request: 14461 Town supply history.
Definition saveload.h:414
@ FixCargoMonitor
Saveload version: 207, GitHub pull request: 7175, release: 1.9 Cargo monitor data packing fix to sup...
Definition saveload.h:297
@ StoreMapVariety
Saveload version: 197, SVN revision: 27978, release: 1.8 Store map variety.
Definition saveload.h:285
@ NewGRFIndustryLayout
Saveload version: 73, SVN revision: 10903 NewGRF provided layouts for industries.
Definition saveload.h:136
@ RemoveOldAISettings
Saveload version: 110, SVN revision: 15148 Remove remnants of the old AI's configuration.
Definition saveload.h:181
@ ExtendVehicleRandom
Saveload version: 310, GitHub pull request: 10701 Extend vehicle random bits.
Definition saveload.h:357
@ CompanyServiceIntervals
Saveload version: 120, SVN revision: 16439 Make service intervals configurable per company.
Definition saveload.h:193
@ EngineMultiRailtype
Saveload version: 362, GitHub pull request: 14357, release: 15.0 Train engines can have multiple rai...
Definition saveload.h:419
@ MoreAirportBlocks
Saveload version: 46, SVN revision: 8705 Increase number of blocks an airport can have.
Definition saveload.h:104
@ ReducePlaneCrashes
Saveload version: 138, SVN revision: 18942, release: 1.0.x Setting to reduce/disable crashing of pla...
Definition saveload.h:214
@ RoadTypeLabelMap
Saveload version: 344, GitHub pull request: 13021 Add road type label map to allow upgrade/conversio...
Definition saveload.h:397
@ RocksStayUnderSnow
Saveload version: 135, SVN revision: 18719 Rocks stay under snow, i.e. they return when the snow goe...
Definition saveload.h:211
@ WaterRegions
Saveload version: 324, GitHub pull request: 10543 Water Regions for ship pathfinder.
Definition saveload.h:373
@ MinVersion
First savegame version.
Definition saveload.h:36
@ EconomyDate
Saveload version: 326, GitHub pull request: 10700 Split calendar and economy timers and dates.
Definition saveload.h:376
@ IndustryAcceptedHistory
Saveload version: 357, GitHub pull request: 14321 Add per-industry history of cargo delivered and wa...
Definition saveload.h:413
@ ScenarioDeitySigns
Saveload version: 171, SVN revision: 23835 Signs made in scenarios become of OWNER_DEITY,...
Definition saveload.h:254
@ OrderMaxSpeed
Saveload version: 172, SVN revision: 23947 Set maximum speed for orders.
Definition saveload.h:255
@ NewGRFSettings
Saveload version: 41, SVN revision: 7348, release: 0.5.x Save what NewGRFs are used in the game and ...
Definition saveload.h:98
@ MoreUnderBridges
Saveload version: 29, SVN revision: 5070 Support crossings, fields and bridge/tunnel heads under bri...
Definition saveload.h:83
@ MoreHouseAnimationFrames
Saveload version: 91, SVN revision: 12347 Increase number of animation frames for NewGRF houses.
Definition saveload.h:158
@ TradingAge
Saveload version: 217, GitHub pull request: 7780 Configurable company trading age.
Definition saveload.h:309
@ WaypointMoreLikeStation
Saveload version: 122, SVN revision: 16855 Make waypoint data look more like stations.
Definition saveload.h:195
@ ExtendRailtypes
Saveload version: 200, GitHub pull request: 6805 Extend railtypes to 64, adding uint16_t to map arra...
Definition saveload.h:289
@ RemoveLoadedAtXY
Saveload version: 318, GitHub pull request: 11276 Remove loaded_at_xy variable from CargoPacket.
Definition saveload.h:366
@ StoreAIVersion
Saveload version: 108, SVN revision: 15045 Store the version of the AI script.
Definition saveload.h:178
@ VeryLowTownIndustryNumber
Saveload version: 58, SVN revision: 9762 Difficulty settings for very low number of industries and t...
Definition saveload.h:118
@ ProtectPlacedHouses
Saveload version: 351, GitHub pull request: 13270 Houses individually placed by players can be prote...
Definition saveload.h:406
@ SplitLoadWaitCounters
Saveload version: 136, SVN revision: 18764 Split counters for (un)loading and signal waiting/turning...
Definition saveload.h:212
@ Storybooks
Saveload version: 185, SVN revision: 25620 Storybooks.
Definition saveload.h:271
@ LeaveRoadStopSeparately
Saveload version: 153, SVN revision: 21263 Fix issue where multiple vehicles could leave a road stop...
Definition saveload.h:232
@ IndustryCargoReorganise
Saveload version: 315, GitHub pull request: 10853 Industry accepts/produced data reorganised.
Definition saveload.h:363
@ StatueOwner
Saveload version: 52, SVN revision: 9066 Store the owner of the statue, so the town can be informed ...
Definition saveload.h:111
@ CompanyAllowList
Saveload version: 335, GitHub pull request: 12337 Saving of list of client keys that are allowed to ...
Definition saveload.h:387
@ SplitHQ
Saveload version: 112, SVN revision: 15290 Split the behaviour of headquarters from the other unmova...
Definition saveload.h:183
@ UniqueDepotNames
Saveload version: 141, SVN revision: 19799 Give depots unique names.
Definition saveload.h:218
@ DepotWaterOwners
Saveload version: 83, SVN revision: 11589 Store the owner of the water under depots,...
Definition saveload.h:148
@ LargerAIStateCounter
Saveload version: 13.1, SVN revision: 2080, releases: 0.4.0, 0.4.0.1 AI state counter increased due ...
Definition saveload.h:62
@ StoreNewGRFVersion
Saveload version: 151, SVN revision: 20918 Store the version of the used NewGRFs.
Definition saveload.h:230
@ FeederShare
Saveload version: 51, SVN revision: 8978 Rewrite of transfers to retain knowledge about the already ...
Definition saveload.h:110
@ TownGrowthInGameTicks
Saveload version: 198, GitHub pull request: 6763 Switch town growth rate and counter to actual game ...
Definition saveload.h:286
@ NewGRFMoreAnimation
Saveload version: 80, SVN revision: 11228 Support more types of animation for NewGRF industries.
Definition saveload.h:145
@ Tgp
Saveload version: 30, SVN revision: 5946 TerraGenesis Perlin.
Definition saveload.h:85
@ DepotUnbunching
Saveload version: 331, GitHub pull request: 11945 Allow unbunching shared order vehicles at a depot.
Definition saveload.h:382
@ ScriptInt64
Saveload version: 296, GitHub pull request: 9415 SQInteger is 64bit but was saved as 32bit.
Definition saveload.h:340
@ ShipsStopInLocks
Saveload version: 206, GitHub pull request: 7150 Ship/lock movement changes.
Definition saveload.h:296
@ IndustryTileWaterClass
Saveload version: 99, SVN revision: 13838 Add water classes to industry tiles.
Definition saveload.h:167
@ ScriptRandomizer
Saveload version: 333, GitHub pull request: 12063, release: 14.0-RC1 Save script randomizers.
Definition saveload.h:384
@ RepairObjectDockingTiles
Saveload version: 299, GitHub pull request: 9594, release: 12.0 Fixing issue with docking tiles over...
Definition saveload.h:343
@ RemoveOldPbs
Saveload version: 21, SVN revision: 3472, release: 0.4.x Remove old implementation of path based sig...
Definition saveload.h:74
@ IndustryNumValidHistory
Saveload version: 356, GitHub pull request: 14416 Store number of valid history records for industri...
Definition saveload.h:412
@ NewGRFDepotBuildDate
Saveload version: 142, SVN revision: 20003 Depot build date for NewGRFs.
Definition saveload.h:219
@ BiggerStationVariables
Saveload version: 3.0 Increase size of airport blocks/station build date.
Definition saveload.h:42
@ NewGRFAirportSmoke
Saveload version: 145, SVN revision: 20376 NewGRF support for airport and configurable amount of smo...
Definition saveload.h:223
@ CompanyInauguratedPeriod
Saveload version: 339, GitHub pull request: 12798 Companies show the period inaugurated in wallclock...
Definition saveload.h:391
@ MapgenSettingsRevamp
Saveload version: 290, GitHub pull request: 8891, release: 1.11 Revamp of some mapgen settings (snow...
Definition saveload.h:333
@ FixStationPickupAccounting
Saveload version: 74, SVN revision: 11030 Accounting of which cargos a station would pick up was don...
Definition saveload.h:137
@ DistantStationJoining
Saveload version: 106, SVN revision: 14919 Distant joining of stations.
Definition saveload.h:176
@ SaveloadListLength
Saveload version: 293, GitHub pull request: 9374 Consistency in list length with SaveLoadType::Struc...
Definition saveload.h:336
@ CustomSubsidyDuration
Saveload version: 292, GitHub pull request: 9081 Configurable subsidy duration.
Definition saveload.h:335
@ VelocityNautical
Saveload version: 305, GitHub pull request: 10594 Separation of land and nautical velocity (knots!...
Definition saveload.h:351
@ CalendarSubDateFract
Saveload version: 328, GitHub pull request: 11428 Add sub_date_fract to measure calendar days.
Definition saveload.h:378
@ ShipRotation
Saveload version: 204, GitHub pull request: 7065 Add extra rotation stages for ships.
Definition saveload.h:293
@ CustomTownNumber
Saveload version: 115, SVN revision: 15695 Configuration for specific number of towns to build.
Definition saveload.h:187
@ Liveries
Saveload version: 34, SVN revision: 6455 Liveries and two company colours (2cc).
Definition saveload.h:89
@ Timetables
Saveload version: 67, SVN revision: 10236 Introduce timetables for vehicles.
Definition saveload.h:129
@ DocksUnderBridges
Saveload version: 360, GitHub pull request: 14594 Allow docks under bridges.
Definition saveload.h:417
@ WaterRegionEvalSimplified
Saveload version: 325, GitHub pull request: 11750 Simplified Water Region evaluation.
Definition saveload.h:375
@ GroupNumbers
Saveload version: 336, GitHub pull request: 12297 Add per-company group numbers.
Definition saveload.h:388
@ RvRealisticAcceleration
Saveload version: 139, SVN revision: 19346 Realistic acceleration of road vehicles.
Definition saveload.h:215
@ ServeNeutralIndustries
Saveload version: 210, GitHub pull request: 7234 Company stations can serve industries with attached...
Definition saveload.h:301
@ ReorderUnmovableRemoveReserved
Saveload version: 144, SVN revision: 20334 Reorder map bits of unmovable tiles and remove unused res...
Definition saveload.h:221
@ Yapp
Saveload version: 100, SVN revision: 13952 New version of path based signals.
Definition saveload.h:169
@ MultiTileWaypoints
Saveload version: 124, SVN revision: 16993 Waypoints can be bigger than a single tile.
Definition saveload.h:197
@ FaceStyles
Saveload version: 355, GitHub pull request: 14319 Addition of face styles, replacing gender and ethn...
Definition saveload.h:411
@ NewGRFCargo
Saveload version: 55, SVN revision: 9638 Increase number of cargos and NewGRF control of cargos.
Definition saveload.h:115
@ CargoPackets
Saveload version: 68, SVN revision: 10266 Account for individual units of cargo, i....
Definition saveload.h:130
@ TerraformLimits
Saveload version: 156, SVN revision: 21728 Introduce limits for terraforming and clearing times.
Definition saveload.h:236
@ SeparateLocaleUnits
Saveload version: 184, SVN revision: 25508 Unit localisation split.
Definition saveload.h:269
@ TreesWaterClass
Saveload version: 213, GitHub pull request: 7405 WaterClass update for tree tiles.
Definition saveload.h:304
@ AdjacentStations
Saveload version: 62, SVN revision: 9905 Allow building multiple stations directly next to eachother...
Definition saveload.h:123
@ UnifyRvTravelTime
Saveload version: 188, SVN revision: 26169, release: 1.4 Unify RV travel time.
Definition saveload.h:274
@ MaxBridgeMapHeight
Saveload version: 194, SVN revision: 26881, release: 1.5 Setting for maximum bridge and map height.
Definition saveload.h:281
@ TimetableStart
Saveload version: 129, SVN revision: 18292 Allow setting the start date of a timetable.
Definition saveload.h:203
@ ScriptSaveInstances
Saveload version: 352, GitHub pull request: 13556 Scripts are allowed to save instances.
Definition saveload.h:407
@ NewGRFObjectView
Saveload version: 155, SVN revision: 21453 Support for views in NewGRF objects.
Definition saveload.h:235
@ MaxVersion
Highest possible saveload version.
Definition saveload.h:428
@ NoMultiheadReference
Saveload version: 20, SVN revision: 3403 Remove reference from one multihead to the other one.
Definition saveload.h:73
@ IndustryPlatform
Saveload version: 148, SVN revision: 20659 Setting to make a flat area around (new) industries.
Definition saveload.h:226
@ ScriptTownGrowth
Saveload version: 165, SVN revision: 23304 Storage of cargo statistics for use by game scripts.
Definition saveload.h:247
@ SpreadIndustryProductionChanges
Saveload version: 102, SVN revision: 14332 Spread the industry production changes over the month,...
Definition saveload.h:171
@ PauseLevel
Saveload version: 154, SVN revision: 21426 Setting to determine what commands are allowed when pause...
Definition saveload.h:233
@ FixCompanyCargoTypes
Saveload version: 94, SVN revision: 12816 The company's cargo types should have increased in since w...
Definition saveload.h:161
@ GradualLoading
Saveload version: 40, SVN revision: 7326 Gradual (un)loading of cargo.
Definition saveload.h:97
@ NewGRFStations
Saveload version: 27, SVN revision: 4757 NewGRF graphics for stations.
Definition saveload.h:81
@ FixRoadOwnership
Saveload version: 173, SVN revision: 23967, release: 1.2.0-RC1 Seemingly unneeded bump supposed to f...
Definition saveload.h:256
@ StartPatchpacks
Saveload version: 220 First known patchpack to use a version just above ours.
Definition saveload.h:326
@ ExtendPersistentStorage
Saveload version: 201, GitHub pull request: 6885 Extend NewGRF persistent storages.
Definition saveload.h:290
@ NoAI
Saveload version: 107, SVN revision: 15027 Replace built in cheating AI with framework for externall...
Definition saveload.h:177
@ LocksUnderBridges
Saveload version: 361, GitHub pull request: 14595 Allow locks under bridges.
Definition saveload.h:418
@ ScriptTownText
Saveload version: 168, SVN revision: 23637 Game scripts can put a text in the town window.
Definition saveload.h:250
@ UnifyWaterClass
Saveload version: 146, SVN revision: 20446 Unify location for storing water class in the map.
Definition saveload.h:224
@ Cities
Saveload version: 56, SVN revision: 9667 Cities that start bigger and grow faster.
Definition saveload.h:116
@ AirportNoise
Saveload version: 96, SVN revision: 13226 Introduce noise for airports, to allow more than two airpo...
Definition saveload.h:164
@ CargoPaymentOverflow
Saveload version: 70, SVN revision: 10541 Fix overflow of cargo payment rates, plus preparation for ...
Definition saveload.h:133
@ RiffToArray
Saveload version: 294, GitHub pull request: 9375 Changed many ChunkType::Riff chunks to ChunkType::A...
Definition saveload.h:337
@ FixOrderBackup
Saveload version: 192, SVN revision: 26700 Fix saving of order backups.
Definition saveload.h:279
@ BridgeWormhole
Saveload version: 42, SVN revision: 7573 Bridges become wormholes, so more things can be built under...
Definition saveload.h:99
@ TramLivery
Saveload version: 63, SVN revision: 9956 Add separate livery for trams.
Definition saveload.h:124
@ GSIndustryControl
Saveload version: 287, GitHub pull request: 7912 and 8115 GS industry control.
Definition saveload.h:329
@ LinkFarmFieldToIndustry
Saveload version: 32, SVN revision: 6001 Link farm fields to the industry, so it gets removed when t...
Definition saveload.h:87
@ ConsistentPartialZ
Saveload version: 306, GitHub pull request: 10570 Conversion from an inconsistent partial Z calculat...
Definition saveload.h:352
@ ScriptSettingsProfile
Saveload version: 178, SVN revision: 24789 Setting for the difficulty profile of AIs.
Definition saveload.h:262
@ HideEnginesForCompany
Saveload version: 193, SVN revision: 26802 Hiding of engines for a company.
Definition saveload.h:280
constexpr size_t SlVarSize(VarMemType type)
Return expect size in bytes of a VarType.
Definition saveload.h:1185
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
bool IsSavegameVersionBeforeOrAt(SaveLoadVersion major)
Checks whether the savegame is below or at major.
Definition saveload.h:1239
void SlGlobList(const SaveLoadTable &slt)
Save or Load (a list of) global variables.
ChunkType
Type of a chunk.
Definition saveload.h:445
@ SparseTable
A SparseArray with a header describing the elements.
Definition saveload.h:450
@ ReadOnly
Chunk is never saved.
Definition saveload.h:453
@ Table
An Array with a header describing the elements.
Definition saveload.h:449
@ FileTypeMask
All ChunkType values that are saved in the file have to be within this mask.
Definition saveload.h:452
@ Riff
4 bits store the chunk type, 28 bits the number of bytes.
Definition saveload.h:446
@ SparseArray
Array of elements with index for each element.
Definition saveload.h:448
int64_t ReadValue(const void *ptr, VarMemType conv)
Return a signed-long version of the value of a setting.
Definition saveload.cpp:886
void SlAutolength(AutolengthProc *proc, int arg)
Do something of which I have no idea what it is :P.
void SlReadString(std::string &str, size_t length)
Read the given amount of bytes from the buffer into the string.
void SlSetStructListLength(size_t length)
Set the length of this list.
Label< struct ChunkIdTag > ChunkId
Label/unique identifier for each of the chunks in the savegame.
Definition saveload.h:457
Types often used outside the saveload code related to saving and loading games.
std::span< const struct SaveLoad > SaveLoadTable
A table of SaveLoad entries.
std::vector< Titem, ScriptStdAllocator< Titem > > Array
Definition of a simple array.
Types for strings.
EnumBitSet< StringValidationSetting, uint8_t > StringValidationSettings
Bitset of StringValidationSetting elements.
Definition string_type.h:57
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
Base for a four character label/tag/id.
Container for cargo from the same location and time.
Definition cargopacket.h:40
virtual void FixPointers() const
Fix the pointers.
Definition saveload.h:492
ChunkType type
Type of the chunk.
Definition saveload.h:462
virtual void LoadCheck(size_t len=0) const
Load the chunk for game preview.
ChunkHandler(ChunkId id, ChunkType type)
Create this ChunkHandler.
Definition saveload.h:469
ChunkId id
Unique ID (4 letters).
Definition saveload.h:461
std::string GetName() const
Get the name of this chunk.
Definition saveload.h:505
virtual void Load() const =0
Load the chunk.
virtual ~ChunkHandler()=default
Ensure the destructor of the sub classes are called as well.
virtual void Save() const
Save the chunk.
Definition saveload.h:478
Struct to store engine replacements.
A four character label/tag/id.
Shared order list linking together the linked list of orders and the list of vehicles sharing this or...
Definition order_base.h:383
A Stop for a Road Vehicle.
SaveLoad information for backwards compatibility.
Definition saveload.h:1173
std::string_view name
Name of the field.
Definition saveload.h:1174
SaveLoadVersion version_to
Save/load the variable before this savegame version.
Definition saveload.h:1177
SaveLoadVersion version_from
Save/load the variable starting from this savegame version.
Definition saveload.h:1176
uint16_t null_length
Length of the NULL field.
Definition saveload.h:1175
SaveLoad type struct.
Definition saveload.h:763
static constexpr AddressFunction ToAddressFunction(AddressFunction< T > address_func)
To be able to get the type information into the SaveLoad constructing functions, we need some infrast...
Definition saveload.h:905
static SaveLoad StructList(std::string name, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion)
Storage of a list of structs, optionally in some savegame versions.
Definition saveload.h:1102
uint16_t length
(Conditional) length of the variable (eg. arrays) (max array size is 65536 elements).
Definition saveload.h:778
static SaveLoad SaveByte(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion)
Storage of a byte variable in some savegame versions that is not automatically read by the SaveLoad c...
Definition saveload.h:1124
std::shared_ptr< SaveLoadHandler > handler
Custom handler for Save/Load procs.
Definition saveload.h:783
static constexpr bool IsIntegralFileType(VarFileType file_type)
Check whether the given file type is stored as a simple number.
Definition saveload.h:790
AddressFunction address_func
Callback function the get the actual variable address in memory.
Definition saveload.h:781
static SaveLoad Variable(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion, size_t extra=0)
Storage of a variable in some savegame versions.
Definition saveload.h:925
static SaveLoad ReferenceList(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion)
Storage of a list of references to pool elements in some savegame versions.
Definition saveload.h:1077
const R *(*)(const void *base, size_t extra) AddressFunction
Function that returns the address of a variable.
Definition saveload.h:773
static SaveLoad Array(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion, size_t extra=0)
Storage of an array in some savegame versions.
Definition saveload.h:1025
SaveLoadVersion version_to
Save/load the variable before this savegame version.
Definition saveload.h:780
static SaveLoad Vector(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion)
Storage of a vector in some savegame versions.
Definition saveload.h:1052
static SaveLoad ReferenceVector(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion)
Storage of a vector of references to pool elements in some savegame versions.
Definition saveload.h:1148
SaveLoadType cmd
The action to take with the saved/loaded type, All types need different action.
Definition saveload.h:776
static SaveLoad Reference(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion)
Storage of a reference to a pool element in some savegame versions.
Definition saveload.h:950
static SaveLoad Struct(std::string name, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion)
Storage of a structs, optionally in some savegame versions.
Definition saveload.h:1000
std::string name
Name of this field (optional, used for tables).
Definition saveload.h:775
VarType conv
Type of the variable to be saved; this field combines both FileVarType and MemVarType.
Definition saveload.h:777
static constexpr bool IsValidRefType(SLRefType ref_type)
Checks whether the memory type and given reference type match.
Definition saveload.h:878
static constexpr VarMemType DetermineMemType()
Determine the VarMemType type given the variable's decltype and occasionally the file type to disting...
Definition saveload.h:817
size_t extra_data
Extra data for the callback proc.
Definition saveload.h:782
static SaveLoad String(std::string name, AddressFunction< T > address_func, StringValidationSettings string_validation_settings={}, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion, size_t extra=0)
Storage of a string in some savegame versions.
Definition saveload.h:976
SaveLoadVersion version_from
Save/load the variable starting from this savegame version.
Definition saveload.h:779
Station data structure.
Town data structure.
Definition town.h:64
Container of a variable's characteristics about a variable's storage.
Definition saveload.h:674
constexpr VarType()
Create an empty VarType.
Definition saveload.h:681
SLRefType ref
The reference type.
Definition saveload.h:678
constexpr VarType(StringValidationSettings string_validation_settings)
Create a String var type with the given string validation settings.
Definition saveload.h:694
VarMemType mem
The way of storing data in memory.
Definition saveload.h:676
StringValidationSettings string_validation_settings
Any settings related to validation of the strings.
Definition saveload.h:677
constexpr bool operator==(const VarType &other) const =default
Equality operator.
VarFileType file
The way of storing data in the file.
Definition saveload.h:675
constexpr VarType(VarFileType file, VarMemType mem)
Create a VarType with the given file and memory configurations.
Definition saveload.h:688
constexpr VarType(SLRefType ref)
Create a VarType linking to a reference.
Definition saveload.h:701
Container for holding some default VarType instances.
Definition saveload.h:712
static constexpr VarType U16
Store a 16 bits unsigned int.
Definition saveload.h:717
static constexpr VarType U8
Store a 8 bits unsigned int.
Definition saveload.h:715
static constexpr VarType STR
Store string.
Definition saveload.h:723
static constexpr VarType I16
Store a 16 bits signed int.
Definition saveload.h:716
static constexpr VarType NAME
A string stored in the custom string array.
Definition saveload.h:724
static constexpr VarType I64
Store a 64 bits signed int.
Definition saveload.h:720
static constexpr VarType U64
Store a 64 bits unsigned int.
Definition saveload.h:721
static constexpr VarType I8
Store a 8 bits signed int.
Definition saveload.h:714
static constexpr VarType LABEL
Store a Label as-is.
Definition saveload.h:725
static constexpr VarType U32
Store a 32 bits unsigned int.
Definition saveload.h:719
static constexpr VarType STRINGID
Store a StringID.
Definition saveload.h:722
static constexpr VarType I32
Store a 32 bits signed int.
Definition saveload.h:718
static constexpr VarType BOOL
Store a boolean (as int8).
Definition saveload.h:713
Vehicle data structure.
Base of the town class.
TownLayout
Town Layouts.
Definition town_type.h:83
WaterClass
classes of water (for WaterTileType::Clear water tile type).
Definition water_map.h:41
WaterTileType
Available water tile types.
Definition water_map.h:31