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