diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index baa0a143..1f0e1440 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -5854,6 +5854,21 @@ std::string Game::timetstring( int t ) return tempstring; } +void Game::timestringcenti(char* buffer, const size_t buffer_size) +{ + /* 16 chars should be plenty for int32s */ + char hours_str[16] = {'\0'}; + if (hours > 0) + { + SDL_snprintf(hours_str, sizeof(hours_str), "%i:", hours); + } + SDL_snprintf( + buffer, buffer_size, + "%s%02i:%02i.%02i", + hours_str, minutes, seconds, frames * 100 / 30 + ); +} + void Game::returnmenu(void) { if (menustack.empty()) diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index 4f517e69..fd0fc103 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -136,6 +136,8 @@ public: std::string timetstring(int t); + void timestringcenti(char* buffer, size_t buffer_size); + void returnmenu(void); void returntomenu(enum Menu::MenuName t); void createmenu(enum Menu::MenuName t, bool samemenu = false); diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 93b03c41..c8b51528 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1743,8 +1743,10 @@ void gamerender(void) if (graphics.fademode==0 && !game.intimetrial && !game.isingamecompletescreen() && (!game.swnmode || game.swngame != 1) && game.showingametimer) { + char buffer[40 + 1]; /* Screen width 40, ASCII only */ graphics.bprint(6, 6, "TIME:", 255,255,255); - graphics.bprint(46, 6, game.timestring(), 196, 196, 196); + game.timestringcenti(buffer, sizeof(buffer)); + graphics.bprint(46, 6, buffer, 196, 196, 196); } if(map.extrarow==0 || (map.custommode && map.roomname!="")) @@ -1952,6 +1954,9 @@ void gamerender(void) } else { + char buffer[40 + 1]; /* Screen width 40, ASCII only */ + game.timestringcenti(buffer, sizeof(buffer)); + //Draw OSD stuff graphics.bprint(6, 18, "TIME :", 255,255,255); graphics.bprint(6, 30, "DEATH:", 255, 255, 255); @@ -1959,11 +1964,11 @@ void gamerender(void) if(game.timetrialparlost) { - graphics.bprint(56, 18, game.timestring(), 196, 80, 80); + graphics.bprint(56, 18, buffer, 196, 80, 80); } else { - graphics.bprint(56, 18, game.timestring(), 196, 196, 196); + graphics.bprint(56, 18, buffer, 196, 196, 196); } if(game.deathcounts>0) {