From 20c53c7473fc6cc08944f502f078dfe57bcae1c9 Mon Sep 17 00:00:00 2001 From: Mel Date: Fri, 21 Oct 2022 17:46:35 +0200 Subject: Broken infinite world --- src/World/ChunkIndex.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/World/ChunkIndex.hpp (limited to 'src/World/ChunkIndex.hpp') 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 +#include +#include + +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 { + 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 { + std::size_t operator()(const MC::World::ChunkIndex& i) const noexcept { + std::size_t xh = std::hash{}(i.x); + std::size_t yh = std::hash{}(i.y); + return xh ^ (yh << 1); + } +}; \ No newline at end of file -- cgit 1.4.1