diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/engine.cpp | 19 | ||||
-rw-r--r-- | src/engine_type.h | 2 | ||||
-rw-r--r-- | src/newgrf.cpp | 24 | ||||
-rw-r--r-- | src/table/engines.h | 10 |
4 files changed, 25 insertions, 30 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index d2a0f2bb6..71e09773b 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -184,6 +184,13 @@ void LoadCustomEngineNames() DEBUG(misc, 1, "LoadCustomEngineNames: not done"); } +/* Determine if an engine type is a wagon (and not a loco) */ +static bool IsWagon(EngineID index) +{ + const Engine *e = GetEngine(index); + return e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON; +} + static void CalcEngineReliability(Engine *e) { uint age = e->age; @@ -256,10 +263,9 @@ void StartupEngines() e->duration_phase_2 = GB(r, 5, 4) + ei->base_life * 12 - 96; e->duration_phase_3 = GB(r, 9, 7) + 120; - e->reliability_spd_dec = (ei->unk2&0x7F) << 2; + e->reliability_spd_dec = ei->decay_speed << 2; - /* my invented flag for something that is a wagon */ - if (ei->unk2 & 0x80) { + if (IsWagon(e->index)) { e->age = 0xFFFF; } else { CalcEngineReliability(e); @@ -377,13 +383,6 @@ CommandCost CmdWantEnginePreview(TileIndex tile, uint32 flags, uint32 p1, uint32 return CommandCost(); } -/* Determine if an engine type is a wagon (and not a loco) */ -static bool IsWagon(EngineID index) -{ - const Engine *e = GetEngine(index); - return e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON; -} - StringID GetEngineCategoryName(EngineID engine); static void NewVehicleAvailable(Engine *e) diff --git a/src/engine_type.h b/src/engine_type.h index 66a495607..db923d8b9 100644 --- a/src/engine_type.h +++ b/src/engine_type.h @@ -109,7 +109,7 @@ struct EngineInfo { Date base_intro; Year lifelength; Year base_life; - byte unk2; ///< flag for carriage(bit 7) and decay speed(bits0..6) + byte decay_speed; byte load_amount; byte climates; uint32 refit_mask; diff --git a/src/newgrf.cpp b/src/newgrf.cpp index 110182169..aa7496b92 100644 --- a/src/newgrf.cpp +++ b/src/newgrf.cpp @@ -417,18 +417,6 @@ static void MapSpriteMappingRecolour(PalSpriteID *grf_sprite) typedef bool (*VCI_Handler)(uint engine, int numinfo, int prop, byte **buf, int len); -static void dewagonize(int condition, Engine *e) -{ - if (condition != 0) { - e->info.unk2 &= ~0x80; - if (e->u.rail.railveh_type == RAILVEH_WAGON) - e->u.rail.railveh_type = RAILVEH_SINGLEHEAD; - } else { - e->info.unk2 |= 0x80; - e->u.rail.railveh_type = RAILVEH_WAGON; - } -} - static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **bufp, int len) { byte *buf = *bufp; @@ -468,7 +456,15 @@ static bool RailVehicleChangeInfo(uint engine, int numinfo, int prop, byte **buf case 0x0B: // Power rvi->power = grf_load_word(&buf); - dewagonize(rvi->power, e); + + /* Set engine / wagon state based on power */ + if (rvi->power != 0) { + if (rvi->railveh_type == RAILVEH_WAGON) { + rvi->railveh_type = RAILVEH_SINGLEHEAD; + } + } else { + rvi->railveh_type = RAILVEH_WAGON; + } break; case 0x0D: // Running cost factor @@ -2300,7 +2296,7 @@ static void FeatureChangeInfo(byte *buf, size_t len) break; case 0x02: // Decay speed - SB(ei->unk2, 0, 7, grf_load_byte(&buf) & 0x7F); + ei->decay_speed = grf_load_byte(&buf); break; case 0x03: // Vehicle life diff --git a/src/table/engines.h b/src/table/engines.h index 3ca03afba..3e8bc3057 100644 --- a/src/table/engines.h +++ b/src/table/engines.h @@ -18,7 +18,7 @@ enum { /** Writes the properties of a train or road vehicle into the EngineInfo struct. * @see EngineInfo * @param a Introduction date - * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6) + * @param b decay speed * @param c life length * @param d base life * @param e Bitmask of the climates @@ -29,18 +29,18 @@ enum { /** Writes the properties of a train carriage into the EngineInfo struct. * @param a Introduction date - * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6) + * @param b decay speed * @param c life length * @param d base life * @param e Bitmask of the climates * @see MK * @note the 5 between d and e is the load amount */ -#define MW(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b | 0x80, 5, e, 0, 8, 0, 0, 0, STR_EMPTY } +#define MW(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, e, 0, 8, 0, 0, 0, STR_EMPTY } /** Writes the properties of a ship into the EngineInfo struct. * @param a Introduction date - * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6) + * @param b decay speed * @param c life length * @param d base life * @param e Bitmask of the climates @@ -51,7 +51,7 @@ enum { /** Writes the properties of an aeroplane into the EngineInfo struct. * @param a Introduction date - * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6) + * @param b decay speed * @param c life length * @param d base life * @param e Bitmask of the climates |