author | KUDr |
Wed, 31 May 2006 20:08:55 +0000 | |
changeset 3927 | e3bb59b8ce4f |
parent 3793 | 7fe24e10ea63 |
child 3933 | 231ae3c419f4 |
permissions | -rw-r--r-- |
3146
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
2 |
|
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
3 |
#include "stdafx.h" |
8d95593c5ff0
(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
729951cb5448
(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
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
7 |
#include "road_map.h" |
8d95593c5ff0
(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
eb8ebfe5df67
(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
e3bb59b8ce4f
(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
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
12 |
|
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
13 |
|
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
14 |
RoadBits GetAnyRoadBits(TileIndex tile) |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
15 |
{ |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
16 |
switch (GetTileType(tile)) { |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
17 |
case MP_STREET: |
3793
7fe24e10ea63
(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
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
19 |
default: |
3793
7fe24e10ea63
(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); |
7fe24e10ea63
(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); |
7fe24e10ea63
(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
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
23 |
} |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
24 |
|
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
25 |
case MP_STATION: |
3404
eb8ebfe5df67
(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; |
eb8ebfe5df67
(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
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
28 |
|
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
29 |
case MP_TUNNELBRIDGE: |
3234
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3196
diff
changeset
|
30 |
if (IsBridge(tile)) { |
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3196
diff
changeset
|
31 |
if (IsBridgeMiddle(tile)) { |
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3196
diff
changeset
|
32 |
if (!IsTransportUnderBridge(tile) || |
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3196
diff
changeset
|
33 |
GetBridgeTransportType(tile) != TRANSPORT_ROAD) { |
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3196
diff
changeset
|
34 |
return 0; |
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3196
diff
changeset
|
35 |
} |
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3196
diff
changeset
|
36 |
return GetRoadBitsUnderBridge(tile); |
3146
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
37 |
} else { |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
38 |
// ending |
3234
a2791a480b71
(svn r3907) Replace many bridge related direct map accesses with calls to shiny new functions and mark some strange constructs with XXX
tron
parents:
3196
diff
changeset
|
39 |
if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return 0; |
3196 | 40 |
return DiagDirToRoadBits(ReverseDiagDir(GetBridgeRampDirection(tile))); |
3146
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
41 |
} |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
42 |
} else { |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
43 |
// tunnel |
3154 | 44 |
if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return 0; |
45 |
return DiagDirToRoadBits(ReverseDiagDir(GetTunnelDirection(tile))); |
|
3146
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
46 |
} |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
47 |
|
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
48 |
default: return 0; |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
49 |
} |
8d95593c5ff0
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
50 |
} |
3150
729951cb5448
(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
|
51 |
|
729951cb5448
(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 |
|
729951cb5448
(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
|
53 |
TrackBits GetAnyRoadTrackBits(TileIndex tile) |
729951cb5448
(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
|
54 |
{ |
3927
e3bb59b8ce4f
(svn r5062) -Fix: town extends road beyond depot or roadstop (introduced by YAPF related change of GetTileTrackStatus() - r4419)
KUDr
parents:
3793
diff
changeset
|
55 |
if (IsTileType(tile, MP_STREET) && !IsTileDepotType(tile, TRANSPORT_ROAD)) { |
e3bb59b8ce4f
(svn r5062) -Fix: town extends road beyond depot or roadstop (introduced by YAPF related change of GetTileTrackStatus() - r4419)
KUDr
parents:
3793
diff
changeset
|
56 |
uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD); |
e3bb59b8ce4f
(svn r5062) -Fix: town extends road beyond depot or roadstop (introduced by YAPF related change of GetTileTrackStatus() - r4419)
KUDr
parents:
3793
diff
changeset
|
57 |
return (byte)(r | (r >> 8)); |
e3bb59b8ce4f
(svn r5062) -Fix: town extends road beyond depot or roadstop (introduced by YAPF related change of GetTileTrackStatus() - r4419)
KUDr
parents:
3793
diff
changeset
|
58 |
} |
e3bb59b8ce4f
(svn r5062) -Fix: town extends road beyond depot or roadstop (introduced by YAPF related change of GetTileTrackStatus() - r4419)
KUDr
parents:
3793
diff
changeset
|
59 |
return 0; |
3150
729951cb5448
(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
|
60 |
} |