summary refs log tree commit diff
path: root/src/World/ChunkRegistry.cpp
diff options
context:
space:
mode:
authorMel <einebeere@gmail.com>2024-02-15 12:32:03 +0100
committerMel <einebeere@gmail.com>2024-02-15 12:32:03 +0100
commit3e6eb265a018fd0422b59ca9ea1b8918abee5c16 (patch)
tree3ae93c50f7b75d7e03a1b5e69157e36a65d99175 /src/World/ChunkRegistry.cpp
parent39d5b006063f27effd4bf96a0a40f02aded7c8f5 (diff)
downloadmeowcraft-3e6eb265a018fd0422b59ca9ea1b8918abee5c16.tar.zst
meowcraft-3e6eb265a018fd0422b59ca9ea1b8918abee5c16.zip
Not every valid block position is within a chunk, `ChunkRegistry::find` should reflect that
Diffstat (limited to 'src/World/ChunkRegistry.cpp')
-rw-r--r--src/World/ChunkRegistry.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/World/ChunkRegistry.cpp b/src/World/ChunkRegistry.cpp
index 97896fe..95ae6bd 100644
--- a/src/World/ChunkRegistry.cpp
+++ b/src/World/ChunkRegistry.cpp
@@ -14,11 +14,12 @@ ChunkRegistry::Data& ChunkRegistry::get(ChunkIndex index) {
     return entry->second;
 }
 
-ChunkRegistry::Data& ChunkRegistry::find(Position::BlockWorld pos) {
-    return get(ChunkIndex::from_position(pos));
+ChunkRegistry::Data* ChunkRegistry::find(Position::BlockWorld pos) {
+    if (!Chunk::is_valid_position(pos.to_local())) return nullptr;
+    return &get(ChunkIndex::from_position(pos));
 }
 
-ChunkRegistry::Data& ChunkRegistry::find(Position::World pos) {
+ChunkRegistry::Data* ChunkRegistry::find(Position::World pos) {
     return find(pos.round_to_block());
 }