equal
deleted
inserted
replaced
1 /* $Id$ */ |
1 /* $Id$ */ |
2 |
2 |
3 #include "stdafx.h" |
3 #include "stdafx.h" |
4 #include "openttd.h" |
4 #include "openttd.h" |
5 #include "bridge_map.h" |
5 #include "bridge_map.h" |
|
6 #include "variables.h" |
6 |
7 |
7 |
8 |
8 TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir) |
9 TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir) |
9 { |
10 { |
10 TileIndexDiff delta = TileOffsByDir(dir); |
11 TileIndexDiff delta = TileOffsByDir(dir); |
11 |
12 |
12 assert(DiagDirToAxis(dir) == GetBridgeAxis(tile)); |
13 do { tile += delta; } while (IsBridgeAbove(tile) && IsBridgeOfAxis(tile, DiagDirToAxis(dir))); |
13 |
|
14 do { |
|
15 tile += delta; |
|
16 } while (!IsBridgeRamp(tile)); |
|
17 |
14 |
18 return tile; |
15 return tile; |
|
16 } |
|
17 |
|
18 |
|
19 TileIndex GetNorthernBridgeEnd(TileIndex t) |
|
20 { |
|
21 return GetBridgeEnd(t, ReverseDiagDir(AxisToDiagDir(GetBridgeAxis(t)))); |
19 } |
22 } |
20 |
23 |
21 |
24 |
22 TileIndex GetSouthernBridgeEnd(TileIndex t) |
25 TileIndex GetSouthernBridgeEnd(TileIndex t) |
23 { |
26 { |
25 } |
28 } |
26 |
29 |
27 |
30 |
28 TileIndex GetOtherBridgeEnd(TileIndex tile) |
31 TileIndex GetOtherBridgeEnd(TileIndex tile) |
29 { |
32 { |
30 TileIndexDiff delta = TileOffsByDir(GetBridgeRampDirection(tile)); |
33 assert(IsBridgeTile(tile)); |
|
34 return GetBridgeEnd(tile, GetBridgeRampDirection(tile)); |
|
35 } |
31 |
36 |
32 do { |
37 uint GetBridgeHeight(TileIndex tile, Axis a) |
33 tile += delta; |
38 { |
34 } while (!IsBridgeRamp(tile)); |
39 uint h, f; |
|
40 uint tileh = GetTileSlope(tile, &h); |
35 |
41 |
36 return tile; |
42 f = GetBridgeFoundation(tileh, a); |
|
43 |
|
44 if (f) { |
|
45 if (f < 15) { |
|
46 h += TILE_HEIGHT; |
|
47 tileh = SLOPE_FLAT; |
|
48 } else { |
|
49 tileh = _inclined_tileh[f - 15]; |
|
50 } |
|
51 } |
|
52 |
|
53 return h + TILE_HEIGHT; |
37 } |
54 } |