internal Group(Module module, uint contentSize, uint label, ModuleGroupType groupType) : base(module.Manager, "") { BinaryReader reader = module.Reader; ContentSize = contentSize; LabelUInt32 = label; GroupType = groupType; var timeStampDay = reader.ReadByte(); // One-based day in the month. var timeStampMonth = reader.ReadByte(); TimeStamp = new DateTime(2002, 12, 1).AddMonths(timeStampMonth); int currentMonth = TimeStamp.Month; if (timeStampDay == 0) throw new InvalidDataException(); TimeStamp = TimeStamp.AddDays(timeStampDay - 1); if (TimeStamp.Month != currentMonth) throw new InvalidDataException(); //.AddDays(timeStampDay); Unknowns.ReadInt16s(reader, 1); Version = reader.ReadUInt16(); Unknowns.ReadInt16s(reader, 1); ContentOffset = reader.BaseStream.Position; reader.BaseStream.Seek(ContentSize, SeekOrigin.Current); Name = GroupType + " " + LabelValue; }
internal static Record Read(Module module, RecordReader reader) { switch (reader.Record.Type) { default: return new UnknownRecord(module, reader); } }
internal static Group ReadGroup(Module module) { BinaryReader reader = module.Reader; string type = reader.ReadId4(); if (type != "GRUP") throw new InvalidDataException(string.Format("Expected GRUP; received {0}.", type)); uint contentSize = checked(reader.ReadUInt32() - 24); uint label = reader.ReadUInt32(); string labelId = Extensions.ToId4((int)label); ModuleGroupType groupType = (ModuleGroupType)reader.ReadInt32(); switch (groupType) { case ModuleGroupType.Top: switch(labelId) { case "CELL": case "WRLD": case "DIAL": return new GroupTopGroup(module, contentSize, label); default: return new RecordTopGroup(module, contentSize, label); } default: throw new NotImplementedException("Group type " + groupType + " is not implemented."); } }
internal Record(Module module, RecordReader reader) : base(module.Manager, "") { Header = reader.Record; Name = Header.Type; }