Simplify printing time taken for missions.

This removes a lot of lines while at the same time preventing printing a string
onto itself, which is a bug. Problem was found by cppcheck.
This commit is contained in:
Guus Sliepen 2011-08-24 16:01:36 +02:00
parent b9fded8131
commit 943a4c7bf3
2 changed files with 2 additions and 33 deletions

View File

@ -142,23 +142,8 @@ void setStatusLines()
int timeTaken = currentGame.timeTaken;
signed char clock = 0;
while (timeTaken > 3599)
{
clock++;
timeTaken -= 3600;
}
snprintf(string, sizeof string, "Total Time : %2d:%02d:%02d", timeTaken / 3600, (timeTaken / 60) % 60, timeTaken % 60);
sprintf(string, "Total Time : %.2d", clock);
clock = 0;
while (timeTaken > 59)
{
clock++;
timeTaken -= 60;
}
sprintf(string, "%s:%.2d:%.2d", string, clock, timeTaken);
graphics.textSurface(26, string, -1, 0, FONT_WHITE);
graphics.textSurface(27, "Current Status", -1, 0, FONT_WHITE);

View File

@ -871,23 +871,7 @@ void missionFinishedScreen()
currentGame.timeTaken += engine.timeTaken;
signed char clock = 0;
while (engine.timeTaken > 3599)
{
clock++;
engine.timeTaken -= 3600;
}
sprintf(temp, "Mission Time: %.2d", clock);
clock = 0;
while (engine.timeTaken > 59)
{
clock++;
engine.timeTaken -= 60;
}
sprintf(temp, "%s:%.2d:%.2d", temp, clock, engine.timeTaken);
snprintf(temp, sizeof temp, "Mission Time: %2d:%02d:%02d", engine.timeTaken / 3600, (engine.timeTaken / 60) % 60, engine.timeTaken % 60);
graphics.drawString(temp, -1, 500, FONT_WHITE);