diff --git a/src/graphics/slip_stream.cpp b/src/graphics/slip_stream.cpp index be8b1af0d..7c45c9e00 100644 --- a/src/graphics/slip_stream.cpp +++ b/src/graphics/slip_stream.cpp @@ -44,6 +44,7 @@ */ SlipStream::SlipStream(AbstractKart* kart) { + m_speed_increase_ticks = m_speed_increase_duration = -1; m_kart = kart; m_moving = NULL; m_moving_fast = NULL; @@ -215,7 +216,7 @@ void SlipStream::reset() m_slipstream_mode = SS_NONE; m_slipstream_time = 0; m_bonus_time = 0; - + m_speed_increase_ticks = m_speed_increase_duration = -1; // Reset a potential max speed increase m_kart->increaseMaxSpeed(MaxSpeed::MS_INCREASE_SLIPSTREAM, 0, 0, 0, 0); } // reset @@ -827,28 +828,8 @@ void SlipStream::update(int ticks) m_slipstream_time = 0.0f; m_bonus_active = true; - float speed_increase = kp->getSlipstreamMaxSpeedIncrease(); - float add_power = kp->getSlipstreamAddPower(); - int duration = stk_config->time2Ticks(m_bonus_time); - int fade_out = kp->getSlipstreamFadeOutTicks(); - m_kart->instantSpeedIncrease( - MaxSpeed::MS_INCREASE_SLIPSTREAM, speed_increase, - speed_increase, add_power, duration, fade_out); - - if (RewindManager::get()->useLocalEvent()) - { - AbstractKart* kart = m_kart; - RewindManager::get()->addRewindInfoEventFunction(new - RewindInfoEventFunction( - World::getWorld()->getTicksSinceStart(), - [](){}, - [kart, speed_increase, add_power, duration, fade_out]() - { - kart->instantSpeedIncrease( - MaxSpeed::MS_INCREASE_SLIPSTREAM, speed_increase, - speed_increase, add_power, duration, fade_out); - })); - } + m_speed_increase_duration = stk_config->time2Ticks(m_bonus_time); + m_speed_increase_ticks = World::getWorld()->getTicksSinceStart(); } if(!is_sstreaming) @@ -913,3 +894,18 @@ void SlipStream::update(int ticks) #endif m_slipstream_mode = SS_COLLECT; } // update + +// ---------------------------------------------------------------------------- +void SlipStream::updateSpeedIncrease() +{ + if (m_speed_increase_ticks == World::getWorld()->getTicksSinceStart()) + { + const KartProperties* kp = m_kart->getKartProperties(); + float speed_increase = kp->getSlipstreamMaxSpeedIncrease(); + float add_power = kp->getSlipstreamAddPower(); + int fade_out = kp->getSlipstreamFadeOutTicks(); + m_kart->instantSpeedIncrease( + MaxSpeed::MS_INCREASE_SLIPSTREAM, speed_increase, + speed_increase, add_power, m_speed_increase_duration, fade_out); + } +} // updateSpeedIncrease diff --git a/src/graphics/slip_stream.hpp b/src/graphics/slip_stream.hpp index 67452b806..c0f41dc79 100644 --- a/src/graphics/slip_stream.hpp +++ b/src/graphics/slip_stream.hpp @@ -94,7 +94,8 @@ private: int m_current_target_id; int m_previous_target_id; - + int m_speed_increase_ticks; + int m_speed_increase_duration; /** Slipstream mode: either nothing happening, or the kart is collecting * 'slipstream credits'. Credits can be accumulated while the bonus is used */ @@ -121,11 +122,11 @@ private: void updateBonusTexture(); public: SlipStream (AbstractKart* kart); - virtual ~SlipStream (); + ~SlipStream (); void reset(); - virtual void update(int ticks); + void update(int ticks); bool isSlipstreamReady() const; - + void updateSpeedIncrease(); // ------------------------------------------------------------------------ /** Returns the quad in which slipstreaming is effective for * this kart. */ diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index eba18f28e..4308910a4 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -1463,6 +1463,7 @@ void Kart::update(int ticks) if (!RewindManager::get()->isRewinding()) m_slipstream->update(ticks); + m_slipstream->updateSpeedIncrease(); // TODO: hiker said this probably will be moved to btKart or so when updating bullet engine. // Neutralize any yaw change if the kart leaves the ground, so the kart falls more or less