示例#1
0
 /// <summary>
 /// Constructs a new Table and reads the header.
 /// </summary>
 /// <param name="reader">
 /// The SaveReader to read from. It should be positioned at the start of the table header.
 /// When the function finishes, it will point to the first entry in the entry list (see the HeaderSize constant).
 /// </param>
 public Table(SaveIO.SaveReader reader)
 {
     _name = reader.ReadAscii(0x1E);
     reader.Skip(2);  // Index of last entry - 1, not needed
     _entryCount = reader.ReadUInt16();
     _entrySize  = reader.ReadUInt16();
     reader.Skip(2 + 2 + 4); // 2 unknown uint16's + uint32 magic number
     _firstDeleted  = reader.ReadUInt16();
     _nextFree      = reader.ReadUInt16();
     _activeEntries = reader.ReadUInt16();
     _nextSalt      = reader.ReadUInt16();
     _memAddress    = reader.ReadUInt32();
 }
示例#2
0
        public void ReadFrom(SaveIO.SaveReader reader)
        {
            long baseOffset = reader.Position;

            string saveType = reader.ReadAscii(SaveTypeSize);

            if (saveType != "non compressed save")
            {
                throw new ArgumentException("Invalid save header - expected a non-compressed HCEX save");
            }
            if (reader.ReadUInt32() != Magic1)
            {
                throw new ArgumentException("Invalid save header - bad magic number 1 (expected 0x92F7E104)");
            }
            _map = reader.ReadAscii();

            reader.SeekTo(baseOffset + Magic2Offset);
            if (reader.ReadUInt32() != Magic2)
            {
                throw new ArgumentException("Invalid save header - bad magic number 2 (expected 0xDEADBEEF)");
            }
        }
示例#3
0
        /// <summary>
        /// Constructs a new Chunk object, reading header data out of a SaveReader.
        /// </summary>
        /// <param name="reader">The SaveReader to read from.</param>
        public Chunk(SaveIO.SaveReader reader, ChunkOffset offset)
        {
            long baseAddress = (long)offset;

            reader.Seek(baseAddress, SeekOrigin.Begin);

            // Read header data
            _name      = reader.ReadAscii(32);
            _entrySize = reader.ReadUInt32();
            reader.Seek(baseAddress + 0x28, SeekOrigin.Begin);
            _entryCount = reader.ReadUInt32();
            reader.Seek(baseAddress + 0x34, SeekOrigin.Begin);
            _firstDeleted  = reader.ReadUInt32();
            _nextFree      = reader.ReadUInt32();
            _activeEntries = reader.ReadUInt32();
            reader.Seek(baseAddress + 0x50, SeekOrigin.Begin);
            int entryListSize = reader.ReadInt32() - 0x54;

            _entryListStart = baseAddress + 0x54;
        }
示例#4
0
        public void ReadFrom(SaveIO.SaveReader reader)
        {
            // Ignore the CRC32 but read everything else
            reader.Skip(CRC32Size);
            _unknown        = reader.ReadUInt32();
            _cfgSize        = reader.ReadInt32();
            _dataBlock1Size = reader.ReadInt32();
            _dataBlock2Size = reader.ReadInt32();
            _saveDataSize   = reader.ReadInt32();
            if (_saveDataSize == 0)
            {
                throw new ArgumentException("The save file is empty. Please get a different save and ensure that you reach a checkpoint first.");
            }

            // Skip the CFG CRC32 and read the CFG text
            reader.Skip(CRC32Size);
            CFGText = reader.ReadAscii(_cfgSize - CRC32Size);

            // Parse the CFG data
            CFGData = new SaveCFG(CFGText);
        }