truelight@9450: /* $Id$ */ truelight@9450: truelight@9450: /** @file ai_execmode.hpp class to switch the AI to Execute mode */ truelight@9450: truelight@9450: #ifndef AI_EXECMODE_HPP truelight@9450: #define AI_EXECMODE_HPP truelight@9450: truelight@9450: #include "ai_object.hpp" truelight@9450: truelight@9450: /** truelight@9450: * Class to switch current mode to Execute mode. truelight@9450: * If you create an instance of this class, the mode will be switched to truelight@9450: * Execute. The original mode is stored and recovered from when ever the truelight@9450: * instance is destroyed. truelight@9450: * In Execute mode all commands you do are executed for real. truelight@9450: */ truelight@9450: class AIExecMode : public AIObject { truelight@9450: private: truelight@9450: AIModeProc *last_mode; truelight@9473: AIObject *last_instance; truelight@9450: truelight@9450: protected: truelight@9475: /** truelight@9475: * The callback proc for Execute mode. truelight@9475: */ truelight@9486: static bool ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint procc, int32 costs); truelight@9450: truelight@9450: public: truelight@9450: /** truelight@9450: * Creating instance of this class switches the build mode to Execute. truelight@9450: * @note when the instance is destroyed, he restores the mode that was truelight@9450: * current when the instance was created! truelight@9450: */ truelight@9450: AIExecMode(); truelight@9450: truelight@9450: /** truelight@9450: * Destroying this instance reset the building mode to the mode it was truelight@9450: * in when the instance was created. truelight@9450: */ truelight@9450: ~AIExecMode(); truelight@9450: }; truelight@9450: truelight@9450: #ifdef DEFINE_SQUIRREL_CLASS truelight@9450: void SQAIExecModeRegister(Squirrel *engine) { truelight@9450: DefSQClass SQAIExecMode("AIExecMode"); truelight@9450: SQAIExecMode.PreRegister(engine); truelight@9450: SQAIExecMode.AddConstructor(engine); truelight@9450: SQAIExecMode.PostRegister(engine); truelight@9450: } rubidium@9520: #endif /* DEFINE_SQUIRREL_CLASS */ truelight@9450: truelight@9450: #endif /* AI_EXECMODE_HPP */