Пример #1
0
        private void readJsonHibernatedObjects(JToken node, ReadingOptions options)
        {
            hibernationClasses.Clear();
            hibernationIndices.Clear();
            HibernationEntries.Clear();
            JObject hibernation = node.Value <JObject>("hibernation");

            if (options.Hibernation && hibernation != null && hibernation.Type != JTokenType.Null)
            {
                hibernationV8Unknown1 = hibernation.Value <int>("v8Unknown1");
                hibernationV8Unknown2 = hibernation.Value <int>("v8Unknown2");
                hibernationV8Unknown3 = hibernation.Value <int>("v8Unknown3");
                hibernationV8Unknown4 = hibernation.Value <int>("v8Unknown4");
                hibernationUnknown1   = hibernation.Value <int>("unknown1");
                hibernationUnknown2   = hibernation.Value <int>("unknown2");

                JArray classesArray = hibernation.Value <JArray>("classes");
                if (classesArray != null)
                {
                    foreach (JToken clazz in classesArray)
                    {
                        hibernationClasses.Add(clazz.Value <string>());
                    }
                }

                JArray indicesArray = hibernation.Value <JArray>("indices");
                if (indicesArray != null)
                {
                    foreach (JToken index in indicesArray)
                    {
                        hibernationIndices.Add(index.Value <int>());
                    }
                }

                JArray entriesArray = hibernation.Value <JArray>("entries");
                if (entriesArray != null)
                {
                    foreach (JToken hibernatedObject in entriesArray)
                    {
                        HibernationEntries.Add(new HibernationEntry(hibernatedObject, options));
                    }
                }
            }
            else
            {
                hibernationV8Unknown1 = 0;
                hibernationV8Unknown2 = 0;
                hibernationV8Unknown3 = 0;
                hibernationV8Unknown4 = 0;
                hibernationUnknown1   = 0;
                hibernationUnknown2   = 0;
            }
        }
Пример #2
0
        private void readBinaryHibernation(ArkArchive archive, ReadingOptions options)
        {
            if (!options.Hibernation)
            {
                hibernationV8Unknown1 = 0;
                hibernationV8Unknown2 = 0;
                hibernationV8Unknown3 = 0;
                hibernationV8Unknown4 = 0;
                hibernationUnknown1   = 0;
                hibernationUnknown2   = 0;
                hibernationClasses.Clear();
                hibernationIndices.Clear();
                HibernationEntries.Clear();
                archive.HasUnknownData = true;
                return;
            }

            archive.Position = hibernationOffset;

            if (SaveVersion > 7)
            {
                hibernationV8Unknown1 = archive.ReadInt();
                hibernationV8Unknown2 = archive.ReadInt();
                hibernationV8Unknown3 = archive.ReadInt();
                hibernationV8Unknown4 = archive.ReadInt();
            }

            // No hibernate section if we reached the nameTable
            if (archive.Position == nameTableOffset)
            {
                return;
            }

            hibernationUnknown1 = archive.ReadInt();
            hibernationUnknown2 = archive.ReadInt();

            int hibernatedClassesCount = archive.ReadInt();

            hibernationClasses.Clear();
            hibernationClasses.Capacity = hibernatedClassesCount;
            for (int index = 0; index < hibernatedClassesCount; index++)
            {
                hibernationClasses.Add(archive.ReadString());
            }

            int hibernatedIndicesCount = archive.ReadInt();

            if (hibernatedIndicesCount != hibernatedClassesCount)
            {
                archive.DebugMessage("hibernatedClassesCount does not match hibernatedIndicesCount");
                throw new NotSupportedException();
            }

            hibernationIndices.Clear();
            hibernationIndices.Capacity = hibernatedIndicesCount;
            for (int index = 0; index < hibernatedIndicesCount; index++)
            {
                hibernationIndices.Add(archive.ReadInt());
            }

            int hibernatedObjectsCount = archive.ReadInt();

            HibernationEntries.Clear();
            HibernationEntries.Capacity = hibernatedObjectsCount;
            for (int index = 0; index < hibernatedObjectsCount; index++)
            {
                HibernationEntries.Add(new HibernationEntry(archive, options));
            }
        }