public void Read(ref EndianReader br, ref uint[] BspsMagic) { IndexHeader = new MapIndexHeader(); IndexHeader.Read(ref br); br.Seek(IndexHeader.CalculatedIndexOffset, SeekOrigin.Begin); IndexItems = new MapIndexItem[IndexHeader.TagCount]; TagClassItem = new MapTagClassItem[IndexHeader.TagCountInTagList]; for (int x = 0; x < IndexHeader.TagCount; x++) { IndexItems[x] = new MapIndexItem(); IndexItems[x].Read(ref br); IndexItems[x].Index = x; IDLookUp.Add(IndexItems[x].ID, IndexItems[x]); if (TAG.TestTag(IndexItems[x].TagType, TagGroups.sbsp.Tag)) { bspList.Add(IndexItems[x]); } } bsps = new MapIndexItem[bspList.Count]; int i = 0; foreach (MapIndexItem bsp in bspList) { bsps[i] = bsp; i++; } }
public void Read(ref EndianReader er, bool PC, ref uint Magic, ref uint[] BspsMagic) { IndexMagic = er.ReadUInt32(); Magic = (IndexMagic - ((er.Position - 4) + 40)); //(PC ? 40 : 36))); StartingID = er.ReadUInt32(); Unknown2 = er.ReadInt32(); TagCount = er.ReadUInt32(); VertexObjectCount = er.ReadInt32(); VertexOffset = er.ReadInt32(); IndecesOffsetCount = er.ReadInt32(); IndecesOffset = er.ReadInt32(); if (PC) { Unknown3 = er.ReadInt32(); } er.ReadUInt32(); TagsOffset = er.Position; // Load tag item data IndexItems = new MapIndexItem[TagCount]; uint sbsp_offset = 0; for (uint x = 0; x < IndexItems.Length; x++) { IndexItems[x] = new MapIndexItem(); IndexItems[x].Read(ref er, x, Magic); IDTable.Add(IndexItems[x].ID, IndexItems[x]); // load scnr's bsps block header if (x == 0) { uint temp_pos = er.Position; er.Seek(this[0].MetaOffset + 1444, System.IO.SeekOrigin.Begin); BspsMagic = new uint[er.ReadUInt32()]; sbsp_offset = er.ReadUInt32() - Magic; er.Seek(temp_pos, System.IO.SeekOrigin.Begin); } if (Core.TAG.TestTag(IndexItems[x].TagClass, Core.TagGroups.sbsp.Tag)) { uint temp_pos = er.Position; // I swear I'm going to kill VS with its BS about converting "long to unit" // when there IS NO F*****G LONG! er.Seek(sbsp_offset + (uint)(bspCount * 32), System.IO.SeekOrigin.Begin); IndexItems[x].MetaOffset = er.ReadUInt32(); IndexItems[x].MetaSize = er.ReadUInt32(); BspsMagic[bspCount] = er.ReadUInt32() - IndexItems[x].MetaOffset; IndexItems[x].MetaOffset += 24; IndexItems[x].BSPIndex = bspCount; ++bspCount; er.Seek(temp_pos, System.IO.SeekOrigin.Begin); } } // Load tag strings for (int x = 0; x < IndexItems.Length; x++) { IndexItems[x].FileName = er.ReadCString(); } }