OpenTTD Source 20241224-master-gf74b0cf984
|
All actions handling saving and loading goes on in this file. More...
#include "../stdafx.h"
#include "../debug.h"
#include "../station_base.h"
#include "../thread.h"
#include "../town.h"
#include "../network/network.h"
#include "../window_func.h"
#include "../strings_func.h"
#include "../core/endian_func.hpp"
#include "../vehicle_base.h"
#include "../company_func.h"
#include "../timer/timer_game_economy.h"
#include "../autoreplace_base.h"
#include "../roadstop_base.h"
#include "../linkgraph/linkgraph.h"
#include "../linkgraph/linkgraphjob.h"
#include "../statusbar_gui.h"
#include "../fileio_func.h"
#include "../gamelog.h"
#include "../string_func.h"
#include "../fios.h"
#include "../error.h"
#include <atomic>
#include "table/strings.h"
#include "saveload_internal.h"
#include "saveload_filter.h"
#include "../safeguards.h"
#include <lzo/lzo1x.h>
#include <zlib.h>
#include <lzma.h>
Go to the source code of this file.
Data Structures | |
struct | ReadBuffer |
A buffer for reading (and buffering) savegame data. More... | |
struct | MemoryDumper |
Container for dumping the savegame (quickly) to memory. More... | |
struct | SaveLoadParams |
The saveload struct, containing reader-writer functions, buffer, version, etc. More... | |
class | SlStorageHelper< Tstorage, Tvar, Tallocator > |
Template class to help with list-like types. More... | |
class | SlSkipHandler |
Handler that is assigned when there is a struct read in the savegame which is not known to the code. More... | |
struct | FileReader |
Yes, simply reading from a file. More... | |
struct | FileWriter |
Yes, simply writing to a file. More... | |
struct | LZOLoadFilter |
Filter using LZO compression. More... | |
struct | LZOSaveFilter |
Filter using LZO compression. More... | |
struct | NoCompLoadFilter |
Filter without any compression. More... | |
struct | NoCompSaveFilter |
Filter without any compression. More... | |
struct | ZlibLoadFilter |
Filter using Zlib compression. More... | |
struct | ZlibSaveFilter |
Filter using Zlib compression. More... | |
struct | LZMALoadFilter |
Filter without any compression. More... | |
struct | LZMASaveFilter |
Filter using LZMA compression. More... | |
struct | SaveLoadFormat |
The format for a reader/writer type of a savegame. More... | |
Typedefs | |
typedef void(* | AsyncSaveFinishProc) () |
Callback for when the savegame loading is finished. | |
Enumerations | |
enum | SaveLoadAction { SLA_LOAD , SLA_SAVE , SLA_PTRS , SLA_NULL , SLA_LOAD_CHECK } |
What are we currently doing? More... | |
enum | NeedLength { NL_NONE = 0 , NL_WANTLENGTH = 1 , NL_CALCLENGTH = 2 } |
Functions | |
static const std::vector< ChunkHandlerRef > & | ChunkHandlers () |
static void | SlNullPointers () |
Null all pointers (convert index -> nullptr) | |
void | SlError (StringID string, const std::string &extra_msg) |
Error handler. | |
void | SlErrorCorrupt (const std::string &msg) |
Error handler for corrupt savegames. | |
static void | SetAsyncSaveFinish (AsyncSaveFinishProc proc) |
Called by save thread to tell we finished saving. | |
void | ProcessAsyncSaveFinish () |
Handle async save finishes. | |
uint8_t | SlReadByte () |
Wrapper for reading a byte from the buffer. | |
void | SlWriteByte (uint8_t b) |
Wrapper for writing a byte to the dumper. | |
static int | SlReadUint16 () |
static uint32_t | SlReadUint32 () |
static uint64_t | SlReadUint64 () |
static void | SlWriteUint16 (uint16_t v) |
static void | SlWriteUint32 (uint32_t v) |
static void | SlWriteUint64 (uint64_t x) |
static uint | SlReadSimpleGamma () |
Read in the header descriptor of an object or an array. | |
static void | SlWriteSimpleGamma (size_t i) |
Write the header descriptor of an object or an array. | |
static uint | SlGetGammaLength (size_t i) |
Return how many bytes used to encode a gamma value. | |
static uint | SlReadSparseIndex () |
static void | SlWriteSparseIndex (uint index) |
static uint | SlReadArrayLength () |
static void | SlWriteArrayLength (size_t length) |
static uint | SlGetArrayLength (size_t length) |
static uint8_t | GetSavegameFileType (const SaveLoad &sld) |
Return the type as saved/loaded inside the savegame. | |
static uint | SlCalcConvMemLen (VarType conv) |
Return the size in bytes of a certain type of normal/atomic variable as it appears in memory. | |
static uint8_t | SlCalcConvFileLen (VarType conv) |
Return the size in bytes of a certain type of normal/atomic variable as it appears in a saved game. | |
static size_t | SlCalcRefLen () |
Return the size in bytes of a reference (pointer) | |
void | SlSetArrayIndex (uint index) |
int | SlIterateArray () |
Iterate through the elements of an array and read the whole thing. | |
void | SlSkipArray () |
Skip an array or sparse array. | |
void | SlSetLength (size_t length) |
Sets the length of either a RIFF object or the number of items in an array. | |
static void | SlCopyBytes (void *ptr, size_t length) |
Save/Load bytes. | |
size_t | SlGetFieldLength () |
Get the length of the current object. | |
int64_t | ReadValue (const void *ptr, VarType conv) |
Return a signed-long version of the value of a setting. | |
void | WriteValue (void *ptr, VarType conv, int64_t val) |
Write the value of a setting. | |
static void | SlSaveLoadConv (void *ptr, VarType conv) |
Handle all conversion and typechecking of variables here. | |
static size_t | SlCalcStdStringLen (const void *ptr) |
Calculate the gross length of the string that it will occupy in the savegame. | |
static void | FixSCCEncoded (std::string &str) |
Scan the string for old values of SCC_ENCODED and fix it to it's new, value. | |
static void | SlStdString (void *ptr, VarType conv) |
Save/Load a std::string . | |
static void | SlCopyInternal (void *object, size_t length, VarType conv) |
Internal function to save/Load a list of SL_VARs. | |
void | SlCopy (void *object, size_t length, VarType conv) |
Copy a list of SL_VARs to/from a savegame. | |
static size_t | SlCalcArrayLen (size_t length, VarType conv) |
Return the size in bytes of a certain type of atomic array. | |
static void | SlArray (void *array, size_t length, VarType conv) |
Save/Load the length of the array followed by the array of SL_VAR elements. | |
static size_t | ReferenceToInt (const void *obj, SLRefType rt) |
Pointers cannot be saved to a savegame, so this functions gets the index of the item, and if not available, it hussles with pointers (looks really bad :() Remember that a nullptr item has value 0, and all indices have +1, so vehicle 0 is saved as index 1. | |
static void * | IntToReference (size_t index, SLRefType rt) |
Pointers cannot be loaded from a savegame, so this function gets the index from the savegame and returns the appropriate pointer from the already loaded base. | |
void | SlSaveLoadRef (void *ptr, VarType conv) |
Handle conversion for references. | |
static size_t | SlCalcRefListLen (const void *list, VarType conv) |
Return the size in bytes of a list. | |
static void | SlRefList (void *list, VarType conv) |
Save/Load a list. | |
static size_t | SlCalcRefVectorLen (const void *vector, VarType conv) |
Return the size in bytes of a vector. | |
static void | SlRefVector (void *vector, VarType conv) |
Save/Load a vector. | |
static size_t | SlCalcDequeLen (const void *deque, VarType conv) |
Return the size in bytes of a std::deque. | |
static void | SlDeque (void *deque, VarType conv) |
Save/load a std::deque. | |
static size_t | SlCalcVectorLen (const void *vector, VarType conv) |
Return the size in bytes of a std::vector. | |
static void | SlVector (void *vector, VarType conv) |
Save/load a std::vector. | |
static bool | SlIsObjectValidInSavegame (const SaveLoad &sld) |
Are we going to save this object or not? | |
static size_t | SlCalcTableHeader (const SaveLoadTable &slt) |
Calculate the size of the table header. | |
size_t | SlCalcObjLength (const void *object, const SaveLoadTable &slt) |
Calculate the size of an object. | |
size_t | SlCalcObjMemberLength (const void *object, const SaveLoad &sld) |
static bool | SlObjectMember (void *object, const SaveLoad &sld) |
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 | SlObject (void *object, const SaveLoadTable &slt) |
Main SaveLoad function. | |
std::vector< SaveLoad > | SlTableHeader (const SaveLoadTable &slt) |
Save or Load a table header. | |
std::vector< SaveLoad > | SlCompatTableHeader (const SaveLoadTable &slt, const SaveLoadCompatTable &slct) |
Load a table header in a savegame compatible way. | |
void | SlGlobList (const SaveLoadTable &slt) |
Save or Load (a list of) global variables. | |
void | SlAutolength (AutolengthProc *proc, int arg) |
Do something of which I have no idea what it is :P. | |
static void | SlLoadChunk (const ChunkHandler &ch) |
Load a chunk of data (eg vehicles, stations, etc.) | |
static void | SlLoadCheckChunk (const ChunkHandler &ch) |
Load a chunk of data for checking savegames. | |
static void | SlSaveChunk (const ChunkHandler &ch) |
Save a chunk of data (eg. | |
static void | SlSaveChunks () |
Save all chunks. | |
static const ChunkHandler * | SlFindChunkHandler (uint32_t id) |
Find the ChunkHandler that will be used for processing the found chunk in the savegame or in memory. | |
static void | SlLoadChunks () |
Load all chunks. | |
static void | SlLoadCheckChunks () |
Load all chunks for savegame checking. | |
static void | SlFixPointers () |
Fix all pointers (convert index -> pointer) | |
static std::pair< const SaveLoadFormat &, uint8_t > | GetSavegameFormat (const std::string &full_name) |
Return the savegameformat of the game. | |
void | InitializeGame (uint size_x, uint size_y, bool reset_date, bool reset_settings) |
bool | AfterLoadGame () |
Perform a (large) amount of savegame conversion magic in order to load older savegames and to fill the caches for various purposes. | |
bool | LoadOldSaveGame (const std::string &file) |
static void | ResetSaveloadData () |
Clear temporary data that is passed between various saveload phases. | |
static void | ClearSaveLoadState () |
Clear/free saveload state. | |
static void | SaveFileStart () |
Update the gui accordingly when starting saving and set locks on saveload. | |
static void | SaveFileDone () |
Update the gui accordingly when saving is done and release locks on saveload. | |
void | SetSaveLoadError (StringID str) |
Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friends) | |
StringID | GetSaveLoadErrorType () |
Return the appropriate initial string for an error depending on whether we are saving or loading. | |
StringID | GetSaveLoadErrorMessage () |
Return the description of the error. | |
static void | SaveFileError () |
Show a gui message when saving has failed. | |
static SaveOrLoadResult | SaveFileToDisk (bool threaded) |
We have written the whole game into memory, _memory_savegame, now find and appropriate compressor and start writing to file. | |
void | WaitTillSaved () |
static SaveOrLoadResult | DoSave (std::shared_ptr< SaveFilter > writer, bool threaded) |
Actually perform the saving of the savegame. | |
SaveOrLoadResult | SaveWithFilter (std::shared_ptr< SaveFilter > writer, bool threaded) |
Save the game using a (writer) filter. | |
static const SaveLoadFormat * | DetermineSaveLoadFormat (uint32_t tag, uint32_t raw_version) |
Determines the SaveLoadFormat that is connected to the given tag. | |
static SaveOrLoadResult | DoLoad (std::shared_ptr< LoadFilter > reader, bool load_check) |
Actually perform the loading of a "non-old" savegame. | |
SaveOrLoadResult | LoadWithFilter (std::shared_ptr< LoadFilter > reader) |
Load the game using a (reader) filter. | |
SaveOrLoadResult | SaveOrLoad (const std::string &filename, SaveLoadOperation fop, DetailedFileType dft, Subdirectory sb, bool threaded) |
Main Save or Load function where the high-level saveload functions are handled. | |
void | DoAutoOrNetsave (FiosNumberedSaveName &counter) |
Create an autosave or netsave. | |
void | DoExitSave () |
Do a save when exiting the game (_settings_client.gui.autosave_on_exit) | |
std::string | GenerateDefaultSaveName () |
Get the default name for a savegame or screenshot. | |
Variables | |
const SaveLoadVersion | SAVEGAME_VERSION = (SaveLoadVersion)(SL_MAX_VERSION - 1) |
Current savegame version of OpenTTD. | |
SavegameType | _savegame_type |
type of savegame we are loading | |
FileToSaveLoad | _file_to_saveload |
File to save or load in the openttd loop. | |
uint32_t | _ttdp_version |
version of TTDP savegame (if applicable) | |
SaveLoadVersion | _sl_version |
the major savegame version identifier | |
uint8_t | _sl_minor_version |
the minor savegame version, DO NOT USE! | |
std::string | _savegame_format |
how to compress savegames | |
bool | _do_autosave |
are we doing an autosave at the moment? | |
static const size_t | MEMORY_CHUNK_SIZE = 128 * 1024 |
Save in chunks of 128 KiB. | |
static SaveLoadParams | _sl |
Parameters used for/at saveload. | |
static std::atomic< AsyncSaveFinishProc > | _async_save_finish |
Callback to call when the savegame loading is finished. | |
static std::thread | _save_thread |
The thread we're using to compress and write a savegame. | |
static size_t | _next_offs |
static const uint | LZO_BUFFER_SIZE = 8192 |
Buffer size for the LZO compressor. | |
static const lzma_stream | _lzma_init = LZMA_STREAM_INIT |
Have a copy of an initialised LZMA stream. | |
static const uint32_t | SAVEGAME_TAG_LZO = TO_BE32X('OTTD') |
static const uint32_t | SAVEGAME_TAG_NONE = TO_BE32X('OTTN') |
static const uint32_t | SAVEGAME_TAG_ZLIB = TO_BE32X('OTTZ') |
static const uint32_t | SAVEGAME_TAG_LZMA = TO_BE32X('OTTX') |
static const SaveLoadFormat | _saveload_formats [] |
The different saveload formats known/understood by OpenTTD. | |
All actions handling saving and loading goes on in this file.
The general actions are as follows for saving a game (loading is analogous):
Definition in file saveload.cpp.
typedef void(* AsyncSaveFinishProc) () |
Callback for when the savegame loading is finished.
Definition at line 357 of file saveload.cpp.
enum NeedLength |
Enumerator | |
---|---|
NL_NONE | not working in NeedLength mode |
NL_WANTLENGTH | writing length and data |
NL_CALCLENGTH | need to calculate the length |
Definition at line 77 of file saveload.cpp.
enum SaveLoadAction |
What are we currently doing?
Enumerator | |
---|---|
SLA_LOAD | loading |
SLA_SAVE | saving |
SLA_PTRS | fixing pointers |
SLA_NULL | null all pointers (on loading error) |
SLA_LOAD_CHECK | partial loading into _load_check_data |
Definition at line 69 of file saveload.cpp.
|
extern |
Perform a (large) amount of savegame conversion magic in order to load older savegames and to fill the caches for various purposes.
< Flag for coast.
Definition at line 566 of file afterload.cpp.
References _animated_tiles, _current_company, _gamelog, _grfconfig, _industry_builder, _network_dedicated, _network_server, _networking, _new_competitor_timeout, _old_vds, _pause_mode, _road_stop_stop_frame, _settings_client, _settings_game, _settings_newgame, _tunnel_visibility_frame, ShipVehicleInfo::acceleration, IndustrySpec::accepts_cargo, AddInflation(), CargoPacket::AfterLoad(), AfterLoadCompanyStats(), AfterLoadLabelMaps(), AfterLoadLinkGraphs(), AfterLoadRoadStops(), AfterLoadStoryBook(), AfterLoadVehiclesPhase1(), AfterLoadVehiclesPhase2(), AIR_AIRCRAFT, AircraftNextAirportPos_and_Order(), EconomySettings::allow_town_level_crossings, EconomySettings::allow_town_roads, Animated, AssignBit(), AT_OILRIG, AXIS_X, AXIS_Y, AxisToDirection(), IndustrySpec::behaviour, Object::build_date, Station::bus_stops, CalcClosestTownFromTile(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargo_payment_pool >::CanAllocateItem(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::CanAllocateItem(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_roadstop_pool >::CanAllocateItem(), CARGO_NO_REFIT, CeilDiv(), ChangeTileOwner(), CheckGroundVehiclesAtCorrectZ(), Clamp(), CLEAR_FIELDS, ConstructionSettings::clear_frame_burst, CLEAR_GRASS, CLEAR_SNOW, ClearBridgeMiddle(), ClosestTownFromTile(), ClrBit(), ClientSettings::company, DifficultySettings::competitors_interval, ConnectMultiheadedTrains(), GameSettings::construction, ConvertFromOldCompanyManagerFace(), ConvertOldMultiheadToNew(), CopyFromOldName(), CopyTempEngineData(), TimerGameTick::counter, Vehicle::current_order, TimerGameCalendar::date, TimerGameEconomy::date, TimerGameCalendar::date_fract, TimerGameEconomy::date_fract, Ticks::DAY_TICKS, TimerGameConst< struct Calendar >::DAYS_TILL_ORIGINAL_BASE_YEAR, TimerGameConst< struct Economy >::DAYS_TILL_ORIGINAL_BASE_YEAR, Debug, TimerGameConst< struct Calendar >::DEF_END_YEAR, DIAGDIR_END, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_SE, DIAGDIR_SW, DiagDirToAxis(), DiagDirToDiagTrackBits(), DiagDirToDiagTrackdir(), DiagDirToDir(), GameSettings::difficulty, Vehicle::direction, DirToDiagDir(), VehicleSettings::disable_elrails, DistanceManhattan(), LinkGraphSettings::distribution_armoured, LinkGraphSettings::distribution_default, LinkGraphSettings::distribution_mail, LinkGraphSettings::distribution_pax, DoStartupNewCompany(), DT_MANUAL, VehicleSettings::dynamic_engines, GameSettings::economy, EF_ROAD_TRAM, GameCreationSettings::ending_year, FACIL_AIRPORT, FACIL_DOCK, FACIL_TRAIN, EconomySettings::feeder_payment_share, FindFirstCargoWithTownAcceptanceEffect(), FixOwnerOfRailTrack(), FixupTrainLengths(), FixVehicleInclination(), FLYING, PathfinderSettings::forbid_90_deg, ConstructionSettings::freeform_edges, SpecializedStation< Station, false >::From(), SpecializedVehicle< T, Type >::From(), GameSettings::game_creation, GB(), GCF_COMPATIBLE, GCS_NOT_FOUND, GenerateSavegameId(), GoodsEntry::GES_RATING, SpecializedStation< Station, false >::Get(), CargoSpec::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), GetAircraftFlightLevelBounds(), BaseStation::GetByTile(), Industry::GetByTile(), GetClearDensity(), GetCompanyRailTypes(), GetCompanyRoadTypes(), GetFirstPlayableCompanyID(), OverrideManagerBase::GetGRFID(), GetHouseType(), SpecializedStation< Station, false >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), GetInclinedSlopeDirection(), GetIndustryGfx(), GetIndustrySpec(), GetIndustryType(), GetLockPart(), GetNorthernBridgeEnd(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::GetNumItems(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::GetNumItems(), GetOtherShipDepotTile(), GetOtherTunnelBridgeEnd(), GetRailType(), GetRawClearGround(), GetRoadOwner(), GetRoadTileType(), GetSlopePixelZ(), GetStationGfx(), GetStationType(), GetTargetAirportIfValid(), GetTileMaxPixelZ(), GetTileMaxZ(), GetTileOwner(), GetTileSlope(), GetTileTrackStatus(), GetTileType(), GetTileZ(), GetTreeGround(), GetTunnelBridgeDirection(), GetTunnelBridgeTransportType(), GetWaterClass(), GetWaterTileType(), GF_REPLACE_PROTECTION, GF_REPLACE_WAGON_REMOVAL, GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET, GfxLoadSprites(), GLC_ALL_GOOD, GLC_COMPATIBLE, GLC_NOT_FOUND, Gamelog::GRFAddList(), Gamelog::GRFCompatible(), Gamelog::GRFRemove(), GroundVehicle< T, Type >::gv_flags, GVF_GOINGDOWN_BIT, GVF_GOINGUP_BIT, OrthogonalTileArea::h, HasBit(), HasSignals(), HasStationRail(), HasStationTileRail(), HasTownOwnedRoad(), Object::IncTypeCount(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, Industry, DifficultySettings::industry_density, INDUSTRYBEH_BUILT_ONWATER, INDUSTRYBEH_PLANT_ON_BUILT, Economy::inflation_payment, Economy::inflation_prices, EconomySettings::infrastructure_maintenance, InitializeRailGUI(), InitializeWindowsAndCaches(), INVALID_COMPANY, INVALID_DIR, INVALID_OWNER, INVALID_ROADTYPE, INVALID_STRING_ID, INVALID_TILE, INVALID_TRACK, IsAirportTile(), IsAnyRoadStop(), IsBayRoadStopTile(), IsBridge(), IsBridgeTile(), IsBuoy(), IsBuoyTile(), IsClearGround(), IsDepotTile(), IsDock(), IsDriveThroughStopTile(), SpecializedStation< Station, false >::IsExpected(), IsGoodGRFConfigList(), IsHouseCompleted(), IsInsideMM(), IsLevelCrossing(), IsLevelCrossingTile(), IsLock(), IsOilRig(), IsPlainRail(), IsPlainRailTile(), IsRailDepot(), IsRailDepotTile(), IsRoadDepot(), IsSavegameVersionBefore(), IsSavegameVersionBeforeOrAt(), IsShipDepot(), IsShipDepotTile(), IsStationRoadStop(), IsStationTileBlocked(), IsTileFlat(), IsTileOwner(), IsTileType(), IsTruckStop(), IsTunnelTile(), Order::IsType(), IsValidCargoID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::IsValidID(), IsWater(), Map::Iterate(), SpecializedStation< Waypoint, true >::Iterate(), SpecializedStation< Station, false >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargo_payment_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_engine_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_industry_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_group_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_depot_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_subsidy_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_backup_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_object_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Iterate(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_sign_pool >::Iterate(), SpecializedVehicle< T, Type >::Iterate(), GameCreationSettings::landscape, EconomySettings::larger_towns, GameSettings::linkgraph, LoadStringWidthTable(), GameSettings::locale, Object::location, LOCK_PART_MIDDLE, Tile::m2(), MakeCanal(), MakeClear(), MakeDefaultName(), MakeSea(), MakeShore(), ConstructionSettings::map_height_limit, ConstructionSettings::max_bridge_length, MAX_COMPANIES, MAX_INFLATION, DifficultySettings::max_loan, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::MAX_SIZE, VehicleSettings::max_train_length, ConstructionSettings::max_tunnel_length, MAX_UVALUE, Map::MaxX(), Map::MaxY(), MayAnimateTile(), MayHaveBridgeAbove(), MIN_SNOWLINE_HEIGHT, EngineInfo::misc_flags, StationSettings::modified_catchment, MoveBuoysToWaypoints(), MoveWaypointsToBaseStations(), MP_CLEAR, MP_HOUSE, MP_INDUSTRY, MP_OBJECT, MP_RAILWAY, MP_ROAD, MP_STATION, MP_TREES, MP_TUNNELBRIDGE, MP_VOID, MP_WATER, NEW_HOUSE_OFFSET, GRFConfig::next, SpecializedVehicle< T, Type >::Next(), None, DifficultySettings::number_towns, OBJECT_HQ, OBJECT_STATUE, Economy::old_max_loan_unround, Economy::old_max_loan_unround_fract, Gamelog::Oldver(), OLFB_NO_LOAD, ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, TimerGameConst< struct Calendar >::ORIGINAL_BASE_YEAR, TimerGameConst< struct Economy >::ORIGINAL_BASE_YEAR, OSL_PLATFORM_FAR_END, OUFB_TRANSFER, OUFB_UNLOAD, BaseStation::owner, OWNER_NONE, OWNER_TOWN, OWNER_WATER, GameSettings::pf, VehicleSettings::plane_crashes, VehicleSettings::plane_speed, PM_PAUSED_ERROR, PM_PAUSED_NORMAL, PM_UNPAUSED, Gamelog::PrintDebug(), RailVehicleInfo::railtype, RAILTYPE_ELECTRIC, RAILTYPE_RAIL, RATING_INITIAL, LinkGraphSettings::recalc_interval, LinkGraphSettings::recalc_time, Station::RecomputeCatchmentForAll(), BaseStation::rect, IndustryBuildData::Reset(), ResetCompanyLivery(), ResetOldNames(), ResetSignalHandlers(), Backup< T >::Restore(), PathfinderSettings::reverse_at_signals, ReverseDiagDir(), ReverseDir(), VehicleSettings::road_side, ROAD_TILE_CROSSING, ROAD_TILE_DEPOT, ROAD_TILE_NORMAL, ROAD_X, ROAD_Y, RoadVehicle::roadtype, ROADTYPE_ROAD, ROADTYPE_TRAM, VehicleSettings::roadveh_acceleration_model, VehicleSettings::roadveh_slope_steepness, RVS_DRIVE_SIDE, RVS_ENTERED_STOP, RVS_IN_DT_ROAD_STOP, RVS_IN_ROAD_STOP, RVSB_IN_DEPOT, RVSB_IN_ROAD_STOP, RVSB_WORMHOLE, SB(), TimerGameConst< struct Calendar >::SECONDS_PER_DAY, StationSettings::serve_neutral_industries, SetAircraftPosition(), SetAnimatedTileState(), SetAnimationFrame(), SetBit(), SetBridgeMiddle(), SetClearGroundDensity(), SetCrossingReservation(), TimerGameCalendar::SetDate(), TimerGameEconomy::SetDate(), SetDepotReservation(), SetDockingTile(), SetFence(), SetHouseCompleted(), SetHouseType(), SetLiftPosition(), SetNonFloodingWaterTile(), SetRailStationReservation(), SetRailStationTileFlags(), SetRailType(), SetRoadOwner(), SetRoadTypes(), SetSaveLoadError(), SetSignalHandlers(), SetSignalStates(), SetStationGfx(), SetTileOwner(), SetTileType(), CompanyProperties::settings, SetTownIndex(), SetTrackReservation(), SetTropicZone(), SetTunnelBridgeReservation(), SetWaterClass(), SetWaterClassDependingOnSurroundings(), SetWaterTileType(), ShowErrorMessage(), SIG_ELECTRIC, SIG_SEMAPHORE, SIGTYPE_COMBO, SlError(), SlErrorCorrupt(), SLV_1, SLV_100, SLV_101, SLV_103, SLV_104, SLV_106, SLV_11, SLV_111, SLV_112, SLV_113, SLV_114, SLV_117, SLV_119, SLV_120, SLV_121, SLV_122, SLV_123, SLV_124, SLV_125, SLV_126, SLV_127, SLV_128, SLV_131, SLV_133, SLV_134, SLV_135, SLV_136, SLV_137, SLV_138, SLV_139, SLV_140, SLV_141, SLV_142, SLV_143, SLV_144, SLV_145, SLV_146, SLV_147, SLV_148, SLV_149, SLV_15, SLV_152, SLV_153, SLV_156, SLV_158, SLV_159, SLV_16, SLV_160, SLV_161, SLV_164, SLV_165, SLV_166, SLV_17, SLV_172, SLV_175, SLV_177, SLV_182, SLV_183, SLV_184, SLV_186, SLV_188, SLV_190, SLV_192, SLV_194, SLV_198, SLV_2, SLV_21, SLV_24, SLV_25, SLV_26, SLV_31, SLV_32, SLV_34, SLV_36, SLV_38, SLV_4, SLV_42, SLV_43, SLV_45, SLV_46, SLV_48, SLV_49, SLV_50, SLV_52, SLV_53, SLV_56, SLV_57, SLV_58, SLV_59, SLV_6, SLV_61, SLV_62, SLV_64, SLV_69, SLV_70, SLV_72, SLV_74, SLV_76, SLV_78, SLV_81, SLV_82, SLV_83, SLV_84, SLV_86, SLV_87, SLV_88, SLV_9, SLV_90, SLV_91, SLV_93, SLV_94, SLV_95, SLV_96, SLV_98, SLV_99, SLV_AI_START_DATE, SLV_ANIMATED_TILE_STATE_IN_MAP, SLV_COMPANY_INAUGURATED_PERIOD, SLV_CONSISTENT_PARTIAL_Z, SLV_DEPOT_UNBUNCHING, SLV_ECONOMY_DATE, SLV_ECONOMY_MODE_TIMEKEEPING_UNITS, SLV_ENDING_YEAR, SLV_EXTEND_INDUSTRY_CARGO_SLOTS, SLV_EXTEND_RAILTYPES, SLV_GROUP_NUMBERS, SLV_GROUP_REPLACE_WAGON_REMOVAL, SLV_GS_INDUSTRY_CONTROL, SLV_INCREASE_HOUSE_LIMIT, SLV_INCREASE_STATION_TYPE_FIELD_SIZE, SLV_LAST_LOADING_TICK, SLV_LINKGRAPH_SECONDS, SLV_MAX_LOAN_FOR_COMPANY, SLV_MULTITILE_DOCKS, SLV_MULTITRACK_LEVEL_CROSSINGS, SLV_NEWGRF_LAST_SERVICE, SLV_NONFLOODING_WATER_TILES, SLV_REPAIR_OBJECT_DOCKING_TILES, SLV_ROAD_TYPES, SLV_SAVEGAME_ID, SLV_SCRIPT_RANDOMIZER, SLV_SERVE_NEUTRAL_INDUSTRIES, SLV_SHIP_ACCELERATION, SLV_SHIPS_STOP_IN_LOCKS, SLV_TOWN_CARGOGEN, SLV_TREES_WATER_CLASS, SLV_VEHICLE_ECONOMY_AGE, SLV_VELOCITY_NAUTICAL, SLV_WATER_TILE_TYPE, GameCreationSettings::snow_line_height, GameCreationSettings::starting_year, StartScripts(), StartupEngines(), RoadVehicle::state, GameSettings::station, EconomySettings::station_noise_level, BaseTimer< TTimerType >::storage, Swap(), TAE_FOOD, TAE_GOODS, TAE_MAIL, TAE_PASSENGERS, TAE_WATER, TCGM_ORIGINAL, ConstructionSettings::terraform_frame_burst, Gamelog::TestMode(), Gamelog::TestRevision(), TFP_NONE, TFP_STUCK, OrthogonalTileArea::tile, Vehicle::tile, TILE_HEIGHT, TILE_SIZE, TILE_UNIT_MASK, TileAddXY(), TileDiffXY(), TileHash(), TileHeight(), TileVirtXY(), TileX(), TileXY(), TileY(), EconomySettings::timekeeping_units, TL_BETTER_ROADS, TL_RANDOM, BaseStation::town, Town, Object::town, CargoSpec::town_acceptance_effect, EconomySettings::town_cargogen_mode, TOWN_CUSTOM_GROWTH, TOWN_GROWTH_DESERT, TOWN_GROWTH_RATE_NONE, Ticks::TOWN_GROWTH_TICKS, TOWN_GROWTH_WINTER, TOWN_HOUSE_COMPLETED, EconomySettings::town_layout, GameCreationSettings::town_name, TRACK_BIT_NONE, TRACK_BIT_WORMHOLE, TRACK_BIT_X, TRACK_BIT_Y, TRACK_LOWER, TRACK_UPPER, TrackStatusToTrackBits(), VehicleSettings::train_acceleration_model, VehicleSettings::train_slope_steepness, BaseStation::train_station, TRANSPORT_RAIL, TRANSPORT_ROAD, ConstructionSettings::tree_frame_burst, TREE_GROUND_SHORE, TREE_GROUND_SNOW_DESERT, TrimIndustryAcceptedProduced(), TROPICZONE_NORMAL, Station::truck_stops, Object::type, BaseVehicle::type, LocaleSettings::units_force, LocaleSettings::units_height, LocaleSettings::units_power, LocaleSettings::units_velocity, LocaleSettings::units_velocity_nautical, LocaleSettings::units_volume, LocaleSettings::units_weight, GroupStatistics::UpdateAfterLoad(), UpdateAircraftCache(), UpdateCompanyLiveries(), UpdateHousesAndTowns(), UpdateLevelCrossing(), UpdateNearestTownForRoadTiles(), UpdateOldAircraft(), UpdateStationAcceptance(), UpdateTownMaxPass(), FreeUnitIDGenerator::UseID(), VEH_INVALID, VEH_ROAD, VEH_SHIP, VEH_TRAIN, GameSettings::vehicle, Vehicle::vehstatus, VF_LOADING_FINISHED, VF_PATHFINDER_LOST, VS_CRASHED, VS_HIDDEN, VS_STOPPED, OrthogonalTileArea::w, PathfinderSettings::wait_for_pbs_path, PathfinderSettings::wait_oneway_signal, PathfinderSettings::wait_twoway_signal, WATER_CLASS_CANAL, WATER_CLASS_INVALID, WATER_CLASS_RIVER, WATER_CLASS_SEA, WATER_TILE_CLEAR, WATER_TILE_COAST, WATER_TILE_DEPOT, WATER_TILE_LOCK, WL_CRITICAL, XYNSToDiagDir(), YapfNotifyTrackLayoutChange(), TimerGameCalendar::year, and TimerGameEconomy::year.
Referenced by DoLoad(), and SaveOrLoad().
|
static |
List of all chunks in a savegame.
Definition at line 202 of file saveload.cpp.
Referenced by SlFindChunkHandler(), SlFixPointers(), SlNullPointers(), and SlSaveChunks().
|
inlinestatic |
Clear/free saveload state.
Definition at line 2799 of file saveload.cpp.
References _sl, SaveLoadParams::dumper, SaveLoadParams::lf, SaveLoadParams::reader, and SaveLoadParams::sf.
Referenced by DoLoad(), LoadWithFilter(), SaveFileToDisk(), SaveOrLoad(), and SaveWithFilter().
|
static |
Determines the SaveLoadFormat that is connected to the given tag.
When the given tag is known, that format is chosen and a check on the validity of the version is performed. Otherwise a fallback to an ancient buggy format using LZO is chosen.
tag | The tag from the header describing the savegame compression/format. |
raw_version | The raw version from the savegame header. |
Definition at line 2967 of file saveload.cpp.
References _saveload_formats, _sl, _sl_minor_version, _sl_version, Debug, SaveLoadParams::lf, SAVEGAME_VERSION, SL_MIN_VERSION, SlError(), SLV_END_PATCHPACKS, SLV_START_PATCHPACKS, and SaveLoadFormat::tag.
Referenced by DoLoad().
void DoAutoOrNetsave | ( | FiosNumberedSaveName & | counter | ) |
Create an autosave or netsave.
counter | A reference to the counter variable to be used for rotating the file name. |
netsave | Indicates if this is a regular autosave or a netsave. |
Definition at line 3219 of file saveload.cpp.
References _settings_client, AUTOSAVE_DIR, Debug, DFT_GAME_FILE, FiosNumberedSaveName::Extension(), FiosNumberedSaveName::Filename(), GenerateDefaultSaveName(), ClientSettings::gui, INVALID_STRING_ID, GUISettings::keep_all_autosave, SaveOrLoad(), ShowErrorMessage(), SL_OK, SLO_SAVE, and WL_ERROR.
Referenced by ClientNetworkEmergencySave().
void DoExitSave | ( | ) |
Do a save when exiting the game (_settings_client.gui.autosave_on_exit)
Definition at line 3237 of file saveload.cpp.
References AUTOSAVE_DIR, DFT_GAME_FILE, SaveOrLoad(), and SLO_SAVE.
Referenced by VideoDriver_Null::MainLoop(), and MainWindow::OnHotkey().
|
static |
Actually perform the loading of a "non-old" savegame.
reader | The filter to read the savegame from. |
load_check | Whether to perform the checking ("preview") or actually load the game. |
Definition at line 3008 of file saveload.cpp.
References _gamelog, _grfconfig, _load_check_data, _savegame_type, _sl, AfterLoadGame(), LoadCheckData::checkable, LoadCheckData::Clear(), ClearGRFConfigList(), ClearSaveLoadState(), DetermineSaveLoadFormat(), GLAT_LOAD, LoadCheckData::grf_compatibility, LoadCheckData::grfconfig, SaveLoadFormat::init_load, IsGoodGRFConfigList(), IsSavegameVersionBefore(), SaveLoadParams::lf, SaveLoadFormat::name, SaveLoadParams::reader, Gamelog::Reset(), ResetSaveloadData(), SGT_OTTD, SL_OK, SL_REINIT, SlError(), SlFixPointers(), SlLoadCheckChunks(), SlLoadChunks(), SLV_4, Gamelog::StartAction(), and Gamelog::StopAction().
Referenced by LoadWithFilter(), and SaveOrLoad().
|
static |
Actually perform the saving of the savegame.
General tactics is to first save the game to memory, then write it to file using the writer, either in threaded mode if possible, or single-threaded.
writer | The filter to write the savegame to. |
threaded | Whether to try to perform the saving asynchronously. |
Definition at line 2916 of file saveload.cpp.
References _save_thread, _sl, _sl_version, Debug, SaveLoadParams::dumper, SaveFileDone(), SaveFileStart(), SaveFileToDisk(), SAVEGAME_VERSION, SaveLoadParams::saveinprogress, SaveLoadParams::sf, SL_OK, SlSaveChunks(), and StartNewThread().
Referenced by SaveOrLoad(), and SaveWithFilter().
|
static |
Scan the string for old values of SCC_ENCODED and fix it to it's new, value.
Note that at the moment this runs, the string has not been validated yet because the validation looks for SCC_ENCODED. If there is something invalid, just bail out and do not continue trying to replace the tokens.
str | the string to fix. |
Definition at line 915 of file saveload.cpp.
References Utf8Decode(), Utf8Encode(), and Utf8EncodedCharLen().
Referenced by SlStdString().
std::string GenerateDefaultSaveName | ( | ) |
Get the default name for a savegame or screenshot.
Definition at line 3245 of file saveload.cpp.
References _local_company, _settings_client, TimerGameTick::counter, TimerGameEconomy::date, GUISettings::date_format_in_default_names, GetString(), ClientSettings::gui, Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_company_pool >::Iterate(), SanitizeFilename(), SetDParam(), Ticks::TICKS_PER_SECOND, and TimerGameEconomy::UsingWallclockUnits().
Referenced by DoAutoOrNetsave(), SaveLoadWindow::GenerateFileName(), and MakeScreenshotName().
|
static |
Return the type as saved/loaded inside the savegame.
Definition at line 552 of file saveload.cpp.
References SaveLoad::cmd, SaveLoad::conv, GetVarFileType(), IsSavegameVersionBefore(), SL_ARR, SL_DEQUE, SL_REF, SL_REFLIST, SL_REFVECTOR, SL_SAVEBYTE, SL_STDSTR, SL_STRUCT, SL_STRUCTLIST, SL_VAR, SL_VECTOR, SLE_FILE_HAS_LENGTH_FIELD, and SLV_69.
Referenced by SlTableHeader().
|
static |
Return the savegameformat of the game.
Whether it was created with ZLIB compression uncompressed, or another type
full_name | Name of the savegame format. If empty it picks the first available one |
Definition at line 2741 of file saveload.cpp.
References _saveload_formats, Clamp(), SaveLoadFormat::default_compression, SaveLoadFormat::name, SetDParamStr(), ShowErrorMessage(), SlError(), and WL_CRITICAL.
Referenced by SaveFileToDisk().
StringID GetSaveLoadErrorMessage | ( | ) |
Return the description of the error.
Definition at line 2842 of file saveload.cpp.
References _sl, SaveLoadParams::error_str, SaveLoadParams::extra_msg, and SetDParamStr().
Referenced by SaveFileError(), SaveFileToDisk(), and SaveOrLoad().
StringID GetSaveLoadErrorType | ( | ) |
Return the appropriate initial string for an error depending on whether we are saving or loading.
Definition at line 2836 of file saveload.cpp.
References _sl, SaveLoadParams::action, and SLA_SAVE.
Referenced by SaveFileError(), SaveFileToDisk(), and SaveOrLoad().
void InitializeGame | ( | uint | size_x, |
uint | size_y, | ||
bool | reset_date, | ||
bool | reset_settings | ||
) |
|
static |
Pointers cannot be loaded from a savegame, so this function gets the index from the savegame and returns the appropriate pointer from the already loaded base.
Remember that an index of 0 is a nullptr pointer so all indices are +1 so vehicle 0 is saved as 1.
index | The index that is being converted to a pointer |
rt | SLRefType type of the object the pointer is sought of |
Definition at line 1139 of file saveload.cpp.
References _sl, SaveLoadParams::action, SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_job_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargopacket_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_roadstop_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_persistent_storage_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_enginerenew_pool >::Get(), IsSavegameVersionBefore(), SpecializedStation< Station, false >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargopacket_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_town_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_orderlist_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_roadstop_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_link_graph_job_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_enginerenew_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_persistent_storage_pool >::IsValidID(), REF_CARGO_PACKET, REF_ENGINE_RENEWS, REF_LINK_GRAPH, REF_LINK_GRAPH_JOB, REF_ORDER, REF_ORDERLIST, REF_ROADSTOPS, REF_STATION, REF_STORAGE, REF_TOWN, REF_VEHICLE, REF_VEHICLE_OLD, SLA_PTRS, SlErrorCorrupt(), SLV_4, and SLV_5.
Referenced by SlSaveLoadRef().
|
extern |
Definition at line 259 of file oldloader.cpp.
SaveOrLoadResult LoadWithFilter | ( | std::shared_ptr< LoadFilter > | reader | ) |
Load the game using a (reader) filter.
reader | The filter to read the savegame from. |
Definition at line 3108 of file saveload.cpp.
References _sl, SaveLoadParams::action, ClearSaveLoadState(), DoLoad(), SL_REINIT, and SLA_LOAD.
Referenced by SafeLoad().
void ProcessAsyncSaveFinish | ( | ) |
Handle async save finishes.
Definition at line 376 of file saveload.cpp.
References _async_save_finish, and _save_thread.
int64_t ReadValue | ( | const void * | ptr, |
VarType | conv | ||
) |
Return a signed-long version of the value of a setting.
ptr | pointer to the variable |
conv | type of variable, can be a non-clean type, eg one with other flags because it is parsed |
Definition at line 794 of file saveload.cpp.
References GetVarMemType(), and SLE_VAR_NULL.
Referenced by CheatWindow::DrawWidget(), CheatWindow::OnClick(), CheatWindow::OnQueryTextFinished(), IntSettingDesc::Read(), and SlSaveLoadConv().
|
static |
Pointers cannot be saved to a savegame, so this functions gets the index of the item, and if not available, it hussles with pointers (looks really bad :() Remember that a nullptr item has value 0, and all indices have +1, so vehicle 0 is saved as index 1.
obj | The object that we want to get the index of |
rt | SLRefType type of the object the index is being sought of |
Definition at line 1106 of file saveload.cpp.
References _sl, SaveLoadParams::action, REF_CARGO_PACKET, REF_ENGINE_RENEWS, REF_LINK_GRAPH, REF_LINK_GRAPH_JOB, REF_ORDER, REF_ORDERLIST, REF_ROADSTOPS, REF_STATION, REF_STORAGE, REF_TOWN, REF_VEHICLE, REF_VEHICLE_OLD, and SLA_SAVE.
Referenced by SlSaveLoadRef().
|
static |
Clear temporary data that is passed between various saveload phases.
Definition at line 2789 of file saveload.cpp.
Referenced by DoLoad(), and SaveOrLoad().
|
static |
Update the gui accordingly when saving is done and release locks on saveload.
Definition at line 2817 of file saveload.cpp.
References _sl, InvalidateWindowData(), SaveLoadParams::saveinprogress, SBI_SAVELOAD_FINISH, SetMouseCursorBusy(), and WC_STATUS_BAR.
Referenced by DoSave(), SaveFileError(), and SaveFileToDisk().
|
static |
Show a gui message when saving has failed.
Definition at line 2849 of file saveload.cpp.
References GetSaveLoadErrorMessage(), GetSaveLoadErrorType(), SaveFileDone(), ShowErrorMessage(), and WL_ERROR.
Referenced by SaveFileToDisk().
|
static |
Update the gui accordingly when starting saving and set locks on saveload.
Definition at line 2808 of file saveload.cpp.
References _sl, InvalidateWindowData(), SaveLoadParams::saveinprogress, SBI_SAVELOAD_START, SetMouseCursorBusy(), and WC_STATUS_BAR.
Referenced by DoSave().
|
static |
We have written the whole game into memory, _memory_savegame, now find and appropriate compressor and start writing to file.
Definition at line 2859 of file saveload.cpp.
References _savegame_format, _sl, ClearSaveLoadState(), Debug, SaveLoadParams::dumper, SaveLoadParams::error_str, GetSavegameFormat(), GetSaveLoadErrorMessage(), GetSaveLoadErrorType(), GetString(), SaveFileDone(), SaveFileError(), SAVEGAME_VERSION, SetAsyncSaveFinish(), SaveLoadParams::sf, and SL_OK.
Referenced by DoSave().
SaveOrLoadResult SaveOrLoad | ( | const std::string & | 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
filename | The name of the savegame being created/loaded |
fop | Save or load mode. Load can also be a TTD(Patch) game. |
sb | The sub directory to save the savegame in |
threaded | True when threaded saving is allowed |
Definition at line 3128 of file saveload.cpp.
References _do_autosave, _gamelog, _grfconfig, _settings_client, _sl, _sl_minor_version, _sl_version, SaveLoadParams::action, AfterLoadGame(), BASE_DIR, ClearGRFConfigList(), ClearSaveLoadState(), TimerGameEconomy::date, TimerGameEconomy::date_fract, Debug, DFT_GAME_FILE, DFT_OLD_GAME_FILE, DoLoad(), DoSave(), FioFOpenFile(), GetSaveLoadErrorMessage(), GetSaveLoadErrorType(), GetString(), GLAT_LOAD, ClientSettings::gui, INVALID_STRING_ID, Gamelog::Reset(), ResetSaveloadData(), SAVE_DIR, SaveLoadParams::saveinprogress, SCENARIO_DIR, ShowErrorMessage(), SL_MIN_VERSION, SL_OK, SL_REINIT, SLA_LOAD, SLA_LOAD_CHECK, SLA_SAVE, SlError(), SLO_CHECK, SLO_LOAD, SLO_SAVE, Gamelog::StartAction(), Gamelog::StopAction(), GUISettings::threaded_saves, and WL_ERROR.
Referenced by _GenerateWorld(), DEF_CONSOLE_CMD(), DoAutoOrNetsave(), DoExitSave(), LoadIntroGame(), SaveLoadWindow::OnClick(), openttd_main(), SafeLoad(), StateGameLoop(), and CrashLog::WriteSavegame().
SaveOrLoadResult SaveWithFilter | ( | std::shared_ptr< SaveFilter > | writer, |
bool | threaded | ||
) |
Save the game using a (writer) filter.
writer | The filter to write the savegame to. |
threaded | Whether to try to perform the saving asynchronously. |
Definition at line 2948 of file saveload.cpp.
References _sl, SaveLoadParams::action, ClearSaveLoadState(), DoSave(), and SLA_SAVE.
Referenced by ServerNetworkGameSocketHandler::SendMap().
|
static |
Called by save thread to tell we finished saving.
proc | The callback to call when saving is done. |
Definition at line 365 of file saveload.cpp.
References _async_save_finish, and CSleep().
Referenced by SaveFileToDisk().
void SetSaveLoadError | ( | StringID | str | ) |
Set the error message from outside of the actual loading/saving of the game (AfterLoadGame and friends)
Definition at line 2830 of file saveload.cpp.
References _sl, and SaveLoadParams::error_str.
Referenced by AfterLoadGame().
|
static |
Save/Load the length of the array followed by the array of SL_VAR elements.
array | The array being manipulated |
length | The length of the array in elements |
conv | VarType type of the atomic array (int, uint8_t, uint64_t, etc.) |
Definition at line 1060 of file saveload.cpp.
References _sl, SaveLoadParams::action, GetVarMemType(), IsSavegameVersionBefore(), SLA_LOAD, SLA_LOAD_CHECK, SLA_NULL, SLA_PTRS, SLA_SAVE, SlCopyInternal(), SLE_VAR_NULL, SlErrorCorrupt(), and SLV_SAVELOAD_LIST_LENGTH.
void SlAutolength | ( | AutolengthProc * | proc, |
int | arg | ||
) |
Do something of which I have no idea what it is :P.
proc | The callback procedure that is called |
arg | The variable that will be used for the callback procedure |
Definition at line 1988 of file saveload.cpp.
References _sl, SaveLoadParams::action, SaveLoadParams::dumper, SaveLoadParams::need_length, NL_CALCLENGTH, NL_WANTLENGTH, SaveLoadParams::obj_len, SLA_SAVE, and SlSetLength().
Referenced by AIPLChunkHandler::Save(), and GSDTChunkHandler::Save().
|
inlinestatic |
Return the size in bytes of a certain type of atomic array.
length | The length of the array counted in elements |
conv | VarType type of the variable that is used in calculating the size |
Definition at line 1049 of file saveload.cpp.
References SlCalcConvFileLen().
|
inlinestatic |
Return the size in bytes of a certain type of normal/atomic variable as it appears in a saved game.
See VarTypes
conv | VarType type of variable that is used for calculating the size |
Definition at line 618 of file saveload.cpp.
References GetVarFileType(), SLE_FILE_END, and SLE_FILE_STRINGID.
Referenced by SlCalcArrayLen(), SlStorageHelper< Tstorage, Tvar, Tallocator >::SlCalcLen(), SlCalcTableHeader(), SlCopy(), and SlCopyInternal().
|
inlinestatic |
Return the size in bytes of a certain type of normal/atomic variable as it appears in memory.
See VarTypes
conv | VarType type of variable that is used for calculating the size |
Definition at line 588 of file saveload.cpp.
References GetVarMemType(), SLE_VAR_NAME, SLE_VAR_NULL, SLE_VAR_STR, and SLE_VAR_STRQ.
Referenced by SlCopyInternal().
|
inlinestatic |
Return the size in bytes of a std::deque.
deque | The std::deque to find the size of |
conv | VarType type of variable that is used for calculating the size |
Definition at line 1388 of file saveload.cpp.
References GetVarMemType(), SlStorageHelper< Tstorage, Tvar, Tallocator >::SlCalcLen(), and SLE_VAR_STR.
size_t SlCalcObjLength | ( | const void * | object, |
const SaveLoadTable & | slt | ||
) |
Calculate the size of an object.
object | to be measured. |
slt | The SaveLoad table with objects to save/load. |
Definition at line 1539 of file saveload.cpp.
Referenced by SlObject().
size_t SlCalcObjMemberLength | ( | const void * | object, |
const SaveLoad & | sld | ||
) |
Definition at line 1550 of file saveload.cpp.
|
inlinestatic |
Return the size in bytes of a reference (pointer)
Definition at line 642 of file saveload.cpp.
References IsSavegameVersionBefore(), and SLV_69.
|
inlinestatic |
Return the size in bytes of a list.
list | The std::list to find the size of. |
conv | VarType type of variable that is used for calculating the size. |
Definition at line 1334 of file saveload.cpp.
References SL_REF, and SlStorageHelper< Tstorage, Tvar, Tallocator >::SlCalcLen().
Referenced by SlRefList().
|
static |
Return the size in bytes of a vector.
vector | The std::vector to find the size of. |
conv | VarType type of variable that is used for calculating the size. |
Definition at line 1361 of file saveload.cpp.
References SL_REF, and SlStorageHelper< Tstorage, Tvar, Tallocator >::SlCalcLen().
Referenced by SlRefVector().
|
inlinestatic |
Calculate the gross length of the string that it will occupy in the savegame.
This includes the real length, returned by SlCalcNetStringLen and the length that the index will occupy.
ptr | Pointer to the std::string . |
Definition at line 899 of file saveload.cpp.
Referenced by SlCalcTableHeader().
|
static |
Calculate the size of the table header.
slt | The SaveLoad table with objects to save/load. |
Definition at line 1510 of file saveload.cpp.
References SL_STRUCT, SL_STRUCTLIST, SlCalcConvFileLen(), SlCalcStdStringLen(), SlCalcTableHeader(), and SlIsObjectValidInSavegame().
Referenced by SlCalcTableHeader(), and SlTableHeader().
|
inlinestatic |
Return the size in bytes of a std::vector.
vector | The std::vector to find the size of |
conv | VarType type of variable that is used for calculating the size |
Definition at line 1446 of file saveload.cpp.
References GetVarMemType(), SlStorageHelper< Tstorage, Tvar, Tallocator >::SlCalcLen(), and SLE_VAR_STR.
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.
slt | The SaveLoad table with objects to save/load. |
slct | The SaveLoadCompat table the original order of the fields. |
Definition at line 1924 of file saveload.cpp.
References _sl, SaveLoadParams::action, SaveLoadParams::block_mode, SaveLoad::cmd, Debug, GetVarFileType(), SaveLoad::handler, SaveLoad::name, SL_NULL, SL_STRUCT, SL_STRUCTLIST, SLA_LOAD, SLA_LOAD_CHECK, SlCompatTableHeader(), SLE_VAR_NULL, SlErrorCorrupt(), SlIsObjectValidInSavegame(), and SlTableHeader().
Referenced by AIPLChunkHandler::Load(), ANITChunkHandler::Load(), ERNWChunkHandler::Load(), CMDLChunkHandler::Load(), CMPUChunkHandler::Load(), CAPAChunkHandler::Load(), CHTSChunkHandler::Load(), PLYRChunkHandler::Load(), DEPTChunkHandler::Load(), ECMYChunkHandler::Load(), CAPYChunkHandler::Load(), ENGNChunkHandler::Load(), EIDSChunkHandler::Load(), GSDTChunkHandler::Load(), GSTRChunkHandler::Load(), GOALChunkHandler::Load(), GRPSChunkHandler::Load(), INDYChunkHandler::Load(), IBLDChunkHandler::Load(), ITBLChunkHandler::Load(), RAILChunkHandler::Load(), ROTTChunkHandler::Load(), LGRPChunkHandler::Load(), LGRJChunkHandler::Load(), LGRSChunkHandler::Load(), MAPSChunkHandler::Load(), VIEWChunkHandler::Load(), NewGRFMappingChunkHandler::Load(), OBJSChunkHandler::Load(), ORDRChunkHandler::Load(), ORDLChunkHandler::Load(), BKORChunkHandler::Load(), SIGNChunkHandler::Load(), STNSChunkHandler::Load(), STNNChunkHandler::Load(), ROADChunkHandler::Load(), PSACChunkHandler::Load(), STPEChunkHandler::Load(), STPAChunkHandler::Load(), SUBSChunkHandler::Load(), CITYChunkHandler::Load(), VEHSChunkHandler::Load(), PLYRChunkHandler::LoadCheck(), MAPSChunkHandler::LoadCheck(), LoadSettings(), and SlCompatTableHeader().
void SlCopy | ( | void * | object, |
size_t | length, | ||
VarType | conv | ||
) |
Copy a list of SL_VARs to/from a savegame.
These entries are copied as-is, and you as caller have to make sure things like length-fields are calculated correctly.
object | The object being manipulated. |
length | The length of the object in elements |
conv | VarType type of the items. |
Definition at line 1030 of file saveload.cpp.
References _sl, SaveLoadParams::action, SaveLoadParams::need_length, NL_CALCLENGTH, NL_NONE, SLA_NULL, SLA_PTRS, SlCalcConvFileLen(), SlCopyInternal(), and SlSetLength().
Referenced by ANITChunkHandler::Load(), PRICChunkHandler::Load(), CAPRChunkHandler::Load(), ENGSChunkHandler::Load(), MAPTChunkHandler::Load(), MAPHChunkHandler::Load(), MAPOChunkHandler::Load(), MAP2ChunkHandler::Load(), M3LOChunkHandler::Load(), M3HIChunkHandler::Load(), MAP5ChunkHandler::Load(), MAPEChunkHandler::Load(), MAP7ChunkHandler::Load(), MAP8ChunkHandler::Load(), ORDRChunkHandler::Load(), NAMEChunkHandler::Load(), ScriptInstance::LoadObjects(), MAPTChunkHandler::Save(), MAPHChunkHandler::Save(), MAPOChunkHandler::Save(), MAP2ChunkHandler::Save(), M3LOChunkHandler::Save(), M3HIChunkHandler::Save(), MAP5ChunkHandler::Save(), MAPEChunkHandler::Save(), MAP7ChunkHandler::Save(), MAP8ChunkHandler::Save(), and ScriptInstance::SaveObject().
|
static |
Save/Load bytes.
These do not need to be converted to Little/Big Endian so directly write them or read them to/from file
ptr | The source or destination of the object being manipulated |
length | number of bytes this fast CopyBytes lasts |
Definition at line 765 of file saveload.cpp.
References _sl, SaveLoadParams::action, SLA_LOAD, SLA_LOAD_CHECK, SLA_SAVE, SlReadByte(), and SlWriteByte().
Referenced by SlCopyInternal(), and SlStdString().
|
static |
Internal function to save/Load a list of SL_VARs.
SlCopy() and SlArray() are very similar, with the exception of the header. This function represents the common part.
object | The object being manipulated. |
length | The length of the object in elements |
conv | VarType type of the items. |
Definition at line 981 of file saveload.cpp.
References _sl, _sl_version, SaveLoadParams::action, BSWAP32(), GetVarMemType(), SLA_SAVE, SlCalcConvFileLen(), SlCalcConvMemLen(), SlCopyBytes(), SLE_VAR_NULL, SlSaveLoadConv(), and SlSkipBytes().
|
static |
Save/load a std::deque.
deque | The std::deque being manipulated |
conv | VarType type of variable that is used for calculating the size |
Definition at line 1415 of file saveload.cpp.
References _sl, SaveLoadParams::action, GetVarMemType(), SL_STDSTR, SLA_SAVE, SLE_VAR_STR, and SlStorageHelper< Tstorage, Tvar, Tallocator >::SlSaveLoad().
void SlError | ( | StringID | string, |
const std::string & | extra_msg | ||
) |
Error handler.
Sets everything up to show an error message and to clean up the mess of a partial savegame load.
string | The translatable error message to show. |
extra_msg | An extra error message coming from one of the APIs. |
Definition at line 321 of file saveload.cpp.
References _gamelog, _load_check_data, _sl, SaveLoadParams::action, LoadCheckData::error, LoadCheckData::error_msg, SaveLoadParams::error_str, SaveLoadParams::extra_msg, SLA_LOAD, SLA_LOAD_CHECK, SLA_PTRS, and SlNullPointers().
Referenced by AfterLoadGame(), DetermineSaveLoadFormat(), DoLoad(), PacketWriter::Finish(), GetSavegameFormat(), LZMALoadFilter::LZMALoadFilter(), LZMASaveFilter::LZMASaveFilter(), LZOLoadFilter::LZOLoadFilter(), LZOSaveFilter::LZOSaveFilter(), MoveWaypointsToBaseStations(), ZlibLoadFilter::Read(), LZMALoadFilter::Read(), LZOLoadFilter::Read(), SaveOrLoad(), SlErrorCorrupt(), PacketWriter::Write(), FileWriter::Write(), ZlibSaveFilter::WriteLoop(), LZMASaveFilter::WriteLoop(), ZlibLoadFilter::ZlibLoadFilter(), and ZlibSaveFilter::ZlibSaveFilter().
void SlErrorCorrupt | ( | const std::string & | msg | ) |
Error handler for corrupt savegames.
Sets everything up to show the error message and to clean up the mess of a partial savegame load.
msg | Location the corruption has been spotted. |
Definition at line 351 of file saveload.cpp.
References SlError().
Referenced by AfterLoadGame(), AfterLoadVehiclesPhase2(), ConvertOldMultiheadToNew(), CHKPChunkHandler::FixPointers(), IntToReference(), AIPLChunkHandler::Load(), ANITChunkHandler::Load(), CHTSChunkHandler::Load(), ECMYChunkHandler::Load(), GSDTChunkHandler::Load(), IBLDChunkHandler::Load(), ITBLChunkHandler::Load(), LGRSChunkHandler::Load(), MAPSChunkHandler::Load(), VIEWChunkHandler::Load(), NGRFChunkHandler::Load(), NewGRFMappingChunkHandler::Load(), NAMEChunkHandler::Load(), CITYChunkHandler::Load(), VEHSChunkHandler::Load(), MAPSChunkHandler::LoadCheck(), ScriptInstance::LoadObjects(), LoadSettings(), MoveWaypointsToBaseStations(), LZOLoadFilter::Read(), SetWaterClassDependingOnSurroundings(), SlArray(), SlCompatTableHeader(), SlGetStructListLength(), SlLoadCheckChunk(), SlLoadCheckChunks(), SlLoadChunk(), SlLoadChunks(), SlReadSimpleGamma(), SlSaveChunk(), and SlTableHeader().
|
static |
Find the ChunkHandler that will be used for processing the found chunk in the savegame or in memory.
id | the chunk in question |
Definition at line 2191 of file saveload.cpp.
References ChunkHandlers().
Referenced by SlLoadCheckChunks(), and SlLoadChunks().
|
static |
Fix all pointers (convert index -> pointer)
Definition at line 2228 of file saveload.cpp.
References _sl, SaveLoadParams::action, ChunkHandlers(), Debug, and SLA_PTRS.
Referenced by DoLoad().
|
inlinestatic |
Definition at line 544 of file saveload.cpp.
size_t SlGetFieldLength | ( | ) |
Get the length of the current object.
Definition at line 782 of file saveload.cpp.
References _sl, and SaveLoadParams::obj_len.
Referenced by ANITChunkHandler::Load(), CHTSChunkHandler::Load(), ORDRChunkHandler::Load(), and NAMEChunkHandler::Load().
|
inlinestatic |
Return how many bytes used to encode a gamma value.
Definition at line 519 of file saveload.cpp.
size_t SlGetStructListLength | ( | size_t | limit | ) |
Get the length of this list; if it exceeds the limit, error out.
limit | The maximum size the list can be. |
Definition at line 1720 of file saveload.cpp.
References SlErrorCorrupt().
Referenced by VectorSaveLoadHandler< TImpl, TObject, TElementType, MAX_LENGTH >::GetLength(), SlStationSpecList< T >::GetLength(), SlStationGoods::GetNumCargo(), SlTownSupplied::GetNumCargo(), SlCompanyLiveries::GetNumLiveries(), and SlSkipHandler::Load().
void SlGlobList | ( | const SaveLoadTable & | slt | ) |
Save or Load (a list of) global variables.
slt | The SaveLoad table with objects to save/load. |
Definition at line 1978 of file saveload.cpp.
References SlObject().
Referenced by ANITChunkHandler::Load(), IBLDChunkHandler::Load(), MAPSChunkHandler::Load(), VIEWChunkHandler::Load(), MAPSChunkHandler::LoadCheck(), ANITChunkHandler::Save(), IBLDChunkHandler::Save(), MAPSChunkHandler::Save(), DATEChunkHandler::Save(), and VIEWChunkHandler::Save().
|
inlinestatic |
Are we going to save this object or not?
Definition at line 1500 of file saveload.cpp.
References _sl_version, SaveLoad::version_from, and SaveLoad::version_to.
Referenced by SlCalcTableHeader(), SlCompatTableHeader(), and SlTableHeader().
int SlIterateArray | ( | ) |
Iterate through the elements of an array and read the whole thing.
Definition at line 659 of file saveload.cpp.
References _sl, SaveLoadParams::block_mode, Debug, SaveLoadParams::expect_table_header, SaveLoadParams::obj_len, and SaveLoadParams::reader.
Referenced by AIPLChunkHandler::Load(), ANITChunkHandler::Load(), ERNWChunkHandler::Load(), CMDLChunkHandler::Load(), CMPUChunkHandler::Load(), CAPAChunkHandler::Load(), CHTSChunkHandler::Load(), PLYRChunkHandler::Load(), DEPTChunkHandler::Load(), ECMYChunkHandler::Load(), CAPYChunkHandler::Load(), ENGNChunkHandler::Load(), EIDSChunkHandler::Load(), GSDTChunkHandler::Load(), GSTRChunkHandler::Load(), GOALChunkHandler::Load(), GRPSChunkHandler::Load(), INDYChunkHandler::Load(), IBLDChunkHandler::Load(), ITBLChunkHandler::Load(), RAILChunkHandler::Load(), ROTTChunkHandler::Load(), LEAEChunkHandler::Load(), LEATChunkHandler::Load(), LGRPChunkHandler::Load(), LGRJChunkHandler::Load(), LGRSChunkHandler::Load(), MAPSChunkHandler::Load(), VIEWChunkHandler::Load(), NewGRFMappingChunkHandler::Load(), OBJSChunkHandler::Load(), ORDRChunkHandler::Load(), ORDLChunkHandler::Load(), BKORChunkHandler::Load(), SRNDChunkHandler::Load(), SIGNChunkHandler::Load(), STNSChunkHandler::Load(), STNNChunkHandler::Load(), ROADChunkHandler::Load(), PSACChunkHandler::Load(), STPEChunkHandler::Load(), STPAChunkHandler::Load(), NAMEChunkHandler::Load(), SUBSChunkHandler::Load(), CITYChunkHandler::Load(), VEHSChunkHandler::Load(), CHKPChunkHandler::Load(), PLYRChunkHandler::LoadCheck(), MAPSChunkHandler::LoadCheck(), LoadSettings(), SlLoadCheckChunk(), SlLoadChunk(), and SlSkipArray().
|
static |
Load a chunk of data for checking savegames.
If the chunkhandler is nullptr, the chunk is skipped.
ch | The chunkhandler that will be used for the operation |
Definition at line 2088 of file saveload.cpp.
References _sl, SaveLoadParams::block_mode, CH_TYPE_MASK, SaveLoadParams::expect_table_header, ChunkHandler::LoadCheck(), SaveLoadParams::obj_len, SaveLoadParams::reader, SlErrorCorrupt(), SlIterateArray(), and SlReadByte().
Referenced by SlLoadCheckChunks().
|
static |
Load all chunks for savegame checking.
Definition at line 2213 of file saveload.cpp.
References Debug, SlErrorCorrupt(), SlFindChunkHandler(), and SlLoadCheckChunk().
Referenced by DoLoad().
|
static |
Load a chunk of data (eg vehicles, stations, etc.)
ch | The chunkhandler that will be used for the operation |
Definition at line 2035 of file saveload.cpp.
References _sl, SaveLoadParams::block_mode, CH_TYPE_MASK, SaveLoadParams::expect_table_header, ChunkHandler::Load(), SaveLoadParams::obj_len, SaveLoadParams::reader, SlErrorCorrupt(), SlIterateArray(), and SlReadByte().
Referenced by SlLoadChunks().
|
static |
Load all chunks.
Definition at line 2198 of file saveload.cpp.
References Debug, SlErrorCorrupt(), SlFindChunkHandler(), and SlLoadChunk().
Referenced by DoLoad().
|
static |
Null all pointers (convert index -> nullptr)
Definition at line 296 of file saveload.cpp.
References _sl, _sl_version, SaveLoadParams::action, ChunkHandlers(), Debug, SAVEGAME_VERSION, and SLA_NULL.
Referenced by SlError().
void SlObject | ( | void * | object, |
const SaveLoadTable & | slt | ||
) |
Main SaveLoad function.
object | The object that is being saved or loaded. |
slt | The SaveLoad table with objects to save/load. |
Definition at line 1733 of file saveload.cpp.
References _sl, SaveLoadParams::need_length, NL_CALCLENGTH, NL_NONE, SlCalcObjLength(), and SlSetLength().
Referenced by ERNWChunkHandler::FixPointers(), PLYRChunkHandler::FixPointers(), DEPTChunkHandler::FixPointers(), CAPYChunkHandler::FixPointers(), INDYChunkHandler::FixPointers(), LGRSChunkHandler::FixPointers(), OBJSChunkHandler::FixPointers(), ORDRChunkHandler::FixPointers(), ORDLChunkHandler::FixPointers(), BKORChunkHandler::FixPointers(), STNSChunkHandler::FixPointers(), STNNChunkHandler::FixPointers(), ROADChunkHandler::FixPointers(), CITYChunkHandler::FixPointers(), VEHSChunkHandler::FixPointers(), CHKPChunkHandler::FixPointers(), AIPLChunkHandler::Load(), ERNWChunkHandler::Load(), CMDLChunkHandler::Load(), CMPUChunkHandler::Load(), CAPAChunkHandler::Load(), CHTSChunkHandler::Load(), PLYRChunkHandler::Load(), DEPTChunkHandler::Load(), ECMYChunkHandler::Load(), CAPYChunkHandler::Load(), ENGNChunkHandler::Load(), EIDSChunkHandler::Load(), GSDTChunkHandler::Load(), GSTRChunkHandler::Load(), GOALChunkHandler::Load(), GRPSChunkHandler::Load(), INDYChunkHandler::Load(), ITBLChunkHandler::Load(), RAILChunkHandler::Load(), ROTTChunkHandler::Load(), LEAEChunkHandler::Load(), LEATChunkHandler::Load(), LGRPChunkHandler::Load(), LGRJChunkHandler::Load(), LGRSChunkHandler::Load(), NewGRFMappingChunkHandler::Load(), OBJSChunkHandler::Load(), ORDRChunkHandler::Load(), ORDLChunkHandler::Load(), BKORChunkHandler::Load(), SRNDChunkHandler::Load(), SIGNChunkHandler::Load(), STNSChunkHandler::Load(), STNNChunkHandler::Load(), ROADChunkHandler::Load(), PSACChunkHandler::Load(), STPEChunkHandler::Load(), STPAChunkHandler::Load(), SUBSChunkHandler::Load(), CITYChunkHandler::Load(), VEHSChunkHandler::Load(), CHKPChunkHandler::Load(), ScriptInstance::Load(), SlSkipHandler::Load(), PLYRChunkHandler::LoadCheck(), ScriptInstance::LoadEmpty(), ScriptInstance::LoadObjects(), LoadSettings(), ScriptInstance::Save(), ERNWChunkHandler::Save(), CMDLChunkHandler::Save(), CMPUChunkHandler::Save(), CAPAChunkHandler::Save(), CHTSChunkHandler::Save(), PLYRChunkHandler::Save(), DEPTChunkHandler::Save(), ECMYChunkHandler::Save(), CAPYChunkHandler::Save(), ENGNChunkHandler::Save(), EIDSChunkHandler::Save(), GSTRChunkHandler::Save(), GLOGChunkHandler::Save(), GOALChunkHandler::Save(), GRPSChunkHandler::Save(), INDYChunkHandler::Save(), ITBLChunkHandler::Save(), RAILChunkHandler::Save(), ROTTChunkHandler::Save(), LEAEChunkHandler::Save(), LEATChunkHandler::Save(), LGRPChunkHandler::Save(), LGRJChunkHandler::Save(), LGRSChunkHandler::Save(), NGRFChunkHandler::Save(), NewGRFMappingChunkHandler::Save(), OBJSChunkHandler::Save(), ORDRChunkHandler::Save(), ORDLChunkHandler::Save(), BKORChunkHandler::Save(), SRNDChunkHandler::Save(), SIGNChunkHandler::Save(), STNNChunkHandler::Save(), ROADChunkHandler::Save(), PSACChunkHandler::Save(), STPEChunkHandler::Save(), STPAChunkHandler::Save(), SUBSChunkHandler::Save(), CITYChunkHandler::Save(), VEHSChunkHandler::Save(), ScriptInstance::SaveEmpty(), ScriptInstance::SaveObject(), SaveSettings(), and SlGlobList().
|
static |
Definition at line 1597 of file saveload.cpp.
|
inlinestatic |
Definition at line 534 of file saveload.cpp.
uint8_t SlReadByte | ( | ) |
Wrapper for reading a byte from the buffer.
Definition at line 392 of file saveload.cpp.
References _sl, and SaveLoadParams::reader.
Referenced by STNNChunkHandler::Load(), VEHSChunkHandler::Load(), SlCopyBytes(), SlLoadCheckChunk(), SlLoadChunk(), SlReadSimpleGamma(), SlSaveLoadConv(), and SlSkipBytes().
|
static |
Read in the header descriptor of an object or an array.
If the highest bit is set (7), then the index is bigger than 127 elements, so use the next byte to read in the real value. The actual value is then both bytes added with the first shifted 8 bits to the left, and dropping the highest bit (which only indicated a big index). x = ((x & 0x7F) << 8) + SlReadByte();
Definition at line 452 of file saveload.cpp.
References HasBit(), SlErrorCorrupt(), and SlReadByte().
|
inlinestatic |
Definition at line 524 of file saveload.cpp.
|
inlinestatic |
Definition at line 406 of file saveload.cpp.
|
inlinestatic |
Definition at line 412 of file saveload.cpp.
|
inlinestatic |
Definition at line 418 of file saveload.cpp.
|
static |
Save/Load a list.
list | The list being manipulated. |
conv | VarType type of variable that is used for calculating the size. |
Definition at line 1344 of file saveload.cpp.
References _sl, SaveLoadParams::need_length, NL_CALCLENGTH, NL_NONE, SL_REF, SlCalcRefListLen(), SlStorageHelper< Tstorage, Tvar, Tallocator >::SlSaveLoad(), and SlSetLength().
|
static |
Save/Load a vector.
vector | The vector being manipulated. |
conv | VarType type of variable that is used for calculating the size. |
Definition at line 1371 of file saveload.cpp.
References _sl, SaveLoadParams::need_length, NL_CALCLENGTH, NL_NONE, SL_REF, SlCalcRefVectorLen(), SlStorageHelper< Tstorage, Tvar, Tallocator >::SlSaveLoad(), and SlSetLength().
|
static |
Save a chunk of data (eg.
vehicles, stations, etc.). Each chunk is prefixed by an ID identifying it, followed by data, and terminator where appropriate
ch | The chunkhandler that will be used for the operation |
Definition at line 2139 of file saveload.cpp.
References _sl, SaveLoadParams::block_mode, CH_READONLY, Debug, SaveLoadParams::expect_table_header, ChunkHandler::id, SaveLoadParams::last_array_index, SaveLoadParams::need_length, NL_NONE, NL_WANTLENGTH, ChunkHandler::Save(), SlErrorCorrupt(), SlWriteByte(), and ChunkHandler::type.
Referenced by SlSaveChunks().
|
static |
Save all chunks.
Definition at line 2175 of file saveload.cpp.
References ChunkHandlers(), and SlSaveChunk().
Referenced by DoSave().
|
static |
Handle all conversion and typechecking of variables here.
In the case of saving, read in the actual value from the struct and then write them to file, endian safely. Loading a value goes exactly the opposite way
ptr | The object being filled/read |
conv | VarType type of the current element of the struct |
Definition at line 844 of file saveload.cpp.
References _sl, SaveLoadParams::action, GetVarFileType(), ReadValue(), RemapOldStringID(), SLA_LOAD, SLA_LOAD_CHECK, SLA_NULL, SLA_PTRS, SLA_SAVE, SLE_FILE_STRINGID, SlReadByte(), SlWriteByte(), and WriteValue().
Referenced by SlCopyInternal(), and SlTableHeader().
void SlSaveLoadRef | ( | void * | ptr, |
VarType | conv | ||
) |
Handle conversion for references.
ptr | The object being filled/read. |
conv | VarType type of the current element of the struct. |
Definition at line 1215 of file saveload.cpp.
References _sl, SaveLoadParams::action, IntToReference(), IsSavegameVersionBefore(), ReferenceToInt(), SLA_LOAD, SLA_LOAD_CHECK, SLA_NULL, SLA_PTRS, SLA_SAVE, and SLV_69.
void SlSetArrayIndex | ( | uint | index | ) |
Definition at line 647 of file saveload.cpp.
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
length | The length of the sought object/array |
Definition at line 713 of file saveload.cpp.
References _sl, SaveLoadParams::action, SaveLoadParams::block_mode, SaveLoadParams::expect_table_header, SaveLoadParams::last_array_index, SaveLoadParams::need_length, NL_CALCLENGTH, NL_NONE, NL_WANTLENGTH, SaveLoadParams::obj_len, and SLA_SAVE.
Referenced by MAPTChunkHandler::Save(), MAPHChunkHandler::Save(), MAPOChunkHandler::Save(), MAP2ChunkHandler::Save(), M3LOChunkHandler::Save(), M3HIChunkHandler::Save(), MAP5ChunkHandler::Save(), MAPEChunkHandler::Save(), MAP7ChunkHandler::Save(), MAP8ChunkHandler::Save(), SlAutolength(), SlCopy(), SlObject(), SlRefList(), SlRefVector(), SlSetStructListLength(), and SlTableHeader().
void SlSetStructListLength | ( | size_t | length | ) |
Set the length of this list.
The | length of the list. |
Definition at line 1704 of file saveload.cpp.
References _sl, SaveLoadParams::need_length, NL_CALCLENGTH, NL_NONE, and SlSetLength().
void SlSkipArray | ( | ) |
Skip an array or sparse array.
Definition at line 701 of file saveload.cpp.
References _sl, SaveLoadParams::reader, SlIterateArray(), and SlSkipBytes().
Referenced by WaterRegionChunkHandler::Load(), and ChunkHandler::LoadCheck().
|
static |
Save/Load a std::string
.
ptr | the string being manipulated |
conv | must be SLE_FILE_STRING |
Definition at line 933 of file saveload.cpp.
References _sl, SaveLoadParams::action, FixSCCEncoded(), GetVarMemType(), IsSavegameVersionBefore(), settings, SLA_LOAD, SLA_LOAD_CHECK, SLA_NULL, SLA_PTRS, SLA_SAVE, SlCopyBytes(), SLE_VAR_NULL, SLF_ALLOW_CONTROL, SLF_ALLOW_NEWLINE, SlSkipBytes(), SLV_169, StrMakeValid(), SVS_ALLOW_CONTROL_CODE, SVS_ALLOW_NEWLINE, and SVS_REPLACE_WITH_QUESTION_MARK.
Referenced by SlTableHeader().
std::vector< SaveLoad > SlTableHeader | ( | const SaveLoadTable & | slt | ) |
Save or Load a table header.
slt | The SaveLoad table with objects to save/load. |
Definition at line 1786 of file saveload.cpp.
References _sl, SaveLoadParams::action, SaveLoadParams::block_mode, SaveLoad::cmd, Debug, GetSavegameFileType(), SaveLoad::handler, SaveLoad::name, SaveLoadParams::need_length, NL_CALCLENGTH, NL_NONE, SL_ARR, SL_MAX_VERSION, SL_MIN_VERSION, SL_STDSTR, SL_STRUCT, SL_STRUCTLIST, SL_VAR, SLA_LOAD, SLA_LOAD_CHECK, SLA_SAVE, SlCalcTableHeader(), SLE_FILE_END, SLE_FILE_HAS_LENGTH_FIELD, SLE_FILE_TYPE_MASK, SLE_VAR_NULL, SlErrorCorrupt(), SlIsObjectValidInSavegame(), SlSaveLoadConv(), SlSetLength(), SlStdString(), and SlTableHeader().
Referenced by LEAEChunkHandler::Load(), LEATChunkHandler::Load(), SRNDChunkHandler::Load(), WaterRegionChunkHandler::Load(), ChunkHandler::LoadCheck(), AIPLChunkHandler::Save(), ANITChunkHandler::Save(), ERNWChunkHandler::Save(), CMDLChunkHandler::Save(), CMPUChunkHandler::Save(), CAPAChunkHandler::Save(), CHTSChunkHandler::Save(), PLYRChunkHandler::Save(), DEPTChunkHandler::Save(), ECMYChunkHandler::Save(), CAPYChunkHandler::Save(), ENGNChunkHandler::Save(), EIDSChunkHandler::Save(), GSDTChunkHandler::Save(), GSTRChunkHandler::Save(), GLOGChunkHandler::Save(), GOALChunkHandler::Save(), GRPSChunkHandler::Save(), INDYChunkHandler::Save(), IBLDChunkHandler::Save(), ITBLChunkHandler::Save(), RAILChunkHandler::Save(), ROTTChunkHandler::Save(), LEAEChunkHandler::Save(), LEATChunkHandler::Save(), LGRPChunkHandler::Save(), LGRJChunkHandler::Save(), LGRSChunkHandler::Save(), MAPSChunkHandler::Save(), DATEChunkHandler::Save(), VIEWChunkHandler::Save(), NGRFChunkHandler::Save(), NewGRFMappingChunkHandler::Save(), OBJSChunkHandler::Save(), ORDRChunkHandler::Save(), ORDLChunkHandler::Save(), BKORChunkHandler::Save(), SRNDChunkHandler::Save(), SIGNChunkHandler::Save(), STNNChunkHandler::Save(), ROADChunkHandler::Save(), PSACChunkHandler::Save(), STPEChunkHandler::Save(), STPAChunkHandler::Save(), SUBSChunkHandler::Save(), CITYChunkHandler::Save(), VEHSChunkHandler::Save(), SaveSettings(), SlCompatTableHeader(), and SlTableHeader().
|
static |
Save/load a std::vector.
vector | The std::vector being manipulated |
conv | VarType type of variable that is used for calculating the size |
Definition at line 1473 of file saveload.cpp.
References _sl, SaveLoadParams::action, GetVarMemType(), SL_STDSTR, SLA_SAVE, SLE_VAR_STR, and SlStorageHelper< Tstorage, Tvar, Tallocator >::SlSaveLoad().
|
inlinestatic |
Definition at line 539 of file saveload.cpp.
void SlWriteByte | ( | uint8_t | b | ) |
Wrapper for writing a byte to the dumper.
b | The byte to write. |
Definition at line 401 of file saveload.cpp.
References _sl, and SaveLoadParams::dumper.
Referenced by SlCopyBytes(), SlSaveChunk(), SlSaveLoadConv(), and SlWriteSimpleGamma().
|
static |
Write the header descriptor of an object or an array.
If the element is bigger than 127, use 2 bytes for saving and use the highest byte of the first written one as a notice that the length consists of 2 bytes, etc.. like this: 0xxxxxxx 10xxxxxx xxxxxxxx 110xxxxx xxxxxxxx xxxxxxxx 1110xxxx xxxxxxxx xxxxxxxx xxxxxxxx 11110— xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx We could extend the scheme ad infinum to support arbitrarily large chunks, but as sizeof(size_t) == 4 is still very common we don't support anything above 32 bits. That's why in the last case the 3 most significant bits are unused.
i | Index being written |
Definition at line 494 of file saveload.cpp.
References SlWriteByte().
|
inlinestatic |
Definition at line 529 of file saveload.cpp.
|
inlinestatic |
Definition at line 425 of file saveload.cpp.
|
inlinestatic |
Definition at line 431 of file saveload.cpp.
|
inlinestatic |
Definition at line 437 of file saveload.cpp.
void WaitTillSaved | ( | ) |
Definition at line 2898 of file saveload.cpp.
void WriteValue | ( | void * | ptr, |
VarType | conv, | ||
int64_t | val | ||
) |
Write the value of a setting.
ptr | pointer to the variable |
conv | type of variable, can be a non-clean type, eg with other flags. It is parsed upon read |
val | the new value being given to the variable |
Definition at line 818 of file saveload.cpp.
References CopyFromOldName(), GetVarMemType(), SLE_VAR_NAME, and SLE_VAR_NULL.
Referenced by LoadIntList(), CheatWindow::OnClick(), CheatWindow::OnQueryTextFinished(), SlSaveLoadConv(), and IntSettingDesc::Write().
|
static |
Callback to call when the savegame loading is finished.
Definition at line 358 of file saveload.cpp.
Referenced by ProcessAsyncSaveFinish(), and SetAsyncSaveFinish().
bool _do_autosave |
are we doing an autosave at the moment?
Definition at line 66 of file saveload.cpp.
Referenced by StatusBarWindow::DrawWidget(), and SaveOrLoad().
FileToSaveLoad _file_to_saveload |
File to save or load in the openttd loop.
Definition at line 60 of file saveload.cpp.
Referenced by GenerateLandscape(), InitializeWindowsAndCaches(), SIGNChunkHandler::Load(), LoadTownData(), NetworkRestartMap(), SaveLoadWindow::OnClick(), SaveLoadWindow::OnTimeout(), openttd_main(), and ClientNetworkGameSocketHandler::Receive_SERVER_MAP_DONE().
|
static |
Have a copy of an initialised LZMA stream.
We need this as it's impossible to "re"-assign LZMA_STREAM_INIT to a variable in some compilers, i.e. LZMA_STREAM_INIT can't be used to set something. This var has to be used instead.
Definition at line 2577 of file saveload.cpp.
|
static |
Definition at line 653 of file saveload.cpp.
|
static |
The thread we're using to compress and write a savegame.
Definition at line 359 of file saveload.cpp.
Referenced by DoSave(), and ProcessAsyncSaveFinish().
std::string _savegame_format |
how to compress savegames
Definition at line 65 of file saveload.cpp.
Referenced by SaveFileToDisk().
SavegameType _savegame_type |
type of savegame we are loading
Definition at line 59 of file saveload.cpp.
Referenced by Order::ConvertFromOldSavegame(), CopyFromOldName(), DoLoad(), LoadChunk(), and Gamelog::Oldver().
|
static |
The different saveload formats known/understood by OpenTTD.
Definition at line 2706 of file saveload.cpp.
Referenced by DetermineSaveLoadFormat(), and GetSavegameFormat().
|
static |
Parameters used for/at saveload.
Definition at line 200 of file saveload.cpp.
Referenced by ClearSaveLoadState(), DetermineSaveLoadFormat(), DoLoad(), DoSave(), GetSaveLoadErrorMessage(), GetSaveLoadErrorType(), IntToReference(), ChunkHandler::LoadCheck(), LoadWithFilter(), ReferenceToInt(), SaveFileDone(), SaveFileStart(), SaveFileToDisk(), SaveOrLoad(), SaveWithFilter(), SetSaveLoadError(), SlArray(), SlAutolength(), SlCompatTableHeader(), SlCopy(), SlCopyBytes(), SlCopyInternal(), SlDeque(), SlError(), SlFixPointers(), SlGetFieldLength(), SlIterateArray(), SlLoadCheckChunk(), SlLoadChunk(), SlNullPointers(), SlObject(), SlReadByte(), SlRefList(), SlRefVector(), SlSaveChunk(), SlStorageHelper< Tstorage, Tvar, Tallocator >::SlSaveLoad(), SlSaveLoadConv(), SlSaveLoadRef(), SlSetLength(), SlSetStructListLength(), SlSkipArray(), SlStdString(), SlTableHeader(), SlVector(), and SlWriteByte().
uint8_t _sl_minor_version |
the minor savegame version, DO NOT USE!
Definition at line 64 of file saveload.cpp.
Referenced by DetermineSaveLoadFormat(), IsSavegameVersionBefore(), Gamelog::Oldver(), and SaveOrLoad().
SaveLoadVersion _sl_version |
the major savegame version identifier
Definition at line 63 of file saveload.cpp.
Referenced by DetermineSaveLoadFormat(), DoSave(), IsSavegameVersionBefore(), IsSavegameVersionBeforeOrAt(), Gamelog::Oldver(), LZOLoadFilter::Read(), SaveOrLoad(), SlCopyInternal(), SlIsObjectValidInSavegame(), and SlNullPointers().
uint32_t _ttdp_version |
version of TTDP savegame (if applicable)
Definition at line 62 of file saveload.cpp.
Referenced by Gamelog::Oldver().
|
static |
Buffer size for the LZO compressor.
Definition at line 2322 of file saveload.cpp.
Referenced by LZOLoadFilter::Read(), and LZOSaveFilter::Write().
|
static |
Save in chunks of 128 KiB.
Definition at line 84 of file saveload.cpp.
Referenced by MemoryDumper::Flush(), and MemoryDumper::WriteByte().
|
static |
Definition at line 2703 of file saveload.cpp.
|
static |
Definition at line 2700 of file saveload.cpp.
|
static |
Definition at line 2701 of file saveload.cpp.
|
static |
Definition at line 2702 of file saveload.cpp.