summaryrefslogtreecommitdiff
path: root/rail_cmd.c
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
commit32c1de3be0fae3f1fbd36b81c6407971682c2131 (patch)
tree582ccbd3f8ff96862af7dbdbd4df834ad5e4945b /rail_cmd.c
parent47e63297a154f8bd38c9939d43eef43f70e8868f (diff)
downloadopenttd-32c1de3be0fae3f1fbd36b81c6407971682c2131.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).
Diffstat (limited to 'rail_cmd.c')
-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;