--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/slope.h Thu Jun 15 16:45:29 2006 +0000
@@ -0,0 +1,30 @@
+/* $Id$ */
+
+#ifndef SLOPE_H
+#define SLOPE_H
+
+typedef enum Slope {
+ SLOPE_FLAT = 0x00,
+ SLOPE_W = 0x01,
+ SLOPE_S = 0x02,
+ SLOPE_E = 0x04,
+ SLOPE_N = 0x08,
+ SLOPE_STEEP = 0x10,
+ SLOPE_NW = SLOPE_N | SLOPE_W,
+ SLOPE_SW = SLOPE_S | SLOPE_W,
+ SLOPE_SE = SLOPE_S | SLOPE_E,
+ SLOPE_NE = SLOPE_N | SLOPE_E,
+ SLOPE_EW = SLOPE_E | SLOPE_W,
+ SLOPE_NS = SLOPE_N | SLOPE_S,
+ SLOPE_ELEVATED = SLOPE_N | SLOPE_E | SLOPE_S | SLOPE_W,
+ SLOPE_NWS = SLOPE_N | SLOPE_W | SLOPE_S,
+ SLOPE_WSE = SLOPE_W | SLOPE_S | SLOPE_E,
+ SLOPE_SEN = SLOPE_S | SLOPE_E | SLOPE_N,
+ SLOPE_ENW = SLOPE_E | SLOPE_N | SLOPE_W,
+ SLOPE_STEEP_W = SLOPE_STEEP | SLOPE_NWS,
+ SLOPE_STEEP_S = SLOPE_STEEP | SLOPE_WSE,
+ SLOPE_STEEP_E = SLOPE_STEEP | SLOPE_SEN,
+ SLOPE_STEEP_N = SLOPE_STEEP | SLOPE_ENW
+} Slope;
+
+#endif
--- a/tunnelbridge_cmd.c Thu Jun 15 15:25:18 2006 +0000
+++ b/tunnelbridge_cmd.c Thu Jun 15 16:45:29 2006 +0000
@@ -8,6 +8,7 @@
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
+#include "slope.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
@@ -713,6 +714,19 @@
return start;
}
+
+static uint GetBridgeHeightRamp(TileIndex t)
+{
+ /* Return the height there (the height of the NORTH CORNER)
+ * If the end of the bridge is on a tile with all corners except the north corner raised,
+ * the z coordinate is 1 height level too low. Compensate for that */
+ return
+ TilePixelHeight(t) +
+ (GetTileSlope(t, NULL) == SLOPE_WSE ? TILE_HEIGHT : 0) +
+ TILE_HEIGHT;
+}
+
+
static int32 DoClearBridge(TileIndex tile, uint32 flags)
{
TileIndex endtile;
@@ -898,16 +912,13 @@
} else if ((_m[tile].m5 & 0xC6) == 0x80) {
TileIndex starttile;
int32 cost;
- uint z = TilePixelHeight(tile);
-
- z += 8;
if (!CheckTileOwnership(tile)) return CMD_ERROR;
// railway bridge
starttile = tile = FindEdgesOfBridge(tile, &endtile);
// Make sure there's no vehicle on the bridge
- v = FindVehicleBetween(tile, endtile, z);
+ v = FindVehicleBetween(tile, endtile, GetBridgeHeightRamp(tile));
if (v != NULL) {
VehicleInTheWayErrMsg(v);
return CMD_ERROR;