summary refs log tree commit diff
path: root/src/World/ChunkIndex.hpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2022-10-22 00:16:14 +0200
committerMel <einebeere@gmail.com>2022-10-22 00:16:14 +0200
commit7b20942c765334687fd5f58df4c0190601b97b58 (patch)
tree771a9df76abf29b9fd43636584f01e7f6125490c /src/World/ChunkIndex.hpp
parent20c53c7473fc6cc08944f502f078dfe57bcae1c9 (diff)
downloadmeowcraft-7b20942c765334687fd5f58df4c0190601b97b58.tar.zst
meowcraft-7b20942c765334687fd5f58df4c0190601b97b58.zip
Fix chunk index hash to show infinite world
Diffstat (limited to 'src/World/ChunkIndex.hpp')
-rw-r--r--src/World/ChunkIndex.hpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/World/ChunkIndex.hpp b/src/World/ChunkIndex.hpp
index 330d202..cf5af07 100644
--- a/src/World/ChunkIndex.hpp
+++ b/src/World/ChunkIndex.hpp
@@ -7,13 +7,9 @@
 namespace MC::World {
 
 struct ChunkIndex {
-    ChunkIndex(int64_t x, int64_t y) : x(x), y(x) {}
+    ChunkIndex(int32_t x, int32_t y) : x(x), y(y) {}
 
-    bool operator==(ChunkIndex& other) const {
-        return x == other.x && y == other.y;
-    }
-
-    int64_t x, y;
+    int32_t x, y;
 };
 
 }
@@ -25,9 +21,7 @@ template<> struct std::equal_to<MC::World::ChunkIndex> {
 };
 
 template<> struct std::hash<MC::World::ChunkIndex> {
-    std::size_t operator()(const MC::World::ChunkIndex& i) const noexcept {
-        std::size_t xh = std::hash<int64_t>{}(i.x);
-        std::size_t yh = std::hash<int64_t>{}(i.y);
-        return xh ^ (yh << 1);
+    size_t operator()(const MC::World::ChunkIndex& i) const noexcept {
+        return ((int64_t)i.x << 32) | i.y;
     }
 };
\ No newline at end of file