diff options
| author | Mel <einebeere@gmail.com> | 2022-10-21 17:46:35 +0200 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2022-10-21 17:46:35 +0200 |
| commit | 20c53c7473fc6cc08944f502f078dfe57bcae1c9 (patch) | |
| tree | 7e6b09cea68251d4564a363c1a372d6daf746dcf /src/World/ChunkIndex.hpp | |
| parent | 6ed978051668c08f5a957c97570f364dd580c807 (diff) | |
| download | meowcraft-20c53c7473fc6cc08944f502f078dfe57bcae1c9.tar.zst meowcraft-20c53c7473fc6cc08944f502f078dfe57bcae1c9.zip | |
Broken infinite world
Diffstat (limited to 'src/World/ChunkIndex.hpp')
| -rw-r--r-- | src/World/ChunkIndex.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/World/ChunkIndex.hpp b/src/World/ChunkIndex.hpp new file mode 100644 index 0000000..330d202 --- /dev/null +++ b/src/World/ChunkIndex.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include <cstdint> +#include <cstdlib> +#include <functional> + +namespace MC::World { + +struct ChunkIndex { + ChunkIndex(int64_t x, int64_t y) : x(x), y(x) {} + + bool operator==(ChunkIndex& other) const { + return x == other.x && y == other.y; + } + + int64_t x, y; +}; + +} + +template<> struct std::equal_to<MC::World::ChunkIndex> { + bool operator()(const MC::World::ChunkIndex& i1, const MC::World::ChunkIndex& i2) const noexcept { + return i1.x == i2.x && i1.y == i2.y; + } +}; + +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); + } +}; \ No newline at end of file |
