From e165a5680bb5f0e41b9809214c6f208f348c452e Mon Sep 17 00:00:00 2001 From: Alayan <25536748+Alayan-stk-2@users.noreply.github.com> Date: Tue, 21 May 2024 15:31:46 +0200 Subject: [PATCH] Fix #4742 --- src/modes/follow_the_leader.cpp | 10 +++++++--- src/modes/follow_the_leader.hpp | 7 ++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/modes/follow_the_leader.cpp b/src/modes/follow_the_leader.cpp index 48990c30f..0a69448c5 100644 --- a/src/modes/follow_the_leader.cpp +++ b/src/modes/follow_the_leader.cpp @@ -47,6 +47,7 @@ FollowTheLeaderRace::FollowTheLeaderRace() : LinearWorld() m_use_highscores = false; // disable high scores setClockMode(WorldStatus::CLOCK_COUNTDOWN, m_leader_intervals[0]); m_is_over_delay = 5.0f; + m_leader_hit_count = 0; } //----------------------------------------------------------------------------- @@ -89,6 +90,7 @@ void FollowTheLeaderRace::reset(bool restart) m_leader_intervals[0]); m_is_over_delay = 2.0f; + m_leader_hit_count = 0; } // reset //----------------------------------------------------------------------------- @@ -122,7 +124,8 @@ const btTransform &FollowTheLeaderRace::getStartTransform(int index) */ void FollowTheLeaderRace::countdownReachedZero() { - m_last_eliminated_time += m_leader_intervals[0]; + m_last_eliminated_time += m_leader_intervals[0] + m_leader_hit_count * LEADER_HIT_TIME; + m_leader_hit_count = 0; // Reset the hit counter if(m_leader_intervals.size()>1) m_leader_intervals.erase(m_leader_intervals.begin()); WorldStatus::setTime(m_leader_intervals[0]); @@ -146,7 +149,7 @@ void FollowTheLeaderRace::countdownReachedZero() { if(UserConfigParams::m_ftl_debug) { - Log::debug("[FTL", "Eliminiating kart '%s' at position %d.", + Log::debug("[FTL", "Eliminating kart '%s' at position %d.", kart->getIdent().c_str(), position_to_remove); } eliminateKart(kart->getWorldKartId()); @@ -227,8 +230,9 @@ bool FollowTheLeaderRace::isRaceOver() void FollowTheLeaderRace::leaderHit() { int countdown = getTimeTicks(); - countdown += stk_config->time2Ticks(5.0f); + countdown += stk_config->time2Ticks(LEADER_HIT_TIME); setTicks(countdown); + m_leader_hit_count++; } // leaderHit //----------------------------------------------------------------------------- diff --git a/src/modes/follow_the_leader.hpp b/src/modes/follow_the_leader.hpp index 498521a73..3eef8c7bb 100644 --- a/src/modes/follow_the_leader.hpp +++ b/src/modes/follow_the_leader.hpp @@ -18,6 +18,8 @@ #ifndef _follow_the_leader_hpp_ #define _follow_the_leader_hpp_ +#define LEADER_HIT_TIME 5.0f + #include "modes/linear_world.hpp" /** @@ -27,9 +29,12 @@ class FollowTheLeaderRace : public LinearWorld { private: - // time till elimination in follow leader + // time till elimination in follow leader std::vector m_leader_intervals; + // Number of rescue/hit endured by the leader since the previous kart elimination + unsigned int m_leader_hit_count; + /** A timer used before terminating the race. */ float m_is_over_delay;