summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2008-03-27 17:51:20 +0000
committerpeter1138 <peter1138@openttd.org>2008-03-27 17:51:20 +0000
commit7df7a3069c010efd6994e373153833a8c7917ec1 (patch)
treea28f15d6635f2858017c9b303dc4361a1a0dee34 /src
parent3343586c84efde39ea15b681760a432546315053 (diff)
downloadopenttd-7df7a3069c010efd6994e373153833a8c7917ec1.tar.xz
(svn r12450) -Codechange: Use a pointer instead of several array dereferences.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 8ee2e059b..5d405b483 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -5373,17 +5373,18 @@ static const CargoLabel *_default_refitmasks[] = {
static void CalculateRefitMasks()
{
for (EngineID engine = 0; engine < TOTAL_NUM_ENGINES; engine++) {
+ EngineInfo *ei = &_engine_info[engine];
uint32 mask = 0;
uint32 not_mask = 0;
uint32 xor_mask = 0;
- if (_engine_info[engine].refit_mask != 0) {
+ if (ei->refit_mask != 0) {
const GRFFile *file = GetEngineGRF(engine);
if (file != NULL && file->cargo_max != 0) {
/* Apply cargo translation table to the refit mask */
uint num_cargo = min(32, file->cargo_max);
for (uint i = 0; i < num_cargo; i++) {
- if (!HasBit(_engine_info[engine].refit_mask, i)) continue;
+ if (!HasBit(ei->refit_mask, i)) continue;
CargoID c = GetCargoIDByLabel(file->cargo_list[i]);
if (c == CT_INVALID) continue;
@@ -5396,7 +5397,7 @@ static void CalculateRefitMasks()
const CargoSpec *cs = GetCargo(c);
if (!cs->IsValid()) continue;
- if (HasBit(_engine_info[engine].refit_mask, cs->bitnum)) SetBit(xor_mask, c);
+ if (HasBit(ei->refit_mask, cs->bitnum)) SetBit(xor_mask, c);
}
}
}
@@ -5427,7 +5428,8 @@ static void CalculateRefitMasks()
}
}
}
- _engine_info[engine].refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask;
+
+ ei->refit_mask = ((mask & ~not_mask) ^ xor_mask) & _cargo_mask;
/* Check if this engine's cargo type is valid. If not, set to the first refittable
* cargo type. Apparently cargo_type isn't a common property... */
@@ -5437,19 +5439,19 @@ static void CalculateRefitMasks()
case VEH_TRAIN: {
RailVehicleInfo *rvi = &_rail_vehicle_info[engine];
if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine);
- if (rvi->cargo_type == CT_INVALID) _engine_info[engine].climates = 0;
+ if (rvi->cargo_type == CT_INVALID) ei->climates = 0;
break;
}
case VEH_ROAD: {
RoadVehicleInfo *rvi = &_road_vehicle_info[engine - ROAD_ENGINES_INDEX];
if (rvi->cargo_type == CT_INVALID) rvi->cargo_type = FindFirstRefittableCargo(engine);
- if (rvi->cargo_type == CT_INVALID) _engine_info[engine].climates = 0;
+ if (rvi->cargo_type == CT_INVALID) ei->climates = 0;
break;
}
case VEH_SHIP: {
ShipVehicleInfo *svi = &_ship_vehicle_info[engine - SHIP_ENGINES_INDEX];
if (svi->cargo_type == CT_INVALID) svi->cargo_type = FindFirstRefittableCargo(engine);
- if (svi->cargo_type == CT_INVALID) _engine_info[engine].climates = 0;
+ if (svi->cargo_type == CT_INVALID) ei->climates = 0;
break;
}
}