diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index e79f26911..e3ef86d53 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -1990,9 +1990,9 @@ void Kart::crashed(const Material *m, const Vec3 &normal) */ void Kart::playCrashSFX(const Material* m, AbstractKart *k) { - if(World::getWorld()->getTime()-m_time_last_crash < 0.5f) return; + if(World::getWorld()->getTimeSinceStart()-m_time_last_crash < 0.5f) return; - m_time_last_crash = World::getWorld()->getTime(); + m_time_last_crash = World::getWorld()->getTimeSinceStart(); // After a collision disable the engine for a short time so that karts // can 'bounce back' a bit (without this the engine force will prevent // karts from bouncing back, they will instead stuck towards the obstable). diff --git a/src/modes/follow_the_leader.cpp b/src/modes/follow_the_leader.cpp index 7b29a8653..626d1260a 100644 --- a/src/modes/follow_the_leader.cpp +++ b/src/modes/follow_the_leader.cpp @@ -113,15 +113,6 @@ const btTransform &FollowTheLeaderRace::getStartTransform(int index) return m_track->getStartTransform(start_index); } // getStartTransform -//----------------------------------------------------------------------------- -/** Returns the original time at which the countdown timer started. This is - * used by the race_gui to display the music credits in FTL mode correctly. - */ -float FollowTheLeaderRace::getClockStartTime() const -{ - return m_leader_intervals[0]; -} // getClockStartTime - //----------------------------------------------------------------------------- /** Called when a kart must be eliminated. */ diff --git a/src/modes/follow_the_leader.hpp b/src/modes/follow_the_leader.hpp index 37e395b8f..dcfaa62be 100644 --- a/src/modes/follow_the_leader.hpp +++ b/src/modes/follow_the_leader.hpp @@ -49,7 +49,6 @@ public: virtual void reset() OVERRIDE; virtual const std::string& getIdent() const OVERRIDE; virtual const btTransform &getStartTransform(int index) OVERRIDE; - virtual float getClockStartTime() const; virtual void getKartsDisplayInfo( std::vector *info) OVERRIDE; virtual void init() OVERRIDE; diff --git a/src/modes/world.cpp b/src/modes/world.cpp index 2cbd03982..413c8d3c5 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -461,6 +461,7 @@ World::~World() race_manager->setRaceGhostKarts(false); race_manager->setRecordRace(false); race_manager->setWatchingReplay(false); + race_manager->setTimeTarget(0.0f); Camera::removeAllCameras(); diff --git a/src/modes/world_status.cpp b/src/modes/world_status.cpp index 880a18175..81e066a0e 100644 --- a/src/modes/world_status.cpp +++ b/src/modes/world_status.cpp @@ -70,7 +70,8 @@ void WorldStatus::reset() { m_time = 0.0f; m_auxiliary_timer = 0.0f; - + m_count_up_timer = 0.0f; + m_engines_started = false; // Using SETUP_PHASE will play the track into sfx first, and has no @@ -340,16 +341,19 @@ void WorldStatus::update(const float dt) { case CLOCK_CHRONO: m_time += dt; + m_count_up_timer += dt; break; case CLOCK_COUNTDOWN: // stop countdown when race is over if (m_phase == RESULT_DISPLAY_PHASE || m_phase == FINISH_PHASE) { m_time = 0.0f; + m_count_up_timer = 0.0f; break; } m_time -= dt; + m_count_up_timer += dt; if(m_time <= 0.0) { diff --git a/src/modes/world_status.hpp b/src/modes/world_status.hpp index 736dcfb6b..0a329d8f9 100644 --- a/src/modes/world_status.hpp +++ b/src/modes/world_status.hpp @@ -114,6 +114,8 @@ private: */ float m_auxiliary_timer; + float m_count_up_timer; + bool m_engines_started; void startEngines(); public: @@ -172,6 +174,10 @@ public: /** Called when the race actually starts. */ virtual void onGo() {}; + // ------------------------------------------------------------------------ + /** Get the time since start regardless of which way the clock counts */ + float getTimeSinceStart() const { return m_count_up_timer; } + }; // WorldStatus diff --git a/src/states_screens/race_gui_base.cpp b/src/states_screens/race_gui_base.cpp index 5d69851e8..03606a355 100644 --- a/src/states_screens/race_gui_base.cpp +++ b/src/states_screens/race_gui_base.cpp @@ -41,7 +41,7 @@ #include "karts/kart_properties.hpp" #include "karts/kart_properties_manager.hpp" #include "karts/rescue_animation.hpp" -#include "modes/follow_the_leader.hpp" +#include "modes/linear_world.hpp" #include "modes/world.hpp" #include "tracks/track.hpp" #include "utils/constants.hpp" @@ -457,15 +457,7 @@ void RaceGUIBase::drawGlobalMusicDescription() gui::IGUIFont* font = GUIEngine::getFont(); - float race_time = World::getWorld()->getTime(); - // In the modes that the clock counts backwards, convert the - // countdown time to time since start: - if(race_manager->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER) - race_time = ((FollowTheLeaderRace*)World::getWorld())->getClockStartTime() - - race_time; - else if (race_manager->getMinorMode()==RaceManager::MINOR_MODE_SOCCER && - race_manager->hasTimeTarget()) - race_time = race_manager->getTimeTarget() - World::getWorld()->getTime(); + float race_time = World::getWorld()->getTimeSinceStart(); // ---- Manage pulsing effect // 3.0 is the duration of ready/set (TODO: don't hardcode)