Changeset - r19514:de47675bfa33
[Not reviewed]
master
0 1 0
frosch - 12 years ago 2012-07-27 19:55:27
frosch@openttd.org
(svn r24439) -Fix [FS#5254]: In some cases ships could be covered with land.
1 file changed with 11 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/rail_cmd.cpp
Show inline comments
 
@@ -2927,21 +2927,32 @@ static CommandCost TestAutoslopeOnRailTi
 
		if (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old)) cost.AddCost(_price[PR_CLEAR_WATER]);
 
		if ((flags & DC_EXEC) != 0) SetRailGroundType(tile, RAIL_GROUND_BARREN);
 
	}
 
	return  cost;
 
}
 

	
 
/**
 
 * Test-procedure for HasVehicleOnPos to check for a ship.
 
 */
 
static Vehicle *EnsureNoShipProc(Vehicle *v, void *data)
 
{
 
	return v->type == VEH_SHIP ? v : NULL;
 
}
 

	
 
static CommandCost TerraformTile_Track(TileIndex tile, DoCommandFlag flags, int z_new, Slope tileh_new)
 
{
 
	int z_old;
 
	Slope tileh_old = GetTileSlope(tile, &z_old);
 
	if (IsPlainRail(tile)) {
 
		TrackBits rail_bits = GetTrackBits(tile);
 
		/* Is there flat water on the lower halftile that must be cleared expensively? */
 
		bool was_water = (GetRailGroundType(tile) == RAIL_GROUND_WATER && IsSlopeWithOneCornerRaised(tileh_old));
 

	
 
		/* Allow clearing the water only if there is no ship */
 
		if (was_water && HasVehicleOnPos(tile, NULL, &EnsureNoShipProc)) return_cmd_error(STR_ERROR_SHIP_IN_THE_WAY);
 

	
 
		/* First test autoslope. However if it succeeds we still have to test the rest, because non-autoslope terraforming is cheaper. */
 
		CommandCost autoslope_result = TestAutoslopeOnRailTile(tile, flags, z_old, tileh_old, z_new, tileh_new, rail_bits);
 

	
 
		/* When there is only a single horizontal/vertical track, one corner can be terraformed. */
 
		Corner allowed_corner;
 
		switch (rail_bits) {
0 comments (0 inline, 0 general)