GetRealMilliseconds calculation is bad on mac platform
by Paul Scott · in Torque Game Engine · 05/17/2004 (8:25 pm) · 7 replies
On the mac platform, the method U32 Platform::getRealMilliseconds() does not calculate correctly. The result is that every 71 minutes, the getRealMilliseconds count jumps forward by a substantial amount.
This could cause serious problems on any game that uses schedule(), and is run on a mac. It would appear as a non reproducable bug. Lots of events scheduled for several minutes in the future would all fire at once, causing some unusual behavior.
The fix is easy.
in macCarbTime.cc, at about line 50, after
change the return line from
This could cause serious problems on any game that uses schedule(), and is run on a mac. It would appear as a non reproducable bug. Lots of events scheduled for several minutes in the future would all fire at once, causing some unusual behavior.
The fix is easy.
in macCarbTime.cc, at about line 50, after
U32 Platform::getRealMilliseconds()
{
UnsignedWide time;
Microseconds(&time);change the return line from
return (time.hi*5000000) + (time.lo/1000);to
return (time.hi*4294967296)/1000 + (time.lo/1000); }
#2
05/18/2004 (8:46 am)
Well, this only defers the problem. You'd still get the same effect after 49.7 days. Come on, you've got to cater to us hardcore gamers too. (I'm totally kidding... nice find! :)
#3
05/18/2004 (10:25 am)
Yeah, I don't know whether I'll use this solution. I definitely want to research it more and try to come up with something better. If nothing else, this would be a viable temporary stop-gap. It was about 3am when I responded to your post, so sorry for not being more detailed. :)
#4
I'm not sure what other solution there is, unless you use something from the unix side. I tried gettimeofday just now, but as it returns time since the epoch, it tends to overflow one little U32. getRealTime() spat out negative numbers at me.
I wasn't aware that there'd be any problem with the above math after 50 days. It could be important for long - running servers.
I'm gonna regret asking this, but, what's the math error, please?
05/18/2004 (12:08 pm)
Cool, glad you like it.I'm not sure what other solution there is, unless you use something from the unix side. I tried gettimeofday just now, but as it returns time since the epoch, it tends to overflow one little U32. getRealTime() spat out negative numbers at me.
I wasn't aware that there'd be any problem with the above math after 50 days. It could be important for long - running servers.
I'm gonna regret asking this, but, what's the math error, please?
#5
I'm not even sure there is one yet. :) Truth be told, I haven't had time yet to do anything more than glance at your solution. I was just going off what John said, and if there is a prob, I'll let you know. If not, we'll certainly use this.
In either case, thanks much for the find and fix. Even if it just serves as a stop-gap it's nice to have.
Edit: Fix checked in 7/18/04
05/18/2004 (12:21 pm)
Paul,I'm not even sure there is one yet. :) Truth be told, I haven't had time yet to do anything more than glance at your solution. I was just going off what John said, and if there is a prob, I'll let you know. If not, we'll certainly use this.
In either case, thanks much for the find and fix. Even if it just serves as a stop-gap it's nice to have.
Edit: Fix checked in 7/18/04
#6
05/18/2004 (1:35 pm)
So the both of you know, my comment was 100% facetious. (I'm an incorrigible punster... feel free to defenestrate me). Granted, it is still a problem after 49.7 days, but even if a server had a sudden surge of events happen every two months, I don't think too many people would be upset, unless it was a subscription MMORPG or something. I also think that if someone is capable to make a MMORPG, they would be able to come up with a fix or work-around. I'd put in Paul's fix and then maybe classify this as the lowest-priority bug.
#7
05/18/2004 (8:30 pm)
The 49.7 days thing refers to an, uh, interesting bug in the windows timing code, as I recall. :)
Torque Owner Josh Williams
Default Studio Name