mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
changed signed handling
This commit is contained in:
parent
c0c9cb499e
commit
d058dcfaff
@ -23,8 +23,9 @@ NetworkTimePrecision = 100.0
|
|||||||
|
|
||||||
# These values are derived from the above.
|
# These values are derived from the above.
|
||||||
NetworkTimeMask = (1 << NetworkTimeBits) - 1
|
NetworkTimeMask = (1 << NetworkTimeBits) - 1
|
||||||
|
NetworkTimeSignedMask = NetworkTimeMask >> 1 # the max absolute value bits.
|
||||||
NetworkTimeTopBits = 32 - NetworkTimeBits
|
NetworkTimeTopBits = 32 - NetworkTimeBits
|
||||||
MaxTimeDelta = (NetworkTimeMask / 2.0) / NetworkTimePrecision
|
MaxTimeDelta = NetworkTimeSignedMask / NetworkTimePrecision
|
||||||
|
|
||||||
# This is the maximum number of seconds by which we expect our clock
|
# This is the maximum number of seconds by which we expect our clock
|
||||||
# (or the server's clock) to drift over an hour.
|
# (or the server's clock) to drift over an hour.
|
||||||
@ -310,6 +311,13 @@ class ClockDelta(DirectObject.DirectObject):
|
|||||||
Preserves the lower NetworkTimeBits of the networkTime value,
|
Preserves the lower NetworkTimeBits of the networkTime value,
|
||||||
and extends the sign bit all the way up.
|
and extends the sign bit all the way up.
|
||||||
"""
|
"""
|
||||||
return ((networkTime & NetworkTimeMask) << NetworkTimeTopBits) >> NetworkTimeTopBits
|
if networkTime < 0:
|
||||||
|
# flip the sign, mask it as if it were positive, flip the sign back:
|
||||||
|
r = (networkTime * -1 & NetworkTimeSignedMask) * -1
|
||||||
|
else:
|
||||||
|
r = networkTime & NetworkTimeSignedMask
|
||||||
|
assert -32768 <= r <= 32767
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
globalClockDelta = ClockDelta()
|
globalClockDelta = ClockDelta()
|
||||||
|
@ -1098,7 +1098,7 @@ def randInt32(rng=random.random):
|
|||||||
"""
|
"""
|
||||||
i = int(rng() * 0x7FFFFFFF)
|
i = int(rng() * 0x7FFFFFFF)
|
||||||
if rng() < .5:
|
if rng() < .5:
|
||||||
i += 0x80000000
|
i *= -1
|
||||||
return i
|
return i
|
||||||
|
|
||||||
class Enum:
|
class Enum:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user