From e22daa10d55c26f15a170ab76645e656e956901c Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Tue, 28 Nov 2017 19:30:07 +0100 Subject: [PATCH] fix creature iteration --- src/world/world.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/world/world.cpp b/src/world/world.cpp index 19f6f4a..eee1283 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -138,11 +138,15 @@ glm::dmat4 Body::FromUniverse() const noexcept { return m; } +namespace { +std::vector ccache; +} + void Body::Tick(double dt) { rotation += dt * AngularMomentum() / Inertia(); Cache(); - for (creature::Creature *c : Creatures()) { - // TODO: this is self modifying, fix it fix it fix it + ccache = Creatures(); + for (creature::Creature *c : ccache) { c->Tick(dt); } for (auto c = Creatures().begin(); c != Creatures().end();) { -- 2.39.2