Fixed crash in case that a race takes more than 100 minutes. Now

a race can take up to 68 days ... good enough I'd say.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5430 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-05-11 13:20:14 +00:00
parent 0628d7f565
commit 9c30a9a77d

View File

@ -341,7 +341,16 @@ namespace StringUtils
int min = (int) floor ( time / 60.0 ) ;
int sec = (int) floor ( time - (double) ( 60 * min ) ) ;
int hundredths = (int) floor ( 100.0f * (time - (double)(sec + 60* min)));
char s[9];
// The proper c++ way would be:
// std::ostringstream s;
// s<<std::setw(2)<<std::setfill(' ')<<min<<":"
// <<std::setw(2)<<std::setfill('0')<<sec<<":"
// <<std::setw(2)<<std::setfill(' ')<<hundredths;
// return s.str();
// but that appears to be awfully complicated and slow, compared to
// which admittedly only works for min < 100000 - which is about 68
// days - good enough.
char s[12];
sprintf ( s, "%02d:%02d:%02d", min, sec, hundredths) ;
return std::string(s);
} // timeToString