mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-08-27 08:29:11 +00:00
(svn r9582) [0.5] -Backport from trunk (r9425, r9437, r9455, r9519):
- Fix: housekeeping in convert rail functions (r9425) - Fix: dedicated server crashed when the y part of the resolution was less than 10 (r9437) - Fix: values of diff_custom and snow_line in .cfg weren't checked properly (r9455) - Fix: free the malloc'd variable, not the pointer to that variable (r9519)
This commit is contained in:
@@ -764,6 +764,16 @@ static int32 ClearTile_TunnelBridge(TileIndex tile, byte flags)
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Switches the rail type for a tunnel or a bridgehead. As the railtype
|
||||
* on the bridge are determined by the one of the bridgehead, this
|
||||
* functions converts the railtype on the entire bridge.
|
||||
* @param tile The tile on which the railtype is to be convert.
|
||||
* @param totype The railtype we want to convert to
|
||||
* @param exec Switches between test and execute mode
|
||||
* @return The cost and state of the operation
|
||||
* @retval CMD_ERROR An error occured during the operation.
|
||||
*/
|
||||
int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||
{
|
||||
TileIndex endtile;
|
||||
@@ -792,7 +802,7 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
YapfNotifyTrackLayoutChange(endtile, track);
|
||||
}
|
||||
return (length + 1) * (_price.build_rail >> 1);
|
||||
return (length + 1) * (_price.build_rail / 2);
|
||||
} else if (IsBridge(tile) &&
|
||||
IsBridgeMiddle(tile) &&
|
||||
IsTransportUnderBridge(tile) &&
|
||||
@@ -809,7 +819,7 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||
|
||||
YapfNotifyTrackLayoutChange(tile, GetRailUnderBridge(tile));
|
||||
}
|
||||
return _price.build_rail >> 1;
|
||||
return _price.build_rail / 2;
|
||||
} else if (IsBridge(tile) && IsBridgeRamp(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
|
||||
TileIndexDiff delta;
|
||||
int32 cost;
|
||||
@@ -837,14 +847,14 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
|
||||
YapfNotifyTrackLayoutChange(tile, track);
|
||||
YapfNotifyTrackLayoutChange(endtile, track);
|
||||
}
|
||||
cost = 2 * (_price.build_rail >> 1);
|
||||
cost = 2 * (_price.build_rail / 2);
|
||||
delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
|
||||
for (tile += delta; tile != endtile; tile += delta) {
|
||||
if (exec) {
|
||||
SetRailTypeOnBridge(tile, totype);
|
||||
MarkTileDirtyByTile(tile);
|
||||
}
|
||||
cost += _price.build_rail >> 1;
|
||||
cost += _price.build_rail / 2;
|
||||
}
|
||||
|
||||
return cost;
|
||||
|
Reference in New Issue
Block a user