From fb6e53b57dc685a96e6d085dcea0a611dfd48bdc Mon Sep 17 00:00:00 2001 From: Roger Hughston Date: Thu, 22 Jun 2006 00:31:10 +0000 Subject: [PATCH] Add multi field update to the dcclass parser --- direct/src/dcparser/dcClass.cxx | 70 +++++++++++++++++++++++++-------- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 3f97074196..465d936d40 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/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 " "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 class SortFieldsByIndex { @@ -469,25 +474,58 @@ receive_update(PyObject *distobj, DatagramIterator &di) const { #ifdef WITHIN_PANDA PStatTimer timer(((DCClass *)this)->_class_update_pcollector); #endif - DCPacker packer; - packer.set_unpack_data(di.get_remaining_bytes()); + if(dc_update_multifield) + { + while(di.get_remaining_size() > 0) + { - 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; - } + DCPacker packer; + packer.set_unpack_data(di.get_remaining_bytes()); - packer.begin_unpack(field); - field->receive_update(packer, distobj); - packer.end_unpack(); - di.skip_bytes(packer.get_num_unpacked_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; + } + + packer.begin_unpack(field); + field->receive_update(packer, distobj); + packer.end_unpack(); + + di.skip_bytes(packer.get_num_unpacked_bytes()); + } + } #endif // HAVE_PYTHON