From 0183ed8507fb23d83875b464186e3e267e819918 Mon Sep 17 00:00:00 2001 From: deveee Date: Tue, 8 Oct 2013 19:19:05 +0000 Subject: [PATCH] Explode rubber ball in non-linear world. Accidentally used in debug mode it caused crashes. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@14221 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/items/rubber_ball.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/items/rubber_ball.cpp b/src/items/rubber_ball.cpp index 50eaf038f..ad1dceb17 100644 --- a/src/items/rubber_ball.cpp +++ b/src/items/rubber_ball.cpp @@ -87,6 +87,10 @@ RubberBall::RubberBall(AbstractKart *kart) m_delete_timer = -1.0f; m_tunnel_count = 0; + LinearWorld *world = dynamic_cast(World::getWorld()); + // FIXME: what does the rubber ball do in case of battle mode?? + if(!world) return; + computeTarget(); // initialises the current graph node @@ -141,8 +145,6 @@ void RubberBall::initializeControlPoints(const Vec3 &xyz) void RubberBall::computeTarget() { LinearWorld *world = dynamic_cast(World::getWorld()); - // FIXME: what does the rubber ball do in case of battle mode?? - if(!world) return; for(unsigned int p = race_manager->getFinishedKarts()+1; p < world->getNumKarts()+1; p++) @@ -190,13 +192,11 @@ unsigned int RubberBall::getSuccessorToHitTarget(unsigned int node_index, { int succ = 0; LinearWorld *lin_world = dynamic_cast(World::getWorld()); - // FIXME: what does the rubber ball do in case of battle mode?? - if(lin_world) - { - unsigned int sect = - lin_world->getSectorForKart(m_target); - succ = QuadGraph::get()->getNode(node_index).getSuccessorToReach(sect); - } + + unsigned int sect = + lin_world->getSectorForKart(m_target); + succ = QuadGraph::get()->getNode(node_index).getSuccessorToReach(sect); + if(dist) *dist += QuadGraph::get()->getNode(node_index) .getDistanceToSuccessor(succ); @@ -322,6 +322,10 @@ const core::stringw RubberBall::getHitString(const AbstractKart *kart) const */ bool RubberBall::updateAndDelete(float dt) { + LinearWorld *world = dynamic_cast(World::getWorld()); + // FIXME: what does the rubber ball do in case of battle mode?? + if(!world) return true; + if(m_delete_timer>0) { m_delete_timer -= dt; @@ -629,7 +633,6 @@ float RubberBall::getMaxTerrainHeight(const Vec3 &vertical_offset) const void RubberBall::updateDistanceToTarget() { const LinearWorld *world = dynamic_cast(World::getWorld()); - if(!world) return; // FIXME battle mode float target_distance = world->getDistanceDownTrackForKart(m_target->getWorldKartId());