author | Darkvater |
Fri, 17 Mar 2006 18:54:42 +0000 | |
changeset 3244 | d5bc3f0987ba |
parent 3234 | 986c30171e92 |
child 3404 | 3ac4f7fedfb5 |
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" |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
10 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
11 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
12 |
RoadBits GetAnyRoadBits(TileIndex tile) |
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 |
switch (GetTileType(tile)) { |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
15 |
case MP_STREET: |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
16 |
switch (GetRoadType(tile)) { |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
17 |
default: |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
18 |
case ROAD_NORMAL: return GetRoadBits(tile); |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
19 |
case ROAD_CROSSING: return GetCrossingRoadBits(tile); |
3167
197b5ee5a831
(svn r3795) Add a function to request the orientation of a depot
tron
parents:
3154
diff
changeset
|
20 |
case ROAD_DEPOT: return DiagDirToRoadBits(GetRoadDepotDirection(tile)); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
21 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
22 |
|
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
23 |
case MP_STATION: |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
24 |
if (!IsRoadStationTile(tile)) return 0; |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
25 |
return DiagDirToRoadBits(GetRoadStationDir(tile)); |
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 |
case MP_TUNNELBRIDGE: |
3234
986c30171e92
(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
|
28 |
if (IsBridge(tile)) { |
986c30171e92
(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
|
29 |
if (IsBridgeMiddle(tile)) { |
986c30171e92
(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 (!IsTransportUnderBridge(tile) || |
986c30171e92
(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 |
GetBridgeTransportType(tile) != TRANSPORT_ROAD) { |
986c30171e92
(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 |
return 0; |
986c30171e92
(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 |
} |
986c30171e92
(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 GetRoadBitsUnderBridge(tile); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
35 |
} else { |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
36 |
// ending |
3234
986c30171e92
(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
|
37 |
if (GetBridgeTransportType(tile) != TRANSPORT_ROAD) return 0; |
3196 | 38 |
return DiagDirToRoadBits(ReverseDiagDir(GetBridgeRampDirection(tile))); |
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
39 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
40 |
} else { |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
41 |
// tunnel |
3154 | 42 |
if (GetTunnelTransportType(tile) != TRANSPORT_ROAD) return 0; |
43 |
return DiagDirToRoadBits(ReverseDiagDir(GetTunnelDirection(tile))); |
|
3146
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
44 |
} |
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 |
default: return 0; |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
47 |
} |
36523d434783
(svn r3766) Add a function to get the RoadBits from an arbitrary tile
tron
parents:
diff
changeset
|
48 |
} |
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
|
49 |
|
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 |
|
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
|
51 |
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
|
52 |
{ |
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
|
53 |
uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD); |
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
|
54 |
return (byte)(r | (r >> 8)); |
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
|
55 |
} |