src/ai/api/ai_town.hpp
author truebrain
Thu, 24 Apr 2008 23:39:18 +0000
branchnoai
changeset 10339 ce6cd68d9eb8
parent 9838 0839682a601b
child 10360 3234cb59de55
permissions -rw-r--r--
(svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
-Note: this is perfectly safe; when a type changes, any sane compiler starts complaining about redefining the typedef to an other type
/* $Id$ */

/** @file ai_town.hpp Everything to query towns. */

#ifndef AI_TOWN_HPP
#define AI_TOWN_HPP

#include "ai_object.hpp"

/**
 * Class that handles all town related functions.
 */
class AITown : public AIObject {
public:
	static const char *GetClassName() { return "AITown"; }

	/**
	 * Gets the maximum town index; there are no valid towns with a higher index.
	 * @return The maximum town index.
	 * @post Return value is always non-negative.
	 */
	static TownID GetMaxTownID();

	/**
	 * Gets the number of towns. This is different than GetMaxTownID()
	 *   because of the way OpenTTD works internally.
	 * @return The number of towns.
	 * @post Return value is always non-negative.
	 */
	static int32 GetTownCount();

	/**
	 * Checks whether the given town index is valid.
	 * @param town_id The index to check.
	 * @return True if and only if the town is valid.
	 */
	static bool IsValidTown(TownID town_id);

	/**
	 * Get the name of the town.
	 * @param town_id The town to get the name of.
	 * @pre IsValidTown(town_id).
	 * @return The name of the town.
	 */
	static char *GetName(TownID town_id);

	/**
	 * Gets the number of inhabitants in the town.
	 * @param town_id The town to get the name of.
	 * @pre IsValidTown(town_id).
	 * @return The number of inhabitants.
	 * @post Return value is always non-negative.
	 */
	static int32 GetPopulation(TownID town_id);

	/**
	 * Gets the location of the town.
	 * @param town_id The location of the town.
	 * @pre IsValidTown(town_id).
	 * @return The location of the town.
	 */
	static TileIndex GetLocation(TownID town_id);

	/**
	 * Get the manhattan distance from the tile to the AITown::GetLocation()
	 *  of the town.
	 * @param town_id The town to get the distance to.
	 * @param tile The tile to get the distance to.
	 * @pre IsValidTown(town_id).
	 * @return The distance between town and tile.
	 */
	static int32 GetDistanceManhattanToTile(TownID town_id, TileIndex tile);

	/**
	 * Get the square distance from the tile to the AITown::GetLocation()
	 *  of the town.
	 * @param town_id The town to get the distance to.
	 * @param tile The tile to get the distance to.
	 * @pre IsValidTown(town_id).
	 * @return The distance between town and tile.
	 */
	static int32 GetDistanceSquareToTile(TownID town_id, TileIndex tile);
};

#endif /* AI_TOWN_HPP */