Changeset - r8385:b9b4b8b2f2cc
[Not reviewed]
master
0 1 0
peter1138 - 16 years ago 2008-01-23 08:28:19
peter1138@openttd.org
(svn r11955) -Fix (r11926): Prevent bridge and tunnel ends being placed on rivers.
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -255,13 +255,13 @@ CommandCost CmdBuildBridge(TileIndex end
 
	bridge_len = sx + sy - x - y - 1;
 
	if (!CheckBridge_Stuff(bridge_type, bridge_len)) return_cmd_error(STR_5015_CAN_T_BUILD_BRIDGE_HERE);
 

	
 
	/* retrieve landscape height and ensure it's on land */
 
	tile_start = TileXY(x, y);
 
	tile_end = TileXY(sx, sy);
 
	if (IsWaterTile(tile_start) || IsWaterTile(tile_end)) {
 
	if (IsWaterTile(tile_start) || IsRiverTile(tile_start) || IsWaterTile(tile_end) || IsRiverTile(tile_end)) {
 
		return_cmd_error(STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH);
 
	}
 

	
 
	tileh_start = GetTileSlope(tile_start, &z_start);
 
	tileh_end = GetTileSlope(tile_end, &z_end);
 

	
 
@@ -481,12 +481,14 @@ CommandCost CmdBuildTunnel(TileIndex sta
 
		case SLOPE_SE: direction = DIAGDIR_SE; break;
 
		case SLOPE_NW: direction = DIAGDIR_NW; break;
 
		case SLOPE_NE: direction = DIAGDIR_NE; break;
 
		default: return_cmd_error(STR_500B_SITE_UNSUITABLE_FOR_TUNNEL);
 
	}
 

	
 
	if (IsRiverTile(start_tile)) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
 

	
 
	ret = DoCommand(start_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
	if (CmdFailed(ret)) return ret;
 

	
 
	/* XXX - do NOT change 'ret' in the loop, as it is used as the price
 
	 * for the clearing of the entrance of the tunnel. Assigning it to
 
	 * cost before the loop will yield different costs depending on start-
 
@@ -533,12 +535,14 @@ CommandCost CmdBuildTunnel(TileIndex sta
 
	cost.AddCost(_price.build_tunnel);
 
	cost.AddCost(ret);
 

	
 
	/* if the command fails from here on we want the end tile to be highlighted */
 
	_build_tunnel_endtile = end_tile;
 

	
 
	if (IsRiverTile(end_tile)) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
 

	
 
	/* slope of end tile must be complementary to the slope of the start tile */
 
	if (end_tileh != ComplementSlope(start_tileh)) {
 
		/* Check if there is a structure on the terraformed tile. Do not add the cost, that will be done by the terraforming */
 
		ret = DoCommand(end_tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR);
 
		if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND);
 

	
0 comments (0 inline, 0 general)