(svn r9284) [NoAI] -Fix: reset internal static AIObject data per AI on AI startup
/* $Id$ */
/** @file ai_object.hpp declaration of class for AIObject class */
#ifndef AI_OBJECT_HPP
#define AI_OBJECT_HPP
#include "../../stdafx.h"
#include "../../functions.h"
typedef bool (AIModeProc)(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
/**
* Uper-parent object of all API classes. You should never use this class in
* your AI, as it doesn't publish any public functions. It is used
* internally to have a common place to handle general things, like internal
* command processing, and command-validation checks.
*/
class AIObject {
private:
struct AIDoCommandStruct {
AIModeProc *mode;
uint delay;
int32 costs;
};
/**
* The current mode of the AI players.
*/
static AIDoCommandStruct *GetDoCommandStruct(PlayerID player);
protected:
/**
* Executes a raw DoCommand for the AI.
*/
bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);
/**
* Sets the DoCommand costs counter to a value.
*/
void SetDoCommandCosts(int32 value);
/**
* Increase the current value of the DoCommand costs counter.
*/
void IncreaseDoCommandCosts(int32 value);
/**
* Get the current DoCommand costs counter.
*/
int32 GetDoCommandCosts();
/**
* Set the current mode of your AI to this proc.
*/
void SetDoCommandMode(AIModeProc *proc);
/**
* Get the current mode your AI is currently under.
*/
AIModeProc *GetDoCommandMode();
/**
* Set the delay of the DoCommand.
*/
void SetDoCommandDelay(uint ticks);
/**
* Get the delay of the DoCommand.
*/
uint GetDoCommandDelay();
public:
/**
* If an AI starts, some internals needs to be resetted. This function
* takes care of that.
*/
static void ResetInternalPlayerData();
};
#endif /* AI_OBJECT_HPP */