From: Ingo Ruhnke Date: Wed, 28 Apr 2004 20:28:38 +0000 (+0000) Subject: - replaced evil cast with std::find X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=b672a3164e372bc663f207a31b94b4ba329e5e95;p=supertux.git - replaced evil cast with std::find SVN-Revision: 818 --- diff --git a/src/gameobjs.cpp b/src/gameobjs.cpp index aaf6319f2..d185556af 100644 --- a/src/gameobjs.cpp +++ b/src/gameobjs.cpp @@ -79,7 +79,12 @@ BrokenBrick::action(double frame_ratio) if (!timer.check()) { - World::current()->broken_bricks.erase(static_cast::iterator>(this)); + std::vector::iterator i + = std::find(World::current()->broken_bricks.begin(), + World::current()->broken_bricks.end(), + this); + if (i != World::current()->broken_bricks.end()) + World::current()->broken_bricks.erase(i); } } @@ -123,7 +128,14 @@ BouncyBrick::action(double frame_ratio) /* Stop bouncing? */ if (offset >= 0) - World::current()->bouncy_bricks.erase(static_cast::iterator>(this)); + { + std::vector::iterator i + = std::find(World::current()->bouncy_bricks.begin(), + World::current()->bouncy_bricks.end(), + this); + if (i != World::current()->bouncy_bricks.end()) + World::current()->bouncy_bricks.erase(i); + } } void @@ -179,7 +191,14 @@ FloatingScore::action(double frame_ratio) base.y = base.y - 2 * frame_ratio; if(!timer.check()) - World::current()->floating_scores.erase(static_cast::iterator>(this)); + { + std::vector::iterator i + = std::find(World::current()->floating_scores.begin(), + World::current()->floating_scores.end(), + this); + if (i != World::current()->floating_scores.end()) + World::current()->floating_scores.erase(i); + } } void