@@ -493,7 +493,8 @@ public static WorldLocation UidLocation(UiD uid)
493493 public class SoundSource : SoundSourceBase
494494 {
495495 /// <summary>
496- /// Squeared cutoff distance. No sound is audible above that
496+ /// Squared cutoff distance. No sound is audible above that, except for the actual player train,
497+ /// where cutoff occurs at a distance wich is higher than the train length
497498 /// </summary>
498499 private const int CUTOFFDISTANCE = 4000000 ;
499500 /// <summary>
@@ -1009,13 +1010,15 @@ public bool isOutOfDistance()
10091010 float . IsNaN ( WorldLocation . Location . Y ) ||
10101011 float . IsNaN ( WorldLocation . Location . Z ) )
10111012 {
1012- DistanceSquared = CUTOFFDISTANCE + 1 ;
1013+ DistanceSquared = ( Car != null && Car . Train != null && Car . Train . IsActualPlayerTrain ?
1014+ Math . Max ( CUTOFFDISTANCE , Car . Train . Length * Car . Train . Length ) : CUTOFFDISTANCE ) + 1 ;
10131015 return true ;
10141016 }
10151017
10161018 DistanceSquared = WorldLocation . GetDistanceSquared ( WorldLocation , Viewer . Camera . CameraWorldLocation ) ;
10171019
1018- return DistanceSquared > CUTOFFDISTANCE ;
1020+ return DistanceSquared > ( Car != null && Car . Train != null && Car . Train . IsActualPlayerTrain ?
1021+ Math . Max ( CUTOFFDISTANCE , Car . Train . Length * Car . Train . Length ) + 2500f : CUTOFFDISTANCE ) ;
10191022 }
10201023
10211024 /// <summary>
@@ -1034,7 +1037,8 @@ public bool Activate()
10341037 {
10351038 // (ActivationConditions.Distance == 0) means distance checking disabled
10361039 if ( ( ActivationConditions . Distance == 0 || DistanceSquared < ActivationConditions . Distance * ActivationConditions . Distance ) &&
1037- DistanceSquared < CUTOFFDISTANCE )
1040+ DistanceSquared < ( Car != null && Car . Train != null && Car . Train . IsActualPlayerTrain ?
1041+ Math . Max ( CUTOFFDISTANCE , Car . Train . Length * Car . Train . Length ) + 2500f : CUTOFFDISTANCE ) )
10381042 return true ;
10391043 }
10401044 else
@@ -1059,7 +1063,8 @@ public bool DeActivate()
10591063 if ( WorldLocation != WorldLocation . None )
10601064 {
10611065 if ( DeactivationConditions . Distance != 0 && DistanceSquared > DeactivationConditions . Distance * DeactivationConditions . Distance ||
1062- DistanceSquared > CUTOFFDISTANCE )
1066+ DistanceSquared > ( Car != null && Car . Train != null && Car . Train . IsActualPlayerTrain ?
1067+ Math . Max ( CUTOFFDISTANCE , Car . Train . Length * Car . Train . Length ) + 2500f : CUTOFFDISTANCE ) )
10631068 return true ;
10641069 }
10651070
0 commit comments