OpenTTD Source 20260711-master-g3fb3006dff
saveload.h File Reference

Functions/types related to saving and loading games. More...

#include "saveload_error.hpp"
#include "../fileio_type.h"
#include "../fios.h"

Go to the source code of this file.

Data Structures

struct  FileToSaveLoad
 Deals with the type of the savegame, independent of extension. More...
struct  ChunkHandler
 Handlers and description of chunk. More...
class  SaveLoadHandler
 Handler for saving/loading an object to/from disk. More...
class  DefaultSaveLoadHandler< TImpl, TObject >
 Default handler for saving/loading an object to/from disk. More...
struct  VarType
 Container of a variable's characteristics about a variable's storage. More...
struct  VarTypes
 Container for holding some default VarType instances. More...
struct  SaveLoad
 SaveLoad type struct. More...
struct  SaveLoadCompat
 SaveLoad information for backwards compatibility. More...
class  VectorSaveLoadHandler< TImpl, TObject, TElementType, MAX_LENGTH >
 Default handler for saving/loading a vector to/from disk. More...

Macros

#define SLE_GENERAL_NAME(cmd, name, base, variable, type, length, from, to, extra)
 Storage of simple variables, references (pointers), and arrays.
#define SLE_GENERAL(cmd, base, variable, type, length, from, to, extra)
 Storage of simple variables, references (pointers), and arrays with a custom name.
#define SLE_CONDVAR(base, variable, type, from, to)
 Storage of a variable in some savegame versions.
#define SLE_CONDVARNAME(base, variable, name, type, from, to)
 Storage of a variable in some savegame versions.
#define SLE_CONDREF(base, variable, type, from, to)
 Storage of a reference in some savegame versions.
#define SLE_CONDARR(base, variable, type, length, from, to)
 Storage of a fixed-size array of SaveLoadType::Variable elements in some savegame versions.
#define SLE_CONDARRNAME(base, variable, name, type, length, from, to)
 Storage of a fixed-size array of SaveLoadType::Variable elements in some savegame versions.
#define SLE_CONDSSTR(base, variable, type, from, to)
 Storage of a std::string in some savegame versions.
#define SLE_CONDSSTRNAME(base, variable, name, type, from, to)
 Storage of a std::string in some savegame versions.
#define SLE_CONDREFLIST(base, variable, type, from, to)
 Storage of a list of SaveLoadType::Reference elements in some savegame versions.
#define SLE_CONDREFVECTOR(base, variable, type, from, to)
 Storage of a vector of SaveLoadType::Reference elements in some savegame versions.
#define SLE_CONDVECTOR(base, variable, type, from, to)
 Storage of a vector of SaveLoadType::Variable elements in some savegame versions.
#define SLE_CONDVECTOR(base, variable, type, from, to)
 Storage of a vector of SaveLoadType::Variable elements in some savegame versions.
#define SLE_VAR(base, variable, type)
 Storage of a variable in every version of a savegame.
#define SLE_VARNAME(base, variable, name, type)
 Storage of a variable in every version of a savegame.
#define SLE_REF(base, variable, type)
 Storage of a reference in every version of a savegame.
#define SLE_ARR(base, variable, type, length)
 Storage of fixed-size array of SaveLoadType::Variable elements in every version of a savegame.
#define SLE_ARRNAME(base, variable, name, type, length)
 Storage of fixed-size array of SaveLoadType::Variable elements in every version of a savegame.
#define SLE_SSTR(base, variable, type)
 Storage of a std::string in every savegame version.
#define SLE_SSTRNAME(base, variable, name, type)
 Storage of a std::string in every savegame version.
#define SLE_REFLIST(base, variable, type)
 Storage of a list of SaveLoadType::Reference elements in every savegame version.
#define SLE_REFVECTOR(base, variable, type)
 Storage of a vector of SaveLoadType::Reference elements in every savegame version.
#define SLE_SAVEBYTE(base, variable)
 Only write byte during saving; never read it during loading.
#define SLEG_GENERAL(name, cmd, variable, type, length, from, to, extra)
 Storage of global simple variables, references (pointers), and arrays.
#define SLEG_CONDVAR(name, variable, type, from, to)
 Storage of a global variable in some savegame versions.
#define SLEG_CONDREF(name, variable, type, from, to)
 Storage of a global reference in some savegame versions.
#define SLEG_CONDARR(name, variable, type, length, from, to)
 Storage of a global fixed-size array of SaveLoadType::Variable elements in some savegame versions.
#define SLEG_CONDSSTR(name, variable, type, from, to)
 Storage of a global std::string in some savegame versions.
#define SLEG_CONDSTRUCT(name, handler, from, to)
 Storage of a structs in some savegame versions.
#define SLEG_CONDREFLIST(name, variable, type, from, to)
 Storage of a global reference list in some savegame versions.
#define SLEG_CONDVECTOR(name, variable, type, from, to)
 Storage of a global vector of SaveLoadType::Variable elements in some savegame versions.
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
 Storage of a list of structs in some savegame versions.
#define SLEG_VAR(name, variable, type)
 Storage of a global variable in every savegame version.
#define SLEG_REF(name, variable, type)
 Storage of a global reference in every savegame version.
#define SLEG_ARR(name, variable, type, length)
 Storage of a global fixed-size array of SaveLoadType::Variable elements in every savegame version.
#define SLEG_SSTR(name, variable, type)
 Storage of a global std::string in every savegame version.
#define SLEG_STRUCT(name, handler)
 Storage of a structs in every savegame version.
#define SLEG_REFLIST(name, variable, type)
 Storage of a global reference list in every savegame version.
#define SLEG_VECTOR(name, variable, type)
 Storage of a global vector of SaveLoadType::Variable elements in every savegame version.
#define SLEG_STRUCTLIST(name, handler)
 Storage of a list of structs in every savegame version.
#define SLC_VAR(name)
 Field name where the real SaveLoad can be located.
#define SLC_NULL(length, from, to)
 Empty space in every savegame version.

Typedefs

typedef void AutolengthProc(int)
using ChunkHandlerRef = std::reference_wrapper<const ChunkHandler>
 A reference to ChunkHandler.
using ChunkHandlerTable = std::span<const ChunkHandlerRef>
 A table of ChunkHandler entries.
using SaveLoadTable = std::span<const struct SaveLoad>
 A table of SaveLoad entries.
using SaveLoadCompatTable = std::span<const struct SaveLoadCompat>
 A table of SaveLoadCompat entries.
typedef void * SaveLoadAddrProc(void *base, size_t extra)

Enumerations

enum class  SaveLoadVersion : uint16_t {
  MinVersion , BigCurrency , VehicleCurrencyStationChanges , BiggerStationVariables ,
  TownTolerancePauseMode , BigMap , MultipleRoadStops , LargerCargoSource ,
  LargerUnitNumber , LargerTownCargoStatistics , LargerTownCounter , LargerTownIterator ,
  LinkWaypointToTown , LargerAIStateCounter , TransferOrder , MoveSemaphoreBits ,
  EngineRenew , StoreWaypointIdInMap , RemoveMinorVersion , EngineRenewPool ,
  NoMultiheadReference , RemoveOldPbs , SavePatches , RemoveAutosaveInterval ,
  Elrail , ImproveMultistop , LastVehicleType , NewGRFStations ,
  Yapf , MoreUnderBridges , Tgp , BigDates ,
  LinkFarmFieldToIndustry , SaveYapfSettings , Liveries , LiveryRefit ,
  RefitOrders , Utf8 , DisableElrailSetting , FreightWeight ,
  GradualLoading , NewGRFSettings , BridgeWormhole , UnifyAnimationState ,
  CargoSourceTile , CountPaidForCargo , MoreAirportBlocks , DriveThroughRoadStops ,
  RailTrackTypeUnification , SimplifyPlayerFace , AircraftSpeedHolding , FeederShare ,
  StatueOwner , NewGRFHouses , TownGrowthControl , NewGRFCargo ,
  Cities , FifoLoading , VeryLowTownIndustryNumber , TownLayout ,
  VehicleGroups , MultipleRoadTypes , AdjacentStations , TramLivery ,
  MultipleSignalTypes , UnifyCurrency , NewGRFTownNames , Timetables ,
  CargoPackets , MoreCargoPackets , CargoPaymentOverflow , UngroupedVehicles ,
  SplitStationTypeFromGfxid , NewGRFIndustryLayout , FixStationPickupAccounting , Autoslope ,
  NewGRFPersistentStorage , CleanupUnconnectedRoads , StoreIndustryCargo , FairPlaySettings ,
  NewGRFMoreAnimation , FixTreeGround , NewGRFIndustryRandomTriggers , DepotWaterOwners ,
  ReplaceCustomNameArray , MaglevMonorailPaxWagonLivery , WaterClass , SimplifyPathfinderSettings ,
  FractionProfitRunningTicks , MoreWaypointsPerTown , PlaneSpeedFactor , MoreHouseAnimationFrames ,
  RemoveHouseCount , ImprovedOrders , FixCompanyCargoTypes , MoreEngineTypes ,
  AirportNoise , MergeOptsPats , Gamelog , IndustryTileWaterClass ,
  Yapp , NewGRFPalette , SpreadIndustryProductionChanges , NewGRFSuppliedStationName ,
  MoreCompanies , OrderList , DistantStationJoining , NoAI ,
  StoreAIVersion , NextCompetitorStartOverflow , RemoveOldAISettings , FreeformEdges ,
  SplitHQ , RoadLayoutPerTown , SeparateRoadOwners , CustomTownNumber ,
  GamelogEmergency , PlatformStopLocation , DigitGroupSeparator , PauseModes ,
  CompanyServiceIntervals , CargoPayments , WaypointMoreLikeStation , UnifyWaypointAndStation ,
  MultiTileWaypoints , RemoveSubsidyStationBinding , CumulatedInflation , TownAcceptance ,
  FoundTown , TimetableStart , RoadStopOccupancyPenalty , MaximumDepotPenalty ,
  DisallowTreeBuilding , TrainSlopeSteepness , VirtualFeederSharePayment , RocksStayUnderSnow ,
  SplitLoadWaitCounters , AirportAnimationFrames , ReducePlaneCrashes , RvRealisticAcceleration ,
  StoreAirportSize , UniqueDepotNames , NewGRFDepotBuildDate , DisableTownLevelCrossing ,
  ReorderUnmovableRemoveReserved , NewGRFAirportSmoke , UnifyWaterClass , UnifyAnimationFrame ,
  IndustryPlatform , CustomSeaLevel , FractionalCargoDelivery , StoreNewGRFVersion ,
  IndustryManagement , LeaveRoadStopSeparately , PauseLevel , NewGRFObjectView ,
  TerraformLimits , UnifyGroundVehicles , TrackRealAndAutoOrders , MaxLengthAndReverseSignals ,
  DisallowRoadReconstruction , PersistentStoragePool , NewGRFCustomCargoAging , Rivers ,
  VehicleCentreAndZPos , ScriptTownGrowth , InfrastructureMaintenanceCosts , NewGRFAircraftRange ,
  ScriptTownText , MoveSccEncoded , CountIndividualCargoes , ScenarioDeitySigns ,
  OrderMaxSpeed , FixRoadOwnership , CurrentOrderMaxSpeed , AutoreplaceWhenOldTreeLimit ,
  BackupOrderState , MonthlyBankruptcyCheck , ScriptSettingsProfile , RobustEnginePreview ,
  ServiceIntervalPercent , CargoReservation , GoalProgressPlaneAcceleration , Cargodist ,
  SeparateLocaleUnits , Storybooks , ObjectTypeToPool , LinkgraphRestrictedFlow ,
  UnifyRvTravelTime , GroupHierarchy , SeparateOrderTravelWaitTime , LinkgraphLocationDisasterStore ,
  FixOrderBackup , HideEnginesForCompany , MaxBridgeMapHeight , Distinguish16 ,
  Distinguish17 , StoreMapVariety , TownGrowthInGameTicks , ExtendCargotypes ,
  ExtendRailtypes , ExtendPersistentStorage , ExtendIndustryCargoSlots , ShipPathCache ,
  ShipRotation , GroupLiveries , ShipsStopInLocks , FixCargoMonitor ,
  TownCargogen , ShipCurvePenalty , ServeNeutralIndustries , RoadvehPathCache ,
  RemoveOldPathfinder , TreesWaterClass , RoadTypes , ScriptMemlimit ,
  MultitileDocks , TradingAge , EndingYear , RemoveTownCargoCache ,
  StartPatchpacks , EndPatchpacks = 286 , GSIndustryControl , VehMotionCounter ,
  IndustryText , MapgenSettingsRevamp , GroupReplaceWagonRemoval , CustomSubsidyDuration ,
  SaveloadListLength , RiffToArray , TableChunks , ScriptInt64 ,
  LinkgraphTravelTime , DockDockingtiles , RepairObjectDockingTiles , U64TickCounter ,
  LastLoadingTick , MultitrackLevelCrossings , NewGRFRoadStops , LinkgraphEdges ,
  VelocityNautical , ConsistentPartialZ , MoreCargoAge , LinkgraphSeconds ,
  AIStartDate , ExtendVehicleRandom , ExtendEntityMapping , DisasterVehState ,
  SavegameId , StringGamelog , IndustryCargoReorganise , PeriodsInTransitRename ,
  NewGRFLastService , RemoveLoadedAtXY , CargoTravelled , StationRatingCheat ,
  TimetableStartTicks , TimetableStartTicksFix , TimetableTicksType , WaterRegions ,
  WaterRegionEvalSimplified , EconomyDate , EconomyModeTimekeepingUnits , CalendarSubDateFract ,
  ShipAcceleration , MaxLoanForCompany , DepotUnbunching , AILocalConfig ,
  ScriptRandomizer , VehicleEconomyAge , CompanyAllowList , GroupNumbers ,
  IncreaseStationTypeFieldSize , RoadWaypoints , CompanyInauguratedPeriod , RoadStopTileData ,
  CompanyAllowListV2 , WaterTileType , ProductionHistory , RoadTypeLabelMap ,
  NonfloodingWaterTiles , PathCacheFormat , AnimatedTileStateInMap , IncreaseHouseLimit ,
  CompanyInauguratedPeriodV2 , EncodedStringFormat , ProtectPlacedHouses , ScriptSaveInstances ,
  FixSccEncodedNegative , OrdersOwnedByOrderlist , FaceStyles , IndustryNumValidHistory ,
  IndustryAcceptedHistory , TownSupplyHistory , StationsUnderBridges , DocksUnderBridges ,
  LocksUnderBridges , EngineMultiRailtype , SignTextColours , BuoysAt0_0 ,
  DriveBackwards , DepotsUnderBridges , MaxVersion
}
 SaveLoad versions Previous savegame versions, the trunk revision where they were introduced and the released version that had that particular savegame version. More...
enum class  SaveLoadResult : uint8_t { Ok , Error , ReInit }
 Save or load result codes. More...
