src/ai/api/ai_object.hpp
author truelight
Sun, 18 Mar 2007 18:02:27 +0000
branchnoai
changeset 9452 4c5eedbc3ba9
parent 9450 d675836e865c
child 9454 ee6a65b37b82
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.
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;
9452
4c5eedbc3ba9 (svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents: 9450
diff changeset
    24
		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
    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
	/**
d675836e865c (svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents: 9448
diff changeset
    28
	 * 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
    29
	 */
d675836e865c (svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents: 9448
diff changeset
    30
	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
    31
9361
7bb2bd22b16e (svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff changeset
    32
protected:
7bb2bd22b16e (svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff changeset
    33
	/**
7bb2bd22b16e (svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff changeset
    34
	 * 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
    35
	 */
9452
4c5eedbc3ba9 (svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents: 9450
diff changeset
    36
	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
    37
a7f7bbec08da (svn r9212) [NoAI] -Add: added CmdFailed and CmdSucceeded in AIObject() and used it
truelight
parents: 9388
diff changeset
    38
	/**
9452
4c5eedbc3ba9 (svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents: 9450
diff changeset
    39
	 * 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
    40
	 */
9452
4c5eedbc3ba9 (svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents: 9450
diff changeset
    41
	void SetDoCommandCosts(int32 value);
9414
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
	/**
9452
4c5eedbc3ba9 (svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents: 9450
diff changeset
    44
	 * 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
    45
	 */
9452
4c5eedbc3ba9 (svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents: 9450
diff changeset
    46
	void IncreaseDoCommandCosts(int32 value);
4c5eedbc3ba9 (svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents: 9450
diff changeset
    47
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
	 * 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
    50
	 */
4c5eedbc3ba9 (svn r9282) [NoAI] -Add: added AIAccounting, which tracks the cost of your buying/selling.
truelight
parents: 9450
diff changeset
    51
	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
    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
	/**
d675836e865c (svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents: 9448
diff changeset
    54
	 * 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
    55
	 */
d675836e865c (svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents: 9448
diff changeset
    56
	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
    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
	/**
d675836e865c (svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents: 9448
diff changeset
    59
	 * 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
    60
	 */
d675836e865c (svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents: 9448
diff changeset
    61
	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
    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
	/**
d675836e865c (svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents: 9448
diff changeset
    64
	 * 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
    65
	 */
d675836e865c (svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents: 9448
diff changeset
    66
	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
    67
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
	 * 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
    70
	 */
d675836e865c (svn r9278) [NoAI] -Add: added AISettings which adds the function to control the Delay-value on DoCommands
truelight
parents: 9448
diff changeset
    71
	uint GetDoCommandDelay();
9361
7bb2bd22b16e (svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff changeset
    72
};
7bb2bd22b16e (svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff changeset
    73
7bb2bd22b16e (svn r9144) [NoAI] -Change: moved command functions to AIObject, and made AIBase depend on AIObject
truelight
parents:
diff changeset
    74
#endif /* AI_OBJECT_HPP */