@ -104,6 +104,7 @@ void VehicleServiceInDepot(Vehicle *v)
if ( v - > Next ( ) ! = NULL ) VehicleServiceInDepot ( v - > Next ( ) ) ;
if ( v - > Next ( ) ! = NULL ) VehicleServiceInDepot ( v - > Next ( ) ) ;
if ( ! ( Train : : From ( v ) - > IsEngine ( ) ) & & ! ( Train : : From ( v ) - > IsRearDualheaded ( ) ) ) return ;
if ( ! ( Train : : From ( v ) - > IsEngine ( ) ) & & ! ( Train : : From ( v ) - > IsRearDualheaded ( ) ) ) return ;
ClrBit ( Train : : From ( v ) - > flags , VRF_NEED_REPAIR ) ;
ClrBit ( Train : : From ( v ) - > flags , VRF_NEED_REPAIR ) ;
Train : : From ( v ) - > critical_breakdown_count = 0 ;
const RailVehicleInfo * rvi = & e - > u . rail ;
const RailVehicleInfo * rvi = & e - > u . rail ;
v - > vcache . cached_max_speed = rvi - > max_speed ;
v - > vcache . cached_max_speed = rvi - > max_speed ;
if ( Train : : From ( v ) - > IsFrontEngine ( ) ) {
if ( Train : : From ( v ) - > IsFrontEngine ( ) ) {
@ -1352,17 +1353,12 @@ bool Vehicle::HandleBreakdown()
}
}
/* Max Speed reduction*/
/* Max Speed reduction*/
if ( _settings_game . vehicle . improved_breakdowns ) {
if ( _settings_game . vehicle . improved_breakdowns ) {
const Engine * e = Engine : : Get ( this - > engine_type ) ;
if ( ! HasBit ( Train : : From ( this ) - > flags , VRF_NEED_REPAIR ) ) {
const RailVehicleInfo * rvi = & e - > u . rail ;
if ( ! HasBit ( Train : : From ( this ) - > flags , VRF_NEED_REPAIR ) ) {
if ( rvi - > max_speed > this - > vcache . cached_max_speed ) {
this - > vcache . cached_max_speed = rvi - > max_speed ;
}
}
uint16 target_max_speed = min ( this - > vcache . cached_max_speed -
( this - > vcache . cached_max_speed > > 1 ) / Train : : From ( this - > First ( ) ) - > tcache . cached_num_engines + 1 , this - > vcache . cached_max_speed ) ;
this - > vcache . cached_max_speed = max ( target_max_speed , min < uint16 > ( rvi - > max_speed / 4 , 28 ) ) ;
SetBit ( Train : : From ( this ) - > flags , VRF_NEED_REPAIR ) ;
SetBit ( Train : : From ( this ) - > flags , VRF_NEED_REPAIR ) ;
Train : : From ( this ) - > critical_breakdown_count = 1 ;
} else if ( Train : : From ( this ) - > critical_breakdown_count ! = 255 ) {
Train : : From ( this ) - > critical_breakdown_count + + ;
}
Train : : From ( this - > First ( ) ) - > ConsistChanged ( CCF_TRACK ) ;
Train : : From ( this - > First ( ) ) - > ConsistChanged ( CCF_TRACK ) ;
}
}
/* FALL THROUGH */
/* FALL THROUGH */