Fix crash sound only working once if the timer counts backwards
This commit is contained in:
parent
b2a62c222c
commit
b903baf226
@ -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).
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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<RaceGUIBase::KartIconDisplayInfo> *info) OVERRIDE;
|
||||
virtual void init() OVERRIDE;
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user