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