summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/tile-image.hpp2
-rw-r--r--src/tile.hpp2
-rw-r--r--src/world.cpp2
-rw-r--r--src/world.hpp12
4 files changed, 10 insertions, 8 deletions
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<tile_atlas> 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<chunk&, tile&> 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 <unordered_map>
#include <memory>
-#include <optional>
namespace std::filesystem { class path; }
@@ -23,21 +22,24 @@ private:
};
std::unordered_map<chunk_coords, chunk, decltype(hasher)> _chunks;
- mutable std::tuple<chunk*, chunk_coords>_last_chunk;
+ mutable std::tuple<chunk*, chunk_coords> _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<typename Hash, typename Alloc, typename Pred>
explicit world(std::unordered_map<chunk_coords, chunk, Hash, Alloc, Pred>&& chunks);
chunk& operator[](chunk_coords c) noexcept;
- std::tuple<chunk&, tile&> 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