diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-02 14:44:32 +0100 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-12-02 14:46:59 +0100 |
| commit | 889d2c0c0933cf2fd9e068b1d2b79eb936b29b58 (patch) | |
| tree | cfc5f5b6e417c28482734645a69e0d49388fa5b3 /src/tile.cpp | |
| parent | 8dbf450e34121358992e48212ae22cb7f5fc92f9 (diff) | |
src, serialize: work on pass mode
1. add one more value to the enum
2. serialize it properly in binary
3. serialize it as string in json
Diffstat (limited to 'src/tile.cpp')
| -rw-r--r-- | src/tile.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/tile.cpp b/src/tile.cpp index b9ed5ab6..419e59a3 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -7,8 +7,9 @@ pass_mode_ref::pass_mode_ref(chunk& c, std::uint8_t i) noexcept : _chunk{&c}, i{ { } -pass_mode_ref& pass_mode_ref::operator=(pass_mode x) noexcept +pass_mode_ref& pass_mode_ref::operator=(pass_mode val) noexcept { + auto x = std::underlying_type_t<pass_mode>(val) & pass_mode_COUNT; auto& bitset = _chunk->_passability; bitset[i*2 + 0] = x & 1; bitset[i*2 + 1] = x >> 1 & 1; @@ -63,15 +64,15 @@ tile_image_proto tile_ref::wall_north() const noexcept { return { _chunk->_wall_ tile_image_proto tile_ref::wall_west() const noexcept { return { _chunk->_wall_atlases[i*2+1], _chunk->_wall_variants[i*2+1] }; } scenery_proto tile_ref::scenery() const noexcept { return { _chunk->_scenery_atlases[i], _chunk->_scenery_variants[i] }; } -pass_mode_ref tile_ref::pass_mode() noexcept { return { *_chunk, i }; } -pass_mode tile_ref::pass_mode() const noexcept { return pass_mode_ref { *const_cast<struct chunk*>(_chunk), i }; } +pass_mode_ref tile_ref::passability() noexcept { return { *_chunk, i }; } +pass_mode tile_ref::passability() const noexcept { return pass_mode_ref { *const_cast<struct chunk*>(_chunk), i }; } tile_ref::operator tile_proto() const noexcept { return { _chunk->_ground_atlases[i], _chunk->_wall_atlases[i*2+0], _chunk->_wall_atlases[i*2+1], _chunk->_scenery_atlases[i], _chunk->_ground_variants[i], _chunk->_wall_variants[i*2+0], _chunk->_wall_variants[i*2+1], _chunk->_scenery_variants[i], - pass_mode(), + passability(), }; } @@ -84,7 +85,7 @@ bool operator==(const tile_ref& a, const tile_ref& b) noexcept a.wall_north() == b.wall_north() && a.wall_west() == b.wall_west() && a.scenery() == b.scenery() && - a.pass_mode() == b.pass_mode(); + a.passability() == b.passability(); } } // namespace floormat |
