コード例 #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.BaseStream.Length)
            {
                lastChunk = new string(reader.ReadChars(4));
                reader.AllChunkNames.Add(lastChunk);
                uint length = reader.ReadUInt32();
                reader.Position += length;
            }
            reader.LastChunkName = lastChunk;
            reader.Position      = startPos;

            // 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);
                }
            }
        }
コード例 #2
0
        internal override void UnserializeChunk(UndertaleReader reader)
        {
            Chunks.Clear();
            uint startPos = reader.Position;

            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);
                }
            }
        }