From 7e8448cff283140d8a8588a1273d1d3b77414faa Mon Sep 17 00:00:00 2001 From: Samir Naik Date: Tue, 15 Mar 2005 23:18:54 +0000 Subject: [PATCH] make sure we dont do setLocation work if unnecessary --- direct/src/distributed/DistributedObjectAI.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/direct/src/distributed/DistributedObjectAI.py b/direct/src/distributed/DistributedObjectAI.py index c10f0b5544..cf40ffc7b4 100644 --- a/direct/src/distributed/DistributedObjectAI.py +++ b/direct/src/distributed/DistributedObjectAI.py @@ -20,6 +20,9 @@ class DistributedObjectAI(DirectObject.DirectObject): self.accountName='' # Record the repository self.air = air + # Record our parentId and zoneId + self.__location = None + # Record our distributed class className = self.__class__.__name__ self.dclass = self.air.dclassesByName[className] @@ -140,9 +143,13 @@ class DistributedObjectAI(DirectObject.DirectObject): self.air.addInterest(self.getDoId(), zoneId, note, event) 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): return self.__location