summaryrefslogtreecommitdiff
path: root/src/ai/ai_storage.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/ai_storage.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/ai_storage.hpp')
-rw-r--r--src/ai/ai_storage.hpp78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/ai/ai_storage.hpp b/src/ai/ai_storage.hpp
new file mode 100644
index 000000000..2e85046b4
--- /dev/null
+++ b/src/ai/ai_storage.hpp
@@ -0,0 +1,78 @@
+/* $Id$ */
+
+/** @file ai_storage.hpp Defines AIStorage and includes all files required for it. */
+
+#ifndef AI_STORAGE_HPP
+#define AI_STORAGE_HPP
+
+#include "../command_func.h"
+#include "../map_func.h"
+#include "../network/network.h"
+#include "../company_func.h"
+#include "../signs_func.h"
+#include "../tunnelbridge.h"
+#include "../vehicle_func.h"
+#include "../group.h"
+
+#include <vector>
+
+/**
+ * The callback function for Mode-classes.
+ */
+typedef bool (AIModeProc)(TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCost costs);
+
+/**
+ * The storage for each AI. It keeps track of important information.
+ */
+class AIStorage {
+friend class AIObject;
+private:
+ AIModeProc *mode; //!< The current build mode we are int.
+ class AIObject *mode_instance; //!< The instance belonging to the current build mode.
+
+ uint delay; //!< The ticks of delay each DoCommand has.
+ bool allow_do_command; //!< Is the usage of DoCommands restricted?
+
+ CommandCost costs; //!< The costs the AI is tracking.
+ Money last_cost; //!< The last cost of the command.
+ uint last_error; //!< The last error of the command.
+ bool last_command_res; //!< The last result of the command.
+
+ VehicleID new_vehicle_id; //!< The ID of the new Vehicle.
+ SignID new_sign_id; //!< The ID of the new Sign.
+ TileIndex new_tunnel_endtile; //!< The TileIndex of the new Tunnel.
+ GroupID new_group_id; //!< The ID of the new Group.
+
+ std::vector<int> callback_value; //!< The values which need to survive a callback.
+
+ RoadType road_type; //!< The current roadtype we build.
+ RailType rail_type; //!< The current railtype we build.
+
+ void *event_data; //!< Pointer to the event data storage.
+ void *log_data; //!< Pointer to the log data storage.
+
+public:
+ AIStorage() :
+ mode (NULL),
+ mode_instance (NULL),
+ delay (1),
+ allow_do_command (true),
+ /* costs (can't be set) */
+ last_cost (0),
+ last_error (STR_NULL),
+ last_command_res (true),
+ new_vehicle_id (0),
+ new_sign_id (0),
+ new_tunnel_endtile(INVALID_TILE),
+ new_group_id (0),
+ /* calback_value (can't be set) */
+ road_type (INVALID_ROADTYPE),
+ rail_type (INVALID_RAILTYPE),
+ event_data (NULL),
+ log_data (NULL)
+ { }
+
+ ~AIStorage();
+};
+
+#endif /* AI_STORAGE_HPP */