public void Init(DAT dat) { this.length = 8 + Convert.ToUInt32(dat.ParentTerf.files * 8); int pad = dat.GetPad((int)length, (int)dat.ParentTerf.filepad); this.length += (uint)pad; this.DirTable = new List <direntry>(); for (int c = 0; c < dat.ParentTerf.files; c++) { direntry entry = new direntry(); entry.filelength = 0; entry.datatable_offset = 0; this.DirTable.Add(entry); } }
public void Fix(TERF terf) // Fix DIR1, specify terf to account for nested terf in data { this.DirTable = new List <direntry>(); uint holder = 8 + (uint)terf.GetPad(8); // Holder for current offset for (int c = 0; c < terf.Data.DataFiles.Count; c++) { direntry de = new direntry(); de.datatable_offset = holder; de.filelength = (uint)terf.Data.DataFiles[c].GetSize(); this.DirTable.Add(de); holder += (uint)terf.Data.DataFiles[c].GetSize(); int pad = terf.GetPad(terf.Data.DataFiles[c].GetSize()); holder += (uint)pad; } this.length = (uint)(this.GetSize(terf)); needsfixed = false; }
public void Read(DAT dat, TERF terf) { if (this.dir1_id != dat.binreader.ReadUInt32()) { dat.binreader.BaseStream.Position -= 4; dat.errormsg = "Problem with Terf header"; return; } this.DirTable = new List <direntry>(); this.length = dat.binreader.ReadUInt32(); for (int c = 0; c < dat.ParentTerf.files; c++) { direntry de = new direntry(); de.datatable_offset = dat.binreader.ReadUInt32(); de.filelength = dat.binreader.ReadUInt32(); this.DirTable.Add(de); } dat.binreader.BaseStream.Position += terf.GetPad(8 + (this.DirTable.Count * 8)); // Padding is part of the dir1 size }