Correct finish time for GPs when skipping a race (#3276)
* Make human players have a correct finish time when skipping a GP race * Don't compute the estimated finish time twice
This commit is contained in:
parent
7cb0ffe844
commit
79e3d298ce
@ -98,36 +98,56 @@ void StandardRace::endRaceEarly()
|
|||||||
std::vector<int> active_players;
|
std::vector<int> active_players;
|
||||||
// Required for debugging purposes
|
// Required for debugging purposes
|
||||||
beginSetKartPositions();
|
beginSetKartPositions();
|
||||||
|
float worse_finish_time = 0.0f;
|
||||||
|
|
||||||
for (unsigned int i = 1; i <= kart_amount; i++)
|
for (unsigned int i = 1; i <= kart_amount; i++)
|
||||||
{
|
{
|
||||||
int kartid = m_position_index[i-1];
|
int kartid = m_position_index[i-1];
|
||||||
AbstractKart* kart = m_karts[kartid];
|
AbstractKart* kart = m_karts[kartid];
|
||||||
|
|
||||||
if (kart->hasFinishedRace())
|
if (kart->hasFinishedRace())
|
||||||
{
|
{
|
||||||
|
if (kart->getFinishTime() > worse_finish_time)
|
||||||
|
worse_finish_time = kart->getFinishTime();
|
||||||
|
|
||||||
// Have to do this to keep endSetKartPosition happy
|
// Have to do this to keep endSetKartPosition happy
|
||||||
setKartPosition(kartid, kart->getPosition());
|
setKartPosition(kartid, kart->getPosition());
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kart->getController()->isPlayerController())
|
|
||||||
{
|
|
||||||
// Keep active players apart for now
|
|
||||||
active_players.push_back(kartid);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
float estimated_finish_time = estimateFinishTimeForKart(kart);
|
||||||
|
if (estimated_finish_time > worse_finish_time)
|
||||||
|
worse_finish_time = estimated_finish_time;
|
||||||
|
|
||||||
|
// Keep active players apart for now
|
||||||
|
if (kart->getController()->isPlayerController())
|
||||||
|
{
|
||||||
|
active_players.push_back(kartid);
|
||||||
|
}
|
||||||
// AI karts finish
|
// AI karts finish
|
||||||
setKartPosition(kartid, i - (unsigned int) active_players.size());
|
else
|
||||||
kart->finishedRace(estimateFinishTimeForKart(kart));
|
{
|
||||||
|
setKartPosition(kartid, i - (unsigned int) active_players.size());
|
||||||
|
kart->finishedRace(estimated_finish_time);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} // i <= kart_amount
|
} // i <= kart_amount
|
||||||
|
|
||||||
// Now make the active players finish
|
// Now make the active players finish
|
||||||
for (unsigned int i = 0; i < active_players.size(); i++)
|
for (unsigned int i = 0; i < active_players.size(); i++)
|
||||||
{
|
{
|
||||||
int kartid = active_players[i];
|
int kartid = active_players[i];
|
||||||
int position = getNumKarts() - (int) active_players.size() + 1 + i;
|
int position = getNumKarts() - (int) active_players.size() + 1 + i;
|
||||||
setKartPosition(kartid, position);
|
setKartPosition(kartid, position);
|
||||||
m_karts[kartid]->eliminate();
|
float punished_time = estimateFinishTimeForKart(m_karts[kartid])
|
||||||
|
+ worse_finish_time - WorldStatus::getTime();
|
||||||
|
m_karts[kartid]->finishedRace(punished_time);
|
||||||
|
|
||||||
|
// In networked races, endRaceEarly will be called if a player
|
||||||
|
// takes too much time to finish, so don't mark him as eliminated
|
||||||
|
if (!isNetworkWorld())
|
||||||
|
m_karts[kartid]->eliminate();
|
||||||
} // Finish the active players
|
} // Finish the active players
|
||||||
endSetKartPositions();
|
endSetKartPositions();
|
||||||
setPhase(RESULT_DISPLAY_PHASE);
|
setPhase(RESULT_DISPLAY_PHASE);
|
||||||
|
Loading…
Reference in New Issue
Block a user