demoinfocs-golang icon indicating copy to clipboard operation
demoinfocs-golang copied to clipboard

Proper support for polymorphic fields

Open markus-wa opened this issue 1 year ago • 1 comments
trafficstars

Follow up from #501

My hunch is that it has something to do with this:

message ProtoFlattenedSerializerField_t { message polymorphic_field_t { optional int32 polymorphic_field_serializer_name_sym = 1; optional int32 polymorphic_field_serializer_version = 2; }

optional int32 var_type_sym = 1; optional int32 var_name_sym = 2; optional int32 bit_count = 3; optional float low_value = 4; optional float high_value = 5; optional int32 encode_flags = 6; optional int32 field_serializer_name_sym = 7; optional int32 field_serializer_version = 8; optional int32 send_node_sym = 9; optional int32 var_encoder_sym = 10; repeated .ProtoFlattenedSerializerField_t.polymorphic_field_t polymorphic_types = 11; } Polymorphic fields are there for 8 months now, and in my parser (clarity) I made a weird fix for a pointer field which had a few bits I could not understand.

From a first glance, you also do not support polymorphic fields.

Now they start to use it, and this breaks it.

polymorphic pointers are indeed a thing. There is one entity in the replay I have here CCSGameModeRules, which uses it When you decode a polymorphic pointer (if it is enabled, you can read a ubitvar (I think) to get the type it is referencing

Well, I would still recommend to look into polymorphic fields. It got rid of this nasty workaround:

https://github.com/skadistats/clarity/blob/5cce7dc88f6718bac3293c3be883819c6fc3f609/src/main/java/skadistats/clarity/io/s2/field/PointerField.java#L17-L21

https://github.com/skadistats/clarity/blob/5cce7dc88f6718bac3293c3be883819c6fc3f609/src/main/java/skadistats/clarity/io/decoder/GameRulesModeFixDecoder.java

The six bits are the polymorphic type of the field (as ubitvar, so it might be even more bits in other replays).

markus-wa avatar Feb 09 '24 13:02 markus-wa

This is how I implemented it:

https://github.com/skadistats/clarity/commit/ef98dbc5d066500457dd59cd44f319d40ce80951

spheenik avatar Feb 09 '24 15:02 spheenik