@@ -686,6 +686,14 @@ public virtual void LoadFromWagFile(string wagFilePath)
686
686
var ( brakeMode , maxMass ) = BrakeSystems ? . Count > 0 ? BrakeSystems . Keys . FirstOrDefault ( ) : default ;
687
687
SetBrakeSystemMode ( brakeMode , maxMass , forceSwitch : true ) ;
688
688
689
+ LoadFullMassKg = LoadEmptyMassKg = MassKG ;
690
+ LoadFullORTSDavis_A = LoadEmptyORTSDavis_A = DavisAN ;
691
+ LoadFullORTSDavis_B = LoadEmptyORTSDavis_B = DavisBNSpM ;
692
+ LoadFullORTSDavis_C = LoadEmptyORTSDavis_C = DavisCNSSpMM ;
693
+ LoadFullDavisDragConstant = LoadEmptyDavisDragConstant = DavisDragConstant ;
694
+ LoadFullWagonFrontalAreaM2 = LoadEmptyWagonFrontalAreaM2 = WagonFrontalAreaM2 ;
695
+ LoadFullCentreOfGravityM_Y = LoadEmptyCentreOfGravityM_Y = CentreOfGravityM . Y ;
696
+
689
697
if ( FreightAnimations != null )
690
698
{
691
699
foreach ( var ortsFreightAnim in FreightAnimations . Animations )
@@ -698,270 +706,52 @@ public virtual void LoadFromWagFile(string wagFilePath)
698
706
699
707
}
700
708
709
+ void setIfNonZero ( ref float result , float ? value ) { if ( value > 0 ) result = ( float ) value ; }
710
+
701
711
// Read freight animation values from animation INCLUDE files
702
712
// Read (initialise) "common" (empty values first).
703
713
// Test each value to make sure that it has been defined in the WAG file, if not default to Root WAG file value
704
- if ( FreightAnimations . WagonEmptyWeight > 0 )
705
- {
706
- LoadEmptyMassKg = FreightAnimations . WagonEmptyWeight ;
707
- }
708
- else
709
- {
710
- LoadEmptyMassKg = MassKG ;
711
- }
712
-
713
- if ( FreightAnimations . EmptyORTSDavis_A > 0 )
714
- {
715
- LoadEmptyORTSDavis_A = FreightAnimations . EmptyORTSDavis_A ;
716
- }
717
- else
718
- {
719
- LoadEmptyORTSDavis_A = DavisAN ;
720
- }
721
-
722
- if ( FreightAnimations . EmptyORTSDavis_B > 0 )
723
- {
724
- LoadEmptyORTSDavis_B = FreightAnimations . EmptyORTSDavis_B ;
725
- }
726
- else
727
- {
728
- LoadEmptyORTSDavis_B = DavisBNSpM ;
729
- }
730
-
731
- if ( FreightAnimations . EmptyORTSDavis_C > 0 )
732
- {
733
- LoadEmptyORTSDavis_C = FreightAnimations . EmptyORTSDavis_C ;
734
- }
735
- else
736
- {
737
- LoadEmptyORTSDavis_C = DavisCNSSpMM ;
738
- }
739
-
740
- if ( FreightAnimations . EmptyORTSDavisDragConstant > 0 )
741
- {
742
- LoadEmptyDavisDragConstant = FreightAnimations . EmptyORTSDavisDragConstant ;
743
- }
744
- else
745
- {
746
- LoadEmptyDavisDragConstant = DavisDragConstant ;
747
- }
748
-
749
- if ( FreightAnimations . EmptyORTSWagonFrontalAreaM2 > 0 )
750
- {
751
- LoadEmptyWagonFrontalAreaM2 = FreightAnimations . EmptyORTSWagonFrontalAreaM2 ;
752
- }
753
- else
754
- {
755
- LoadEmptyWagonFrontalAreaM2 = WagonFrontalAreaM2 ;
756
- }
757
-
758
- if ( FreightAnimations . EmptyMaxBrakeShoeForceN > 0 )
759
- {
760
- LoadEmptyMaxBrakeForceN = FreightAnimations . EmptyMaxBrakeShoeForceN ;
761
- }
762
- else if ( FreightAnimations . EmptyMaxBrakeForceN > 0 )
763
- {
764
- LoadEmptyMaxBrakeForceN = FreightAnimations . EmptyMaxBrakeForceN ;
765
- }
766
-
767
- if ( FreightAnimations . EmptyMaxHandbrakeForceN > 0 )
768
- {
769
- LoadEmptyMaxHandbrakeForceN = FreightAnimations . EmptyMaxHandbrakeForceN ;
770
- }
771
-
772
- if ( FreightAnimations . EmptyCentreOfGravityM_Y > 0 )
773
- {
774
- LoadEmptyCentreOfGravityM_Y = FreightAnimations . EmptyCentreOfGravityM_Y ;
775
- }
776
- else
777
- {
778
- LoadEmptyCentreOfGravityM_Y = CentreOfGravityM . Y ;
779
- }
780
-
781
- if ( FreightAnimations . EmptyRelayValveRatio > 0 )
782
- {
783
- LoadEmptyRelayValveRatio = FreightAnimations . EmptyRelayValveRatio ;
784
- }
785
-
786
- if ( FreightAnimations . EmptyInshotPSI != 0 )
787
- {
788
- LoadEmptyInshotPSI = FreightAnimations . EmptyInshotPSI ;
789
- }
714
+ setIfNonZero ( ref LoadEmptyMassKg , FreightAnimations . WagonEmptyWeight ) ;
715
+ setIfNonZero ( ref LoadEmptyORTSDavis_A , FreightAnimations . EmptyORTSDavis_A ) ;
716
+ setIfNonZero ( ref LoadEmptyORTSDavis_B , FreightAnimations . EmptyORTSDavis_B ) ;
717
+ setIfNonZero ( ref LoadEmptyORTSDavis_C , FreightAnimations . EmptyORTSDavis_C ) ;
718
+ setIfNonZero ( ref LoadEmptyDavisDragConstant , FreightAnimations . EmptyORTSDavisDragConstant ) ;
719
+ setIfNonZero ( ref LoadEmptyWagonFrontalAreaM2 , FreightAnimations . EmptyORTSWagonFrontalAreaM2 ) ;
720
+ setIfNonZero ( ref LoadEmptyMaxBrakeForceN , FreightAnimations . EmptyMaxBrakeShoeForceN ) ;
721
+ setIfNonZero ( ref LoadEmptyMaxBrakeForceN , FreightAnimations . EmptyMaxBrakeForceN ) ;
722
+ setIfNonZero ( ref LoadEmptyMaxHandbrakeForceN , FreightAnimations . EmptyMaxHandbrakeForceN ) ;
723
+ setIfNonZero ( ref LoadEmptyCentreOfGravityM_Y , FreightAnimations . EmptyCentreOfGravityM_Y ) ;
724
+ setIfNonZero ( ref LoadEmptyRelayValveRatio , FreightAnimations . EmptyRelayValveRatio ) ;
725
+ setIfNonZero ( ref LoadEmptyInshotPSI , FreightAnimations . EmptyInshotPSI ) ;
790
726
791
727
// Read (initialise) Static load ones if a static load
792
728
// Test each value to make sure that it has been defined in the WAG file, if not default to Root WAG file value
793
- if ( FreightAnimations . FullPhysicsStaticOne != null )
794
- {
795
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticORTSDavis_A > 0 )
796
- {
797
- LoadFullORTSDavis_A = FreightAnimations . FullPhysicsStaticOne . FullStaticORTSDavis_A ;
798
- }
799
- else
800
- {
801
- LoadFullORTSDavis_A = DavisAN ;
802
- }
803
-
804
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticORTSDavis_B > 0 )
805
- {
806
- LoadFullORTSDavis_B = FreightAnimations . FullPhysicsStaticOne . FullStaticORTSDavis_B ;
807
- }
808
- else
809
- {
810
- LoadFullORTSDavis_B = DavisBNSpM ;
811
- }
812
-
813
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticORTSDavis_C > 0 )
814
- {
815
- LoadFullORTSDavis_C = FreightAnimations . FullPhysicsStaticOne . FullStaticORTSDavis_C ;
816
- }
817
- else
818
- {
819
- LoadFullORTSDavis_C = DavisCNSSpMM ;
820
- }
821
-
822
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticORTSDavisDragConstant > 0 )
823
- {
824
- LoadFullDavisDragConstant = FreightAnimations . FullPhysicsStaticOne . FullStaticORTSDavisDragConstant ;
825
- }
826
- else
827
- {
828
- LoadFullDavisDragConstant = DavisDragConstant ;
829
- }
830
-
831
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticORTSWagonFrontalAreaM2 > 0 )
832
- {
833
- LoadFullWagonFrontalAreaM2 = FreightAnimations . FullPhysicsStaticOne . FullStaticORTSWagonFrontalAreaM2 ;
834
- }
835
- else
836
- {
837
- LoadFullWagonFrontalAreaM2 = WagonFrontalAreaM2 ;
838
- }
839
-
840
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticMaxBrakeShoeForceN > 0 )
841
- {
842
- LoadFullMaxBrakeForceN = FreightAnimations . FullPhysicsStaticOne . FullStaticMaxBrakeShoeForceN ;
843
- }
844
- else if ( FreightAnimations . FullPhysicsStaticOne . FullStaticMaxBrakeForceN > 0 )
845
- {
846
- LoadFullMaxBrakeForceN = FreightAnimations . FullPhysicsStaticOne . FullStaticMaxBrakeForceN ;
847
- }
848
-
849
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticMaxHandbrakeForceN > 0 )
850
- {
851
- LoadFullMaxHandbrakeForceN = FreightAnimations . FullPhysicsStaticOne . FullStaticMaxHandbrakeForceN ;
852
- }
853
-
854
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticCentreOfGravityM_Y > 0 )
855
- {
856
- LoadFullCentreOfGravityM_Y = FreightAnimations . FullPhysicsStaticOne . FullStaticCentreOfGravityM_Y ;
857
- }
858
- else
859
- {
860
- LoadFullCentreOfGravityM_Y = CentreOfGravityM . Y ;
861
- }
862
-
863
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticRelayValveRatio > 0 )
864
- {
865
- LoadFullRelayValveRatio = FreightAnimations . FullPhysicsStaticOne . FullStaticRelayValveRatio ;
866
- }
867
-
868
- if ( FreightAnimations . FullPhysicsStaticOne . FullStaticInshotPSI > 0 )
869
- {
870
- LoadFullInshotPSI = FreightAnimations . FullPhysicsStaticOne . FullStaticInshotPSI ;
871
- }
872
- }
729
+ setIfNonZero ( ref LoadFullORTSDavis_A , FreightAnimations . FullPhysicsStaticOne ? . FullStaticORTSDavis_A ) ;
730
+ setIfNonZero ( ref LoadFullORTSDavis_B , FreightAnimations . FullPhysicsStaticOne ? . FullStaticORTSDavis_B ) ;
731
+ setIfNonZero ( ref LoadFullORTSDavis_C , FreightAnimations . FullPhysicsStaticOne ? . FullStaticORTSDavis_C ) ;
732
+ setIfNonZero ( ref LoadFullDavisDragConstant , FreightAnimations . FullPhysicsStaticOne ? . FullStaticORTSDavisDragConstant ) ;
733
+ setIfNonZero ( ref LoadFullWagonFrontalAreaM2 , FreightAnimations . FullPhysicsStaticOne ? . FullStaticORTSWagonFrontalAreaM2 ) ;
734
+ setIfNonZero ( ref LoadFullMaxBrakeForceN , FreightAnimations . FullPhysicsStaticOne ? . FullStaticMaxBrakeShoeForceN ) ;
735
+ setIfNonZero ( ref LoadFullMaxBrakeForceN , FreightAnimations . FullPhysicsStaticOne ? . FullStaticMaxBrakeForceN ) ;
736
+ setIfNonZero ( ref LoadFullMaxHandbrakeForceN , FreightAnimations . FullPhysicsStaticOne ? . FullStaticMaxHandbrakeForceN ) ;
737
+ setIfNonZero ( ref LoadFullCentreOfGravityM_Y , FreightAnimations . FullPhysicsStaticOne ? . FullStaticCentreOfGravityM_Y ) ;
738
+ setIfNonZero ( ref LoadFullRelayValveRatio , FreightAnimations . FullPhysicsStaticOne ? . FullStaticRelayValveRatio ) ;
739
+ setIfNonZero ( ref LoadFullInshotPSI , FreightAnimations . FullPhysicsStaticOne ? . FullStaticInshotPSI ) ;
873
740
874
741
// Read (initialise) Continuous load ones if a continuous load
875
742
// Test each value to make sure that it has been defined in the WAG file, if not default to Root WAG file value
876
- if ( FreightAnimations . FullPhysicsContinuousOne != null )
877
- {
878
- if ( FreightAnimations . FullPhysicsContinuousOne . FreightWeightWhenFull > 0 )
879
- {
880
- LoadFullMassKg = FreightAnimations . WagonEmptyWeight + FreightAnimations . FullPhysicsContinuousOne . FreightWeightWhenFull ;
881
- }
882
- else
883
- {
884
- LoadFullMassKg = MassKG ;
885
- }
886
-
887
- if ( FreightAnimations . FullPhysicsContinuousOne . FullORTSDavis_A > 0 )
888
- {
889
- LoadFullORTSDavis_A = FreightAnimations . FullPhysicsContinuousOne . FullORTSDavis_A ;
890
- }
891
- else
892
- {
893
- LoadFullORTSDavis_A = DavisAN ;
894
- }
895
-
896
- if ( FreightAnimations . FullPhysicsContinuousOne . FullORTSDavis_B > 0 )
897
- {
898
- LoadFullORTSDavis_B = FreightAnimations . FullPhysicsContinuousOne . FullORTSDavis_B ;
899
- }
900
- else
901
- {
902
- LoadFullORTSDavis_B = DavisBNSpM ;
903
- }
904
-
905
- if ( FreightAnimations . FullPhysicsContinuousOne . FullORTSDavis_C > 0 )
906
- {
907
- LoadFullORTSDavis_C = FreightAnimations . FullPhysicsContinuousOne . FullORTSDavis_C ;
908
- }
909
- else
910
- {
911
- LoadFullORTSDavis_C = DavisCNSSpMM ;
912
- }
913
-
914
- if ( FreightAnimations . FullPhysicsContinuousOne . FullORTSDavisDragConstant > 0 )
915
- {
916
- LoadFullDavisDragConstant = FreightAnimations . FullPhysicsContinuousOne . FullORTSDavisDragConstant ;
917
- }
918
- else
919
- {
920
- LoadFullDavisDragConstant = DavisDragConstant ;
921
- }
922
-
923
- if ( FreightAnimations . FullPhysicsContinuousOne . FullORTSWagonFrontalAreaM2 > 0 )
924
- {
925
- LoadFullWagonFrontalAreaM2 = FreightAnimations . FullPhysicsContinuousOne . FullORTSWagonFrontalAreaM2 ;
926
- }
927
- else
928
- {
929
- LoadFullWagonFrontalAreaM2 = WagonFrontalAreaM2 ;
930
- }
931
-
932
- if ( FreightAnimations . FullPhysicsContinuousOne . FullMaxBrakeShoeForceN > 0 )
933
- {
934
- LoadFullMaxBrakeForceN = FreightAnimations . FullPhysicsContinuousOne . FullMaxBrakeShoeForceN ;
935
- }
936
- else if ( FreightAnimations . FullPhysicsContinuousOne . FullMaxBrakeForceN > 0 )
937
- {
938
- LoadFullMaxBrakeForceN = FreightAnimations . FullPhysicsContinuousOne . FullMaxBrakeForceN ;
939
- }
940
-
941
- if ( FreightAnimations . FullPhysicsContinuousOne . FullMaxHandbrakeForceN > 0 )
942
- {
943
- LoadFullMaxHandbrakeForceN = FreightAnimations . FullPhysicsContinuousOne . FullMaxHandbrakeForceN ;
944
- }
945
-
946
- if ( FreightAnimations . FullPhysicsContinuousOne . FullCentreOfGravityM_Y > 0 )
947
- {
948
- LoadFullCentreOfGravityM_Y = FreightAnimations . FullPhysicsContinuousOne . FullCentreOfGravityM_Y ;
949
- }
950
- else
951
- {
952
- LoadFullCentreOfGravityM_Y = CentreOfGravityM . Y ;
953
- }
954
-
955
- if ( FreightAnimations . FullPhysicsContinuousOne . FullRelayValveRatio > 0 )
956
- {
957
- LoadFullRelayValveRatio = FreightAnimations . FullPhysicsContinuousOne . FullRelayValveRatio ;
958
- }
959
-
960
- if ( FreightAnimations . FullPhysicsContinuousOne . FullInshotPSI != 0 )
961
- {
962
- LoadFullInshotPSI = FreightAnimations . FullPhysicsContinuousOne . FullInshotPSI ;
963
- }
964
- }
743
+ setIfNonZero ( ref LoadFullMassKg , FreightAnimations . WagonEmptyWeight + FreightAnimations . FullPhysicsContinuousOne ? . FreightWeightWhenFull ) ;
744
+ setIfNonZero ( ref LoadFullORTSDavis_A , FreightAnimations . FullPhysicsContinuousOne ? . FullORTSDavis_A ) ;
745
+ setIfNonZero ( ref LoadFullORTSDavis_B , FreightAnimations . FullPhysicsContinuousOne ? . FullORTSDavis_B ) ;
746
+ setIfNonZero ( ref LoadFullORTSDavis_C , FreightAnimations . FullPhysicsContinuousOne ? . FullORTSDavis_C ) ;
747
+ setIfNonZero ( ref LoadFullDavisDragConstant , FreightAnimations . FullPhysicsContinuousOne ? . FullORTSDavisDragConstant ) ;
748
+ setIfNonZero ( ref LoadFullWagonFrontalAreaM2 , FreightAnimations . FullPhysicsContinuousOne ? . FullORTSWagonFrontalAreaM2 ) ;
749
+ setIfNonZero ( ref LoadFullMaxBrakeForceN , FreightAnimations . FullPhysicsContinuousOne ? . FullMaxBrakeShoeForceN ) ;
750
+ setIfNonZero ( ref LoadFullMaxBrakeForceN , FreightAnimations . FullPhysicsContinuousOne ? . FullMaxBrakeForceN ) ;
751
+ setIfNonZero ( ref LoadFullMaxHandbrakeForceN , FreightAnimations . FullPhysicsContinuousOne ? . FullMaxHandbrakeForceN ) ;
752
+ setIfNonZero ( ref LoadFullCentreOfGravityM_Y , FreightAnimations . FullPhysicsContinuousOne ? . FullCentreOfGravityM_Y ) ;
753
+ setIfNonZero ( ref LoadFullRelayValveRatio , FreightAnimations . FullPhysicsContinuousOne ? . FullRelayValveRatio ) ;
754
+ setIfNonZero ( ref LoadFullInshotPSI , FreightAnimations . FullPhysicsContinuousOne ? . FullInshotPSI ) ;
965
755
966
756
if ( ! FreightAnimations . MSTSFreightAnimEnabled ) FreightShapeFileName = null ;
967
757
if ( FreightAnimations . WagonEmptyWeight != - 1 )
@@ -996,6 +786,8 @@ public virtual void LoadFromWagFile(string wagFilePath)
996
786
TempMassDiffRatio = 0 ;
997
787
}
998
788
789
+ UpdateDavisLoadCompensation ( TempMassDiffRatio ) ;
790
+
999
791
#if DEBUG_VARIABLE_MASS
1000
792
1001
793
Trace . TraceInformation ( " =============================== Variable Load Initialisation (MSTSWagon.cs) ===============================" ) ;
@@ -1039,8 +831,6 @@ public virtual void LoadFromWagFile(string wagFilePath)
1039
831
1040
832
if ( TrackGaugeM <= 0 ) // Use gauge of route/sim settings if gauge wasn't defined
1041
833
TrackGaugeM = Simulator . RouteTrackGaugeM ;
1042
-
1043
- UpdateDavisLoadCompensation ( TempMassDiffRatio ) ;
1044
834
}
1045
835
1046
836
public void SetBrakeSystemMode ( BrakeModes mode , float massKg , bool forceSwitch = false )
0 commit comments