Display a finish (survival) time in FTL result screen.
This commit is contained in:
parent
d27ba5f6fe
commit
b18d0275fd
@ -53,6 +53,7 @@ FollowTheLeaderRace::FollowTheLeaderRace() : LinearWorld()
|
|||||||
*/
|
*/
|
||||||
void FollowTheLeaderRace::init()
|
void FollowTheLeaderRace::init()
|
||||||
{
|
{
|
||||||
|
m_last_eliminated_time = 0;
|
||||||
LinearWorld::init();
|
LinearWorld::init();
|
||||||
// WorldWithRank determines the score based on getNumKarts(), but since
|
// WorldWithRank determines the score based on getNumKarts(), but since
|
||||||
// we ignore the leader, the points need to be based on number of karts -1
|
// we ignore the leader, the points need to be based on number of karts -1
|
||||||
@ -114,6 +115,7 @@ float FollowTheLeaderRace::getClockStartTime()
|
|||||||
*/
|
*/
|
||||||
void FollowTheLeaderRace::countdownReachedZero()
|
void FollowTheLeaderRace::countdownReachedZero()
|
||||||
{
|
{
|
||||||
|
m_last_eliminated_time += m_leader_intervals[0];
|
||||||
if(m_leader_intervals.size()>1)
|
if(m_leader_intervals.size()>1)
|
||||||
m_leader_intervals.erase(m_leader_intervals.begin());
|
m_leader_intervals.erase(m_leader_intervals.begin());
|
||||||
WorldStatus::setTime(m_leader_intervals[0]);
|
WorldStatus::setTime(m_leader_intervals[0]);
|
||||||
@ -162,7 +164,7 @@ void FollowTheLeaderRace::countdownReachedZero()
|
|||||||
updateRacePosition();
|
updateRacePosition();
|
||||||
}
|
}
|
||||||
// Time doesn't make any sense in FTL (and it is not displayed)
|
// Time doesn't make any sense in FTL (and it is not displayed)
|
||||||
kart->finishedRace(-1.0f);
|
kart->finishedRace(m_last_eliminated_time);
|
||||||
|
|
||||||
// Move any camera for this kart to the leader, facing backwards,
|
// Move any camera for this kart to the leader, facing backwards,
|
||||||
// so that the eliminated player has something to watch.
|
// so that the eliminated player has something to watch.
|
||||||
@ -229,34 +231,31 @@ void FollowTheLeaderRace::terminateRace()
|
|||||||
// position 1, the leader now position 2, but the point distribution
|
// position 1, the leader now position 2, but the point distribution
|
||||||
// depends on the 'first' (non-leader) kart to be on position 2.
|
// depends on the 'first' (non-leader) kart to be on position 2.
|
||||||
// That situation can also occur during the delay after eliminating
|
// That situation can also occur during the delay after eliminating
|
||||||
// the last kart before the race result is shown.
|
// the last kart before the race result is shown (when the leader
|
||||||
// To avoid this problem, adjust the position of any kart that is
|
// is overtaken during that time). To avoid this problem, adjust the
|
||||||
// ahead of the leader.
|
// position of any kart that is ahead of the leader.
|
||||||
beginSetKartPositions();
|
beginSetKartPositions();
|
||||||
for (unsigned int i = 0; i < getNumKarts(); i++)
|
for (unsigned int i = 0; i < getNumKarts(); i++)
|
||||||
{
|
{
|
||||||
if (!m_karts[i]->hasFinishedRace() && !m_karts[i]->isEliminated())
|
if (!m_karts[i]->hasFinishedRace() && !m_karts[i]->isEliminated() &&
|
||||||
|
m_karts[i]->getPosition() < pos_leader)
|
||||||
{
|
{
|
||||||
if (m_karts[i]->getPosition() < pos_leader)
|
setKartPosition(i, m_karts[i]->getPosition() + 1);
|
||||||
{
|
|
||||||
setKartPosition(i, m_karts[i]->getPosition() + 1);
|
|
||||||
}
|
|
||||||
// Update the estimated finishing time for all karts that haven't
|
|
||||||
// finished yet.
|
|
||||||
m_karts[i]->finishedRace(0.0f);
|
|
||||||
}
|
}
|
||||||
} // i < number of karts
|
} // i < number of karts
|
||||||
setKartPosition(/*kart id*/0, /*position*/1);
|
setKartPosition(/*kart id*/0, /*position*/1);
|
||||||
endSetKartPositions();
|
endSetKartPositions();
|
||||||
|
|
||||||
// Mark all still racing karts to be finished.
|
// Mark all still racing karts to be finished.
|
||||||
for (unsigned int n = 0; n < m_karts.size(); n++)
|
for (int i = m_karts.size(); i>0; i--)
|
||||||
{
|
{
|
||||||
if (!m_karts[n]->isEliminated() &&
|
AbstractKart *kart = getKartAtPosition(i);
|
||||||
!m_karts[n]->hasFinishedRace())
|
if (kart->isEliminated() || kart->hasFinishedRace())
|
||||||
{
|
continue;
|
||||||
m_karts[n]->finishedRace(getTime());
|
m_last_eliminated_time += m_leader_intervals[0];
|
||||||
}
|
if (m_leader_intervals.size() > 1)
|
||||||
|
m_leader_intervals.erase(m_leader_intervals.begin());
|
||||||
|
kart->finishedRace(m_last_eliminated_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,6 +33,9 @@ private:
|
|||||||
/** A timer used before terminating the race. */
|
/** A timer used before terminating the race. */
|
||||||
float m_is_over_delay;
|
float m_is_over_delay;
|
||||||
|
|
||||||
|
/** Time the last kart was eliminated. It is used to assign each
|
||||||
|
* kart a 'finish' time (i.e. how long they lasted). */
|
||||||
|
float m_last_eliminated_time;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
FollowTheLeaderRace();
|
FollowTheLeaderRace();
|
||||||
|
@ -468,7 +468,9 @@ void RaceResultGUI::determineTableLayout()
|
|||||||
kart->getKartProperties()->getIconMaterial()->getTexture();
|
kart->getKartProperties()->getIconMaterial()->getTexture();
|
||||||
ri->m_kart_icon = icon;
|
ri->m_kart_icon = icon;
|
||||||
|
|
||||||
if (kart->isEliminated())
|
// FTL karts will get a time assigned, they are not shown as eliminated
|
||||||
|
if (kart->isEliminated() &&
|
||||||
|
race_manager->getMinorMode()!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
||||||
{
|
{
|
||||||
ri->m_finish_time_string = core::stringw(_("Eliminated"));
|
ri->m_finish_time_string = core::stringw(_("Eliminated"));
|
||||||
}
|
}
|
||||||
@ -830,16 +832,19 @@ void RaceResultGUI::determineGPLayout()
|
|||||||
ri->m_player = ri->m_is_player_kart
|
ri->m_player = ri->m_is_player_kart
|
||||||
? kart->getController()->getPlayer() : NULL;
|
? kart->getController()->getPlayer() : NULL;
|
||||||
|
|
||||||
if (!kart->isEliminated())
|
// In FTL karts do have a time, which is shown even when the kart
|
||||||
|
// is eliminated
|
||||||
|
if (kart->isEliminated() &&
|
||||||
|
race_manager->getMinorMode()!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
||||||
|
{
|
||||||
|
ri->m_finish_time_string = core::stringw(_("Eliminated"));
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
float time = race_manager->getOverallTime(kart_id);
|
float time = race_manager->getOverallTime(kart_id);
|
||||||
ri->m_finish_time_string
|
ri->m_finish_time_string
|
||||||
= StringUtils::timeToString(time).c_str();
|
= StringUtils::timeToString(time).c_str();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
ri->m_finish_time_string = core::stringw(_("Eliminated"));
|
|
||||||
}
|
|
||||||
ri->m_start_at = m_time_between_rows * rank;
|
ri->m_start_at = m_time_between_rows * rank;
|
||||||
ri->m_x_pos = (float)UserConfigParams::m_width;
|
ri->m_x_pos = (float)UserConfigParams::m_width;
|
||||||
ri->m_y_pos = (float)(m_top+rank*m_distance_between_rows);
|
ri->m_y_pos = (float)(m_top+rank*m_distance_between_rows);
|
||||||
@ -916,15 +921,10 @@ void RaceResultGUI::displayOneEntry(unsigned int x, unsigned int y,
|
|||||||
current_x += m_width_kart_name + m_width_column_space;
|
current_x += m_width_kart_name + m_width_column_space;
|
||||||
|
|
||||||
|
|
||||||
// Draw the time except in FTL mode
|
core::recti dest_rect = core::recti(current_x, y, current_x + 100, y + 10);
|
||||||
// --------------------------------
|
m_font->draw(ri->m_finish_time_string, dest_rect, color, false, false,
|
||||||
if(race_manager->getMinorMode()!=RaceManager::MINOR_MODE_FOLLOW_LEADER)
|
NULL, true /* ignoreRTL */);
|
||||||
{
|
current_x += m_width_finish_time + m_width_column_space;
|
||||||
core::recti dest_rect = core::recti(current_x, y, current_x+100, y+10);
|
|
||||||
m_font->draw(ri->m_finish_time_string, dest_rect, color, false, false,
|
|
||||||
NULL, true /* ignoreRTL */);
|
|
||||||
current_x += m_width_finish_time + m_width_column_space;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only display points in GP mode and when the GP results are displayed.
|
// Only display points in GP mode and when the GP results are displayed.
|
||||||
// =====================================================================
|
// =====================================================================
|
||||||
|
Loading…
x
Reference in New Issue
Block a user