summaryrefslogtreecommitdiff
path: root/src/autoreplace_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-10-06 19:17:07 +0000
committerfrosch <frosch@openttd.org>2009-10-06 19:17:07 +0000
commitf3aacb8fe3e96efd90b0ab93dbf8fb33a8842434 (patch)
tree373048e110915c31097d4e056da5f54833620492 /src/autoreplace_cmd.cpp
parent95dfee1c604d420df9f0d5860fcddf29e657fc32 (diff)
downloadopenttd-f3aacb8fe3e96efd90b0ab93dbf8fb33a8842434.tar.xz
(svn r17725) -Codechange: Reduce usage of EngInfo and XxxVehInfo, esp. when a Engine * is already present.
Diffstat (limited to 'src/autoreplace_cmd.cpp')
-rw-r--r--src/autoreplace_cmd.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 6bef8dcc8..2c3f973f8 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -56,32 +56,31 @@ bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company)
/* we can't replace an engine into itself (that would be autorenew) */
if (from == to) return false;
- VehicleType type = Engine::Get(from)->type;
+ const Engine *e_from = Engine::Get(from);
+ const Engine *e_to = Engine::Get(to);
+ VehicleType type = e_from->type;
/* check that the new vehicle type is available to the company and its type is the same as the original one */
if (!IsEngineBuildable(to, type, company)) return false;
switch (type) {
case VEH_TRAIN: {
- const RailVehicleInfo *rvi_from = RailVehInfo(from);
- const RailVehicleInfo *rvi_to = RailVehInfo(to);
-
/* make sure the railtypes are compatible */
- if ((GetRailTypeInfo(rvi_from->railtype)->compatible_railtypes & GetRailTypeInfo(rvi_to->railtype)->compatible_railtypes) == 0) return false;
+ if ((GetRailTypeInfo(e_from->u.rail.railtype)->compatible_railtypes & GetRailTypeInfo(e_to->u.rail.railtype)->compatible_railtypes) == 0) return false;
/* make sure we do not replace wagons with engines or vise versa */
- if ((rvi_from->railveh_type == RAILVEH_WAGON) != (rvi_to->railveh_type == RAILVEH_WAGON)) return false;
+ if ((e_from->u.rail.railveh_type == RAILVEH_WAGON) != (e_to->u.rail.railveh_type == RAILVEH_WAGON)) return false;
break;
}
case VEH_ROAD:
/* make sure that we do not replace a tram with a normal road vehicles or vise versa */
- if (HasBit(EngInfo(from)->misc_flags, EF_ROAD_TRAM) != HasBit(EngInfo(to)->misc_flags, EF_ROAD_TRAM)) return false;
+ if (HasBit(e_from->info.misc_flags, EF_ROAD_TRAM) != HasBit(e_to->info.misc_flags, EF_ROAD_TRAM)) return false;
break;
case VEH_AIRCRAFT:
/* make sure that we do not replace a plane with a helicopter or vise versa */
- if ((AircraftVehInfo(from)->subtype & AIR_CTOL) != (AircraftVehInfo(to)->subtype & AIR_CTOL)) return false;
+ if ((e_from->u.air.subtype & AIR_CTOL) != (e_to->u.air.subtype & AIR_CTOL)) return false;
break;
default: break;