summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-11-07 22:34:59 +0000
committerpeter1138 <peter1138@openttd.org>2006-11-07 22:34:59 +0000
commitf03125c656449d8018c4a80c536bb865b54996dd (patch)
tree582ccbd3f8ff96862af7dbdbd4df834ad5e4945b
parent0b733ac28adb7c76b85c90a1017708c2d9d3c804 (diff)
downloadopenttd-f03125c656449d8018c4a80c536bb865b54996dd.tar.xz
(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).
-rw-r--r--rail_cmd.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index 24b1cf77c..29999fabb 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -273,7 +273,7 @@ int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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 @@ int32 CmdBuildSingleRail(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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;