diff --git a/direct/src/distributed/AstronClientRepository.py b/direct/src/distributed/AstronClientRepository.py index 85a5938ae9..bbc872408f 100644 --- a/direct/src/distributed/AstronClientRepository.py +++ b/direct/src/distributed/AstronClientRepository.py @@ -1,14 +1,23 @@ """AstronClientRepository module: contains the AstronClientRepository class""" +from direct.directnotify import DirectNotifyGlobal from ClientRepositoryBase import ClientRepositoryBase from MsgTypesAstron import * +from direct.distributed.PyDatagram import PyDatagram +from pandac.PandaModules import STUint16, STUint32 class AstronClientRepository(ClientRepositoryBase): """ The Astron implementation of a clients repository for communication with an Astron ClientAgent. """ - + + notify = DirectNotifyGlobal.directNotify.newCategory("ClientRepository") + + # This is required by DoCollectionManager, even though it's not + # used by this implementation. + GameGlobalsId = 0 + def __init__(self, *args, **kwargs): ClientRepositoryBase.__init__(self, *args, **kwargs) base.finalExitCallbacks.append(self.shutdown) @@ -18,9 +27,10 @@ class AstronClientRepository(ClientRepositoryBase): # Message Handling # - def handleDatagram(self, di): + #def handleDatagram(self, di): + #msgType = self.getMsgType() - msgType = self.getMsgType() + def handleMessageType(self, msgType, di): # These are the messages to a client that Astron specifies. @@ -54,7 +64,7 @@ class AstronClientRepository(ClientRepositoryBase): self.considerHeartbeat() - def handleEnterObjectRequired(di) + def handleEnterObjectRequired(self, di): do_id = di.getArg(STUint32) parent_id = di.getArg(STUint32) zone_id = di.getArg(STUint32) @@ -62,7 +72,7 @@ class AstronClientRepository(ClientRepositoryBase): dclass = self.dclassesByNumber[dclass_id] self.generateWithRequiredFields(dclass, do_id, di, parent_id, zone_id) - def handleEnterObjectRequiredOwner(di) + def handleEnterObjectRequiredOwner(self, di): avatar_doId = di.getArg(STUint32) parentId = di.getArg(STUint32) zoneId = di.getArg(STUint32) @@ -111,40 +121,40 @@ class AstronClientRepository(ClientRepositoryBase): # updateRequiredFields calls announceGenerate return distObj - def handleObjectSetField(di): - do_id = di.getArg(STUint32) - field_id = di.getArg(STUint16) - # FIXME: Is this really the best way? - do = self.doId2do[do_id] - # FIXME: Figure out field types and unpack them, or use - # some code that auto-unpacks them. - field_name = self.get_dc_file().get_field_by_index(field_id).get_name() - # FIXME: You actually need to figure out the fields types and unpack them! - self.sendUpdate(field_name, [fieldArguments]) + def handleObjectSetField(self, di): + do_id = di.getArg(STUint32) + field_id = di.getArg(STUint16) + # FIXME: Is this really the best way? + do = self.doId2do[do_id] + # FIXME: Figure out field types and unpack them, or use + # some code that auto-unpacks them. + field_name = self.get_dc_file().get_field_by_index(field_id).get_name() + # FIXME: You actually need to figure out the fields types and unpack them! + self.sendUpdate(field_name, [fieldArguments]) - def handleObjectSetFields(di): - # FIXME: Implement this! - pass + def handleObjectSetFields(self, di): + # FIXME: Implement this! + pass - def handleObjectLeaving(di): - # FIXME: Implement this! - pass + def handleObjectLeaving(self, di): + # FIXME: Implement this! + pass - def handleObjectLocation(di): - # FIXME: Implement this! - pass + def handleObjectLocation(self, di): + # FIXME: Implement this! + pass - def handleAddInterest(di): - # FIXME: Implement this! - pass + def handleAddInterest(self, di): + # FIXME: Implement this! + pass - def handleAddInterestMultiple(di): - # FIXME: Implement this! - pass + def handleAddInterestMultiple(self, di): + # FIXME: Implement this! + pass - def handleRemoveInterest(di): - # FIXME: Implement this! - pass + def handleRemoveInterest(self, di): + # FIXME: Implement this! + pass # # Sending messages @@ -153,7 +163,7 @@ class AstronClientRepository(ClientRepositoryBase): # FIXME: The version string should default to a .prc variable. def sendHello(self, version_string): dg = PyDatagram() - dg.add_uint16(MsgTypes.CLIENT_HELLO) + dg.add_uint16(CLIENT_HELLO) dg.add_uint32(self.get_dc_file().get_hash()) dg.add_string(version_string) self.send(dg) @@ -165,7 +175,7 @@ class AstronClientRepository(ClientRepositoryBase): def sendAddInterest(self, context, interest_id, parent_id, zone_id): dg = PyDatagram() - dg.add_uint16(MsgTypes.CLIENT_ADD_INTEREST) + dg.add_uint16(CLIENT_ADD_INTEREST) dg.add_uint32(context) dg.add_uint16(interest_id) dg.add_uint32(parent_id) @@ -174,7 +184,7 @@ class AstronClientRepository(ClientRepositoryBase): def sendAddInterestMultiple(self, context, interest_id, parent_id, zone_ids): dg = PyDatagram() - dg.add_uint16(MsgTypes.CLIENT_ADD_INTEREST_MULTIPLE) + dg.add_uint16(CLIENT_ADD_INTEREST_MULTIPLE) dg.add_uint32(context) dg.add_uint16(interest_id) dg.add_uint32(parent_id) @@ -185,7 +195,7 @@ class AstronClientRepository(ClientRepositoryBase): def sendRemoveInterest(self, context, interest_id): dg = PyDatagram() - dg.add_uint16(MsgTypes.CLIENT_REMOVE_INTEREST) + dg.add_uint16(CLIENT_REMOVE_INTEREST) dg.add_uint32(context) dg.add_uint16(interest_id) self.send(dg) diff --git a/direct/src/distributed/DistributedNode.py b/direct/src/distributed/DistributedNode.py index 353b001cc2..af4aa10e82 100644 --- a/direct/src/distributed/DistributedNode.py +++ b/direct/src/distributed/DistributedNode.py @@ -17,6 +17,7 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath): self.DistributedNode_initialized = 1 self.gotStringParentToken = 0 DistributedObject.DistributedObject.__init__(self, cr) + NodePath.__init__(self, "DistributedNode") # initialize gridParent self.gridParent = None