(svn r9795) -Codechange: enumify the EngineClass.

This commit is contained in:
rubidium 2007-05-06 15:01:44 +00:00
parent abbaa1691e
commit 5c0a52149d
4 changed files with 21 additions and 15 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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;