示例#1
0
        public static GameVersion Deserialize(NetBuffer buffer)
        {
            GameVersionPhase phase = (GameVersionPhase)buffer.ReadByte();
            uint             major = buffer.ReadUInt32();
            uint             minor = buffer.ReadUInt32();
            char?            rev   = null;

            if (buffer.ReadBool())
            {
                rev = buffer.ReadChar();
            }

            return(new GameVersion(phase, major, minor, rev));
        }
示例#2
0
        static object ReadPrimitive(NetBuffer buffer, SnapshotPrimitiveType type)
        {
            switch (type)
            {
            case SnapshotPrimitiveType.Byte:
                return(buffer.ReadByte());

            case SnapshotPrimitiveType.Char:
                return(buffer.ReadChar());

            case SnapshotPrimitiveType.Boolean:
                return(buffer.ReadBool());

            case SnapshotPrimitiveType.Int16:
            case SnapshotPrimitiveType.SByte:     // SByte is written as a short
                return(buffer.ReadInt16());

            case SnapshotPrimitiveType.UInt16:
                return(buffer.ReadUInt16());

            case SnapshotPrimitiveType.Int32:
                return(buffer.ReadInt32());

            case SnapshotPrimitiveType.UInt32:
                return(buffer.ReadUInt32());

            case SnapshotPrimitiveType.Int64:
                return(buffer.ReadInt64());

            case SnapshotPrimitiveType.UInt64:
                return(buffer.ReadUInt64());

            case SnapshotPrimitiveType.Single:
                return(buffer.ReadFloat());

            case SnapshotPrimitiveType.Double:
                return(buffer.ReadDouble());

            case SnapshotPrimitiveType.ByteFlag:
                return(buffer.ReadByteFlag());

            default:
                throw new Exception("Snapshot primitive type '" + type + "' is not supported!");
            }
        }