From 3e5b43638dac74a88918fecc139b4533bd1c0643 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 8 Apr 2023 07:57:20 +0200 Subject: a --- src/entity.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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 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, -- cgit v1.2.3