truelight@9361: /* $Id$ */ truelight@9361: truelight@9416: /** @file ai_object.hpp declaration of class for AIObject class */ truelight@9361: truelight@9361: #ifndef AI_OBJECT_HPP truelight@9361: #define AI_OBJECT_HPP truelight@9361: truelight@9441: #include "../../stdafx.h" truelight@9441: #include "../../functions.h" truelight@9679: #include "../../misc/countedptr.hpp" truelight@9361: truelight@9475: /** truelight@9475: * The callback function for Mode-classes. truelight@9475: */ glx@9629: typedef bool (AIModeProc)(TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCost costs); truelight@9450: truelight@9448: /** truelight@9448: * Uper-parent object of all API classes. You should never use this class in truelight@9448: * your AI, as it doesn't publish any public functions. It is used truelight@9448: * internally to have a common place to handle general things, like internal truelight@9448: * command processing, and command-validation checks. truelight@9448: */ truelight@9679: class AIObject : public SimpleCountedObject { truelight@9450: private: truelight@9450: struct AIDoCommandStruct { truelight@9450: AIModeProc *mode; truelight@9473: AIObject *mode_instance; truelight@9450: uint delay; glx@9629: CommandCost costs; truelight@9496: VehicleID new_vehicle_id; rubidium@9511: SignID new_sign_id; truelight@9680: void *event_data; truelight@9450: }; truelight@9450: truelight@9450: /** truelight@9450: * The current mode of the AI players. truelight@9450: */ truelight@9450: static AIDoCommandStruct *GetDoCommandStruct(PlayerID player); truelight@9450: truelight@9361: protected: truelight@9361: /** truelight@9361: * Executes a raw DoCommand for the AI. truelight@9361: */ truelight@9695: static bool DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint procc, bool water_protection = true); truelight@9414: truelight@9414: /** truelight@9452: * Sets the DoCommand costs counter to a value. truelight@9414: */ glx@9629: static void SetDoCommandCosts(Money value); truelight@9414: truelight@9414: /** truelight@9452: * Increase the current value of the DoCommand costs counter. truelight@9414: */ glx@9629: static void IncreaseDoCommandCosts(Money value); truelight@9452: truelight@9452: /** truelight@9452: * Get the current DoCommand costs counter. truelight@9452: */ glx@9629: static Money GetDoCommandCosts(); truelight@9450: truelight@9450: /** truelight@9450: * Set the current mode of your AI to this proc. truelight@9450: */ truelight@9473: static void SetDoCommandMode(AIModeProc *proc, AIObject *instance); truelight@9450: truelight@9450: /** truelight@9450: * Get the current mode your AI is currently under. truelight@9450: */ truelight@9473: static AIModeProc *GetDoCommandMode(); truelight@9473: truelight@9473: /** truelight@9473: * Get the instance of the current mode your AI is currently under. truelight@9473: */ truelight@9473: static AIObject *GetDoCommandModeInstance(); truelight@9450: truelight@9450: /** truelight@9450: * Set the delay of the DoCommand. truelight@9450: */ truelight@9473: static void SetDoCommandDelay(uint ticks); truelight@9450: truelight@9450: /** truelight@9450: * Get the delay of the DoCommand. truelight@9450: */ truelight@9473: static uint GetDoCommandDelay(); truelight@9454: truelight@9496: /** truelight@9496: * Get the latest stored new_vehicle_id. truelight@9496: */ truelight@9496: static VehicleID GetNewVehicleID(); truelight@9496: rubidium@9511: /** rubidium@9511: * Get the latest stored new_sign_id. rubidium@9511: */ rubidium@9511: static SignID GetNewSignID(); rubidium@9511: truelight@9680: /** truelight@9680: * Get the pointer to store event data in. truelight@9680: */ truelight@9682: static void *&GetEventPointer(); truelight@9680: truelight@9454: public: truelight@9454: /** truelight@9496: * Store a new_vehicle_id per player. truelight@9496: * @note NEVER use this yourself in your AI! truelight@9496: */ truelight@9496: static void SetNewVehicleID(VehicleID vehicle); truelight@9496: truelight@9496: /** rubidium@9511: * Store a new_sign_id per player. rubidium@9511: * @note NEVER use this yourself in your AI! rubidium@9511: */ rubidium@9511: static void SetNewSignID(SignID vehicle); rubidium@9511: rubidium@9511: /** truelight@9454: * If an AI starts, some internals needs to be resetted. This function truelight@9454: * takes care of that. truelight@9496: * @note NEVER use this yourself in your AI! truelight@9454: */ truelight@9454: static void ResetInternalPlayerData(); truelight@9361: }; truelight@9361: truelight@9361: #endif /* AI_OBJECT_HPP */