author | peter1138 |
Sat, 03 Jun 2006 19:23:14 +0000 | |
changeset 3943 | d3d5f7b3d3d0 |
parent 3933 | 231ae3c419f4 |
child 3977 | 513433ebd092 |
permissions | -rw-r--r-- |
3214
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
2 |
|
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
3 |
#include "stdafx.h" |
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
4 |
#include "openttd.h" |
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
5 |
#include "bridge_map.h" |
3933 | 6 |
#include "variables.h" |
3214
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
7 |
|
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
8 |
|
3225
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
9 |
TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir) |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
10 |
{ |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
11 |
TileIndexDiff delta = TileOffsByDir(dir); |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
12 |
|
3933 | 13 |
do { tile += delta; } while (IsBridgeAbove(tile) && IsBridgeOfAxis(tile, DiagDirToAxis(dir))); |
3225
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
14 |
|
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
15 |
return tile; |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
16 |
} |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
17 |
|
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
18 |
|
3933 | 19 |
TileIndex GetNorthernBridgeEnd(TileIndex t) |
20 |
{ |
|
21 |
return GetBridgeEnd(t, ReverseDiagDir(AxisToDiagDir(GetBridgeAxis(t)))); |
|
22 |
} |
|
23 |
||
24 |
||
3225
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
25 |
TileIndex GetSouthernBridgeEnd(TileIndex t) |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
26 |
{ |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
27 |
return GetBridgeEnd(t, AxisToDiagDir(GetBridgeAxis(t))); |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
28 |
} |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
29 |
|
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
30 |
|
3214
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
31 |
TileIndex GetOtherBridgeEnd(TileIndex tile) |
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
32 |
{ |
3933 | 33 |
assert(IsBridgeTile(tile)); |
34 |
return GetBridgeEnd(tile, GetBridgeRampDirection(tile)); |
|
35 |
} |
|
3214
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
36 |
|
3933 | 37 |
uint GetBridgeHeight(TileIndex tile, Axis a) |
38 |
{ |
|
39 |
uint h, f; |
|
40 |
uint tileh = GetTileSlope(tile, &h); |
|
3214
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
41 |
|
3933 | 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; |
|
3214
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
54 |
} |