X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fchunk.cpp;fp=src%2Fworld%2Fchunk.cpp;h=60ece9a83451673a1d928d561795e529b394749b;hb=da21395e4900bf283ece7364c67d9bad27dca279;hp=e93966e959ce13d4678dfaa3f5870ffcade50e17;hpb=642b09d8e887f53d36566da886903b479f94f2ef;p=blank.git diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index e93966e..60ece9a 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -1075,7 +1075,7 @@ ChunkIndex *ChunkStore::ClosestIndex(const ExactLocation::Coarse &pos) { return closest_index; } -Chunk *ChunkStore::Get(const ExactLocation::Coarse &pos) { +Chunk *ChunkStore::Get(const ExactLocation::Coarse &pos) noexcept { for (ChunkIndex &index : indices) { Chunk *chunk = index.Get(pos); if (chunk) { @@ -1085,6 +1085,16 @@ Chunk *ChunkStore::Get(const ExactLocation::Coarse &pos) { return nullptr; } +const Chunk *ChunkStore::Get(const ExactLocation::Coarse &pos) const noexcept { + for (const ChunkIndex &index : indices) { + const Chunk *chunk = index.Get(pos); + if (chunk) { + return chunk; + } + } + return nullptr; +} + Chunk *ChunkStore::Allocate(const ExactLocation::Coarse &pos) { Chunk *chunk = Get(pos); if (chunk) {