change ossl link sound functions to search for sound both on script host and target prims

0.9.1.0-post-fixes
UbitUmarov 2018-11-14 19:02:00 +00:00
parent afb1d6cdd7
commit fad6295398
2 changed files with 43 additions and 23 deletions

View File

@ -93,15 +93,33 @@ namespace OpenSim.Region.Framework.Scenes.Scripting
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type) public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, string identifier, AssetType type)
{ {
UUID key; UUID key;
if (UUID.TryParse(identifier, out key))
return key;
if (!UUID.TryParse(identifier, out key)) TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
if (item != null && item.Type == (int)type)
return item.AssetID;
return UUID.Zero;
}
public static UUID GetAssetIdFromKeyOrItemName(SceneObjectPart part, SceneObjectPart host, string identifier, AssetType type)
{
UUID key;
if (UUID.TryParse(identifier, out key))
return key;
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier);
if (item != null && item.Type == (int)type)
return item.AssetID;
if (part.LocalId != host.LocalId)
{ {
TaskInventoryItem item = part.Inventory.GetInventoryItem(identifier); item = host.Inventory.GetInventoryItem(identifier);
if (item != null && item.Type == (int)type) if (item != null && item.Type == (int)type)
key = item.AssetID; return item.AssetID;
} }
return UUID.Zero;
return key;
} }
} }
} }

View File

@ -4900,7 +4900,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(sop == null) if(sop == null)
return; return;
sop.AdjustSoundGain(volume); sop.AdjustSoundGain(volume);
ScriptSleep(100);
} }
public void osSetSoundRadius(LSL_Integer linknum, LSL_Float radius) public void osSetSoundRadius(LSL_Integer linknum, LSL_Float radius)
@ -4909,7 +4908,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
SceneObjectPart sop = GetSingleLinkPart(linknum); SceneObjectPart sop = GetSingleLinkPart(linknum);
if(sop == null) if(sop == null)
return; return;
m_host.SoundRadius = radius; sop.SoundRadius = radius;
} }
public void osPlaySound(LSL_Integer linknum, LSL_String sound, LSL_Float volume) public void osPlaySound(LSL_Integer linknum, LSL_String sound, LSL_Float volume)
@ -4923,8 +4922,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(sop == null) if(sop == null)
return; return;
UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound);
if(soundID == UUID.Zero) if (soundID == UUID.Zero)
return; return;
// send the sound, once, to all clients in range // send the sound, once, to all clients in range
@ -4942,8 +4941,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(sop == null) if(sop == null)
return; return;
UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound);
if(soundID == UUID.Zero) if (soundID == UUID.Zero)
return; return;
m_SoundModule.LoopSound(sop.UUID, soundID, volume, false,false); m_SoundModule.LoopSound(sop.UUID, soundID, volume, false,false);
@ -4953,12 +4952,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (m_SoundModule == null)
return;
SceneObjectPart sop = GetSingleLinkPart(linknum); SceneObjectPart sop = GetSingleLinkPart(linknum);
if(sop == null) if(sop == null)
return; return;
UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound);
if(soundID == UUID.Zero) if (soundID == UUID.Zero)
return; return;
m_SoundModule.LoopSound(sop.UUID, soundID, volume, true, false); m_SoundModule.LoopSound(sop.UUID, soundID, volume, true, false);
@ -4975,8 +4977,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(sop == null) if(sop == null)
return; return;
UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound);
if(soundID == UUID.Zero) if (soundID == UUID.Zero)
return; return;
m_SoundModule.LoopSound(sop.UUID, soundID, volume, false, true); m_SoundModule.LoopSound(sop.UUID, soundID, volume, false, true);
@ -4993,8 +4995,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(sop == null) if(sop == null)
return; return;
UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound);
if(soundID == UUID.Zero) if (soundID == UUID.Zero)
return; return;
// send the sound, once, to all clients in range // send the sound, once, to all clients in range
@ -5012,8 +5014,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(sop == null) if(sop == null)
return; return;
UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound);
if(soundID == UUID.Zero) if (soundID == UUID.Zero)
return; return;
// send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory. // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory.
@ -5032,8 +5034,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(sop == null) if(sop == null)
return; return;
UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound);
if(soundID == UUID.Zero) if (soundID == UUID.Zero)
return; return;
m_SoundModule.TriggerSoundLimited(sop.UUID, soundID, volume, m_SoundModule.TriggerSoundLimited(sop.UUID, soundID, volume,
@ -5065,8 +5067,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if(sop == null) if(sop == null)
return; return;
UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, sound, AssetType.Sound); UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(sop, m_host, sound, AssetType.Sound);
if(soundID == UUID.Zero) if (soundID == UUID.Zero)
return; return;
m_SoundModule.PreloadSound(sop.UUID, soundID); m_SoundModule.PreloadSound(sop.UUID, soundID);