diff options
author | tron <tron@openttd.org> | 2006-03-06 20:55:24 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2006-03-06 20:55:24 +0000 |
commit | f2dc736554c06d69dd936131c4a09ddbc6b58083 (patch) | |
tree | 14ef1d7e7e885dff603aa06189b416a7bd2a6ae0 /tunnel_map.c | |
parent | 2d3c28f2b3d24c2b01e54a51e2dcf5ad7f4851c8 (diff) | |
download | openttd-f2dc736554c06d69dd936131c4a09ddbc6b58083.tar.xz |
(svn r3777) Add some functions to handle tunnels
Diffstat (limited to 'tunnel_map.c')
-rw-r--r-- | tunnel_map.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tunnel_map.c b/tunnel_map.c new file mode 100644 index 000000000..d39c7ef04 --- /dev/null +++ b/tunnel_map.c @@ -0,0 +1,25 @@ +/* $Id$ */ + +#include "stdafx.h" +#include "openttd.h" +#include "tile.h" +#include "tunnel_map.h" + +TileIndex GetOtherTunnelEnd(TileIndex tile) +{ + DiagDirection dir = GetTunnelDirection(tile); + TileIndexDiff delta = TileOffsByDir(dir); + uint z = GetTileZ(tile); + + dir = ReverseDiagDir(dir); + do { + tile += delta; + } while ( + !IsTileType(tile, MP_TUNNELBRIDGE) || + GB(_m[tile].m5, 4, 4) != 0 || + GetTunnelDirection(tile) != dir || + GetTileZ(tile) != z + ); + + return tile; +} |