summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-08-25 10:58:24 +0000
committerpeter1138 <peter1138@openttd.org>2008-08-25 10:58:24 +0000
commitc76455be02acc40e11d6ccd303a1a623add35a1e (patch)
tree91e6bea48996a557aa97f6ab2db0ab37014a7fc8 /src
parent411c65e755eb6dd2e1412d2edb0f811ebd5ce73d (diff)
downloadopenttd-c76455be02acc40e11d6ccd303a1a623add35a1e.tar.xz
(svn r14165) -Codechange: When over-building rail with a different type, don't convert the rail if the engines of the new type are powered on the existing type.
Diffstat (limited to 'src')
-rw-r--r--src/rail_cmd.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 88112966d..992eddd25 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -355,11 +355,16 @@ CommandCost CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p
cost.AddCost(ret);
/* If the rail types don't match, try to convert only if engines of
+ * the new rail type are not powered on the present rail type and engines of
* the present rail type are powered on the new rail type. */
- if (GetRailType(tile) != railtype && HasPowerOnRail(GetRailType(tile), railtype)) {
- ret = DoCommand(tile, tile, railtype, flags, CMD_CONVERT_RAIL);
- if (CmdFailed(ret)) return ret;
- cost.AddCost(ret);
+ if (GetRailType(tile) != railtype && !HasPowerOnRail(railtype, GetRailType(tile))) {
+ if (HasPowerOnRail(GetRailType(tile), railtype)) {
+ ret = DoCommand(tile, tile, railtype, flags, CMD_CONVERT_RAIL);
+ if (CmdFailed(ret)) return ret;
+ cost.AddCost(ret);
+ } else {
+ return CMD_ERROR;
+ }
}
if (flags & DC_EXEC) {