summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-22 10:29:03 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-22 10:29:03 +0200
commitf1330bf596b045131ba2906e0b99646835257456 (patch)
treee0a5a583dae55703df793e768ca2c0da49da24f0
parentd18a02d38f86d44e1825619a84cd01dcd5f28cf6 (diff)
more dumb crap
-rw-r--r--main/editor.hpp6
-rw-r--r--src/world.hpp7
2 files changed, 6 insertions, 7 deletions
diff --git a/main/editor.hpp b/main/editor.hpp
index a308c437..c156d0b9 100644
--- a/main/editor.hpp
+++ b/main/editor.hpp
@@ -25,12 +25,10 @@ struct tile_type final
tile_type(editor_mode mode, Containers::StringView name);
std::shared_ptr<tile_atlas> maybe_atlas(Containers::StringView str);
std::shared_ptr<tile_atlas> atlas(Containers::StringView str);
- auto begin() & { return _atlases.begin(); }
- auto end() & { return _atlases.end(); }
- auto begin() const&& { return _atlases.cbegin(); }
- auto end() const&& { return _atlases.cend(); }
auto cbegin() const { return _atlases.cbegin(); }
auto cend() const { return _atlases.cend(); }
+ auto begin() const { return _atlases.cbegin(); }
+ auto end() const { return _atlases.cend(); }
Containers::StringView name() const { return _name; }
editor_mode mode() const { return _mode; }
diff --git a/src/world.hpp b/src/world.hpp
index 89bc4feb..6321606e 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -12,13 +12,13 @@ struct chunk;
struct world final
{
- world();
std::shared_ptr<chunk> operator[](chunk_coords c) noexcept;
std::tuple<std::shared_ptr<chunk>, tile&> operator[](global_coords pt) noexcept;
bool contains(chunk_coords c) const noexcept;
void clear();
void collect();
+ world();
fm_DECLARE_DELETED_COPY_ASSIGNMENT(world);
private:
@@ -26,13 +26,14 @@ private:
static constexpr std::size_t initial_capacity = 64, collect_every = 32;
static constexpr float max_load_factor = .5;
- static constexpr auto hasher = [](chunk_coords c) -> std::size_t {
+ static constexpr auto hasher = [](chunk_coords c) constexpr -> std::size_t {
return int_hash((std::size_t)c.y << 16 | (std::size_t)c.x);
};
std::size_t _last_collection = 0;
- mutable std::optional<std::tuple<std::shared_ptr<chunk>, chunk_coords>> _last_chunk;
+
std::unordered_map<chunk_coords, std::shared_ptr<chunk>, decltype(hasher)> _chunks{initial_capacity, hasher};
+ mutable std::optional<std::tuple<std::shared_ptr<chunk>, chunk_coords>> _last_chunk;
};
} // namespace floormat