I wasn't sure if this should be in a coding subforum, so correct me if I was wrong.
As many of you know, MBG's timer freezes at 60:00.99. Oddly enough, however, this is *not* the correct value--the time stored in the game's engine is 3599999 milliseconds, or 59:59.99. The reason why this occurs is due to a floating-point bug. First, MBG calculates the hundredths of a second, which correctly return as 99. Then, the code divides by 1000 and rounds down to find the total number of seconds. This erroneously comes out as 3600. So the game thinks 3600.99 seconds have passed, while the actual value is 3599.99.
Strangely enough, the fault seems to lie in the division operator. When the game divides 3599999 by 1000, it somehow decides to round the answer up slightly, losing the precision. I checked in C, and single-precision floats don't do this -- maybe Jeff or someone who knows more about the workings of the engine can figure out why this happens.
In any case, the glitch could be fixed as follows if anyone wants to. Replace the following line of code in marble/client/playGui.cs:
with:
Although I haven't tested this directly, it should work according to console tests.
For the record, MBP's clock continues until 99:59.99 and displays it correctly (at least in 1.50 beta 3).
As many of you know, MBG's timer freezes at 60:00.99. Oddly enough, however, this is *not* the correct value--the time stored in the game's engine is 3599999 milliseconds, or 59:59.99. The reason why this occurs is due to a floating-point bug. First, MBG calculates the hundredths of a second, which correctly return as 99. Then, the code divides by 1000 and rounds down to find the total number of seconds. This erroneously comes out as 3600. So the game thinks 3600.99 seconds have passed, while the actual value is 3599.99.
Strangely enough, the fault seems to lie in the division operator. When the game divides 3599999 by 1000, it somehow decides to round the answer up slightly, losing the precision. I checked in C, and single-precision floats don't do this -- maybe Jeff or someone who knows more about the workings of the engine can figure out why this happens.
In any case, the glitch could be fixed as follows if anyone wants to. Replace the following line of code in marble/client/playGui.cs:
Code:
%totalSeconds = mFloor(%et / 1000);
Code:
%totalSeconds = mFloor((%et - %et % 1000) / 1000);
For the record, MBP's clock continues until 99:59.99 and displays it correctly (at least in 1.50 beta 3).