Browse Source

guard for calling setLocation twice

Joe Shochet 21 years ago
parent
commit
0b3f17397b
1 changed files with 16 additions and 14 deletions
  1. 16 14
      direct/src/distributed/DistributedObjectAI.py

+ 16 - 14
direct/src/distributed/DistributedObjectAI.py

@@ -152,20 +152,22 @@ class DistributedObjectAI(DirectObject.DirectObject):
         def setLocation(self, parentId, zoneId):
             oldParentId = self.parentId
             oldZoneId = self.zoneId
-            self.zoneId = zoneId
-            self.parentId = parentId
-            self.air.changeDOZoneInTables(self, zoneId, oldZoneId)
-            messenger.send(self.getZoneChangeEvent(), [zoneId, oldZoneId])
-            # if we are not going into the quiet zone, send a 'logical' zone
-            # change message
-            if zoneId != DistributedObjectAI.QuietZone:
-                lastLogicalZone = oldZoneId
-                if oldZoneId == DistributedObjectAI.QuietZone:
-                    lastLogicalZone = self.lastNonQuietZone
-                self.handleLogicalZoneChange(zoneId, lastLogicalZone)
-                self.lastNonQuietZone = zoneId
-            # self.air.storeObjectLocation(self.doId, parentId, zoneId)
-            self.__location = (parentId, zoneId)
+            if ((oldParentId != parentId) or
+                (oldZoneId != zoneId)):
+                self.zoneId = zoneId
+                self.parentId = parentId
+                self.air.changeDOZoneInTables(self, zoneId, oldZoneId)
+                messenger.send(self.getZoneChangeEvent(), [zoneId, oldZoneId])
+                # if we are not going into the quiet zone, send a 'logical' zone
+                # change message
+                if zoneId != DistributedObjectAI.QuietZone:
+                    lastLogicalZone = oldZoneId
+                    if oldZoneId == DistributedObjectAI.QuietZone:
+                        lastLogicalZone = self.lastNonQuietZone
+                    self.handleLogicalZoneChange(zoneId, lastLogicalZone)
+                    self.lastNonQuietZone = zoneId
+                # self.air.storeObjectLocation(self.doId, parentId, zoneId)
+                self.__location = (parentId, zoneId)
 
         def getLocation(self):
             return self.__location