21static uint32_t _map_dim_x;
22static uint32_t _map_dim_y;
29struct MAPSChunkHandler : ChunkHandler {
67static const uint MAP_SL_BUF_SIZE = 4096;
69struct MAPTChunkHandler : ChunkHandler {
74 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
79 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).type() = buf[j];
85 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
90 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).type();
96struct MAPHChunkHandler : ChunkHandler {
101 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
106 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).height() = buf[j];
112 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
117 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).height();
123struct MAPOChunkHandler : ChunkHandler {
128 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
133 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).m1() = buf[j];
139 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
144 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).m1();
150struct MAP2ChunkHandler : ChunkHandler {
155 std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
159 SlCopy(buf.data(), MAP_SL_BUF_SIZE,
163 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).m2() = buf[j];
169 std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
172 SlSetLength(
static_cast<uint32_t
>(size) *
sizeof(uint16_t));
174 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).m2();
180struct M3LOChunkHandler : ChunkHandler {
185 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
190 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).m3() = buf[j];
196 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
201 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).m3();
207struct M3HIChunkHandler : ChunkHandler {
212 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
217 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).m4() = buf[j];
223 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
228 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).m4();
234struct MAP5ChunkHandler : ChunkHandler {
239 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
244 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).m5() = buf[j];
250 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
255 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).m5();
261struct MAPEChunkHandler : ChunkHandler {
266 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
273 for (uint j = 0; j != 1024; j++) {
274 Tile(i++).m6() =
GB(buf[j], 0, 2);
275 Tile(i++).m6() =
GB(buf[j], 2, 2);
276 Tile(i++).m6() =
GB(buf[j], 4, 2);
277 Tile(i++).m6() =
GB(buf[j], 6, 2);
283 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).m6() = buf[j];
290 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
295 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).m6();
301struct MAP7ChunkHandler : ChunkHandler {
306 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
311 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).m7() = buf[j];
317 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
322 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).m7();
328struct MAP8ChunkHandler : ChunkHandler {
333 std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
338 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++)
Tile(i++).m8() = buf[j];
344 std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
347 SlSetLength(
static_cast<uint32_t
>(size) *
sizeof(uint16_t));
349 for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] =
Tile(i++).m8();
Functions related to bit mathematics.
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Declarations for savegames operations.
LoadCheckData _load_check_data
Data loaded from save during SL_LOAD_CHECK.
@ Tile
Destination is a tile.
Functions related to maps.
Loading for map chunks before table headers were added.
const SaveLoadCompat _map_sl_compat[]
Original field order for _map_desc.
A number of safeguards to prevent using unsafe methods.
std::vector< SaveLoad > SlCompatTableHeader(const SaveLoadTable &slt, const SaveLoadCompatTable &slct)
Load a table header in a savegame compatible way.
int SlIterateArray()
Iterate through the elements of an array and read the whole thing.
void SlCopy(void *object, size_t length, VarType conv)
Copy a list of SaveLoadType::Variables to/from a savegame.
void SlErrorCorrupt(const std::string &msg)
Error handler for corrupt savegames.
void SlSetLength(size_t length)
Sets the length of either a RIFF object or the number of items in an array.
std::vector< SaveLoad > SlTableHeader(const SaveLoadTable &slt)
Save or Load a table header.
void SlGlobList(const SaveLoadTable &slt)
Save or Load (a list of) global variables.
Functions/types related to saving and loading games.
@ U16
A 16 bit unsigned int.
@ U8
A 8 bit unsigned int.
#define SLEG_CONDVAR(name, variable, type, from, to)
Storage of a global variable in some savegame versions.
std::reference_wrapper< const ChunkHandler > ChunkHandlerRef
A reference to ChunkHandler.
std::span< const ChunkHandlerRef > ChunkHandlerTable
A table of ChunkHandler entries.
bool IsSavegameVersionBefore(SaveLoadVersion major, uint8_t minor=0)
Checks whether the savegame is below major.
@ BigMap
Saveload version: 5.0, SVN revision: 1429 Making maps a different size than 256x256.
@ MultipleRoadStops
Saveload version: 6.0, SVN revision: 1721 Multi tile road stops, and some map size related fixes.
@ MaxVersion
Highest possible saveload version.
@ RiffToArray
Saveload version: 294, GitHub pull request: 9375 Changed many ChunkType::Riff chunks to ChunkType::A...
@ BridgeWormhole
Saveload version: 42, SVN revision: 7573 Bridges become wormholes, so more things can be built under...
@ Table
An Array with a header describing the elements.
@ Riff
4 bits store the chunk type, 28 bits the number of bytes.
Definition of base types and functions in a cross-platform compatible way.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void Save() const override
Save the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
void LoadCheck(size_t) const override
Load the chunk for game preview.
void Load() const override
Load the chunk.
void Load() const override
Load the chunk.
void Save() const override
Save the chunk.
static uint SizeX()
Get the size of the map along the X.
static uint SizeY()
Get the size of the map along the Y.
static void Allocate(uint size_x, uint size_y)
(Re)allocates a map with the given dimension
static uint Size()
Get the size of the map.
static constexpr VarType U16
Store a 16 bits unsigned int.
static constexpr VarType U8
Store a 8 bits unsigned int.
static constexpr VarType U32
Store a 32 bits unsigned int.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.