X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fworld.cpp;h=738fa4ad9b06bb7256f66886bfeca86bd5e3bd2c;hb=1bc2f230105ad6e1ee8d999ddc079cd85d244bf9;hp=b07d05ade64d3788ca8ea953a07ad1f8398ba42b;hpb=f40ef0f5cc3d451c3789112e760719abb393ac03;p=blank.git diff --git a/src/world/world.cpp b/src/world/world.cpp index b07d05a..738fa4a 100644 --- a/src/world/world.cpp +++ b/src/world/world.cpp @@ -340,7 +340,20 @@ World::World(const BlockTypeRegistry &types, const Config &config) } World::~World() { - + for (Entity &e : entities) { + e.Kill(); + } + std::size_t removed = 0; + do { + removed = 0; + for (auto e = entities.begin(), end = entities.end(); e != end; ++e) { + if (e->CanRemove()) { + e = RemoveEntity(e); + end = entities.end(); + ++removed; + } + } + } while (removed > 0 && !entities.empty()); }