enum  SavegameType : uint8_t {
  TTD , TTDP1 , TTDP2 , OTTD ,
  TTO , Invalid = 0xFF
}
 Types of save games. More...
enum class  ChunkType : uint8_t {
  Riff = 0 , Array = 1 , SparseArray = 2 , Table = 3 ,
  SparseTable = 4 , FileTypeMask = 0xf , ReadOnly
}
 Type of a chunk. More...
enum class  SLRefType : uint8_t {
  Vehicle = 1 , Station = 2 , Town = 3 , OldVehicle = 4 ,
  RoadStop = 5 , EngineRenew = 6 , CargoPacket = 7 , OrderList = 8 ,
  Storage = 9 , LinkGraph = 10 , LinkGraphJob = 11
}
 Type of reference (SLE_REF, SLE_CONDREF). More...
enum class  VarFileType : uint8_t {
  I8 = 1 , U8 = 2 , I16 = 3 , U16 = 4 ,
  I32 = 5 , U32 = 6 , I64 = 7 , U64 = 8 ,
  StringID = 9 , String = 10 , Struct = 11
}
 The types/structures of data that can be stored in the file. More...
enum class  VarMemType : uint8_t {
  Bool = 0 , I8 = 1 , U8 = 2 , I16 = 3 ,
  U16 = 4 , I32 = 5 , U32 = 6 , I64 = 7 ,
  U64 = 8 , Null = 9 , Str = 12 , StrQ = 13 ,
  Name = 14
}
 The types/structures of data we have in memory. More...
enum class  SaveLoadType : uint8_t {
  Variable = 0 , Reference = 1 , Struct = 2 , String = 4 ,
  Array = 5 , Vector = 7 , ReferenceList = 8 , StructList = 9 ,
  SaveByte = 10 , Null = 11 , ReferenceVector = 12
}
 Type of data saved. More...

Functions

std::string GenerateDefaultSaveName ()
 Get the default name for a savegame or screenshot.
void SetSaveLoadError (StringID str)
 Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friends).
EncodedString GetSaveLoadErrorType ()
 Return the appropriate initial string for an error depending on whether we are saving or loading.
EncodedString GetSaveLoadErrorMessage ()
 Return the description of the error.
SaveLoadResult SaveOrLoad (std::string_view filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded=true)
 Main Save or Load function where the high-level saveload functions are handled.
void WaitTillSaved ()
void ProcessAsyncSaveFinish ()
 Handle async save finishes.
void DoExitSave ()
 Do a save when exiting the game (_settings_client.gui.autosave_on_exit).
void DoAutoOrNetsave (FiosNumberedSaveName &counter)
 Create an autosave or netsave.
SaveLoadResult SaveWithFilter (std::shared_ptr< struct SaveFilter > writer, bool threaded)
SaveLoadResult LoadWithFilter (std::shared_ptr< struct LoadFilter > reader)
constexpr VarType operator| (VarFileType file, VarMemType mem)
 Transitional helper function to combine a file and memory storage configuration.
constexpr size_t SlVarSize (VarMemType type)
 Return expect size in bytes of a VarType.
constexpr bool SlCheckVarSize (SaveLoadType cmd, VarType type, size_t length, size_t size)
 Check if a saveload cmd/type/length entry matches the size of the variable.
bool IsSavegameVersionBefore (SaveLoadVersion major, uint8_t minor=0)
 Checks whether the savegame is below major.
bool IsSavegameVersionBeforeOrAt (SaveLoadVersion major)
 Checks whether the savegame is below or at major.
bool SlIsObjectCurrentlyValid (SaveLoadVersion version_from, SaveLoadVersion version_to)
 Checks if some version from/to combination falls within the range of the active savegame version.
void * GetVariableAddress (const void *object, const SaveLoad &sld)
 Get the address of the variable.
int64_t ReadValue (const void *ptr, VarMemType conv)
 Return a signed-long version of the value of a setting.
void WriteValue (void *ptr, VarMemType conv, int64_t val)
 Write the value of a setting.
void SlSetArrayIndex (uint index)
static void SlSetArrayIndex (const ConvertibleThroughBase auto &index)
int SlIterateArray ()
 Iterate through the elements of an array and read the whole thing.
void SlSetStructListLength (size_t length)
 Set the length of this list.
size_t SlGetStructListLength (size_t limit)
 Get the length of this list; if it exceeds the limit, error out.
void SlAutolength (AutolengthProc *proc, int arg)
 Do something of which I have no idea what it is :P.
size_t SlGetFieldLength ()
 Get the length of the current object.
void SlSetLength (size_t length)
 Sets the length of either a RIFF object or the number of items in an array.
size_t SlCalcObjMemberLength (const void *object, const SaveLoad &sld)
size_t SlCalcObjLength (const void *object, const SaveLoadTable &slt)
 Calculate the size of an object.
uint8_t SlReadByte ()
 Wrapper for reading a byte from the buffer.
void SlReadString (std::string &str, size_t length)
 Read the given amount of bytes from the buffer into the string.
void SlWriteByte (uint8_t b)
 Wrapper for writing a byte to the dumper.
void SlGlobList (const SaveLoadTable &slt)
 Save or Load (a list of) global variables.
void SlCopy (void *object, size_t length, VarType conv)
 Copy a list of SaveLoadType::Variables to/from a savegame.
std::vector< SaveLoadSlTableHeader (const SaveLoadTable &slt)
 Save or Load a table header.
std::vector< SaveLoadSlCompatTableHeader (const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
 Load a table header in a savegame compatible way.
void SlObject (void *object, const SaveLoadTable &slt)
 Main SaveLoad function.
bool SaveloadCrashWithMissingNewGRFs ()
 Did loading the savegame cause a crash?
void SlSkipBytes (size_t length)
 Read in bytes from the file/data structure but don't do anything with them, discarding them in effect.

Variables

FileToSaveLoad _file_to_saveload
 File to save or load in the openttd loop.
std::string _savegame_format
 how to compress savegames
bool _do_autosave
 are we doing an autosave at the moment?

Detailed Description

Functions/types related to saving and loading games.

Definition in file saveload.h.

Macro Definition Documentation

◆ SLC_NULL

#define SLC_NULL ( length,
from,
to )
Value:
{{}, length, from, to}

Empty space in every savegame version.

Parameters
lengthLength of the empty space in bytes.
fromFirst savegame version that has the empty space.
toLast savegame version that has the empty space.

Definition at line 1270 of file saveload.h.

◆ SLC_VAR

#define SLC_VAR ( name)
Value:
@ MinVersion
First savegame version.
Definition saveload.h:31
@ MaxVersion
Highest possible saveload version.
Definition saveload.h:421

Field name where the real SaveLoad can be located.

Parameters
nameThe name of the field.

Definition at line 1262 of file saveload.h.

◆ SLE_ARR

#define SLE_ARR ( base,
variable,
type,
length )
Value:
#define SLE_CONDARR(base, variable, type, length, from, to)
Storage of a fixed-size array of SaveLoadType::Variable elements in some savegame versions.
Definition saveload.h:936

Storage of fixed-size array of SaveLoadType::Variable elements in every version of a savegame.

Parameters
baseName of the class or struct containing the array.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
lengthNumber of elements in the array.

Definition at line 1043 of file saveload.h.

◆ SLE_ARRNAME

#define SLE_ARRNAME ( base,
variable,
name,
type,
length )
Value:
#define SLE_CONDARRNAME(base, variable, name, type, length, from, to)
Storage of a fixed-size array of SaveLoadType::Variable elements in some savegame versions.
Definition saveload.h:948

Storage of fixed-size array of SaveLoadType::Variable elements in every version of a savegame.

Parameters
baseName of the class or struct containing the array.
variableName of the variable in the class or struct referenced by base.
nameField name for table chunks.
typeStorage of the data in memory and in the savegame.
lengthNumber of elements in the array.

Definition at line 1053 of file saveload.h.

◆ SLE_CONDARR

#define SLE_CONDARR ( base,
variable,
type,
length,
from,
to )
Value:
SLE_GENERAL(SaveLoadType::Array, base, variable, type, length, from, to, 0)
#define SLE_GENERAL(cmd, base, variable, type, length, from, to, extra)
Storage of simple variables, references (pointers), and arrays with a custom name.
Definition saveload.h:894
@ Array
Save/load a fixed-size array of SaveLoadType::Variable elements.
Definition saveload.h:773

Storage of a fixed-size array of SaveLoadType::Variable elements in some savegame versions.

Parameters
baseName of the class or struct containing the array.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
lengthNumber of elements in the array.
fromFirst savegame version that has the array.
toLast savegame version that has the array.

Definition at line 936 of file saveload.h.

◆ SLE_CONDARRNAME

#define SLE_CONDARRNAME ( base,
variable,
name,
type,
length,
from,
to )
Value:
SLE_GENERAL_NAME(SaveLoadType::Array, name, base, variable, type, length, from, to, 0)
#define SLE_GENERAL_NAME(cmd, name, base, variable, type, length, from, to, extra)
Storage of simple variables, references (pointers), and arrays.
Definition saveload.h:875

Storage of a fixed-size array of SaveLoadType::Variable elements in some savegame versions.

Parameters
baseName of the class or struct containing the array.
variableName of the variable in the class or struct referenced by base.
nameField name for table chunks.
typeStorage of the data in memory and in the savegame.
lengthNumber of elements in the array.
fromFirst savegame version that has the array.
toLast savegame version that has the array.

Definition at line 948 of file saveload.h.

◆ SLE_CONDREF

#define SLE_CONDREF ( base,
variable,
type,
from,
to )
Value:
SLE_GENERAL(SaveLoadType::Reference, base, variable, type, 0, from, to, 0)
@ Reference
Save/load a reference.
Definition saveload.h:768

Storage of a reference in some savegame versions.

Parameters
baseName of the class or struct containing the variable.
variableName of the variable in the class or struct referenced by base.
typeType of the reference, a value from SLRefType.
fromFirst savegame version that has the field.
toLast savegame version that has the field.

Definition at line 925 of file saveload.h.

Referenced by OrderBackup::GetOrderBackupDescription.

◆ SLE_CONDREFLIST

#define SLE_CONDREFLIST ( base,
variable,
type,
from,
to )
Value:
SLE_GENERAL(SaveLoadType::ReferenceList, base, variable, type, 0, from, to, 0)
@ ReferenceList
Save/load a list of SaveLoadType::Reference elements.
Definition saveload.h:775

Storage of a list of SaveLoadType::Reference elements in some savegame versions.

Parameters
baseName of the class or struct containing the list.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the list.
toLast savegame version that has the list.

Definition at line 979 of file saveload.h.

◆ SLE_CONDREFVECTOR

#define SLE_CONDREFVECTOR ( base,
variable,
type,
from,
to )
Value:
SLE_GENERAL(SaveLoadType::ReferenceVector, base, variable, type, 0, from, to, 0)
@ ReferenceVector
Save/load a vector of SaveLoadType::Reference elements.
Definition saveload.h:781

Storage of a vector of SaveLoadType::Reference elements in some savegame versions.

Parameters
baseName of the class or struct containing the vector.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the vector.
toLast savegame version that has the vector.

Definition at line 989 of file saveload.h.

◆ SLE_CONDSSTR

#define SLE_CONDSSTR ( base,
variable,
type,
from,
to )
Value:
SLE_GENERAL(SaveLoadType::String, base, variable, type, 0, from, to, 0)
@ String
Save/load a std::string.
Definition saveload.h:771

Storage of a std::string in some savegame versions.

Parameters
baseName of the class or struct containing the string.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the string.
toLast savegame version that has the string.

Definition at line 958 of file saveload.h.

◆ SLE_CONDSSTRNAME

#define SLE_CONDSSTRNAME ( base,
variable,
name,
type,
from,
to )
Value:
SLE_GENERAL_NAME(SaveLoadType::String, name, base, variable, type, 0, from, to, 0)

Storage of a std::string in some savegame versions.

Parameters
baseName of the class or struct containing the string.
variableName of the variable in the class or struct referenced by base.
nameField name for table chunks.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the string.
toLast savegame version that has the string.

Definition at line 969 of file saveload.h.

◆ SLE_CONDVAR

#define SLE_CONDVAR ( base,
variable,
type,
from,
to )
Value:
SLE_GENERAL(SaveLoadType::Variable, base, variable, type, 0, from, to, 0)
@ Variable
Save/load a variable.
Definition saveload.h:767

Storage of a variable in some savegame versions.

Parameters
baseName of the class or struct containing the variable.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the field.
toLast savegame version that has the field.

Definition at line 904 of file saveload.h.

Referenced by CargoPacket::GetCargoPacketDesc, and OrderBackup::GetOrderBackupDescription.

◆ SLE_CONDVARNAME

#define SLE_CONDVARNAME ( base,
variable,
name,
type,
from,
to )
Value:
SLE_GENERAL_NAME(SaveLoadType::Variable, name, base, variable, type, 0, from, to, 0)

Storage of a variable in some savegame versions.

Parameters
baseName of the class or struct containing the variable.
variableName of the variable in the class or struct referenced by base.
nameField name for table chunks.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the field.
toLast savegame version that has the field.

Definition at line 915 of file saveload.h.

Referenced by CargoPacket::GetCargoPacketDesc, OrderBackup::GetOrderBackupDescription, Order::GetOrderDescription, and OrderList::GetOrderListDescription.

◆ SLE_CONDVECTOR [1/2]

#define SLE_CONDVECTOR ( base,
variable,
type,
from,
to )
Value:
SLE_GENERAL(SaveLoadType::Vector, base, variable, type, 0, from, to, 0)
@ Vector
Save/load a vector of SaveLoadType::Variable elements.
Definition saveload.h:774

Storage of a vector of SaveLoadType::Variable elements in some savegame versions.

Parameters
baseName of the class or struct containing the list.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the list.
toLast savegame version that has the list.

Definition at line 999 of file saveload.h.

◆ SLE_CONDVECTOR [2/2]

#define SLE_CONDVECTOR ( base,
variable,
type,
from,
to )
Value:
SLE_GENERAL(SaveLoadType::Vector, base, variable, type, 0, from, to, 0)

Storage of a vector of SaveLoadType::Variable elements in some savegame versions.

Parameters
baseName of the class or struct containing the list.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the list.
toLast savegame version that has the list.

Definition at line 999 of file saveload.h.

◆ SLE_GENERAL

