author | truebrain |
Wed, 26 Mar 2008 15:17:40 +0000 | |
branch | noai |
changeset 9823 | 0b7f816cf46f |
parent 9801 | 03a3eebd7fb7 |
child 9833 | 89a64246458f |
permissions | -rw-r--r-- |
9379
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
2 |
|
9430
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
3 |
/** @file ai_map.cpp handles the query-related of the AIMap class */ |
9379
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
4 |
|
9430
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
5 |
#include "ai_map.hpp" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9655
diff
changeset
|
6 |
#include "../../command_type.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9655
diff
changeset
|
7 |
#include "../../map_func.h" |
9801
03a3eebd7fb7
(svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents:
9737
diff
changeset
|
8 |
#include "../../tile_map.h" |
9379
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
9 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
10 |
/* static */ bool AIMap::IsValidTile(TileIndex t) |
9379
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
11 |
{ |
9801
03a3eebd7fb7
(svn r12307) [NoAI] -Codechange: as followup on r12303 (trunk), use ::IsValidTile to check if a tile is inside the map, instead of all our custom ways
truebrain
parents:
9737
diff
changeset
|
12 |
return ::IsValidTile(t); |
9379
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
13 |
} |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
14 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
15 |
/* static */ TileIndex AIMap::GetMapSize() |
9379
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
16 |
{ |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
17 |
return ::MapSize(); |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
18 |
} |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
19 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
20 |
/* static */ uint32 AIMap::GetMapSizeX() |
9379
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
21 |
{ |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
22 |
return ::MapSizeX(); |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
23 |
} |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
24 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
25 |
/* static */ uint32 AIMap::GetMapSizeY() |
9379
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
26 |
{ |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
27 |
return ::MapSizeY(); |
6e89b780c2c9
(svn r9168) [NoAI] -Add: AI wrapper functions for some map related queries.
rubidium
parents:
diff
changeset
|
28 |
} |
9430
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
29 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
30 |
/* static */ uint32 AIMap::GetTileX(TileIndex t) |
9430
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
31 |
{ |
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
32 |
return ::TileX(t); |
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
33 |
} |
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
34 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
35 |
/* static */ uint32 AIMap::GetTileY(TileIndex t) |
9430
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
36 |
{ |
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
37 |
return ::TileY(t); |
9e0a193b2bec
(svn r9234) [NoAI] -Codechange: move away from the 'much' subdirectory approach for the API implementation.
rubidium
parents:
9427
diff
changeset
|
38 |
} |
9489
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
39 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
40 |
/* static */ TileIndex AIMap::GetTileIndex(uint32 x, uint32 y) |
9502
5eb285182114
(svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents:
9489
diff
changeset
|
41 |
{ |
5eb285182114
(svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents:
9489
diff
changeset
|
42 |
return ::TileXY(x, y); |
5eb285182114
(svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents:
9489
diff
changeset
|
43 |
} |
5eb285182114
(svn r9379) [NoAI] -Add: function to get the TileIndex from an (X, Y) coordinate.
rubidium
parents:
9489
diff
changeset
|
44 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
45 |
/* static */ uint32 AIMap::DistanceManhattan(TileIndex t1, TileIndex t2) |
9489
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
46 |
{ |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
47 |
return ::DistanceManhattan(t1, t2); |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
48 |
} |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
49 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
50 |
/* static */ uint32 AIMap::DistanceMax(TileIndex t1, TileIndex t2) |
9489
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
51 |
{ |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
52 |
return ::DistanceMax(t1, t2); |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
53 |
} |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
54 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
55 |
/* static */ uint32 AIMap::DistanceSquare(TileIndex t1, TileIndex t2) |
9489
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
56 |
{ |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
57 |
return ::DistanceSquare(t1, t2); |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
58 |
} |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
59 |
|
9655
e8e43f333832
(svn r10557) [NoAI] -Add: added for all lists 2 valuators: DistanceManhattanToTile and DistanceSquareToTile, to get the distance from object to some tile you specify
truelight
parents:
9502
diff
changeset
|
60 |
/* static */ uint32 AIMap::DistanceFromEdge(TileIndex t) |
9489
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
61 |
{ |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
62 |
return ::DistanceFromEdge(t); |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
63 |
} |
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
64 |
|
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
|
65 |
/* static */ bool AIMap::DemolishTile(TileIndex t) |
9489
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
66 |
{ |
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
|
67 |
return AIObject::DoCommand(t, 0, 0, CMD_LANDSCAPE_CLEAR); |
9489
d7ee0a65ead9
(svn r9359) [NoAI] -Add: function to determine distance and clear tiles.
rubidium
parents:
9430
diff
changeset
|
68 |
} |