author | truebrain |
Mon, 21 Apr 2008 20:52:54 +0000 | |
branch | noai |
changeset 10292 | 7856e972f8aa |
parent 9836 | 54afebfded49 |
child 10300 | f947a1d7e544 |
permissions | -rw-r--r-- |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
2 |
|
9829
80fbe02a4184
(svn r12491) [NoAI] -Documentation: made parts of the comments more uniform (@file header and class header)
truebrain
parents:
9814
diff
changeset
|
3 |
/** @file ai_industry.hpp Everything to query and build industries. */ |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
4 |
|
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
5 |
#ifndef AI_INDUSTRY_HPP |
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
6 |
#define AI_INDUSTRY_HPP |
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
7 |
|
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
8 |
#include "ai_object.hpp" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9710
diff
changeset
|
9 |
#include "../../industry.h" |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
10 |
|
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
11 |
/** |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
12 |
* Class that handles all industry related functions. |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
13 |
*/ |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
14 |
class AIIndustry : public AIObject { |
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
15 |
public: |
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
16 |
static const char *GetClassName() { return "AIIndustry"; } |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
17 |
|
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9526
diff
changeset
|
18 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
19 |
* Gets the maximum industry index; there are no valid industries with a |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
20 |
* higher index. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
21 |
* @return The maximum industry index. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
22 |
* @post Return value is always non-negative. |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
23 |
*/ |
9737
ee408edf3851
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents:
9723
diff
changeset
|
24 |
static IndustryID GetMaxIndustryID(); |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
25 |
|
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
26 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
27 |
* Gets the number of industries. This is different than GetMaxIndustryID() |
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
28 |
* because of the way OpenTTD works internally. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
29 |
* @return The number of industries. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
30 |
* @post Return value is always non-negative. |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
31 |
*/ |
9737
ee408edf3851
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents:
9723
diff
changeset
|
32 |
static int32 GetIndustryCount(); |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
33 |
|
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
34 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
35 |
* Checks whether the given industry index is valid. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
36 |
* @param industry_id The index to check. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
37 |
* @return True if and only if the industry is valid. |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
38 |
*/ |
9497
f6678533ccba
(svn r9369) [NoAI] -Codechange: make some IsValidXXX() function static, so they can be used by the other classes without the need for an instance.
rubidium
parents:
9448
diff
changeset
|
39 |
static bool IsValidIndustry(IndustryID industry_id); |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
40 |
|
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
41 |
/** |
9448
2a4c4340233d
(svn r9273) [NoAI] -Documentation: finished documenting the last few files; they should now be readable for any non-programmer.
truelight
parents:
9427
diff
changeset
|
42 |
* Get the name of the industry. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
43 |
* @param industry_id The industry to get the name of. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
44 |
* @pre IsValidIndustry(industry_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
45 |
* @return The name of the industry. |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
46 |
*/ |
9737
ee408edf3851
(svn r12216) [NoAI] -Codechange: made most functions 'static', which removes the need to create an instance to get, for example, engine information, and therefor heavily simplifying AI creation (Morloth)
truebrain
parents:
9723
diff
changeset
|
47 |
static char *GetName(IndustryID industry_id); |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
48 |
|
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
49 |
/** |
9649
bc8c06513f5b
(svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents:
9596
diff
changeset
|
50 |
* Gets the production of a cargo of the industry. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
51 |
* @param industry_id The index of the industry. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
52 |
* @param cargo_id The index of the cargo. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
53 |
* @pre IsValidIndustry(industry_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
54 |
* @pre AICargo::IsValidCargo(cargo_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
55 |
* @return The production of the cargo for this industry, or -1 if |
9787
959f15f96a1c
(svn r12283) [NoAI] -Fix: document that GetProduction can return -1 if the Industry doesn't produce the Cargo (tnx Progman)
truebrain
parents:
9737
diff
changeset
|
56 |
* this industry doesn't produce this cargo. |
9649
bc8c06513f5b
(svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents:
9596
diff
changeset
|
57 |
*/ |
9650
7e5e1a7ecbff
(svn r10545) [NoAI] -Fix: GetProduction doesn't return a tile, but a value (tnx glx)
truelight
parents:
9649
diff
changeset
|
58 |
static int32 GetProduction(IndustryID industry_id, CargoID cargo_id); |
9649
bc8c06513f5b
(svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents:
9596
diff
changeset
|
59 |
|
bc8c06513f5b
(svn r10544) [NoAI] -Add: added AIIndustryList to list industries
truelight
parents:
9596
diff
changeset
|
60 |
/** |
9710
ba44f8c1fd52
(svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents:
9650
diff
changeset
|
61 |
* See if an industry accepts a certain cargo. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
62 |
* @param industry_id The index of the industry. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
63 |
* @param cargo_id The index of the cargo. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
64 |
* @pre IsValidIndustry(industry_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
65 |
* @pre AICargo::IsValidCargo(cargo_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
66 |
* @return The production of the cargo for this industry. |
9710
ba44f8c1fd52
(svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents:
9650
diff
changeset
|
67 |
*/ |
ba44f8c1fd52
(svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents:
9650
diff
changeset
|
68 |
static bool IsCargoAccepted(IndustryID industry_id, CargoID cargo_id); |
ba44f8c1fd52
(svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents:
9650
diff
changeset
|
69 |
|
ba44f8c1fd52
(svn r11294) [NoAI] -Add: added AIIndustry::IsCargoAccepted + Valuator (on request by Kilinich)
truelight
parents:
9650
diff
changeset
|
70 |
/** |
9810
a84fc1be9e3b
(svn r12327) [NoAI] -Add: GetLastMonth(Production|Transported) (Morloth)
truebrain
parents:
9801
diff
changeset
|
71 |
* Get the total last month's production of the given cargo at an industry. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
72 |
* @param industry_id The index of the industry. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
73 |
* @param cargo_id The index of the cargo. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
74 |
* @pre IsValidIndustry(industry_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
75 |
* @pre AICargo::IsValidCargo(cargo_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
76 |
* @return The last month's production of the given cargo for this industry. |
9810
a84fc1be9e3b
(svn r12327) [NoAI] -Add: GetLastMonth(Production|Transported) (Morloth)
truebrain
parents:
9801
diff
changeset
|
77 |
*/ |
a84fc1be9e3b
(svn r12327) [NoAI] -Add: GetLastMonth(Production|Transported) (Morloth)
truebrain
parents:
9801
diff
changeset
|
78 |
static uint16 GetLastMonthProduction(IndustryID industry_id, CargoID cargo_id); |
a84fc1be9e3b
(svn r12327) [NoAI] -Add: GetLastMonth(Production|Transported) (Morloth)
truebrain
parents:
9801
diff
changeset
|
79 |
|
a84fc1be9e3b
(svn r12327) [NoAI] -Add: GetLastMonth(Production|Transported) (Morloth)
truebrain
parents:
9801
diff
changeset
|
80 |
/** |
a84fc1be9e3b
(svn r12327) [NoAI] -Add: GetLastMonth(Production|Transported) (Morloth)
truebrain
parents:
9801
diff
changeset
|
81 |
* Get the total amount of cargo transported from an industry last month. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
82 |
* @param industry_id The index of the industry. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
83 |
* @param cargo_id The index of the cargo. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
84 |
* @pre IsValidIndustry(industry_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
85 |
* @pre AICargo::IsValidCargo(cargo_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
86 |
* @return The amount of given cargo transported from this industry last month. |
9810
a84fc1be9e3b
(svn r12327) [NoAI] -Add: GetLastMonth(Production|Transported) (Morloth)
truebrain
parents:
9801
diff
changeset
|
87 |
*/ |
a84fc1be9e3b
(svn r12327) [NoAI] -Add: GetLastMonth(Production|Transported) (Morloth)
truebrain
parents:
9801
diff
changeset
|
88 |
static uint16 GetLastMonthTransported(IndustryID industry_id, CargoID cargo_id); |
9814
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
89 |
|
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
90 |
/** |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
91 |
* Gets the location of the industry. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
92 |
* @param industry_id The index of the industry. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
93 |
* @pre IsValidIndustry(industry_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
94 |
* @return The location of the industry. |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
95 |
*/ |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
96 |
static TileIndex GetLocation(IndustryID industry_id); |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
97 |
|
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
98 |
/** |
9814
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
99 |
* Get the manhattan distance from the tile to the AIIndustry::GetLocation() |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
100 |
* of the industry. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
101 |
* @param industry_id The industry to get the distance to. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
102 |
* @param tile The tile to get the distance to. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
103 |
* @pre IsValidIndustry(industry_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
104 |
* @pre AIMap::IsValidTile(tile). |
9814
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
105 |
* @return The distance between industry and tile. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
106 |
*/ |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
107 |
static int32 GetDistanceManhattanToTile(IndustryID industry_id, TileIndex tile); |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
108 |
|
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
109 |
/** |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
110 |
* Get the square distance from the tile to the AIIndustry::GetLocation() |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
111 |
* of the industry. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
112 |
* @param industry_id The industry to get the distance to. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
113 |
* @param tile The tile to get the distance to. |
9836
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
114 |
* @pre IsValidIndustry(industry_id). |
54afebfded49
(svn r12502) [NoAI] -Documentation: even more comment consistancy
truebrain
parents:
9829
diff
changeset
|
115 |
* @pre AIMap::IsValidTile(tile). |
9814
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
116 |
* @return The distance between industry and tile. |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
117 |
*/ |
be51ea0adc29
(svn r12411) [NoAI] -Change [API CHANGE]: order of params of CargoIncome is changed
truebrain
parents:
9810
diff
changeset
|
118 |
static int32 GetDistanceSquareToTile(IndustryID industry_id, TileIndex tile); |
9405
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
119 |
}; |
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
120 |
|
df6f3b4b0038
(svn r9202) [NoAI] -Add: some initial functions for cargo and industries.
rubidium
parents:
diff
changeset
|
121 |
#endif /* AI_INDUSTRY_HPP */ |