Browse Source

don't send setZone msg if viz has not changed

Darren Ranalli 22 years ago
parent
commit
3576ea4cc9
1 changed files with 22 additions and 10 deletions
  1. 22 10
      direct/src/level/DistributedLevel.py

+ 22 - 10
direct/src/level/DistributedLevel.py

@@ -574,7 +574,10 @@ class DistributedLevel(DistributedObject.DistributedObject,
 
 
         # we should not have the uberZone in the list at this point
         # we should not have the uberZone in the list at this point
         assert not LevelConstants.UberZoneEntId in visibleZoneNums
         assert not LevelConstants.UberZoneEntId in visibleZoneNums
-        
+
+        # this flag will prevent a network msg from being sent if
+        # the list of visible zones has not changed
+        vizZonesChanged = 1
         if DistributedLevel.HideZones:
         if DistributedLevel.HideZones:
             # figure out which zones are new and which are going invisible
             # figure out which zones are new and which are going invisible
             # use dicts because it's faster to use dict.has_key(x)
             # use dicts because it's faster to use dict.has_key(x)
@@ -592,15 +595,24 @@ class DistributedLevel(DistributedObject.DistributedObject,
                     addedZoneNums.append(vz)
                     addedZoneNums.append(vz)
                 else:
                 else:
                     removedZoneNums.append(vz)
                     removedZoneNums.append(vz)
-            # show the new, hide the old
-            DistributedLevel.notify.info('showing zones %s' % addedZoneNums)
-            for az in addedZoneNums:
-                self.showZone(az)
-            DistributedLevel.notify.info('hiding zones %s' % removedZoneNums)
-            for rz in removedZoneNums:
-                self.hideZone(rz)
-
-        self.setVisibility(visibleZoneNums.keys())
+
+            if (not addedZoneNums) and (not removedZoneNums):
+                DistributedLevel.notify.info(
+                    'visible zone list has not changed')
+                vizZonesChanged = 0
+            else:
+                # show the new, hide the old
+                DistributedLevel.notify.info('showing zones %s' %
+                                             addedZoneNums)
+                for az in addedZoneNums:
+                    self.showZone(az)
+                DistributedLevel.notify.info('hiding zones %s' %
+                                             removedZoneNums)
+                for rz in removedZoneNums:
+                    self.hideZone(rz)
+
+        if vizZonesChanged:
+            self.setVisibility(visibleZoneNums.keys())
 
 
         self.curZoneNum = zoneNum
         self.curZoneNum = zoneNum
         self.curVisibleZoneNums = visibleZoneNums
         self.curVisibleZoneNums = visibleZoneNums