private static void ReadOptionalChunks(BinaryReader br, WMOGroup currentWMOGroup)
{
// We start here at the end of the required chunks
uint type = 0;
uint size = 0;
var curPos = AdvanceToNextChunk(br, br.BaseStream.Position, ref type, ref size);
if (currentWMOGroup.Header.HasMOLR)
{
if (type == Signatures.MOLR)
{
ReadMOLR(br, currentWMOGroup, size);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MOLR, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
}
if (currentWMOGroup.Header.HasMODR)
{
if (type == Signatures.MODR)
{
ReadMODR(br, currentWMOGroup, size);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MODR, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
}
if (currentWMOGroup.Header.HasBSPInfo)
{
if (type == Signatures.MOBN)
{
ReadMOBN(br, currentWMOGroup, size);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MOBN, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
if (type == Signatures.MOBR)
{
ReadMOBR(br, currentWMOGroup, size);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MOBR, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
}
if (currentWMOGroup.Header.HasMPChunks)
{
if (type == Signatures.MPBV)
{
ReadMPBV(br, currentWMOGroup);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MPBV, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
if (type == Signatures.MPBP)
{
ReadMPBP(br, currentWMOGroup);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MPBP, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
if (type == Signatures.MPBI)
{
ReadMPBI(br, currentWMOGroup);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MPBI, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
if (type == Signatures.MPBG)
{
ReadMPBG(br, currentWMOGroup);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MPBG, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
}
if (currentWMOGroup.Header.HasMOCV1)
{
if (type == Signatures.MOCV)
{
ReadMOCV1(br, currentWMOGroup, size);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MOCV 1, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
}
if (currentWMOGroup.Header.HasMLIQ)
{
if (type == Signatures.MLIQ)
{
ReadMLIQ(br, currentWMOGroup);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MLIQ, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
}
if (currentWMOGroup.Header.HasMORChunks)
{
if (type == Signatures.MORI)
{
ReadMORI(br, currentWMOGroup);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MORI, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
if (type == Signatures.MORB)
{
ReadMORB(br, currentWMOGroup);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MORB, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
}
if (currentWMOGroup.Header.HasMOTV2)
{
if (type == Signatures.MOTV)
{
ReadMOTV2(br, currentWMOGroup, size);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MOTV2, but was specified in the flags");
}
curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
}
if (currentWMOGroup.Header.HasMOCV2)
{
if (type == Signatures.MOCV)
{
ReadMOCV2(br, currentWMOGroup, size);
}
else
{
Console.WriteLine(
"ERROR: WMO Group did not have optional chunk MOCV2, but was specified in the flags");
}
// This is the final chunk in the file (or should be...)
//curPos = AdvanceToNextChunk(br, curPos, ref type, ref size);
}
}