equal
deleted
inserted
replaced
|
1 /* $Id$ */ |
|
2 |
|
3 #include "stdafx.h" |
|
4 #include "openttd.h" |
|
5 #include "bridge_map.h" |
|
6 #include "variables.h" |
|
7 |
|
8 |
|
9 TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir) |
|
10 { |
|
11 TileIndexDiff delta = TileOffsByDiagDir(dir); |
|
12 |
|
13 dir = ReverseDiagDir(dir); |
|
14 do { |
|
15 tile += delta; |
|
16 } while (!IsBridgeTile(tile) || GetBridgeRampDirection(tile) != dir); |
|
17 |
|
18 return tile; |
|
19 } |
|
20 |
|
21 |
|
22 TileIndex GetNorthernBridgeEnd(TileIndex t) |
|
23 { |
|
24 return GetBridgeEnd(t, ReverseDiagDir(AxisToDiagDir(GetBridgeAxis(t)))); |
|
25 } |
|
26 |
|
27 |
|
28 TileIndex GetSouthernBridgeEnd(TileIndex t) |
|
29 { |
|
30 return GetBridgeEnd(t, AxisToDiagDir(GetBridgeAxis(t))); |
|
31 } |
|
32 |
|
33 |
|
34 TileIndex GetOtherBridgeEnd(TileIndex tile) |
|
35 { |
|
36 assert(IsBridgeTile(tile)); |
|
37 return GetBridgeEnd(tile, GetBridgeRampDirection(tile)); |
|
38 } |
|
39 |
|
40 uint GetBridgeHeight(TileIndex t) |
|
41 { |
|
42 uint h; |
|
43 uint tileh = GetTileSlope(t, &h); |
|
44 uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t))); |
|
45 |
|
46 // one height level extra if the ramp is on a flat foundation |
|
47 return |
|
48 h + TILE_HEIGHT + |
|
49 (IS_INT_INSIDE(f, 1, 15) ? TILE_HEIGHT : 0) + |
|
50 (IsSteepSlope(tileh) ? TILE_HEIGHT : 0); |
|
51 } |