浏览代码

Add multi field update to the dcclass parser

Roger Hughston 19 年之前
父节点
当前提交
fb6e53b57d
共有 1 个文件被更改,包括 54 次插入16 次删除
  1. 54 16
      direct/src/dcparser/dcClass.cxx

+ 54 - 16
direct/src/dcparser/dcClass.cxx

@@ -56,6 +56,11 @@ ConfigVariableBool dc_sort_inheritance_by_file
           "rather than based on the order in which the references are made "
           "rather than based on the order in which the references are made "
           "within the class."));
           "within the class."));
 
 
+
+ConfigVariableBool dc_update_multifield
+("dc-update-multifield", false,
+ PRC_DESC("Set this true to support Multiple updates in a field update"));
+
 #endif  // WITHIN_PANDA
 #endif  // WITHIN_PANDA
 
 
 class SortFieldsByIndex {
 class SortFieldsByIndex {
@@ -469,25 +474,58 @@ receive_update(PyObject *distobj, DatagramIterator &di) const {
 #ifdef WITHIN_PANDA
 #ifdef WITHIN_PANDA
   PStatTimer timer(((DCClass *)this)->_class_update_pcollector);
   PStatTimer timer(((DCClass *)this)->_class_update_pcollector);
 #endif
 #endif
-  DCPacker packer;
-  packer.set_unpack_data(di.get_remaining_bytes());
+    if(dc_update_multifield)
+    {
+        while(di.get_remaining_size() > 0)
+        {
+
+            DCPacker packer;
+            packer.set_unpack_data(di.get_remaining_bytes());
+
+
+            int field_id = packer.raw_unpack_uint16();
+            DCField *field = get_field_by_index(field_id);
+            if (field == (DCField *)NULL) {
+                ostringstream strm;
+                strm
+                    << "Received update for field " << field_id << ", not in class "
+                    << get_name();
+                nassert_raise(strm.str());
+                return;
+            }
+
+            packer.begin_unpack(field);
+            field->receive_update(packer, distobj);
+            packer.end_unpack();
+
+            di.skip_bytes(packer.get_num_unpacked_bytes());
+        }
+    }
+    else
+    {
+
+        DCPacker packer;
+        packer.set_unpack_data(di.get_remaining_bytes());
+
+
+        int field_id = packer.raw_unpack_uint16();
+        DCField *field = get_field_by_index(field_id);
+        if (field == (DCField *)NULL) {
+            ostringstream strm;
+            strm
+                << "Received update for field " << field_id << ", not in class "
+                << get_name();
+            nassert_raise(strm.str());
+            return;
+        }
 
 
-  int field_id = packer.raw_unpack_uint16();
-  DCField *field = get_field_by_index(field_id);
-  if (field == (DCField *)NULL) {
-    ostringstream strm;
-    strm
-      << "Received update for field " << field_id << ", not in class "
-      << get_name();
-    nassert_raise(strm.str());
-    return;
-  }
+        packer.begin_unpack(field);
+        field->receive_update(packer, distobj);
+        packer.end_unpack();
 
 
-  packer.begin_unpack(field);
-  field->receive_update(packer, distobj);
-  packer.end_unpack();
+        di.skip_bytes(packer.get_num_unpacked_bytes());
+    }
 
 
-  di.skip_bytes(packer.get_num_unpacked_bytes());
 }
 }
 #endif  // HAVE_PYTHON
 #endif  // HAVE_PYTHON