summaryrefslogtreecommitdiffhomepage
path: root/src/entity.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-08 07:57:20 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-08 07:57:20 +0200
commit3e5b43638dac74a88918fecc139b4533bd1c0643 (patch)
treeec17d6ac501a5dea3953ee4dafcafa2980794ff5 /src/entity.cpp
parent85ade98d72850f1db2549f665c4fc51961e1611a (diff)
a
Diffstat (limited to 'src/entity.cpp')
-rw-r--r--src/entity.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/entity.cpp b/src/entity.cpp
index b0d12d12..cf7eb662 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -127,11 +127,14 @@ Pair<global_coords, Vector2b> entity::normalize_coords(global_coords coord, Vect
return { coord, Vector2b(off_new) };
}
-bool entity::can_move_to(Vector2i delta, global_coords coord, Vector2b offset, Vector2b bbox_offset, Vector2ub bbox_size)
+bool entity::can_move_to(Vector2i delta, global_coords coord2, Vector2b offset, Vector2b bbox_offset, Vector2ub bbox_size)
{
- auto [coord_, offset_] = normalize_coords(coord, offset, delta);
+ if (coord2.z() != coord.z()) [[unlikely]]
+ return false;
+
+ auto [coord_, offset_] = normalize_coords(coord2, offset, delta);
auto& w = *c->_world;
- auto& c_ = coord.chunk() == coord_.chunk() ? *c : w[coord_.chunk()];
+ auto& c_ = coord_.chunk() == coord.chunk() ? *c : w[coord_.chunk()];
const auto center = Vector2(coord_.local())*TILE_SIZE2 + Vector2(offset_) + Vector2(bbox_offset),
half_bbox = Vector2(bbox_size)*.5f,