author | truelight |
Mon, 19 Mar 2007 12:23:45 +0000 | |
branch | noai |
changeset 9473 | dcbcd1c4496d |
parent 9454 | ee6a65b37b82 |
child 9475 | 58c20c0e394f |
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 |
|
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
11 |
typedef bool (AIModeProc)(TileIndex tile, uint32 p1, uint32 p2, uint32 flags, uint procc, int32 costs); |
9450
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; |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
23 |
AIObject *mode_instance; |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
24 |
uint delay; |
9452
4c5eedbc3ba9
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents:
9450
diff
changeset
|
25 |
int32 costs; |
9450
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 |
|
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 |
* 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
|
30 |
*/ |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
31 |
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
|
32 |
|
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
33 |
protected: |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
34 |
/** |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
35 |
* 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
|
36 |
*/ |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
37 |
static bool 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
|
38 |
|
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
39 |
/** |
9452
4c5eedbc3ba9
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents:
9450
diff
changeset
|
40 |
* Sets the DoCommand costs counter to a value. |
9414
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
41 |
*/ |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
42 |
static void SetDoCommandCosts(int32 value); |
9414
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
43 |
|
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
44 |
/** |
9452
4c5eedbc3ba9
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents:
9450
diff
changeset
|
45 |
* Increase the current value of the DoCommand costs counter. |
9414
a7f7bbec08da
(svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents:
9388
diff
changeset
|
46 |
*/ |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
47 |
static void IncreaseDoCommandCosts(int32 value); |
9452
4c5eedbc3ba9
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents:
9450
diff
changeset
|
48 |
|
4c5eedbc3ba9
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents:
9450
diff
changeset
|
49 |
/** |
4c5eedbc3ba9
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents:
9450
diff
changeset
|
50 |
* Get the current DoCommand costs counter. |
4c5eedbc3ba9
(svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents:
9450
diff
changeset
|
51 |
*/ |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
52 |
static int32 GetDoCommandCosts(); |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
53 |
|
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 |
* 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
|
56 |
*/ |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
57 |
static void SetDoCommandMode(AIModeProc *proc, AIObject *instance); |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
58 |
|
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 |
* 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
|
61 |
*/ |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
62 |
static AIModeProc *GetDoCommandMode(); |
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
63 |
|
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
64 |
/** |
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
65 |
* Get the instance of the current mode your AI is currently under. |
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
66 |
*/ |
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
67 |
static AIObject *GetDoCommandModeInstance(); |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
68 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
69 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
70 |
* 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
|
71 |
*/ |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
72 |
static void SetDoCommandDelay(uint ticks); |
9450
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
73 |
|
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
74 |
/** |
d675836e865c
(svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents:
9448
diff
changeset
|
75 |
* 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
|
76 |
*/ |
9473
dcbcd1c4496d
(svn r9318) [NoAI] -Add: added new param in ModeCallback: costs
truelight
parents:
9454
diff
changeset
|
77 |
static uint GetDoCommandDelay(); |
9454
ee6a65b37b82
(svn r9284) [NoAI] -Fix: reset internal static AIObject data per AI on AI startup
truelight
parents:
9452
diff
changeset
|
78 |
|
ee6a65b37b82
(svn r9284) [NoAI] -Fix: reset internal static AIObject data per AI on AI startup
truelight
parents:
9452
diff
changeset
|
79 |
public: |
ee6a65b37b82
(svn r9284) [NoAI] -Fix: reset internal static AIObject data per AI on AI startup
truelight
parents:
9452
diff
changeset
|
80 |
/** |
ee6a65b37b82
(svn r9284) [NoAI] -Fix: reset internal static AIObject data per AI on AI startup
truelight
parents:
9452
diff
changeset
|
81 |
* If an AI starts, some internals needs to be resetted. This function |
ee6a65b37b82
(svn r9284) [NoAI] -Fix: reset internal static AIObject data per AI on AI startup
truelight
parents:
9452
diff
changeset
|
82 |
* takes care of that. |
ee6a65b37b82
(svn r9284) [NoAI] -Fix: reset internal static AIObject data per AI on AI startup
truelight
parents:
9452
diff
changeset
|
83 |
*/ |
ee6a65b37b82
(svn r9284) [NoAI] -Fix: reset internal static AIObject data per AI on AI startup
truelight
parents:
9452
diff
changeset
|
84 |
static void ResetInternalPlayerData(); |
9361
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
85 |
}; |
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
86 |
|
7bb2bd22b16e
(svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff
changeset
|
87 |
#endif /* AI_OBJECT_HPP */ |