From 48c1cf880d9370edfc94277258b960e5f69e647b Mon Sep 17 00:00:00 2001 From: Alayan Date: Tue, 26 Feb 2019 16:09:52 +0100 Subject: [PATCH] Fix inconsistency between comment and code --- src/karts/controller/skidding_ai.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/karts/controller/skidding_ai.cpp b/src/karts/controller/skidding_ai.cpp index 5ed5e7116..dd861a1f4 100644 --- a/src/karts/controller/skidding_ai.cpp +++ b/src/karts/controller/skidding_ai.cpp @@ -2231,7 +2231,7 @@ void SkiddingAI::handleNitroAndZipper(float max_safe_speed) { if ((nitro_skill < 4) && (item_skill < 5)) return; - // No sle-if because the nitro_skill and item_skill conditions can happen together + // No else-if because the nitro_skill and item_skill conditions can happen together if (nitro_skill < 4) nitro_skill = 0; if (item_skill < 5) @@ -2263,6 +2263,15 @@ void SkiddingAI::handleNitroAndZipper(float max_safe_speed) // If the AI has a lot of nitro, it should consume it without waiting for some fadeout bool big_reserve = false; + + // If this kart is the last kart, set nitro reserve to be at most 2 + const unsigned int num_karts = m_world->getCurrentNumKarts(); + if(nitro_skill >= 2 && m_kart->getPosition()== (int)num_karts && + num_karts > 1 ) + { + energy_reserve = 2; + } + // Estimate time towards the end of the race. // Decreases the reserve size when there is an estimate of time remaining // to the end of less than 2,5 times the maximum nitro effect duration. @@ -2315,14 +2324,6 @@ void SkiddingAI::handleNitroAndZipper(float max_safe_speed) } } - // If this kart is the last kart, set nitro reserve to 2 - const unsigned int num_karts = m_world->getCurrentNumKarts(); - if(nitro_skill >= 2 && m_kart->getPosition()== (int)num_karts && - num_karts > 1 ) - { - energy_reserve = 0; - } - // TODO : if a kart behind and reasonably close goes faster // and it has a swatter, use nitro to try and dodge the swatter.