src/ai/api/ai_tilelist_valuator.cpp
branchnoai
changeset 9617 df9cedf12aab
parent 9611 5cf58c6571b7
child 9655 e8e43f333832
--- a/src/ai/api/ai_tilelist_valuator.cpp	Fri May 04 21:46:28 2007 +0000
+++ b/src/ai/api/ai_tilelist_valuator.cpp	Fri May 04 22:59:59 2007 +0000
@@ -1,40 +1,22 @@
 #include "ai_tilelist_valuator.hpp"
+#include "ai_tile.hpp"
+#include "ai_road.hpp"
 #include "../../tile.h"
 #include "../../road_map.h"
-#include "../../variables.h"
-#include "../../station.h"
 
 int32 AITileListBuildable::Valuate(int32 tile) const
 {
-	switch (::GetTileType(tile)) {
-		default: return 1;
-		case MP_VOID:
-		case MP_HOUSE:
-		case MP_STATION:
-		case MP_INDUSTRY:
-		case MP_UNMOVABLE: return 0;
-	}
+	return AITile::IsBuildable(tile);
 }
 
 int32 AITileListSlope::Valuate(int32 tile) const
 {
-	return GetTileSlope(tile, NULL);
+	return AITile::GetSlope(tile);
 }
 
-int32 AITileListNeighbourRoad::Valuate(int32 tile) const
+int32 AITileListNeighbourRoadCount::Valuate(int32 tile) const
 {
-	int32 neighbour = 0;
-
-	if (::IsTileType(tile + ::TileDiffXY(-1, 0), MP_STREET) && ::GetRoadTileType(tile + ::TileDiffXY(-1, 0)) != ROAD_TILE_DEPOT)
-		neighbour++;
-	if (::IsTileType(tile + ::TileDiffXY( 1, 0), MP_STREET) && ::GetRoadTileType(tile + ::TileDiffXY( 1, 0)) != ROAD_TILE_DEPOT)
-		neighbour++;
-	if (::IsTileType(tile + ::TileDiffXY( 0,-1), MP_STREET) && ::GetRoadTileType(tile + ::TileDiffXY( 0,-1)) != ROAD_TILE_DEPOT)
-		neighbour++;
-	if (::IsTileType(tile + ::TileDiffXY( 0, 1), MP_STREET) && ::GetRoadTileType(tile + ::TileDiffXY( 0, 1)) != ROAD_TILE_DEPOT)
-		neighbour++;
-
-	return neighbour;
+	return AIRoad::GetNeighbourRoadCount(tile);
 }
 
 int32 AITileListRoadTile::Valuate(int32 tile) const
@@ -44,10 +26,5 @@
 
 int32 AITileListCargoAcceptance::Valuate(int32 tile) const
 {
-	/* TODO -- Make it an enum via constructor, for now it assumes RoadVehicle Station */
-	uint rad = 3;
-
-	AcceptedCargo accepts;
-	GetAcceptanceAroundTiles(accepts, tile, 1, 1, _patches.modified_catchment ? rad : 4);
-	return accepts[this->cargo_type];
+	return AITile::GetCargoAcceptance(tile, this->cargo_type);
 }