summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/engine.h8
-rw-r--r--src/newgrf.cpp14
-rw-r--r--src/table/engines.h2
-rw-r--r--src/vehicle.cpp12
4 files changed, 21 insertions, 15 deletions
diff --git a/src/engine.h b/src/engine.h
index 54920e135..7f0d14875 100644
--- a/src/engine.h
+++ b/src/engine.h
@@ -16,6 +16,12 @@ enum RailVehicleTypes {
RAILVEH_WAGON, ///< simple wagon, not motorized
};
+enum EngineClass {
+ EC_STEAM,
+ EC_DIESEL,
+ EC_ELECTRIC,
+};
+
struct RailVehicleInfo {
byte image_index;
RailVehicleTypes railveh_type;
@@ -26,7 +32,7 @@ struct RailVehicleInfo {
uint16 weight;
byte running_cost_base;
byte running_cost_class;
- byte engclass; ///< 0: steam, 1: diesel, 2: electric
+ EngineClass engclass; ///< Class of engine for this vehicle
byte capacity;
CargoID cargo_type;
byte ai_rank;
diff --git a/src/newgrf.cpp b/src/newgrf.cpp
index 88ebbd3fc..97411ca03 100644
--- a/src/newgrf.cpp
+++ b/src/newgrf.cpp
@@ -447,21 +447,21 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf
*/
FOR_EACH_OBJECT {
uint8 traction = grf_load_byte(&buf);
- int engclass;
+ EngineClass engclass;
if (traction <= 0x07) {
- engclass = 0;
+ engclass = EC_STEAM;
} else if (traction <= 0x27) {
- engclass = 1;
+ engclass = EC_DIESEL;
} else if (traction <= 0x31) {
- engclass = 2;
+ engclass = EC_ELECTRIC;
} else if (traction <= 0x41) {
- engclass = 2;
+ engclass = EC_ELECTRIC;
} else {
break;
}
- if (rvi[i].railtype == RAILTYPE_RAIL && engclass == 2) rvi[i].railtype = RAILTYPE_ELECTRIC;
- if (rvi[i].railtype == RAILTYPE_ELECTRIC && engclass != 2) rvi[i].railtype = RAILTYPE_RAIL;
+ if (rvi[i].railtype == RAILTYPE_RAIL && engclass == EC_ELECTRIC) rvi[i].railtype = RAILTYPE_ELECTRIC;
+ if (rvi[i].railtype == RAILTYPE_ELECTRIC && engclass != EC_ELECTRIC) rvi[i].railtype = RAILTYPE_RAIL;
rvi[i].engclass = engclass;
}
diff --git a/src/table/engines.h b/src/table/engines.h
index 71d7c4146..54af58361 100644
--- a/src/table/engines.h
+++ b/src/table/engines.h
@@ -346,7 +346,7 @@ const EngineInfo orig_engine_info[] = {
* @param l railtype
* Tractive effort coefficient by default is the same as TTDPatch, 0.30*256=76
*/
-#define RVI(a, b, c, d, e, f, g, h, i, j, k, l) { a, b, c, {l}, d, e, f, g, h, h, i, j, k, 0, 0, 0, 0, 76, 0 }
+#define RVI(a, b, c, d, e, f, g, h, i, j, k, l) { a, b, c, {l}, d, e, f, g, h, (EngineClass)h, i, j, k, 0, 0, 0, 0, 76, 0 }
#define M RAILVEH_MULTIHEAD
#define W RAILVEH_WAGON
#define G RAILVEH_SINGLEHEAD
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index f8c233184..897fee58d 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2454,9 +2454,9 @@ const Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID pa
scheme = LS_PASSENGER_WAGON_STEAM;
} else {
switch (RailVehInfo(parent_engine_type)->engclass) {
- case 0: scheme = LS_PASSENGER_WAGON_STEAM; break;
- case 1: scheme = LS_PASSENGER_WAGON_DIESEL; break;
- case 2: scheme = LS_PASSENGER_WAGON_ELECTRIC; break;
+ case EC_STEAM: scheme = LS_PASSENGER_WAGON_STEAM; break;
+ case EC_DIESEL: scheme = LS_PASSENGER_WAGON_DIESEL; break;
+ case EC_ELECTRIC: scheme = LS_PASSENGER_WAGON_ELECTRIC; break;
}
}
} else {
@@ -2466,9 +2466,9 @@ const Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID pa
bool is_mu = HASBIT(_engine_info[engine_type].misc_flags, EF_RAIL_IS_MU);
switch (rvi->engclass) {
- case 0: scheme = LS_STEAM; break;
- case 1: scheme = is_mu ? LS_DMU : LS_DIESEL; break;
- case 2: scheme = is_mu ? LS_EMU : LS_ELECTRIC; break;
+ case EC_STEAM: scheme = LS_STEAM; break;
+ case EC_DIESEL: scheme = is_mu ? LS_DMU : LS_DIESEL; break;
+ case EC_ELECTRIC: scheme = is_mu ? LS_EMU : LS_ELECTRIC; break;
}
}
break;