Browse Source

*** empty log message ***

Joe Shochet 24 years ago
parent
commit
160ecdf91c
3 changed files with 53 additions and 60 deletions
  1. 3 1
      direct/src/particles/Particles.py
  2. 45 50
      direct/src/showbase/Messenger.py
  3. 5 9
      direct/src/task/Task.py

+ 3 - 1
direct/src/particles/Particles.py

@@ -25,7 +25,6 @@ import SphereVolumeEmitter
 import TangentRingEmitter
 import TangentRingEmitter
 import string
 import string
 import os
 import os
-import DirectSelection
 import DirectNotifyGlobal
 import DirectNotifyGlobal
 
 
 SparkleParticleRenderer.SparkleParticleRenderer.SPNOSCALE = 0
 SparkleParticleRenderer.SparkleParticleRenderer.SPNOSCALE = 0
@@ -135,6 +134,9 @@ class Particles(ParticleSystem.ParticleSystem):
 	elif (type == "GeomParticleRenderer"):
 	elif (type == "GeomParticleRenderer"):
 	    self.renderer = GeomParticleRenderer.GeomParticleRenderer()
 	    self.renderer = GeomParticleRenderer.GeomParticleRenderer()
 	    npath = hidden.attachNewNode(NamedNode('default-geom'))
 	    npath = hidden.attachNewNode(NamedNode('default-geom'))
+            # This was moved here because we do not want to download
+            # the direct tools with toontown.
+            import DirectSelection
 	    bbox = DirectSelection.DirectBoundingBox(npath)
 	    bbox = DirectSelection.DirectBoundingBox(npath)
 	    self.renderer.setGeomNode(bbox.lines.node())
 	    self.renderer.setGeomNode(bbox.lines.node())
 	elif (type == "SparkleParticleRenderer"):
 	elif (type == "SparkleParticleRenderer"):

+ 45 - 50
direct/src/showbase/Messenger.py

@@ -37,11 +37,12 @@ class Messenger:
         to this event, otherwise it will respond only once.
         to this event, otherwise it will respond only once.
         """
         """
 
 
-        Messenger.notify.debug('object: ' + `object`
-                  + '\n now accepting: ' + `event`
-                  + '\n method: ' + `method`
-                  + '\n extraArgs: ' + `extraArgs`
-                  + '\n persistent: ' + `persistent`)
+        if Messenger.notify.getDebug():
+            Messenger.notify.debug('object: ' + `object`
+                                   + '\n now accepting: ' + `event`
+                                   + '\n method: ' + `method`
+                                   + '\n extraArgs: ' + `extraArgs`
+                                   + '\n persistent: ' + `persistent`)
             
             
         acceptorDict = ifAbsentPut(self.dict, event, {})
         acceptorDict = ifAbsentPut(self.dict, event, {})
         acceptorDict[object] = [method, extraArgs, persistent]
         acceptorDict[object] = [method, extraArgs, persistent]
@@ -51,39 +52,34 @@ class Messenger:
         Make this object no longer respond to this event.
         Make this object no longer respond to this event.
         It is safe to call even if it was not already accepting
         It is safe to call even if it was not already accepting
         """
         """
-
-        Messenger.notify.debug(`object` + '\n now ignoring: ' + `event`)
-            
-        if self.dict.has_key(event):
-            # Find the dictionary of all the objects accepting this event
-            acceptorDict = self.dict[event]
-            # If this object is there, delete it from the dictionary
-            if acceptorDict.has_key(object):
-                del acceptorDict[object]
+        if Messenger.notify.getDebug():
+            Messenger.notify.debug(`object` + '\n now ignoring: ' + `event`)
+
+        # Find the dictionary of all the objects accepting this event
+        acceptorDict = self.dict.get(event)
+        # If this object is there, delete it from the dictionary
+        if acceptorDict and acceptorDict.has_key(object):
+            del acceptorDict[object]
             # If this dictionary is now empty, remove the event
             # If this dictionary is now empty, remove the event
             # entry from the Messenger alltogether
             # entry from the Messenger alltogether
             if (len(acceptorDict) == 0):
             if (len(acceptorDict) == 0):
                 del self.dict[event]
                 del self.dict[event]
-
-
+    
     def ignoreAll(self, object):
     def ignoreAll(self, object):
         """ ignoreAll(self, DirectObject)
         """ ignoreAll(self, DirectObject)
         Make this object no longer respond to any events it was accepting
         Make this object no longer respond to any events it was accepting
         Useful for cleanup
         Useful for cleanup
         """
         """
