예제 #1
0
        internal override void UnserializeChunk(UndertaleReader reader)
        {
            Chunks.Clear();
            uint startPos = reader.Position;

            // First, find the last chunk in the file because of padding changes
            // (also, calculate all present chunks while we're at it)
            reader.AllChunkNames = new List <string>();
            string lastChunk = "";

            while (reader.Position < reader.Length)
            {
                lastChunk = reader.ReadChars(4);
                reader.AllChunkNames.Add(lastChunk);
                uint length = reader.ReadUInt32();
                reader.SmallReadAt(reader.Position + length, 8);
            }
            reader.LastChunkName = lastChunk;
            reader.Position      = startPos;

            reader.GMS2_3 = reader.AllChunkNames.Contains("SEQN");
            reader.undertaleData.GMS2_3 = reader.GMS2_3;

            // Now, parse the chunks
            while (reader.Position < startPos + Length)
            {
                UndertaleChunk chunk = reader.ReadUndertaleChunk();
                if (chunk != null)
                {
                    if (Chunks.ContainsKey(chunk.Name))
                    {
                        throw new IOException("Duplicate chunk " + chunk.Name);
                    }
                    Chunks.Add(chunk.Name, chunk);
                }
            }
        }