Esempio n. 1
0
        public void DeserializeStateObject(SaveState state)
        {
            bool skipReading = false;

            if (state.SaveVersion >= 21)
            {
                skipReading = state.Reader.ReadBooleanStrict();
            }

            if (skipReading)
            {
                return;
            }

            state.DeserializeObjectClassMembers(typeof(QuestSystem), this);

            // Hardcoded number of entries
            UnknownArray = new UnknownEntry[4];

            for (int i = 0; i < UnknownArray.Length; i++)
            {
                UnknownArray[i] = new UnknownEntry();

                UnknownArray[i].UnknownList = state.ReadVariableItemList((ref (BaseGGUUID GUID, List <BaseGGUUID> GUIDList)e) =>
                {
                    e.GUID     = state.ReadIndexedGUID();
                    e.GUIDList = state.ReadVariableItemList((ref BaseGGUUID GUID) =>
                    {
                        GUID = state.ReadIndexedGUID();
                    });
                });
Esempio n. 2
0
        /// <summary>
        ///     Gets the SDL2 data from a byte array buffer.
        /// </summary>
        /// <param name="Buffer">The buffer with the data</param>
        /// <returns>The SDL2 data</returns>
        public static SDL2Data GetDataFromBuffer(byte[] Buffer)
        {
            SDL2Data Output = new SDL2Data();

            using (MemoryStream SDL2 = new MemoryStream(Buffer))
            {
                EncryptedBinary Reader = new EncryptedBinary(SDL2);
                
                string Signature = Reader.ReadString(4);
                if (Signature != "SDL2") throw new Exception("SDL2 signature not found!");
                Output.Key = Reader.Key = Reader.ReadUInt32();

                ushort Table0Count = Reader.ReadUInt16XOrBE();
                ushort DialogsCount = Reader.ReadUInt16XOrBE();

                Output.Unknown = new UnknownEntry[Table0Count];

                for (int i = 0; i < Table0Count; i++)
                {
                    uint SectionBOffset = Reader.ReadUInt32XOrBE();
                    uint SectionAOffset = Reader.ReadUInt32XOrBE();
                    long Position = SDL2.Position;

                    UnknownEntry Entry = new UnknownEntry();

                    SDL2.Seek(SectionAOffset, SeekOrigin.Begin);
                    uint Entries = Reader.ReadUInt32XOrBE();
                    Entry.Values = new SectionAEntry[Entries];
                    for (int j = 0; j < Entries; j++)
                    {
                        Entry.Values[j].Value0 = Reader.ReadUInt32XOrBE();
                        Entry.Values[j].Value1 = Reader.ReadUInt32XOrBE();
                    }

                    SDL2.Seek(SectionBOffset, SeekOrigin.Begin);
                    Entry.Value0 = Reader.ReadUInt32XOrBE();
                    Entry.Value1 = Reader.ReadUInt32XOrBE();
                    Output.Unknown[i] = Entry;

                    SDL2.Seek(Position, SeekOrigin.Begin);
                }

                Output.Dialogs = new string[DialogsCount];

                for (int i = 0; i < DialogsCount; i++)
                {
                    uint DialogOffset = Reader.ReadUInt32XOrBE();
                    long Position = SDL2.Position;

                    SDL2.Seek(DialogOffset, SeekOrigin.Begin);
                    Output.Dialogs[i] = Reader.ReadUTF8();

                    SDL2.Seek(Position, SeekOrigin.Begin);
                }
            }

            return Output;
        }
Esempio n. 3
0
        public static void ReportUnknownEntry(UnknownEntry ue)
        {
            string jsonContents = MiscSerializer.Serialize(ue);
            var    contents     = new StringContent(jsonContents, Encoding.UTF8, "application/json");
            var    httpResponse = HttpClient.PostAsync(ReportUnknownEntryUrl, contents).Result;

            if (!httpResponse.IsSuccessStatusCode)
            {
                throw new DeclaratorApiException(httpResponse, "Could not report unknown entry to Declarator API");
            }
        }
        public static string Serialize(UnknownEntry ue)
        {
            var res = new JObject()
            {
                new JProperty("data", ue.Contents),
                new JProperty("content_type", ue.EntryType),
                new JProperty("file_name", ue.FileName),
                new JProperty("document_file_id", ue.DocumentFileId),
                new JProperty("row", ue.ExcelRowNumber),
                new JProperty("sheet", ue.ExcelSheetNumber),
                new JProperty("page", ue.WordPageNumber)
            };

            return(res.ToString());
        }
Esempio n. 5
0
        /// <summary>
        ///     Gets the SDL2 data from a byte array buffer.
        /// </summary>
        /// <param name="Buffer">The buffer with the data</param>
        /// <returns>The SDL2 data</returns>
        public static SDL2Data GetDataFromBuffer(byte[] Buffer)
        {
            SDL2Data Output = new SDL2Data();

            using (MemoryStream SDL2 = new MemoryStream(Buffer))
            {
                EncryptedBinary Reader = new EncryptedBinary(SDL2);

                string Signature = Reader.ReadString(4);
                if (Signature != "SDL2")
                {
                    throw new Exception("SDL2 signature not found!");
                }
                Output.Key = Reader.Key = Reader.ReadUInt32();

                ushort Table0Count  = Reader.ReadUInt16XOrBE();
                ushort DialogsCount = Reader.ReadUInt16XOrBE();

                Output.Unknown = new UnknownEntry[Table0Count];

                for (int i = 0; i < Table0Count; i++)
                {
                    uint SectionBOffset = Reader.ReadUInt32XOrBE();
                    uint SectionAOffset = Reader.ReadUInt32XOrBE();
                    long Position       = SDL2.Position;

                    UnknownEntry Entry = new UnknownEntry();

                    SDL2.Seek(SectionAOffset, SeekOrigin.Begin);
                    uint Entries = Reader.ReadUInt32XOrBE();
                    Entry.Values = new SectionAEntry[Entries];
                    for (int j = 0; j < Entries; j++)
                    {
                        Entry.Values[j].Value0 = Reader.ReadUInt32XOrBE();
                        Entry.Values[j].Value1 = Reader.ReadUInt32XOrBE();
                    }

                    SDL2.Seek(SectionBOffset, SeekOrigin.Begin);
                    Entry.Value0      = Reader.ReadUInt32XOrBE();
                    Entry.Value1      = Reader.ReadUInt32XOrBE();
                    Output.Unknown[i] = Entry;

                    SDL2.Seek(Position, SeekOrigin.Begin);
                }

                Output.Dialogs = new string[DialogsCount];

                for (int i = 0; i < DialogsCount; i++)
                {
                    uint DialogOffset = Reader.ReadUInt32XOrBE();
                    long Position     = SDL2.Position;

                    SDL2.Seek(DialogOffset, SeekOrigin.Begin);
                    Output.Dialogs[i] = Reader.ReadUTF8();

                    SDL2.Seek(Position, SeekOrigin.Begin);
                }
            }

            return(Output);
        }