pkt: fix conditional streaming

isolation_bkp/dynres
Dominik Madarász 2021-08-09 15:57:56 +02:00
parent 999763f197
commit c28925cc07
2 changed files with 5 additions and 6 deletions

View File

@ -4,16 +4,15 @@
ZPL_TABLE_DEFINE(entity_view_tbl, entity_view_tbl_, entity_view);
// TODO(zaklaus): Fix conditional streaming
pkt_desc pkt_entity_view_desc[] = {
{ PKT_UINT(entity_view, kind) },
{ PKT_UINT(entity_view, flag) },
{ PKT_HALF(entity_view, x) },
{ PKT_HALF(entity_view, y) },
//{ PKT_SKIP_IF(entity_view, blocks_used, 1, 2) }, // NOTE(zaklaus): skip velocity for chunks
{ PKT_SKIP_IF(entity_view, blocks_used, 1, 2) }, // NOTE(zaklaus): skip velocity for chunks
{ PKT_HALF(entity_view, vx) },
{ PKT_HALF(entity_view, vy) },
//{ PKT_SKIP_IF(entity_view, blocks_used, 0, 1) }, // NOTE(zaklaus): skip blocks for anything else
{ PKT_SKIP_IF(entity_view, blocks_used, 0, 1) }, // NOTE(zaklaus): skip blocks for anything else
{ PKT_ARRAY(entity_view, blocks) },
{ PKT_HALF(entity_view, hp) },
{ PKT_HALF(entity_view, max_hp) },

View File

@ -64,7 +64,7 @@ int32_t pkt_unpack_struct(cw_unpack_context *uc, pkt_desc *desc, void *raw_blob,
uint8_t *blob = (uint8_t*)raw_blob;
for (pkt_desc *field = desc; field->type != CWP_NOT_AN_ITEM; ++field) {
cw_unpack_next(uc);
if (field->skip_count) {
if (field->skip_count != 0) {
if (uc->item.type != CWP_ITEM_POSITIVE_INTEGER) return -1; // unexpected field
field += uc->item.as.u64;
continue;
@ -104,11 +104,11 @@ int32_t pkt_unpack_struct(cw_unpack_context *uc, pkt_desc *desc, void *raw_blob,
int32_t pkt_pack_struct(cw_pack_context *pc, pkt_desc *desc, void *raw_blob, uint32_t blob_size) {
uint8_t *blob = (uint8_t*)raw_blob;
for (pkt_desc *field = desc; field->type != CWP_NOT_AN_ITEM; ++field) {
if (field->skip_count) {
if (field->skip_count != 0) {
uint8_t val = *(uint8_t*)(blob + field->offset);
if (val == field->skip_eq) {
field += field->skip_count;
cw_pack_unsigned(pc, field->skip_count);
field += field->skip_count;
} else {
cw_pack_unsigned(pc, 0);
}