author | celestar |
Fri, 29 Dec 2006 10:13:35 +0000 | |
branch | custombridgeheads |
changeset 5592 | fd60d4ecc921 |
parent 5590 | dc34c43fc3eb |
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 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
3 |
#include "stdafx.h" |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
4 |
#include "openttd.h" |
3196 | 5 |
#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
|
6 |
#include "functions.h" |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
7 |
#include "road_map.h" |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
8 |
#include "station.h" |
3154 | 9 |
#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
|
10 |
#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
|
11 |
#include "depot.h" |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
12 |
|
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 |
RoadBits GetAnyRoadBits(TileIndex tile) |
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 |
switch (GetTileType(tile)) { |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
17 |
case MP_STREET: |
3793
33cdb5bf7b21
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3404
diff
changeset
|
18 |
switch (GetRoadTileType(tile)) { |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
19 |
default: |
3793
33cdb5bf7b21
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3404
diff
changeset
|
20 |
case ROAD_TILE_NORMAL: return GetRoadBits(tile); |
33cdb5bf7b21
(svn r4789) - Codechange: rename RoadType to RoadTileType and ROAD_{NORMAL,CROSSING,DEPOT} to ROAD_TILE_* for consistency
rubidium
parents:
3404
diff
changeset
|
21 |
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
|
22 |
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
|
23 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
24 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
25 |
case MP_STATION: |
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
|
26 |
if (!IsRoadStopTile(tile)) return 0; |
3ac4f7fedfb5
(svn r4215) -Codechange: Renamed *RoadStation* functions to *RoadStop* and moved them to station_map.h to keep consistency
celestar
parents:
3234
diff
changeset
|
27 |
return DiagDirToRoadBits(GetRoadStopDir(tile)); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
28 |
|
5590
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
29 |
case MP_TUNNEL: |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
30 |
if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return 0; |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
31 |
return DiagDirToRoadBits(ReverseDiagDir(GetTunnelDirection(tile))); |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
32 |
|
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
33 |
case MP_STREET_BRIDGE: |
dc34c43fc3eb
(svn r7597) [cbh] - Codechange: Remove MP_TUNNELBRIDGE and introduce three new TileTypes: MP_TUNNEL, MP_STREET_BRIDGE, MP_RAILWAY_BRIDGE
celestar
parents:
5573
diff
changeset
|
34 |
return DiagDirToRoadBits(ReverseDiagDir(GetBridgeRampDirection(tile))); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
35 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
36 |
default: return 0; |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
37 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
38 |
} |
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
|
39 |
|
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
|
40 |
|
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
|
41 |
TrackBits GetAnyRoadTrackBits(TileIndex tile) |
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 |
{ |
4233
572e339d3ceb
(svn r5798) - Fix [r5062]: When expanding a town, the test to check if a tile is a
peter1138
parents:
3977
diff
changeset
|
43 |
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
|
44 |
|
4615
09d62f8da967
(svn r6473) -Fix: FS#347 town extends road beyond road stop. Fixed by r5062, unfixed by r5798. Now there is proper comment, so it should not happen again.
KUDr
parents:
4233
diff
changeset
|
45 |
// Don't allow local authorities to build roads through road depots or road stops. |
09d62f8da967
(svn r6473) -Fix: FS#347 town extends road beyond road stop. Fixed by r5062, unfixed by r5798. Now there is proper comment, so it should not happen again.
KUDr
parents:
4233
diff
changeset
|
46 |
if ((IsTileType(tile, MP_STREET) && IsTileDepotType(tile, TRANSPORT_ROAD)) || IsTileType(tile, MP_STATION)) { |
4233
572e339d3ceb
(svn r5798) - Fix [r5062]: When expanding a town, the test to check if a tile is a
peter1138
parents:
3977
diff
changeset
|
47 |
return 0; |
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
|
48 |
} |
4233
572e339d3ceb
(svn r5798) - Fix [r5062]: When expanding a town, the test to check if a tile is a
peter1138
parents:
3977
diff
changeset
|
49 |
|
572e339d3ceb
(svn r5798) - Fix [r5062]: When expanding a town, the test to check if a tile is a
peter1138
parents:
3977
diff
changeset
|
50 |
r = GetTileTrackStatus(tile, TRANSPORT_ROAD); |
572e339d3ceb
(svn r5798) - Fix [r5062]: When expanding a town, the test to check if a tile is a
peter1138
parents:
3977
diff
changeset
|
51 |
return (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
|
52 |
} |