diff options
author | Melanie | 2012-10-30 01:02:20 +0000 |
---|---|---|
committer | Melanie | 2012-10-30 01:02:20 +0000 |
commit | 48569e856a9c9ced207652b10e2abde94c849687 (patch) | |
tree | 8955c0206f1822f4bbb44466fae74e18923d125c /OpenSim/Region/ScriptEngine/Shared | |
parent | Merge branch 'avination' into careminster (diff) | |
parent | Make MeshAssetReceived private. (diff) | |
download | opensim-SC-48569e856a9c9ced207652b10e2abde94c849687.zip opensim-SC-48569e856a9c9ced207652b10e2abde94c849687.tar.gz opensim-SC-48569e856a9c9ced207652b10e2abde94c849687.tar.bz2 opensim-SC-48569e856a9c9ced207652b10e2abde94c849687.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 179 |
1 files changed, 78 insertions, 101 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9011966..3bbdbe8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -113,6 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
113 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = | 113 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = |
114 | new Dictionary<UUID, UserInfoCacheEntry>(); | 114 | new Dictionary<UUID, UserInfoCacheEntry>(); |
115 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | 115 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. |
116 | protected ISoundModule m_SoundModule = null; | ||
116 | 117 | ||
117 | // protected Timer m_ShoutSayTimer; | 118 | // protected Timer m_ShoutSayTimer; |
118 | protected int m_SayShoutCount = 0; | 119 | protected int m_SayShoutCount = 0; |
@@ -160,6 +161,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
160 | m_TransferModule = | 161 | m_TransferModule = |
161 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); | 162 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); |
162 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 163 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
164 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); | ||
163 | 165 | ||
164 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | 166 | AsyncCommands = new AsyncCommandManager(ScriptEngine); |
165 | } | 167 | } |
@@ -427,6 +429,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
427 | return key; | 429 | return key; |
428 | } | 430 | } |
429 | 431 | ||
432 | /// <summary> | ||
433 | /// Return the UUID of the asset matching the specified key or name | ||
434 | /// and asset type. | ||
435 | /// </summary> | ||
436 | /// <param name="k"></param> | ||
437 | /// <param name="type"></param> | ||
438 | /// <returns></returns> | ||
439 | protected UUID KeyOrName(string k, AssetType type) | ||
440 | { | ||
441 | UUID key; | ||
442 | |||
443 | if (!UUID.TryParse(k, out key)) | ||
444 | { | ||
445 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); | ||
446 | if (item != null && item.Type == (int)type) | ||
447 | key = item.AssetID; | ||
448 | } | ||
449 | else | ||
450 | { | ||
451 | lock (m_host.TaskInventory) | ||
452 | { | ||
453 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in m_host.TaskInventory) | ||
454 | { | ||
455 | if (item.Value.Type == (int)type && item.Value.Name == k) | ||
456 | { | ||
457 | key = item.Value.ItemID; | ||
458 | break; | ||
459 | } | ||
460 | } | ||
461 | } | ||
462 | } | ||
463 | |||
464 | |||
465 | return key; | ||
466 | } | ||
467 | |||
430 | //These are the implementations of the various ll-functions used by the LSL scripts. | 468 | //These are the implementations of the various ll-functions used by the LSL scripts. |
431 | public LSL_Float llSin(double f) | 469 | public LSL_Float llSin(double f) |
432 | { | 470 | { |
@@ -2279,8 +2317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2279 | public LSL_Vector llGetPos() | 2317 | public LSL_Vector llGetPos() |
2280 | { | 2318 | { |
2281 | m_host.AddScriptLPS(1); | 2319 | m_host.AddScriptLPS(1); |
2282 | Vector3 pos = m_host.GetWorldPosition(); | 2320 | return m_host.GetWorldPosition(); |
2283 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | ||
2284 | } | 2321 | } |
2285 | 2322 | ||
2286 | public LSL_Vector llGetLocalPos() | 2323 | public LSL_Vector llGetLocalPos() |
@@ -2638,63 +2675,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2638 | m_host.AddScriptLPS(1); | 2675 | m_host.AddScriptLPS(1); |
2639 | 2676 | ||
2640 | // send the sound, once, to all clients in range | 2677 | // send the sound, once, to all clients in range |
2641 | m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false); | 2678 | if (m_SoundModule != null) |
2679 | { | ||
2680 | m_SoundModule.SendSound(m_host.UUID, | ||
2681 | KeyOrName(sound, AssetType.Sound), volume, false, 0, | ||
2682 | 0, false, false); | ||
2683 | } | ||
2642 | } | 2684 | } |
2643 | 2685 | ||
2644 | // Xantor 20080528 we should do this differently. | ||
2645 | // 1) apply the sound to the object | ||
2646 | // 2) schedule full update | ||
2647 | // just sending the sound out once doesn't work so well when other avatars come in view later on | ||
2648 | // or when the prim gets moved, changed, sat on, whatever | ||
2649 | // see large number of mantises (mantes?) | ||
2650 | // 20080530 Updated to remove code duplication | ||
2651 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work | ||
2652 | public void llLoopSound(string sound, double volume) | 2686 | public void llLoopSound(string sound, double volume) |
2653 | { | 2687 | { |
2654 | m_host.AddScriptLPS(1); | 2688 | m_host.AddScriptLPS(1); |
2655 | 2689 | if (m_SoundModule != null) | |
2656 | if (m_host.Sound != UUID.Zero) | 2690 | { |
2657 | llStopSound(); | 2691 | m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), |
2658 | 2692 | volume, 20, false); | |
2659 | m_host.Sound = KeyOrName(sound); | 2693 | } |
2660 | m_host.SoundGain = volume; | ||
2661 | m_host.SoundFlags = 1; // looping | ||
2662 | m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
2663 | |||
2664 | m_host.ScheduleFullUpdate(); | ||
2665 | m_host.SendFullUpdateToAllClients(); | ||
2666 | } | 2694 | } |
2667 | 2695 | ||
2668 | public void llLoopSoundMaster(string sound, double volume) | 2696 | public void llLoopSoundMaster(string sound, double volume) |
2669 | { | 2697 | { |
2670 | m_host.AddScriptLPS(1); | 2698 | m_host.AddScriptLPS(1); |
2671 | m_host.ParentGroup.LoopSoundMasterPrim = m_host; | 2699 | if (m_SoundModule != null) |
2672 | lock (m_host.ParentGroup.LoopSoundSlavePrims) | ||
2673 | { | 2700 | { |
2674 | foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims) | 2701 | m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), |
2675 | { | 2702 | volume, 20, true); |
2676 | if (prim.Sound != UUID.Zero) | ||
2677 | llStopSound(); | ||
2678 | |||
2679 | prim.Sound = KeyOrName(sound); | ||
2680 | prim.SoundGain = volume; | ||
2681 | prim.SoundFlags = 1; // looping | ||
2682 | prim.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
2683 | |||
2684 | prim.ScheduleFullUpdate(); | ||
2685 | prim.SendFullUpdateToAllClients(); | ||
2686 | } | ||
2687 | } | 2703 | } |
2688 | if (m_host.Sound != UUID.Zero) | ||
2689 | llStopSound(); | ||
2690 | |||
2691 | m_host.Sound = KeyOrName(sound); | ||
2692 | m_host.SoundGain = volume; | ||
2693 | m_host.SoundFlags = 1; // looping | ||
2694 | m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
2695 | |||
2696 | m_host.ScheduleFullUpdate(); | ||
2697 | m_host.SendFullUpdateToAllClients(); | ||
2698 | } | 2704 | } |
2699 | 2705 | ||
2700 | public void llLoopSoundSlave(string sound, double volume) | 2706 | public void llLoopSoundSlave(string sound, double volume) |
@@ -2711,61 +2717,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2711 | m_host.AddScriptLPS(1); | 2717 | m_host.AddScriptLPS(1); |
2712 | 2718 | ||
2713 | // send the sound, once, to all clients in range | 2719 | // send the sound, once, to all clients in range |
2714 | m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, true, false); | 2720 | if (m_SoundModule != null) |
2721 | { | ||
2722 | m_SoundModule.SendSound(m_host.UUID, | ||
2723 | KeyOrName(sound, AssetType.Sound), volume, false, 0, | ||
2724 | 0, true, false); | ||
2725 | } | ||
2715 | } | 2726 | } |
2716 | 2727 | ||
2717 | public void llTriggerSound(string sound, double volume) | 2728 | public void llTriggerSound(string sound, double volume) |
2718 | { | 2729 | { |
2719 | m_host.AddScriptLPS(1); | 2730 | m_host.AddScriptLPS(1); |
2720 | // send the sound, once, to all clients in range | 2731 | // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory. |
2721 | m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, 0, false, false); | 2732 | if (m_SoundModule != null) |
2733 | { | ||
2734 | m_SoundModule.SendSound(m_host.UUID, | ||
2735 | KeyOrName(sound, AssetType.Sound), volume, true, 0, 0, | ||
2736 | false, false); | ||
2737 | } | ||
2722 | } | 2738 | } |
2723 | 2739 | ||
2724 | // Xantor 20080528: Clear prim data of sound instead | ||
2725 | public void llStopSound() | 2740 | public void llStopSound() |
2726 | { | 2741 | { |
2727 | m_host.AddScriptLPS(1); | 2742 | m_host.AddScriptLPS(1); |
2728 | if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) | 2743 | |
2729 | { | 2744 | if (m_SoundModule != null) |
2730 | if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) | 2745 | m_SoundModule.StopSound(m_host.UUID); |
2731 | { | ||
2732 | foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) | ||
2733 | { | ||
2734 | part.Sound = UUID.Zero; | ||
2735 | part.SoundGain = 0; | ||
2736 | part.SoundFlags = 0; | ||
2737 | part.SoundRadius = 0; | ||
2738 | part.ScheduleFullUpdate(); | ||
2739 | part.SendFullUpdateToAllClients(); | ||
2740 | } | ||
2741 | m_host.ParentGroup.LoopSoundMasterPrim = null; | ||
2742 | m_host.ParentGroup.LoopSoundSlavePrims.Clear(); | ||
2743 | } | ||
2744 | else | ||
2745 | { | ||
2746 | m_host.Sound = UUID.Zero; | ||
2747 | m_host.SoundGain = 0; | ||
2748 | m_host.SoundFlags = 0; | ||
2749 | m_host.SoundRadius = 0; | ||
2750 | m_host.ScheduleFullUpdate(); | ||
2751 | m_host.SendFullUpdateToAllClients(); | ||
2752 | } | ||
2753 | } | ||
2754 | else | ||
2755 | { | ||
2756 | m_host.Sound = UUID.Zero; | ||
2757 | m_host.SoundGain = 0; | ||
2758 | m_host.SoundFlags = 0; | ||
2759 | m_host.SoundRadius = 0; | ||
2760 | m_host.ScheduleFullUpdate(); | ||
2761 | m_host.SendFullUpdateToAllClients(); | ||
2762 | } | ||
2763 | } | 2746 | } |
2764 | 2747 | ||
2765 | public void llPreloadSound(string sound) | 2748 | public void llPreloadSound(string sound) |
2766 | { | 2749 | { |
2767 | m_host.AddScriptLPS(1); | 2750 | m_host.AddScriptLPS(1); |
2768 | m_host.PreloadSound(sound); | 2751 | if (m_SoundModule != null) |
2752 | m_SoundModule.PreloadSound(m_host.UUID, KeyOrName(sound), 0); | ||
2769 | ScriptSleep(1000); | 2753 | ScriptSleep(1000); |
2770 | } | 2754 | } |
2771 | 2755 | ||
@@ -4747,16 +4731,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4747 | return; | 4731 | return; |
4748 | } | 4732 | } |
4749 | // TODO: Parameter check logic required. | 4733 | // TODO: Parameter check logic required. |
4750 | UUID soundId = UUID.Zero; | 4734 | m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound); |
4751 | if (!UUID.TryParse(impact_sound, out soundId)) | ||
4752 | { | ||
4753 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(impact_sound); | ||
4754 | |||
4755 | if (item != null && item.Type == (int)AssetType.Sound) | ||
4756 | soundId = item.AssetID; | ||
4757 | } | ||
4758 | |||
4759 | m_host.CollisionSound = soundId; | ||
4760 | m_host.CollisionSoundVolume = (float)impact_volume; | 4735 | m_host.CollisionSoundVolume = (float)impact_volume; |
4761 | m_host.CollisionSoundType = 1; | 4736 | m_host.CollisionSoundType = 1; |
4762 | } | 4737 | } |
@@ -6318,10 +6293,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6318 | LSL_Vector bottom_south_west) | 6293 | LSL_Vector bottom_south_west) |
6319 | { | 6294 | { |
6320 | m_host.AddScriptLPS(1); | 6295 | m_host.AddScriptLPS(1); |
6321 | float radius1 = (float)llVecDist(llGetPos(), top_north_east); | 6296 | if (m_SoundModule != null) |
6322 | float radius2 = (float)llVecDist(llGetPos(), bottom_south_west); | 6297 | { |
6323 | float radius = Math.Abs(radius1 - radius2); | 6298 | m_SoundModule.TriggerSoundLimited(m_host.UUID, |
6324 | m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, radius, false, false); | 6299 | KeyOrName(sound, AssetType.Sound), volume, |
6300 | bottom_south_west, top_north_east); | ||
6301 | } | ||
6325 | } | 6302 | } |
6326 | 6303 | ||
6327 | public void llEjectFromLand(string pest) | 6304 | public void llEjectFromLand(string pest) |