HeapsIO / hxbit

Haxe Binary serialization and network synchronization library
155 stars 30 forks source link

Add __net_bit_fieldName to NetworkSerializables #75

Closed Speedphoenix closed 2 months ago

Speedphoenix commented 2 months ago

Sometimes you need to do something like

@:s @:condSend(specialCondition()) var fieldName;

override function networkAllow(mode, prop, client) {
    if (!specialCondition()) {
        if (mode == SetField && propIsFieldName(prop))
            return true;
    }
    return super.networkAllow(mode, prop, client);
}

Where the condition is specific enough that you wouldn't want to add a meta and a custom getter just for that one field.

This PR allows doing prop == __net_bit_fieldName instead of networkGetName and a String comparison every time

ncannasse commented 2 months ago

This already exists and is called networkPropFieldName ;)