fixed door-not-opening bug

This commit is contained in:
Darren Ranalli 2004-02-05 23:59:44 +00:00
parent 46f98ca7c3
commit ec3bb127cd
2 changed files with 56 additions and 43 deletions

View File

@ -23,7 +23,6 @@ class DistributedLevel(DistributedObject.DistributedObject,
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLevel') notify = DirectNotifyGlobal.directNotify.newCategory('DistributedLevel')
WantVisibility = config.GetBool('level-visibility', 1) WantVisibility = config.GetBool('level-visibility', 1)
HideZones = config.GetBool('level-hidezones', 1)
# set this to true to get all distrib objs when showing hidden zones # set this to true to get all distrib objs when showing hidden zones
ColorZonesAllDOs = 0 ColorZonesAllDOs = 0
@ -435,7 +434,7 @@ class DistributedLevel(DistributedObject.DistributedObject,
self.curZoneNum = None self.curZoneNum = None
self.visChangedThisFrame = 0 self.visChangedThisFrame = 0
self.sentFirstSetZone = 0 self.fForceSetZoneThisFrame = 0
# listen for camera-ray/floor collision events # listen for camera-ray/floor collision events
def handleCameraRayFloorCollision(collEntry, self=self): def handleCameraRayFloorCollision(collEntry, self=self):
@ -457,6 +456,8 @@ class DistributedLevel(DistributedObject.DistributedObject,
if not DistributedLevel.WantVisibility: if not DistributedLevel.WantVisibility:
zoneNums = list(self.zoneNums) zoneNums = list(self.zoneNums)
zoneNums.remove(LevelConstants.UberZoneEntId) zoneNums.remove(LevelConstants.UberZoneEntId)
# make sure a setZone goes out on the first frame
self.forceSetZoneThisFrame()
self.setVisibility(zoneNums) self.setVisibility(zoneNums)
# send out any zone changes at the end of the frame, just before # send out any zone changes at the end of the frame, just before
@ -579,10 +580,8 @@ class DistributedLevel(DistributedObject.DistributedObject,
# this flag will prevent a network msg from being sent if # this flag will prevent a network msg from being sent if
# the list of visible zones has not changed # the list of visible zones has not changed
vizZonesChanged = 1 vizZonesChanged = 1
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 'x in dict' is faster than 'x in list'
# than 'x in list'
addedZoneNums = [] addedZoneNums = []
removedZoneNums = [] removedZoneNums = []
allVZ = dict(visibleZoneNums) allVZ = dict(visibleZoneNums)
@ -615,9 +614,9 @@ class DistributedLevel(DistributedObject.DistributedObject,
# it's important for us to send a setZone request on the first # it's important for us to send a setZone request on the first
# frame, whether or not the visibility is different from what # frame, whether or not the visibility is different from what
# we already have # we already have
if vizZonesChanged or not self.sentFirstSetZone: if vizZonesChanged or self.fForceSetZoneThisFrame:
self.setVisibility(visibleZoneNums.keys()) self.setVisibility(visibleZoneNums.keys())
self.sentFirstSetZone = 1 self.fForceSetZoneThisFrame = 0
self.curZoneNum = zoneNum self.curZoneNum = zoneNum
self.curVisibleZoneNums = visibleZoneNums self.curVisibleZoneNums = visibleZoneNums
@ -660,10 +659,14 @@ class DistributedLevel(DistributedObject.DistributedObject,
Level.Level.handleVisChange(self) Level.Level.handleVisChange(self)
self.visChangedThisFrame = 1 self.visChangedThisFrame = 1
def forceSetZoneThisFrame(self):
# call this to ensure that a setZone call will be generated this frame
self.fForceSetZoneThisFrame = 1
def visChangeTask(self, task): def visChangeTask(self, task):
# this runs just before igloop; if viz lists have changed # this runs just before igloop; if viz lists have changed
# this frame, updates the visibility and sends out a setZoneMsg # this frame, updates the visibility and sends out a setZoneMsg
if self.visChangedThisFrame: if self.visChangedThisFrame or self.fForceSetZoneThisFrame:
self.updateVisibility() self.updateVisibility()
self.visChangedThisFrame = 0 self.visChangedThisFrame = 0
return Task.cont return Task.cont

View File

@ -22,21 +22,31 @@ class VisibilityBlocker:
will be called when it's safe to show the new zones.""" will be called when it's safe to show the new zones."""
if self.__nextSetZoneDoneEvent is None: if self.__nextSetZoneDoneEvent is None:
self.__nextSetZoneDoneEvent = self.level.cr.getNextSetZoneDoneEvent() self.__nextSetZoneDoneEvent = self.level.cr.getNextSetZoneDoneEvent()
self.accept(self.__nextSetZoneDoneEvent, self.okToUnblockVis) self.acceptOnce(self.__nextSetZoneDoneEvent, self.okToUnblockVis)
# make sure that a setZone is sent this frame, even if the
# visibility list doesn't change
self.level.forceSetZoneThisFrame()
def cancelUnblockVis(self): def cancelUnblockVis(self):
"""derived class should call this if they have called requestUnblockVis, """
but no longer need that service. For example the user could have canceled derived class should call this if they have called
the request that started the visibility change.""" requestUnblockVis, but no longer need that service. For example
the user could have canceled the request that started the
visibility change.
"""
if self.__nextSetZoneDoneEvent is not None: if self.__nextSetZoneDoneEvent is not None:
self.ignore(self.__nextSetZoneDoneEvent) self.ignore(self.__nextSetZoneDoneEvent)
self.__nextSetZoneDoneEvent = None self.__nextSetZoneDoneEvent = None
def isWaitingForUnblockVis(self): def isWaitingForUnblockVis(self):
"""returns a boolean for whether there is a requestUnblockVis() pending.""" """
returns a boolean for whether there is a requestUnblockVis() pending.
"""
return self.__nextSetZoneDoneEvent is not None return self.__nextSetZoneDoneEvent is not None
def okToUnblockVis(self): def okToUnblockVis(self):
"""derived class should override this func and do the vis unblock """
(i.e. open the door, etc.)""" derived class should override this func and do the vis unblock
(i.e. open the door, etc.)
"""
self.cancelUnblockVis() self.cancelUnblockVis()