From: RĂ©mi Verschelde Date: Sat, 10 Dec 2016 12:55:38 +0000 (+0100) Subject: Fix 7s offset between shown challenge time and high score X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=96f10b742814fab1d16e3fa704160773c3381795;p=lugaru.git Fix 7s offset between shown challenge time and high score Also properly rounds the float time so that 26.89s does not end up as 26 but 27. --- diff --git a/Source/Game.cpp b/Source/Game.cpp index e0aeeda..39b7df7 100644 --- a/Source/Game.cpp +++ b/Source/Game.cpp @@ -67,7 +67,9 @@ bool firstload = 0; Texture hawktexture; float hawkyaw = 0; float hawkcalldelay = 0; + float leveltime = 0; +float wonleveltime = 0; float loadtime = 0; Model hawk; diff --git a/Source/Game.h b/Source/Game.h index 43f256e..68a23a3 100644 --- a/Source/Game.h +++ b/Source/Game.h @@ -76,6 +76,7 @@ extern bool cameramode; extern bool firstload; extern float leveltime; +extern float wonleveltime; extern float loadtime; extern Model hawk; diff --git a/Source/GameDraw.cpp b/Source/GameDraw.cpp index 7ee322e..a0c92d5 100644 --- a/Source/GameDraw.cpp +++ b/Source/GameDraw.cpp @@ -1610,21 +1610,19 @@ int Game::DrawGLScene(StereoSide side) sprintf (string, "Score: %d", (int)(bonustotal - startbonustotal)); text->glPrintOutlined(1024 / 30, 768 * 6 / 8, string, 1, 2, 1024, 768); - if (campaign) - sprintf (string, "Press Escape or Space to continue"); - else - sprintf (string, "Press Escape to return to menu or Space to continue"); + sprintf (string, "Press Escape to return to menu or Space to continue"); text->glPrintOutlined(640 / 2 - strlen(string) * 5, 480 * 1 / 16, string, 1, 1, 640, 480); char temp[255]; for (int i = 0; i < 255; i++) string[i] = '\0'; - sprintf (temp, "Time: %d:", (int)(((int)leveltime - (int)(leveltime) % 60) / 60)); + int wontime = (int)round(wonleveltime); + sprintf (temp, "Time: %d:", int((wontime - wontime % 60) / 60)); strcat(string, temp); - if ((int)(leveltime) % 60 < 10) + if (wontime % 60 < 10) strcat(string, "0"); - sprintf (temp, "%d", (int)(leveltime) % 60); + sprintf (temp, "%d", wontime % 60); strcat(string, temp); text->glPrintOutlined(1024 / 30, 768 * 6 / 8 - 40, string, 1, 2, 1024, 768); diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 1dfebb2..1a84485 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -1105,6 +1105,7 @@ void Game::Loadlevel(const std::string& name) firstload = 1; leveltime = 0; + wonleveltime = 0; visibleloading = 0; } @@ -6218,6 +6219,7 @@ void Game::TickOnceAfter() accountactive->winCampaignLevel(whichchoice, bonustotal, leveltime); scoreadded = 1; } else { + wonleveltime = leveltime; accountactive->winLevel(whichlevel, bonustotal - startbonustotal, leveltime); } won = 1; diff --git a/Source/Menu.cpp b/Source/Menu.cpp index 8ed62b4..9e08d74 100644 --- a/Source/Menu.cpp +++ b/Source/Menu.cpp @@ -464,11 +464,12 @@ void Menu::Load() if (name.size() < 32) { name.append((32 - name.size()), ' '); } - name += to_string(int((int(accountactive->getFastTime(i)) - int(accountactive->getFastTime(i)) % 60) / 60)); + int fasttime = (int)round(accountactive->getFastTime(i)); + name += to_string(int((fasttime - fasttime % 60) / 60)); name += ":"; - if ((int)(accountactive->getFastTime(i)) % 60 < 10) + if (fasttime % 60 < 10) name += "0"; - name += to_string((int)(accountactive->getFastTime(i)) % 60); + name += to_string(fasttime % 60); addButton(i, name, 10, 400 - i * 25, i > accountactive->getProgress() ? 0.5 : 1, 0, 0); }