src/ai/api/ai_execmode.hpp
author rubidium
Sun, 03 Feb 2008 20:17:54 +0000
branchnoai
changeset 9724 b39bc69bb2f2
parent 9629 66dde6412125
child 9829 80fbe02a4184
permissions -rw-r--r--
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
/* $Id$ */

/** @file ai_execmode.hpp class to switch the AI to Execute mode */

#ifndef AI_EXECMODE_HPP
#define AI_EXECMODE_HPP

#include "ai_object.hpp"

/**
 * Class to switch current mode to Execute mode.
 * If you create an instance of this class, the mode will be switched to
 *   Execute. The original mode is stored and recovered from when ever the
 *   instance is destroyed.
 * In Execute mode all commands you do are executed for real.
 */
class AIExecMode : public AIObject {
private:
	AIModeProc *last_mode;
	AIObject *last_instance;

protected:
	/**
	 * The callback proc for Execute mode.
	 */
	static bool ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint procc, CommandCost costs);

public:
	/**
	 * The name of the class, needed by several sub-processes.
	 */
	static const char *GetClassName() { return "AIExecMode"; }

	/**
	 * Creating instance of this class switches the build mode to Execute.
	 * @note when the instance is destroyed, he restores the mode that was
	 *   current when the instance was created!
	 */
	AIExecMode();

	/**
	 * Destroying this instance reset the building mode to the mode it was
	 *   in when the instance was created.
	 */
	~AIExecMode();
};

#endif /* AI_EXECMODE_HPP */