changeset 5059:64de9e340548 draft

(svn r7112) -Codechange (r7106): Improve the test for determining if the rail type should be converted
author peter1138 <peter1138@openttd.org>
date Wed, 08 Nov 2006 10:09:46 +0000
parents 796ba2b73fdf
children d3c28305504d
files rail_cmd.c
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -285,10 +285,9 @@
 			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;