# HG changeset patch # User peter1138 # Date 1162938899 0 # Node ID 45cfda0fd7ebd157dcf46b00ef919d31ab1215f9 # Parent f00d49506b9ce9b00640e37d4a5fb73a90ff149d (svn r7106) -Feature: Allow over-building of compatible railtypes, i.e. normal and electrified rail. If building electrified rail, normal rail is upgraded for you (for the normal cost). diff -r f00d49506b9c -r 45cfda0fd7eb rail_cmd.c --- a/rail_cmd.c Tue Nov 07 18:42:31 2006 +0000 +++ b/rail_cmd.c Tue Nov 07 22:34:59 2006 +0000 @@ -273,7 +273,7 @@ return CMD_ERROR; } if (!IsTileOwner(tile, _current_player) || - GetRailType(tile) != p1) { + !IsCompatibleRail(GetRailType(tile), p1)) { // Get detailed error message return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); } @@ -282,6 +282,15 @@ 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) < p1) { + ret = DoCommand(tile, tile, p1, flags, CMD_CONVERT_RAIL); + if (CmdFailed(ret)) return ret; + cost += ret; + } + if (flags & DC_EXEC) { SetRailGroundType(tile, RAIL_GROUND_BARREN); _m[tile].m5 |= trackbit;