Fix inconsistency between comment and code

This commit is contained in:
Alayan 2019-02-26 16:09:52 +01:00
parent bf1d8241e3
commit 48c1cf880d

View File

@ -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.