Skip to content

Support Deserialising Array3 Properties Into Arrays #12

@MarkKoz

Description

@MarkKoz

A data table stores properties of several types. One of those types is Array3. This type is distinct from the Array type and is serialised quite differently. An Array3 is actually send as a data table, with each element of the array being a property of the data table. These properties are given a name from "000" to "1023" based on their order in the corresponding array.

For example, m_hostageRescueX is an Array3 field of the class C_CS_PlayerResource. Serialisation results in a DT_CSPlayerResource data table which has a property m_hostageRescueX. That property is also a data table and contains properties like "000", "001", and so on.

Currently, the demo parser handles Array3 by flattening all the properties into the parent data table's properties. Following the above example, the result would be that DT_CSPlayerResource directly contains properties m_hostageRescueX.000, m_hostageRescueX.001, and so on. This is clumsy because there's no way to easily iterate over the properties for a specific array nor to know how many properties that array has.

Deserialising it into an array instead would be great, but it doesn't seem so simple to accomplish. First, how can the parser know it's dealing with an Array3? Currently, all it knows is that it has a data table. A possible avenue for detecting this would be checking if SendProp.m_pArrayProp is not null. Both Array and Array3 set this, but the former's m_Type is DPT_Array while the latter's is DPT_DataTable. However, m_pArrayProp is not something that's in the CSVCMsg_SendTable protobuf message.

The Source Engine has class definitions on both the server and client side. Each side has the DLL for the other, so each side has access to the class definitions in the other. The class definitions are registered into a global registry as data tables, and their fields are registered as properties of those data tables. When receiving a property, the engine can use this registry to know into which class to deserialise that property. This mechanism is likely how it can distinguish Array3 types. However, I have not figured out how exactly it goes about deserialising Array3.

Second, how can the parser actually get all the data into an array at once? The current API design requires an event handler to be attached to a property, because deserialising the values of the properties happens after the data table's metadata (such as the list of properties) is parsed. Deserialising Array is relatively simple since all its data in the stream is contiguous, but is this also the case for Array3 properties?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions