Browse Source

faster tasks and network updates from objects

Zachary Pavlov 18 years ago
parent
commit
a20301a2b5

+ 3 - 1
direct/src/distributed/DistributedObjectAI.py

@@ -329,7 +329,9 @@ class DistributedObjectAI(DistributedObjectBase, EnforcesCalldowns):
     def sendUpdate(self, fieldName, args = []):
         assert self.notify.debugStateCall(self)
         if self.air:
-            self.air.sendUpdate(self, fieldName, args)
+            dg = self.dclass.aiFormatUpdate(
+                fieldName, self.doId, self.doId, self.air.ourChannel, args)
+            self.air.sendDatagram(dg)        
 
     def GetPuppetConnectionChannel(self, doId):
         return doId + (1L << 32)

+ 2 - 2
direct/src/showbase/PythonUtil.py

@@ -3050,12 +3050,12 @@ if __debug__:
 
 def quickProfile(name="unnamed"):    
     def profileDecorator(f):
-        if(not base.config.GetBool("use-profiler",0)):
+        if(not config.GetBool("use-profiler",0)):
             return f
         def _profiled(*args, **kArgs):
             # must do this in here because we don't have base/simbase
             # at the time that PythonUtil is loaded
-            if(not base.config.GetBool("profile-debug",0)):
+            if(not config.GetBool("profile-debug",0)):
                 #dumb timings
                 st=globalClock.getRealTime()
                 f(*args,**kArgs)

+ 7 - 11
direct/src/task/Task.py

@@ -410,30 +410,26 @@ class TaskManager:
     def hasTaskNamed(self, taskName):
         # TODO: check pending task list
         # Get the tasks with this name
-        tasks = self.nameDict.get(taskName)
         # If we found some, see if any of them are still active (not removed)
-        if tasks:
-            for task in tasks:
-                if not task._removed:
-                    return 1
+        for task in self.nameDict.get(taskName, []):
+            if not task._removed:
+                return 1
         # Didnt find any, return 0
         return 0
 
     def getTasksNamed(self, taskName):
         # TODO: check pending tasks
         # Get the tasks with this name
-        tasks = self.nameDict.get(taskName, [])
-        # Filter out the tasks that have been removed
-        if tasks:
-            tasks = filter(lambda task: not task._removed, tasks)
-        return tasks
+        return [task for task in self.nameDict.get(taskName, []) #grab all tasks with name
+                   if not task._removed] #filter removed tasks
 
     def __doLaterFilter(self):
         # Filter out all the tasks that have been removed like a mark and
         # sweep garbage collector. Returns the number of tasks that have
         # been removed Warning: this creates an entirely new doLaterList.
         oldLen = len(self.__doLaterList)
-        self.__doLaterList = filter(lambda task: not task._removed, self.__doLaterList)
+        self.__doLaterList = [task for task in self.__doLaterList #grab all tasks with name
+                              if not task._removed] #filter removed tasks
         # Re heapify to maintain ordering after filter
         heapify(self.__doLaterList)
         newLen = len(self.__doLaterList)