src/ai/api/ai_sign.hpp
author truebrain
Sun, 08 Jun 2008 21:20:48 +0000
branchnoai
changeset 10871 326ee226e9d7
parent 10855 90904faa1890
child 10952 d16212cc2394
permissions -rw-r--r--
(svn r13422) [NoAI] -Change [API CHANGE]: remove Stop() as part of the AIController. This means you no longer need to have a Stop() function in your AI, nor is it ever called. This because it was silly, never used, and couldn't do anything real (all Sleep/DoCommands resulted in an assert, as the game expected the company to be gone).
/* $Id$ */

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

#ifndef AI_SIGN_HPP
#define AI_SIGN_HPP

#include "ai_object.hpp"
#include "ai_error.hpp"
#include "ai_company.hpp"

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

	/**
	 * All sign related error messages.
	 */
	enum ErrorMessages {

		/** Base for sign building related errors */
		ERR_SIGN_BASE = AIError::ERR_CAT_SIGN << AIError::ERR_CAT_BIT_SIZE,

		/** Too many signs have been placed */
		ERR_SIGN_TOO_MANY_SIGNS,             // [STR_2808_TOO_MANY_SIGNS]
	};

	/**
	 * 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();

	/**
	 * 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 IsValidSign(sign_id).
	 * @return The text on the sign.
	 */
	static char *GetText(SignID sign_id);

	/**
	 * Gets the location of the sign.
	 * @param sign_id The sign to get the location of.
	 * @pre IsValidSign(sign_id).
	 * @return The location of the sign.
	 */
	static TileIndex GetLocation(SignID sign_id);

	/**
	 * Get the owner of a sign.
	 * @param sign_id The sign to get the owner of.
	 * @pre IsValidSign(sign_id).
	 * @return The owner of the sign.
	 */
	static AICompany::CompanyID GetOwner(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 of non-zero length.
	 * @exception ERR_SIGN_TOO_MANY_SIGNS
	 * @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);

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

#endif /* AI_SIGN_HPP */