--- a/src/ai/api/ai_controller.hpp Mon May 19 14:06:55 2008 +0000
+++ b/src/ai/api/ai_controller.hpp Mon May 19 14:11:21 2008 +0000
@@ -5,29 +5,26 @@
#ifndef AI_CONTROLLER_HPP
#define AI_CONTROLLER_HPP
-#include "../../stdafx.h"
-
/**
- * Class that handles the core of every AI. Each AI needs to extend this class
- * in order to work. The OpenTTD core makes sure GetTick gets increased when
- * needed.
+ * The Controller, the class each AI should extend. It creates the AI, makes
+ * sure the logic kicks in correctly, and that GetTick() has a valid value.
*/
class AIController {
private:
uint tick;
public:
+ static const char *GetClassName() { return "AIController"; }
+
/**
* Initializer of the AIController.
*/
- AIController() :
- tick(0)
- {}
+ AIController(const char *script, const char *class_name);
/**
* Destructor of the AIController.
*/
- virtual ~AIController() { }
+ ~AIController();
/**
* This function is called to start your AI. Your AI starts here. If you
@@ -38,7 +35,7 @@
* that annoying.
* @note Cannot be called from within your AI.
*/
- virtual void Start() = 0;
+ void Start();
/**
* When this function is called, the AI must stop as soon as possible.
@@ -46,20 +43,20 @@
* and Sleep().
* @note Cannot be called from within your AI.
*/
- virtual void Stop() = 0;
+ void Stop();
/**
* Increase the internal ticker. You should never call this yourself,
* as it is called by the OpenTTD system itself.
* @note Cannot be called from within your AI.
*/
- void IncreaseTick() { this->tick++; }
+ void IncreaseTick();
/**
* Find at which tick your AI currently is.
* @return returns the current tick.
*/
- uint GetTick() { return this->tick; }
+ uint GetTick();
/**
* Sleep for X ticks. The code continues after this line when the X AI ticks
@@ -79,6 +76,15 @@
* @note Use AILog.Info/Warning/Error instead of 'print'.
*/
static void Print(bool error_msg, const char *message);
+
+private:
+ class Squirrel *engine;
+ HSQOBJECT *SQ_instance;
+
+ /**
+ * Register all classes that are known inside the NoAI API.
+ */
+ void RegisterClasses();
};
#endif /* AI_CONTROLLER_HPP */