From f8b5b6667fa6f416f5f6b5c9ca98c390cb37e27f Mon Sep 17 00:00:00 2001 From: peter1138 Date: Wed, 23 Jan 2008 09:43:53 +0000 Subject: (svn r11957) -Codechange [FS#1678]: Minor simplification and optimisation when checking for available road/rail types (bilbo) --- src/rail.cpp | 5 +++-- src/road.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rail.cpp b/src/rail.cpp index 99119ce09..ab94cc04c 100644 --- a/src/rail.cpp +++ b/src/rail.cpp @@ -167,11 +167,12 @@ RailTypes GetPlayerRailtypes(PlayerID p) { 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); diff --git a/src/road.cpp b/src/road.cpp index 7fa9b4398..2a7241af1 100644 --- a/src/road.cpp +++ b/src/road.cpp @@ -96,11 +96,12 @@ RoadTypes GetPlayerRoadtypes(PlayerID p) { 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); } -- cgit v1.2.3-70-g09d2