author | skidd13 |
Tue, 20 Nov 2007 14:11:19 +0000 | |
changeset 8428 | f8300c908bd9 |
parent 8424 | 4a488a90ccab |
child 8579 | 3efbb430092e |
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 |
|
6889
f7f6d9cb07a0
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents:
6338
diff
changeset
|
3 |
/** @file road_map.cpp */ |
f7f6d9cb07a0
(svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
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" |
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
|
8 |
#include "functions.h" |
6949
72d11a1e1e60
(svn r9609) -Codechange: Move some function prototypes out of functions.h and into landscape.h, and add a few where they didn't exist.
maedhros
parents:
6914
diff
changeset
|
9 |
#include "landscape.h" |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
10 |
#include "road_map.h" |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
11 |
#include "station.h" |
3154 | 12 |
#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
|
13 |
#include "station_map.h" |
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
|
14 |
#include "depot.h" |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
15 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
16 |
|
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
6949
diff
changeset
|
17 |
RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt) |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
18 |
{ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7866
diff
changeset
|
19 |
if (!HasBit(GetRoadTypes(tile), rt)) return ROAD_NONE; |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
6949
diff
changeset
|
20 |
|
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
21 |
switch (GetTileType(tile)) { |
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7179
diff
changeset
|
22 |
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
|
23 |
switch (GetRoadTileType(tile)) { |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
24 |
default: |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
6949
diff
changeset
|
25 |
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
|
26 |
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
|
27 |
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
|
28 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
29 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
return DiagDirToRoadBits(GetRoadStopDir(tile)); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
34 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
35 |
case MP_TUNNELBRIDGE: |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4777
diff
changeset
|
36 |
if (IsTunnel(tile)) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
37 |
if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE; |
3154 | 38 |
return DiagDirToRoadBits(ReverseDiagDir(GetTunnelDirection(tile))); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4777
diff
changeset
|
39 |
} else { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
40 |
if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4777
diff
changeset
|
41 |
return DiagDirToRoadBits(ReverseDiagDir(GetBridgeRampDirection(tile))); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
42 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
43 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
44 |
default: return ROAD_NONE; |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
45 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
46 |
} |
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
|
47 |
|
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
|
48 |
|
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
6949
diff
changeset
|
49 |
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
|
50 |
{ |
4233
572e339d3ceb
(svn r5798) - Fix [r5062]: When expanding a town, the test to check if a tile is a
peter1138
parents:
3977
diff
changeset
|
51 |
uint32 r; |
572e339d3ceb
(svn r5798) - Fix [r5062]: When expanding a town, the test to check if a tile is a
peter1138
parents:
3977
diff
changeset
|
52 |
|
6914
3ba37b6fa39b
(svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents:
6889
diff
changeset
|
53 |
/* Don't allow local authorities to build roads through road depots or road stops. */ |
8424
4a488a90ccab
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7866
diff
changeset
|
54 |
if ((IsTileType(tile, MP_ROAD) && IsTileDepotType(tile, TRANSPORT_ROAD)) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile)) || !HasBit(GetRoadTypes(tile), rt)) { |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
55 |
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
|
56 |
} |
4233
572e339d3ceb
(svn r5798) - Fix [r5062]: When expanding a town, the test to check if a tile is a
peter1138
parents:
3977
diff
changeset
|
57 |
|
7179
3e123c2b7c93
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents:
7157
diff
changeset
|
58 |
r = GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt)); |
7157
270bc5b64e08
(svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium
parents:
6949
diff
changeset
|
59 |
|
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
60 |
return (TrackBits)(byte)(r | (r >> 8)); |
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
|
61 |
} |