(svn r12431) [NoAI] -Add: added AIEventSubsidiaryOffer, which keeps you informed about new Subsidiaries
/* $Id$ */
/** @file ai_controller.hpp declaration of class for AIController class */
#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.
*/
class AIController {
private:
uint tick;
public:
/**
* Initializer of the AIController.
*/
AIController() :
tick(0)
{}
/**
* Destructor of the AIController.
*/
virtual ~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.
*/
virtual void Start() = 0;
/**
* When this function is called, the AI must stop as soon as possible.
* It may not call any function that might suspend, like DoCommand()
* and Sleep().
* @note Cannot be called from within your AI.
*/
virtual void Stop() = 0;
/**
* 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++; }
/**
* Find at which tick your AI currently is.
* @return returns the current tick.
*/
uint GetTick() { return this->tick; }
/**
* 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);
/**
* Print a message to the AI log.
* @param error_msg If true, it is marked as error message.
* @param message The message you want to log.
*/
static void Print(bool error_msg, const char *message);
};
#endif /* AI_CONTROLLER_HPP */