diff options
-rw-r--r-- | rail_cmd.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/rail_cmd.c b/rail_cmd.c index 805dc16a4..6c0d1890d 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -113,29 +113,36 @@ static bool CheckTrackCombination(byte map5, byte trackbits, byte flags) { _error_message = STR_1001_IMPOSSIBLE_TRACK_COMBINATION; - if ((map5&RAIL_TYPE_MASK) == RAIL_TYPE_SIGNALS) { - - if (map5 & trackbits) { - _error_message = STR_1007_ALREADY_BUILT; - return false; - } + switch (map5 & RAIL_TYPE_MASK) { + case RAIL_TYPE_NORMAL: + if (map5 & trackbits) { + _error_message = STR_1007_ALREADY_BUILT; + return false; + } - map5 |= trackbits; - return (map5 == (RAIL_TYPE_SIGNALS|RAIL_BIT_UPPER|RAIL_BIT_LOWER) || map5 == (RAIL_TYPE_SIGNALS|RAIL_BIT_LEFT|RAIL_BIT_RIGHT)); + if (flags & DC_NO_RAIL_OVERLAP) { + // Computer players are not allowed to intersect pieces of rail. + map5 |= trackbits; + return + map5 == (RAIL_BIT_UPPER | RAIL_BIT_LOWER) || + map5 == (RAIL_BIT_LEFT | RAIL_BIT_RIGHT); + } else { + return true; + } - } else if ((map5&RAIL_TYPE_MASK) == RAIL_TYPE_NORMAL) { - _error_message = STR_1007_ALREADY_BUILT; - if (map5 & trackbits) - return false; + case RAIL_TYPE_SIGNALS: + if (map5 & trackbits) { + _error_message = STR_1007_ALREADY_BUILT; + return false; + } - // Computer players are not allowed to intersect pieces of rail. - if (!(flags&DC_NO_RAIL_OVERLAP)) - return true; + map5 |= trackbits; + return + map5 == (RAIL_TYPE_SIGNALS | RAIL_BIT_UPPER | RAIL_BIT_LOWER) || + map5 == (RAIL_TYPE_SIGNALS | RAIL_BIT_LEFT | RAIL_BIT_RIGHT); - map5 |= trackbits; - return (map5 == (RAIL_BIT_UPPER|RAIL_BIT_LOWER) || map5 == (RAIL_BIT_LEFT|RAIL_BIT_RIGHT)); - } else { - return false; + default: + return false; } } |