diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-06 04:12:36 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-06 04:12:40 +0200 |
commit | 89e46a8291cc0de20b20bed18ad4c75948341133 (patch) | |
tree | 0e44412f119a352415c216b91b43aa5faec2e180 | |
parent | f18be9b4686fa11f6fd3caf67396894e38a65d3a (diff) |
editor: fix crash when chunk::_objects array reallocates itself
-rw-r--r-- | editor/update.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/editor/update.cpp b/editor/update.cpp index ce9fa874..52c84d4d 100644 --- a/editor/update.cpp +++ b/editor/update.cpp @@ -238,12 +238,10 @@ void app::update_world(Ns dt) if (!cʹ) continue; auto& c = *cʹ; - const auto& es = c.objects(); -start: auto size = (uint32_t)es.size(); + auto size = (uint32_t)c.objects().size(); for (auto i = 0u; i < size; i++) { - Debug{} << "world::update start"; - auto eʹ = es[i]; + auto& eʹ = c.objects().data()[i]; auto index = size_t{i}; auto& e = *eʹ; if (e.last_frame_no == frame_no) [[unlikely]] @@ -252,12 +250,9 @@ start: auto size = (uint32_t)es.size(); e.update(eʹ, index, dt); // objects can't delete themselves during update() if (&e.chunk() != cʹ || index > i) [[unlikely]] { - Debug{} << "changed" << c.coord() << "to" << e.chunk().coord(); - goto start; + i--; + size = (uint32_t)c.objects().size(); } - else - Debug{} << "unchanged"; - Debug{} << "world::update end"; } } |