Пример #1
0
        public void DeserializeExtraData(BinaryReader reader)
        {
            VertexElementCount = reader.ReadUInt32();
            uint vertexStreamCount = reader.ReadUInt32();

            IsStreaming = reader.ReadBooleanStrict();

            Streams = new VertexStream[vertexStreamCount];

            for (int i = 0; i < Streams.Length; i++)
            {
                var stream = new VertexStream();
                Streams[i] = stream;

                stream.Flags = reader.ReadUInt32();
                uint vertexByteStride = reader.ReadUInt32();
                stream.UnknownData = new byte[reader.ReadUInt32()][];

                for (uint j = 0; j < stream.UnknownData.Length; j++)
                {
                    // 4 bytes read separately
                    stream.UnknownData[j] = reader.ReadBytesStrict(4);
                }

                stream.GUID   = GGUUID.FromData(reader);
                stream.Buffer = HwBuffer.FromVertexData(reader, IsStreaming, vertexByteStride, VertexElementCount);
            }
        }
        public void DeserializeExtraData(BinaryReader reader)
        {
            uint vertexElementCount = reader.ReadUInt32();
            uint vertexStreamCount  = reader.ReadUInt32();
            bool isStreaming        = reader.ReadBooleanStrict();

            ResourceGUIDs = new GGUUID[vertexStreamCount];
            Buffers       = new HwBuffer[vertexStreamCount];

            for (uint i = 0; i < Buffers.Length; i++)
            {
                uint unknownFlags     = reader.ReadUInt32();
                uint vertexByteStride = reader.ReadUInt32();
                uint unknownCounter   = reader.ReadUInt32();

                for (uint j = 0; j < unknownCounter; j++)
                {
                    // 4 bytes read separately
                    var packedData = reader.ReadBytesStrict(4);
                }

                ResourceGUIDs[i] = GGUUID.FromData(reader);
                Buffers[i]       = HwBuffer.FromVertexData(reader, isStreaming, vertexByteStride, vertexElementCount);
            }
        }
