# HG changeset patch # User peter1138 # Date 2006-11-08 10:09:46 # Node ID 9db34c5638060657c64ad15655d8f6aac1ddb57e # Parent a49343af9c7aea6d328cee62f4cf461d09f7152e (svn r7112) -Codechange (r7106): Improve the test for determining if the rail type should be converted diff --git a/rail_cmd.c b/rail_cmd.c --- a/rail_cmd.c +++ b/rail_cmd.c @@ -285,10 +285,9 @@ int32 CmdBuildSingleRail(TileIndex tile, 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;