oldschool-toontown/otp/distributed/OTPInternalRepository.py

44 lines
1.7 KiB
Python
Raw Normal View History

2019-11-08 21:20:04 -06:00
from direct.directnotify import DirectNotifyGlobal
from direct.distributed.AstronInternalRepository import AstronInternalRepository
2020-01-02 21:02:07 -06:00
from direct.distributed.PyDatagram import *
2019-11-08 21:20:04 -06:00
2019-11-27 23:17:22 -06:00
2019-11-08 21:20:04 -06:00
# TODO: Remove Astron dependence.
class OTPInternalRepository(AstronInternalRepository):
notify = DirectNotifyGlobal.directNotify.newCategory('OTPInternalRepository')
dbId = 4003
def __init__(self, baseChannel, serverId, dcFileNames, dcSuffix, connectMethod, threadedNet):
2019-11-27 23:17:22 -06:00
AstronInternalRepository.__init__(self, baseChannel, serverId=serverId, dcFileNames=dcFileNames,
dcSuffix=dcSuffix, connectMethod=connectMethod, threadedNet=threadedNet)
2019-11-08 21:20:04 -06:00
def handleConnected(self):
AstronInternalRepository.handleConnected(self)
2019-11-15 20:15:38 -06:00
def getAccountIdFromSender(self):
return (self.getMsgSender() >> 32) & 0xFFFFFFFF
2019-11-17 15:29:23 -06:00
def getAvatarIdFromSender(self):
return self.getMsgSender() & 0xFFFFFFFF
2019-11-22 19:58:35 -06:00
def sendSetZone(self, distObj, zoneId):
distObj.setLocation(distObj.parentId, zoneId)
self.sendSetLocation(distObj, distObj.parentId, zoneId)
2020-01-02 21:02:07 -06:00
def setAllowClientSend(self, avId, distObj, fieldNameList=[]):
dg = PyDatagram()
dg.addServerHeader(distObj.GetPuppetConnectionChannel(avId), self.ourChannel, CLIENTAGENT_SET_FIELDS_SENDABLE)
fieldIds = []
for fieldName in fieldNameList:
field = distObj.dclass.getFieldByName(fieldName)
if field:
fieldIds.append(field.getNumber())
dg.addUint32(distObj.getDoId())
dg.addUint16(len(fieldIds))
for fieldId in fieldIds:
dg.addUint16(fieldId)
self.send(dg)