Server.TileData.TileData C# (CSharp) Méthode

TileData() static private méthode

static private TileData ( ) : System
Résultat System
		static TileData()
		{
			string filePath = Core.FindDataFile( "tiledata.mul" );

			if ( File.Exists( filePath ) )
			{
				using ( FileStream fs = new FileStream( filePath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
				{
					BinaryReader bin = new BinaryReader( fs );

					if ( fs.Length == 3188736 ) { // 7.0.9.0
						m_LandData = new LandData[0x4000];

						for ( int i = 0; i < 0x4000; ++i )
						{
							if ( i == 1 || ( i > 0 && (i & 0x1F) == 0 ) )
							{
								bin.ReadInt32(); // header
							}

							TileFlag flags = (TileFlag)bin.ReadInt64();
							bin.ReadInt16(); // skip 2 bytes -- textureID

							m_LandData[i] = new LandData( ReadNameString( bin ), flags );
						}

						m_ItemData = new ItemData[0x10000];

						for ( int i = 0; i < 0x10000; ++i )
						{
							if ( (i & 0x1F) == 0 )
							{
								bin.ReadInt32(); // header
							}

							TileFlag flags = (TileFlag)bin.ReadInt64();
							int weight = bin.ReadByte();
							int quality = bin.ReadByte();
							bin.ReadInt16();
							bin.ReadByte();
							int quantity = bin.ReadByte();
							bin.ReadInt32();
							bin.ReadByte();
							int value = bin.ReadByte();
							int height = bin.ReadByte();

							m_ItemData[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height );
						}
					} else {
						m_LandData = new LandData[0x4000];

						for ( int i = 0; i < 0x4000; ++i )
						{
							if ( (i & 0x1F) == 0 )
							{
								bin.ReadInt32(); // header
							}

							TileFlag flags = (TileFlag)bin.ReadInt32();
							bin.ReadInt16(); // skip 2 bytes -- textureID

							m_LandData[i] = new LandData( ReadNameString( bin ), flags );
						}

						if ( fs.Length == 1644544 ) { // 7.0.0.0
							m_ItemData = new ItemData[0x8000];

							for ( int i = 0; i < 0x8000; ++i )
							{
								if ( (i & 0x1F) == 0 )
								{
									bin.ReadInt32(); // header
								}

								TileFlag flags = (TileFlag)bin.ReadInt32();
								int weight = bin.ReadByte();
								int quality = bin.ReadByte();
								bin.ReadInt16();
								bin.ReadByte();
								int quantity = bin.ReadByte();
								bin.ReadInt32();
								bin.ReadByte();
								int value = bin.ReadByte();
								int height = bin.ReadByte();

								m_ItemData[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height );
							}
						} else {
							m_ItemData = new ItemData[0x4000];

							for ( int i = 0; i < 0x4000; ++i )
							{
								if ( (i & 0x1F) == 0 )
								{
									bin.ReadInt32(); // header
								}

								TileFlag flags = (TileFlag)bin.ReadInt32();
								int weight = bin.ReadByte();
								int quality = bin.ReadByte();
								bin.ReadInt16();
								bin.ReadByte();
								int quantity = bin.ReadByte();
								bin.ReadInt32();
								bin.ReadByte();
								int value = bin.ReadByte();
								int height = bin.ReadByte();

								m_ItemData[i] = new ItemData( ReadNameString( bin ), flags, weight, quality, quantity, value, height );
							}
						}
					}
				}

				m_MaxLandValue = m_LandData.Length - 1;
				m_MaxItemValue = m_ItemData.Length - 1;
			}
			else
			{
				Console.WriteLine( "tiledata.mul was not found" );
				Console.WriteLine( "Make sure your Scripts/Misc/DataPath.cs is properly configured" );
				Console.WriteLine( "After pressing return an exception will be thrown and the server will terminate" );

				throw new Exception( String.Format( "TileData: {0} not found", filePath ) );
			}
		}
	}