rubidium@9511: /* $Id$ */ rubidium@9511: truebrain@9829: /** @file ai_sign.hpp Everything to query and build signs. */ rubidium@9511: rubidium@9511: #ifndef AI_SIGN_HPP rubidium@9511: #define AI_SIGN_HPP rubidium@9511: rubidium@9511: #include "ai_object.hpp" rubidium@10090: #include "ai_error.hpp" rubidium@9511: rubidium@9511: /** rubidium@9513: * Class that handles all sign related functions. rubidium@9511: */ rubidium@9511: class AISign : public AIObject { rubidium@9511: public: truelight@9529: static const char *GetClassName() { return "AISign"; } truelight@9529: truebrain@10096: /** truebrain@10096: * All sign related error messages. truebrain@10096: */ rubidium@10090: enum ErrorMessages { rubidium@10090: rubidium@10090: /** Base for sign building related errors */ rubidium@10090: ERR_SIGN_BASE = AIError::ERR_CAT_SIGN << AIError::ERR_CAT_BIT_SIZE, rubidium@10090: rubidium@10090: /** Too many signs have been placed */ rubidium@10090: ERR_SIGN_TOO_MANY_SIGNS, // [STR_2808_TOO_MANY_SIGNS] rubidium@10090: }; rubidium@10090: truelight@9529: /** rubidium@9511: * Gets the maximum sign index; there are no valid signs with a higher index. truebrain@9838: * @return The maximum sign index. truebrain@9838: * @post Return value is always non-negative. rubidium@9511: */ truebrain@9737: static SignID GetMaxSignID(); rubidium@9511: rubidium@9511: /** rubidium@9513: * Gets the number of signs. This is different than GetMaxSignID() rubidium@9511: * because of the way OpenTTD works internally. truebrain@9838: * @return The number of signs. truebrain@9838: * @post Return value is always non-negative. rubidium@9511: */ truebrain@9737: static int32 GetSignCount(); rubidium@9511: rubidium@9511: /** rubidium@9511: * Checks whether the given sign index is valid. truebrain@9838: * @param sign_id The index to check. truebrain@9838: * @return True if and only if the sign is valid. rubidium@9511: */ rubidium@9511: static bool IsValidSign(SignID sign_id); rubidium@9511: rubidium@9511: /** rubidium@9511: * Get the text on the sign. truebrain@9838: * @param sign_id The sign to get the text of. truebrain@9838: * @pre IsValidSign(sign_id). truebrain@9838: * @return The text on the sign. rubidium@9511: */ truebrain@9737: static char *GetText(SignID sign_id); rubidium@9511: rubidium@9511: /** rubidium@9511: * Gets the location of the sign. truebrain@9838: * @param sign_id The sign to get the location of. truebrain@9838: * @pre IsValidSign(sign_id). truebrain@9838: * @return The location of the sign. rubidium@9511: */ truebrain@9737: static TileIndex GetLocation(SignID sign_id); rubidium@9511: rubidium@9511: /** rubidium@9511: * Builds a sign on the map. truebrain@9838: * @param location The place to build the sign. truebrain@9838: * @param text The text to place on the sign. truebrain@9801: * @pre AIMap::IsValidTile(location). rubidium@10090: * @pre text is of non-zero length. rubidium@10090: * @exception ERR_SIGN_TOO_MANY_SIGNS truebrain@9838: * @return The SignID of the build sign (use IsValidSign() to check for validity). truelight@9562: * In test-mode it returns 0 if successful, or any other value to indicate truelight@9562: * failure. rubidium@9511: */ truebrain@9737: static SignID BuildSign(TileIndex location, const char *text); truebrain@9829: truebrain@9829: /** truebrain@9829: * Removes a sign from the map. truebrain@9838: * @param sign_id The sign to remove. truebrain@9838: * @pre IsValidSign(sign_id). truebrain@9838: * @return True if and only if the sign has been removed. truebrain@9829: */ truebrain@9829: static bool RemoveSign(SignID sign_id); rubidium@9511: }; rubidium@9511: rubidium@9511: #endif /* AI_SIGN_HPP */