src/ai/api/ai_sign.hpp
author truebrain
Sat, 23 Feb 2008 16:21:10 +0000
branchnoai
changeset 9746 e4ab7ea8d897
parent 9737 ee408edf3851
child 9801 03a3eebd7fb7
permissions -rw-r--r--
(svn r12226) [NoAI] -Fix: remove the dep for AIStationList_Vehicle on AIStationList, as Squirrel doesn't like it
/* $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 positive and below AIMap::GetMapSize().
	 */
	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 location is always positive and below AIMap::GetMapSize()
	 * @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 */