|
1 /* $Id$ */ |
|
2 |
|
3 /** @file ai_testmode.hpp class to switch the AI to Testing mode */ |
|
4 |
|
5 #ifndef AI_TESTMODE_HPP |
|
6 #define AI_TESTMODE_HPP |
|
7 |
|
8 #include "ai_object.hpp" |
|
9 |
|
10 /** |
|
11 * Class to switch current mode to Testing mode. |
|
12 * If you create an instance of this class, the mode will be switched to |
|
13 * Testing. The original mode is stored and recovered from when ever the |
|
14 * instance is destroyed. |
|
15 * In Test mode all the commands you execute aren't really executed. The |
|
16 * system only checks if it would be able to execute your requests, and what |
|
17 * the cost would be. |
|
18 */ |
|
19 class AITestMode : public AIObject { |
|
20 private: |
|
21 AIModeProc *last_mode; |
|
22 |
|
23 protected: |
|
24 static bool ModeProc(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); |
|
25 |
|
26 public: |
|
27 /** |
|
28 * Creating instance of this class switches the build mode to Testing. |
|
29 * @note when the instance is destroyed, he restores the mode that was |
|
30 * current when the instance was created! |
|
31 */ |
|
32 AITestMode(); |
|
33 |
|
34 /** |
|
35 * Destroying this instance reset the building mode to the mode it was |
|
36 * in when the instance was created. |
|
37 */ |
|
38 ~AITestMode(); |
|
39 }; |
|
40 |
|
41 #ifdef DEFINE_SQUIRREL_CLASS |
|
42 void SQAITestModeRegister(Squirrel *engine) { |
|
43 DefSQClass <AITestMode> SQAITestMode("AITestMode"); |
|
44 SQAITestMode.PreRegister(engine); |
|
45 SQAITestMode.AddConstructor(engine); |
|
46 SQAITestMode.PostRegister(engine); |
|
47 } |
|
48 #endif /* SQUIRREL_CLASS */ |
|
49 |
|
50 #endif /* AI_TESTMODE_HPP */ |