src/ai/api/ai_town.hpp
author truebrain
Mon, 31 Mar 2008 06:32:27 +0000
branchnoai
changeset 9829 80fbe02a4184
parent 9814 be51ea0adc29
child 9838 0839682a601b
permissions -rw-r--r--
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
[NoAI] -Documentation: fixed the order of functions: SetNN before GetNN, Build after Set/Get, Remove after Build. This makes reading the docs more easy
[NoAI] -Documentation: Removed unneeded comments which were direct copy/paste all over the place
[NoAI] -Fix: missing $Id$ tags
/* $Id$ */

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

#ifndef AI_TOWN_HPP
#define AI_TOWN_HPP

#include "ai_object.hpp"
#include "../../town_type.h"

/**
 * 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 town_id has to be valid (use IsValidTown()).
	 * @return the name of the town.
	 * @note the returned name must be free'd (C++ only).
	 */
	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 town_id has to be valid (use IsValidTown()).
	 * @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 town_id has to be valid (use IsValidTown()).
	 * @return the location of the town.
	 * @post return value is always valid with AIMap::IsValidTile().
	 */
	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.
	 * @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.
	 * @return The distance between town and tile.
	 */
	static int32 GetDistanceSquareToTile(TownID town_id, TileIndex tile);
};

#endif /* AI_TOWN_HPP */