summaryrefslogtreecommitdiff
path: root/rail_cmd.c
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-04-02 22:04:43 +0000
committertron <tron@openttd.org>2005-04-02 22:04:43 +0000
commit03569d1c49eeda330b3908ed8f9b907997c9caaa (patch)
tree5f7efbdce6bedb5aaf443b96acae87b70e03a29d /rail_cmd.c
parentc75d699b02d2e884e474ae12e74ef1dffea48332 (diff)
downloadopenttd-03569d1c49eeda330b3908ed8f9b907997c9caaa.tar.xz
(svn r2134) Return the correct error message if rail is already under a bridge, fix for r2131
Diffstat (limited to 'rail_cmd.c')
-rw-r--r--rail_cmd.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/rail_cmd.c b/rail_cmd.c
index 832941b17..8c48fa6b7 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -299,21 +299,31 @@ int32 CmdBuildSingleRail(int x, int y, uint32 flags,
switch (GetTileType(tile)) {
case MP_TUNNELBRIDGE:
if ((m5 & 0xC0) != 0xC0 || // not bridge middle part?
- (m5 & 0x01 ? 1 : 2) != rail_bit || // wrong direction?
- (m5 & 0x38) != 0x00) { // no clear land underneath?
+ (m5 & 0x01 ? 1 : 2) != rail_bit) { // wrong direction?
// Get detailed error message
return DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
- ret = CheckRailSlope(tileh, rail_bit, 0, tile);
- if (ret & CMD_ERROR) return ret;
- cost += ret;
+ switch (m5 & 0x38) { // what's under the bridge?
+ case 0x00: // clear land
+ ret = CheckRailSlope(tileh, rail_bit, 0, tile);
+ if (ret & CMD_ERROR) return ret;
+ cost += ret;
- if (flags & DC_EXEC) {
- _map_owner[tile] = _current_player;
- _map3_lo[tile] &= ~0x0F;
- _map3_lo[tile] |= rail_type;
- _map5[tile] = (m5 & 0xC7) | 0x20; // railroad under bridge
+ if (flags & DC_EXEC) {
+ _map_owner[tile] = _current_player;
+ _map3_lo[tile] &= ~0x0F;
+ _map3_lo[tile] |= rail_type;
+ _map5[tile] = (m5 & 0xC7) | 0x20; // railroad under bridge
+ }
+ break;
+
+ case 0x20: // rail already there
+ return_cmd_error(STR_1007_ALREADY_BUILT);
+
+ default:
+ // Get detailed error message
+ return DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
break;