diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-08 07:57:20 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-04-08 07:57:20 +0200 |
commit | 3e5b43638dac74a88918fecc139b4533bd1c0643 (patch) | |
tree | ec17d6ac501a5dea3953ee4dafcafa2980794ff5 /src | |
parent | 85ade98d72850f1db2549f665c4fc51961e1611a (diff) |
a
Diffstat (limited to 'src')
-rw-r--r-- | src/entity.cpp | 9 |
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, |