diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-16 09:24:27 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2023-03-17 23:23:11 +0100 |
commit | c699da23c93ce840da2f87749efe0a69c3c37335 (patch) | |
tree | 401465e64f4cb0167985a9727f8574fc10b45756 /src/entity.cpp | |
parent | a1df7c84a5c49adb3b8e8cd3796fd53a02684dd5 (diff) |
a
Diffstat (limited to 'src/entity.cpp')
-rw-r--r-- | src/entity.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/entity.cpp b/src/entity.cpp index e7d2398b..abe53f6d 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -51,9 +51,9 @@ Vector2b entity::ordinal_offset_for_type(entity_type type, Vector2b offset) return offset; default: fm_warn_once("unknown entity type '%zu'", std::size_t(type)); - [[fallthrough]]; - case entity_type::character: return {}; + case entity_type::character: + return { 0, -iTILE_SIZE[1]/4 }; } } @@ -177,7 +177,7 @@ void entity::move(It it, Vector2i delta) if (coord_.chunk() == coord.chunk()) { c._replace_bbox(bb0, bb1, b0, b1); - auto it_ = std::lower_bound(es.cbegin(), es.cend(), e_, [ord](const auto& a, const auto&) { return a->ordinal() < ord; }); + auto it_ = std::lower_bound(es.cbegin(), es.cend(), e_, [=](const auto& a, const auto&) { return a->ordinal() < ord; }); e_->coord = coord_; e_->offset = offset_; auto pos0 = std::distance(es.cbegin(), it), pos1 = std::distance(es.cbegin(), it_); @@ -192,14 +192,15 @@ void entity::move(It it, Vector2i delta) } else { - auto& c2 = w[coord.chunk()]; + auto& c2 = w[coord_.chunk()]; if (!e.is_dynamic()) c2.mark_scenery_modified(false); - c._remove_bbox(bb0); c2._add_bbox(bb1); c.remove_entity(it); - auto it_ = std::lower_bound(c2._entities.cbegin(), c2._entities.cend(), e_, - [ord](const auto& a, const auto&) { return a->ordinal() < ord; }); + const auto& es = c2._entities; + auto it_ = std::lower_bound(es.cbegin(), es.cend(), e_, [=](const auto& a, const auto&) { return a->ordinal() < ord; }); + e_->coord = coord_; + e_->offset = offset_; c2._entities.insert(it_, std::move(e_)); } } |