author | truelight |
Sun, 18 Mar 2007 16:02:23 +0000 | |
branch | noai |
changeset 9450 | d675836e865c |
parent 9448 | 2a4c4340233d |
child 9452 | 4c5eedbc3ba9 |
permissions | -rw-r--r-- |
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
1 |
/* $Id$ */ |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
2 |
|
9416
432e904ce0e1
(svn r9214) [NoAI] -Documentation: wrong @file flag
truelight
parents:
9414
diff
changeset
|
3 |
/** @file ai_object.hpp declaration of class for AIObject class */ |
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
4 |
|
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
5 |
#ifndef AI_OBJECT_HPP |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
6 |
#define AI_OBJECT_HPP |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
7 |
|
9441
03da911c8d5f
(svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
9427
diff
changeset
|
8 |
#include "../../stdafx.h" |
03da911c8d5f
(svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
9427
diff
changeset
|
9 |
#include "../../functions.h" |
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
10 |
|
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
11 |
typedef bool (AIModeProc)(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
12 |
|
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9441
diff
changeset
|
13 |
/** |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9441
diff
changeset
|
14 |
* Uper-parent object of all API classes. You should never use this class in |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9441
diff
changeset
|
15 |
* your AI, as it doesn't publish any public functions. It is used |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9441
diff
changeset
|
16 |
* internally to have a common place to handle general things, like internal |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9441
diff
changeset
|
17 |
* command processing, and command-validation checks. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9441
diff
changeset
|
18 |
*/ |
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
19 |
class AIObject { |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
20 |
private: |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
21 |
struct AIDoCommandStruct { |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
22 |
AIModeProc *mode; |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
23 |
uint delay; |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
24 |
}; |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
25 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
26 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
27 |
* The current mode of the AI players. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
28 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
29 |
static AIDoCommandStruct *GetDoCommandStruct(PlayerID player); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
30 |
|
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
31 |
protected: |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
32 |
/** |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
33 |
* Executes a raw DoCommand for the AI. |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
34 |
*/ |
9441
03da911c8d5f
(svn r9255) [NoAI] -Add: each AI now runs in a seperate thread. The main thread is suspended if any AI thread is running, only one AI thread runs at the time.
truelight
parents:
9427
diff
changeset
|
35 |
int32 DoCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc); |
9414
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
36 |
|
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
37 |
/** |
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
38 |
* Checks if the result of a DoCommand went wrong. |
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
39 |
*/ |
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
40 |
bool CmdFailed(int32 res); |
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
41 |
|
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
42 |
/** |
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
43 |
* Checks if the result of a DoCommand went okay. |
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
44 |
*/ |
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
45 |
bool CmdSucceeded(int32 res); |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
46 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
47 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
48 |
* Set the current mode of your AI to this proc. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
49 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
50 |
void SetDoCommandMode(AIModeProc *proc); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
51 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
52 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
53 |
* Get the current mode your AI is currently under. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
54 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
55 |
AIModeProc *GetDoCommandMode(); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
56 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
57 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
58 |
* Set the delay of the DoCommand. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
59 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
60 |
void SetDoCommandDelay(uint ticks); |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
61 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
62 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
63 |
* Get the delay of the DoCommand. |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
64 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
65 |
uint GetDoCommandDelay(); |
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
66 |
}; |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
67 |
|
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
68 |
#endif /* AI_OBJECT_HPP */ |