2
0
Эх сурвалжийг харах

make sure we dont do setLocation work if unnecessary

Samir Naik 21 жил өмнө
parent
commit
7e8448cff2

+ 10 - 3
direct/src/distributed/DistributedObjectAI.py

@@ -20,6 +20,9 @@ class DistributedObjectAI(DirectObject.DirectObject):
             self.accountName=''
             self.accountName=''
             # Record the repository
             # Record the repository
             self.air = air
             self.air = air
+            # Record our parentId and zoneId
+            self.__location = None
+            
             # Record our distributed class
             # Record our distributed class
             className = self.__class__.__name__
             className = self.__class__.__name__
             self.dclass = self.air.dclassesByName[className]
             self.dclass = self.air.dclassesByName[className]
@@ -140,9 +143,13 @@ class DistributedObjectAI(DirectObject.DirectObject):
             self.air.addInterest(self.getDoId(), zoneId, note, event)
             self.air.addInterest(self.getDoId(), zoneId, note, event)
 
 
         def setLocation(self, parentId, zoneId):
         def setLocation(self, parentId, zoneId):
-            # The store must run first so we know the old location
-            self.air.sendSetLocation(self, parentId, zoneId)
-            self.__location = (parentId, zoneId)
+            if self.__location:
+                # Make sure our parentId and/or zoneId are actually changing before doing any work
+                oldParentId, oldZoneId = self.__location
+                if oldParentId != parentId or oldZoneId != zoneId:
+                    # The store must run first so we know the old location
+                    self.air.sendSetLocation(self, parentId, zoneId)
+                    self.__location = (parentId, zoneId)
 
 
         def getLocation(self):
         def getLocation(self):
             return self.__location
             return self.__location