summaryrefslogtreecommitdiff
path: root/bridge_map.c
blob: cbb955c37774a61cea3c7f6a49537d3701a8f904 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* $Id$ */

#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"


TileIndex GetBridgeEnd(TileIndex tile, DiagDirection dir)
{
	TileIndexDiff delta = TileOffsByDir(dir);

	assert(DiagDirToAxis(dir) == GetBridgeAxis(tile));

	do {
		tile += delta;
	} while (!IsBridgeRamp(tile));

	return tile;
}


TileIndex GetSouthernBridgeEnd(TileIndex t)
{
	return GetBridgeEnd(t, AxisToDiagDir(GetBridgeAxis(t)));
}


TileIndex GetOtherBridgeEnd(TileIndex tile)
{
	TileIndexDiff delta = TileOffsByDir(GetBridgeRampDirection(tile));

	do {
		tile += delta;
	} while (!IsBridgeRamp(tile));

	return tile;
}