diff options
| author | Mel <einebeere@gmail.com> | 2024-02-15 12:32:03 +0100 |
|---|---|---|
| committer | Mel <einebeere@gmail.com> | 2024-02-15 12:32:03 +0100 |
| commit | 3e6eb265a018fd0422b59ca9ea1b8918abee5c16 (patch) | |
| tree | 3ae93c50f7b75d7e03a1b5e69157e36a65d99175 /src/World/ChunkRegistry.cpp | |
| parent | 39d5b006063f27effd4bf96a0a40f02aded7c8f5 (diff) | |
| download | meowcraft-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.cpp | 7 |
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()); } |