#define SLE_GENERAL ( cmd,
base,
variable,
type,
length,
from,
to,
extra )
Value:
SLE_GENERAL_NAME(cmd, #variable, base, variable, type, length, from, to, extra)

Storage of simple variables, references (pointers), and arrays with a custom name.

Parameters
cmdLoad/save type.
See also
SaveLoadType
Parameters
baseName of the class or struct containing the variable.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
lengthNumber of elements in the array.
fromFirst savegame version that has the field.
toLast savegame version that has the field.
extraExtra data to pass to the address callback function.
Note
In general, it is better to use one of the SLE_* macros below.

Definition at line 894 of file saveload.h.

◆ SLE_GENERAL_NAME

#define SLE_GENERAL_NAME ( cmd,
name,
base,
variable,
type,
length,
from,
to,
extra )
Value:
SaveLoad {name, cmd, type, length, from, to, [] (void *b, size_t) -> void * { \
static_assert(SlCheckVarSize(cmd, type, length, sizeof(static_cast<base *>(b)->variable))); \
assert(b != nullptr); \
return const_cast<void *>(static_cast<const void *>(std::addressof(static_cast<base *>(b)->variable))); \
}, extra, nullptr}
constexpr bool SlCheckVarSize(SaveLoadType cmd, VarType type, size_t length, size_t size)
Check if a saveload cmd/type/length entry matches the size of the variable.
Definition saveload.h:847
SaveLoad type struct.
Definition saveload.h:787

Storage of simple variables, references (pointers), and arrays.

Parameters
cmdLoad/save type.
See also
SaveLoadType
Parameters
nameField name for table chunks.
baseName of the class or struct containing the variable.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.
lengthNumber of elements in the array.
fromFirst savegame version that has the field.
toLast savegame version that has the field.
extraExtra data to pass to the address callback function.
Note
In general, it is better to use one of the SLE_* macros below.

Definition at line 875 of file saveload.h.

◆ SLE_REF

#define SLE_REF ( base,
variable,
type )
Value:
#define SLE_CONDREF(base, variable, type, from, to)
Storage of a reference in some savegame versions.
Definition saveload.h:925

Storage of a reference in every version of a savegame.

Parameters
baseName of the class or struct containing the variable.
variableName of the variable in the class or struct referenced by base.
typeType of the reference, a value from SLRefType.

Definition at line 1034 of file saveload.h.

◆ SLE_REFLIST

#define SLE_REFLIST ( base,
variable,
type )
Value:
#define SLE_CONDREFLIST(base, variable, type, from, to)
Storage of a list of SaveLoadType::Reference elements in some savegame versions.
Definition saveload.h:979

Storage of a list of SaveLoadType::Reference elements in every savegame version.

Parameters
baseName of the class or struct containing the list.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.

Definition at line 1078 of file saveload.h.

Referenced by LinkGraphSchedule::GetLinkGraphScheduleDesc.

◆ SLE_REFVECTOR

#define SLE_REFVECTOR ( base,
variable,
type )
Value:
#define SLE_CONDREFVECTOR(base, variable, type, from, to)
Storage of a vector of SaveLoadType::Reference elements in some savegame versions.
Definition saveload.h:989

Storage of a vector of SaveLoadType::Reference elements in every savegame version.

Parameters
baseName of the class or struct containing the vector.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.

Definition at line 1086 of file saveload.h.

◆ SLE_SAVEBYTE

#define SLE_SAVEBYTE ( base,
variable )
Value:
@ SaveByte
Save (but not load) a byte.
Definition saveload.h:778

Only write byte during saving; never read it during loading.

When using SLE_SAVEBYTE you will have to read this byte before the table this is in is read. This also means SLE_SAVEBYTE can only be used at the top of a chunk. This is intended to be used to indicate what type of entry this is in a list of entries.

Parameters
baseName of the class or struct containing the variable.
variableName of the variable in the class or struct referenced by base.

Definition at line 1098 of file saveload.h.

◆ SLE_SSTR

#define SLE_SSTR ( base,
variable,
type )
Value:
#define SLE_CONDSSTR(base, variable, type, from, to)
Storage of a std::string in some savegame versions.
Definition saveload.h:958

Storage of a std::string in every savegame version.

Parameters
baseName of the class or struct containing the string.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.

Definition at line 1061 of file saveload.h.

Referenced by OrderBackup::GetOrderBackupDescription.

◆ SLE_SSTRNAME

#define SLE_SSTRNAME ( base,
variable,
name,
type )
Value:
#define SLE_CONDSSTRNAME(base, variable, name, type, from, to)
Storage of a std::string in some savegame versions.
Definition saveload.h:969

Storage of a std::string in every savegame version.

Parameters
baseName of the class or struct containing the string.
variableName of the variable in the class or struct referenced by base.
nameField name for table chunks.
typeStorage of the data in memory and in the savegame.

Definition at line 1070 of file saveload.h.

◆ SLE_VAR

#define SLE_VAR ( base,
variable,
type )
Value:
#define SLE_CONDVAR(base, variable, type, from, to)
Storage of a variable in some savegame versions.
Definition saveload.h:904

Storage of a variable in every version of a savegame.

Parameters
baseName of the class or struct containing the variable.
variableName of the variable in the class or struct referenced by base.
typeStorage of the data in memory and in the savegame.

Definition at line 1017 of file saveload.h.

Referenced by CargoPacket::GetCargoPacketDesc, LinkGraph::GetLinkGraphDesc, LinkGraph::GetLinkGraphJobDesc, and OrderBackup::GetOrderBackupDescription.

◆ SLE_VARNAME

#define SLE_VARNAME ( base,
variable,
name,
type )
Value:
#define SLE_CONDVARNAME(base, variable, name, type, from, to)
Storage of a variable in some savegame versions.
Definition saveload.h:915

Storage of a variable in every version of a savegame.

Parameters
baseName of the class or struct containing the variable.
variableName of the variable in the class or struct referenced by base.
nameField name for table chunks.
typeStorage of the data in memory and in the savegame.

Definition at line 1026 of file saveload.h.

Referenced by CargoPacket::GetCargoPacketDesc, and Order::GetOrderDescription.

◆ SLEG_ARR

#define SLEG_ARR ( name,
variable,
type,
length )
Value:
#define SLEG_CONDARR(name, variable, type, length, from, to)
Storage of a global fixed-size array of SaveLoadType::Variable elements in some savegame versions.
Definition saveload.h:1145

Storage of a global fixed-size array of SaveLoadType::Variable elements in every savegame version.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.
lengthNumber of elements in the array.

Definition at line 1218 of file saveload.h.

◆ SLEG_CONDARR

#define SLEG_CONDARR ( name,
variable,
type,
length,
from,
to )
Value:
SLEG_GENERAL(name, SaveLoadType::Array, variable, type, length, from, to, 0)
#define SLEG_GENERAL(name, cmd, variable, type, length, from, to, extra)
Storage of global simple variables, references (pointers), and arrays.
Definition saveload.h:1111

Storage of a global fixed-size array of SaveLoadType::Variable elements in some savegame versions.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.
lengthNumber of elements in the array.
fromFirst savegame version that has the array.
toLast savegame version that has the array.

Definition at line 1145 of file saveload.h.

◆ SLEG_CONDREF

#define SLEG_CONDREF ( name,
variable,
type,
from,
to )
Value:
SLEG_GENERAL(name, SaveLoadType::Reference, variable, type, 0, from, to, 0)

Storage of a global reference in some savegame versions.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the field.
toLast savegame version that has the field.

Definition at line 1134 of file saveload.h.

◆ SLEG_CONDREFLIST

#define SLEG_CONDREFLIST ( name,
variable,
type,
from,
to )
Value:
SLEG_GENERAL(name, SaveLoadType::ReferenceList, variable, type, 0, from, to, 0)

Storage of a global reference list in some savegame versions.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the list.
toLast savegame version that has the list.

Definition at line 1174 of file saveload.h.

◆ SLEG_CONDSSTR

#define SLEG_CONDSSTR ( name,
variable,
type,
from,
to )
Value:
SLEG_GENERAL(name, SaveLoadType::String, variable, type, 0, from, to, 0)

Storage of a global std::string in some savegame versions.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the string.
toLast savegame version that has the string.

Definition at line 1155 of file saveload.h.

◆ SLEG_CONDSTRUCT

#define SLEG_CONDSTRUCT ( name,
handler,
from,
to )
Value:
SaveLoad {name, SaveLoadType::Struct, {}, 0, from, to, nullptr, 0, std::make_shared<handler>()}
@ Struct
Save/load a struct.
Definition saveload.h:769

Storage of a structs in some savegame versions.

Parameters
nameThe name of the field.
handlerSaveLoadHandler for the structs.
fromFirst savegame version that has the struct.
toLast savegame version that has the struct.

Definition at line 1164 of file saveload.h.

◆ SLEG_CONDSTRUCTLIST

#define SLEG_CONDSTRUCTLIST ( name,
handler,
from,
to )
Value:
SaveLoad {name, SaveLoadType::StructList, {}, 0, from, to, nullptr, 0, std::make_shared<handler>()}
@ StructList
Save/load a list of structs.
Definition saveload.h:776

Storage of a list of structs in some savegame versions.

Parameters
nameThe name of the field.
handlerSaveLoadHandler for the list of structs.
fromFirst savegame version that has the list.
toLast savegame version that has the list.

Definition at line 1193 of file saveload.h.

Referenced by OrderBackup::GetOrderBackupDescription, and OrderList::GetOrderListDescription.

◆ SLEG_CONDVAR

#define SLEG_CONDVAR ( name,
variable,
type,
from,
to )
Value:
SLEG_GENERAL(name, SaveLoadType::Variable, variable, type, 0, from, to, 0)

Storage of a global variable in some savegame versions.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the field.
toLast savegame version that has the field.

Definition at line 1124 of file saveload.h.

Referenced by LinkGraph::GetLinkGraphDesc.

◆ SLEG_CONDVECTOR

#define SLEG_CONDVECTOR ( name,
variable,
type,
from,
to )
Value:
SLEG_GENERAL(name, SaveLoadType::Vector, variable, type, 0, from, to, 0)

Storage of a global vector of SaveLoadType::Variable elements in some savegame versions.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the list.
toLast savegame version that has the list.

Definition at line 1184 of file saveload.h.

◆ SLEG_GENERAL

#define SLEG_GENERAL ( name,
cmd,
variable,
type,
length,
from,
to,
extra )
Value:
SaveLoad {name, cmd, type, length, from, to, [] (void *, size_t) -> void * { \
static_assert(SlCheckVarSize(cmd, type, length, sizeof(variable))); \
return static_cast<void *>(std::addressof(variable)); }, extra, nullptr}

Storage of global simple variables, references (pointers), and arrays.

Parameters
nameThe name of the field.
cmdLoad/save type.
See also
SaveLoadType
Parameters
variableName of the global variable.
typeStorage of the data in memory and in the savegame.
fromFirst savegame version that has the field.
toLast savegame version that has the field.
extraExtra data to pass to the address callback function.
Note
In general, it is better to use one of the SLEG_* macros below.

Definition at line 1111 of file saveload.h.

◆ SLEG_REF

#define SLEG_REF ( name,
variable,
type )
Value:
#define SLEG_CONDREF(name, variable, type, from, to)
Storage of a global reference in some savegame versions.
Definition saveload.h:1134

Storage of a global reference in every savegame version.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.

Definition at line 1209 of file saveload.h.

◆ SLEG_REFLIST

#define SLEG_REFLIST ( name,
variable,
type )
Value:
#define SLEG_CONDREFLIST(name, variable, type, from, to)
Storage of a global reference list in some savegame versions.
Definition saveload.h:1174

Storage of a global reference list in every savegame version.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.

Definition at line 1241 of file saveload.h.

◆ SLEG_SSTR

#define SLEG_SSTR ( name,
variable,
type )
Value:
#define SLEG_CONDSSTR(name, variable, type, from, to)
Storage of a global std::string in some savegame versions.
Definition saveload.h:1155

Storage of a global std::string in every savegame version.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.

Definition at line 1226 of file saveload.h.

◆ SLEG_STRUCT

#define SLEG_STRUCT ( name,
handler )
Value:
#define SLEG_CONDSTRUCT(name, handler, from, to)
Storage of a structs in some savegame versions.
Definition saveload.h:1164

Storage of a structs in every savegame version.

Parameters
nameThe name of the field.
handlerSaveLoadHandler for the structs.

Definition at line 1233 of file saveload.h.

Referenced by LinkGraph::GetLinkGraphJobDesc.

◆ SLEG_STRUCTLIST

#define SLEG_STRUCTLIST ( name,
handler )
Value:
#define SLEG_CONDSTRUCTLIST(name, handler, from, to)
Storage of a list of structs in some savegame versions.
Definition saveload.h:1193

Storage of a list of structs in every savegame version.

Parameters
nameThe name of the field.
handlerSaveLoadHandler for the list of structs.

Definition at line 1256 of file saveload.h.

Referenced by LinkGraph::GetLinkGraphDesc.

◆ SLEG_VAR

#define SLEG_VAR ( name,
variable,
type )
Value:
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
Definition saveload.h:1124

Storage of a global variable in every savegame version.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.

Definition at line 1201 of file saveload.h.

◆ SLEG_VECTOR

#define SLEG_VECTOR ( name,
variable,
type )
Value:
#define SLEG_CONDVECTOR(name, variable, type, from, to)
Storage of a global vector of SaveLoadType::Variable elements in some savegame versions.
Definition saveload.h:1184

Storage of a global vector of SaveLoadType::Variable elements in every savegame version.

Parameters
nameThe name of the field.
variableName of the global variable.
typeStorage of the data in memory and in the savegame.

Definition at line 1249 of file saveload.h.

Typedef Documentation

◆ AutolengthProc

typedef void AutolengthProc(int)

Definition at line 468 of file saveload.h.

◆ ChunkHandlerRef

using ChunkHandlerRef = std::reference_wrapper<const ChunkHandler>

A reference to ChunkHandler.

Definition at line 530 of file saveload.h.

◆ ChunkHandlerTable

using ChunkHandlerTable = std::span<const ChunkHandlerRef>

A table of ChunkHandler entries.

Definition at line 533 of file saveload.h.

◆ SaveLoadAddrProc

typedef void * SaveLoadAddrProc(void *base, size_t extra)

Definition at line 784 of file saveload.h.

◆ SaveLoadCompatTable

using SaveLoadCompatTable = std::span<const struct SaveLoadCompat>

A table of SaveLoadCompat entries.

Definition at line 539 of file saveload.h.

◆ SaveLoadTable

using SaveLoadTable = std::span<const struct SaveLoad>

A table of SaveLoad entries.

Definition at line 536 of file saveload.h.

Enumeration Type Documentation

◆ ChunkType

enum class ChunkType : uint8_t
strong

Type of a chunk.

Enumerator
Riff 

4 bits store the chunk type, 28 bits the number of bytes.

Array 

Contiguous array of elements starting at index 0.

SparseArray 

Array of elements with index for each element.

Table 

An Array with a header describing the elements.

SparseTable 

A SparseArray with a header describing the elements.

FileTypeMask 

All ChunkType values that are saved in the file have to be within this mask.

ReadOnly 

Chunk is never saved.

Definition at line 471 of file saveload.h.

◆ SavegameType

enum SavegameType : uint8_t

Types of save games.

Enumerator
TTD 

TTD savegame (can be detected incorrectly).

TTDP1 

