diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 229 |
1 files changed, 118 insertions, 111 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index cf801ba..acf4d8c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -107,6 +107,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
107 | protected IUrlModule m_UrlModule = null; | 107 | protected IUrlModule m_UrlModule = null; |
108 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); | 108 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); |
109 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | 109 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. |
110 | protected ISoundModule m_SoundModule = null; | ||
110 | 111 | ||
111 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 112 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
112 | { | 113 | { |
@@ -119,6 +120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
119 | m_TransferModule = | 120 | m_TransferModule = |
120 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); | 121 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); |
121 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 122 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
123 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); | ||
122 | 124 | ||
123 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | 125 | AsyncCommands = new AsyncCommandManager(ScriptEngine); |
124 | } | 126 | } |
@@ -331,6 +333,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
331 | return key; | 333 | return key; |
332 | } | 334 | } |
333 | 335 | ||
336 | /// <summary> | ||
337 | /// Return the UUID of the asset matching the specified key or name | ||
338 | /// and asset type. | ||
339 | /// </summary> | ||
340 | /// <param name="k"></param> | ||
341 | /// <param name="type"></param> | ||
342 | /// <returns></returns> | ||
343 | protected UUID KeyOrName(string k, AssetType type) | ||
344 | { | ||
345 | UUID key; | ||
346 | |||
347 | if (!UUID.TryParse(k, out key)) | ||
348 | { | ||
349 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); | ||
350 | if (item != null && item.Type == (int)type) | ||
351 | key = item.AssetID; | ||
352 | } | ||
353 | else | ||
354 | { | ||
355 | lock (m_host.TaskInventory) | ||
356 | { | ||
357 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in m_host.TaskInventory) | ||
358 | { | ||
359 | if (item.Value.Type == (int)type && item.Value.Name == k) | ||
360 | { | ||
361 | key = item.Value.ItemID; | ||
362 | break; | ||
363 | } | ||
364 | } | ||
365 | } | ||
366 | } | ||
367 | |||
368 | |||
369 | return key; | ||
370 | } | ||
371 | |||
334 | //These are the implementations of the various ll-functions used by the LSL scripts. | 372 | //These are the implementations of the various ll-functions used by the LSL scripts. |
335 | public LSL_Float llSin(double f) | 373 | public LSL_Float llSin(double f) |
336 | { | 374 | { |
@@ -2044,8 +2082,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2044 | public LSL_Vector llGetPos() | 2082 | public LSL_Vector llGetPos() |
2045 | { | 2083 | { |
2046 | m_host.AddScriptLPS(1); | 2084 | m_host.AddScriptLPS(1); |
2047 | Vector3 pos = m_host.GetWorldPosition(); | 2085 | return m_host.GetWorldPosition(); |
2048 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | ||
2049 | } | 2086 | } |
2050 | 2087 | ||
2051 | public LSL_Vector llGetLocalPos() | 2088 | public LSL_Vector llGetLocalPos() |
@@ -2365,63 +2402,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2365 | m_host.AddScriptLPS(1); | 2402 | m_host.AddScriptLPS(1); |
2366 | 2403 | ||
2367 | // send the sound, once, to all clients in range | 2404 | // send the sound, once, to all clients in range |
2368 | m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false); | 2405 | if (m_SoundModule != null) |
2406 | { | ||
2407 | m_SoundModule.SendSound(m_host.UUID, | ||
2408 | KeyOrName(sound, AssetType.Sound), volume, false, 0, | ||
2409 | 0, false, false); | ||
2410 | } | ||
2369 | } | 2411 | } |
2370 | 2412 | ||
2371 | // Xantor 20080528 we should do this differently. | ||
2372 | // 1) apply the sound to the object | ||
2373 | // 2) schedule full update | ||
2374 | // just sending the sound out once doesn't work so well when other avatars come in view later on | ||
2375 | // or when the prim gets moved, changed, sat on, whatever | ||
2376 | // see large number of mantises (mantes?) | ||
2377 | // 20080530 Updated to remove code duplication | ||
2378 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work | ||
2379 | public void llLoopSound(string sound, double volume) | 2413 | public void llLoopSound(string sound, double volume) |
2380 | { | 2414 | { |
2381 | m_host.AddScriptLPS(1); | 2415 | m_host.AddScriptLPS(1); |
2382 | 2416 | if (m_SoundModule != null) | |
2383 | if (m_host.Sound != UUID.Zero) | 2417 | { |
2384 | llStopSound(); | 2418 | m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), |
2385 | 2419 | volume, 20, false); | |
2386 | m_host.Sound = KeyOrName(sound); | 2420 | } |
2387 | m_host.SoundGain = volume; | ||
2388 | m_host.SoundFlags = 1; // looping | ||
2389 | m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
2390 | |||
2391 | m_host.ScheduleFullUpdate(); | ||
2392 | m_host.SendFullUpdateToAllClients(); | ||
2393 | } | 2421 | } |
2394 | 2422 | ||
2395 | public void llLoopSoundMaster(string sound, double volume) | 2423 | public void llLoopSoundMaster(string sound, double volume) |
2396 | { | 2424 | { |
2397 | m_host.AddScriptLPS(1); | 2425 | m_host.AddScriptLPS(1); |
2398 | m_host.ParentGroup.LoopSoundMasterPrim = m_host; | 2426 | if (m_SoundModule != null) |
2399 | lock (m_host.ParentGroup.LoopSoundSlavePrims) | ||
2400 | { | 2427 | { |
2401 | foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims) | 2428 | m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), |
2402 | { | 2429 | volume, 20, true); |
2403 | if (prim.Sound != UUID.Zero) | ||
2404 | llStopSound(); | ||
2405 | |||
2406 | prim.Sound = KeyOrName(sound); | ||
2407 | prim.SoundGain = volume; | ||
2408 | prim.SoundFlags = 1; // looping | ||
2409 | prim.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
2410 | |||
2411 | prim.ScheduleFullUpdate(); | ||
2412 | prim.SendFullUpdateToAllClients(); | ||
2413 | } | ||
2414 | } | 2430 | } |
2415 | if (m_host.Sound != UUID.Zero) | ||
2416 | llStopSound(); | ||
2417 | |||
2418 | m_host.Sound = KeyOrName(sound); | ||
2419 | m_host.SoundGain = volume; | ||
2420 | m_host.SoundFlags = 1; // looping | ||
2421 | m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
2422 | |||
2423 | m_host.ScheduleFullUpdate(); | ||
2424 | m_host.SendFullUpdateToAllClients(); | ||
2425 | } | 2431 | } |
2426 | 2432 | ||
2427 | public void llLoopSoundSlave(string sound, double volume) | 2433 | public void llLoopSoundSlave(string sound, double volume) |
@@ -2438,61 +2444,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2438 | m_host.AddScriptLPS(1); | 2444 | m_host.AddScriptLPS(1); |
2439 | 2445 | ||
2440 | // send the sound, once, to all clients in range | 2446 | // send the sound, once, to all clients in range |
2441 | m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, true, false); | 2447 | if (m_SoundModule != null) |
2448 | { | ||
2449 | m_SoundModule.SendSound(m_host.UUID, | ||
2450 | KeyOrName(sound, AssetType.Sound), volume, false, 0, | ||
2451 | 0, true, false); | ||
2452 | } | ||
2442 | } | 2453 | } |
2443 | 2454 | ||
2444 | public void llTriggerSound(string sound, double volume) | 2455 | public void llTriggerSound(string sound, double volume) |
2445 | { | 2456 | { |
2446 | m_host.AddScriptLPS(1); | 2457 | m_host.AddScriptLPS(1); |
2447 | // send the sound, once, to all clients in range | 2458 | // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory. |
2448 | m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, 0, false, false); | 2459 | if (m_SoundModule != null) |
2460 | { | ||
2461 | m_SoundModule.SendSound(m_host.UUID, | ||
2462 | KeyOrName(sound, AssetType.Sound), volume, true, 0, 0, | ||
2463 | false, false); | ||
2464 | } | ||
2449 | } | 2465 | } |
2450 | 2466 | ||
2451 | // Xantor 20080528: Clear prim data of sound instead | ||
2452 | public void llStopSound() | 2467 | public void llStopSound() |
2453 | { | 2468 | { |
2454 | m_host.AddScriptLPS(1); | 2469 | m_host.AddScriptLPS(1); |
2455 | if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) | 2470 | |
2456 | { | 2471 | if (m_SoundModule != null) |
2457 | if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) | 2472 | m_SoundModule.StopSound(m_host.UUID); |
2458 | { | ||
2459 | foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) | ||
2460 | { | ||
2461 | part.Sound = UUID.Zero; | ||
2462 | part.SoundGain = 0; | ||
2463 | part.SoundFlags = 0; | ||
2464 | part.SoundRadius = 0; | ||
2465 | part.ScheduleFullUpdate(); | ||
2466 | part.SendFullUpdateToAllClients(); | ||
2467 | } | ||
2468 | m_host.ParentGroup.LoopSoundMasterPrim = null; | ||
2469 | m_host.ParentGroup.LoopSoundSlavePrims.Clear(); | ||
2470 | } | ||
2471 | else | ||
2472 | { | ||
2473 | m_host.Sound = UUID.Zero; | ||
2474 | m_host.SoundGain = 0; | ||
2475 | m_host.SoundFlags = 0; | ||
2476 | m_host.SoundRadius = 0; | ||
2477 | m_host.ScheduleFullUpdate(); | ||
2478 | m_host.SendFullUpdateToAllClients(); | ||
2479 | } | ||
2480 | } | ||
2481 | else | ||
2482 | { | ||
2483 | m_host.Sound = UUID.Zero; | ||
2484 | m_host.SoundGain = 0; | ||
2485 | m_host.SoundFlags = 0; | ||
2486 | m_host.SoundRadius = 0; | ||
2487 | m_host.ScheduleFullUpdate(); | ||
2488 | m_host.SendFullUpdateToAllClients(); | ||
2489 | } | ||
2490 | } | 2473 | } |
2491 | 2474 | ||
2492 | public void llPreloadSound(string sound) | 2475 | public void llPreloadSound(string sound) |
2493 | { | 2476 | { |
2494 | m_host.AddScriptLPS(1); | 2477 | m_host.AddScriptLPS(1); |
2495 | m_host.PreloadSound(sound); | 2478 | if (m_SoundModule != null) |
2479 | m_SoundModule.PreloadSound(m_host.UUID, KeyOrName(sound), 0); | ||
2496 | ScriptSleep(1000); | 2480 | ScriptSleep(1000); |
2497 | } | 2481 | } |
2498 | 2482 | ||
@@ -3979,17 +3963,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3979 | 3963 | ||
3980 | if (m_TransferModule != null) | 3964 | if (m_TransferModule != null) |
3981 | { | 3965 | { |
3982 | byte[] bucket = new byte[] { (byte)item.Type }; | 3966 | byte[] bucket = new byte[1]; |
3967 | bucket[0] = (byte)item.Type; | ||
3983 | 3968 | ||
3984 | GridInstantMessage msg = new GridInstantMessage(World, | 3969 | GridInstantMessage msg = new GridInstantMessage(World, |
3985 | m_host.UUID, m_host.Name + ", an object owned by " + | 3970 | m_host.OwnerID, m_host.Name, destId, |
3986 | resolveName(m_host.OwnerID) + ",", destId, | ||
3987 | (byte)InstantMessageDialog.TaskInventoryOffered, | 3971 | (byte)InstantMessageDialog.TaskInventoryOffered, |
3988 | false, item.Name + "\n" + m_host.Name + " is located at " + | 3972 | false, item.Name+". "+m_host.Name+" is located at "+ |
3989 | World.RegionInfo.RegionName+" "+ | 3973 | World.RegionInfo.RegionName+" "+ |
3990 | m_host.AbsolutePosition.ToString(), | 3974 | m_host.AbsolutePosition.ToString(), |
3991 | agentItem.ID, true, m_host.AbsolutePosition, | 3975 | agentItem.ID, true, m_host.AbsolutePosition, |
3992 | bucket, true); // TODO: May actually send no timestamp | 3976 | bucket, true); |
3993 | 3977 | ||
3994 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 3978 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
3995 | } | 3979 | } |
@@ -4358,16 +4342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4358 | m_host.AddScriptLPS(1); | 4342 | m_host.AddScriptLPS(1); |
4359 | 4343 | ||
4360 | // TODO: Parameter check logic required. | 4344 | // TODO: Parameter check logic required. |
4361 | UUID soundId = UUID.Zero; | 4345 | m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound); |
4362 | if (!UUID.TryParse(impact_sound, out soundId)) | ||
4363 | { | ||
4364 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(impact_sound); | ||
4365 | |||
4366 | if (item != null && item.Type == (int)AssetType.Sound) | ||
4367 | soundId = item.AssetID; | ||
4368 | } | ||
4369 | |||
4370 | m_host.CollisionSound = soundId; | ||
4371 | m_host.CollisionSoundVolume = (float)impact_volume; | 4346 | m_host.CollisionSoundVolume = (float)impact_volume; |
4372 | } | 4347 | } |
4373 | 4348 | ||
@@ -4388,7 +4363,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4388 | { | 4363 | { |
4389 | AnimationSet currentAnims = presence.Animator.Animations; | 4364 | AnimationSet currentAnims = presence.Animator.Animations; |
4390 | string currentAnimationState = String.Empty; | 4365 | string currentAnimationState = String.Empty; |
4391 | if (animationstateNames.TryGetValue(currentAnims.DefaultAnimation.AnimID, out currentAnimationState)) | 4366 | if (animationstateNames.TryGetValue(currentAnims.ImplicitDefaultAnimation.AnimID, out currentAnimationState)) |
4392 | return currentAnimationState; | 4367 | return currentAnimationState; |
4393 | } | 4368 | } |
4394 | } | 4369 | } |
@@ -5705,7 +5680,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5705 | flags |= ScriptBaseClass.AGENT_SITTING; | 5680 | flags |= ScriptBaseClass.AGENT_SITTING; |
5706 | } | 5681 | } |
5707 | 5682 | ||
5708 | if (agent.Animator.Animations.DefaultAnimation.AnimID | 5683 | if (agent.Animator.Animations.ImplicitDefaultAnimation.AnimID |
5709 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 5684 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) |
5710 | { | 5685 | { |
5711 | flags |= ScriptBaseClass.AGENT_SITTING; | 5686 | flags |= ScriptBaseClass.AGENT_SITTING; |
@@ -5890,10 +5865,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5890 | LSL_Vector bottom_south_west) | 5865 | LSL_Vector bottom_south_west) |
5891 | { | 5866 | { |
5892 | m_host.AddScriptLPS(1); | 5867 | m_host.AddScriptLPS(1); |
5893 | float radius1 = (float)llVecDist(llGetPos(), top_north_east); | 5868 | if (m_SoundModule != null) |
5894 | float radius2 = (float)llVecDist(llGetPos(), bottom_south_west); | 5869 | { |
5895 | float radius = Math.Abs(radius1 - radius2); | 5870 | m_SoundModule.TriggerSoundLimited(m_host.UUID, |
5896 | m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, radius, false, false); | 5871 | KeyOrName(sound, AssetType.Sound), volume, |
5872 | bottom_south_west, top_north_east); | ||
5873 | } | ||
5897 | } | 5874 | } |
5898 | 5875 | ||
5899 | public void llEjectFromLand(string pest) | 5876 | public void llEjectFromLand(string pest) |
@@ -6660,6 +6637,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6660 | m_host.SetCameraAtOffset(offset); | 6637 | m_host.SetCameraAtOffset(offset); |
6661 | } | 6638 | } |
6662 | 6639 | ||
6640 | public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at) | ||
6641 | { | ||
6642 | m_host.AddScriptLPS(1); | ||
6643 | |||
6644 | if (link == ScriptBaseClass.LINK_SET || | ||
6645 | link == ScriptBaseClass.LINK_ALL_CHILDREN || | ||
6646 | link == ScriptBaseClass.LINK_ALL_OTHERS) return; | ||
6647 | |||
6648 | SceneObjectPart part = null; | ||
6649 | |||
6650 | switch (link) | ||
6651 | { | ||
6652 | case ScriptBaseClass.LINK_ROOT: | ||
6653 | part = m_host.ParentGroup.RootPart; | ||
6654 | break; | ||
6655 | case ScriptBaseClass.LINK_THIS: | ||
6656 | part = m_host; | ||
6657 | break; | ||
6658 | default: | ||
6659 | part = m_host.ParentGroup.GetLinkNumPart(link); | ||
6660 | break; | ||
6661 | } | ||
6662 | |||
6663 | if (null != part) | ||
6664 | { | ||
6665 | part.SetCameraEyeOffset(eye); | ||
6666 | part.SetCameraAtOffset(at); | ||
6667 | } | ||
6668 | } | ||
6669 | |||
6663 | public LSL_String llDumpList2String(LSL_List src, string seperator) | 6670 | public LSL_String llDumpList2String(LSL_List src, string seperator) |
6664 | { | 6671 | { |
6665 | m_host.AddScriptLPS(1); | 6672 | m_host.AddScriptLPS(1); |
@@ -7892,7 +7899,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7892 | { | 7899 | { |
7893 | LSL_Vector lower; | 7900 | LSL_Vector lower; |
7894 | LSL_Vector upper; | 7901 | LSL_Vector upper; |
7895 | if (presence.Animator.Animations.DefaultAnimation.AnimID | 7902 | if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID |
7896 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 7903 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) |
7897 | { | 7904 | { |
7898 | // This is for ground sitting avatars | 7905 | // This is for ground sitting avatars |
@@ -10685,12 +10692,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10685 | 10692 | ||
10686 | internal void Deprecated(string command) | 10693 | internal void Deprecated(string command) |
10687 | { | 10694 | { |
10688 | throw new Exception("Command deprecated: " + command); | 10695 | throw new ScriptException("Command deprecated: " + command); |
10689 | } | 10696 | } |
10690 | 10697 | ||
10691 | internal void LSLError(string msg) | 10698 | internal void LSLError(string msg) |
10692 | { | 10699 | { |
10693 | throw new Exception("LSL Runtime Error: " + msg); | 10700 | throw new ScriptException("LSL Runtime Error: " + msg); |
10694 | } | 10701 | } |
10695 | 10702 | ||
10696 | public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); | 10703 | public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); |