mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/Framework/Scenes/SceneObjectPart.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
This commit is contained in:
@@ -113,6 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
|
||||
new Dictionary<UUID, UserInfoCacheEntry>();
|
||||
protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp.
|
||||
protected ISoundModule m_SoundModule = null;
|
||||
|
||||
// protected Timer m_ShoutSayTimer;
|
||||
protected int m_SayShoutCount = 0;
|
||||
@@ -160,6 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_TransferModule =
|
||||
m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
|
||||
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
|
||||
m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>();
|
||||
|
||||
AsyncCommands = new AsyncCommandManager(ScriptEngine);
|
||||
}
|
||||
@@ -427,6 +429,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the UUID of the asset matching the specified key or name
|
||||
/// and asset type.
|
||||
/// </summary>
|
||||
/// <param name="k"></param>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
protected UUID KeyOrName(string k, AssetType type)
|
||||
{
|
||||
UUID key;
|
||||
|
||||
if (!UUID.TryParse(k, out key))
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k);
|
||||
if (item != null && item.Type == (int)type)
|
||||
key = item.AssetID;
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (m_host.TaskInventory)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, TaskInventoryItem> item in m_host.TaskInventory)
|
||||
{
|
||||
if (item.Value.Type == (int)type && item.Value.Name == k)
|
||||
{
|
||||
key = item.Value.ItemID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
//These are the implementations of the various ll-functions used by the LSL scripts.
|
||||
public LSL_Float llSin(double f)
|
||||
{
|
||||
@@ -2279,8 +2317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
public LSL_Vector llGetPos()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
Vector3 pos = m_host.GetWorldPosition();
|
||||
return new LSL_Vector(pos.X, pos.Y, pos.Z);
|
||||
return m_host.GetWorldPosition();
|
||||
}
|
||||
|
||||
public LSL_Vector llGetLocalPos()
|
||||
@@ -2638,63 +2675,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
// send the sound, once, to all clients in range
|
||||
m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false);
|
||||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.SendSound(m_host.UUID,
|
||||
KeyOrName(sound, AssetType.Sound), volume, false, 0,
|
||||
0, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Xantor 20080528 we should do this differently.
|
||||
// 1) apply the sound to the object
|
||||
// 2) schedule full update
|
||||
// just sending the sound out once doesn't work so well when other avatars come in view later on
|
||||
// or when the prim gets moved, changed, sat on, whatever
|
||||
// see large number of mantises (mantes?)
|
||||
// 20080530 Updated to remove code duplication
|
||||
// 20080530 Stop sound if there is one, otherwise volume only changes don't work
|
||||
public void llLoopSound(string sound, double volume)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
if (m_host.Sound != UUID.Zero)
|
||||
llStopSound();
|
||||
|
||||
m_host.Sound = KeyOrName(sound);
|
||||
m_host.SoundGain = volume;
|
||||
m_host.SoundFlags = 1; // looping
|
||||
m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable?
|
||||
|
||||
m_host.ScheduleFullUpdate();
|
||||
m_host.SendFullUpdateToAllClients();
|
||||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound),
|
||||
volume, 20, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void llLoopSoundMaster(string sound, double volume)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
m_host.ParentGroup.LoopSoundMasterPrim = m_host;
|
||||
lock (m_host.ParentGroup.LoopSoundSlavePrims)
|
||||
if (m_SoundModule != null)
|
||||
{
|
||||
foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims)
|
||||
{
|
||||
if (prim.Sound != UUID.Zero)
|
||||
llStopSound();
|
||||
|
||||
prim.Sound = KeyOrName(sound);
|
||||
prim.SoundGain = volume;
|
||||
prim.SoundFlags = 1; // looping
|
||||
prim.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable?
|
||||
|
||||
prim.ScheduleFullUpdate();
|
||||
prim.SendFullUpdateToAllClients();
|
||||
}
|
||||
m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound),
|
||||
volume, 20, true);
|
||||
}
|
||||
if (m_host.Sound != UUID.Zero)
|
||||
llStopSound();
|
||||
|
||||
m_host.Sound = KeyOrName(sound);
|
||||
m_host.SoundGain = volume;
|
||||
m_host.SoundFlags = 1; // looping
|
||||
m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable?
|
||||
|
||||
m_host.ScheduleFullUpdate();
|
||||
m_host.SendFullUpdateToAllClients();
|
||||
}
|
||||
|
||||
public void llLoopSoundSlave(string sound, double volume)
|
||||
@@ -2711,61 +2717,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_host.AddScriptLPS(1);
|
||||
|
||||
// send the sound, once, to all clients in range
|
||||
m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, true, false);
|
||||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.SendSound(m_host.UUID,
|
||||
KeyOrName(sound, AssetType.Sound), volume, false, 0,
|
||||
0, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void llTriggerSound(string sound, double volume)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
// send the sound, once, to all clients in range
|
||||
m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, 0, false, false);
|
||||
// send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory.
|
||||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.SendSound(m_host.UUID,
|
||||
KeyOrName(sound, AssetType.Sound), volume, true, 0, 0,
|
||||
false, false);
|
||||
}
|
||||
}
|
||||
|
||||
// Xantor 20080528: Clear prim data of sound instead
|
||||
public void llStopSound()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host))
|
||||
{
|
||||
if (m_host.ParentGroup.LoopSoundMasterPrim == m_host)
|
||||
{
|
||||
foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims)
|
||||
{
|
||||
part.Sound = UUID.Zero;
|
||||
part.SoundGain = 0;
|
||||
part.SoundFlags = 0;
|
||||
part.SoundRadius = 0;
|
||||
part.ScheduleFullUpdate();
|
||||
part.SendFullUpdateToAllClients();
|
||||
}
|
||||
m_host.ParentGroup.LoopSoundMasterPrim = null;
|
||||
m_host.ParentGroup.LoopSoundSlavePrims.Clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_host.Sound = UUID.Zero;
|
||||
m_host.SoundGain = 0;
|
||||
m_host.SoundFlags = 0;
|
||||
m_host.SoundRadius = 0;
|
||||
m_host.ScheduleFullUpdate();
|
||||
m_host.SendFullUpdateToAllClients();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_host.Sound = UUID.Zero;
|
||||
m_host.SoundGain = 0;
|
||||
m_host.SoundFlags = 0;
|
||||
m_host.SoundRadius = 0;
|
||||
m_host.ScheduleFullUpdate();
|
||||
m_host.SendFullUpdateToAllClients();
|
||||
}
|
||||
|
||||
if (m_SoundModule != null)
|
||||
m_SoundModule.StopSound(m_host.UUID);
|
||||
}
|
||||
|
||||
public void llPreloadSound(string sound)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
m_host.PreloadSound(sound);
|
||||
if (m_SoundModule != null)
|
||||
m_SoundModule.PreloadSound(m_host.UUID, KeyOrName(sound), 0);
|
||||
ScriptSleep(1000);
|
||||
}
|
||||
|
||||
@@ -4747,16 +4731,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return;
|
||||
}
|
||||
// TODO: Parameter check logic required.
|
||||
UUID soundId = UUID.Zero;
|
||||
if (!UUID.TryParse(impact_sound, out soundId))
|
||||
{
|
||||
TaskInventoryItem item = m_host.Inventory.GetInventoryItem(impact_sound);
|
||||
|
||||
if (item != null && item.Type == (int)AssetType.Sound)
|
||||
soundId = item.AssetID;
|
||||
}
|
||||
|
||||
m_host.CollisionSound = soundId;
|
||||
m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound);
|
||||
m_host.CollisionSoundVolume = (float)impact_volume;
|
||||
m_host.CollisionSoundType = 1;
|
||||
}
|
||||
@@ -6318,10 +6293,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
LSL_Vector bottom_south_west)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
float radius1 = (float)llVecDist(llGetPos(), top_north_east);
|
||||
float radius2 = (float)llVecDist(llGetPos(), bottom_south_west);
|
||||
float radius = Math.Abs(radius1 - radius2);
|
||||
m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, radius, false, false);
|
||||
if (m_SoundModule != null)
|
||||
{
|
||||
m_SoundModule.TriggerSoundLimited(m_host.UUID,
|
||||
KeyOrName(sound, AssetType.Sound), volume,
|
||||
bottom_south_west, top_north_east);
|
||||
}
|
||||
}
|
||||
|
||||
public void llEjectFromLand(string pest)
|
||||
|
||||
Reference in New Issue
Block a user