author | truebrain |
Sun, 15 Jun 2008 22:37:35 +0000 | |
branch | noai |
changeset 10972 | 986675d19245 |
parent 10774 | 2c882f0468f2 |
child 10975 | 6bbc826d7812 |
permissions | -rw-r--r-- |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
2 |
|
9833
89a64246458f
(svn r12496) [NoAI] -Documentation: give the .cpp files a nice uniform format too
truebrain
parents:
9803
diff
changeset
|
3 |
/** @file ai_road.cpp Implementation of AIRoad. */ |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
4 |
|
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
5 |
#include "ai_road.hpp" |
10668
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
6 |
#include "ai_map.hpp" |
10339
ce6cd68d9eb8
(svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
truebrain
parents:
10094
diff
changeset
|
7 |
#include "../../openttd.h" |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
8 |
#include "../../road_map.h" |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
9 |
#include "../../station_map.h" |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10339
diff
changeset
|
10 |
#include "../../command_type.h" |
10668
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
11 |
#include "../../player_func.h" |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
12 |
|
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
|
13 |
/* static */ bool AIRoad::IsRoadTile(TileIndex tile) |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
14 |
{ |
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
|
15 |
if (!::IsValidTile(tile)) return false; |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
16 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9659
diff
changeset
|
17 |
return (::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) != ROAD_TILE_DEPOT) || |
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
|
18 |
IsDriveThroughRoadStationTile(tile); |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
19 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
20 |
|
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
|
21 |
/* static */ bool AIRoad::IsRoadDepotTile(TileIndex tile) |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
22 |
{ |
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
|
23 |
if (!::IsValidTile(tile)) return false; |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
24 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9659
diff
changeset
|
25 |
return ::IsTileType(tile, MP_ROAD) && ::GetRoadTileType(tile) == ROAD_TILE_DEPOT; |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
26 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
27 |
|
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
|
28 |
/* static */ bool AIRoad::IsRoadStationTile(TileIndex tile) |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
29 |
{ |
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
|
30 |
if (!::IsValidTile(tile)) return false; |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
31 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
32 |
return ::IsRoadStopTile(tile); |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
33 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
34 |
|
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
|
35 |
/* static */ bool AIRoad::IsDriveThroughRoadStationTile(TileIndex tile) |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
36 |
{ |
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
|
37 |
if (!::IsValidTile(tile)) return false; |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
38 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
39 |
return ::IsDriveThroughStopTile(tile); |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
40 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
41 |
|
10668
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
42 |
/* static */ bool AIRoad::IsRoadTypeAvailable(RoadType road_type) |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
43 |
{ |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
44 |
return ::HasRoadTypesAvail(_current_player, ::RoadTypeToRoadTypes((::RoadType)road_type)); |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
45 |
} |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
46 |
|
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
47 |
/* static */ AIRoad::RoadType AIRoad::GetCurrentRoadType() |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
48 |
{ |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
49 |
return (RoadType)AIObject::GetRoadType(); |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
50 |
} |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
51 |
|
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
52 |
/* static */ void AIRoad::SetCurrentRoadType(RoadType road_type) |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
53 |
{ |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
54 |
if (!IsRoadTypeAvailable(road_type)) return; |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
55 |
|
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
56 |
AIObject::SetRoadType((::RoadType)road_type); |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
57 |
} |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
58 |
|
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
59 |
/* static */ bool AIRoad::HasRoadType(TileIndex tile, RoadType road_type) |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
60 |
{ |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
61 |
if (!AIMap::IsValidTile(tile)) return false; |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
62 |
if (!IsRoadTypeAvailable(road_type)) return false; |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
63 |
return ::GetAnyRoadBits(tile, (::RoadType)road_type, false) != ROAD_NONE; |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
64 |
} |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
65 |
|
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
|
66 |
/* static */ bool AIRoad::AreRoadTilesConnected(TileIndex t1, TileIndex t2) |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
67 |
{ |
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
|
68 |
if (!::IsValidTile(t1)) return false; |
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
|
69 |
if (!::IsValidTile(t2)) return false; |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
70 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
71 |
/* Tiles not neighbouring */ |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
72 |
if ((abs((int)::TileX(t1) - (int)::TileX(t2)) + abs((int)::TileY(t1) - (int)::TileY(t2))) != 1) return false; |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
73 |
|
10668
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
74 |
RoadBits r1 = ::GetAnyRoadBits(t1, AIObject::GetRoadType()); |
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
75 |
RoadBits r2 = ::GetAnyRoadBits(t2, AIObject::GetRoadType()); |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
76 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
77 |
DiagDirection dir_1 = (DiagDirection)((::TileX(t1) == ::TileX(t2)) ? (::TileY(t1) < ::TileY(t2) ? 2 : 0) : (::TileX(t1) < ::TileX(t2) ? 1 : 3)); |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
78 |
DiagDirection dir_2 = ::ReverseDiagDir(dir_1); |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
79 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9694
diff
changeset
|
80 |
return HasBit(r1, dir_1) && HasBit(r2, dir_2); |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
81 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
82 |
|
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
|
83 |
/* static */ int32 AIRoad::GetNeighbourRoadCount(TileIndex tile) |
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
84 |
{ |
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
|
85 |
if (!::IsValidTile(tile)) return false; |
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
86 |
|
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
87 |
int32 neighbour = 0; |
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
88 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9659
diff
changeset
|
89 |
if (::IsTileType(tile + ::TileDiffXY(-1, 0), MP_ROAD) && ::GetRoadTileType(tile + ::TileDiffXY(-1, 0)) != ROAD_TILE_DEPOT) neighbour++; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9659
diff
changeset
|
90 |
if (::IsTileType(tile + ::TileDiffXY( 1, 0), MP_ROAD) && ::GetRoadTileType(tile + ::TileDiffXY( 1, 0)) != ROAD_TILE_DEPOT) neighbour++; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9659
diff
changeset
|
91 |
if (::IsTileType(tile + ::TileDiffXY( 0,-1), MP_ROAD) && ::GetRoadTileType(tile + ::TileDiffXY( 0,-1)) != ROAD_TILE_DEPOT) neighbour++; |
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9659
diff
changeset
|
92 |
if (::IsTileType(tile + ::TileDiffXY( 0, 1), MP_ROAD) && ::GetRoadTileType(tile + ::TileDiffXY( 0, 1)) != ROAD_TILE_DEPOT) neighbour++; |
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
93 |
|
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
94 |
return neighbour; |
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
95 |
} |
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
96 |
|
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
|
97 |
/* static */ TileIndex AIRoad::GetRoadDepotFrontTile(TileIndex depot) |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
98 |
{ |
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
|
99 |
if (!IsRoadDepotTile(depot)) return INVALID_TILE; |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
100 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
101 |
return depot + ::TileOffsByDiagDir(::GetRoadDepotDirection(depot)); |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
102 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
103 |
|
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
|
104 |
/* static */ TileIndex AIRoad::GetRoadStationFrontTile(TileIndex station) |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
105 |
{ |
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
|
106 |
if (!IsRoadStationTile(station)) return INVALID_TILE; |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
107 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
108 |
return station + ::TileOffsByDiagDir(::GetRoadStopDir(station)); |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
109 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
110 |
|
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
|
111 |
/* static */ TileIndex AIRoad::GetDriveThroughBackTile(TileIndex station) |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
112 |
{ |
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
|
113 |
if (!IsDriveThroughRoadStationTile(station)) return INVALID_TILE; |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
114 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
115 |
return station + ::TileOffsByDiagDir(::ReverseDiagDir(::GetRoadStopDir(station))); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
116 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
117 |
|
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
|
118 |
/* static */ bool AIRoad::BuildRoad(TileIndex start, TileIndex end) |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
119 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
120 |
EnforcePrecondition(false, start != end); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
121 |
EnforcePrecondition(false, ::IsValidTile(start)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
122 |
EnforcePrecondition(false, ::IsValidTile(end)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
123 |
EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end)); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
124 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
125 |
return AIObject::DoCommand(end, start, (::TileY(start) != ::TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (AIObject::GetRoadType() << 3), CMD_BUILD_LONG_ROAD); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
126 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
127 |
|
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
|
128 |
/* static */ bool AIRoad::BuildRoadFull(TileIndex start, TileIndex end) |
9659
ff5908205170
(svn r10568) [NoAI] -Add: {Build|Remove}RoadFull(). These functions have the same behaviour as {Build|Remove}Road(), except road is built/removed on both halves of ending tiles (ie build a sloped road on sloped tile instead half road with fundations)
glx
parents:
9624
diff
changeset
|
129 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
130 |
EnforcePrecondition(false, start != end); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
131 |
EnforcePrecondition(false, ::IsValidTile(start)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
132 |
EnforcePrecondition(false, ::IsValidTile(end)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
133 |
EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end)); |
9659
ff5908205170
(svn r10568) [NoAI] -Add: {Build|Remove}RoadFull(). These functions have the same behaviour as {Build|Remove}Road(), except road is built/removed on both halves of ending tiles (ie build a sloped road on sloped tile instead half road with fundations)
glx
parents:
9624
diff
changeset
|
134 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
135 |
return AIObject::DoCommand(end, start, (::TileY(start) != ::TileY(end) ? 4 : 0) | (start < end ? 2 : 1) | (AIObject::GetRoadType() << 3), CMD_BUILD_LONG_ROAD); |
9659
ff5908205170
(svn r10568) [NoAI] -Add: {Build|Remove}RoadFull(). These functions have the same behaviour as {Build|Remove}Road(), except road is built/removed on both halves of ending tiles (ie build a sloped road on sloped tile instead half road with fundations)
glx
parents:
9624
diff
changeset
|
136 |
} |
ff5908205170
(svn r10568) [NoAI] -Add: {Build|Remove}RoadFull(). These functions have the same behaviour as {Build|Remove}Road(), except road is built/removed on both halves of ending tiles (ie build a sloped road on sloped tile instead half road with fundations)
glx
parents:
9624
diff
changeset
|
137 |
|
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
|
138 |
/* static */ bool AIRoad::BuildRoadDepot(TileIndex tile, TileIndex front) |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
139 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
140 |
EnforcePrecondition(false, tile != front); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
141 |
EnforcePrecondition(false, ::IsValidTile(tile)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
142 |
EnforcePrecondition(false, ::IsValidTile(front)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
143 |
EnforcePrecondition(false, ::TileX(tile) == ::TileX(front) || ::TileY(tile) == ::TileY(front)); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
144 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
145 |
uint entrance_dir = (::TileX(tile) == ::TileX(front)) ? (::TileY(tile) < ::TileY(front) ? 1 : 3) : (::TileX(tile) < ::TileX(front) ? 2 : 0); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
146 |
|
10774
2c882f0468f2
(svn r13324) [NoAI] -Fix [FS#2047]: you could not build tram-depots (you got to love the consistancy of bit-placement in p1 and p2 ;))
truebrain
parents:
10668
diff
changeset
|
147 |
return AIObject::DoCommand(tile, entrance_dir | (AIObject::GetRoadType() << 2), 0, CMD_BUILD_ROAD_DEPOT); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
148 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
149 |
|
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
|
150 |
/* static */ bool AIRoad::BuildRoadStation(TileIndex tile, TileIndex front, bool truck, bool drive_through) |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
151 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
152 |
EnforcePrecondition(false, tile != front); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
153 |
EnforcePrecondition(false, ::IsValidTile(tile)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
154 |
EnforcePrecondition(false, ::IsValidTile(front)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
155 |
EnforcePrecondition(false, ::TileX(tile) == ::TileX(front) || ::TileY(tile) == ::TileY(front)); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
156 |
|
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
157 |
uint entrance_dir; |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
158 |
if (drive_through) { |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
159 |
entrance_dir = ::TileY(tile) != ::TileY(front); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
160 |
} else { |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
161 |
entrance_dir = (::TileX(tile) == ::TileX(front)) ? (::TileY(tile) < ::TileY(front) ? 1 : 3) : (::TileX(tile) < ::TileX(front) ? 2 : 0); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
162 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
163 |
|
10668
495789401303
(svn r13212) [NoAI] -Add: introducing the ability to build trams. Use AIRoad.SetCurrentRoadType to switch to Trams, than all AIRoad functions will produce tram-objects.
truebrain
parents:
10513
diff
changeset
|
164 |
return AIObject::DoCommand(tile, entrance_dir, (drive_through ? 2 : 0) | (truck ? 1 : 0) | (::RoadTypeToRoadTypes(AIObject::GetRoadType()) << 2), CMD_BUILD_ROAD_STOP); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
165 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
166 |
|
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
|
167 |
/* static */ bool AIRoad::RemoveRoad(TileIndex start, TileIndex end) |
9659
ff5908205170
(svn r10568) [NoAI] -Add: {Build|Remove}RoadFull(). These functions have the same behaviour as {Build|Remove}Road(), except road is built/removed on both halves of ending tiles (ie build a sloped road on sloped tile instead half road with fundations)
glx
parents:
9624
diff
changeset
|
168 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
169 |
EnforcePrecondition(false, ::IsValidTile(start)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
170 |
EnforcePrecondition(false, ::IsValidTile(end)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
171 |
EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end)); |
9659
ff5908205170
(svn r10568) [NoAI] -Add: {Build|Remove}RoadFull(). These functions have the same behaviour as {Build|Remove}Road(), except road is built/removed on both halves of ending tiles (ie build a sloped road on sloped tile instead half road with fundations)
glx
parents:
9624
diff
changeset
|
172 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
173 |
return AIObject::DoCommand(end, start, (::TileY(start) != ::TileY(end) ? 4 : 0) | (start < end ? 1 : 2) | (AIObject::GetRoadType() << 3), CMD_REMOVE_LONG_ROAD); |
9659
ff5908205170
(svn r10568) [NoAI] -Add: {Build|Remove}RoadFull(). These functions have the same behaviour as {Build|Remove}Road(), except road is built/removed on both halves of ending tiles (ie build a sloped road on sloped tile instead half road with fundations)
glx
parents:
9624
diff
changeset
|
174 |
} |
ff5908205170
(svn r10568) [NoAI] -Add: {Build|Remove}RoadFull(). These functions have the same behaviour as {Build|Remove}Road(), except road is built/removed on both halves of ending tiles (ie build a sloped road on sloped tile instead half road with fundations)
glx
parents:
9624
diff
changeset
|
175 |
|
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
|
176 |
/* static */ bool AIRoad::RemoveRoadFull(TileIndex start, TileIndex end) |
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
|
177 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
178 |
EnforcePrecondition(false, ::IsValidTile(start)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
179 |
EnforcePrecondition(false, ::IsValidTile(end)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
180 |
EnforcePrecondition(false, ::TileX(start) == ::TileX(end) || ::TileY(start) == ::TileY(end)); |
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
|
181 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
182 |
return AIObject::DoCommand(end, start, (::TileY(start) != ::TileY(end) ? 4 : 0) | (start < end ? 2 : 1) | (AIObject::GetRoadType() << 3), CMD_REMOVE_LONG_ROAD); |
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
|
183 |
} |
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
|
184 |
|
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
|
185 |
/* static */ bool AIRoad::RemoveRoadDepot(TileIndex tile) |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
186 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
187 |
EnforcePrecondition(false, ::IsValidTile(tile)); |
10094
e737405b06dd
(svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
10091
diff
changeset
|
188 |
EnforcePrecondition(false, IsTileType(tile, MP_ROAD)) |
e737405b06dd
(svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
10091
diff
changeset
|
189 |
EnforcePrecondition(false, GetRoadTileType(tile) == ROAD_TILE_DEPOT); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
190 |
|
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
|
191 |
return AIObject::DoCommand(tile, 0, 0, CMD_LANDSCAPE_CLEAR); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
192 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
193 |
|
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
|
194 |
/* static */ bool AIRoad::RemoveRoadStation(TileIndex tile) |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
195 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
196 |
EnforcePrecondition(false, ::IsValidTile(tile)); |
10094
e737405b06dd
(svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
10091
diff
changeset
|
197 |
EnforcePrecondition(false, IsTileType(tile, MP_STATION)); |
e737405b06dd
(svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
10091
diff
changeset
|
198 |
EnforcePrecondition(false, IsRoadStop(tile)); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
199 |
|
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
|
200 |
return AIObject::DoCommand(tile, 0, GetRoadStopType(tile), CMD_REMOVE_ROAD_STOP); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
201 |
} |