Changeset - r1082:5511b4ed9376
[Not reviewed]
master
0 3 0
darkvater - 19 years ago 2005-01-21 19:52:32
darkvater@openttd.org
(svn r1583) -Fix: You should no longer be able to delete bridges on any type of underground when there is a vehicle on it
3 files changed with 24 insertions and 16 deletions:
0 comments (0 inline, 0 general)
functions.h
Show inline comments
 
@@ -214,6 +214,7 @@ bool ScrollWindowTo(int x, int y, Window
 
bool ScrollMainWindowToTile(TileIndex tile);
 
bool ScrollMainWindowTo(int x, int y);
 
void DrawSprite(uint32 img, int x, int y);
 
uint GetCorrectTileHeight(TileIndex tile);
 
bool EnsureNoVehicle(TileIndex tile);
 
bool EnsureNoVehicleZ(TileIndex tile, byte z);
 
void MarkAllViewportsDirty(int left, int top, int right, int bottom);
tunnelbridge_cmd.c
Show inline comments
 
@@ -742,7 +742,8 @@ static int32 DoClearBridge(uint tile, ui
 
	*/
 
	tile		+= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
 
	endtile	-= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
 
	if ((v = FindVehicleBetween(tile, endtile, TilePixelHeight(tile) + 8)) != NULL) {
 
	/* Bridges on slopes might have their Z-value offset..correct this */
 
	if ((v = FindVehicleBetween(tile, endtile, TilePixelHeight(tile) + 8 + GetCorrectTileHeight(tile))) != NULL) {
 
		VehicleInTheWayErrMsg(v);
 
		return CMD_ERROR;
 
	}
 
@@ -804,25 +805,21 @@ clear_it:;
 
}
 

	
 
static int32 ClearTile_TunnelBridge(uint tile, byte flags) {
 
	int32 ret;
 
	byte m5 = _map5[tile];
 

	
 
	if ((m5 & 0xF0) == 0) {
 
		if (flags & DC_AUTO)
 
			return_cmd_error(STR_5006_MUST_DEMOLISH_TUNNEL_FIRST);
 

	
 
		return DoClearTunnel(tile, flags);
 
	} else if (m5 & 0x80) {
 
		if (flags & DC_AUTO)
 
			return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
 

	
 
		ret = DoClearBridge(tile, flags);
 
		if (ret == CMD_ERROR)
 
			return CMD_ERROR;
 

	
 
		return ret;
 
	} else {
 
		return CMD_ERROR;
 
	}
 
		return DoClearBridge(tile, flags);
 
	} 
 
	
 
	return CMD_ERROR;
 
}
 

	
 
int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec)
vehicle.c
Show inline comments
 
@@ -73,17 +73,27 @@ static void *EnsureNoVehicleProcZ(Vehicl
 
	return v;
 
}
 

	
 
static inline uint Correct_Z(uint tileh)
 
{
 
	// needs z correction for slope-type graphics that have the NORTHERN tile lowered
 
	// 1, 2, 3, 4, 5, 6 and 7
 
	return (CORRECT_Z(tileh)) ? 8 : 0;
 
}
 

	
 
uint GetCorrectTileHeight(TileIndex tile)
 
{
 
	TileInfo ti;
 

	
 
	FindLandscapeHeightByTile(&ti, tile);
 
	return Correct_Z(ti.tileh);
 
}
 

	
 
bool EnsureNoVehicleZ(TileIndex tile, byte z)
 
{
 
	TileInfo ti;
 

	
 
	FindLandscapeHeightByTile(&ti, tile);
 
	// needs z correction for slope-type graphics that have the NORTHERN tile lowered
 
	// 1, 2, 3, 4, 5, 6 and 7
 
	if (CORRECT_Z(ti.tileh))
 
		z += 8;
 

	
 
	ti.z = z;
 
	ti.z = z + Correct_Z(ti.tileh);
 

	
 
	return VehicleFromPos(tile, &ti, EnsureNoVehicleProcZ) == NULL;
 
}
0 comments (0 inline, 0 general)