summaryrefslogtreecommitdiff
path: root/src/ai/api/ai_sign.hpp
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2009-01-12 17:11:45 +0000
committertruebrain <truebrain@openttd.org>2009-01-12 17:11:45 +0000
commita3dd7506d377b1434f913bd65c019eed52b64b6e (patch)
treeced1a262eb143ad6e64ec02f4a4c89835c0c32fd /src/ai/api/ai_sign.hpp
parent9294f9616866b9778c22076c19b5a32b4f85f788 (diff)
downloadopenttd-a3dd7506d377b1434f913bd65c019eed52b64b6e.tar.xz
(svn r15027) -Merge: tomatos and bananas left to be, here is NoAI for all to see.
NoAI is an API (a framework) to build your own AIs in. See: http://wiki.openttd.org/wiki/index.php/AI:Main_Page With many thanks to: - glx and Rubidium for their syncing, feedback and hard work - Yexo for his feedback, patches, and AIs which tested the system very deep - Morloth for his feedback and patches - TJIP for hosting a challenge which kept NoAI on track - All AI authors for testing our AI API, and all other people who helped in one way or another -Remove: all old AIs and their cheats/hacks
Diffstat (limited to 'src/ai/api/ai_sign.hpp')
-rw-r--r--src/ai/api/ai_sign.hpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/ai/api/ai_sign.hpp b/src/ai/api/ai_sign.hpp
new file mode 100644
index 000000000..8bf7e0b79
--- /dev/null
+++ b/src/ai/api/ai_sign.hpp
@@ -0,0 +1,96 @@
+/* $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);
+
+ /**
+ * Set the name of a sign.
+ * @param sign_id The sign to set the name for.
+ * @param name The name for the sign.
+ * @pre IsValidSign(sign_id).
+ * @pre 'name' must have at least one character.
+ * @pre 'name' must have at most 30 characters.
+ * @exception AIError::ERR_NAME_IS_NOT_UNIQUE
+ * @return True if and only if the name was changed.
+ */
+ static bool SetName(SignID sign_id, const char *name);
+
+ /**
+ * Get the name of the sign.
+ * @param sign_id The sign to get the name of.
+ * @pre IsValidSign(sign_id).
+ * @return The name of the sign.
+ */
+ static const char *GetName(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);
+
+ /**
+ * 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' must have at least one character.
+ * @pre 'text' must have at most 30 characters.
+ * @exception AISign::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 */