diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-10 09:04:07 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-10 10:35:00 +0200 |
commit | 95b940b807eb213e2e86a32f8f4cc98fd6b13400 (patch) | |
tree | c42c9ba29424e56e27ed2b81eecf8c2d07dde910 /src/world.hpp | |
parent | 8c2dca2cfaf57f22fe2fe84d939d0071c06ddd6c (diff) |
src/world: cleanup & fix hash stuff
Diffstat (limited to 'src/world.hpp')
-rw-r--r-- | src/world.hpp | 8 |
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'); |