2828using Orts . Simulation . RollingStocks . SubSystems . Brakes . MSTS ;
2929using Orts . Simulation . RollingStocks . SubSystems . PowerSupplies ;
3030using Orts . Simulation . RollingStocks . SubSystems . PowerTransmissions ;
31+ using Orts . Simulation . Simulation . RollingStocks . SubSystems . PowerSupplies ;
3132using Orts . Viewer3D . Processes ;
3233using ORTS . Common ;
3334using ORTS . Scripting . Api ;
@@ -583,6 +584,11 @@ void TextPageConsistInfo(TableData table)
583584 }
584585 }
585586
587+ /// <summary>
588+ /// Calculates Whyte noatation for the vehicle
589+ /// For duplex steam locomotives wheel axles can be grouped under the main object shape, and hence the multiple engines will be counted as a single grouping.
590+ /// For multiple engines, the number of wheels defined in the attached axles will be used to determine the axles in the "non-bogie" groupings.
591+ /// </summary>
586592 static string GetCarWhyteLikeNotation ( TrainCar car )
587593 {
588594 if ( car . WheelAxles . Count == 0 )
@@ -591,18 +597,85 @@ static string GetCarWhyteLikeNotation(TrainCar car)
591597 var whyte = new List < string > ( ) ;
592598 var currentCount = 0 ;
593599 var currentBogie = car . WheelAxles [ 0 ] . BogieIndex ;
594- foreach ( var axle in car . WheelAxles )
600+ bool PreviousAxlePart = true ; // Assume a bogie
601+
602+ var steamloco = car as MSTSSteamLocomotive ;
603+
604+ if ( car is MSTSSteamLocomotive && steamloco . SteamEngines . Count > 1 )
605+ {
606+ var i = 0 ; // Count for number of steam engines
607+ var axlesCount = 0 ;
608+
609+ foreach ( var axle in car . WheelAxles )
610+ {
611+ if ( ! axle . Part . bogie ) // if not a bogie then check for the number of axles.
612+ {
613+ if ( currentBogie != axle . BogieIndex && currentCount != 0 )
614+ {
615+ whyte . Add ( currentCount . ToString ( ) ) ;
616+ currentBogie = axle . BogieIndex ;
617+ currentCount = 0 ;
618+ }
619+
620+ if ( steamloco . SteamEngines [ i ] . AuxiliarySteamEngineType != SteamEngine . AuxiliarySteamEngineTypes . Booster )
621+ {
622+ currentCount += 2 ;
623+ axlesCount += 1 ;
624+
625+ if ( axlesCount >= steamloco . SteamEngines [ i ] . AttachedAxle . NumberWheelAxles && currentCount != 0 )
626+ {
627+ whyte . Add ( currentCount . ToString ( ) ) ;
628+ currentBogie = axle . BogieIndex ;
629+ currentCount = 0 ;
630+ axlesCount = 0 ;
631+ i = i + 1 ;
632+ }
633+ }
634+ }
635+ else if ( axle . Part . bogie ) // this is a bogie
636+ {
637+ if ( PreviousAxlePart )
638+ {
639+ currentBogie = axle . BogieIndex ;
640+ }
641+
642+ if ( currentBogie != axle . BogieIndex && currentCount != 0 )
643+ {
644+ whyte . Add ( currentCount . ToString ( ) ) ;
645+ currentBogie = axle . BogieIndex ;
646+ currentCount = 0 ;
647+ }
648+ currentCount += 2 ;
649+ }
650+
651+ if ( axle . Part . bogie )
652+ {
653+ PreviousAxlePart = true ;
654+ }
655+ else
656+ {
657+ PreviousAxlePart = false ;
658+ }
659+ }
660+
661+ whyte . Add ( currentCount . ToString ( ) ) ;
662+ return String . Join ( "-" , whyte . ToArray ( ) ) ;
663+ }
664+ else // default axle computation - used for most wheel configurations
595665 {
596- if ( currentBogie != axle . BogieIndex )
666+ foreach ( var axle in car . WheelAxles )
597667 {
598- whyte . Add ( currentCount . ToString ( ) ) ;
599- currentBogie = axle . BogieIndex ;
600- currentCount = 0 ;
668+ if ( currentBogie != axle . BogieIndex && currentCount != 0 )
669+ {
670+ whyte . Add ( currentCount . ToString ( ) ) ;
671+ currentBogie = axle . BogieIndex ;
672+ currentCount = 0 ;
673+ }
674+ currentCount += 2 ;
601675 }
602- currentCount += 2 ;
676+ whyte . Add ( currentCount . ToString ( ) ) ;
677+ return String . Join ( "-" , whyte . ToArray ( ) ) ;
603678 }
604- whyte . Add ( currentCount . ToString ( ) ) ;
605- return String . Join ( "-" , whyte . ToArray ( ) ) ;
606679 }
607680
608681 void TextPageLocomotiveInfo ( TableData table )
0 commit comments