Changeset - r22061:afde426625d7
[Not reviewed]
master
0 1 0
planetmaker - 9 years ago 2015-04-11 11:50:02
planetmaker@openttd.org
(svn r27225) -Change [FS#6262]: Be more lenient about road stop removal when at least one stop could be removed (afd88)
1 file changed with 10 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/station_cmd.cpp
Show inline comments
 
@@ -2045,14 +2045,16 @@ CommandCost CmdRemoveRoadStop(TileIndex 
 
	if (width == 0 || height == 0) return CMD_ERROR;
 
	/* Check if the first tile and the last tile are valid */
 
	if (!IsValidTile(tile) || TileAddWrap(tile, width - 1, height - 1) == INVALID_TILE) return CMD_ERROR;
 

	
 
	TileArea roadstop_area(tile, width, height);
 

	
 
	int quantity = 0;
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	CommandCost last_error(STR_ERROR_THERE_IS_NO_STATION);
 
	bool had_success = false;
 

	
 
	TILE_AREA_LOOP(cur_tile, roadstop_area) {
 
		/* Make sure the specified tile is a road stop of the correct type */
 
		if (!IsTileType(cur_tile, MP_STATION) || !IsRoadStop(cur_tile) || (uint32)GetRoadStopType(cur_tile) != GB(p2, 0, 1)) continue;
 

	
 
		/* Save the stop info before it is removed */
 
		bool is_drive_through = IsDriveThroughStopTile(cur_tile);
 
@@ -2061,16 +2063,19 @@ CommandCost CmdRemoveRoadStop(TileIndex 
 
				((GetRoadStopDir(cur_tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y) :
 
				DiagDirToRoadBits(GetRoadStopDir(cur_tile));
 

	
 
		Owner road_owner = GetRoadOwner(cur_tile, ROADTYPE_ROAD);
 
		Owner tram_owner = GetRoadOwner(cur_tile, ROADTYPE_TRAM);
 
		CommandCost ret = RemoveRoadStop(cur_tile, flags);
 
		if (ret.Failed()) return ret;
 
		if (ret.Failed()) {
 
			last_error = ret;
 
			continue;
 
		}
 
		cost.AddCost(ret);
 

	
 
		quantity++;
 
		had_success = true;
 

	
 
		/* If the stop was a drive-through stop replace the road */
 
		if ((flags & DC_EXEC) && is_drive_through) {
 
			MakeRoadNormal(cur_tile, road_bits, rts, ClosestTownFromTile(cur_tile, UINT_MAX)->index,
 
					road_owner, tram_owner);
 

	
 
			/* Update company infrastructure counts. */
 
@@ -2082,15 +2087,13 @@ CommandCost CmdRemoveRoadStop(TileIndex 
 
					DirtyCompanyInfrastructureWindows(c->index);
 
				}
 
			}
 
		}
 
	}
 

	
 
	if (quantity == 0) return_cmd_error(STR_ERROR_THERE_IS_NO_STATION);
 

	
 
	return cost;
 
	return had_success ? cost : last_error;
 
}
 

	
 
/**
 
 * Computes the minimal distance from town's xy to any airport's tile.
 
 * @param it An iterator over all airport tiles.
 
 * @param town_tile town's tile (t->xy)
0 comments (0 inline, 0 general)