summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-01-23 09:43:53 +0000
committerpeter1138 <peter1138@openttd.org>2008-01-23 09:43:53 +0000
commitf8b5b6667fa6f416f5f6b5c9ca98c390cb37e27f (patch)
treeb1a1951dd45415bb1d5f6de42fbeeee774236a25 /src
parenta2d416b253021a328176b1a0d93436ed2d73df92 (diff)
downloadopenttd-f8b5b6667fa6f416f5f6b5c9ca98c390cb37e27f.tar.xz
(svn r11957) -Codechange [FS#1678]: Minor simplification and optimisation when checking for available road/rail types (bilbo)
Diffstat (limited to 'src')
-rw-r--r--src/rail.cpp5
-rw-r--r--src/road.cpp5
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);
}