827445d8fa
progress includes: - cogs appear on streets now - additionally, street interests are setup for astron clients. - cog battles are mostly working - updated some sequences to work with newer panda3d - fixed particle effects search paths so that they load now - handled disconnect reasons for clients that disconnect during cog battles etc. - fleshed out the holiday manager a bit more
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
import time
|
|
|
|
from direct.directnotify import DirectNotifyGlobal
|
|
from direct.distributed.ClockDelta import globalClockDelta
|
|
from direct.distributed.DistributedObjectAI import DistributedObjectAI
|
|
|
|
from otp.otpbase import OTPGlobals
|
|
|
|
|
|
class TimeManagerAI(DistributedObjectAI):
|
|
notify = DirectNotifyGlobal.directNotify.newCategory('TimeManagerAI')
|
|
|
|
def __init__(self, air):
|
|
DistributedObjectAI.__init__(self, air)
|
|
self.avId2disconnectcode = {}
|
|
|
|
def requestServerTime(self, context):
|
|
avId = self.air.getAvatarIdFromSender()
|
|
if not avId:
|
|
return
|
|
|
|
self.sendUpdateToAvatarId(avId, 'serverTime',
|
|
[context, globalClockDelta.getRealNetworkTime(bits=32), int(time.time())])
|
|
|
|
def setDisconnectReason(self, disconnectCode):
|
|
avId = self.air.getAvatarIdFromSender()
|
|
if not avId:
|
|
return
|
|
|
|
self.avId2disconnectcode[avId] = disconnectCode
|
|
self.air.writeServerEvent('disconnect-reason', avId=avId,
|
|
reason=OTPGlobals.DisconnectReasons.get(disconnectCode, 'unknown'))
|