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,35 +98,55 @@ void StandardRace::endRaceEarly()
|
||||
std::vector<int> active_players;
|
||||
// Required for debugging purposes
|
||||
beginSetKartPositions();
|
||||
float worse_finish_time = 0.0f;
|
||||
|
||||
for (unsigned int i = 1; i <= kart_amount; i++)
|
||||
{
|
||||
int kartid = m_position_index[i-1];
|
||||
AbstractKart* kart = m_karts[kartid];
|
||||
|
||||
if (kart->hasFinishedRace())
|
||||
{
|
||||
if (kart->getFinishTime() > worse_finish_time)
|
||||
worse_finish_time = kart->getFinishTime();
|
||||
|
||||
// Have to do this to keep endSetKartPosition happy
|
||||
setKartPosition(kartid, kart->getPosition());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (kart->getController()->isPlayerController())
|
||||
{
|
||||
// Keep active players apart for now
|
||||
active_players.push_back(kartid);
|
||||
}
|
||||
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
|
||||
else
|
||||
{
|
||||
setKartPosition(kartid, i - (unsigned int) active_players.size());
|
||||
kart->finishedRace(estimateFinishTimeForKart(kart));
|
||||
kart->finishedRace(estimated_finish_time);
|
||||
}
|
||||
}
|
||||
} // i <= kart_amount
|
||||
|
||||
// Now make the active players finish
|
||||
for (unsigned int i = 0; i < active_players.size(); i++)
|
||||
{
|
||||
int kartid = active_players[i];
|
||||
int position = getNumKarts() - (int) active_players.size() + 1 + i;
|
||||
setKartPosition(kartid, position);
|
||||
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
|
||||
endSetKartPositions();
|
||||
|
Loading…
Reference in New Issue
Block a user