@ -108,12 +108,11 @@ void TrainPowerChanged(Vehicle *v)
uint32 max_te = 0 ;
for ( const Vehicle * u = v ; u ! = NULL ; u = u - > Next ( ) ) {
/* Power is not added for articulated parts */
if ( IsArticulatedPart ( u ) ) continue ;
RailType railtype = GetRailType ( u - > tile ) ;
/* Power is not added for articulated parts */
if ( ! IsArticulatedPart ( u ) ) {
bool engine_has_power = HasPowerOnRail ( u - > u . rail . railtype , railtype ) ;
bool wagon_has_power = HasPowerOnRail ( v - > u . rail . railtype , railtype ) ;
const RailVehicleInfo * rvi_u = RailVehInfo ( u - > engine_type ) ;
@ -128,8 +127,9 @@ void TrainPowerChanged(Vehicle *v)
max_te + = ( u - > u . rail . cached_veh_weight * 10000 * GetVehicleProperty ( u , 0x1F , rvi_u - > tractive_effort ) ) / 256 ;
}
}
}
if ( HasBit ( u - > u . rail . flags , VRF_POWEREDWAGON ) & & ( wagon_has_power ) ) {
if ( HasBit ( u - > u . rail . flags , VRF_POWEREDWAGON ) & & HasPowerOnRail ( v - > u . rail . railtype , railtype ) ) {
total_power + = RailVehInfo ( u - > u . rail . first_engine ) - > pow_wag_power ;
}
}
@ -162,9 +162,10 @@ static void TrainCargoChanged(Vehicle *v)
if ( ! IsArticulatedPart ( u ) ) {
/* vehicle weight is the sum of the weight of the vehicle and the weight of its cargo */
vweight + = GetVehicleProperty ( u , 0x16 , RailVehInfo ( u - > engine_type ) - > weight ) ;
}
/* powered wagons have extra weight added */
if ( HasBit ( u - > u . rail . flags , VRF_POWEREDWAGON ) )
if ( HasBit ( u - > u . rail . flags , VRF_POWEREDWAGON ) ) {
vweight + = RailVehInfo ( u - > u . rail . first_engine ) - > pow_wag_weight ;
}
@ -306,7 +307,6 @@ void TrainConsistChanged(Vehicle *v, bool same_length)
}
}
if ( ! IsArticulatedPart ( u ) ) {
/* Check powered wagon / visual effect callback */
if ( HasBit ( EngInfo ( u - > engine_type ) - > callbackmask , CBM_TRAIN_WAGON_POWER ) ) {
uint16 callback = GetVehicleCallback ( CBID_TRAIN_WAGON_POWER , 0 , 0 , u - > engine_type , u ) ;
@ -322,6 +322,7 @@ void TrainConsistChanged(Vehicle *v, bool same_length)
ClrBit ( u - > u . rail . flags , VRF_POWEREDWAGON ) ;
}
if ( ! IsArticulatedPart ( u ) ) {
/* Do not count powered wagons for the compatible railtypes, as wagons always
have railtype normal */
if ( rvi_u - > power > 0 ) {