author | KUDr |
Fri, 20 Apr 2007 19:43:06 +0000 | |
changeset 6513 | 454347ca3dfb |
parent 6418 | e04693bbe82a |
child 7336 | 180fe387acfc |
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 |
|
6418
e04693bbe82a
(svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents:
6123
diff
changeset
|
3 |
/** @file bridge_map.cpp Map accessor functions for bridges. */ |
6123
04eb770ec17e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5587
diff
changeset
|
4 |
|
3214
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 "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
|
6 |
#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
|
7 |
#include "bridge_map.h" |
6418
e04693bbe82a
(svn r9554) -Documentation: add documentation to some map accessors.
rubidium
parents:
6123
diff
changeset
|
8 |
#include "bridge.h" |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
9 |
#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
|
10 |
|
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
11 |
|
3225
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
12 |
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
|
13 |
{ |
4559
aa0c13e39840
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
3977
diff
changeset
|
14 |
TileIndexDiff delta = TileOffsByDiagDir(dir); |
3225
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
15 |
|
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
16 |
dir = ReverseDiagDir(dir); |
3977
513433ebd092
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3933
diff
changeset
|
17 |
do { |
513433ebd092
(svn r5155) - Remove the bridge branch merge (revision r5070)
tron
parents:
3933
diff
changeset
|
18 |
tile += delta; |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
19 |
} while (!IsBridgeTile(tile) || GetBridgeRampDirection(tile) != dir); |
3225
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
20 |
|
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
21 |
return tile; |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
22 |
} |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
23 |
|
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
24 |
|
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
25 |
TileIndex GetNorthernBridgeEnd(TileIndex t) |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
26 |
{ |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
27 |
return GetBridgeEnd(t, ReverseDiagDir(AxisToDiagDir(GetBridgeAxis(t)))); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
28 |
} |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
29 |
|
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
30 |
|
3225
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
31 |
TileIndex GetSouthernBridgeEnd(TileIndex t) |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
32 |
{ |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
33 |
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
|
34 |
} |
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
35 |
|
3a3e35bd39a6
(svn r3898) Add functions to find a bridge end starting at a middle tile
tron
parents:
3214
diff
changeset
|
36 |
|
3214
dd744119dfac
(svn r3887) Add a function to get the other bridge end when you're at a bridge ramp
tron
parents:
diff
changeset
|
37 |
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
|
38 |
{ |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
39 |
assert(IsBridgeTile(tile)); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
40 |
return GetBridgeEnd(tile, GetBridgeRampDirection(tile)); |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
41 |
} |
3933 | 42 |
|
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
43 |
uint GetBridgeHeight(TileIndex t) |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
44 |
{ |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
45 |
uint h; |
5587
167d9a91ef02
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5584
diff
changeset
|
46 |
Slope tileh = GetTileSlope(t, &h); |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
47 |
uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(t))); |
3933 | 48 |
|
6123
04eb770ec17e
(svn r8859) -Cleanup: doxygen changes. Mostly @files missing tags and a few comments style.
belugas
parents:
5587
diff
changeset
|
49 |
/* one height level extra if the ramp is on a flat foundation */ |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
50 |
return |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
51 |
h + TILE_HEIGHT + |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
52 |
(IS_INT_INSIDE(f, 1, 15) ? TILE_HEIGHT : 0) + |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
53 |
(IsSteepSlope(tileh) ? TILE_HEIGHT : 0); |
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 |
} |