public Master(string filename) { if (Path.GetFileNameWithoutExtension(filename).ToLower() != "morrowind") { throw new Exception("Morrowind not present."); } using (var reader = new BetterBinaryReader(File.OpenRead(filename))) { var tes3 = new Record(reader.ReadString(4)); tes3.Deserialize(reader); Utils.LogBuffer("# Loading Morrowind"); Record record; var records = new List <Record>(); var name = string.Empty; while (reader.Position < reader.Length) { name = reader.ReadString(4); record = new Record(name); record.Deserialize(reader); records.Add(record); } _records = records.ToArray(); } }
public TES3Master(string filename) { using (var reader = new BetterBinaryReader(File.OpenRead(filename))) { var tes3 = new Record(); tes3.Deserialize(reader, reader.ReadString(4)); if (tes3.Type != "TES3") { throw new Exception("That's not a Morrowind master file."); } Utils.LogBuffer("# Loading Morrowind"); Utils.LogBuffer("\t- Record: {0}", tes3.Type); var mDico = new List <string>(); var mRecords = new List <Record>(); Record mRecord = null; while (reader.Position < reader.Length) { mRecord = new Record(); mRecord.Deserialize(reader, reader.ReadString(4)); mRecords.Add(mRecord); if (!mDico.Contains(mRecord.Type)) { mDico.Add(mRecord.Type); Utils.LogBuffer("\t- Record: {0}", mRecord.Type); } } _records = mRecords.ToArray(); } }
public TES4Master(string filename) { var gameID = GameID.Oblivion; switch (Path.GetFileNameWithoutExtension(filename).ToLower()) { case "oblivion": gameID = GameID.Oblivion; break; case "skyrim": gameID = GameID.Skyrim; break; case "fallout3": gameID = GameID.Fallout3; break; case "falloutNV": gameID = GameID.FalloutNV; break; case "fallout4": gameID = GameID.Fallout4; break; } _groups = new Dictionary <string, Group>(); using (var reader = new BetterBinaryReader(File.OpenRead(filename))) { var tes4 = new TES4Record(); tes4.Deserialize(reader, reader.ReadString(4), gameID); if (tes4.Type != "TES4") { throw new Exception("That's not a TES4/5 compatible master file."); } Utils.LogBuffer("# Loading {0}", gameID); Utils.LogBuffer("\t- Record: {0}", tes4.Type); string groupName = string.Empty; Group group = null; while (reader.Position < reader.Length) { groupName = reader.ReadString(4); group = new Group(); group.Deserialize(reader, groupName, gameID); if (_groups.ContainsKey(group.Label)) { continue; } _groups.Add(group.Label, group); } } }
public void Deserialize(BetterBinaryReader reader) { FileID = reader.ReadString(4); Version = reader.ReadUInt32(); Offset = reader.ReadUInt32(); Flags = reader.ReadUInt32(); FolderCount = reader.ReadUInt32(); FileCount = reader.ReadUInt32(); FolderNameLength = reader.ReadUInt32(); FileNameLength = reader.ReadUInt32(); FileFlags = reader.ReadUInt32(); }