author | KUDr |
Sun, 04 Mar 2007 12:53:05 +0000 | |
branch | cpp_gui |
changeset 6287 | e59240e63a90 |
parent 6268 | 4b5241e5dd10 |
child 6307 | f40e88cff863 |
permissions | -rw-r--r-- |
3214
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
2 |
|
6268
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5838
diff
changeset
|
3 |
/** @file bridge_map.cpp */ |
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5838
diff
changeset
|
4 |
|
3214
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
6 |
#include "openttd.h" |
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
7 |
#include "bridge_map.h" |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
8 |
#include "variables.h" |
3214
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
9 |
|
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
10 |
|
3225
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
11 |
TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir) |
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
12 |
{ |
4559
c853d2440065
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
3977
diff
changeset
|
13 |
TileIndexDiff delta = TileOffsByDiagDir(dir); |
3225
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
14 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
15 |
dir = ReverseDiagDir(dir); |
3977
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3933
diff
changeset
|
16 |
do { |
edb5b94e2094
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3933
diff
changeset
|
17 |
tile += delta; |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
18 |
} while (!IsBridgeTile(tile) || GetBridgeRampDirection(tile) != dir); |
3225
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
19 |
|
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
20 |
return tile; |
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
21 |
} |
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
22 |
|
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
23 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
24 |
TileIndex GetNorthernBridgeEnd(TileIndex t) |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
25 |
{ |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
26 |
return GetBridgeEnd(t, ReverseDiagDir(AxisToDiagDir(GetBridgeAxis(t)))); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
27 |
} |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
28 |
|
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
29 |
|
3225
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
30 |
TileIndex GetSouthernBridgeEnd(TileIndex t) |
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
31 |
{ |
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
32 |
return GetBridgeEnd(t, AxisToDiagDir(GetBridgeAxis(t))); |
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
33 |
} |
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
34 |
|
655763f3861c
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
35 |
|
3214
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
36 |
TileIndex GetOtherBridgeEnd(TileIndex tile) |
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
37 |
{ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
38 |
assert(IsBridgeTile(tile)); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
39 |
return GetBridgeEnd(tile, GetBridgeRampDirection(tile)); |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
40 |
} |
3933 | 41 |
|
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
42 |
uint GetBridgeHeight(TileIndex t) |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
43 |
{ |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
44 |
uint h; |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5835
diff
changeset
|
45 |
Slope tileh = GetTileSlope(t, &h); |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
46 |
uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t))); |
3933 | 47 |
|
6268
4b5241e5dd10
(svn r8938) [cpp_gui] -Sync with trunk (r8772..r8900)
bjarni
parents:
5838
diff
changeset
|
48 |
/* one height level extra if the ramp is on a flat foundation */ |
5573
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
49 |
return |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
50 |
h + TILE_HEIGHT + |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
51 |
(IS_INT_INSIDE(f, 1, 15) ? TILE_HEIGHT : 0) + |
afa6f92a71fd
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
52 |
(IsSteepSlope(tileh) ? TILE_HEIGHT : 0); |
3214
172b409bf612
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
53 |
} |