22static uint32_t _map_dim_x;
23static uint32_t _map_dim_y;
75 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
80 for (
auto b : buf)
Tile(i++).type() = b;
86 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
91 for (
auto &b : buf) b =
Tile(i++).type();
102 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
107 for (
auto b : buf)
Tile(i++).height() = b;
113 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
118 for (
auto &b : buf) b =
Tile(i++).height();
129 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
134 for (
auto b : buf)
Tile(i++).m1() = b;
140 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
145 for (
auto &b : buf) b =
Tile(i++).m1();
156 std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
164 for (
auto b : buf)
Tile(i++).m2() = b;
170 std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
173 SlSetLength(
static_cast<uint32_t
>(size) *
sizeof(uint16_t));
175 for (
auto &b : buf) b =
Tile(i++).m2();
186 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
191 for (
auto b : buf)
Tile(i++).m3() = b;
197 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
202 for (
auto &b : buf) b =
Tile(i++).m3();
213 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
218 for (
auto b : buf)
Tile(i++).m4() = b;
224 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
229 for (
auto &b : buf) b =
Tile(i++).m4();
240 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
245 for (
auto b : buf)
Tile(i++).m5() = b;
251 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
256 for (
auto &b : buf) b =
Tile(i++).m5();
275 Tile(i++).m6() =
GB(b, 0, 2);
276 Tile(i++).m6() =
GB(b, 2, 2);
277 Tile(i++).m6() =
GB(b, 4, 2);
278 Tile(i++).m6() =
GB(b, 6, 2);
282 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
285 for (
auto b : buf)
Tile(i++).m6() = b;
292 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
297 for (
auto &b : buf) b =
Tile(i++).m6();
308 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
313 for (
auto b : buf)
Tile(i++).m7() = b;
319 std::array<uint8_t, MAP_SL_BUF_SIZE> buf;
324 for (
auto &b : buf) b =
Tile(i++).m7();
335 std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
340 for (
auto b : buf)
Tile(i++).m8() = b;
346 std::array<uint16_t, MAP_SL_BUF_SIZE> buf;
349 SlSetLength(
static_cast<uint32_t
>(size) *
sizeof(uint16_t));
351 for (
auto &b : buf) b =
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.
static constexpr uint MAP_SL_BUF_SIZE
Buffer size for saving/loading the map array. Sized to the smallest map.
Loading for map chunks before table headers were added.
const SaveLoadCompat _map_sl_compat[]
Original field order for _map_desc.
static const uint MIN_MAP_SIZE
Minimal map size = 64.
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 SLE_GLOBAL_ADDRESS(variable)
Macro to be able to pass the variable type and construct the SaveLoad::AddressFunction given a global...
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.
@ 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.
Functions/types related to errors from savegames.
Definition of base types and functions in a cross-platform compatible way.
ChunkHandler(ChunkId id, ChunkType type)
Create this ChunkHandler.
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 SaveLoad Variable(std::string name, AddressFunction< T > address_func, SaveLoadVersion from=SaveLoadVersion::MinVersion, SaveLoadVersion to=SaveLoadVersion::MaxVersion, size_t extra=0)
Storage of a variable in some savegame versions.
Container of a variable's characteristics about a variable's storage.
static constexpr VarType U16
Store a 16 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.