summaryrefslogtreecommitdiffhomepage
path: root/src/world.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-10 09:04:07 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-10 10:35:00 +0200
commit95b940b807eb213e2e86a32f8f4cc98fd6b13400 (patch)
treec42c9ba29424e56e27ed2b81eecf8c2d07dde910 /src/world.hpp
parent8c2dca2cfaf57f22fe2fe84d939d0071c06ddd6c (diff)
src/world: cleanup & fix hash stuff
Diffstat (limited to 'src/world.hpp')
-rw-r--r--src/world.hpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/world.hpp b/src/world.hpp
index 90067c35..2dce958c 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -4,8 +4,9 @@
#include "global-coords.hpp"
#include "entity-type.hpp"
#include "compat/exception.hpp"
-#include <unordered_map>
+#include "compat/int-hash.hpp"
#include <memory>
+#include <unordered_map>
#include <tsl/robin_map.h>
template<>
@@ -17,6 +18,9 @@ namespace floormat {
struct entity;
template<typename T> struct entity_type_;
+struct object_id_hasher {
+ size_t operator()(object_id id) const noexcept { return int_hash(id); }
+};
struct world final
{
@@ -32,7 +36,7 @@ private:
} _last_chunk;
std::unordered_map<chunk_coords_, chunk> _chunks;
- tsl::robin_map<object_id, std::weak_ptr<entity>> _entities;
+ tsl::robin_map<object_id, std::weak_ptr<entity>, object_id_hasher> _entities;
size_t _last_collection = 0;
size_t _collect_every = 64;
std::shared_ptr<char> _unique_id = std::make_shared<char>('A');