TTDP savegame ( -//- ) (data at NW border).

TTDP2 

TTDP savegame in new format (data at SE border).

OTTD 

OTTD savegame.

TTO 

TTO savegame.

Invalid 

broken savegame (used internally)

Definition at line 443 of file saveload.h.

◆ SaveLoadResult

enum class SaveLoadResult : uint8_t
strong

Save or load result codes.

Enumerator
Ok 

completed successfully

Error 

error that was caught before internal structures were modified

ReInit 

error that was caught in the middle of updating game state, need to clear it. (can only happen during load)

Definition at line 425 of file saveload.h.

◆ SaveLoadType

enum class SaveLoadType : uint8_t
strong

Type of data saved.

Enumerator
Variable 

Save/load a variable.

Reference 

Save/load a reference.

Struct 

Save/load a struct.

String 

Save/load a std::string.

Array 

Save/load a fixed-size array of SaveLoadType::Variable elements.

Vector 

Save/load a vector of SaveLoadType::Variable elements.

ReferenceList 

Save/load a list of SaveLoadType::Reference elements.

StructList 

Save/load a list of structs.

SaveByte 

Save (but not load) a byte.

Null 

Save null-bytes and load to nowhere.

ReferenceVector 

Save/load a vector of SaveLoadType::Reference elements.

Definition at line 766 of file saveload.h.

◆ SaveLoadVersion

enum class SaveLoadVersion : uint16_t
strong

SaveLoad versions Previous savegame versions, the trunk revision where they were introduced and the released version that had that particular savegame version.

Up to savegame version 18 there is a minor version as well.

Older entries keep their original numbering.

Newer entries should use a descriptive labels, numeric version and PR can be added to comment.

Note that this list must not be reordered.

Enumerator
MinVersion 

First savegame version.

BigCurrency 

Saveload version: 1.0, releases: 0.1.x, 0.2.x
Change currency from 32 to 64 bits.

VehicleCurrencyStationChanges 

Saveload version: 2.0, release: 0.3.0
Adding vehicle state, larger currency size for statistics, station size revamped.

Saveload version: 2.1, releases: 0.3.1, 0.3.2
Unify way of storing town owner.

Saveload version: 2.2
New airports.

BiggerStationVariables 

Saveload version: 3.0
Increase size of airport blocks/station build date.

TownTolerancePauseMode 

Saveload version: 4.0, SVN revision: 1
Town council tolerance and pause mode.

Saveload version: 4.1, SVN revision: 122, releases: 0.3.3, 0.3.4
Store exclusive rights in towns.

Saveload version: 4.2, SVN revision: 1222, release: 0.3.5
Currencies are reordered.

Saveload version: 4.3, SVN revision: 1417
Make water owned by OWNER_NONE.

Saveload version: 4.4, SVN revision: 1426
Make vehicle references same as other references.

BigMap 

Saveload version: 5.0, SVN revision: 1429
Making maps a different size than 256x256.

Saveload version: 5.1, SVN revision: 1440
Flexible airport layouts.

Saveload version: 5.2, SVN revision: 1525, release: 0.3.6
Dynamic order array.

MultipleRoadStops 

Saveload version: 6.0, SVN revision: 1721
Multi tile road stops, and some map size related fixes.

Saveload version: 6.1, SVN revision: 1768
Town index in m2.

LargerCargoSource 

Saveload version: 7.0, SVN revision: 1770
With more stations, the size of the cargo source needed to be increased.

LargerUnitNumber 

Saveload version: 8.0, SVN revision: 1786
Increase size of (vehicle) unit numbers.

LargerTownCargoStatistics 

Saveload version: 9.0, SVN revision: 1909
Increase size of passenger/mail production of this and previous months.

LargerTownCounter 

Saveload version: 10.0, SVN revision: 2030
Increase size of the town counter.

LargerTownIterator 

Saveload version: 11.0, SVN revision: 2033
Increase size of the town iterator.

Saveload version: 11.1, SVN revision: 2041
Fix vehicle counters.

LinkWaypointToTown 

Saveload version: 12.1, SVN revision: 2046
Link waypoints to towns and remove some bit stuffing.

LargerAIStateCounter 

Saveload version: 13.1, SVN revision: 2080, releases: 0.4.0, 0.4.0.1
AI state counter increased due it storing tile indices.

TransferOrder 

Saveload version: 14.0, SVN revision: 2441
Transfer orders for feeder systems.

MoveSemaphoreBits 

Saveload version: 15.0, SVN revision: 2499
Move rail signal bit for semaphores.

EngineRenew 

Saveload version: 16.0, SVN revision: 2817
Automatic replacing/renewing of vehicles.

Saveload version: 16.1, SVN revision: 3155
Keep vehicle length during autoreplace.

StoreWaypointIdInMap 

Saveload version: 17.0, SVN revision: 3212
Store the ID of waypoints in m2 of the map.

Saveload version: 17.1, SVN revision: 3218
Make train subtype a bitmask.

RemoveMinorVersion 

Saveload version: 18, SVN revision: 3227
Remove the minor versions from savegames.

EngineRenewPool 

Saveload version: 19, SVN revision: 3396
Engine renews are now stored in a pool.

NoMultiheadReference 

Saveload version: 20, SVN revision: 3403
Remove reference from one multihead to the other one.

RemoveOldPbs 

Saveload version: 21, SVN revision: 3472, release: 0.4.x
Remove old implementation of path based signals.

SavePatches 

Saveload version: 22, SVN revision: 3726
Save state of patches (precursor of settings) in the savegame.

RemoveAutosaveInterval 

Saveload version: 23, SVN revision: 3915
Store autosave interval locally, instead of in savegame.

Elrail 

Saveload version: 24, SVN revision: 4150
Electrified railways.

ImproveMultistop 

Saveload version: 25, SVN revision: 4259
Improve the behaviour of RVs going to road stops.

LastVehicleType 

Saveload version: 26, SVN revision: 4466
Store the last vehicle type at stations instead of the vehicle ID.

NewGRFStations 

Saveload version: 27, SVN revision: 4757
NewGRF graphics for stations.

Yapf 

Saveload version: 28, SVN revision: 4987
Yet another path finder.

MoreUnderBridges 

Saveload version: 29, SVN revision: 5070
Support crossings, fields and bridge/tunnel heads under bridges.

Tgp 

Saveload version: 30, SVN revision: 5946
TerraGenesis Perlin.

BigDates 

Saveload version: 31, SVN revision: 5999
Change date from 1920 - 2090 to 0 - 5 000 000.

LinkFarmFieldToIndustry 

Saveload version: 32, SVN revision: 6001
Link farm fields to the industry, so it gets removed when the industry goes away.

SaveYapfSettings 

Saveload version: 33, SVN revision: 6440
Some YAPF settings were not saved properly.

Liveries 

Saveload version: 34, SVN revision: 6455
Liveries and two company colours (2cc).

LiveryRefit 

Saveload version: 35, SVN revision: 6602
NewGRF livery refits.

RefitOrders 

Saveload version: 36, SVN revision: 6624
Vehicles can be refitted as part of an order.

Utf8 

Saveload version: 37, SVN revision: 7182
UTF-8 strings.

DisableElrailSetting 

Saveload version: 38, SVN revision: 7195
Add setting to disable electrified rails.

FreightWeight 

Saveload version: 39, SVN revision: 7269
Setting to increase the weight of cargo on freight trains.

GradualLoading 

Saveload version: 40, SVN revision: 7326
Gradual (un)loading of cargo.

NewGRFSettings 

Saveload version: 41, SVN revision: 7348, release: 0.5.x
Save what NewGRFs are used in the game and their settings.

BridgeWormhole 

Saveload version: 42, SVN revision: 7573
Bridges become wormholes, so more things can be built under them (e.g. signals).

UnifyAnimationState 

Saveload version: 43, SVN revision: 7642
Put all animation state information in same map bits.

CargoSourceTile 

Saveload version: 44, SVN revision: 8144
Store the source tile of the cargo, so accurate payment can happen when the source station is removed.

CountPaidForCargo 

Saveload version: 45, SVN revision: 8501
Count the amount of cargo that was paid for.

MoreAirportBlocks 

Saveload version: 46, SVN revision: 8705
Increase number of blocks an airport can have.

DriveThroughRoadStops 

Saveload version: 47, SVN revision: 8735
Drive through road stops.

RailTrackTypeUnification 

Saveload version: 48, SVN revision: 8935
Put all the rail track type information in same map bits.

SimplifyPlayerFace 

Saveload version: 49, SVN revision: 8969
Simplify the storage of player face information.

AircraftSpeedHolding 

Saveload version: 50, SVN revision: 8973
Aircraft speed in km-ish/h and reduced speed in holding patterns.

FeederShare 

Saveload version: 51, SVN revision: 8978
Rewrite of transfers to retain knowledge about the already paid amount for transfered cargo.

StatueOwner 

Saveload version: 52, SVN revision: 9066
Store the owner of the statue, so the town can be informed of their removal.

NewGRFHouses 

Saveload version: 53, SVN revision: 9316
NewGRF controlled houses.

TownGrowthControl 

Saveload version: 54, SVN revision: 9613
Give the player control over the town growth.

NewGRFCargo 

Saveload version: 55, SVN revision: 9638
Increase number of cargos and NewGRF control of cargos.

Cities 

Saveload version: 56, SVN revision: 9667
Cities that start bigger and grow faster.

FifoLoading 

Saveload version: 57, SVN revision: 9691
First-in-first-out loading of vehicles.

VeryLowTownIndustryNumber 

Saveload version: 58, SVN revision: 9762
Difficulty settings for very low number of industries and towns.

TownLayout 

Saveload version: 59, SVN revision: 9779
More layout options for towns.

VehicleGroups 

Saveload version: 60, SVN revision: 9874
Arbitrary grouping, by the player, of vehicles.

MultipleRoadTypes 

Saveload version: 61, SVN revision: 9892
Multiple road types for the same tile.

AdjacentStations 

Saveload version: 62, SVN revision: 9905
Allow building multiple stations directly next to eachother.

TramLivery 

Saveload version: 63, SVN revision: 9956
Add separate livery for trams.

MultipleSignalTypes 

Saveload version: 64, SVN revision: 10006
Multiple different signal types on the same (diagonal) tile, instead of the same for both directions.

UnifyCurrency 

Saveload version: 65, SVN revision: 10210
Make all variables related to currency 64 bits.

NewGRFTownNames 

Saveload version: 66, SVN revision: 10211
NewGRF provided town names.

Timetables 

Saveload version: 67, SVN revision: 10236
Introduce timetables for vehicles.

CargoPackets 

Saveload version: 68, SVN revision: 10266
Account for individual units of cargo, i.e. there can be cargo from multiple sources/ages in one vehicle.

MoreCargoPackets 

Saveload version: 69, SVN revision: 10319
Allow more than ~65k cargo packets.

CargoPaymentOverflow 

Saveload version: 70, SVN revision: 10541
Fix overflow of cargo payment rates, plus preparation for player founded industries.

UngroupedVehicles 

Saveload version: 71, SVN revision: 10567
Add a group with vehicles that aren't in any other group.

SplitStationTypeFromGfxid 

Saveload version: 72, SVN revision: 10601
Splits the encoding of station type from the graphics identifer.

NewGRFIndustryLayout 

Saveload version: 73, SVN revision: 10903
NewGRF provided layouts for industries.

FixStationPickupAccounting 

Saveload version: 74, SVN revision: 11030
Accounting of which cargos a station would pick up was done incorrectly.

Autoslope 

Saveload version: 75, SVN revision: 11107
Terraforming under buildings/track/anything that supports foundations.

NewGRFPersistentStorage 

Saveload version: 76, SVN revision: 11139
Persistently store some state of NewGRF objects/entities.

CleanupUnconnectedRoads 

Saveload version: 77, SVN revision: 11172
Option to remove unconnected roads during a town's road reconstruction.

StoreIndustryCargo 

Saveload version: 78, SVN revision: 11176
Store an industry's cargo, so it can be customised upon building.

FairPlaySettings 

Saveload version: 79, SVN revision: 11188
Add setting to disable exclusive rights in a town and giving money.

NewGRFMoreAnimation 

Saveload version: 80, SVN revision: 11228
Support more types of animation for NewGRF industries.

FixTreeGround 

Saveload version: 81, SVN revision: 11244
Various fixes to improve the visuals of the ground under trees.

NewGRFIndustryRandomTriggers 

Saveload version: 82, SVN revision: 11410
NewGRF random triggers for industries.

DepotWaterOwners 

Saveload version: 83, SVN revision: 11589
Store the owner of the water under depots, so removing of the depot doesn't disown the original owner.

ReplaceCustomNameArray 

Saveload version: 84, SVN revision: 11822
Replace single fixed size array of custom names, by moving the name into the appropriate objects.

MaglevMonorailPaxWagonLivery 

Saveload version: 85, SVN revision: 11874
Add livery for maglev/monorail passenger wagons.

WaterClass 

Saveload version: 86, SVN revision: 12042
Store the type of water (sea/ocean, canal, river) for buoys, docks, locks and depots.

SimplifyPathfinderSettings 

Saveload version: 87, SVN revision: 12129
Make it easier to select the pathfinder to use.

FractionProfitRunningTicks 

Saveload version: 88, SVN revision: 12134
Store vehicle profits as a (fixed point) fraction, and store the number of ticks a vehicle ran in a day.

MoreWaypointsPerTown 

Saveload version: 89, SVN revision: 12160
Support more than 64 waypoints per town.

PlaneSpeedFactor 

Saveload version: 90, SVN revision: 12293
Setting to increase aircraft speed to be on par with the other vehicles.

MoreHouseAnimationFrames 

Saveload version: 91, SVN revision: 12347
Increase number of animation frames for NewGRF houses.

RemoveHouseCount 

Saveload version: 92, SVN revision: 12381, release 0.6.x
Remove number of houses in a town from the save.

ImprovedOrders 

Saveload version: 93, SVN revision: 12648
Orders support all full load/non stop types at the same time now.

FixCompanyCargoTypes 

Saveload version: 94, SVN revision: 12816
The company's cargo types should have increased in since with NewGRFCargo.

MoreEngineTypes 

Saveload version: 95, SVN revision: 12924
Allow more than the original 255 engine types.

AirportNoise 

Saveload version: 96, SVN revision: 13226
Introduce noise for airports, to allow more than two airports per town.

MergeOptsPats 

Saveload version: 97, SVN revision: 13256
Merge the OPTS and PATS chunks, i.e. all settings in one chunk.

Gamelog 

Saveload version: 98, SVN revision: 13375
Logging of important actions/situations in the save.

IndustryTileWaterClass 

Saveload version: 99, SVN revision: 13838
Add water classes to industry tiles.

Yapp 

Saveload version: 100, SVN revision: 13952
New version of path based signals.

NewGRFPalette 

Saveload version: 101, SVN revision: 14233
Store palette used by each of the NewGRFs.

SpreadIndustryProductionChanges 

Saveload version: 102, SVN revision: 14332
Spread the industry production changes over the month, instead of doing all on the same day.

NewGRFSuppliedStationName 

Saveload version: 103, SVN revision: 14598
NewGRF industry supplying default names for nearby stations.

MoreCompanies 

Saveload version: 104, SVN revision: 14735
Increase maximum number of companies to 15.

OrderList 

Saveload version: 105, SVN revision: 14803
Create separate order list objects for maintaining orders.

DistantStationJoining 

Saveload version: 106, SVN revision: 14919
Distant joining of stations.

NoAI 

Saveload version: 107, SVN revision: 15027
Replace built in cheating AI with framework for externally developed (scripted) AIs.

StoreAIVersion 

Saveload version: 108, SVN revision: 15045
Store the version of the AI script.

NextCompetitorStartOverflow 

Saveload version: 109, SVN revision: 15075
Prevent overflow in the next competitor start counter.

RemoveOldAISettings 

Saveload version: 110, SVN revision: 15148
Remove remnants of the old AI's configuration.

FreeformEdges 

Saveload version: 111, SVN revision: 15190
Allow terraforming along the edge of the map.

SplitHQ 

Saveload version: 112, SVN revision: 15290
Split the behaviour of headquarters from the other unmovable objects.

RoadLayoutPerTown 

Saveload version: 113, SVN revision: 15340
Allow for different road layouts for each of the towns.

SeparateRoadOwners 

Saveload version: 114, SVN revision: 15601
Separate owners for road bits, tram bits and the road stop.

CustomTownNumber 

Saveload version: 115, SVN revision: 15695
Configuration for specific number of towns to build.

GamelogEmergency 

Saveload version: 116, SVN revision: 15893, release: 0.7.x
Gamelog event for emergency/crash saves.

PlatformStopLocation 

Saveload version: 117, SVN revision: 16037
Set the platform stop location via train orders.

DigitGroupSeparator 

Saveload version: 118, SVN revision: 16129
Configurable digit group separator.

PauseModes 

Saveload version: 119, SVN revision: 16242
Use bitmask of reason to pause, so manual/auto pausing do not conflict.

CompanyServiceIntervals 

Saveload version: 120, SVN revision: 16439
Make service intervals configurable per company.

CargoPayments 

Saveload version: 121, SVN revision: 16694
Perform payment of cargo after unloading.

WaypointMoreLikeStation 

Saveload version: 122, SVN revision: 16855
Make waypoint data look more like stations.

UnifyWaypointAndStation 

Saveload version: 123, SVN revision: 16909
Unify stations and waypoints.

MultiTileWaypoints 

Saveload version: 124, SVN revision: 16993
Waypoints can be bigger than a single tile.

RemoveSubsidyStationBinding 

Saveload version: 125, SVN revision: 17113
Awarded subsidies are not bound to stations, but to their actual source/destination.

CumulatedInflation 

Saveload version: 126, SVN revision: 17433
Store cumulated inflation, and recalculate prices/payments upon load.

TownAcceptance 

Saveload version: 127, SVN revision: 17439
Store mask of cargos accepted by town houses and head quarters.

FoundTown 

Saveload version: 128, SVN revision: 18281
Founding of new towns.

TimetableStart 

Saveload version: 129, SVN revision: 18292
Allow setting the start date of a timetable.

RoadStopOccupancyPenalty 

Saveload version: 130, SVN revision: 18404
Add configurable pathfinder penalty for an occupied road stop.

MaximumDepotPenalty 

Saveload version: 131, SVN revision: 18481
Add configurable maximum pathfinder penalty for finding a depot.

DisallowTreeBuilding 

Saveload version: 132, SVN revision: 18522
Setting to partially disable building of trees.

TrainSlopeSteepness 

Saveload version: 133, SVN revision: 18674
Setting to increase steepness of slopes for trains under realistic acceleration.

VirtualFeederSharePayment 

Saveload version: 134, SVN revision: 18703
Pay a part of the virtual profit during a transfer to the intermediate vehicle.

RocksStayUnderSnow 

Saveload version: 135, SVN revision: 18719
Rocks stay under snow, i.e. they return when the snow goes away.

SplitLoadWaitCounters 

Saveload version: 136, SVN revision: 18764
Split counters for (un)loading and signal waiting/turning as otherwise they interfere.

AirportAnimationFrames 

Saveload version: 137, SVN revision: 18912
Use animation frames instead of many airport tile ids for animation.

ReducePlaneCrashes 

Saveload version: 138, SVN revision: 18942, release: 1.0.x
Setting to reduce/disable crashing of planes.

RvRealisticAcceleration 

Saveload version: 139, SVN revision: 19346
Realistic acceleration of road vehicles.

StoreAirportSize 

Saveload version: 140, SVN revision: 19382
Store the size of the airport in the station.

UniqueDepotNames 

Saveload version: 141, SVN revision: 19799
Give depots unique names.

NewGRFDepotBuildDate 

Saveload version: 142, SVN revision: 20003
Depot build date for NewGRFs.

DisableTownLevelCrossing 

Saveload version: 143, SVN revision: 20048
Setting to be able to disable building rail/road crossings by towns.

ReorderUnmovableRemoveReserved 

Saveload version: 144, SVN revision: 20334
Reorder map bits of unmovable tiles and remove unused reserved zero bytes.

NewGRFAirportSmoke 

Saveload version: 145, SVN revision: 20376
NewGRF support for airport and configurable amount of smoke for vehicles.

UnifyWaterClass 

Saveload version: 146, SVN revision: 20446
Unify location for storing water class in the map.

UnifyAnimationFrame 

Saveload version: 147, SVN revision: 20621
Unify location of animation frame.

IndustryPlatform 

Saveload version: 148, SVN revision: 20659
Setting to make a flat area around (new) industries.

CustomSeaLevel 

Saveload version: 149, SVN revision: 20832
Setting to influence the sea level (amount of water).

FractionalCargoDelivery 

Saveload version: 150, SVN revision: 20857
When spreading cargo over stations, spread fractional amounts for fairness.

StoreNewGRFVersion 

Saveload version: 151, SVN revision: 20918
Store the version of the used NewGRFs.

IndustryManagement 

Saveload version: 152, SVN revision: 21171
Manage the amount of industries that ought to be spawned per type.

LeaveRoadStopSeparately 

Saveload version: 153, SVN revision: 21263
Fix issue where multiple vehicles could leave a road stop at the same time.

PauseLevel 

Saveload version: 154, SVN revision: 21426
Setting to determine what commands are allowed when paused.

NewGRFObjectView 

Saveload version: 155, SVN revision: 21453
Support for views in NewGRF objects.

TerraformLimits 

Saveload version: 156, SVN revision: 21728
Introduce limits for terraforming and clearing times.

UnifyGroundVehicles 

Saveload version: 157, SVN revision: 21862
Unify the way ground vehicles are handled (articulated parts, etc).

TrackRealAndAutoOrders 

Saveload version: 158, SVN revision: 21933
Track which real and auto order is the current order.

MaxLengthAndReverseSignals 

Saveload version: 159, SVN revision: 21962
Settings for reversing at signals, and maximum train, bridge and tunnel length.

DisallowRoadReconstruction 

Saveload version: 160, SVN revision: 21974, release: 1.1.x
Setting to disallow road reconstruction.

PersistentStoragePool 

Saveload version: 161, SVN revision: 22567
Store persistent storage in a pool.

NewGRFCustomCargoAging 

Saveload version: 162, SVN revision: 22713
NewGRF influence on aging of cargo in vehicles.

Rivers 

Saveload version: 163, SVN revision: 22767
Rivers.

VehicleCentreAndZPos 

Saveload version: 164, SVN revision: 23290
Vehicle centres are not fixed at 4/8 of the vehicle; change type of z-positions to prepare for higher maps.

ScriptTownGrowth 

Saveload version: 165, SVN revision: 23304
Storage of cargo statistics for use by game scripts.

InfrastructureMaintenanceCosts 

Saveload version: 166, SVN revision: 23415
Infrastructure can now cost some periodic fee.

NewGRFAircraftRange 

Saveload version: 167, SVN revision: 23504
NewGRF provided maximum aircraft range.

ScriptTownText 

Saveload version: 168, SVN revision: 23637
Game scripts can put a text in the town window.

MoveSccEncoded 

Saveload version: 169, SVN revision: 23816
Move SCC_ENCODED to the first StringControlCode.

CountIndividualCargoes 

Saveload version: 170, SVN revision: 23826
Store the count of individual cargo delivery for a period.

ScenarioDeitySigns 

Saveload version: 171, SVN revision: 23835
Signs made in scenarios become of OWNER_DEITY, so they are always shown.

OrderMaxSpeed 

Saveload version: 172, SVN revision: 23947
Set maximum speed for orders.

FixRoadOwnership 

Saveload version: 173, SVN revision: 23967, release: 1.2.0-RC1
Seemingly unneeded bump supposed to fix something with road ownership.

CurrentOrderMaxSpeed 

Saveload version: 174, SVN revision: 23973, release: 1.2.x
Save maximum speed of current order.

AutoreplaceWhenOldTreeLimit 

Saveload version: 175, SVN revision: 24136
Autoreplace vehicle only when they are old, and putting limit on amount of trees to build (at once).

BackupOrderState 

Saveload version: 176, SVN revision: 24446
Put more of the state of a vehicle's orders (like lateness, start point) in the order backup.

MonthlyBankruptcyCheck 

Saveload version: 177, SVN revision: 24619
Check for bankruptcy on a monthly cycle.

ScriptSettingsProfile 

Saveload version: 178, SVN revision: 24789
Setting for the difficulty profile of AIs.

RobustEnginePreview 

Saveload version: 179, SVN revision: 24810
Make engine preview offers robust when company ranking changes.

ServiceIntervalPercent 

Saveload version: 180, SVN revision: 24998, release: 1.3.x
Service interval in percent or days stored per vehicle.

CargoReservation 

Saveload version: 181, SVN revision: 25012
Persist the reservation of cargo for vehicles instead of recalculating it each time.

GoalProgressPlaneAcceleration 

Saveload version: 182, SVN revision: 25115, r25259, r25296
Goal status and plane acceleration fixes.

Cargodist 

Saveload version: 183, SVN revision: 25363
Cargodist.

SeparateLocaleUnits 

Saveload version: 184, SVN revision: 25508
Unit localisation split.

Storybooks 

Saveload version: 185, SVN revision: 25620
Storybooks.

ObjectTypeToPool 

Saveload version: 186, SVN revision: 25833
Move object type from map to pool object.

LinkgraphRestrictedFlow 

Saveload version: 187, SVN revision: 25899
Linkgraph - restricted flows.

UnifyRvTravelTime 

Saveload version: 188, SVN revision: 26169, release: 1.4
Unify RV travel time.

GroupHierarchy 

Saveload version: 189, SVN revision: 26450
Hierarchical vehicle subgroups.

SeparateOrderTravelWaitTime 

Saveload version: 190, SVN revision: 26547
Separate order travel and wait times.

LinkgraphLocationDisasterStore 

Saveload version: 191, SVN revision: 26636, 26646
Fix disaster vehicle storage, Linkgraph - store locations.

FixOrderBackup 

Saveload version: 192, SVN revision: 26700
Fix saving of order backups.

HideEnginesForCompany 

Saveload version: 193, SVN revision: 26802
Hiding of engines for a company.

MaxBridgeMapHeight 

Saveload version: 194, SVN revision: 26881, release: 1.5
Setting for maximum bridge and map height.

Distinguish16 

Saveload version: 195, SVN revision: 27572, release: 1.6.1
Convenience bump to distinguish 1.6 from 1.5 saves.

Distinguish17 

Saveload version: 196, SVN revision: 27778, release: 1.7
Convenience bump to distinguish 1.7 from 1.6 saves.

StoreMapVariety 

Saveload version: 197, SVN revision: 27978, release: 1.8
Store map variety.

TownGrowthInGameTicks 

Saveload version: 198, GitHub pull request: 6763
Switch town growth rate and counter to actual game ticks.

ExtendCargotypes 

Saveload version: 199, GitHub pull request: 6802
Extend cargotypes to 64.

ExtendRailtypes 

Saveload version: 200, GitHub pull request: 6805
Extend railtypes to 64, adding uint16_t to map array.

ExtendPersistentStorage 

Saveload version: 201, GitHub pull request: 6885
Extend NewGRF persistent storages.

ExtendIndustryCargoSlots 

Saveload version: 202, GitHub pull request: 6867
Increase industry cargo slots to 16 in, 16 out.

ShipPathCache 

Saveload version: 203, GitHub pull request: 7072
Add path cache for ships.

ShipRotation 

Saveload version: 204, GitHub pull request: 7065
Add extra rotation stages for ships.

GroupLiveries 

Saveload version: 205, GitHub pull request: 7108
Livery storage change and group liveries.

ShipsStopInLocks 

Saveload version: 206, GitHub pull request: 7150
Ship/lock movement changes.

FixCargoMonitor 

Saveload version: 207, GitHub pull request: 7175, release: 1.9
Cargo monitor data packing fix to support 64 cargotypes.

TownCargogen 

Saveload version: 208, GitHub pull request: 6965
New algorithms for town building cargo generation.

ShipCurvePenalty 

Saveload version: 209, GitHub pull request: 7289
Configurable ship curve penalties.

ServeNeutralIndustries 

Saveload version: 210, GitHub pull request: 7234
Company stations can serve industries with attached neutral stations.

RoadvehPathCache 

Saveload version: 211, GitHub pull request: 7261
Add path cache for road vehicles.

RemoveOldPathfinder 

Saveload version: 212, GitHub pull request: 7245
Remove OPF.

TreesWaterClass 

Saveload version: 213, GitHub pull request: 7405
WaterClass update for tree tiles.

RoadTypes 

Saveload version: 214, GitHub pull request: 6811
NewGRF road types.

ScriptMemlimit 

Saveload version: 215, GitHub pull request: 7516
Limit on AI/GS memory consumption.

MultitileDocks 

Saveload version: 216, GitHub pull request: 7380
Multiple docks per station.

TradingAge 

Saveload version: 217, GitHub pull request: 7780
Configurable company trading age.

EndingYear 

Saveload version: 218, GitHub pull request: 7747, release: 1.10
Configurable ending year.

RemoveTownCargoCache 

Saveload version: 219, GitHub pull request: 8258
Remove town cargo acceptance and production caches.

StartPatchpacks 

Saveload version: 220
First known patchpack to use a version just above ours.

EndPatchpacks 

Saveload version: 286
Last known patchpack to use a version just above ours.

GSIndustryControl 

Saveload version: 287, GitHub pull request: 7912 and 8115
GS industry control.

VehMotionCounter 

Saveload version: 288, GitHub pull request: 8591
Desync safe motion counter.

IndustryText 

Saveload version: 289, GitHub pull request: 8576, release: 1.11.0-RC1
Additional GS text for industries.

MapgenSettingsRevamp 

Saveload version: 290, GitHub pull request: 8891, release: 1.11
Revamp of some mapgen settings (snow coverage, desert coverage, heightmap height, custom terrain type).

GroupReplaceWagonRemoval 

Saveload version: 291, GitHub pull request: 7441
Per-group wagon removal flag.

CustomSubsidyDuration 

Saveload version: 292, GitHub pull request: 9081
Configurable subsidy duration.

SaveloadListLength 

Saveload version: 293, GitHub pull request: 9374
Consistency in list length with SaveLoadType::Struct / SaveLoadType::StructList / SaveLoadType::ReferenceList.

RiffToArray 

Saveload version: 294, GitHub pull request: 9375
Changed many ChunkType::Riff chunks to ChunkType::Array chunks.

TableChunks 

Saveload version: 295, GitHub pull request: 9322
Introduction of ChunkType::Table and ChunkType::SparseTable.

ScriptInt64 

Saveload version: 296, GitHub pull request: 9415
SQInteger is 64bit but was saved as 32bit.

LinkgraphTravelTime 

Saveload version: 297, GitHub pull request: 9457, release: 12.0-RC1
Store travel time in the linkgraph.

DockDockingtiles 

Saveload version: 298, GitHub pull request: 9578
All tiles around docks may be docking tiles.

RepairObjectDockingTiles 

Saveload version: 299, GitHub pull request: 9594, release: 12.0
Fixing issue with docking tiles overlapping objects.

U64TickCounter 

Saveload version: 300, GitHub pull request: 10035
Make tick counter 64bit to avoid wrapping.

LastLoadingTick 

Saveload version: 301, GitHub pull request: 9693
Store tick of last loading for vehicles.

MultitrackLevelCrossings 

Saveload version: 302, GitHub pull request: 9931, release: 13.0
Multi-track level crossings.

NewGRFRoadStops 

Saveload version: 303, GitHub pull request: 10144
NewGRF road stops.

LinkgraphEdges 

Saveload version: 304, GitHub pull request: 10314
Explicitly store link graph edges destination, PR#10471 int64_t instead of uint64_t league rating.

VelocityNautical 

Saveload version: 305, GitHub pull request: 10594
Separation of land and nautical velocity (knots!).

ConsistentPartialZ 

Saveload version: 306, GitHub pull request: 10570
Conversion from an inconsistent partial Z calculation for slopes, to one that is (more) consistent.

MoreCargoAge 

Saveload version: 307, GitHub pull request: 10596
Track cargo age for a longer period.

LinkgraphSeconds 

Saveload version: 308, GitHub pull request: 10610
Store linkgraph update intervals in seconds instead of days.

AIStartDate 

Saveload version: 309, GitHub pull request: 10653
Removal of individual AI start dates and added a generic one.

ExtendVehicleRandom 

Saveload version: 310, GitHub pull request: 10701
Extend vehicle random bits.

ExtendEntityMapping 

Saveload version: 311, GitHub pull request: 10672
Extend entity mapping range.

DisasterVehState 

Saveload version: 312, GitHub pull request: 10798
Explicit storage of disaster vehicle state.

SavegameId 

Saveload version: 313, GitHub pull request: 10719
Add an unique ID to every savegame (used to deduplicate surveys).

StringGamelog 

Saveload version: 314, GitHub pull request: 10801
Use std::string in gamelog.

IndustryCargoReorganise 

Saveload version: 315, GitHub pull request: 10853
Industry accepts/produced data reorganised.

PeriodsInTransitRename 

Saveload version: 316, GitHub pull request: 11112
Rename days in transit to (cargo) periods in transit.

NewGRFLastService 

Saveload version: 317, GitHub pull request: 11124
Added stable date_of_last_service to avoid NewGRF trouble.

RemoveLoadedAtXY 

Saveload version: 318, GitHub pull request: 11276
Remove loaded_at_xy variable from CargoPacket.

CargoTravelled 

Saveload version: 319, GitHub pull request: 11283
CargoPacket now tracks how far it travelled inside a vehicle.

StationRatingCheat 

Saveload version: 320, GitHub pull request: 11346
Add cheat to fix station ratings at 100%.

TimetableStartTicks 

Saveload version: 321, GitHub pull request: 11468
Convert timetable start from a date to ticks.

TimetableStartTicksFix 

Saveload version: 322, GitHub pull request: 11557
Fix for missing convert timetable start from a date to ticks.

TimetableTicksType 

Saveload version: 323, GitHub pull request: 11435
Convert timetable current order time to ticks.

WaterRegions 

Saveload version: 324, GitHub pull request: 10543
Water Regions for ship pathfinder.

WaterRegionEvalSimplified 

Saveload version: 325, GitHub pull request: 11750
Simplified Water Region evaluation.

EconomyDate 

Saveload version: 326, GitHub pull request: 10700
Split calendar and economy timers and dates.

EconomyModeTimekeepingUnits 

Saveload version: 327, GitHub pull request: 11341
Mode to display economy measurements in wallclock units.

CalendarSubDateFract 

Saveload version: 328, GitHub pull request: 11428
Add sub_date_fract to measure calendar days.

ShipAcceleration 

Saveload version: 329, GitHub pull request: 10734
Start using Vehicle's acceleration field for ships too.

MaxLoanForCompany 

Saveload version: 330, GitHub pull request: 11224
Separate max loan for each company.

DepotUnbunching 

Saveload version: 331, GitHub pull request: 11945
Allow unbunching shared order vehicles at a depot.

AILocalConfig 

Saveload version: 332, GitHub pull request: 12003
Config of running AI is stored inside Company.

ScriptRandomizer 

Saveload version: 333, GitHub pull request: 12063, release: 14.0-RC1
Save script randomizers.

VehicleEconomyAge 

Saveload version: 334, GitHub pull request: 12141, release: 14.0
Add vehicle age in economy year, for profit stats minimum age.

CompanyAllowList 

Saveload version: 335, GitHub pull request: 12337
Saving of list of client keys that are allowed to join this company.

GroupNumbers 

Saveload version: 336, GitHub pull request: 12297
Add per-company group numbers.

IncreaseStationTypeFieldSize 

Saveload version: 337, GitHub pull request: 12572
Increase size of StationType field in map array.

RoadWaypoints 

Saveload version: 338, GitHub pull request: 12572
Road waypoints.

CompanyInauguratedPeriod 

Saveload version: 339, GitHub pull request: 12798
Companies show the period inaugurated in wallclock mode.

RoadStopTileData 

Saveload version: 340, GitHub pull request: 12883
Move storage of road stop tile data, also save for road waypoints.

CompanyAllowListV2 

Saveload version: 341, GitHub pull request: 12908
Fixed savegame format for saving of list of client keys that are allowed to join this company.

WaterTileType 

Saveload version: 342, GitHub pull request: 13030
Simplify water tile type.

ProductionHistory 

Saveload version: 343, GitHub pull request: 10541
Industry production history.

RoadTypeLabelMap 

Saveload version: 344, GitHub pull request: 13021
Add road type label map to allow upgrade/conversion of road types.

NonfloodingWaterTiles 

Saveload version: 345, GitHub pull request: 13013
Store water tile non-flooding state.

PathCacheFormat 

Saveload version: 346, GitHub pull request: 12345
Vehicle path cache format changed.

AnimatedTileStateInMap 

Saveload version: 347, GitHub pull request: 13082
Animated tile state saved for improved performance.

IncreaseHouseLimit 

Saveload version: 348, GitHub pull request: 12288
Increase house limit to 4096.

CompanyInauguratedPeriodV2 

Saveload version: 349, GitHub pull request: 13448
Fix savegame storage for company inaugurated year in wallclock mode.

EncodedStringFormat 

Saveload version: 350, GitHub pull request: 13499
Encoded String format changed.

ProtectPlacedHouses 

Saveload version: 351, GitHub pull request: 13270
Houses individually placed by players can be protected from town/AI removal.

ScriptSaveInstances 

Saveload version: 352, GitHub pull request: 13556
Scripts are allowed to save instances.

FixSccEncodedNegative 

Saveload version: 353, GitHub pull request: 14049
Fix encoding of negative parameters.

OrdersOwnedByOrderlist 

Saveload version: 354, GitHub pull request: 13948
Orders stored in OrderList, pool removed.

FaceStyles 

Saveload version: 355, GitHub pull request: 14319
Addition of face styles, replacing gender and ethnicity.

IndustryNumValidHistory 

Saveload version: 356, GitHub pull request: 14416
Store number of valid history records for industries.

IndustryAcceptedHistory 

Saveload version: 357, GitHub pull request: 14321
Add per-industry history of cargo delivered and waiting.

TownSupplyHistory 

Saveload version: 358, GitHub pull request: 14461
Town supply history.

StationsUnderBridges 

Saveload version: 359, GitHub pull request: 14477
Allow stations under bridges.

DocksUnderBridges 

Saveload version: 360, GitHub pull request: 14594
Allow docks under bridges.

LocksUnderBridges 

Saveload version: 361, GitHub pull request: 14595
Allow locks under bridges.

EngineMultiRailtype 

Saveload version: 362, GitHub pull request: 14357, release: 15.0
Train engines can have multiple railtypes.

SignTextColours 

Saveload version: 363, GitHub pull request: 14743
Configurable sign text colors in scenario editor.

BuoysAt0_0 

Saveload version: 364, GitHub pull request: 14983
Allow to build buoys at (0x0).

DriveBackwards 

Saveload version: 365, GitHub pull request: 15379
Trains can drive backwards.

DepotsUnderBridges 

Saveload version: 366, GitHub pull request: 15836
Allow depots under bridges.

MaxVersion 

Highest possible saveload version.

Definition at line 30 of file saveload.h.

◆ SLRefType

enum class SLRefType : uint8_t
strong

Type of reference (SLE_REF, SLE_CONDREF).

Enumerator
Vehicle 

Load/save a reference to a vehicle.

Station 

Load/save a reference to a station.

Town 

Load/save a reference to a town.

OldVehicle 

Load/save an old-style reference to a vehicle (for pre-4.4 savegames).

RoadStop 

Load/save a reference to a bus/truck stop.

EngineRenew 

Load/save a reference to an engine renewal (autoreplace).

CargoPacket 

Load/save a reference to a cargo packet.

OrderList 

Load/save a reference to an orderlist.

Storage 

Load/save a reference to a persistent storage.

LinkGraph 

Load/save a reference to a link graph.

LinkGraphJob 

Load/save a reference to a link graph job.

Definition at line 642 of file saveload.h.

◆ VarFileType

enum class VarFileType : uint8_t
strong

The types/structures of data that can be stored in the file.

Enumerator
I8 

A 8 bit signed int.

U8 

A 8 bit unsigned int.

I16 

A 16 bit signed int.

U16 

A 16 bit unsigned int.

I32 

A 32 bit signed int.

U32 

A 32 bit unsigned int.

I64 

A 64 bit signed int.

U64 

A 64 bit unsigned int.

StringID 

StringID offset into strings-array.

String 

A string.

Struct 

An arbitrary structure.

Definition at line 657 of file saveload.h.

◆ VarMemType

enum class VarMemType : uint8_t
strong

The types/structures of data we have in memory.

Enumerator
Bool 

A boolean value.

I8 

A 8 bit signed int.

U8 

A 8 bit unsigned int.

I16 

A 16 bit signed int.

U16 

A 16 bit unsigned int.

I32 

A 32 bit signed int.

U32 

A 32 bit unsigned int.

I64 

A 64 bit signed int.

U64 

A 64 bit unsigned int.

Null 

useful to write zeros in savegame.

Str 

string pointer

StrQ 

string pointer enclosed in quotes

Name 

old custom name to be converted to a string pointer

Definition at line 676 of file saveload.h.

Function Documentation

◆ DoAutoOrNetsave()

void DoAutoOrNetsave ( FiosNumberedSaveName & counter)

Create an autosave or netsave.

Parameters
counterA reference to the counter variable to be used for rotating the file name.

Definition at line 3380 of file saveload.cpp.

References _settings_client, Autosave, Debug, Error, FiosNumberedSaveName::Extension(), FiosNumberedSaveName::Filename(), GameFile, GenerateDefaultSaveName(), GetEncodedString(), Ok, Save, SaveOrLoad(), and ShowErrorMessage().

Referenced by ClientNetworkEmergencySave().

◆ DoExitSave()

void DoExitSave ( )

Do a save when exiting the game (_settings_client.gui.autosave_on_exit).

Definition at line 3398 of file saveload.cpp.

References Autosave, GameFile, Save, and SaveOrLoad().

Referenced by ConExit(), VideoDriver_Dedicated::MainLoop(), VideoDriver_Null::MainLoop(), and MainWindow::OnHotkey().

◆ GenerateDefaultSaveName()

std::string GenerateDefaultSaveName ( )

Get the default name for a savegame or screenshot.

Returns
The default name, i.e. company name and (play) time.

Definition at line 3407 of file saveload.cpp.

References _local_company, _settings_client, TimerGameTick::counter, TimerGameEconomy::date, GetStringWithArgs(), SanitizeFilename(), Ticks::TICKS_PER_SECOND, and TimerGameEconomy::UsingWallclockUnits().

Referenced by DoAutoOrNetsave(), SaveLoadWindow::GenerateFileName(), and MakeScreenshotName().

◆ GetSaveLoadErrorMessage()

EncodedString GetSaveLoadErrorMessage ( )

Return the description of the error.

Returns
The encoded string with the error message.

Definition at line 3004 of file saveload.cpp.

References _sl, and GetEncodedString().

Referenced by SaveFileError(), SaveFileToDisk(), and SaveOrLoad().

◆ GetSaveLoadErrorType()

EncodedString GetSaveLoadErrorType ( )

Return the appropriate initial string for an error depending on whether we are saving or loading.

Returns
The encoded string with the error type.

Definition at line 2995 of file saveload.cpp.

References _sl, GetEncodedString(), and Save.

Referenced by SaveFileError(), SaveFileToDisk(), and SaveOrLoad().

◆ GetVariableAddress()

void * GetVariableAddress ( const void * object,
const SaveLoad & sld )
inline

Get the address of the variable.

Null-variables don't have an address, everything else has a callback function that returns the address based on the saveload data and the current object for non-globals.

Parameters
objectThe object to get a relative address from, or nullptr for global objects.
sldThe save-load configuration for a single variable.
Returns
The address where to store the given variable into.

Definition at line 1319 of file saveload.h.

References SaveLoad::address_proc, SaveLoad::conv, SaveLoad::extra_data, VarType::mem, and Null.

Referenced by ListSettingDesc::FormatValue(), ListSettingDesc::ParseValue(), IntSettingDesc::Read(), StringSettingDesc::Read(), IntSettingDesc::Write(), and StringSettingDesc::Write().

◆ IsSavegameVersionBefore()

bool IsSavegameVersionBefore ( SaveLoadVersion major,
uint8_t minor = 0 )
inline

Checks whether the savegame is below major.

minor.

Parameters
majorMajor number of the version to check against.
minorMinor number of the version to check against. If minor is 0 or not specified, only the major number is checked.
Returns
Savegame version is earlier than the specified version.

Definition at line 1278 of file saveload.h.

References _sl_minor_version, and _sl_version.

Referenced by CargoPacket::AfterLoad(), AfterLoadGame(), AfterLoadLinkGraphs(), AfterLoadStoryBook(), OrderList::AfterLoadVehiclesPhase1, AfterLoadVehiclesPhase2(), Order::ConvertFromOldSavegame(), CopyFromOldName(), DoLoad(), BKORChunkHandler::FixPointers(), CHKPChunkHandler::FixPointers(), CITYChunkHandler::FixPointers(), DEPTChunkHandler::FixPointers(), OBJSChunkHandler::FixPointers(), ORDLChunkHandler::FixPointers(), SlStationGoods::FixPointers(), STNNChunkHandler::FixPointers(), STNSChunkHandler::FixPointers(), SlStationSpecList< T >::GetLength(), SlStationGoods::GetNumCargo(), SlTownOldSupplied::GetNumCargo(), SlCompanyLiveries::GetNumLiveries(), GetSavegameFileType(), GetSettingsDesc(), HandleOldDiffCustom(), IntToReference(), ANITChunkHandler::Load(), CAPRChunkHandler::Load(), CHTSChunkHandler::Load(), CITYChunkHandler::Load(), CMDLChunkHandler::Load(), CMPUChunkHandler::Load(), DEPTChunkHandler::Load(), ECMYChunkHandler::Load(), ENGNChunkHandler::Load(), ERNWChunkHandler::Load(), GRPSChunkHandler::Load(), IBLDChunkHandler::Load(), INDYChunkHandler::Load(), LGRSChunkHandler::Load(), MAP2ChunkHandler::Load(), MAPEChunkHandler::Load(), MAPSChunkHandler::Load(), ORDRChunkHandler::Load(), PRICChunkHandler::Load(), SIGNChunkHandler::Load(), SlCompanyLiveries::Load(), SlCompanyOldEconomy::Load(), SlGameLanguageString::Load(), SlGamelogAction::Load(), SlGamelogRevision::Load(), SlLinkgraphEdge::Load(), SlLinkgraphNode::Load(), SlStationCargo::Load(), SlStationFlow::Load(), SlStationGoods::Load(), SlTownReceived::Load(), SlVehicleRoadVeh::Load(), SlVehicleShip::Load(), VEHSChunkHandler::Load(), VIEWChunkHandler::Load(), DATEChunkHandler::LoadCheck(), MAPSChunkHandler::LoadCheck(), PLYRChunkHandler::LoadCheck(), ScriptInstance::LoadObjects(), LoadSettings(), MoveWaypointsToBaseStations(), SlArray(), SlCalcRefLen(), SlStorageHelper< Tstorage, Tvar, Tallocator >::SlSaveLoad(), SlSaveLoadRef(), and SlStdString().

◆ IsSavegameVersionBeforeOrAt()

bool IsSavegameVersionBeforeOrAt ( SaveLoadVersion major)
inline

Checks whether the savegame is below or at major.

This should be used to repair data from existing savegames which is no longer corrupted in new savegames, but for which otherwise no savegame bump is required.

Parameters
majorMajor number of the version to check against.
Returns
Savegame version is at most the specified version.

Definition at line 1292 of file saveload.h.

References _sl_version.

Referenced by AfterLoadGame().

◆ operator|()

VarType operator| ( VarFileType file,
VarMemType mem )
constexpr

Transitional helper function to combine a file and memory storage configuration.

Parameters
fileThe file configuration.
memThe memory configuration.
Returns
The created VarType.

Definition at line 743 of file saveload.h.

◆ ProcessAsyncSaveFinish()

void ProcessAsyncSaveFinish ( )

Handle async save finishes.

Definition at line 394 of file saveload.cpp.

References _async_save_finish, and _save_thread.

◆ ReadValue()

int64_t ReadValue ( const void * ptr,
VarMemType conv )

Return a signed-long version of the value of a setting.

Parameters
ptrpointer to the variable
convtype of variable, can be a non-clean type, eg one with other flags because it is parsed
Returns
returns the value of the pointer-setting

Definition at line 872 of file saveload.cpp.

References Bool, I16, I32, I64, I8, Null, U16, U32, U64, and U8.

Referenced by CheatWindow::OnQueryTextFinished(), IntSettingDesc::Read(), and SlSaveLoadConv().

◆ SaveloadCrashWithMissingNewGRFs()

bool SaveloadCrashWithMissingNewGRFs ( )

Did loading the savegame cause a crash?

If so, were NewGRFs missing?

Returns
when the saveload crashed due to missing NewGRFs.

Definition at line 350 of file afterload.cpp.

References _saveload_crash_with_missing_newgrfs.

Referenced by HandleCrash(), and HandleCrash().

◆ SaveOrLoad()

SaveLoadResult SaveOrLoad ( std::string_view filename,
SaveLoadOperation fop,
DetailedFileType dft,
Subdirectory sb,
bool threaded )

Main Save or Load function where the high-level saveload functions are handled.

It opens the savegame, selects format and checks versions

Parameters
filenameThe name of the savegame being created/loaded
fopSave or load mode. Load can also be a TTD(Patch) game.
dftThe type of file to save or load.
sbThe sub directory to save the savegame in
threadedTrue when threaded saving is allowed
Returns
Return the result of the action. SaveLoadResult::Ok, SaveLoadResult::Error, or SaveLoadResult::ReInit ("unload" the game)

Definition at line 3291 of file saveload.cpp.

References _do_autosave, _gamelog, _grfconfig, _settings_client, _sl, _sl_minor_version, _sl_version, AfterLoadGame(), Base, Check, ClearGRFConfigList(), ClearSaveLoadState(), TimerGameEconomy::date, TimerGameEconomy::date_fract, Debug, DoLoad(), DoSave(), Error, FioFOpenFile(), GameFile, GetEncodedString(), GetSaveLoadErrorMessage(), GetSaveLoadErrorType(), Load, LoadCheck, MinVersion, Ok, OldGameFile, ReInit, ResetSaveloadData(), Save, Scenario, ShowErrorMessage(), and SlError().

Referenced by _GenerateWorld(), ConSave(), DoAutoOrNetsave(), DoExitSave(), LoadIntroGame(), SaveLoadWindow::OnClick(), openttd_main(), SafeLoad(), StateGameLoop(), and CrashLog::WriteSavegame().

◆ SetSaveLoadError()

void SetSaveLoadError ( StringID str)

Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friends).

