From b7a655bf4cafc68e14cade593e8b1aca7f04f7dd Mon Sep 17 00:00:00 2001 From: truebrain Date: Sun, 13 Nov 2011 20:43:48 +0000 Subject: (svn r23209) -Codechange: track the current active script instance directly, instead of assuming the current company points you to the right one. --- src/ai/ai_instance.hpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/ai/ai_instance.hpp') diff --git a/src/ai/ai_instance.hpp b/src/ai/ai_instance.hpp index 65884dc71..b0b32b3b5 100644 --- a/src/ai/ai_instance.hpp +++ b/src/ai/ai_instance.hpp @@ -81,11 +81,16 @@ public: /** * Create a new AI. - * @param info The AI to create the instance of. */ - AIInstance(class AIInfo *info); + AIInstance(); ~AIInstance(); + /** + * Initialize the AI and prepare it for its first run. + * @param info The AI to create the instance of. + */ + void Initialize(class AIInfo *info); + /** * An AI in multiplayer waits for the server to handle his DoCommand. * It keeps waiting for this until this function is called. @@ -105,7 +110,12 @@ public: /** * Get the storage of this AI. */ - static class AIStorage *GetStorage(); + class AIStorage *GetStorage(); + + /** + * Get the log pointer of this AI. + */ + void *GetLogPointer(); /** * Return a true/false reply for a DoCommand. @@ -173,6 +183,22 @@ public: * @return The number of operations to execute. */ SQInteger GetOpsTillSuspend(); + + /** + * DoCommand callback function for all commands executed by AIs. + * @param result The result of the command. + * @param tile The tile on which the command was executed. + * @param p1 p1 as given to DoCommandPInternal. + * @param p2 p2 as given to DoCommandPInternal. + */ + void DoCommandCallback(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2); + + /** + * Insert an event for this AI. + * @param event The event to insert. + */ + void InsertEvent(class AIEvent *event); + private: class AIController *controller; ///< The AI main class. class AIStorage *storage; ///< Some global information for each running AI. -- cgit v1.2.3-54-g00ecf