Fixed #796 (**:**:** as time), which happens if the race is aborted

before a kart has moved (due to a division by zero). Now 99:59:00
is displayed instead, but in case that there should be other 
circumstances that trigger this problem, use 99:59:99 instead of
**:**:**.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@12055 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2012-11-23 13:13:38 +00:00
parent 701ed00dbc
commit e8900f69e6
2 changed files with 6 additions and 2 deletions

View File

@ -546,6 +546,10 @@ float LinearWorld::estimateFinishTimeForKart(AbstractKart* kart)
// Finish time is the time needed for the whole race with
// the computed average speed computed.
const float average_speed = kart_info.m_overall_distance/getTime();
// Avoid NAN as results when average_speed is low
// Instead just set time to 99:59:00
if(average_speed<0.1f)
return 99*60+59;
return getTime() + (full_distance - kart_info.m_overall_distance)
/ average_speed;

View File

@ -471,8 +471,8 @@ namespace StringUtils
// and an incorrect finishing time is estimated.
if(int_time<0)
return std::string("00:00:00");
else if(int_time >= 10000*60) // up to 9999:59.99
return std::string("**:**:**");
else if(int_time >= 10000*60) // up to 99:59.99
return std::string("99:59:99");
int min = int_time / 6000;
int sec = (int_time-min*6000)/100;