Parameters
strThe string describing the error.

Definition at line 2986 of file saveload.cpp.

References _sl.

Referenced by AfterLoadGame().

◆ SlAutolength()

void SlAutolength ( AutolengthProc * proc,
int arg )

Do something of which I have no idea what it is :P.

Parameters
procThe callback procedure that is called
argThe variable that will be used for the callback procedure

Definition at line 2123 of file saveload.cpp.

References _sl, CalcLength, Save, SlErrorCorruptFmt(), SlSetLength(), and WantLength.

Referenced by AIPLChunkHandler::Save(), and GSDTChunkHandler::Save().

◆ SlCalcObjLength()

size_t SlCalcObjLength ( const void * object,
const SaveLoadTable & slt )

Calculate the size of an object.

Parameters
objectto be measured.
sltThe SaveLoad table with objects to save/load.
Returns
size of given object.

Definition at line 1680 of file saveload.cpp.

Referenced by SlObject().

◆ SlCalcObjMemberLength()

size_t SlCalcObjMemberLength ( const void * object,
const SaveLoad & sld )

Definition at line 1691 of file saveload.cpp.

◆ SlCheckVarSize()

bool SlCheckVarSize ( SaveLoadType cmd,
VarType type,
size_t length,
size_t size )
inlineconstexpr

