OpenTTD Source  20240919-master-gdf0233f4c2
oldloader.h File Reference
#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 {
  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_DEREFERENCE_POINTER = 1 << 31,
  OC_END = 0
}
 

Functions

uint8_t ReadByte (LoadgameState *ls)
 Reads a byte from the buffer and decompress if needed. More...
 
bool LoadChunk (LoadgameState *ls, void *base, const OldChunks *chunks)
 Loads a chunk from the old savegame. More...
 
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 strctures and function used in loader of old savegames

Definition in file oldloader.h.

Enumeration Type Documentation

◆ OldChunkType

Enumerator
OC_TTD 

chunk is valid ONLY for TTD savegames

OC_TTO 

-//- TTO (default is neither of these)

OC_DEREFERENCE_POINTER 

Dereference the pointer once before writing to it, so we do not have to use big static arrays.

OC_END 

End of the whole chunk, all 32 bits set to zero.

Definition at line 35 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 122 of file oldloader.cpp.

References _savegame_type, OC_DEREFERENCE_POINTER, OC_END, OC_TTD, OC_TTO, SGT_TTO, and OldChunks::type.

◆ ReadByte()

uint8_t ReadByte ( LoadgameState ls)

Reads a byte from the buffer and decompress if needed.

Definition at line 88 of file oldloader.cpp.

References ReadByteFromFile().