(svn r12309) [NoAI] -Codechange: optimize a little bit (a very small little bit, but every bit counts :) ) (glx)
/* $Id$ */
/** @file ai_tilelist_valuator.hpp all the valuators for AITileList */
#ifndef AI_TILELIST_VALUATOR_HPP
#define AI_TILELIST_VALUATOR_HPP
#include "ai_abstractlist.hpp"
/**
* Check if tiles are buildable for entries in an AITileList instance.
* @note Resulting items are of the type bool (0 = not buildable, 1 = buildable).
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vBuildable : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vBuildable"; }
private:
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 tile) const;
};
/**
* Check if tiles are water-tiles for entries in an AITileList instance.
* @note Resulting items are of the type bool (0 = not water-tile, 1 = water-tile).
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vWater : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vWater"; }
private:
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 tile) const;
};
/**
* Check if tiles are buildable in a rectangle around entries in an AITileList instance, with the entry in the list as top-left.
* @note Resulting items are of the type bool (0 = not buildable, 1 = buildable).
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vBuildableRectangle : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vBuildableRectangle"; }
/**
* @param width The width of the rectangle.
* @param height The height of the rectangle.
*/
AITileList_vBuildableRectangle(uint width, uint height) :
width(width),
height(height)
{}
private:
uint width, height;
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 tile) const;
};
/**
* Check how tiles in an AITileList instance are sloped.
* @note Resulting items are of the type int32 (0 = flat, > 1 = slope).
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vSlope : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vSlope"; }
private:
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 tile) const;
};
/**
* Check the height of the tiles in an AITileList instance.
* @note Resulting items are of the type int32 (height, ranging from 0 to 15).
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vHeight : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vHeight"; }
private:
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 tile) const;
};
/**
* Count for each entry in AITileList the amount of neighbours that contain road.
* This is a value between 0 and 4, as it only check horizontal and vertical.
* @note Resulting items are of the type int32 (the amount of neighbour road tiles, value between 0 and 4).
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vNeighbourRoadCount : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vNeighbourRoad"; }
private:
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 tile) const;
};
/**
* Check if the tiles in AITileList have a piece of road on them.
* @note Resulting items are of the type bool (0 = no road, 1 = road).
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vRoadTile : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vRoadTile"; }
private:
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 tile) const;
};
/**
* Get the amount of estimated accepted cargo for all tiles in AITileList.
* If this value is >= 8, it means it will accept this cargo. For passengers
* and mail it is also a good indicator how much cargo would be brought to
* the station.
* @post Values < 8 means this tile does not accept this cargo.
* @note Resulting items are of the type int32 (indicating acceptance).
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vCargoAcceptance : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vCargoAcceptance"; }
/**
* @param cargo_id The cargo to check the acceptance for.
* @param width The width of your station.
* @param height The height of your station.
* @param radius The radius of your station-type.
*/
AITileList_vCargoAcceptance(CargoID cargo_id, uint width, uint height, uint radius) :
cargo_id(cargo_id),
width(width),
height(height),
radius(radius)
{}
private:
CargoID cargo_id;
uint width, height, radius;
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 tile) const;
};
/**
* Get the amount of tiles producing cargo for all tiles in AITileList.
* This counts the tiles that produce this cargo. It doesn't give any
* indication about the amount it will be producing.
* @note Town(houses) are not included in the value.
* @note Resulting items are of the type int32 (indicating tiles of production).
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vCargoProduction : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vCargoProduction"; }
/**
* @param cargo_id The cargo to check the production for.
* @param width The width of your station.
* @param height The height of your station.
* @param radius The radius of your station-type.
*/
AITileList_vCargoProduction(CargoID cargo_id, uint width, uint height, uint radius) :
cargo_id(cargo_id),
width(width),
height(height),
radius(radius)
{}
private:
CargoID cargo_id;
uint width, height, radius;
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 tile) const;
};
/**
* Get the manhattan distance to a tile for entries in an AITileList instance.
* @note Resulting items are of the type uint32.
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vDistanceManhattanToTile : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vDistanceManhattanToTile"; }
/**
* @param tile The tile to get the distance to.
*/
AITileList_vDistanceManhattanToTile(TileIndex tile) :
tile(tile)
{}
private:
TileIndex tile;
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 station) const;
};
/**
* Get the square distance to a tile for entries in an AITileList instance.
* @note Resulting items are of the type uint32.
* @note Can only operate on an AITileList instance.
* @ingroup AITileList
*/
class AITileList_vDistanceSquareToTile : public AIAbstractList::Valuator {
public:
static const char *GetClassName() { return "AITileList_vDistanceSquareToTile"; }
/**
* @param tile The tile to get the distance to.
*/
AITileList_vDistanceSquareToTile(TileIndex tile) :
tile(tile)
{}
private:
TileIndex tile;
const char *GetListName() const { return "AITileList"; }
int32 Valuate(int32 station) const;
};
#endif /* AI_TILELIST_VALUATOR_HPP */