Factoring out an if-else block in PlayAttachedSound as it was using the previously hard-coded max distance value.

integration
SignpostMarv 2012-10-05 14:04:28 +01:00 committed by Justin Clark-Casey (justincc)
parent 375fb66589
commit 6bd1f0f209
1 changed files with 6 additions and 6 deletions

View File

@ -112,6 +112,9 @@ namespace OpenSim.Region.CoreModules.World.Sound
SceneObjectGroup grp = part.ParentGroup; SceneObjectGroup grp = part.ParentGroup;
if (radius == 0)
radius = MaxDistance;
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
@ -130,9 +133,6 @@ namespace OpenSim.Region.CoreModules.World.Sound
float thisSpGain; float thisSpGain;
// Scale by distance // Scale by distance
if (radius == 0)
thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0));
else
thisSpGain = (float)((double)gain * ((radius - dis) / radius)); thisSpGain = (float)((double)gain * ((radius - dis) / radius));
sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags); sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags);
@ -160,6 +160,9 @@ namespace OpenSim.Region.CoreModules.World.Sound
} }
} }
if (radius == 0)
radius = MaxDistance;
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
{ {
double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
@ -170,9 +173,6 @@ namespace OpenSim.Region.CoreModules.World.Sound
float thisSpGain; float thisSpGain;
// Scale by distance // Scale by distance
if (radius == 0)
thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0));
else
thisSpGain = (float)((double)gain * ((radius - dis) / radius)); thisSpGain = (float)((double)gain * ((radius - dis) / radius));
sp.ControllingClient.SendTriggeredSound( sp.ControllingClient.SendTriggeredSound(