Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
ChunkBlob.hpp File Reference
#include "../core/Types.hpp"
#include "../core/Reflection.hpp"
#include "TilemapSystem.hpp"
#include <cstring>
#include <vector>
Include dependency graph for ChunkBlob.hpp:

Go to the source code of this file.

Classes

struct  esengine::tilemap::CellEncoding
struct  esengine::tilemap::BlobHeader

Namespaces

namespace  esengine
namespace  esengine::tilemap

Functions

CellEncoding esengine::tilemap::runningEncoding ()
CellEncoding esengine::tilemap::v1Encoding ()
void esengine::tilemap::appendBlobHeader (std::vector< u8 > &out, u32 chunkCount)
bool esengine::tilemap::parseBlobHeader (const u8 *raw, usize size, BlobHeader &out)
bool esengine::tilemap::recodeCell (u16 word, const CellEncoding &from, const CellEncoding &to, u16 &out)
template<class Fn>
bool esengine::tilemap::walkBlobCells (const u8 *raw, usize size, const BlobHeader &header, Fn &&emit)
i32 esengine::tilemap::floorDiv (i32 a, i32 b)
i32 esengine::tilemap::floorMod (i32 a, i32 b)

Variables

static constexpr u32 esengine::tilemap::BLOB_MAGIC_V1 = 0x4D545345
static constexpr u32 esengine::tilemap::BLOB_MAGIC_V2 = 0x50414D54
static constexpr u32 esengine::tilemap::V1_CHUNK_SIZE = 16
static constexpr u16 esengine::tilemap::V1_TILE_ID_MASK = 0x1FFF
static constexpr u16 esengine::tilemap::V1_TILE_FLIP_H = 0x2000
static constexpr u16 esengine::tilemap::V1_TILE_FLIP_V = 0x4000
static constexpr u16 esengine::tilemap::V1_TILE_FLIP_D = 0x8000
constexpr usize esengine::tilemap::BLOB_HEADER_V1_BYTES = sizeof(u32) * 2
constexpr usize esengine::tilemap::BLOB_HEADER_V2_BYTES = sizeof(u32) + sizeof(u16) * 6 + sizeof(u32)

Detailed Description

— the saved form of a painted tilemap, and what it says about the encoding it was written under.

The ABI layout hash pairs a BINARY with a BUNDLE. A saved map is neither: it outlives both, and the cell encoding is not written anywhere in it. Widening the id mask by one bit therefore reads every .esscene ever painted into different tiles — every check passes, the byte layout is unchanged, and only the picture is wrong.

So the blob carries its own encoding, and a reader whose encoding differs REFUSES rather than decoding. The legacy magic has no such header; it means exactly the frozen values below, which is why those are literals and never a reference to the live constants.

Definition in file ChunkBlob.hpp.