Mercurial > hg > openttd
changeset 5054:e8337a74da5f draft
(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).
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Tue, 07 Nov 2006 22:34:59 +0000 |
parents | 82762e7993da |
children | ae6047e91cdd |
files | rail_cmd.c |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/rail_cmd.c +++ b/rail_cmd.c @@ -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;