コード例 #1
0
//
// read_network_attributes
//
void ClientSidePrediction::read_network_attributes(Serializable& object, Deserializer& source)
{
    const auto attributes = object.GetNetworkAttributes();
    if (!attributes)
        return;

    unsigned numAttributes = attributes->Size();

    for (unsigned i = 0; i < numAttributes && !source.IsEof(); ++i)
    {
        const auto& attr = attributes->At(i);
        object.OnSetAttribute(attr, source.ReadVariant(attr.type_));
    }
}
コード例 #2
0
//
// write_network_attributes
//
void ClientSidePrediction::write_network_attributes(Serializable& object, Serializer& dest)
{
    const auto attributes = object.GetNetworkAttributes();
    if (!attributes)
        return;

    auto numAttributes = attributes->Size();
    Variant value;

    for (unsigned i = 0; i < numAttributes; ++i)
    {
        const auto& attr = attributes->At(i);
        value.Clear();
        object.OnGetAttribute(attr, value);
        dest.WriteVariantData(value);
    }
}