Mercurial > hg > openttd
changeset 8387:170ba96bf00e draft
(svn r11957) -Codechange [FS#1678]: Minor simplification and optimisation when checking for available road/rail types (bilbo)
author | peter1138 <peter1138@openttd.org> |
---|---|
date | Wed, 23 Jan 2008 09:43:53 +0000 |
parents | b61dbe67cbb3 |
children | 11a08bc12922 |
files | src/rail.cpp src/road.cpp |
diffstat | 2 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/rail.cpp +++ b/src/rail.cpp @@ -167,11 +167,12 @@ { RailTypes rt = RAILTYPES_NONE; - for (EngineID i = 0; i != TOTAL_NUM_ENGINES; i++) { + EngineID i; + FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_TRAIN) { const Engine* e = GetEngine(i); const EngineInfo *ei = EngInfo(i); - if (e->type == VEH_TRAIN && HasBit(ei->climates, _opt.landscape) && + if (HasBit(ei->climates, _opt.landscape) && (HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) { const RailVehicleInfo *rvi = RailVehInfo(i);
--- a/src/road.cpp +++ b/src/road.cpp @@ -96,11 +96,12 @@ { RoadTypes rt = ROADTYPES_NONE; - for (EngineID i = 0; i != TOTAL_NUM_ENGINES; i++) { + EngineID i; + FOR_ALL_ENGINEIDS_OF_TYPE(i, VEH_ROAD) { const Engine* e = GetEngine(i); const EngineInfo *ei = EngInfo(i); - if (e->type == VEH_ROAD && HasBit(ei->climates, _opt.landscape) && + if (HasBit(ei->climates, _opt.landscape) && (HasBit(e->player_avail, p) || _date >= e->intro_date + 365)) { SetBit(rt, HasBit(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD); }