author | richk |
Tue, 17 Jun 2008 13:41:57 +0000 | |
branch | NewGRF_ports |
changeset 10995 | 311b38c7f9a7 |
parent 10724 | 68a692eacf22 |
permissions | -rw-r--r-- |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
2 |
|
10724
68a692eacf22
(svn r13274) [NewGRF_ports] -Sync: with trunk r12806:13144.
richk
parents:
10242
diff
changeset
|
3 |
/** @file road_map.cpp Complex road accessors. */ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6338
diff
changeset
|
4 |
|
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
6 |
#include "openttd.h" |
3196 | 7 |
#include "bridge_map.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
8 |
#include "tile_cmd.h" |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
9 |
#include "road_map.h" |
3154 | 10 |
#include "tunnel_map.h" |
3404
3ac4f7fedfb5
(svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents:
3234
diff
changeset
|
11 |
#include "station_map.h" |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
12 |
#include "tunnelbridge_map.h" |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
13 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
14 |
|
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
15 |
RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance) |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
16 |
{ |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
17 |
if (!HasTileRoadType(tile, rt)) return ROAD_NONE; |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6338
diff
changeset
|
18 |
|
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
19 |
switch (GetTileType(tile)) { |
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6719
diff
changeset
|
20 |
case MP_ROAD: |
3793
33cdb5bf7b21
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3404
diff
changeset
|
21 |
switch (GetRoadTileType(tile)) { |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
22 |
default: |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6338
diff
changeset
|
23 |
case ROAD_TILE_NORMAL: return GetRoadBits(tile, rt); |
3793
33cdb5bf7b21
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3404
diff
changeset
|
24 |
case ROAD_TILE_CROSSING: return GetCrossingRoadBits(tile); |
33cdb5bf7b21
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3404
diff
changeset
|
25 |
case ROAD_TILE_DEPOT: return DiagDirToRoadBits(GetRoadDepotDirection(tile)); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
26 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
27 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
28 |
case MP_STATION: |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
29 |
if (!IsRoadStopTile(tile)) return ROAD_NONE; |
6338
0fb4f452873c
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
5838
diff
changeset
|
30 |
if (IsDriveThroughStopTile(tile)) return (GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y; |
3404
3ac4f7fedfb5
(svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents:
3234
diff
changeset
|
31 |
return DiagDirToRoadBits(GetRoadStopDir(tile)); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
32 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
33 |
case MP_TUNNELBRIDGE: |
6872
1c4a4a609f85
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents:
6871
diff
changeset
|
34 |
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE; |
10184
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
35 |
return straight_tunnel_bridge_entrance ? |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
36 |
AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) : |
fcf5fb2548eb
(svn r12715) [NewGRF_ports] -Sync: with trunk r12351:12644.
richk
parents:
6878
diff
changeset
|
37 |
DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile))); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
38 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
39 |
default: return ROAD_NONE; |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
40 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
41 |
} |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
42 |
|
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
43 |
|
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6338
diff
changeset
|
44 |
TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt) |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
45 |
{ |
6719
4cc327ad39d5
(svn r10027) [NewGRF_ports] -Sync: with trunk r9506-10026
richk
parents:
6338
diff
changeset
|
46 |
/* Don't allow local authorities to build roads through road depots or road stops. */ |
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
47 |
if (IsRoadDepotTile(tile) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasTileRoadType(tile, rt)) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
48 |
return TRACK_BIT_NONE; |
3927
b6e0f409d92d
(svn r5062) -Fix: town extends road beyond depot or roadstop (introduced by YAPF related change of GetTileTrackStatus() - r4419)
KUDr
parents:
3793
diff
changeset
|
49 |
} |
4233
572e339d3ceb
(svn r5798) - Fix [r5062]: When expanding a town, the test to check if a tile is a
peter1138
parents:
3977
diff
changeset
|
50 |
|
6878
7d1ff2f621c7
(svn r12351) [NewGRF_ports] -Sync: with trunk r12051:12350.
richk
parents:
6872
diff
changeset
|
51 |
return TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt))); |
3150
025fe8cd7104
(svn r3773) Shove some semantics down ottd's throat by replacing ints and magic numbers by enums and some related changes
tron
parents:
3146
diff
changeset
|
52 |
} |