src/ai/api/ai_sign.hpp
author truebrain
Wed, 26 Mar 2008 15:17:40 +0000
branchnoai
changeset 9823 0b7f816cf46f
parent 9801 03a3eebd7fb7
child 9829 80fbe02a4184
permissions -rw-r--r--
(svn r12431) [NoAI] -Add: added AIEventSubsidiaryOffer, which keeps you informed about new Subsidiaries
/* $Id$ */

/** @file ai_sign.hpp Everything to query and build signs */

#ifndef AI_SIGN_HPP
#define AI_SIGN_HPP

#include "ai_object.hpp"

/**
 * Class that handles all sign related functions.
 */
class AISign : public AIObject {
public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AISign"; }

	/**
	 * Gets the maximum sign index; there are no valid signs with a higher index.
	 * @return the maximum sign index.
	 * @post return value is always non-negative.
	 */
	static SignID GetMaxSignID();

	/**
	 * Gets the number of signs. This is different than GetMaxSignID()
	 *   because of the way OpenTTD works internally.
	 * @return the number of signs.
	 * @post return value is always non-negative.
	 */
	static int32 GetSignCount();

	/**
	 * Checks whether the given sign index is valid.
	 * @param sign_id the index to check.
	 * @return true if and only if the sign is valid.
	 */
	static bool IsValidSign(SignID sign_id);

	/**
	 * Get the text on the sign.
	 * @param sign_id the sign to get the text of.
	 * @pre sign_id has to be valid (use IsValidSign()).
	 * @return the text on the sign.
	 * @note the returned name must be free'd (C++ only).
	 */
	static char *GetText(SignID sign_id);

	/**
	 * Gets the location of the sign.
	 * @param sign_id the sign to get the location of.
	 * @pre sign_id has to be valid (use IsValidSign()).
	 * @return the location of the sign.
	 * @post return value is always valid with AIMap::IsValidTile().
	 */
	static TileIndex GetLocation(SignID sign_id);

	/**
	 * Removes a sign from the map.
	 * @param sign_id the sign to remove.
	 * @pre sign_id has to be valid (use IsValidSign()).
	 * @return true if and only if the sign has been removed.
	 */
	static bool RemoveSign(SignID sign_id);

	/**
	 * Builds a sign on the map.
	 * @param location the place to build the sign.
	 * @param text     the text to place on the sign.
	 * @pre AIMap::IsValidTile(location).
	 * @pre text is not NULL and non-empty, i.e. length is positive.
	 * @return the SignID of the build sign (use IsValidSign() to check for validity).
	 *   In test-mode it returns 0 if successful, or any other value to indicate
	 *   failure.
	 */
	static SignID BuildSign(TileIndex location, const char *text);
};

#endif /* AI_SIGN_HPP */