src/ai/api/ai_execmode.hpp
author truelight
Sun, 18 Mar 2007 18:02:27 +0000
branchnoai
changeset 9452 4c5eedbc3ba9
parent 9450 d675836e865c
child 9473 dcbcd1c4496d
permissions -rw-r--r--
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
DoCommand no longer returns the cost, it returns a bool.
Costs are available via this Accounting class.
/* $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;

protected:
	static bool ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc);

public:
	/**
	 * 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();
};

#ifdef DEFINE_SQUIRREL_CLASS
void SQAIExecModeRegister(Squirrel *engine) {
	DefSQClass <AIExecMode> SQAIExecMode("AIExecMode");
	SQAIExecMode.PreRegister(engine);
	SQAIExecMode.AddConstructor(engine);
	SQAIExecMode.PostRegister(engine);
}
#endif /* SQUIRREL_CLASS */

#endif /* AI_EXECMODE_HPP */