diff --git a/src/Game.cpp b/src/Game.cpp index 7139839..710434f 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -139,7 +139,6 @@ Game::loop() { // Respawn player at start position on death. if (mPlayer->getHealth() <= 0) { Vector2f pos = mPlayer->getCrosshairPosition(); - mWorld.remove(mPlayer); initPlayer(); mPlayer->setCrosshairPosition(pos); } diff --git a/src/World.cpp b/src/World.cpp index 3c6652f..9fcb58a 100755 --- a/src/World.cpp +++ b/src/World.cpp @@ -19,7 +19,7 @@ */ void World::insert(std::shared_ptr drawable) { -#ifndef NDEBUG +#ifndef RELEASE Sprite::Category cat = drawable->getCategory(); auto item = std::find(mDrawables[cat].begin(), mDrawables[cat].end(), drawable); assert(item == mDrawables[cat].end()); @@ -33,7 +33,7 @@ World::insert(std::shared_ptr drawable) { */ void World::insertCharacter(std::shared_ptr character) { -#ifndef NDEBUG +#ifndef RELEASE auto item = std::find(mCharacters.begin(), mCharacters.end(), character); assert(item == mCharacters.end()); #endif @@ -52,7 +52,7 @@ World::remove(std::shared_ptr drawable) { * Returns all characters that are within maxDistance from position. */ std::vector > - World::getCharacters(const Vector2f& position, float maxDistance) const { +World::getCharacters(const Vector2f& position, float maxDistance) const { std::vector > visible; for (const auto& it : mCharacters) { if (position == it->getPosition()) @@ -123,8 +123,7 @@ World::think(int elapsed) { for (auto it = mCharacters.begin(); it != mCharacters.end(); ) { if ((*it)->getDelete()) { mCharacters.erase(it); - auto& d = mDrawables[Sprite::CATEGORY_ACTOR]; - d.erase(std::find(d.begin(), d.end(), *it)); + remove(*it); } else { (*it)->onThink(elapsed);