(svn r13422) [NoAI] -Change [API CHANGE]: remove Stop() as part of the AIController. This means you no longer need to have a Stop() function in your AI, nor is it ever called. This because it was silly, never used, and couldn't do anything real (all Sleep/DoCommands resulted in an assert, as the game expected the company to be gone).
/* $Id$ */
/** @file ai_controller.hpp The controller of the AI. */
#ifndef AI_CONTROLLER_HPP
#define AI_CONTROLLER_HPP
/**
* 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(const char *script, const char *class_name);
/**
* Destructor of the AIController.
*/
~AIController();
/**
* This function is called to start your AI. Your AI starts here. If you
* return from this function, your AI dies, so make sure that doesn't
* happen. It is okay to use while() {} loops, as long as you put a
* Sleep() in it to give the rest of the game time to do things. Also
* don't keep the system busy for too long, as people will consider
* that annoying.
* @note Cannot be called from within your AI.
*/
void Start();
/**
* 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();
/**
* Find at which tick your AI currently is.
* @return returns the current tick.
*/
uint GetTick();
/**
* Sleep for X ticks. The code continues after this line when the X AI ticks
* are passed. Mind that an AI tick is different from in-game ticks and
* differ per AI speed.
* @param ticks the ticks to wait
* @post the value of GetTick() will be changed exactly 'ticks' in value after
* calling this.
*/
static void Sleep(uint ticks);
/**
* When Squirrel triggers a print, this function is called.
* Squirrel calls this when 'print' is used, or when the script made an error.
* @param error_msg If true, it is a Squirrel error message.
* @param message The message Squirrel logged.
* @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 */