diff --git a/src/karts/ghost_kart.cpp b/src/karts/ghost_kart.cpp index 4783bc2a8..0d6d713f5 100644 --- a/src/karts/ghost_kart.cpp +++ b/src/karts/ghost_kart.cpp @@ -69,8 +69,7 @@ void GhostKart::addReplayEvent(float time, for (int i = 0; i < 4; i++) f += m_all_physic_info[0].m_suspension_length[i]; m_graphical_y_offset = -f / 4 + getKartModel()->getLowestPoint(); - m_kart_model - ->setDefaultSuspension(); + m_kart_model->setDefaultSuspension(); } } // addReplayEvent @@ -118,9 +117,7 @@ void GhostKart::update(float dt) setXYZ((1-f)*m_all_transform[m_current_transform ].getOrigin() + f *m_all_transform[m_current_transform+1].getOrigin() ); const btQuaternion q = m_all_transform[m_current_transform].getRotation() - .slerp(m_all_transform[m_current_transform+1] - .getRotation(), - f); + .slerp(m_all_transform[m_current_transform+1].getRotation(), f); setRotation(q); Vec3 center_shift(0, 0, 0); diff --git a/src/karts/ghost_kart.hpp b/src/karts/ghost_kart.hpp index 30333963f..dc8f6056c 100644 --- a/src/karts/ghost_kart.hpp +++ b/src/karts/ghost_kart.hpp @@ -37,47 +37,52 @@ class GhostKart : public Kart { private: /** The list of the times at which the transform were reached. */ - std::vector m_all_times; + std::vector m_all_times; /** The transforms to assume at the corresponding time in m_all_times. */ - std::vector m_all_transform; + std::vector m_all_transform; - std::vector m_all_physic_info; + std::vector m_all_physic_info; std::vector m_all_replay_events; /** Pointer to the last index in m_all_times that is smaller than * the current world time. */ - unsigned int m_current_transform; + unsigned int m_current_transform; public: - GhostKart(const std::string& ident, - unsigned int world_kart_id, int position); - virtual void update (float dt); - virtual void reset(); + GhostKart(const std::string& ident, + unsigned int world_kart_id, int position); + virtual void update (float dt); + virtual void reset(); // ------------------------------------------------------------------------ /** No physics body for ghost kart, so nothing to adjust. */ - virtual void updateWeight() {}; + virtual void updateWeight() {}; // ------------------------------------------------------------------------ /** No physics for ghost kart. */ - virtual void applyEngineForce (float force) {} + virtual void applyEngineForce (float force) {} // ------------------------------------------------------------------------ // Not needed to create any physics for a ghost kart. - virtual void createPhysics() {} + virtual void createPhysics() {} // ------------------------------------------------------------------------ - const float getSuspensionLength(int index, int wheel) const + const float getSuspensionLength(int index, int wheel) const { return m_all_physic_info[index].m_suspension_length[wheel]; } // ------------------------------------------------------------------------ - void addReplayEvent(float time, - const btTransform &trans, - const ReplayBase::PhysicInfo &pi, - const ReplayBase::KartReplayEvent &kre); + void addReplayEvent(float time, + const btTransform &trans, + const ReplayBase::PhysicInfo &pi, + const ReplayBase::KartReplayEvent &kre); // ------------------------------------------------------------------------ /** Returns whether this kart is a ghost (replay) kart. */ - virtual bool isGhostKart() const { return true; } + virtual bool isGhostKart() const { return true; } // ------------------------------------------------------------------------ /** Ghost can't be hunted. */ - virtual bool isInvulnerable() const { return true; } + virtual bool isInvulnerable() const { return true; } + // ------------------------------------------------------------------------ + /** Returns the speed of the kart in meters/second. */ + virtual float getSpeed() const + { return m_all_physic_info[m_current_transform].m_speed; } + // ------------------------------------------------------------------------ }; // GhostKart #endif diff --git a/src/modes/linear_world.cpp b/src/modes/linear_world.cpp index 9dbab415f..c3ae1e4fd 100644 --- a/src/modes/linear_world.cpp +++ b/src/modes/linear_world.cpp @@ -262,11 +262,16 @@ void LinearWorld::newLap(unsigned int kart_index) // the race crosses the start line again. This avoids 'fastest lap' // messages if the end controller does a fastest lap, but especially // allows the end controller to switch end cameras - if(kart->hasFinishedRace() && !is_gk) + if (!is_gk) { - kart->getController()->newLap(kart_info.m_race_lap); - return; + if (kart->hasFinishedRace()) + { + kart->getController()->newLap(kart_info.m_race_lap); + return; + } } + else if (kart->hasFinishedRace()) + return; const int lap_count = race_manager->getNumLaps();