class CompressedInt32Serializer (Niantic.ARDK.Utilities.BinarySerialization.ItemSerializers.CompressedInt32Serializer)

Overview

class CompressedInt32Serializer: Niantic.ARDK.Utilities.BinarySerialization.ItemSerializers.BaseItemSerializer {
public:
    // fields

    static readonly CompressedInt32Serializer Instance = new CompressedInt32Serializer();

    // methods

    static Int32 ReadCompressedInt32(Stream stream);
    static void WriteCompressedInt32(Stream stream, Int32 value);
};

Inherited Members

public:
    // properties

    Type DataType;

    // methods

    object Deserialize(BinaryDeserializer deserializer);
    T Deserialize(BinaryDeserializer deserializer);
    void Serialize(BinarySerializer serializer, object item);
    void Serialize(BinarySerializer serializer, T item);
    T Deserialize(BinaryDeserializer deserializer);
    void Serialize(BinarySerializer serializer, T item);

Detailed Documentation

Methods

static void WriteCompressedInt32(Stream stream, Int32 value)

Writes an Int32 value in "compressed" format. This uses the UInt32 compression logic, with an extra twist. -1 has all bytes set, meaning that if we just want to use the "compression" on it, it will occupy 5 bytes. So, instead, we shift the sign bit to the right and invert all the bits when a value is negative. In this way, the values 0, -1, 1, -2, 2, -3, 3 etc are actually written as 0, 1, 2, 3, 4, 5, 6, keeping just one byte instead of 4 (no compression) or 5 (bad compression for negatives).