summaryrefslogtreecommitdiffhomepage
path: root/src/entity.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-03-18 13:22:31 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-03-18 13:22:31 +0100
commit2618f4c486848c5e3b080eb77a0c0c143932240e (patch)
tree6f4f106f98f3fc73bc7de6ae7a96322079169dff /src/entity.cpp
parentdb6e21d50d426d0745d844f3166da296a40435e9 (diff)
fix few asserts
Diffstat (limited to 'src/entity.cpp')
-rw-r--r--src/entity.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/entity.cpp b/src/entity.cpp
index 4f0b8807..d06cf52a 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -20,8 +20,11 @@ entity::entity(std::uint64_t id, struct chunk& c, entity_type type, const entity
frame{proto.frame}, type{type}, r{proto.r}, pass{proto.pass}
{
fm_assert(type == proto.type);
- fm_assert(atlas->check_rotation(r));
- fm_assert(frame < atlas->info().nframes);
+ if (atlas)
+ {
+ fm_assert(atlas->check_rotation(r));
+ fm_assert(frame < atlas->info().nframes);
+ }
}
entity::~entity() noexcept
@@ -164,6 +167,7 @@ std::size_t entity::move(std::size_t i, Vector2i delta, rotation new_r)
auto it_ = std::lower_bound(es.cbegin(), es.cend(), e_, [=](const auto& a, const auto&) { return a->ordinal() < ord; });
e_->coord = coord_;
set_bbox_(offset_, bb_offset, bb_size, pass);
+ const_cast<rotation&>(r) = new_r;
auto pos1 = std::distance(es.cbegin(), it_);
if ((std::size_t)pos1 > i)
pos1--;
@@ -189,6 +193,7 @@ std::size_t entity::move(std::size_t i, Vector2i delta, rotation new_r)
auto ret = (std::size_t)std::distance(es.cbegin(), it);
e_->coord = coord_;
set_bbox_(offset_, bb_offset, bb_size, pass);
+ const_cast<rotation&>(r) = new_r;
const_cast<struct chunk*&>(e_->c) = &c2;
es.insert(it, std::move(e_));
return ret;