OpenTTD Source: src/saveload/oldloader.h File Reference

OpenTTD Source 15.0-RC2

Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
oldloader.h File Reference

Declarations of structures and functions used in loader of old savegames. More...

`#include "saveload.h"`
`#include "../tile_type.h"`

Go to the source code of this file.

## Data Structures
struct | LoadgameState
struct | OldChunks

## Macros
#define | OCL_SVAR(type, base, offset) { type, 1, nullptr, [] (void *b) -> void * { return std::addressof(static_cast<base *>(b)->offset); }, nullptr }
#define | OCL_VAR(type, amount, pointer) { type, amount, pointer, nullptr, nullptr }
#define | OCL_END() { OC_END, 0, nullptr, nullptr, nullptr }
#define | OCL_CNULL(type, amount) { OC_NULL | type, amount, nullptr, nullptr, nullptr }
#define | OCL_CCHUNK(type, amount, proc) { OC_CHUNK | type, amount, nullptr, nullptr, proc }
#define | OCL_ASSERT(type, size) { OC_ASSERT | type, 1, (void *)(size_t)size, nullptr, nullptr }
#define | OCL_NULL(amount) OCL_CNULL((OldChunkType)0, amount)
#define | OCL_CHUNK(amount, proc) OCL_CCHUNK((OldChunkType)0, amount, proc)

## Typedefs
typedef bool | OldChunkProc(LoadgameState &ls, int num)
typedef void * | OffsetProc(void *base)

## Enumerations
enum | OldChunkType : uint32_t { OC_SIMPLE = 0 , OC_NULL = 1 , OC_CHUNK = 2 , OC_ASSERT = 3 , OC_TTD = 1 << 4 , OC_TTO = 1 << 5 , OC_VAR_I8 = 1 << 8 , OC_VAR_U8 = 2 << 8 , OC_VAR_I16 = 3 << 8 , OC_VAR_U16 = 4 << 8 , OC_VAR_I32 = 5 << 8 , OC_VAR_U32 = 6 << 8 , OC_VAR_I64 = 7 << 8 , OC_VAR_U64 = 8 << 8 , OC_FILE_I8 = 1 << 16 , OC_FILE_U8 = 2 << 16 , OC_FILE_I16 = 3 << 16 , OC_FILE_U16 = 4 << 16 , OC_FILE_I32 = 5 << 16 , OC_FILE_U32 = 6 << 16 , OC_INT8 = OC_VAR_I8 | OC_FILE_I8 , OC_UINT8 = OC_VAR_U8 | OC_FILE_U8 , OC_INT16 = OC_VAR_I16 | OC_FILE_I16 , OC_UINT16 = OC_VAR_U16 | OC_FILE_U16 , OC_INT32 = OC_VAR_I32 | OC_FILE_I32 , OC_UINT32 = OC_VAR_U32 | OC_FILE_U32 , OC_TILE = OC_VAR_U32 | OC_FILE_U16 , OC_END = 0 }

## Functions
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.
bool | LoadTTDMain (LoadgameState &ls)
bool | LoadTTOMain (LoadgameState &ls)
uint16_t | ReadUint16 (LoadgameState &ls)
uint32_t | ReadUint32 (LoadgameState &ls)

## Variables
static const uint | BUFFER_SIZE = 4096
static const uint | OLD_MAP_SIZE = 256
uint | _bump_assert_value

## Detailed Description

Declarations of structures and functions used in loader of old savegames.

Definition in file oldloader.h.

## Macro Definition Documentation

## ◆ OCL_ASSERT

#define OCL_ASSERT | ( |  | type,
|  |  | size
| ) |  | { OC_ASSERT | type, 1, (void *)(size_t)size, nullptr, nullptr }

Definition at line 126 of file oldloader.h.

## ◆ OCL_CCHUNK

#define OCL_CCHUNK | ( |  | type,
|  |  | amount,
|  |  | proc
| ) |  | { OC_CHUNK | type, amount, nullptr, nullptr, proc }

Definition at line 125 of file oldloader.h.

## ◆ OCL_CHUNK

#define OCL_CHUNK | ( |  | amount,
|  |  | proc
| ) |  | OCL_CCHUNK((OldChunkType)0, amount, proc)

Definition at line 128 of file oldloader.h.

## ◆ OCL_CNULL

#define OCL_CNULL | ( |  | type,
|  |  | amount
| ) |  | { OC_NULL | type, amount, nullptr, nullptr, nullptr }

Definition at line 124 of file oldloader.h.

## ◆ OCL_END

#define OCL_END | ( |  | ) | { OC_END, 0, nullptr, nullptr, nullptr }

Definition at line 123 of file oldloader.h.

## ◆ OCL_NULL

#define OCL_NULL | ( |  | amount | ) | OCL_CNULL((OldChunkType)0, amount)

Definition at line 127 of file oldloader.h.

## ◆ OCL_SVAR

#define OCL_SVAR | ( |  | type,
|  |  | base,
|  |  | offset
| ) |  | { type, 1, nullptr, [] (void *b) -> void * { return std::addressof(static_cast<base *>(b)->offset); }, nullptr }

Definition at line 121 of file oldloader.h.

## ◆ OCL_VAR

#define OCL_VAR | ( |  | type,
|  |  | amount,
|  |  | pointer
| ) |  | { type, amount, pointer, nullptr, nullptr }

Definition at line 122 of file oldloader.h.

## Typedef Documentation

## ◆ OffsetProc

typedef void * OffsetProc(void *base)

Definition at line 82 of file oldloader.h.

## ◆ OldChunkProc

typedef bool OldChunkProc(LoadgameState &ls, int num)

Definition at line 81 of file oldloader.h.

## Enumeration Type Documentation

## ◆ OldChunkType

enum OldChunkType : uint32_t

Enumerator
OC_TTD | chunk is valid ONLY for TTD savegames
OC_TTO | -//- TTO (default is neither of these)
OC_END | End of the whole chunk, all 32 bits set to zero.

Definition at line 38 of file oldloader.h.

## Function Documentation

## ◆ LoadChunk()

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

Loads a chunk from the old savegame.

Definition at line 120 of file oldloader.cpp.

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

## ◆ LoadTTDMain()

bool LoadTTDMain | ( | LoadgameState & | ls | ) |

Definition at line 1797 of file oldloader_sl.cpp.

## ◆ LoadTTOMain()

bool LoadTTOMain | ( | LoadgameState & | ls | ) |

Definition at line 1830 of file oldloader_sl.cpp.

## ◆ ReadByte()

uint8_t ReadByte | ( | LoadgameState & | ls | ) |

Reads a byte from the buffer and decompress if needed.

Definition at line 86 of file oldloader.cpp.

References ReadByteFromFile().

Referenced by LoadChunk(), and LoadOldCustomString().

## ◆ ReadUint16()

uint16_t ReadUint16 | ( | LoadgameState & | ls | ) |
| inline

Definition at line 100 of file oldloader.h.

## ◆ ReadUint32()

uint32_t ReadUint32 | ( | LoadgameState & | ls | ) |
| inline

Definition at line 106 of file oldloader.h.

## Variable Documentation

## ◆ _bump_assert_value

uint _bump_assert_value
| extern

Definition at line 28 of file oldloader.cpp.

## ◆ BUFFER_SIZE

const uint BUFFER_SIZE = 4096
| static

Definition at line 16 of file oldloader.h.

## ◆ OLD_MAP_SIZE

const uint OLD_MAP_SIZE = 256
| static

Definition at line 17 of file oldloader.h.