Skip to content

Commit

Permalink
Simplify timeout in guiConfirmVideoMode
Browse files Browse the repository at this point in the history
It was causing problems when compiling OPL with the -O3 flag. Not sure
why though, but it's simpler like this.
  • Loading branch information
rickgaiser committed May 7, 2020
1 parent de1ade8 commit 51f402d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -1604,12 +1604,12 @@ void guiWarning(const char *text, int count)

int guiConfirmVideoMode(void)
{
clock_t timeStart, timeNow, timeElasped;
clock_t timeEnd;
int terminate = 0;

sfxPlay(SFX_MESSAGE);

timeStart = clock() / (CLOCKS_PER_SEC / 1000);
timeEnd = clock() + OPL_VMODE_CHANGE_CONFIRMATION_TIMEOUT_MS * (CLOCKS_PER_SEC / 1000);
while (!terminate) {
guiStartFrame();

Expand All @@ -1621,9 +1621,7 @@ int guiConfirmVideoMode(void)
terminate = 2;

//If the user fails to respond within the timeout period, deem it as a cancel operation.
timeNow = clock() / (CLOCKS_PER_SEC / 1000);
timeElasped = (timeNow < timeStart) ? UINT_MAX - timeStart + timeNow + 1 : timeNow - timeStart;
if (timeElasped >= OPL_VMODE_CHANGE_CONFIRMATION_TIMEOUT_MS)
if (clock() > timeEnd)
terminate = 1;

guiShow();
Expand Down

0 comments on commit 51f402d

Please sign in to comment.