From a480d86b6234c6fb53be21c4fa4fdd43dc806b73 Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Wed, 9 Jul 2008 01:37:58 +0000 Subject: [PATCH] asserting notify statements to clean up the game logs --- direct/src/actor/Actor.py | 2 +- direct/src/controls/ControlManager.py | 1 - .../distributed/DistributedCartesianGrid.py | 28 ++++++++++++++++++- .../src/distributed/DistributedSmoothNode.py | 6 ++-- direct/src/distributed/DoInterestManager.py | 4 +-- direct/src/task/Task.py | 4 +-- 6 files changed, 35 insertions(+), 10 deletions(-) diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py index de3bc82730..31ed9cd4b3 100644 --- a/direct/src/actor/Actor.py +++ b/direct/src/actor/Actor.py @@ -483,7 +483,7 @@ class Actor(DirectObject, NodePath): def removeNode(self): if self.__geomNode and (self.__geomNode.getNumChildren() > 0): - self.notify.warning("called actor.removeNode() on %s without calling cleanup()" % self.getName()) + assert self.notify.warning("called actor.removeNode() on %s without calling cleanup()" % self.getName()) NodePath.removeNode(self) def clearPythonData(self): diff --git a/direct/src/controls/ControlManager.py b/direct/src/controls/ControlManager.py index ba2dd1fc65..a1af67c7fd 100755 --- a/direct/src/controls/ControlManager.py +++ b/direct/src/controls/ControlManager.py @@ -22,7 +22,6 @@ class ControlManager: wantWASD = config.GetBool('want-WASD', 0) def __init__(self, enable=True, passMessagesThrough = False): - print ("init control manager %s" % (passMessagesThrough)) assert self.notify.debugCall(id(self)) self.passMessagesThrough = passMessagesThrough self.inputStateTokens = [] diff --git a/direct/src/distributed/DistributedCartesianGrid.py b/direct/src/distributed/DistributedCartesianGrid.py index 3a543a428a..e97705eafa 100755 --- a/direct/src/distributed/DistributedCartesianGrid.py +++ b/direct/src/distributed/DistributedCartesianGrid.py @@ -7,6 +7,7 @@ from direct.task import Task from direct.gui import DirectGuiGlobals from direct.showbase.EventGroup import EventGroup from direct.showbase.PythonUtil import report +from direct.distributed.GridParent import GridParent if __debug__: # For grid drawing @@ -76,6 +77,31 @@ class DistributedCartesianGrid(DistributedNode, CartesianGridBase): def getCenterPos(self): return self.centerPos + def handleChildArrive(self, child, zoneId): + DistributedNode.handleChildArrive(self, child, zoneId) + if (zoneId >= self.startingZone): + if not child.gridParent: + child.gridParent = GridParent(child) + child.gridParent.setGridParent(self, zoneId) + elif child.gridParent: + child.gridParent.delete() + child.gridParent = None + + def handleChildArriveZone(self, child, zoneId): + DistributedNode.handleChildArrive(self, child, zoneId) + if (zoneId >= self.startingZone): + if not child.gridParent: + child.gridParent = GridParent(child) + child.gridParent.setGridParent(self, zoneId) + elif child.gridParent: + child.gridParent.delete() + child.gridParent = None + + def handleChildLeave(self, child, zoneId): + if child.gridParent: + child.gridParent.delete() + child.gridParent = None + @report(types = ['deltaStamp', 'avLocation', 'args'], dConfigParam = ['want-connector-report','want-shipboard-report']) def startProcessVisibility(self, avatar): if not self._onOffState: @@ -234,7 +260,7 @@ class DistributedCartesianGrid(DistributedNode, CartesianGridBase): # zones. # Make sure this is a valid zone if not self.isValidZone(zoneId): - self.notify.warning("handleAvatarZoneChange: not a valid zone (%s)" % zoneId) + assert self.notify.warning("handleAvatarZoneChange: not a valid zone (%s)" % zoneId) return # Set the location on the server diff --git a/direct/src/distributed/DistributedSmoothNode.py b/direct/src/distributed/DistributedSmoothNode.py index cfb4af6300..66f47d5bb4 100644 --- a/direct/src/distributed/DistributedSmoothNode.py +++ b/direct/src/distributed/DistributedSmoothNode.py @@ -292,7 +292,7 @@ class DistributedSmoothNode(DistributedNode.DistributedNode, self.lastSuggestResync = realTime timestampB = globalClockDelta.localToNetworkTime(realTime) serverTime = realTime - globalClockDelta.getDelta() - self.notify.info( + assert self.notify.info( "Suggesting resync for %s, with discrepency %s; local time is %s and server time is %s." % ( self.doId, howFarFuture - chug, realTime, serverTime)) @@ -364,12 +364,12 @@ class DistributedSmoothNode(DistributedNode.DistributedNode, globalClockDelta.getUncertainty() != None: other = self.cr.doId2do.get(avId) if (not other): - self.notify.info( + assert self.notify.info( "Warning: couldn't find the avatar %d" % (avId)) elif hasattr(other, "d_returnResync"): realTime = globalClock.getRealTime() serverTime = realTime - globalClockDelta.getDelta() - self.notify.info( + assert self.notify.info( "Returning resync for %s; local time is %s and server time is %s." % ( self.doId, realTime, serverTime)) other.d_returnResync( diff --git a/direct/src/distributed/DoInterestManager.py b/direct/src/distributed/DoInterestManager.py index 30e4496b27..e5a32c8fa9 100755 --- a/direct/src/distributed/DoInterestManager.py +++ b/direct/src/distributed/DoInterestManager.py @@ -259,8 +259,8 @@ class DoInterestManager(DirectObject.DirectObject): # we're not pending a removal, but we have outstanding events? # probably we are waiting for an add/alter complete. # should we send those events now? - self.notify.warning('removeInterest: abandoning events: %s' % - intState.events) + assert self.notify.warning('removeInterest: abandoning events: %s' % + intState.events) intState.clearEvents() intState.state = InterestState.StatePendingDel contextId = self._getNextContextId() diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index 014932844a..c89cb233ae 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -505,7 +505,7 @@ class TaskManager: def doMethodLater(self, delayTime, funcOrTask, name, extraArgs=None, priority=0, uponDeath=None, appendTask=False, owner = None): if delayTime < 0: - self.notify.warning('doMethodLater: added task: %s with negative delay: %s' % (name, delayTime)) + assert self.notify.warning('doMethodLater: added task: %s with negative delay: %s' % (name, delayTime)) if isinstance(funcOrTask, Task): task = funcOrTask elif callable(funcOrTask): @@ -747,7 +747,7 @@ class TaskManager: # warn if the task took too long if self.warnTaskDuration: if dt >= self.taskDurationWarningThreshold: - TaskManager.notify.warning('task %s ran for %.2f seconds' % ( + assert TaskManager.notify.warning('task %s ran for %.2f seconds' % ( task.name, dt)) return ret