summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-10-10 03:48:18 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-10-10 03:48:18 +0200
commit21356ba6adc4df6d56569d4e659fa5eb1ff180e5 (patch)
tree7c5f664cc9e4886872dd7f792c3e05f8bf4f7971 /src
parentc8c99448c061508a4f40a315c4a71934971e6b54 (diff)
move chunk_coords_ conversion to chunk3() member function
Diffstat (limited to 'src')
-rw-r--r--src/object.cpp4
-rw-r--r--src/path-search-dijkstra.cpp6
-rw-r--r--src/point.cpp2
-rw-r--r--src/world.cpp2
-rw-r--r--src/world.hpp2
5 files changed, 8 insertions, 8 deletions
diff --git a/src/object.cpp b/src/object.cpp
index d5f4087b..ca47df9d 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -188,7 +188,7 @@ bool object::can_move_to(Vector2i delta, global_coords coord2, Vector2b offset,
return false;
auto& w = *c->_world;
- auto& c_ = coord_.chunk() == coord.chunk() ? *c : w[chunk_coords_{coord_}];
+ auto& c_ = coord_.chunk() == coord.chunk() ? *c : w[coord_.chunk3()];
const auto center = Vector2(coord_.local())*TILE_SIZE2 + Vector2(offset_) + Vector2(bbox_offset),
half_bbox = Vector2(bbox_size)*.5f,
@@ -240,7 +240,7 @@ void object::move_to(size_t& i, Vector2i delta, rotation new_r)
}
else
{
- auto& c2 = w[chunk_coords_{coord_}];
+ auto& c2 = w[coord_.chunk3()];
if (!is_dynamic())
c2.mark_scenery_modified();
c2._add_bbox(bb1);
diff --git a/src/path-search-dijkstra.cpp b/src/path-search-dijkstra.cpp
index 69db2442..77c3d8b6 100644
--- a/src/path-search-dijkstra.cpp
+++ b/src/path-search-dijkstra.cpp
@@ -216,7 +216,7 @@ path_search_result astar::Dijkstra(world& w, point from_, point to_, object_id o
{
const auto offset = Vector2b(div_size * Vector2i(x, y));
if (auto bb = bbox_union(start_bbox, from_local, offset, own_size);
- path_search::is_passable(w, chunk_coords_{from}, bb, own_id, p))
+ path_search::is_passable(w, from.chunk3(), bb, own_id, p))
{
indexes[{from, offset}] = idx;
nodes.push_back({.dist = from_offset_len, .prev = 0, .coord = from, .offset = offset});
@@ -288,7 +288,7 @@ path_search_result astar::Dijkstra(world& w, point from_, point to_, object_id o
{ auto vec_ = Vector2(vec);
auto bb1 = bbox<float>{ bb0.min + vec_, bb0.max + vec_ };
auto bb = bbox_union(bb1, bb0);
- if (!path_search::is_passable(w, chunk_coords_(new_coord), bb, own_id, p))
+ if (!path_search::is_passable(w, new_coord.chunk3(), bb, own_id, p))
continue;
}
#else
@@ -300,7 +300,7 @@ path_search_result astar::Dijkstra(world& w, point from_, point to_, object_id o
auto bb1 = bbox<float>{ bb0.min + vec_, bb0.max + vec_ };
auto bb = bbox_union(bb1, bb0);
- if (path_search::is_passable(w, chunk_coords_(new_coord), bb, own_id, p))
+ if (path_search::is_passable(w, new_coord.chunk3(), bb, own_id, p))
status = edge_status::good;
else
{
diff --git a/src/point.cpp b/src/point.cpp
index 55785a61..f21e2d40 100644
--- a/src/point.cpp
+++ b/src/point.cpp
@@ -7,7 +7,7 @@ Debug& operator<<(Debug& dbg, const point& pt)
const auto flags = dbg.flags();
dbg.setFlags(flags | Debug::Flag::NoSpace);
- auto c = Vector3i(chunk_coords_{pt.coord});
+ auto c = Vector3i(pt.coord.chunk3());
auto t = Vector2i(pt.coord.local());
auto o = pt.offset;
diff --git a/src/world.cpp b/src/world.cpp
index 221b98f8..9b19aed4 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -92,7 +92,7 @@ chunk& world::operator[](chunk_coords_ coord) noexcept
auto world::operator[](global_coords pt) noexcept -> pair
{
- auto& c = operator[](chunk_coords_{pt});
+ auto& c = operator[](pt.chunk3());
return { c, c[pt.local()] };
}
diff --git a/src/world.hpp b/src/world.hpp
index 9fa48b8b..cdd1bf7f 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -86,7 +86,7 @@ public:
}
std::shared_ptr<T> make_object(object_id id, global_coords pos, Xs&&... xs)
{
- auto ret = std::shared_ptr<T>(new T{id, operator[](chunk_coords_{pos}), Utility::forward<Xs>(xs)...});
+ auto ret = std::shared_ptr<T>(new T{id, operator[](pos.chunk3()), Utility::forward<Xs>(xs)...});
do_make_object(static_pointer_cast<object>(ret), pos, sorted);
return ret;
}