Browse Source

another round of test fixes

David Rose 21 years ago
parent
commit
9fcb8cf159

+ 19 - 0
direct/src/distributed/ClientRepository.py

@@ -723,6 +723,25 @@ class ClientRepository(ConnectionRepository.ConnectionRepository):
         # send the message
         self.send(datagram)
 
+    def getObjectsOfClass(self, objClass):
+        """ returns dict of doId:object, containing all objects
+        that inherit from 'class'. returned dict is safely mutable. """
+        doDict = {}
+        for doId, do in self.doId2do.items():
+            if isinstance(do, objClass):
+                doDict[doId] = do
+        return doDict
+
+    def getObjectsOfExactClass(self, objClass):
+        """ returns dict of doId:object, containing all objects that
+        are exactly of type 'class' (neglecting inheritance). returned
+        dict is safely mutable. """
+        doDict = {}
+        for doId, do in self.doId2do.items():
+            if do.__class__ == objClass:
+                doDict[doId] = do
+        return doDict
+
     if wantOtpServer:
         def sendEmulateSetZone(self, zoneId, visibleZoneList=None, parentIdin=None, event=None):
             """

+ 1 - 1
direct/src/distributed/DistributedObject.py

@@ -350,7 +350,7 @@ class DistributedObject(PandaObject):
         # which means the client created it instead of the AI, and it
         # gets some other special handling.  Normally, only the local
         # avatar class overrides this to return true.
-        return (self.cr.isLocalId(self.doId))
+        return self.cr and self.cr.isLocalId(self.doId)
 
     def updateZone(self, zoneId):
         self.cr.sendUpdateZone(self, zoneId)

+ 1 - 1
direct/src/distributed/DistributedSmoothNode.py

@@ -121,7 +121,7 @@ class DistributedSmoothNode(DistributedNode.DistributedNode,
         running, you won't be able to lerp the node or directly
         position it.
         """
-        if not self.wantsSmoothing() or self.isLocal() or self.isDisabled():
+        if not self.wantsSmoothing() or self.isDisabled() or self.isLocal():
             return
         if not self.smoothStarted:
             taskName = self.taskName("smooth")