author | rubidium |
Tue, 17 Jun 2008 13:06:32 +0000 | |
branch | noai |
changeset 10993 | 203b90795f80 |
parent 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" |
10993
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
7 |
#include "ai_list.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
|
8 |
#include "../../openttd.h" |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
9 |
#include "../../road_map.h" |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
10 |
#include "../../station_map.h" |
10513
33cb70ff2f5d
(svn r13056) [NoAI] -Sync: with trunk r12996:13055.
rubidium
parents:
10339
diff
changeset
|
11 |
#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
|
12 |
#include "../../player_func.h" |
10993
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
13 |
#include "../../settings_type.h" |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
14 |
#include "../../squirrel_helper_type.hpp" |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
15 |
|
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
|
16 |
/* 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
|
17 |
{ |
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
|
18 |
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
|
19 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9659
diff
changeset
|
20 |
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
|
21 |
IsDriveThroughRoadStationTile(tile); |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
22 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
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 */ 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
|
25 |
{ |
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
|
26 |
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
|
27 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9659
diff
changeset
|
28 |
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
|
29 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
30 |
|
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
|
31 |
/* 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
|
32 |
{ |
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
|
33 |
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
|
34 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
35 |
return ::IsRoadStopTile(tile); |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
36 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
37 |
|
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
|
38 |
/* 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
|
39 |
{ |
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
|
40 |
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
|
41 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
42 |
return ::IsDriveThroughStopTile(tile); |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
43 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
44 |
|
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
|
45 |
/* 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
|
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 |
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
|
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 |
|
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 |
/* 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
|
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 |
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
|
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 |
|
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 |
/* 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
|
56 |
{ |
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 |
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
|
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 |
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
|
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 |
|
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 |
/* 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
|
63 |
{ |
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 |
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
|
65 |
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
|
66 |
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
|
67 |
} |
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
|
68 |
|
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
|
69 |
/* 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
|
70 |
{ |
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
|
71 |
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
|
72 |
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
|
73 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
74 |
/* Tiles not neighbouring */ |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
75 |
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
|
76 |
|
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
|
77 |
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
|
78 |
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
|
79 |
|
10975
6bbc826d7812
(svn r13529) [NoAI] -Fix: don't suggest something is DiagDirection if it in fact isn't
truebrain
parents:
10972
diff
changeset
|
80 |
uint dir_1 = (::TileX(t1) == ::TileX(t2)) ? (::TileY(t1) < ::TileY(t2) ? 2 : 0) : (::TileX(t1) < ::TileX(t2) ? 1 : 3); |
6bbc826d7812
(svn r13529) [NoAI] -Fix: don't suggest something is DiagDirection if it in fact isn't
truebrain
parents:
10972
diff
changeset
|
81 |
uint dir_2 = 2 ^ dir_1; |
9551
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
82 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9694
diff
changeset
|
83 |
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
|
84 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
85 |
|
10993
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
86 |
/* Helper functions for AIRoad::CanBuildConnectedRoadParts(). */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
87 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
88 |
/** |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
89 |
* Check whether the given existing bits the start and end part can be build. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
90 |
* As the function assumes the bits being build on a slope that does not |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
91 |
* allow level foundations all of the existing parts will always be in |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
92 |
* a straight line. This also needs to hold for the start and end parts, |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
93 |
* otherwise it is for sure not valid. Finally a check will be done to |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
94 |
* determine whether the existing road parts match the to-be-build parts. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
95 |
* As they can only be placed in one direction, just checking the start |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
96 |
* part with the first existing part is enough. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
97 |
* @param existing The existing road parts. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
98 |
* @param start The part that should be build first. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
99 |
* @param end The part that will be build second. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
100 |
* @return True if and only if the road bits can be build. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
101 |
*/ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
102 |
static bool CheckAutoExpandedRoadBits(const Array *existing, int32 start, int32 end) |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
103 |
{ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
104 |
return (start + end == 0) && (existing->size == 0 || existing->array[0] == start || existing->array[0] == end); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
105 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
106 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
107 |
/** |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
108 |
* Lookup function for building road parts when building on slopes is disabled. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
109 |
* @param slope The slope of the tile to examine. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
110 |
* @param existing The existing road parts. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
111 |
* @param start The part that should be build first. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
112 |
* @param end The part that will be build second. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
113 |
* @return 0 when the build parts do not connect, 1 when they do connect once |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
114 |
* they are build or 2 when building the first part automatically |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
115 |
* builds the second part. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
116 |
*/ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
117 |
static int32 LookupWithoutBuildOnSlopes(::Slope slope, const Array *existing, int32 start, int32 end) |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
118 |
{ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
119 |
switch (slope) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
120 |
/* Flat slopes can always be build. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
121 |
case SLOPE_FLAT: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
122 |
return 1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
123 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
124 |
/* Only 4 of the slopes can be build upon. Testing the existing bits is |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
125 |
* necessary because these bits can be something else when the settings |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
126 |
* in the game have been changed. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
127 |
*/ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
128 |
case SLOPE_NE: case SLOPE_SW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
129 |
return (CheckAutoExpandedRoadBits(existing, start, end) && (start == 1 || end == 1)) ? (existing->size == 0 ? 2 : 1) : 0; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
130 |
case SLOPE_SE: case SLOPE_NW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
131 |
return (CheckAutoExpandedRoadBits(existing, start, end) && (start != 1 && end != 1)) ? (existing->size == 0 ? 2 : 1) : 0; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
132 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
133 |
/* Any other tile cannot be built on. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
134 |
default: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
135 |
return 0; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
136 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
137 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
138 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
139 |
/** |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
140 |
* Rotate a neighbour bit a single time clockwise. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
141 |
* @param neighbour The neighbour. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
142 |
* @return The rotate neighbour data. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
143 |
*/ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
144 |
static int32 RotateNeighbour(int32 neighbour) |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
145 |
{ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
146 |
switch (neighbour) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
147 |
case -2: return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
148 |
case -1: return 2; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
149 |
case 1: return -2; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
150 |
case 2: return 1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
151 |
default: NOT_REACHED(); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
152 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
153 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
154 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
155 |
/** |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
156 |
* Convert a neighbour to a road bit representation for easy internal use. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
157 |
* @param neighbour The neighbour. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
158 |
* @return The bits representing the direction. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
159 |
*/ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
160 |
static RoadBits NeighbourToRoadBits(int32 neighbour) |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
161 |
{ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
162 |
switch (neighbour) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
163 |
case -2: return ROAD_NW; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
164 |
case -1: return ROAD_NE; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
165 |
case 2: return ROAD_SE; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
166 |
case 1: return ROAD_SW; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
167 |
default: NOT_REACHED(); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
168 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
169 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
170 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
171 |
/** |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
172 |
* Lookup function for building road parts when building on slopes is enabled. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
173 |
* @param slope The slope of the tile to examine. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
174 |
* @param existing The existing neighbours. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
175 |
* @param start The part that should be build first. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
176 |
* @param end The part that will be build second. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
177 |
* @return 0 when the build parts do not connect, 1 when they do connect once |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
178 |
* they are build or 2 when building the first part automatically |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
179 |
* builds the second part. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
180 |
*/ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
181 |
static int32 LookupWithBuildOnSlopes(::Slope slope, Array *existing, int32 start, int32 end) |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
182 |
{ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
183 |
if (::IsSteepSlope(slope)) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
184 |
switch (slope) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
185 |
/* On steep slopes one can only build straight roads that will be |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
186 |
* automatically expanded to a straight road. Just check that the existing |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
187 |
* road parts are in the same direction. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
188 |
case SLOPE_STEEP_S: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
189 |
case SLOPE_STEEP_W: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
190 |
case SLOPE_STEEP_N: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
191 |
case SLOPE_STEEP_E: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
192 |
return CheckAutoExpandedRoadBits(existing, start, end) ? (existing->size == 0 ? 2 : 1) : 0; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
193 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
194 |
/* All other slopes are invalid slopes!. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
195 |
default: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
196 |
return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
197 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
198 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
199 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
200 |
/* The slope is not steep. Furthermore lots of slopes are generally the |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
201 |
* same but are only rotated. So to reduce the amount of lookup work that |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
202 |
* needs to be done the data is made uniform. This means rotating the |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
203 |
* existing parts and updating the slope. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
204 |
static const ::Slope base_slopes[] = { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
205 |
SLOPE_FLAT, SLOPE_W, SLOPE_W, SLOPE_SW, |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
206 |
SLOPE_W, SLOPE_EW, SLOPE_SW, SLOPE_WSE, |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
207 |
SLOPE_W, SLOPE_SW, SLOPE_EW, SLOPE_WSE, |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
208 |
SLOPE_SW, SLOPE_WSE, SLOPE_WSE}; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
209 |
static const byte base_rotates[] = {0, 0, 1, 0, 2, 0, 1, 0, 3, 3, 2, 3, 2, 2, 1}; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
210 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
211 |
if (slope >= (::Slope)lengthof(base_slopes)) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
212 |
/* This slope is an invalid slope, so ignore it. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
213 |
return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
214 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
215 |
byte base_rotate = base_rotates[slope]; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
216 |
slope = base_slopes[slope]; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
217 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
218 |
/* Some slopes don't need rotating, so return early when we know we do |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
219 |
* not need to rotate. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
220 |
switch (slope) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
221 |
case SLOPE_FLAT: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
222 |
/* Flat slopes can always be build. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
223 |
return 1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
224 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
225 |
case SLOPE_EW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
226 |
case SLOPE_WSE: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
227 |
/* A slope similar to a SLOPE_EW or SLOPE_WSE will always cause |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
228 |
* foundations which makes them accessible from all sides. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
229 |
return 1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
230 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
231 |
case SLOPE_W: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
232 |
case SLOPE_SW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
233 |
/* A slope for which we need perform some calculations. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
234 |
break; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
235 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
236 |
default: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
237 |
/* An invalid slope. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
238 |
return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
239 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
240 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
241 |
/* Now perform the actual rotation. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
242 |
for (int j = 0; j < base_rotate; j++) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
243 |
for (int i = 0; i < existing->size; i++) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
244 |
existing->array[i] = RotateNeighbour(existing->array[i]); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
245 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
246 |
start = RotateNeighbour(start); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
247 |
end = RotateNeighbour(end); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
248 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
249 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
250 |
/* Create roadbits out of the data for easier handling. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
251 |
RoadBits start_roadbits = NeighbourToRoadBits(start); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
252 |
RoadBits new_roadbits = start_roadbits | NeighbourToRoadBits(end); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
253 |
RoadBits existing_roadbits = ROAD_NONE; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
254 |
for (int i = 0; i < existing->size; i++) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
255 |
existing_roadbits |= NeighbourToRoadBits(existing->array[i]); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
256 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
257 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
258 |
switch (slope) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
259 |
case SLOPE_W: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
260 |
/* A slope similar to a SLOPE_W. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
261 |
switch (new_roadbits) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
262 |
case 6: // ROAD_SE | ROAD_SW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
263 |
case 9: // ROAD_NE | ROAD_NW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
264 |
case 12: // ROAD_NE | ROAD_SE: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
265 |
/* Cannot build anything with a turn from the low side. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
266 |
return 0; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
267 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
268 |
case 5: // ROAD_SE | ROAD_NW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
269 |
case 10: // ROAD_NE | ROAD_SW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
270 |
/* A 'sloped' tile is going to be build. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
271 |
if ((existing_roadbits | new_roadbits) != new_roadbits) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
272 |
/* There is already a foundation on the tile, or at least |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
273 |
* another slope that is not compatible with the new one. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
274 |
return 0; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
275 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
276 |
/* If the start is in the low part, it is automatically |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
277 |
* building the second part too. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
278 |
return ((start_roadbits & (ROAD_NE | ROAD_SE)) && !(existing_roadbits & (ROAD_SW | ROAD_NW))) ? 2 : 1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
279 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
280 |
default: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
281 |
/* Roadbits causing a foundation are going to be build. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
282 |
* When the existing roadbits are slopes (the lower bits |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
283 |
* are used), this cannot be done. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
284 |
if ((existing_roadbits | new_roadbits) == new_roadbits) return 1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
285 |
return (existing_roadbits & (ROAD_NE | ROAD_SE)) ? 0 : 1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
286 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
287 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
288 |
case SLOPE_SW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
289 |
/* A slope similar to a SLOPE_SW. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
290 |
switch (new_roadbits) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
291 |
case 9: // ROAD_NE | ROAD_NW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
292 |
case 12: // ROAD_NE | ROAD_SE: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
293 |
/* Cannot build anything with a turn from the low side. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
294 |
return 0; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
295 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
296 |
case 10: // ROAD_NE | ROAD_SW: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
297 |
/* A 'sloped' tile is going to be build. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
298 |
if ((existing_roadbits | new_roadbits) != new_roadbits) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
299 |
/* There is already a foundation on the tile, or at least |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
300 |
* another slope that is not compatible with the new one. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
301 |
return 0; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
302 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
303 |
/* If the start is in the low part, it is automatically |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
304 |
* building the second part too. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
305 |
return ((start_roadbits & ROAD_NE) && !(existing_roadbits & ROAD_SW)) ? 2 : 1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
306 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
307 |
default: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
308 |
/* Roadbits causing a foundation are going to be build. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
309 |
* When the existing roadbits are slopes (the lower bits |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
310 |
* are used), this cannot be done. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
311 |
return (existing_roadbits & ROAD_NE) ? 0 : 1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
312 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
313 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
314 |
default: |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
315 |
NOT_REACHED(); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
316 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
317 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
318 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
319 |
/** |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
320 |
* Normalise all input data so we can easily handle it without needing |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
321 |
* to call the API lots of times or create large if-elseif-elseif-else |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
322 |
* constructs. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
323 |
* In this case it means that a TileXY(0, -1) becomes -2 and TileXY(0, 1) |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
324 |
* becomes 2. TileXY(-1, 0) and TileXY(1, 0) stay respectively -1 and 1. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
325 |
* Any other value means that it is an invalid tile offset. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
326 |
* @param tile The tile to normalise. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
327 |
* @return True if and only if the tile offset is valid. |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
328 |
*/ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
329 |
static bool NormaliseTileOffset(int32 *tile) |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
330 |
{ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
331 |
if (*tile == 1 || *tile == -1) return true; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
332 |
if (*tile == ::TileDiffXY(0, -1)) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
333 |
*tile = -2; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
334 |
return true; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
335 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
336 |
if (*tile == ::TileDiffXY(0, 1)) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
337 |
*tile = 2; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
338 |
return true; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
339 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
340 |
return false; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
341 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
342 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
343 |
/* static */ int32 AIRoad::CanBuildConnectedRoadParts(AITile::Slope slope_, Array *existing, TileIndex start_, TileIndex end_) |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
344 |
{ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
345 |
::Slope slope = (::Slope)slope_; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
346 |
int32 start = start_; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
347 |
int32 end = end_; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
348 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
349 |
/* The start tile and end tile cannot be the same tile either. */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
350 |
if (start == end) return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
351 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
352 |
for (int i = 0; i < existing->size; i++) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
353 |
if (!NormaliseTileOffset(&existing->array[i])) return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
354 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
355 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
356 |
if (!NormaliseTileOffset(&start)) return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
357 |
if (!NormaliseTileOffset(&end)) return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
358 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
359 |
/* Without build on slopes the characteristics are vastly different, so use |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
360 |
* a different helper function (one that is much simpler). */ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
361 |
return _settings_game.construction.build_on_slopes ? LookupWithBuildOnSlopes(slope, existing, start, end) : LookupWithoutBuildOnSlopes(slope, existing, start, end); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
362 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
363 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
364 |
/* static */ int32 AIRoad::CanBuildConnectedRoadPartsHere(TileIndex tile, TileIndex start, TileIndex end) |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
365 |
{ |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
366 |
if (!::IsValidTile(tile) || !::IsValidTile(start) || !::IsValidTile(end)) return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
367 |
if (::DistanceManhattan(tile, start) != 1 || ::DistanceManhattan(tile, end) != 1) return -1; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
368 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
369 |
static const TileIndex neighbours[] = {::TileDiffXY(-1, 0), ::TileDiffXY(1, 0), ::TileDiffXY(0, -1), ::TileDiffXY(0, 1)}; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
370 |
Array *existing = (Array*)alloca(sizeof(Array) + lengthof(neighbours) * sizeof(int32)); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
371 |
existing->size = 0; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
372 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
373 |
for (uint i = 0; i < lengthof(neighbours); i++) { |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
374 |
if (AIRoad::AreRoadTilesConnected(tile, tile + neighbours[i])) existing->array[existing->size++] = neighbours[i]; |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
375 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
376 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
377 |
return AIRoad::CanBuildConnectedRoadParts(AITile::GetSlope(tile), existing, start - tile, end - tile); |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
378 |
} |
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
379 |
|
203b90795f80
(svn r13547) [NoAI] -Add: functions to determine whether one can build connected roads given a tile, entry and exit 'point' or an abstract representation of a tile with entry and exit 'point'. Works on all valid slopes and it is aware of the build_on_slopes configuration setting.
rubidium
parents:
10975
diff
changeset
|
380 |
|
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
|
381 |
/* static */ int32 AIRoad::GetNeighbourRoadCount(TileIndex tile) |
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
382 |
{ |
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
|
383 |
if (!::IsValidTile(tile)) return false; |
9617
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
384 |
|
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
385 |
int32 neighbour = 0; |
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
386 |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9659
diff
changeset
|
387 |
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
|
388 |
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
|
389 |
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
|
390 |
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
|
391 |
|
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
392 |
return neighbour; |
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
393 |
} |
df9cedf12aab
(svn r9786) [NoAI] -Fix: NeighbourRoad -> NeighbourRoadCount
truelight
parents:
9556
diff
changeset
|
394 |
|
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
|
395 |
/* 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
|
396 |
{ |
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
|
397 |
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
|
398 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
399 |
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
|
400 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
401 |
|
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
|
402 |
/* 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
|
403 |
{ |
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
|
404 |
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
|
405 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
406 |
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
|
407 |
} |
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
408 |
|
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
|
409 |
/* 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
|
410 |
{ |
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
|
411 |
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
|
412 |
|
d015a5b4b0a8
(svn r9489) [NoAI] -Add: functions to query existance and direction of road stations and depots.
rubidium
parents:
9513
diff
changeset
|
413 |
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
|
414 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
415 |
|
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
|
416 |
/* 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
|
417 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
418 |
EnforcePrecondition(false, start != end); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
419 |
EnforcePrecondition(false, ::IsValidTile(start)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
420 |
EnforcePrecondition(false, ::IsValidTile(end)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
421 |
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
|
422 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
423 |
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
|
424 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
425 |
|
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
|
426 |
/* 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
|
427 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
428 |
EnforcePrecondition(false, start != end); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
429 |
EnforcePrecondition(false, ::IsValidTile(start)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
430 |
EnforcePrecondition(false, ::IsValidTile(end)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
431 |
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
|
432 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
433 |
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
|
434 |
} |
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
|
435 |
|
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
|
436 |
/* 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
|
437 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
438 |
EnforcePrecondition(false, tile != front); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
439 |
EnforcePrecondition(false, ::IsValidTile(tile)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
440 |
EnforcePrecondition(false, ::IsValidTile(front)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
441 |
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
|
442 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
443 |
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
|
444 |
|
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
|
445 |
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
|
446 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
447 |
|
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
|
448 |
/* 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
|
449 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
450 |
EnforcePrecondition(false, tile != front); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
451 |
EnforcePrecondition(false, ::IsValidTile(tile)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
452 |
EnforcePrecondition(false, ::IsValidTile(front)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
453 |
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
|
454 |
|
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
455 |
uint entrance_dir; |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
456 |
if (drive_through) { |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
457 |
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
|
458 |
} else { |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
459 |
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
|
460 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
461 |
|
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
|
462 |
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
|
463 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
464 |
|
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
|
465 |
/* 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
|
466 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
467 |
EnforcePrecondition(false, ::IsValidTile(start)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
468 |
EnforcePrecondition(false, ::IsValidTile(end)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
469 |
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
|
470 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
471 |
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
|
472 |
} |
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
|
473 |
|
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
|
474 |
/* 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
|
475 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
476 |
EnforcePrecondition(false, ::IsValidTile(start)); |
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
477 |
EnforcePrecondition(false, ::IsValidTile(end)); |
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
478 |
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
|
479 |
|
10972
986675d19245
(svn r13526) [NoAI] -Fix: some namespace problems and forgotten pre-condition
truebrain
parents:
10774
diff
changeset
|
480 |
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
|
481 |
} |
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
|
482 |
|
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
|
483 |
/* 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
|
484 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
485 |
EnforcePrecondition(false, ::IsValidTile(tile)); |
10094
e737405b06dd
(svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
10091
diff
changeset
|
486 |
EnforcePrecondition(false, IsTileType(tile, MP_ROAD)) |
e737405b06dd
(svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
10091
diff
changeset
|
487 |
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
|
488 |
|
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
|
489 |
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
|
490 |
} |
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
491 |
|
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
|
492 |
/* 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
|
493 |
{ |
10091
e4feb2f9fedf
(svn r12621) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
9833
diff
changeset
|
494 |
EnforcePrecondition(false, ::IsValidTile(tile)); |
10094
e737405b06dd
(svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
10091
diff
changeset
|
495 |
EnforcePrecondition(false, IsTileType(tile, MP_STATION)); |
e737405b06dd
(svn r12625) [NoAI] -Add: support for GetLastError in AIRoad. Patch by Morloth.
rubidium
parents:
10091
diff
changeset
|
496 |
EnforcePrecondition(false, IsRoadStop(tile)); |
9453
727ff178a582
(svn r9283) [NoAI] -Add: API for adding/removing road, road depots and road stations.
rubidium
parents:
diff
changeset
|
497 |
|
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
|
498 |
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
|
499 |
} |