From 280b4c235fe11dd629f882f0fb5054384fcee1d7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 28 Oct 2022 22:10:27 +0200 Subject: more work --- src/tile-image.hpp | 2 +- src/tile.hpp | 2 +- src/world.cpp | 2 +- src/world.hpp | 12 +++++++----- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/tile-image.hpp b/src/tile-image.hpp index deb04e9a..30ae7b0b 100644 --- a/src/tile-image.hpp +++ b/src/tile-image.hpp @@ -10,7 +10,7 @@ struct tile_atlas; struct tile_image final { std::shared_ptr atlas; - std::uint8_t variant = (std::uint8_t)-1; + std::uint16_t variant = (std::uint8_t)-1; explicit operator bool() const noexcept { return !!atlas; } diff --git a/src/tile.hpp b/src/tile.hpp index 5103479d..ef0b1ade 100644 --- a/src/tile.hpp +++ b/src/tile.hpp @@ -12,9 +12,9 @@ struct tile final pass_mode passability = pass_shoot_through; constexpr tile() = default; - tile(tile&&) = default; fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(tile); + fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(tile); }; } //namespace floormat diff --git a/src/world.cpp b/src/world.cpp index cefb2485..39b47db1 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -29,7 +29,7 @@ chunk& world::operator[](chunk_coords coord) noexcept return ret; } -std::tuple world::operator[](global_coords pt) noexcept +auto world::operator[](global_coords pt) noexcept -> pair { auto& c = operator[](pt.chunk()); return { c, c[pt.local()] }; diff --git a/src/world.hpp b/src/world.hpp index fcbb97a2..a18f41f8 100644 --- a/src/world.hpp +++ b/src/world.hpp @@ -1,11 +1,10 @@ #pragma once #include "compat/int-hash.hpp" -#include "global-coords.hpp" -#include "tile.hpp" +#include "compat/integer-types.hpp" #include "chunk.hpp" +#include "global-coords.hpp" #include #include -#include namespace std::filesystem { class path; } @@ -23,21 +22,24 @@ private: }; std::unordered_map _chunks; - mutable std::tuple_last_chunk; + mutable std::tuple _last_chunk; std::size_t _last_collection = 0; explicit world(std::size_t capacity); public: explicit world(); + struct pair final { chunk& c; tile& t; }; // NOLINT(cppcoreguidelines-avoid-const-or-ref-data-members) + template explicit world(std::unordered_map&& chunks); chunk& operator[](chunk_coords c) noexcept; - std::tuple operator[](global_coords pt) noexcept; + pair operator[](global_coords pt) noexcept; bool contains(chunk_coords c) const noexcept; void clear(); void collect(bool force = false); + constexpr std::size_t size() const noexcept { return _chunks.size(); } [[deprecated]] const auto& chunks() const noexcept { return _chunks; } // only for serialization -- cgit v1.2.3