예제 #1
0
		public static ADTTerrainInfo[,] ExtractRegionHeightMaps(WDTFile wdt)
		{
			var terrainInfo = new ADTTerrainInfo[TerrainConstants.TilesPerMapSide, TerrainConstants.TilesPerMapSide];

			for (var y = 0; y < TerrainConstants.TilesPerMapSide; y++)
			{
				for (var x = 0; x < TerrainConstants.TilesPerMapSide; x++)
				{
					if (!wdt.TileProfile[x, y]) continue;
					var info = new ADTTerrainInfo();

					var adtName = TerrainConstants.GetADTFile(wdt.Name, x, y);
					var adt = ADTParser.Process(WDTParser.MpqManager, wdt.Path, adtName);
					if (adt == null) continue;

					info.LiquidProfile = ExtractTileLiquidProfile(adt);
					info.LiquidTypes = ExtractTileLiquidTypes(adt);
					info.HeightMaps = ExtractTileHeightMaps(adt);
					info.CheckFlatness();

					terrainInfo[x, y] = info;
				}
			}

			return terrainInfo;
		}
예제 #2
0
		public static ADTTerrainInfo ReadTileInfo(MapId id, TileCoord coord)
		{
			var filePath = Path.Combine(ToolConfig.MapDir, TerrainConstants.GetHeightMapFile(coord.TileX, coord.TileY));
			var file = File.OpenRead(filePath);
			var reader = new BinaryReader(file);

			var key = reader.ReadString();
			if (key != FileTypeId) log.Error("Invalid file format!");

			var info = new ADTTerrainInfo
			{
				LiquidProfile = ReadLiquidProfile(reader),
				LiquidTypes = ReadLiquidTypes(reader)
			};

			info.HeightMaps = ReadHeightMaps(reader, info.LiquidProfile);
			return info;
		}
예제 #3
0
		public static void WriteADTTerrainInfo(FileStream file, ADTTerrainInfo info)
		{
			var writer = new BinaryWriter(file);
			writer.Write(FileTypeId);

			for (var y = 0; y < TerrainConstants.ChunksPerTileSide; y++)
			{
				for (var x = 0; x < TerrainConstants.ChunksPerTileSide; x++)
				{
					writer.Write(info.LiquidProfile[x, y]);
				}
			}

			for (var y = 0; y < TerrainConstants.ChunksPerTileSide; y++)
			{
				for (var x = 0; x < TerrainConstants.ChunksPerTileSide; x++)
				{
					writer.Write((byte)info.LiquidTypes[x, y]);
				}
			}

			for (var y = 0; y < TerrainConstants.ChunksPerTileSide; y++)
			{
				for (var x = 0; x < TerrainConstants.ChunksPerTileSide; x++)
				{
					WriteHeightMap(writer, info.HeightMaps[x, y], info.LiquidProfile[x, y]);
				}
			}
		}