From a85771f39d397e06bc168ac63f586f0a6f0c4fa1 Mon Sep 17 00:00:00 2001 From: Jesse Schell Date: Wed, 1 Nov 2000 18:35:26 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/distributed/ClientDistClass.py | 8 ++++---- direct/src/distributed/ClientDistUpdate.py | 16 +++++++++------- direct/src/distributed/ClientRepository.py | 13 ++++++++----- direct/src/distributed/DistributedActor.py | 3 ++- direct/src/distributed/DistributedNode.py | 9 +++++---- direct/src/distributed/DistributedObject.py | 6 ++++-- 6 files changed, 32 insertions(+), 23 deletions(-) diff --git a/direct/src/distributed/ClientDistClass.py b/direct/src/distributed/ClientDistClass.py index c1b95b49d8..81b841425a 100644 --- a/direct/src/distributed/ClientDistClass.py +++ b/direct/src/distributed/ClientDistClass.py @@ -51,20 +51,20 @@ class ClientDistClass: def updateField(self, do, di): # Get the update field id - fieldId = di.getArg(ST_uint8) + fieldId = di.getArg(STUint16) # look up the CDU assert(self.number2CDU.has_key(fieldId)) cdu = self.number2CDU[fieldId] # Let the cdu finish the job - cdu.updateField(cdc, do, di) + cdu.updateField(self, do, di) return None - def sendUpdate(self, do, fieldName, args): + def sendUpdate(self, cr, do, fieldName, args): # Look up the cdu assert(self.name2CDU.has_key(fieldName)) cdu = self.name2CDU[fieldName] # Let the cdu finish the job - cdu.sendUpdate(do, args) + cdu.sendUpdate(cr, do, args) diff --git a/direct/src/distributed/ClientDistUpdate.py b/direct/src/distributed/ClientDistUpdate.py index 807fd7a1ed..5eab586783 100644 --- a/direct/src/distributed/ClientDistUpdate.py +++ b/direct/src/distributed/ClientDistUpdate.py @@ -3,6 +3,8 @@ import DirectNotifyGlobal import Avatar import DistributedToon +import Datagram +from MsgTypes import * class ClientDistUpdate: notify = DirectNotifyGlobal.directNotify.newCategory("ClientDistUpdate") @@ -28,7 +30,7 @@ class ClientDistUpdate: componentField = dcFieldMolecular.getAtomic(i) for j in range(0, componentField.getNumElements()): self.types.append(componentField.getElementType(j)) - self.types.append(componentField.getElementDivisor(j)) + self.divisors.append(componentField.getElementDivisor(j)) else: ClientDistUpdate.notify.error("field is neither atom nor molecule") return None @@ -57,17 +59,17 @@ class ClientDistUpdate: numElems = len(args) assert (numElems == len(self.types)) for i in range(0, numElems): - datagram.addArg(args[i], self.types[i]) + datagram.putArg(args[i], self.types[i]) - def sendUpdate(self, do, args): - datagram = Datagram() + def sendUpdate(self, cr, do, args): + datagram = Datagram.Datagram() # Add message type - datagram.addUint16(ALL_OBJECT_UPDATE_FIELD) + datagram.addUint16(CLIENT_OBJECT_UPDATE_FIELD) # Add the DO id datagram.addUint32(do.doId) # Add the field id - datagram.addUint8(self.number) + datagram.addUint16(self.number) # Add the arguments self.addArgs(datagram, args) # send the datagram - + cr.send(datagram) diff --git a/direct/src/distributed/ClientRepository.py b/direct/src/distributed/ClientRepository.py index 37e4c0fa01..919e3990bd 100644 --- a/direct/src/distributed/ClientRepository.py +++ b/direct/src/distributed/ClientRepository.py @@ -106,7 +106,7 @@ class ClientRepository(DirectObject.DirectObject): distObj.updateRequiredFields(cdc, di) else: # Construct a new one - distObj = constructor() + distObj = constructor(self) # Assign it an Id distObj.doId = doId # Update the required fields @@ -119,10 +119,10 @@ class ClientRepository(DirectObject.DirectObject): def handleUpdateField(self, di): # Get the DO Id - doId = di.getArg(ST_uint32) + doId = di.getArg(STUint32) # Find the DO assert(self.doId2do.has_key(doId)) - do = self.doId2do(doId) + do = self.doId2do[doId] # Find the cdc assert(self.doId2cdc.has_key(doId)) cdc = self.doId2cdc[doId] @@ -136,5 +136,8 @@ class ClientRepository(DirectObject.DirectObject): assert(self.doId2cdc.has_key(doId)) cdc = self.doId2cdc[doId] # Let the cdc finish the job - cdc.sendUpdate(do, fieldName, args) - + cdc.sendUpdate(self, do, fieldName, args) + + def send(self, datagram): + self.cw.send(datagram, self.tcpConn) + return None diff --git a/direct/src/distributed/DistributedActor.py b/direct/src/distributed/DistributedActor.py index d37e545b92..bf3b2867c0 100644 --- a/direct/src/distributed/DistributedActor.py +++ b/direct/src/distributed/DistributedActor.py @@ -6,11 +6,12 @@ import Actor class DistributedActor(DistributedNode.DistributedNode, Actor.Actor): """Distributed Actor class:""" - def __init__(self): + def __init__(self, cr): try: self.DistributedActor_initialized except: self.DistributedActor_initialized = 1 + DistributedNode.DistributedNode.__init__(self, cr) return None diff --git a/direct/src/distributed/DistributedNode.py b/direct/src/distributed/DistributedNode.py index 5cc96ee383..7e828b0b5a 100644 --- a/direct/src/distributed/DistributedNode.py +++ b/direct/src/distributed/DistributedNode.py @@ -6,11 +6,12 @@ import DistributedObject class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath): """Distributed Node class:""" - def __init__(self): + def __init__(self, cr): try: self.DistributedNode_initialized except: self.DistributedNode_initialized = 1 + DistributedObject.DistributedObject.__init__(self, cr) return None def generateInit(self, di): @@ -22,10 +23,10 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath): def d_setHpr(self, h, p, r): self.sendUpdate("setHpr", [h, p, r]) - def d_setPosHpr(self): + def d_broadcastPosHpr(self): - self.d_setPos_Hpr(self.getX(), self.getY(), self.getZ(), - self.getH(), self.getP(), self.getR()) + self.d_setPosHpr(self.getX(), self.getY(), self.getZ(), + self.getH(), self.getP(), self.getR()) def d_setPosHpr(self, x, y, z, h, p, r): self.sendUpdate("setPosHpr", [x, y, z, h, p, r]) diff --git a/direct/src/distributed/DistributedObject.py b/direct/src/distributed/DistributedObject.py index c850e4b384..fdf074f207 100644 --- a/direct/src/distributed/DistributedObject.py +++ b/direct/src/distributed/DistributedObject.py @@ -1,14 +1,16 @@ """DistributedObject module: contains the DistributedObject class""" from PandaObject import * +from ToonBaseGlobal import * class DistributedObject(PandaObject): """Distributed Object class:""" - def __init__(self): + def __init__(self, cr): try: self.DistributedObject_initialized except: self.DistributedObject_initialized = 1 + self.cr = cr return None def getDoId(self): @@ -22,7 +24,7 @@ class DistributedObject(PandaObject): i.updateField(cdc, self, di) def sendUpdate(self, fieldName, args): - cr.sendupdate(self, fieldName, args) + self.cr.sendUpdate(self, fieldName, args) def taskName(self, taskString): return (taskString + "-" + str(self.getDoId))