Author |
Message |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Thu Jul 15, 2004 3:37 am Post subject: |
 |
|
|
|
Bak wrote: | The only issue you might get is after the system is on 25 days where the integer variable will wrap around to negatives. Then new players may get warped more than once. I'll update the code to use centiseconds instead and it should solve this, as the value will always stay positive. Good catch Ekted. |
The old wrap. That is one of the first things I try to deal with when handling integer compares. It's especially bad with things like ticks in windows since they are unsigned, and people often try to subtract to compare to some expected range. I never subtract unless I know I set a base that IS relative to the value. _________________ 4,691 irradiated haggis! |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
 |
Mr Ekted Movie Geek

Gender: Joined: Feb 09 2004 Posts: 1379 Offline
|
Posted: Thu Jul 15, 2004 1:55 pm Post subject: |
 |
|
|
|
If you have a known base, like start_time = GetTickCount(), then at some point in the future, you can do GetTickCount() - start_time >= SOME_INTERVAL. This will always work even if the values wrap, because the difference also wraps.
0x00000001 - 0xffffffff = 2
If MERV tags are 32-bit ints, then you can simply cast ticks back and forth to unsigned ints. No change of bits is performed, just change of interpretation. |
|
Back to top |
|
 |
Bak ?ls -s 0 in

Age:26 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Thu Jul 15, 2004 2:38 pm Post subject: |
 |
|
|
|
that's what it's doing. The problem is that if the tag isn't found it'll default to 0.
so curTime = -124114 and
lastWarpTime = 0
curTime - lastWarpTime is -124114 which is < 100 (tolerance).
but with centiseconds the value will never be negative, so the problem is solved. |
|
Back to top |
|
 |
|