/// <summary> /// Copy constructor /// </summary> public IDXEntry(IDXEntry entry) { Filename = entry.Filename; AFSIndex = entry.AFSIndex; Unknown = entry.Unknown; Unknown2 = entry.Unknown2; Unknown3 = entry.Unknown3; IDXType = entry.IDXType; }
/// <summary> /// Tries to map the filenames of all the AFS file entries with the give IDX file. /// </summary> public void MapIDXFile(IDX idx) { for (int i = 0; i < idx.Entries.Count; i++) { IDXEntry entry = idx.Entries[i]; if (i >= Entries.Count) { break; } Entries[i].IDXFilename = entry.Filename; } }
protected override void _Read(BinaryReader reader) { Identifier = reader.ReadUInt32(); Type = GetIDXType(Identifier); if (Type == IDXType.HUMANS) { reader.BaseStream.Seek(-4, SeekOrigin.Current); EntryCount = (ushort)reader.ReadUInt32(); } else if (Type == IDXType.IDXD) { Unknown = reader.ReadUInt32(); EntryCountSelf = reader.ReadUInt16(); EntryCount = reader.ReadUInt16(); reader.BaseStream.Seek(4, SeekOrigin.Current); } else if (Type == IDXType.IDXC) { Unknown = reader.ReadUInt32(); EntryCountSelf = reader.ReadUInt16(); EntryCount = reader.ReadUInt16(); reader.BaseStream.Seek(4, SeekOrigin.Current); } else if (Type == IDXType.IDXB) { Unknown = reader.ReadUInt32(); EntryCountSelf = reader.ReadUInt16(); EntryCount = reader.ReadUInt16(); reader.BaseStream.Seek(4, SeekOrigin.Current); } else { EntryCountSelf = reader.ReadUInt16(); EntryCount = reader.ReadUInt16(); reader.BaseStream.Seek(12, SeekOrigin.Current); } if (Type == IDXType.HUMANS) { uint fileCount = EntryCount; for (int i = 0; i < fileCount; i++) { IDXEntry entryPKF = new IDXEntry(reader, Type); entryPKF.AFSIndex = (ushort)i; Entries.Add(entryPKF); //Add entry two times (for PKF and PKS) IDXEntry entryPKS = new IDXEntry(entryPKF); entryPKS.AFSIndex = (ushort)(i + 1); Entries.Add(entryPKS); } } else if (Type == IDXType.IDXD) { reader.BaseStream.Seek(8, SeekOrigin.Current); //SKIP TABL uint fileCount = EntryCount; for (int i = 0; i < fileCount; i++) { IDXEntry entry = new IDXEntry(reader, Type); entry.AFSIndex = (ushort)i; Entries.Add(entry); } } else if (Type == IDXType.IDXC) { reader.BaseStream.Seek(8, SeekOrigin.Current); //SKIP TABL uint fileCount = EntryCount; for (int i = 0; i < fileCount; i++) { IDXEntry entry = new IDXEntry(reader, Type); entry.AFSIndex = (ushort)i; Entries.Add(entry); } } else if (Type == IDXType.IDXB) { reader.BaseStream.Seek(8, SeekOrigin.Current); //SKIP TABL uint fileCount = EntryCount; for (int i = 0; i < fileCount; i++) { IDXEntry entry = new IDXEntry(reader, Type); entry.AFSIndex = (ushort)i; Entries.Add(entry); } } else { for (int i = 0; i < EntryCount; i++) { IDXEntry entry = new IDXEntry(reader, Type); Entries.Add(entry); } } }
protected override void _Write(BinaryWriter writer) { if (Type == IDXType.HUMANS) { throw new NotImplementedException(); writer.Write(EntryCount); } else { writer.Write(Identifier); if (Type == IDXType.IDXD) { writer.Write(Unknown); writer.Write(EntryCountSelf); writer.Write(EntryCount); writer.BaseStream.Seek(4, SeekOrigin.Current); } else if (Type == IDXType.IDXC) { writer.Write(Unknown); writer.Write(EntryCountSelf); writer.Write(EntryCount); writer.BaseStream.Seek(4, SeekOrigin.Current); } else if (Type == IDXType.IDXB) { writer.Write(Unknown); writer.Write(EntryCountSelf); writer.Write(EntryCount); writer.BaseStream.Seek(4, SeekOrigin.Current); } else { writer.Write(EntryCountSelf); writer.Write(EntryCount); writer.BaseStream.Seek(12, SeekOrigin.Current); } } if (Type == IDXType.HUMANS) { for (int i = 0; i < EntryCount; i++) { IDXEntry entry = Entries[i]; entry.Write(writer); } } else if (Type == IDXType.IDXD) { throw new NotImplementedException(); //TODO: Write table for (int i = 0; i < EntryCount; i++) { IDXEntry entry = Entries[i]; entry.Write(writer); } } else if (Type == IDXType.IDXC) { throw new NotImplementedException(); //TODO: Write table for (int i = 0; i < EntryCount; i++) { IDXEntry entry = Entries[i]; entry.Write(writer); } } else if (Type == IDXType.IDXB) { throw new NotImplementedException(); //TODO: Write table for (int i = 0; i < EntryCount; i++) { IDXEntry entry = Entries[i]; entry.Write(writer); } } else { for (int i = 0; i < EntryCount; i++) { IDXEntry entry = Entries[i]; entry.Write(writer); } } }