src/ai/api/ai_tilelist_valuator.cpp
author truebrain
Sat, 23 Feb 2008 16:21:10 +0000
branchnoai
changeset 9746 e4ab7ea8d897
parent 9723 eee46cb39750
child 9753 7209db94ad12
permissions -rw-r--r--
(svn r12226) [NoAI] -Fix: remove the dep for AIStationList_Vehicle on AIStationList, as Squirrel doesn't like it
#include "ai_tilelist_valuator.hpp"
#include "ai_tile.hpp"
#include "ai_road.hpp"
#include "ai_map.hpp"
#include "../../road_map.h"

int32 AITileListBuildable::Valuate(int32 tile) const
{
	return AITile::IsBuildable(tile);
}

int32 AITileListWater::Valuate(int32 tile) const
{
	return AITile::IsWater(tile);
}

int32 AITileListBuildableRectangle::Valuate(int32 tile) const
{
	uint tx, ty;

	tx = AIMap::GetTileX(tile);
	ty = AIMap::GetTileY(tile);

	for (uint x = tx; x < this->width + tx; x++) {
		for (uint y = ty; y < this->height + ty; y++) {
			if (!AITile::IsBuildable(AIMap::GetTileIndex(x, y))) return false;
		}
	}

	return true;
}

int32 AITileListSlope::Valuate(int32 tile) const
{
	return AITile::GetSlope(tile);
}

int32 AITileListHeight::Valuate(int32 tile) const
{
	return AITile::GetHeight(tile);
}

int32 AITileListNeighbourRoadCount::Valuate(int32 tile) const
{
	return AIRoad::GetNeighbourRoadCount(tile);
}

int32 AITileListRoadTile::Valuate(int32 tile) const
{
	return ::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) != ROAD_TILE_DEPOT;
}

int32 AITileListCargoAcceptance::Valuate(int32 tile) const
{
	return AITile::GetCargoAcceptance(tile, this->cargo_type, this->width, this->height, this->radius);
}

int32 AITileListDistanceManhattanToTile::Valuate(int32 tile) const
{
	return AIMap::DistanceManhattan(this->tile, tile);
}

int32 AITileListDistanceSquareToTile::Valuate(int32 tile) const
{
	return AIMap::DistanceSquare(this->tile, tile);
}