The method in question is this. If anyone can see anything wrong with it, please post. I certainly don't.
Code:
/// <summary>
/// Reads the Difl files needed for patching purposes
/// </summary>
private void GeneratePatchData()
{
//
// MAP: Read from mapdiflX.mul
//
// Note: Some blocks are duplicated.
// Always use the second block or the map will miss pieces
m_MapPatch = new Hashtable();
if ( File.Exists( GetMulFile( MulFileType.MapDifl, m_Map ) ) )
{
FileStream stream = new FileStream( GetMulFile( MulFileType.MapDifl, m_Map ), FileMode.Open, FileAccess.Read, FileShare.Read );
BinaryReader reader = new BinaryReader( stream );
int index = 0;
while ( reader.PeekChar() != -1 )
{
// Read data. Data stored in the file is the key
// The index of the key is the value
int key = reader.ReadInt32();
m_MapPatch[ key ] = index++;
}
stream.Close();
}
//
// STATICS: Read from stadiflX.mul
//
m_StaPatch = new Hashtable();
if ( File.Exists( GetMulFile( MulFileType.StaDifl, m_Map ) ) )
{
FileStream stream = new FileStream( GetMulFile( MulFileType.StaDifl, m_Map ), FileMode.Open, FileAccess.Read, FileShare.Read );
BinaryReader reader = new BinaryReader( stream );
int index = 0;
while ( reader.PeekChar() != -1 )
{
int key = reader.ReadInt32();
m_StaPatch[ key ] = index++;
}
stream.Close();
}
}