@@ -804,12 +804,40 @@ extern const int _default_railtype_cost_
static inline Money RailBuildCost(RailType railtype)
{
assert(railtype < RAILTYPE_END);
return (_price.build_rail * _railtype_cost_multiplier[railtype]) >> 3;
}
/**
* Calculates the cost of rail conversion
* @param from The railtype we are converting from
* @param to The railtype we are converting to
* @return Cost per TrackBit
*/
static inline Money RailConvertCost(RailType from, RailType to)
/* rail -> el. rail
* calculate the price as 5 / 4 of (cost build el. rail) - (cost build rail)
* (the price of workers to get to place is that 1/4)
if (HasPowerOnRail(from, to)) {
return ((RailBuildCost(to) - RailBuildCost(from)) * 5) >> 2;
/* el. rail -> rail
* calculate the price as 1 / 4 of (cost build el. rail) - (cost build rail)
* (the price of workers is 1 / 4 + price of copper sold to a recycle center)
if (HasPowerOnRail(to, from)) {
return (RailBuildCost(from) - RailBuildCost(to)) >> 2;
/* make the price the same as remove + build new type */
return RailBuildCost(to) + _price.remove_rail;
void *UpdateTrainPowerProc(Vehicle *v, void *data);
void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
* Draws overhead wires and pylons for electric railways.
@@ -1198,13 +1198,13 @@ static CommandCost DoConvertRail(TileInd
/* update power of train engines on this tile */
VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
return CommandCost(RailBuildCost(totype) / 2);
return CommandCost(RailConvertCost(GetRailType(tile), totype) * CountBits(GetTrackBits(tile)));
extern CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec);
extern CommandCost DoConvertStreetRail(TileIndex tile, RailType totype, bool exec);
extern CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec);
@@ -603,13 +603,13 @@ CommandCost DoConvertStreetRail(TileInde
SetRailType(tile, totype);
MarkTileDirtyByTile(tile);
YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetCrossingRailBits(tile)));
return CommandCost(RailConvertCost(GetRailType(tile), totype));
/** Build a long piece of road.
* @param end_tile end tile of drag
* @param flags operation to perform
@@ -1306,13 +1306,13 @@ CommandCost DoConvertStationRail(TileInd
YapfNotifyTrackLayoutChange(tile, GetRailStationTrack(tile));
* @param truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK
* @param st The Station to do the whole procedure for
* @return a pointer to where to link a new RoadStop*
@@ -771,13 +771,13 @@ CommandCost DoConvertTunnelBridgeRail(Ti
YapfNotifyTrackLayoutChange(endtile, track);
VehicleFromPos(endtile, &endtile, UpdateTrainPowerProc);
return CommandCost((length + 1) * (RailBuildCost(totype) / 2));
return CommandCost((length + 1) * RailConvertCost(GetRailType(tile), totype));
} else if (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
TileIndex endtile = GetOtherBridgeEnd(tile);
byte bridge_height = GetBridgeHeight(tile);
if (!IsCompatibleRail(GetRailType(tile), totype) &&
(FindVehicleOnTileZ(tile, bridge_height) != NULL ||
@@ -803,13 +803,13 @@ CommandCost DoConvertTunnelBridgeRail(Ti
for (tile += delta; tile != endtile; tile += delta) {
MarkTileDirtyByTile(tile); // TODO encapsulate this into a function
return CommandCost((DistanceManhattan(tile, endtile) + 1) * (RailBuildCost(totype) / 2));
return CommandCost((DistanceManhattan(tile, endtile) + 1) * RailConvertCost(GetRailType(tile), totype));
} else {
return CMD_ERROR;
Status change: