瀏覽代碼

use new dc syntax for barrier data

David Rose 21 年之前
父節點
當前提交
0184ba3609
共有 2 個文件被更改,包括 12 次插入21 次删除
  1. 6 12
      direct/src/distributed/DistributedObject.py
  2. 6 9
      direct/src/distributed/DistributedObjectAI.py

+ 6 - 12
direct/src/distributed/DistributedObject.py

@@ -301,18 +301,12 @@ class DistributedObject(PandaObject):
         # handling whatever it should handle in its current state, it
         # should call doneBarrier(), which will send the context
         # number back to the AI.
-        dg = PyDatagram(data)
-        dgi = PyDatagramIterator(dg)
-        while dgi.getRemainingSize() > 0:
-            context = dgi.getUint16()
-            numToons = dgi.getUint16()
-            for i in range(numToons):
-                avId = dgi.getUint32()
-                if avId == base.localAvatar.doId:
-                    # We found localToon's Id; stop here.
-                    self.__barrierContext = context
-                    assert(self.notify.debug('setBarrierData(%s)' % (context)))
-                    return
+        for context, avIds in data:
+            if base.localAvatar.doId in avIds:
+                # We found localToon's id; stop here.
+                self.__barrierContext = context
+                assert(self.notify.debug('setBarrierData(%s)' % (context)))
+                return
                 
         assert(self.notify.debug('setBarrierData(%s)' % (None)))
         self.__barrierContext = None

+ 6 - 9
direct/src/distributed/DistributedObjectAI.py

@@ -374,18 +374,15 @@ class DistributedObjectAI(DirectObject.DirectObject):
         return context
 
     def __getBarrierData(self):
-        # Returns the barrier data formatted as a blob for sending to
-        # the clients.  This lists all of the current outstanding
-        # barriers and the avIds waiting for them.
-        dg = PyDatagram()
+        # Returns the barrier data formatted for sending to the
+        # clients.  This lists all of the current outstanding barriers
+        # and the avIds waiting for them.
+        data = []
         for context, barrier in self.__barriers.items():
             toons = barrier.pendingToons
             if toons:
-                dg.addUint16(context)
-                dg.addUint16(len(toons))
-                for avId in toons:
-                    dg.addUint32(avId)
-        return dg.getMessage()
+                data.append((context, toons))
+        return data
 
     def ignoreBarrier(self, context):
         # Aborts a previously-set barrier.  The context is the return