Check if a saveload cmd/type/length entry matches the size of the variable.

Parameters
cmdSaveLoadType of entry.
typeVarType of entry.
lengthArray length of entry.
sizeActual size of variable.
Returns
true iff the sizes match.

Definition at line 847 of file saveload.h.

References Array, VarType::mem, Reference, ReferenceList, ReferenceVector, SaveByte, SlVarSize(), String, Variable, and Vector.

◆ SlCompatTableHeader()

std::vector< SaveLoad > SlCompatTableHeader ( const SaveLoadTable & slt,
const SaveLoadCompatTable & slct )

Load a table header in a savegame compatible way.

If the savegame was made before table headers were added, it will fall back to the SaveLoadCompatTable for the order of fields while loading.

Note
You only have to call this function if the chunk existed as a non-table type before converting it to a table. New chunks created as table can call SlTableHeader() directly.
Parameters
sltThe SaveLoad table with objects to save/load.
slctThe SaveLoadCompat table the original order of the fields.
Returns
When loading, the ordered SaveLoad array to use; otherwise an empty list.

Definition at line 2059 of file saveload.cpp.

References _sl, SaveLoad::cmd, Debug, SaveLoad::handler, Load, LoadCheck, SaveLoad::name, Null, SlCompatTableHeader(), SlErrorCorrupt(), SlIsObjectValidInSavegame(), SlTableHeader(), SparseTable, Struct, StructList, Table, and U8.

