View Single Post
Old 08-08-2007, 01:27 AM   #3 (permalink)
Setharnas
Forum Expert
 
Join Date: Dec 2005
Location: Germany
Age: 31
Posts: 401
Default

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();
			}
		}
Setharnas is offline   Reply With Quote