Browse Source

using parentId, zoneId rather than __location

Dave Schuyler 20 years ago
parent
commit
87920f25ac

+ 14 - 9
direct/src/distributed/DistributedObject.py

@@ -35,9 +35,10 @@ class DistributedObject(PandaObject):
         except:
             self.DistributedObject_initialized = 1
             self.cr = cr
-            if wantOtpServer:
-                # Location stores the parentId, zoneId of this object
-                self.__location = (None, None)
+            self.children = {}
+            ## if wantOtpServer:
+                ## # Location stores the parentId, zoneId of this object
+                ## self.__location = (None, None)
 
             # Most DistributedObjects are simple and require no real
             # effort to load.  Some, particularly actors, may take
@@ -396,7 +397,7 @@ class DistributedObject(PandaObject):
                     oldParentObj.handleChildLeave(self, oldZoneId)
 
             # The store must run first so we know the old location
-            self.__location = (parentId, zoneId)
+            ## self.__location = (parentId, zoneId)
             self.parentId = parentId
             self.zoneId = zoneId
             self.cr.storeObjectLocation(self.doId, parentId, zoneId)
@@ -410,24 +411,28 @@ class DistributedObject(PandaObject):
                     parentObj.handleChildArrive(self, zoneId)
             
         def getLocation(self):
-            return self.__location
+            return (self.parentId, self.zoneId)
 
         def handleChildArrive(self, childObj, zoneId):
-            self.notify.debug("handleChildArrive: %s childId: %s zoneId: %s" %
-                             (self.doId, childObj.doId, zoneId))
+            self.notify.debugCall()
             # A new child has just setLocation beneath us.  Give us a
             # chance to run code when a new child sets location to us. For
             # example, we may want to scene graph reparent the child to
             # some subnode we own.
+            ## zone=self.children.setdefault(zoneId, {})
+            ## zone[childObj.doId]=childObj
             
             # Inheritors should override
             pass
 
         def handleChildLeave(self, childObj, zoneId):
-            self.notify.debug("handleChildLeave: %s childId: %s zoneId: %s" %
-                             (self.doId, childObj.doId, zoneId))
+            self.notify.debugCall()
             # A child is about to setLocation away from us.  Give us a
             # chance to run code just before a child sets location away from us.
+            ## zone=self.children[zoneId]
+            ## del zone[childObj.doId]
+            ## if not len(zone):
+            ##     del self.children[zoneId]
             
             # Inheritors should override
             pass

+ 12 - 9
direct/src/distributed/DistributedObjectAI.py

@@ -21,7 +21,9 @@ class DistributedObjectAI(DirectObject):
             # Record the repository
             self.air = air
             # Record our parentId and zoneId
-            self.__location = None
+            ## self.__location = None
+            self.parentId = None
+            self.zoneId = None
 
             # Record our distributed class
             className = self.__class__.__name__
@@ -195,14 +197,15 @@ class DistributedObjectAI(DirectObject):
                     self.handleLogicalZoneChange(zoneId, lastLogicalZone)
                     self.lastNonQuietZone = zoneId
             self.air.storeObjectLocation(self.doId, parentId, zoneId)
-            self.__location = (parentId, zoneId)
+            ## self.__location = (parentId, zoneId)
 
         # Set the initial values of parentId,zoneId
         def setInitLocation(self, parentId, zoneId):
-            self.__location = (parentId, zoneId)
+            self.parentId=parentId
+            self.zoneId=zoneId
             
         def getLocation(self):
-            return self.__location
+            return (self.parentId, self.zoneId)
 
     else:
         # NON OTP
@@ -314,9 +317,9 @@ class DistributedObjectAI(DirectObject):
 
             # The repository is the one that really does the work
             parentId = self.air.districtId
-            self.air.generateWithRequired(self, parentId, zoneId, optionalFields)
             self.parentId = parentId
             self.zoneId = zoneId
+            self.air.generateWithRequired(self, parentId, zoneId, optionalFields)
             self.generate()
     else:
         def generateWithRequired(self, zoneId, optionalFields=[]):
@@ -346,7 +349,7 @@ class DistributedObjectAI(DirectObject):
             self.air.generateWithRequiredAndId(self, doId, parentId, zoneId, optionalFields)
             self.parentId = parentId
             self.zoneId = zoneId
-            self.__location = (parentId, zoneId)
+            ## self.__location = (parentId, zoneId)
             self.generate()
     else:
         def generateWithRequiredAndId(self, doId, zoneId, optionalFields=[]):
@@ -371,7 +374,7 @@ class DistributedObjectAI(DirectObject):
             assert not hasattr(self, 'parentId')
             self.parentId = parentId
             self.zoneId = zoneId
-            self.__location = (parentId, zoneId)
+            ## self.__location = (parentId, zoneId)
             self.generate()
 
         def generateOtpObject(self, parentId, zoneId, optionalFields=[], doId=None):
@@ -392,10 +395,10 @@ class DistributedObjectAI(DirectObject):
             # Send a generate message
             self.sendGenerateWithRequired(self.air, parentId, zoneId, optionalFields)
 
-            assert not hasattr(self, 'parentId')
+            assert not hasattr(self, 'parentId') or self.parentId is None
             self.parentId = parentId
             self.zoneId = zoneId
-            self.__location = (parentId, zoneId)
+            ## self.__location = (parentId, zoneId)
             self.generate()
 
     def generate(self):