summaryrefslogtreecommitdiff
path: root/rail_cmd.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-11-08 10:09:46 +0000
committerpeter1138 <peter1138@openttd.org>2006-11-08 10:09:46 +0000
commitc73578aae6cd14c04a5bd19ab1b1016f3e6bcda9 (patch)
tree8d410de55f4ee6720909a6d9db001496d2ca3b47 /rail_cmd.c
parent2ebd07ecfca2a31c6a0f59bb395ed81745df76ed (diff)
downloadopenttd-c73578aae6cd14c04a5bd19ab1b1016f3e6bcda9.tar.xz
(svn r7112) -Codechange (r7106): Improve the test for determining if the rail type should be converted
Diffstat (limited to 'rail_cmd.c')
-rw-r--r--rail_cmd.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index 395990a71..2877389d5 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -285,10 +285,9 @@ int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (CmdFailed(ret)) return ret;
cost += ret;
- /* XXX Assume a 'higher' railtype has preference. This means we
- * will convert from normal rail to electrified rail, but not
- * the other way around. */
- if (GetRailType(tile) < railtype) {
+ /* If the rail types don't match, try to convert only if 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 += ret;