From ae359d0d021a5d6ac9c108c220acf7e3884c968d Mon Sep 17 00:00:00 2001 From: tron Date: Mon, 28 Mar 2005 07:02:51 +0000 Subject: (svn r2094) In GetTileDesc_Track(): uint -> TileIndex, use enums, if () cascade -> switch --- rail_cmd.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/rail_cmd.c b/rail_cmd.c index 5449e3f55..805dc16a4 100644 --- a/rail_cmd.c +++ b/rail_cmd.c @@ -1938,30 +1938,32 @@ static void ClickTile_Track(uint tile) } -static void GetTileDesc_Track(uint tile, TileDesc *td) +static void GetTileDesc_Track(TileIndex tile, TileDesc *td) { - byte m5 = _map5[tile]; - if (!(m5 & 0x80)) { - if(!(m5 & 0x40)) // no signals + td->owner = _map_owner[tile]; + switch (_map5[tile] & RAIL_TYPE_MASK) { + case RAIL_TYPE_NORMAL: td->str = STR_1021_RAILROAD_TRACK; - else - { - switch(_map3_hi[tile] & 0x03) - { - case 0: td->str = STR_RAILROAD_TRACK_WITH_NORMAL_SIGNALS; - break; - case 1: td->str = STR_RAILROAD_TRACK_WITH_PRESIGNALS; - break; - case 2: td->str = STR_RAILROAD_TRACK_WITH_EXITSIGNALS; - break; - case 3: td->str = STR_RAILROAD_TRACK_WITH_COMBOSIGNALS; - break; - } + break; + + case RAIL_TYPE_SIGNALS: { + const StringID signal_type[] = { + STR_RAILROAD_TRACK_WITH_NORMAL_SIGNALS, + STR_RAILROAD_TRACK_WITH_PRESIGNALS, + STR_RAILROAD_TRACK_WITH_EXITSIGNALS, + STR_RAILROAD_TRACK_WITH_COMBOSIGNALS + }; + + td->str = signal_type[_map3_hi[tile] & 0x03]; + break; } - } else { - td->str = m5 < 0xC4 ? STR_1023_RAILROAD_TRAIN_DEPOT : STR_LANDINFO_WAYPOINT; + + case RAIL_TYPE_DEPOT: + default: + td->str = ((_map5[tile] & RAIL_SUBTYPE_MASK) == RAIL_SUBTYPE_DEPOT) ? + STR_1023_RAILROAD_TRAIN_DEPOT : STR_LANDINFO_WAYPOINT; + break; } - td->owner = _map_owner[tile]; } static void ChangeTileOwner_Track(uint tile, byte old_player, byte new_player) -- cgit v1.2.3-70-g09d2