(svn r11059) -Fix [FS#1182]: inconsistency between Rail<->ElRail conversions of different kinds of rail containing tiles (normal rail, stations, depots, etc). Patch by SmatZ.

This commit is contained in:
rubidium
2007-09-08 09:52:02 +00:00
parent 20a3b37963
commit c97804461e
6 changed files with 69 additions and 67 deletions

View File

@@ -1227,22 +1227,14 @@ static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 fla
*/
CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
{
const Station* st = GetStationByTile(tile);
if (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile)) return CMD_ERROR;
// tile is not a railroad station?
/* Tile is not a railroad station? */
if (!IsRailwayStation(tile)) return CMD_ERROR;
if (GetRailType(tile) == totype) return CMD_ERROR;
// 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
if (exec) {
SetRailType(tile, totype);
MarkTileDirtyByTile(tile);
YapfNotifyTrackLayoutChange(tile, GetRailStationTrack(tile));
VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
}
return CommandCost(_price.build_rail / 2);