mirror of https://github.com/OpenTTD/OpenTTD
parent
8ea68421b1
commit
b7a2166962
|
@ -1565,6 +1565,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
|
|
||||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||||
CommandCost error = CommandCost(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK); // by default, there is no track to convert.
|
CommandCost error = CommandCost(STR_ERROR_NO_SUITABLE_RAILROAD_TRACK); // by default, there is no track to convert.
|
||||||
|
bool found_convertible_track = false; // whether we actually did convert some track (see bug #7633)
|
||||||
|
|
||||||
TileIterator *iter = diagonal ? (TileIterator *)new DiagonalTileIterator(area_start, area_end) : new OrthogonalTileIterator(area_start, area_end);
|
TileIterator *iter = diagonal ? (TileIterator *)new DiagonalTileIterator(area_start, area_end) : new OrthogonalTileIterator(area_start, area_end);
|
||||||
for (; (tile = *iter) != INVALID_TILE; ++(*iter)) {
|
for (; (tile = *iter) != INVALID_TILE; ++(*iter)) {
|
||||||
|
@ -1660,6 +1661,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
InvalidateWindowData(WC_VEHICLE_DEPOT, tile);
|
InvalidateWindowData(WC_VEHICLE_DEPOT, tile);
|
||||||
InvalidateWindowData(WC_BUILD_VEHICLE, tile);
|
InvalidateWindowData(WC_BUILD_VEHICLE, tile);
|
||||||
}
|
}
|
||||||
|
found_convertible_track = true;
|
||||||
cost.AddCost(RailConvertCost(type, totype));
|
cost.AddCost(RailConvertCost(type, totype));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1671,6 +1673,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks));
|
YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
found_convertible_track = true;
|
||||||
cost.AddCost(RailConvertCost(type, totype) * CountBits(GetTrackBits(tile)));
|
cost.AddCost(RailConvertCost(type, totype) * CountBits(GetTrackBits(tile)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1733,6 +1736,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
found_convertible_track = true;
|
||||||
cost.AddCost((GetTunnelBridgeLength(tile, endtile) + 2) * RailConvertCost(type, totype));
|
cost.AddCost((GetTunnelBridgeLength(tile, endtile) + 2) * RailConvertCost(type, totype));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1743,6 +1747,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
YapfNotifyTrackLayoutChange(tile, track);
|
YapfNotifyTrackLayoutChange(tile, track);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
found_convertible_track = true;
|
||||||
cost.AddCost(RailConvertCost(type, totype));
|
cost.AddCost(RailConvertCost(type, totype));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1760,7 +1765,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
}
|
}
|
||||||
|
|
||||||
delete iter;
|
delete iter;
|
||||||
return (cost.GetCost() == 0) ? error : cost;
|
return found_convertible_track ? cost : error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
|
static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
|
||||||
|
|
Loading…
Reference in New Issue