From 0b3f17397b451291cb1d544835938f046623f99b Mon Sep 17 00:00:00 2001 From: Joe Shochet Date: Wed, 16 Mar 2005 00:05:16 +0000 Subject: [PATCH] guard for calling setLocation twice --- direct/src/distributed/DistributedObjectAI.py | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/direct/src/distributed/DistributedObjectAI.py b/direct/src/distributed/DistributedObjectAI.py index c05f037150..c9ed519d2a 100644 --- a/direct/src/distributed/DistributedObjectAI.py +++ b/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