mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-05 11:28:17 -04:00
Add multi field update to the dcclass parser
This commit is contained in:
parent
f27cf426e1
commit
fb6e53b57d
@ -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,9 +474,15 @@ 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
|
||||||
|
if(dc_update_multifield)
|
||||||
|
{
|
||||||
|
while(di.get_remaining_size() > 0)
|
||||||
|
{
|
||||||
|
|
||||||
DCPacker packer;
|
DCPacker packer;
|
||||||
packer.set_unpack_data(di.get_remaining_bytes());
|
packer.set_unpack_data(di.get_remaining_bytes());
|
||||||
|
|
||||||
|
|
||||||
int field_id = packer.raw_unpack_uint16();
|
int field_id = packer.raw_unpack_uint16();
|
||||||
DCField *field = get_field_by_index(field_id);
|
DCField *field = get_field_by_index(field_id);
|
||||||
if (field == (DCField *)NULL) {
|
if (field == (DCField *)NULL) {
|
||||||
@ -489,6 +500,33 @@ receive_update(PyObject *distobj, DatagramIterator &di) const {
|
|||||||
|
|
||||||
di.skip_bytes(packer.get_num_unpacked_bytes());
|
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
|
#endif // HAVE_PYTHON
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
|
Loading…
x
Reference in New Issue
Block a user