Referenced by AIPLChunkHandler::Load(), ANITChunkHandler::Load(), BKORChunkHandler::Load(), CAPAChunkHandler::Load(), CAPYChunkHandler::Load(), CHTSChunkHandler::Load(), CITYChunkHandler::Load(), CMDLChunkHandler::Load(), CMPUChunkHandler::Load(), DEPTChunkHandler::Load(), ECMYChunkHandler::Load(), EIDSChunkHandler::Load(), ENGNChunkHandler::Load(), ERNWChunkHandler::Load(), GOALChunkHandler::Load(), GRPSChunkHandler::Load(), GSDTChunkHandler::Load(), GSTRChunkHandler::Load(), IBLDChunkHandler::Load(), INDYChunkHandler::Load(), ITBLChunkHandler::Load(), LGRJChunkHandler::Load(), LGRPChunkHandler::Load(), LGRSChunkHandler::Load(), MAPSChunkHandler::Load(), NewGRFMappingChunkHandler::Load(), OBJSChunkHandler::Load(), ORDLChunkHandler::Load(), ORDRChunkHandler::Load(), PLYRChunkHandler::Load(), PSACChunkHandler::Load(), RAILChunkHandler::Load(), ROADChunkHandler::Load(), ROTTChunkHandler::Load(), SIGNChunkHandler::Load(), STNNChunkHandler::Load(), STNSChunkHandler::Load(), STPAChunkHandler::Load(), STPEChunkHandler::Load(), SUBSChunkHandler::Load(), VEHSChunkHandler::Load(), VIEWChunkHandler::Load(), MAPSChunkHandler::LoadCheck(), PLYRChunkHandler::LoadCheck(), LoadSettings(), and SlCompatTableHeader().

◆ SlCopy()

◆ SlGetFieldLength()

size_t SlGetFieldLength ( )

Get the length of the current object.

Returns
The length of the object in bytes.

Definition at line 860 of file saveload.cpp.

References _sl.

Referenced by ANITChunkHandler::Load(), CHTSChunkHandler::Load(), NAMEChunkHandler::Load(), and ORDRChunkHandler::Load().

◆ SlGetStructListLength()

◆ SlGlobList()

void SlGlobList ( const SaveLoadTable & slt)

◆ SlIsObjectCurrentlyValid()

bool SlIsObjectCurrentlyValid ( SaveLoadVersion version_from,
SaveLoadVersion version_to )
inline

Checks if some version from/to combination falls within the range of the active savegame version.

Parameters
version_fromInclusive savegame version lower bound.
version_toExclusive savegame version upper bound. MaxVersion if no upper bound.
Returns
Active savegame version falls within the given range.

Definition at line 1305 of file saveload.h.

References SAVEGAME_VERSION.

Referenced by CmdChangeSetting(), GetSaveLoadFromSettingTable(), GetSettingFromName(), IniLoadSettings(), IniSaveSettings(), LoadSettings(), and SurveySettingsTable().

◆ SlIterateArray()

int SlIterateArray ( )

Iterate through the elements of an array and read the whole thing.

Returns
The index of the object, or -1 if we have reached the end of current block

Definition at line 734 of file saveload.cpp.

References _sl, Array, Debug, SlErrorCorruptFmt(), SparseArray, SparseTable, and Table.

Referenced by AIPLChunkHandler::Load(), ANITChunkHandler::Load(), BKORChunkHandler::Load(), CAPAChunkHandler::Load(), CAPYChunkHandler::Load(), CHKPChunkHandler::Load(), CHTSChunkHandler::Load(), CITYChunkHandler::Load(), CMDLChunkHandler::Load(), CMPUChunkHandler::Load(), DEPTChunkHandler::Load(), ECMYChunkHandler::Load(), EIDSChunkHandler::Load(), ENGNChunkHandler::Load(), ERNWChunkHandler::Load(), GOALChunkHandler::Load(), GRPSChunkHandler::Load(), GSDTChunkHandler::Load(), GSTRChunkHandler::Load(), IBLDChunkHandler::Load(), INDYChunkHandler::Load(), ITBLChunkHandler::Load(), LEAEChunkHandler::Load(), LEATChunkHandler::Load(), LGRJChunkHandler::Load(), LGRPChunkHandler::Load(), LGRSChunkHandler::Load(), MAPSChunkHandler::Load(), NAMEChunkHandler::Load(), NewGRFMappingChunkHandler::Load(), OBJSChunkHandler::Load(), ORDLChunkHandler::Load(), ORDRChunkHandler::Load(), PLYRChunkHandler::Load(), PSACChunkHandler::Load(), RAILChunkHandler::Load(), ROADChunkHandler::Load(), ROTTChunkHandler::Load(), SIGNChunkHandler::Load(), SRNDChunkHandler::Load(), STNNChunkHandler::Load(), STNSChunkHandler::Load(), STPAChunkHandler::Load(), STPEChunkHandler::Load(), SUBSChunkHandler::Load(), VEHSChunkHandler::Load(), VIEWChunkHandler::Load(), MAPSChunkHandler::LoadCheck(), PLYRChunkHandler::LoadCheck(), LoadSettings(), SlLoadCheckChunk(), SlLoadChunk(), and SlSkipArray().

◆ SlObject()

void SlObject ( void * object,
const SaveLoadTable & slt )

Main SaveLoad function.

Parameters
objectThe object that is being saved or loaded.
sltThe SaveLoad table with objects to save/load.

Definition at line 1870 of file saveload.cpp.

References _sl, CalcLength, None, SlCalcObjLength(), and SlSetLength().

