changeset 10006:8c4d6357e9b6 draft

(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.
author peter1138 <peter1138@openttd.org>
date Mon, 25 Aug 2008 10:58:24 +0000
parents 016cff5941c6
children 18cc449f6575
files src/rail_cmd.cpp
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -355,11 +355,16 @@
 			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) {