mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-27 05:32:41 -06:00
35b646c4e6
This reverts commit 1e4bad8c6b
.
30 lines
No EOL
1.2 KiB
Python
Executable file
30 lines
No EOL
1.2 KiB
Python
Executable file
from direct.directnotify import DirectNotifyGlobal
|
|
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
|
from direct.distributed.ClockDelta import globalClockDelta
|
|
from otp.otpbase import OTPGlobals
|
|
import time
|
|
|
|
class TimeManagerAI(DistributedObjectAI):
|
|
notify = DirectNotifyGlobal.directNotify.newCategory("TimeManagerAI")
|
|
|
|
def __init__(self, air):
|
|
DistributedObjectAI.__init__(self, air)
|
|
self.avId2DcReason = {}
|
|
|
|
def requestServerTime(self, context):
|
|
self.sendUpdateToAvatarId(self.air.getAvatarIdFromSender(), 'serverTime', [context, globalClockDelta.getRealNetworkTime(bits=32), int(time.time())])
|
|
|
|
def setDisconnectReason(self, reason):
|
|
avId = self.air.getAvatarIdFromSender()
|
|
|
|
if reason == OTPGlobals.DisconnectNone and avId in self.avId2DcReason:
|
|
del self.avId2DcReason[avId]
|
|
else:
|
|
self.avId2DcReason[avId] = reason
|
|
|
|
def setExceptionInfo(self, exception):
|
|
avId = self.air.getAvatarIdFromSender()
|
|
self.air.writeServerEvent('client-exception', avId, exception)
|
|
|
|
def getDisconnectReason(self, avId):
|
|
return self.avId2DcReason.get(avId, 0) |