-
-        Messenger.notify.debug(`object` + '\n now ignoring all events')
-
-        for event in self.dict.keys():
-            # Find the dictionary of all the objects accepting this event
-            acceptorDict = self.dict[event]
+        if Messenger.notify.getDebug():
+            Messenger.notify.debug(`object` + '\n now ignoring all events')
+        for event, acceptorDict in self.dict.items():
             # If this object is there, delete it from the dictionary
             # If this object is there, delete it from the dictionary
             if acceptorDict.has_key(object):
             if acceptorDict.has_key(object):
                 del acceptorDict[object]
                 del acceptorDict[object]
-            # If this dictionary is now empty, remove the event
-            # entry from the Messenger alltogether
-            if (len(acceptorDict) == 0):
-                del self.dict[event]
+                # If this dictionary is now empty, remove the event
+                # entry from the Messenger alltogether
+                if (len(acceptorDict) == 0):
+                    del self.dict[event]
 
 
 
 
     def isAccepting(self, event, object):
     def isAccepting(self, event, object):
@@ -94,7 +90,6 @@ class Messenger:
             if self.dict[event].has_key(object):
             if self.dict[event].has_key(object):
                 # Found it, return true
                 # Found it, return true
                 return 1
                 return 1
-                
         # If we looked in both dictionaries and made it here
         # If we looked in both dictionaries and made it here
         # that object must not be accepting that event.
         # that object must not be accepting that event.
         return 0
         return 0
@@ -115,31 +110,31 @@ class Messenger:
         """ send(self, string, [arg1, arg2,...])
         """ send(self, string, [arg1, arg2,...])
         Send this event, optionally passing in arguments
         Send this event, optionally passing in arguments
         """
         """
-        
         # Do not print the new frame debug, it is too noisy!
         # Do not print the new frame debug, it is too noisy!
-        if (event != 'NewFrame'):
+        if (Messenger.notify.getDebug() and (event != 'NewFrame')):
             Messenger.notify.debug('sent event: ' + event + ' sentArgs: ' + `sentArgs`)
             Messenger.notify.debug('sent event: ' + event + ' sentArgs: ' + `sentArgs`)
-
-        if self.dict.has_key(event):
-            acceptorDict = self.dict[event]
-            for object in self.dict[event].keys():
-                # We have to make this apparently redundant check, because
-                # it is possible that one object removes its own hooks
-                # in response to a handler called by a previous object.
-                if acceptorDict.has_key(object):
-                    method, extraArgs, persistent = acceptorDict[object]
-                    apply(method, (extraArgs + sentArgs))
-                    # If this object was only accepting this event once,
-                    # remove it from the dictionary
-                    if not persistent:
-                        # We need to check this because the apply above might
-                        # have done an ignore.
-                        if acceptorDict.has_key(object):
-                            del acceptorDict[object]
-                        # If the dictionary at this event is now empty, remove the event
-                        # entry from the Messenger alltogether
-                        if (self.dict.has_key(event) and (len(self.dict[event]) == 0)):
-                            del self.dict[event]
+        acceptorDict = self.dict.get(event)
+        if not acceptorDict:
+            return
+        for object in acceptorDict.keys():
+            # We have to make this apparently redundant check, because
+            # it is possible that one object removes its own hooks
+            # in response to a handler called by a previous object.
+            callList = acceptorDict.get(object)
+            if callList:
+                method, extraArgs, persistent = callList
+                apply(method, (extraArgs + sentArgs))
+                # If this object was only accepting this event once,
+                # remove it from the dictionary
+                if not persistent:
+                    # We need to check this because the apply above might
+                    # have done an ignore.
+                    if acceptorDict.has_key(object):
+                        del acceptorDict[object]
+                    # If the dictionary at this event is now empty, remove the event
+                    # entry from the Messenger alltogether
+                    if (self.dict.has_key(event) and (len(self.dict[event]) == 0)):
+                        del self.dict[event]
 
 
     def clear(self):
     def clear(self):
         """clear(self)
         """clear(self)

+ 5 - 9
direct/src/task/Task.py

@@ -316,16 +316,12 @@ class TaskManager:
             self.removeTask(task)
             self.removeTask(task)
 
 
     def removeTask(self, task):
     def removeTask(self, task):
-        if TaskManager.notify.getDebug():
-            TaskManager.notify.debug('removing task: ' + `task`)
-        removed = 0
-        try:
+        # if TaskManager.notify.getDebug():
+        #     TaskManager.notify.debug('removing task: ' + `task`)
+        if task in self.taskList:
             self.taskList.remove(task)
             self.taskList.remove(task)
-            removed = 1
-        except:
-            pass
-        if (task.uponDeath and removed):
-            task.uponDeath(task)
+            if task.uponDeath:
+                task.uponDeath(task)
 
 
     def removeTasksNamed(self, taskName):
     def removeTasksNamed(self, taskName):
         if TaskManager.notify.getDebug():
         if TaskManager.notify.getDebug():