mirror of https://github.com/OpenTTD/OpenTTD
(svn r5283) -Backport: r5260
-Fix: It was possible to convert the railtype of a bridge while a train was on itrelease/0.4
parent
6d4c3f9636
commit
91fc18dcdc
|
@ -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
|
|
@ -8,6 +8,7 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "bridge_map.h"
|
#include "bridge_map.h"
|
||||||
|
#include "slope.h"
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
@ -713,6 +714,19 @@ static TileIndex FindEdgesOfBridge(TileIndex tile, TileIndex *endtile)
|
||||||
return start;
|
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)
|
static int32 DoClearBridge(TileIndex tile, uint32 flags)
|
||||||
{
|
{
|
||||||
TileIndex endtile;
|
TileIndex endtile;
|
||||||
|
@ -898,16 +912,13 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, uint totype, bool exec)
|
||||||
} else if ((_m[tile].m5 & 0xC6) == 0x80) {
|
} else if ((_m[tile].m5 & 0xC6) == 0x80) {
|
||||||
TileIndex starttile;
|
TileIndex starttile;
|
||||||
int32 cost;
|
int32 cost;
|
||||||
uint z = TilePixelHeight(tile);
|
|
||||||
|
|
||||||
z += 8;
|
|
||||||
|
|
||||||
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
if (!CheckTileOwnership(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
// railway bridge
|
// railway bridge
|
||||||
starttile = tile = FindEdgesOfBridge(tile, &endtile);
|
starttile = tile = FindEdgesOfBridge(tile, &endtile);
|
||||||
// Make sure there's no vehicle on the bridge
|
// Make sure there's no vehicle on the bridge
|
||||||
v = FindVehicleBetween(tile, endtile, z);
|
v = FindVehicleBetween(tile, endtile, GetBridgeHeightRamp(tile));
|
||||||
if (v != NULL) {
|
if (v != NULL) {
|
||||||
VehicleInTheWayErrMsg(v);
|
VehicleInTheWayErrMsg(v);
|
||||||
return CMD_ERROR;
|
return CMD_ERROR;
|
||||||
|
|
Loading…
Reference in New Issue