OpenTTD Source 20260311-master-g511d3794ce
oldloader.cpp File Reference

Functions for handling of TTO/TTD/TTDP savegames. More...

#include "../stdafx.h"
#include "../debug.h"
#include "../strings_type.h"
#include "../string_func.h"
#include "../settings_type.h"
#include "../fileio_func.h"
#include "saveload_internal.h"
#include "oldloader.h"
#include "table/strings.h"
#include "../safeguards.h"

Go to the source code of this file.

Typedefs

typedef bool LoadOldMainProc(LoadgameState &ls)

Functions

static OldChunkType GetOldChunkType (OldChunkType type)
static OldChunkType GetOldChunkVarType (OldChunkType type)
static OldChunkType GetOldChunkFileType (OldChunkType type)
static uint8_t CalcOldVarLen (OldChunkType type)
 Return expected size in bytes of a OldChunkType.
static uint8_t ReadByteFromFile (LoadgameState &ls)
 Reads a byte from a file (do not call yourself, use ReadByte()).
uint8_t ReadByte (LoadgameState &ls)
 Reads a byte from the buffer and decompress if needed.
bool LoadChunk (LoadgameState &ls, void *base, const OldChunks *chunks)
 Loads a chunk from the old savegame.
static bool VerifyOldNameChecksum (char *title, uint len)
 Verifies the title has a valid checksum.
static std::tuple< SavegameType, std::string > DetermineOldSavegameTypeAndName (FileHandle &f)
bool LoadOldSaveGame (std::string_view file)
std::string GetOldSaveGameName (std::string_view file)

Variables

static const int TTO_HEADER_SIZE = 41
static const int TTD_HEADER_SIZE = 49
static const int HEADER_CHECKSUM_SIZE = 2
 The size of the checksum in the name/header of the TTD/TTO savegames.
uint32_t _bump_assert_value

Detailed Description

Functions for handling of TTO/TTD/TTDP savegames.

Definition in file oldloader.cpp.

Typedef Documentation

◆ LoadOldMainProc

typedef bool LoadOldMainProc(LoadgameState &ls)

Definition at line 234 of file oldloader.cpp.

Function Documentation

◆ CalcOldVarLen()

uint8_t CalcOldVarLen ( OldChunkType type)
inlinestatic

Return expected size in bytes of a OldChunkType.

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

Definition at line 39 of file oldloader.cpp.

Referenced by LoadChunk().

◆ DetermineOldSavegameTypeAndName()

std::tuple< SavegameType, std::string > DetermineOldSavegameTypeAndName ( FileHandle & f)
static

Definition at line 215 of file oldloader.cpp.

◆ GetOldChunkFileType()

OldChunkType GetOldChunkFileType ( OldChunkType type)
inlinestatic

Definition at line 32 of file oldloader.cpp.

◆ GetOldChunkType()

OldChunkType GetOldChunkType ( OldChunkType type)
inlinestatic

Definition at line 30 of file oldloader.cpp.

◆ GetOldChunkVarType()

OldChunkType GetOldChunkVarType ( OldChunkType type)
inlinestatic

Definition at line 31 of file oldloader.cpp.

◆ GetOldSaveGameName()

std::string GetOldSaveGameName ( std::string_view file)

Definition at line 287 of file oldloader.cpp.

◆ LoadChunk()

bool LoadChunk ( LoadgameState & ls,
void * base,
const OldChunks * chunks )

Loads a chunk from the old savegame.

Parameters
lsThe state for loading the save game.
baseThe pointer to the object to load the data into, or nullptr for global objects.
chunksThe definition of the elements to load for this object.
Returns
true if the chunk was loaded without problems.

Definition at line 122 of file oldloader.cpp.

References _savegame_type, CalcOldVarLen(), Debug, GB(), OC_END, OC_TTD, OC_TTO, ReadByte(), SGT_TTO, and OldChunks::type.

Referenced by Vehicle::LoadOldVehicle.

◆ LoadOldSaveGame()

bool LoadOldSaveGame ( std::string_view file)

Definition at line 236 of file oldloader.cpp.

◆ ReadByte()

uint8_t ReadByte ( LoadgameState & ls)

Reads a byte from the buffer and decompress if needed.

Parameters
lsThe state for loading the save game.
Returns
A single byte.

Definition at line 86 of file oldloader.cpp.

References ReadByteFromFile().

Referenced by LoadChunk(), LoadOldCustomString(), and Vehicle::LoadOldVehicle.

◆ ReadByteFromFile()

uint8_t ReadByteFromFile ( LoadgameState & ls)
static

Reads a byte from a file (do not call yourself, use ReadByte()).

Parameters
lsThe state for loading the save game.
Returns
A single byte.

Definition at line 59 of file oldloader.cpp.

References Debug.

Referenced by ReadByte().

◆ VerifyOldNameChecksum()

bool VerifyOldNameChecksum ( char * title,
uint len )
static

Verifies the title has a valid checksum.

Parameters
titletitle and checksum
lenthe length of the title to read/checksum
Returns
true iff the title is valid

Definition at line 199 of file oldloader.cpp.

References HEADER_CHECKSUM_SIZE, and SB().

Variable Documentation

◆ _bump_assert_value

uint32_t _bump_assert_value

Definition at line 28 of file oldloader.cpp.

◆ HEADER_CHECKSUM_SIZE

const int HEADER_CHECKSUM_SIZE = 2
static

The size of the checksum in the name/header of the TTD/TTO savegames.

Definition at line 26 of file oldloader.cpp.

Referenced by VerifyOldNameChecksum().

◆ TTD_HEADER_SIZE

const int TTD_HEADER_SIZE = 49
static

Definition at line 24 of file oldloader.cpp.

◆ TTO_HEADER_SIZE

const int TTO_HEADER_SIZE = 41
static

Definition at line 23 of file oldloader.cpp.