summaryrefslogtreecommitdiff
path: root/src/tunnelbridge_cmd.cpp
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2007-03-24 09:12:03 +0000
committercelestar <celestar@openttd.org>2007-03-24 09:12:03 +0000
commit49ff7cb9389ca6a2611738fae6b338d7e8a83c3b (patch)
tree0609b0f1d83ccc09e2f2cdf84583392216005ed5 /src/tunnelbridge_cmd.cpp
parentd5f16924d92a7cb793b891118ffc074d902c20a6 (diff)
downloadopenttd-49ff7cb9389ca6a2611738fae6b338d7e8a83c3b.tar.xz
(svn r9425) -Codechange/Fix (FS#689): Housekeeping in the convert rail functions: Changed the order of error checks to generate more meaningful error messages, added some doxygen comments and replaced bitshifting by proper mathematical operations
Diffstat (limited to 'src/tunnelbridge_cmd.cpp')
-rw-r--r--src/tunnelbridge_cmd.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index aa2279d7d..e386da262 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -696,6 +696,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;
@@ -724,7 +734,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) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
if (!CheckTileOwnership(tile)) return CMD_ERROR;
@@ -758,7 +768,7 @@ int32 DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec)
}
}
- return (DistanceManhattan(tile, endtile) + 1) * (_price.build_rail >> 1);
+ return (DistanceManhattan(tile, endtile) + 1) * (_price.build_rail / 2);
} else {
return CMD_ERROR;
}