14#include "../tile_type.h"
16static const uint BUFFER_SIZE = 4096;
17static const uint OLD_MAP_SIZE = 256;
20 std::optional<FileHandle> file;
24 bool decoding =
false;
25 uint8_t decode_char = 0;
27 uint buffer_count = 0;
29 std::array<uint8_t, BUFFER_SIZE> buffer{};
34 std::vector<StringID> vehicle_names;
61 OC_FILE_I16 = 3 << 16,
62 OC_FILE_U16 = 4 << 16,
63 OC_FILE_I32 = 5 << 16,
64 OC_FILE_U32 = 6 << 16,
67 OC_INT8 = OC_VAR_I8 | OC_FILE_I8,
68 OC_UINT8 = OC_VAR_U8 | OC_FILE_U8,
69 OC_INT16 = OC_VAR_I16 | OC_FILE_I16,
70 OC_UINT16 = OC_VAR_U16 | OC_FILE_U16,
71 OC_INT32 = OC_VAR_I32 | OC_FILE_I32,
72 OC_UINT32 = OC_VAR_U32 | OC_FILE_U32,
74 OC_TILE = OC_VAR_U32 | OC_FILE_U16,
82typedef void *OffsetProc(
void *base);
93extern uint _bump_assert_value;
108 uint16_t x = ReadUint16(ls);
109 return x | ReadUint16(ls) << 16;
121#define OCL_SVAR(type, base, offset) { type, 1, nullptr, [] (void *b) -> void * { return std::addressof(static_cast<base *>(b)->offset); }, nullptr }
122#define OCL_VAR(type, amount, pointer) { type, amount, pointer, nullptr, nullptr }
123#define OCL_END() { OC_END, 0, nullptr, nullptr, nullptr }
124#define OCL_CNULL(type, amount) { OC_NULL | type, amount, nullptr, nullptr, nullptr }
125#define OCL_CCHUNK(type, amount, proc) { OC_CHUNK | type, amount, nullptr, nullptr, proc }
126#define OCL_ASSERT(type, size) { OC_ASSERT | type, 1, (void *)(size_t)size, nullptr, nullptr }
127#define OCL_NULL(amount) OCL_CNULL((OldChunkType)0, amount)
128#define OCL_CHUNK(amount, proc) OCL_CCHUNK((OldChunkType)0, amount, proc)
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
@ OC_END
End of the whole chunk, all 32 bits set to zero.
@ OC_TTO
-//- TTO (default is neither of these)
@ OC_TTD
chunk is valid ONLY for TTD savegames
bool LoadChunk(LoadgameState &ls, void *base, const OldChunks *chunks)
Loads a chunk from the old savegame.
uint8_t ReadByte(LoadgameState &ls)
Reads a byte from the buffer and decompress if needed.
Functions/types related to saving and loading games.
uint8_t vehicle_multiplier
TTDPatch vehicle multiplier.
uint32_t amount
Amount of fields.
OldChunkType type
Type of field.
OffsetProc * offset
Pointer to function that returns the actual memory address of a member (ignored if ptr is not nullptr...
void * ptr
Pointer where to save the data (takes precedence over offset)
OldChunkProc * proc
Pointer to function that is called with OC_CHUNK.