summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/world.cpp9
-rw-r--r--src/world.hpp3
2 files changed, 10 insertions, 2 deletions
diff --git a/src/world.cpp b/src/world.cpp
index cdf8c087..56a0b735 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -94,6 +94,15 @@ auto world::operator[](global_coords pt) noexcept -> pair
return { c, c[pt.local()] };
}
+chunk* world::at(chunk_coords_ c) noexcept
+{
+ auto it = _chunks.find(c);
+ if (it != _chunks.end())
+ return &it->second;
+ else
+ return nullptr;
+}
+
bool world::contains(chunk_coords_ c) const noexcept
{
return _chunks.find(c) != _chunks.cend();
diff --git a/src/world.hpp b/src/world.hpp
index 98fa7f47..47e6b01d 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -7,8 +7,6 @@
#include <unordered_map>
#include <memory>
-namespace floormat { struct chunk_coords_; }
-
template<>
struct std::hash<floormat::chunk_coords_> final {
floormat::size_t operator()(const floormat::chunk_coords_& coord) const noexcept;
@@ -56,6 +54,7 @@ public:
chunk& operator[](chunk_coords_ c) noexcept;
pair operator[](global_coords pt) noexcept;
+ chunk* at(chunk_coords_ c) noexcept;
bool contains(chunk_coords_ c) const noexcept;
void clear();
void collect(bool force = false);