public void H2Read(int TagIndex, Map map, bool dontreadraw)
{
int w = map.BSP.FindBSPNumberByBSPIdent(map.MetaInfo.Ident[TagIndex]);
// bsp model 1
map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 172;
int tempc = map.BR.ReadInt32();
int tempr = map.BR.ReadInt32() - map.BSP.sbsp[w].magic;
for (int x = 0; x < tempc; x++)
{
RawDataChunk Raw = new RawDataChunk();
Raw.rawDataType = RawDataType.bsp1;
Raw.pointerMetaOffset = tempr + (x * 176) + 40 - map.MetaInfo.Offset[TagIndex];
map.BR.BaseStream.Position = tempr + (x * 176) + 40;
Raw.offset = map.BR.ReadInt32();
Raw.size = map.BR.ReadInt32();
if (Raw.offset == -1)
{
this.rawChunks.Add(Raw);
continue;
}
map.Functions.ParsePointer(ref Raw.offset, ref Raw.rawLocation);
if (dontreadraw == false)
{
map.OpenMap(Raw.rawLocation);
map.BR.BaseStream.Position = Raw.offset;
Raw.MS = new MemoryStream(Raw.size);
Raw.MS.Write(map.BR.ReadBytes(Raw.size), 0, Raw.size);
map.OpenMap(MapTypes.Internal);
}
this.rawChunks.Add(Raw);
}
// bsp model 2
map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 328;
tempc = map.BR.ReadInt32();
tempr = map.BR.ReadInt32() - map.BSP.sbsp[w].magic;
for (int x = 0; x < tempc; x++)
{
RawDataChunk Raw = new RawDataChunk();
Raw.rawDataType = RawDataType.bsp2;
Raw.pointerMetaOffset = tempr + (x * 200) + 40 - map.MetaInfo.Offset[TagIndex];
map.BR.BaseStream.Position = tempr + (x * 200) + 40;
Raw.offset = map.BR.ReadInt32();
Raw.size = map.BR.ReadInt32();
if (Raw.offset == -1)
{
this.rawChunks.Add(Raw);
continue;
}
map.Functions.ParsePointer(ref Raw.offset, ref Raw.rawLocation);
if (dontreadraw == false)
{
map.OpenMap(Raw.rawLocation);
map.BR.BaseStream.Position = Raw.offset;
Raw.MS = new MemoryStream(Raw.size);
Raw.MS.Write(map.BR.ReadBytes(Raw.size), 0, Raw.size);
map.OpenMap(MapTypes.Internal);
}
this.rawChunks.Add(Raw);
}
// light map
if (map.BSP.sbsp[w].lightmapident != -1)
{
map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 8;
tempr = map.BR.ReadInt32();
if (tempr == 0)
{
goto skiplightmap;
}
tempr -= map.BSP.sbsp[w].magic;
map.BR.BaseStream.Position = tempr + 128;
tempc = map.BR.ReadInt32();
tempr = map.BR.ReadInt32() - map.BSP.sbsp[w].magic;
map.BR.BaseStream.Position = tempr + 64;
tempc = map.BR.ReadInt32();
tempr = map.BR.ReadInt32() - map.BSP.sbsp[w].magic;
for (int x = 0; x < tempc; x++)
{
RawDataChunk Raw = new RawDataChunk();
Raw.rawDataType = RawDataType.ltmp;
Raw.pointerMetaOffset = tempr + (x * 56) + 12 - map.MetaInfo.Offset[TagIndex];
map.BR.BaseStream.Position = tempr + (x * 56) + 12;
Raw.offset = map.BR.ReadInt32();
Raw.size = map.BR.ReadInt32();
if (Raw.offset == -1)
{
this.rawChunks.Add(Raw);
continue;
}
map.Functions.ParsePointer(ref Raw.offset, ref Raw.rawLocation);
if (dontreadraw == false)
{
map.OpenMap(Raw.rawLocation);
map.BR.BaseStream.Position = Raw.offset;
Raw.MS = new MemoryStream(Raw.size);
Raw.MS.Write(map.BR.ReadBytes(Raw.size), 0, Raw.size);
map.OpenMap(MapTypes.Internal);
}
this.rawChunks.Add(Raw);
}
}
skiplightmap:
// bsp model 3
map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 580;
tempc = map.BR.ReadInt32();
tempr = map.BR.ReadInt32() - map.BSP.sbsp[w].magic;
// if (tempc==0){return;}
map.BR.BaseStream.Position = tempr + 16;
tempc = map.BR.ReadInt32();
tempr = map.BR.ReadInt32() - map.BSP.sbsp[w].magic;
for (int x = 0; x < tempc; x++)
{
RawDataChunk Raw = new RawDataChunk();
Raw.rawDataType = RawDataType.bsp3;
Raw.pointerMetaOffset = tempr + (x * 44) - map.MetaInfo.Offset[TagIndex];
map.BR.BaseStream.Position = tempr + (x * 44);
Raw.offset = map.BR.ReadInt32();
Raw.size = map.BR.ReadInt32();
if (Raw.offset == -1)
{
this.rawChunks.Add(Raw);
continue;
}
map.Functions.ParsePointer(ref Raw.offset, ref Raw.rawLocation);
if (dontreadraw == false)
{
map.OpenMap(Raw.rawLocation);
map.BR.BaseStream.Position = Raw.offset;
Raw.MS = new MemoryStream(Raw.size);
Raw.MS.Write(map.BR.ReadBytes(Raw.size), 0, Raw.size);
map.OpenMap(MapTypes.Internal);
}
this.rawChunks.Add(Raw);
}
// bsp model 4
map.BR.BaseStream.Position = map.MetaInfo.Offset[TagIndex] + 548;
tempc = map.BR.ReadInt32();
tempr = map.BR.ReadInt32() - map.BSP.sbsp[w].magic;
for (int x = 0; x < tempc; x++)
{
RawDataChunk Raw = new RawDataChunk();
Raw.rawDataType = RawDataType.bsp4;
Raw.pointerMetaOffset = tempr + (x * 172) + 16 - map.MetaInfo.Offset[TagIndex];
map.BR.BaseStream.Position = tempr + (x * 172) + 16;
Raw.offset = map.BR.ReadInt32();
if (Raw.offset == -1)
{
continue;
}
Raw.size = map.BR.ReadInt32();
map.Functions.ParsePointer(ref Raw.offset, ref Raw.rawLocation);
if (dontreadraw == false)
{
map.OpenMap(Raw.rawLocation);
map.BR.BaseStream.Position = Raw.offset;
Raw.MS = new MemoryStream(Raw.size);
Raw.MS.Write(map.BR.ReadBytes(Raw.size), 0, Raw.size);
map.OpenMap(MapTypes.Internal);
}
this.rawChunks.Add(Raw);
}
}