Referenced by BKORChunkHandler::FixPointers(), CAPYChunkHandler::FixPointers(), CHKPChunkHandler::FixPointers(), CITYChunkHandler::FixPointers(), DEPTChunkHandler::FixPointers(), ERNWChunkHandler::FixPointers(), INDYChunkHandler::FixPointers(), LGRSChunkHandler::FixPointers(), OBJSChunkHandler::FixPointers(), ORDLChunkHandler::FixPointers(), PLYRChunkHandler::FixPointers(), ROADChunkHandler::FixPointers(), SlCompanyEconomy::FixPointers(), SlCompanySettings::FixPointers(), SlStationBase::FixPointers(), SlStationCargo::FixPointers(), SlStationGoods::FixPointers(), SlStationNormal::FixPointers(), SlStationWaypoint::FixPointers(), SlVehicleAircraft::FixPointers(), SlVehicleCommon::FixPointers(), SlVehicleDisaster::FixPointers(), SlVehicleEffect::FixPointers(), SlVehicleRoadVeh::FixPointers(), SlVehicleShip::FixPointers(), SlVehicleTrain::FixPointers(), STNNChunkHandler::FixPointers(), STNSChunkHandler::FixPointers(), VEHSChunkHandler::FixPointers(), AIPLChunkHandler::Load(), BKORChunkHandler::Load(), CAPAChunkHandler::Load(), CAPYChunkHandler::Load(), CHKPChunkHandler::Load(), CHTSChunkHandler::Load(), CITYChunkHandler::Load(), CMDLChunkHandler::Load(), CMPUChunkHandler::Load(), DEPTChunkHandler::Load(), ECMYChunkHandler::Load(), EIDSChunkHandler::Load(), ENGNChunkHandler::Load(), ERNWChunkHandler::Load(), GOALChunkHandler::Load(), GRPSChunkHandler::Load(), GSDTChunkHandler::Load(), GSTRChunkHandler::Load(), INDYChunkHandler::Load(), ITBLChunkHandler::Load(), LEAEChunkHandler::Load(), LEATChunkHandler::Load(), LGRJChunkHandler::Load(), LGRPChunkHandler::Load(), LGRSChunkHandler::Load(), NewGRFMappingChunkHandler::Load(), OBJSChunkHandler::Load(), ORDLChunkHandler::Load(), ORDRChunkHandler::Load(), PLYRChunkHandler::Load(), PSACChunkHandler::Load(), RAILChunkHandler::Load(), ROADChunkHandler::Load(), ROTTChunkHandler::Load(), ScriptInstance::Load(), SIGNChunkHandler::Load(), SlCompanyEconomy::Load(), SlCompanyLiveries::Load(), SlCompanyOldAI::Load(), SlCompanyOldAIBuildRec::Load(), SlCompanyOldEconomy::Load(), SlCompanySettings::Load(), SlGameLanguageString::Load(), SlGamelogEmergency::Load(), SlGamelogGrfadd::Load(), SlGamelogGrfbug::Load(), SlGamelogGrfcompat::Load(), SlGamelogGrfmove::Load(), SlGamelogGrfparam::Load(), SlGamelogGrfrem::Load(), SlGamelogMode::Load(), SlGamelogOldver::Load(), SlGamelogRevision::Load(), SlGamelogSetting::Load(), SlIndustryAcceptedHistory::Load(), SlIndustryProducedHistory::Load(), SlLinkgraphEdge::Load(), SlLinkgraphJobProxy::Load(), SlLinkgraphNode::Load(), SlSkipHandler::Load(), SlStationBase::Load(), SlStationCargo::Load(), SlStationFlow::Load(), SlStationGoods::Load(), SlStationNormal::Load(), SlStationWaitingTriggers::Load(), SlStationWaypoint::Load(), SlTownAcceptanceMatrix::Load(), SlTownAcceptedHistory::Load(), SlTownOldSupplied::Load(), SlTownReceived::Load(), SlTownSuppliedHistory::Load(), SlVehicleAircraft::Load(), SlVehicleCommon::Load(), SlVehicleDisaster::Load(), SlVehicleEffect::Load(), SlVehicleRoadVeh::Load(), SlVehicleShip::Load(), SlVehicleTrain::Load(), SRNDChunkHandler::Load(), STNNChunkHandler::Load(), STNSChunkHandler::Load(), STPAChunkHandler::Load(), STPEChunkHandler::Load(), SUBSChunkHandler::Load(), VectorSaveLoadHandler< TImpl, TObject, TElementType, MAX_LENGTH >::Load(), VEHSChunkHandler::Load(), PLYRChunkHandler::LoadCheck(), ScriptInstance::LoadEmpty(), ScriptInstance::LoadObjects(), LoadSettings(), BKORChunkHandler::Save(), CAPAChunkHandler::Save(), CAPYChunkHandler::Save(), CHTSChunkHandler::Save(), CITYChunkHandler::Save(), CMDLChunkHandler::Save(), CMPUChunkHandler::Save(), DEPTChunkHandler::Save(), ECMYChunkHandler::Save(), EIDSChunkHandler::Save(), ENGNChunkHandler::Save(), ERNWChunkHandler::Save(), GLOGChunkHandler::Save(), GOALChunkHandler::Save(), GRPSChunkHandler::Save(), GSTRChunkHandler::Save(), INDYChunkHandler::Save(), ITBLChunkHandler::Save(), LEAEChunkHandler::Save(), LEATChunkHandler::Save(), LGRJChunkHandler::Save(), LGRPChunkHandler::Save(), LGRSChunkHandler::Save(), NewGRFMappingChunkHandler::Save(), NGRFChunkHandler::Save(), OBJSChunkHandler::Save(), ORDLChunkHandler::Save(), PLYRChunkHandler::Save(), PSACChunkHandler::Save(), RAILChunkHandler::Save(), ROADChunkHandler::Save(), ROTTChunkHandler::Save(), ScriptInstance::Save(), SIGNChunkHandler::Save(), SlCompanyEconomy::Save(), SlCompanyLiveries::Save(), SlCompanyOldEconomy::Save(), SlCompanySettings::Save(), SlGameLanguageString::Save(), SlGamelogAction::Save(), SlGamelogEmergency::Save(), SlGamelogGrfadd::Save(), SlGamelogGrfbug::Save(), SlGamelogGrfcompat::Save(), SlGamelogGrfmove::Save(), SlGamelogGrfparam::Save(), SlGamelogGrfrem::Save(), SlGamelogMode::Save(), SlGamelogOldver::Save(), SlGamelogRevision::Save(), SlGamelogSetting::Save(), SlIndustryAcceptedHistory::Save(), SlIndustryProducedHistory::Save(), SlLinkgraphEdge::Save(), SlLinkgraphJobProxy::Save(), SlLinkgraphNode::Save(), SlStationBase::Save(), SlStationCargo::Save(), SlStationFlow::Save(), SlStationGoods::Save(), SlStationNormal::Save(), SlStationWaitingTriggers::Save(), SlStationWaypoint::Save(), SlTownAcceptedHistory::Save(), SlTownReceived::Save(), SlTownSuppliedHistory::Save(), SlVehicleAircraft::Save(), SlVehicleCommon::Save(), SlVehicleDisaster::Save(), SlVehicleEffect::Save(), SlVehicleRoadVeh::Save(), SlVehicleShip::Save(), SlVehicleTrain::Save(), SRNDChunkHandler::Save(), STNNChunkHandler::Save(), STPAChunkHandler::Save(), STPEChunkHandler::Save(), SUBSChunkHandler::Save(), VectorSaveLoadHandler< TImpl, TObject, TElementType, MAX_LENGTH >::Save(), VEHSChunkHandler::Save(), ScriptInstance::SaveEmpty(), ScriptInstance::SaveObject(), SaveSettings(), and SlGlobList().

◆ SlReadByte()

uint8_t SlReadByte ( )

Wrapper for reading a byte from the buffer.

Returns
The read byte.

Definition at line 410 of file saveload.cpp.

References _sl.

Referenced by SlGamelogAction::Load(), STNNChunkHandler::Load(), VEHSChunkHandler::Load(), SlCopyBytes(), SlLoadCheckChunk(), SlLoadChunk(), SlReadSimpleGamma(), SlSaveLoadConv(), and SlSkipBytes().

◆ SlReadString()

void SlReadString ( std::string & str,
size_t length )

Read the given amount of bytes from the buffer into the string.

Parameters
strThe string to write to.
lengthThe amount of bytes to read into the string.
Note
Does not perform any validation on validity of the string.

Definition at line 1122 of file saveload.cpp.

References SlCopyBytes().

Referenced by NAMEChunkHandler::Load(), and SlStdString().

◆ SlSetArrayIndex() [1/2]

void SlSetArrayIndex ( const ConvertibleThroughBase auto & index)
static

Definition at line 1336 of file saveload.h.

◆ SlSetArrayIndex() [2/2]

void SlSetArrayIndex ( uint index)

Definition at line 722 of file saveload.cpp.

◆ SlSetLength()

void SlSetLength ( size_t length)

Sets the length of either a RIFF object or the number of items in an array.

This lets us load an object or an array of arbitrary size

Parameters
lengthThe length of the sought object/array

Definition at line 788 of file saveload.cpp.

References _sl, Array, CalcLength, None, Riff, Save, SparseArray, SparseTable, Table, and WantLength.

Referenced by M3HIChunkHandler::Save(), M3LOChunkHandler::Save(), MAP2ChunkHandler::Save(), MAP5ChunkHandler::Save(), MAP7ChunkHandler::Save(), MAP8ChunkHandler::Save(), MAPEChunkHandler::Save(), MAPHChunkHandler::Save(), MAPOChunkHandler::Save(), MAPTChunkHandler::Save(), SlAutolength(), SlCopy(), SlObject(), SlRefList(), SlRefVector(), SlSetStructListLength(), and SlTableHeader().

◆ SlSetStructListLength()

◆ SlSkipBytes()

void SlSkipBytes ( size_t length)
inline

Read in bytes from the file/data structure but don't do anything with them, discarding them in effect.

Parameters
lengthThe amount of bytes that is being treated this way

Definition at line 1365 of file saveload.h.

References SlReadByte().

Referenced by SlTownAcceptanceMatrix::Load(), ChunkHandler::LoadCheck(), SlCopyInternal(), SlSkipArray(), and SlStdString().

◆ SlTableHeader()

std::vector< SaveLoad > SlTableHeader ( const SaveLoadTable & slt)

Save or Load a table header.

Note
a table-header can never contain more than 65535 fields.
Parameters
sltThe SaveLoad table with objects to save/load.
Returns
When loading, the ordered SaveLoad array to use; otherwise an empty list.

Definition at line 1923 of file saveload.cpp.

References _sl, Array, CalcLength, SaveLoad::cmd, Debug, GetSavegameFileType(), SaveLoad::handler, SavegameFileType::HasFieldLength(), SavegameFileType::IsEnd(), Load, LoadCheck, MaxVersion, MinVersion, SaveLoad::name, None, Null, Save, SlCalcTableHeader(), SlErrorCorrupt(), SlIsObjectValidInSavegame(), SlSaveLoadConv(), SlSetLength(), SlStdString(), SlTableHeader(), SparseTable, SavegameFileType::storage, VarTypes::STR, String, Struct, StructList, Table, SavegameFileType::Type(), VarTypes::U8, and Variable.

Referenced by LEAEChunkHandler::Load(), LEATChunkHandler::Load(), SRNDChunkHandler::Load(), WaterRegionChunkHandler::Load(), ChunkHandler::LoadCheck(), AIPLChunkHandler::Save(), ANITChunkHandler::Save(), BKORChunkHandler::Save(), CAPAChunkHandler::Save(), CAPYChunkHandler::Save(), CHTSChunkHandler::Save(), CITYChunkHandler::Save(), CMDLChunkHandler::Save(), CMPUChunkHandler::Save(), DATEChunkHandler::Save(), DEPTChunkHandler::Save(), ECMYChunkHandler::Save(), EIDSChunkHandler::Save(), ENGNChunkHandler::Save(), ERNWChunkHandler::Save(), GLOGChunkHandler::Save(), GOALChunkHandler::Save(), GRPSChunkHandler::Save(), GSDTChunkHandler::Save(), GSTRChunkHandler::Save(), IBLDChunkHandler::Save(), INDYChunkHandler::Save(), ITBLChunkHandler::Save(), LEAEChunkHandler::Save(), LEATChunkHandler::Save(), LGRJChunkHandler::Save(), LGRPChunkHandler::Save(), LGRSChunkHandler::Save(), MAPSChunkHandler::Save(), NewGRFMappingChunkHandler::Save(), NGRFChunkHandler::Save(), OBJSChunkHandler::Save(), ORDLChunkHandler::Save(), PLYRChunkHandler::Save(), PSACChunkHandler::Save(), RAILChunkHandler::Save(), ROADChunkHandler::Save(), ROTTChunkHandler::Save(), SIGNChunkHandler::Save(), SRNDChunkHandler::Save(), STNNChunkHandler::Save(), STPAChunkHandler::Save(), STPEChunkHandler::Save(), SUBSChunkHandler::Save(), VEHSChunkHandler::Save(), VIEWChunkHandler::Save(), SaveSettings(), SlCompatTableHeader(), and SlTableHeader().

◆ SlVarSize()

size_t SlVarSize ( VarMemType type)
inlineconstexpr

Return expect size in bytes of a VarType.

Parameters
typeVarType to get size of.
Returns
size of type in bytes.

Definition at line 819 of file saveload.h.

References Bool, I16, I32, I64, I8, Name, Null, Str, StrQ, U16, U32, U64, and U8.

Referenced by LoadIntList(), and SlCheckVarSize().

◆ SlWriteByte()

void SlWriteByte ( uint8_t b)

Wrapper for writing a byte to the dumper.

Parameters
bThe byte to write.

Definition at line 419 of file saveload.cpp.

References _sl.

Referenced by SlCopyBytes(), SlSaveChunk(), SlSaveLoadConv(), and SlWriteSimpleGamma().

◆ WaitTillSaved()

void WaitTillSaved ( )

Definition at line 3060 of file saveload.cpp.

◆ WriteValue()

void WriteValue ( void * ptr,
VarMemType conv,
int64_t val )

Write the value of a setting.

Parameters
ptrpointer to the variable
convtype of variable, can be a non-clean type, eg with other flags. It is parsed upon read
valthe new value being given to the variable

Definition at line 896 of file saveload.cpp.

References Bool, CopyFromOldName(), I16, I32, I64, I8, Name, Null, U16, U32, U64, and U8.

Referenced by LoadIntList(), CheatWindow::OnQueryTextFinished(), SlSaveLoadConv(), and IntSettingDesc::Write().

Variable Documentation

◆ _do_autosave

bool _do_autosave
extern

are we doing an autosave at the moment?

Definition at line 84 of file saveload.cpp.

Referenced by StatusBarWindow::DrawWidget(), and SaveOrLoad().

◆ _file_to_saveload

◆ _savegame_format

std::string _savegame_format
extern

how to compress savegames

Definition at line 83 of file saveload.cpp.

Referenced by SaveFileToDisk().