(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).
--- 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;