void ReadRawData() { MemoryStream stream = new MemoryStream(RawData); BinaryReader reader = new BinaryReader(stream, Encoding.UTF8); // Read Version - must be 0x126 Version = reader.ReadInt32(); if (Version != VersionNumber) { throw new Exception("SaveTree file has an invalid version number, must be 0x126."); } // Read character position. A character position record later in the file (record type 0x04) is used for positioning the player, not this. // Currently not clear what classic uses this one for. CharacterPosition = new HeaderCharacterPositionRecord(); CharacterPosition.Position = SaveTree.ReadPosition(reader); // Read MapID MapID = reader.ReadUInt16(); // Read Environment Environment = reader.ReadByte(); reader.Close(); }
void ReadRecordRoot() { MemoryStream stream = new MemoryStream(streamData); BinaryReader reader = new BinaryReader(stream); // Must have RecordRootLength of bytes to read or something has gone wrong if (stream.Length < RecordRootLength) { stream.Close(); return; } // Position reader.BaseStream.Position = 6; recordRoot.Position = SaveTree.ReadPosition(reader); // RecordID reader.BaseStream.Position = 30; recordRoot.RecordID = reader.ReadUInt32(); // QuestID reader.BaseStream.Position = 37; recordRoot.QuestID = reader.ReadByte(); // ParentRecordID reader.BaseStream.Position = 38; recordRoot.ParentRecordID = reader.ReadUInt32(); // ParentRecordType reader.BaseStream.Position = 66; recordRoot.ParentRecordType = (RecordTypes)reader.ReadInt32(); reader.Close(); }
void ReadRawData() { MemoryStream stream = new MemoryStream(RawData); BinaryReader reader = new BinaryReader(stream, Encoding.UTF8); // Read Version - must be 0x26 Version = reader.ReadByte(); if (Version != VersionNumber) { throw new Exception("SaveTree file has an invalid version number, must be 0x26."); } // Read CharacterPosition.RecordType - must be 0x01 CharacterPosition = new CharacterPositionRecord(); CharacterPosition.RecordType = reader.ReadByte(); if (CharacterPosition.RecordType != (int)RecordTypes.CharacterPosition) { throw new Exception("Expected CharacterPosition in SaveTreeHeader has an invalid record type, must be 0x01."); } // Read CharacterPosition.Unknown CharacterPosition.Unknown = reader.ReadUInt16(); // Read CharacterPosition.Position CharacterPosition.Position = SaveTree.ReadPosition(reader); // Read Unknown Unknown = reader.ReadUInt16(); reader.Close(); }
void ReadRecordRoot() { MemoryStream stream = new MemoryStream(streamData); BinaryReader reader = new BinaryReader(stream); // Must have RecordRootLength of bytes to read or something has gone wrong if (stream.Length < RecordRootLength) { stream.Close(); return; } // Direction reader.BaseStream.Position = 1; recordRoot.Pitch = reader.ReadInt16(); recordRoot.Yaw = reader.ReadInt16(); // Position reader.BaseStream.Position = 7; recordRoot.Position = SaveTree.ReadPosition(reader); // 3d View Picture reader.BaseStream.Position = 27; recordRoot.Picture1 = reader.ReadUInt16(); // Inventory Picture recordRoot.Picture2 = reader.ReadUInt16(); // RecordID recordRoot.RecordID = reader.ReadUInt32(); // QuestID reader.BaseStream.Position = 38; recordRoot.QuestID = reader.ReadByte(); // ParentRecordID recordRoot.ParentRecordID = reader.ReadUInt32(); // ItemObject reader.BaseStream.Position = 47; recordRoot.ItemObject = reader.ReadUInt32(); // QuestObjectID recordRoot.QuestObjectID = reader.ReadUInt32(); // NextObject recordRoot.NextObject = reader.ReadUInt32(); // ChildObject recordRoot.ChildObject = reader.ReadUInt32(); // SublistHead recordRoot.SublistHead = reader.ReadUInt32(); // ParentRecordType recordRoot.ParentRecordType = (RecordTypes)reader.ReadInt32(); reader.Close(); }
void ReadRawData() { MemoryStream stream = new MemoryStream(RawData); BinaryReader reader = new BinaryReader(stream, Encoding.UTF8); // Read Version - must be 0x126 Version = reader.ReadInt32(); if (Version != VersionNumber) { throw new Exception("SaveTree file has an invalid version number, must be 0x126."); } // Read CharacterPosition.Position CharacterPosition = new HeaderCharacterPositionRecord(); CharacterPosition.Position = SaveTree.ReadPosition(reader); // Read MapID MapID = reader.ReadUInt16(); // Read Environment Environment = reader.ReadByte(); reader.Close(); }