From 1d11a1fac9aa62062b80fc5f5ef9484443208ce3 Mon Sep 17 00:00:00 2001 From: hikerstk <hikerstk@178a84e3-b1eb-0310-8ba1-8eac791a3b58> Date: Tue, 12 Feb 2008 00:10:05 +0000 Subject: [PATCH] Bugfix: when a restart is triggered while a kart is being rescued, this kart could not be driven anymore (till it was rescued again). git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1460 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/kart.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/kart.cpp b/src/kart.cpp index c104e1b2c..6e0f260a6 100644 --- a/src/kart.cpp +++ b/src/kart.cpp @@ -150,13 +150,19 @@ Kart::Kart (const KartProperties* kartProperties_, int position_ , m_max_speed_reverse_ratio = m_kart_properties->getMaxSpeedReverseRatio(); m_speed = 0.0f; - m_wheel_rotation = 0; + // Setting rescue to false is important! If rescue is set when reset() is + // called, it is assumed that this was triggered by a restart, and that + // the vehicle must be added back to the physics world. Since reset() is + // also called at the very start, it must be guaranteed that rescue is + // not set. + m_rescue = false; + m_wheel_rotation = 0; - m_wheel_front_l = NULL; - m_wheel_front_r = NULL; - m_wheel_rear_l = NULL; - m_wheel_rear_r = NULL; - m_lap_start_time = -1.0f; + m_wheel_front_l = NULL; + m_wheel_front_r = NULL; + m_wheel_rear_l = NULL; + m_wheel_rear_r = NULL; + m_lap_start_time = -1.0f; loadData(); } // Kart @@ -345,7 +351,6 @@ void Kart::reset() m_finished_race = false; m_finish_time = 0.0f; m_zipper_time_left = 0.0f; - m_rescue = false; m_num_herrings_gobbled = 0; m_wheel_rotation = 0; m_wheelie_angle = 0.0f; @@ -396,6 +401,14 @@ void Kart::reset() m_vehicle->updateWheelTransform(j, true); } + // if the kart was being rescued when a restart is called, + // add the vehicle back into the physical world! + if(m_rescue) + { + world->getPhysics()->addKart(this, m_vehicle); + } + m_rescue = false; + placeModel(); TerrainInfo::update(m_transform.getOrigin()); } // reset