Пример #3
0
        public void ReadSave(SaveState state)
        {
            if (state.SaveVersion < 26)
            {
                int count = state.ReadVariableLengthOffset();

                OverlayBitmapData = state.Reader.ReadBytesStrict(count);
            }
            else
            {
                OverlayBitmapData = new byte[65536];

                for (int offset = 0; offset < OverlayBitmapData.Length;)
                {
                    int  size       = state.ReadVariableLengthInt();
                    byte visibility = state.Reader.ReadByte();

                    for (int i = offset; i < (offset + size); i++)
                    {
                        OverlayBitmapData[i] = visibility;
                    }

                    offset += size;
                }
            }

            bool unknown = state.Reader.ReadBooleanStrict();

            if (unknown)
            {
                UnknownData = state.Reader.ReadBytesStrict(24);
                UnknownGUID = state.ReadIndexedGUID();
            }
        }
        public void Deserialize(BinaryReader reader)
        {
            Type = (Types)reader.ReadByte();

            switch (Type)
            {
            case Types.Null:
                break;

            case Types.LocalCoreUUID:
            case Types.UUIDRef:
                GUID = GGUUID.FromData(reader);
                break;

            case Types.ExternalCoreUUID:
            case Types.StreamingRef:
                GUID = GGUUID.FromData(reader);

                // This could be a Filename instance - no way to determine the type
                ExternalFile = new String();
                ExternalFile.Deserialize(reader);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Пример #5
0
        public static GGUUID FromData(ReadOnlySpan <byte> data)
        {
            var x = new GGUUID();

            x.AssignFromData(data);

            return(x);
        }
Пример #6
0
        public void DeserializeStateObject(SaveState state)
        {
            // NOTE: There's a flaw in their serialization code. RewindCounter will occasionally have invalid values (non-0/1) which breaks
            // some type checking assumptions. Fields are also out of order. I guess this has to be done manually now.
            int unusedTypeIndex = state.ReadVariableLengthInt();

            QuestResourceUUID = state.ReadIndexedGUID();
            State             = (EQuestState)state.Reader.ReadInt32();
            Tracked           = state.Reader.ReadBooleanStrict();
            TrackingEnabled   = state.Reader.ReadBooleanStrict();
            StartTime         = state.ReadVariableLengthInt();
            LastProgressTime  = state.ReadVariableLengthInt();
            RunState          = (EQuestRunState)state.Reader.ReadSByte();
            RewindCounter     = state.Reader.ReadByte() > 0;//RewindCounter = state.Reader.ReadBooleanStrict();
            Version           = state.ReadVariableLengthInt();
        }
Пример #7
0
        public void DeserializeExtraData(BinaryReader reader)
        {
            Header = new TextureHeader();

            // 32 byte texture header
            Header.Type   = (ETextureType)reader.ReadByte(); // 0
            _             = reader.ReadByte();               // 1
            Header.Width  = reader.ReadUInt16();             // 2
            Header.Height = reader.ReadUInt16();             // 4

            Header.TexArraySliceCount = 1;
            Header.Tex3DDepth         = 1;

            switch (Header.Type)
            {
            case ETextureType._2D:
            case ETextureType.CubeMap:
                _ = reader.ReadUInt16();
                break;

            case ETextureType._3D:
                Header.Tex3DDepth = 1u << reader.ReadByte();
                _ = reader.ReadByte();
                break;

            case ETextureType._2DArray:
                Header.TexArraySliceCount = reader.ReadUInt16();
                break;

            default:
                throw new NotImplementedException("Unknown texture type");
            }

            Header.MipCount     = reader.ReadByte();                // 8
            Header.PixelFormat  = (EPixelFormat)reader.ReadByte();  // 9
            Header.Unknown1     = reader.ReadByte();                // 10
            Header.Unknown2     = reader.ReadByte();                // 11
            Header.Unknown3     = reader.ReadByte();                // 12
            Header.Flags        = reader.ReadByte();                // 13
            Header.Unknown4     = reader.ReadByte();                // 14 Something to do with mips. Autogen?
            Header.Unknown5     = reader.ReadByte();                // 15
            Header.ResourceGUID = GGUUID.FromData(reader);          // 16

            uint hwTextureSize = reader.ReadUInt32();

            HwTextureData = reader.ReadBytesStrict(hwTextureSize);
        }
Пример #8
0
        public void DeserializeExtraData(BinaryReader reader)
        {
            // 32 byte texture header
            var textureType = (ETextureType)reader.ReadByte();  // 0

            _ = reader.ReadByte();                              // 1
            ushort width  = reader.ReadUInt16();                // 2
            ushort height = reader.ReadUInt16();                // 4

            uint texArraySliceCount = 1;
            uint tex3DDepth         = 1;

            switch (textureType)
            {
            case ETextureType._2D:
            case ETextureType.CubeMap:
                _ = reader.ReadUInt16();
                break;

            case ETextureType._3D:
                tex3DDepth = 1u << reader.ReadByte();
                _          = reader.ReadByte();
                break;

            case ETextureType._2DArray:
                texArraySliceCount = reader.ReadUInt16();
                break;

            default:
                throw new NotImplementedException("Unknown texture type");
            }

            byte mipCount    = reader.ReadByte();                   // 8
            var  pixelFormat = (EPixelFormat)reader.ReadByte();     // 9
            byte unknown2    = reader.ReadByte();                   // 10
            byte unknown3    = reader.ReadByte();                   // 11
            byte unknown4    = reader.ReadByte();                   // 12
            byte flags       = reader.ReadByte();                   // 13
            byte unknown6    = reader.ReadByte();                   // 14 Something to do with mips
            byte unknown7    = reader.ReadByte();                   // 15

            ResourceGUID = GGUUID.FromData(reader);                 // 16

            uint hwTextureSize = reader.ReadUInt32();
            var  hwTextureData = reader.ReadBytesStrict(hwTextureSize);
        }
        public void DeserializeExtraData(BinaryReader reader)
        {
            uint indexElementCount = reader.ReadUInt32();

            if (indexElementCount > 0)
            {
                Flags = reader.ReadUInt32();
                var  format      = (EIndexFormat)reader.ReadUInt32();
                uint isStreaming = reader.ReadUInt32();

                if (isStreaming != 0 && isStreaming != 1)
                {
                    throw new InvalidDataException("Must be true or false");
                }

                ResourceGUID = GGUUID.FromData(reader);
                Buffer       = HwBuffer.FromIndexData(reader, format, isStreaming != 0, indexElementCount);
            }
        }
Пример #10
0
 private void AssignFromOther(GGUUID other)
 {
     // No unions. No marshalling. Assign each manually...
     Data0  = other.Data0;
     Data1  = other.Data1;
     Data2  = other.Data2;
     Data3  = other.Data3;
     Data4  = other.Data4;
     Data5  = other.Data5;
     Data6  = other.Data6;
     Data7  = other.Data7;
     Data8  = other.Data8;
     Data9  = other.Data9;
     Data10 = other.Data10;
     Data11 = other.Data11;
     Data12 = other.Data12;
     Data13 = other.Data13;
     Data14 = other.Data14;
     Data15 = other.Data15;
 }