diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
4 files changed, 249 insertions, 137 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); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 6809c09..8f34833 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -95,13 +95,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
95 | 95 | ||
96 | internal void MODError(string msg) | 96 | internal void MODError(string msg) |
97 | { | 97 | { |
98 | throw new Exception("MOD Runtime Error: " + msg); | 98 | throw new ScriptException("MOD Runtime Error: " + msg); |
99 | } | 99 | } |
100 | 100 | ||
101 | // | 101 | /// <summary> |
102 | //Dumps an error message on the debug console. | 102 | /// Dumps an error message on the debug console. |
103 | // | 103 | /// </summary> |
104 | 104 | /// <param name='message'></param> | |
105 | internal void MODShoutError(string message) | 105 | internal void MODShoutError(string message) |
106 | { | 106 | { |
107 | if (message.Length > 1023) | 107 | if (message.Length > 1023) |
@@ -359,20 +359,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
359 | result[i] = (string)(LSL_String)plist[i]; | 359 | result[i] = (string)(LSL_String)plist[i]; |
360 | else if (plist[i] is LSL_Integer) | 360 | else if (plist[i] is LSL_Integer) |
361 | result[i] = (int)(LSL_Integer)plist[i]; | 361 | result[i] = (int)(LSL_Integer)plist[i]; |
362 | // The int check exists because of the many plain old int script constants in ScriptBase which | ||
363 | // are not LSL_Integers. | ||
364 | else if (plist[i] is int) | ||
365 | result[i] = plist[i]; | ||
362 | else if (plist[i] is LSL_Float) | 366 | else if (plist[i] is LSL_Float) |
363 | result[i] = (float)(LSL_Float)plist[i]; | 367 | result[i] = (float)(LSL_Float)plist[i]; |
364 | else if (plist[i] is LSL_Key) | 368 | else if (plist[i] is LSL_Key) |
365 | result[i] = new UUID((LSL_Key)plist[i]); | 369 | result[i] = new UUID((LSL_Key)plist[i]); |
366 | else if (plist[i] is LSL_Rotation) | 370 | else if (plist[i] is LSL_Rotation) |
367 | { | 371 | result[i] = (Quaternion)((LSL_Rotation)plist[i]); |
368 | result[i] = (OpenMetaverse.Quaternion)( | ||
369 | (LSL_Rotation)plist[i]); | ||
370 | } | ||
371 | else if (plist[i] is LSL_Vector) | 372 | else if (plist[i] is LSL_Vector) |
372 | { | 373 | result[i] = (Vector3)((LSL_Vector)plist[i]); |
373 | result[i] = (OpenMetaverse.Vector3)( | ||
374 | (LSL_Vector)plist[i]); | ||
375 | } | ||
376 | else | 374 | else |
377 | MODError(String.Format("{0}: unknown LSL list element type", fname)); | 375 | MODError(String.Format("{0}: unknown LSL list element type", fname)); |
378 | } | 376 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 29bc163..828288d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -210,7 +210,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
210 | 210 | ||
211 | internal void OSSLError(string msg) | 211 | internal void OSSLError(string msg) |
212 | { | 212 | { |
213 | throw new Exception("OSSL Runtime Error: " + msg); | 213 | throw new ScriptException("OSSL Runtime Error: " + msg); |
214 | } | 214 | } |
215 | 215 | ||
216 | /// <summary> | 216 | /// <summary> |
@@ -1780,18 +1780,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1780 | protected string LoadNotecard(string notecardNameOrUuid) | 1780 | protected string LoadNotecard(string notecardNameOrUuid) |
1781 | { | 1781 | { |
1782 | UUID assetID = CacheNotecard(notecardNameOrUuid); | 1782 | UUID assetID = CacheNotecard(notecardNameOrUuid); |
1783 | StringBuilder notecardData = new StringBuilder(); | ||
1784 | 1783 | ||
1785 | for (int count = 0; count < NotecardCache.GetLines(assetID); count++) | 1784 | if (assetID != UUID.Zero) |
1786 | { | 1785 | { |
1787 | string line = NotecardCache.GetLine(assetID, count) + "\n"; | 1786 | StringBuilder notecardData = new StringBuilder(); |
1788 | 1787 | ||
1789 | // m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line); | 1788 | for (int count = 0; count < NotecardCache.GetLines(assetID); count++) |
1790 | 1789 | { | |
1791 | notecardData.Append(line); | 1790 | string line = NotecardCache.GetLine(assetID, count) + "\n"; |
1791 | |||
1792 | // m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line); | ||
1793 | |||
1794 | notecardData.Append(line); | ||
1795 | } | ||
1796 | |||
1797 | return notecardData.ToString(); | ||
1792 | } | 1798 | } |
1793 | 1799 | ||
1794 | return notecardData.ToString(); | 1800 | return null; |
1795 | } | 1801 | } |
1796 | 1802 | ||
1797 | /// <summary> | 1803 | /// <summary> |
@@ -2340,11 +2346,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2340 | appearance = new AvatarAppearance(); | 2346 | appearance = new AvatarAppearance(); |
2341 | appearance.Unpack(appearanceOsd); | 2347 | appearance.Unpack(appearanceOsd); |
2342 | } | 2348 | } |
2349 | else | ||
2350 | { | ||
2351 | OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard)); | ||
2352 | } | ||
2343 | } | 2353 | } |
2344 | 2354 | ||
2345 | if (appearance == null) | ||
2346 | return new LSL_Key(UUID.Zero.ToString()); | ||
2347 | |||
2348 | UUID ownerID = UUID.Zero; | 2355 | UUID ownerID = UUID.Zero; |
2349 | if (owned) | 2356 | if (owned) |
2350 | ownerID = m_host.OwnerID; | 2357 | ownerID = m_host.OwnerID; |
@@ -2407,6 +2414,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2407 | return; | 2414 | return; |
2408 | 2415 | ||
2409 | string appearanceSerialized = LoadNotecard(notecard); | 2416 | string appearanceSerialized = LoadNotecard(notecard); |
2417 | |||
2418 | if (appearanceSerialized == null) | ||
2419 | OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard)); | ||
2420 | |||
2410 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | 2421 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); |
2411 | // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); | 2422 | // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); |
2412 | // Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); | 2423 | // Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); |
@@ -3636,5 +3647,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3636 | 3647 | ||
3637 | DropAttachmentAt(false, pos, rot); | 3648 | DropAttachmentAt(false, pos, rot); |
3638 | } | 3649 | } |
3650 | |||
3651 | public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield) | ||
3652 | { | ||
3653 | CheckThreatLevel(ThreatLevel.Low, "osListenRegex"); | ||
3654 | m_host.AddScriptLPS(1); | ||
3655 | UUID keyID; | ||
3656 | UUID.TryParse(ID, out keyID); | ||
3657 | |||
3658 | // if we want the name to be used as a regular expression, ensure it is valid first. | ||
3659 | if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_NAME) == ScriptBaseClass.OS_LISTEN_REGEX_NAME) | ||
3660 | { | ||
3661 | try | ||
3662 | { | ||
3663 | Regex.IsMatch("", name); | ||
3664 | } | ||
3665 | catch (Exception) | ||
3666 | { | ||
3667 | OSSLShoutError("Name regex is invalid."); | ||
3668 | return -1; | ||
3669 | } | ||
3670 | } | ||
3671 | |||
3672 | // if we want the msg to be used as a regular expression, ensure it is valid first. | ||
3673 | if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE) == ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE) | ||
3674 | { | ||
3675 | try | ||
3676 | { | ||
3677 | Regex.IsMatch("", msg); | ||
3678 | } | ||
3679 | catch (Exception) | ||
3680 | { | ||
3681 | OSSLShoutError("Message regex is invalid."); | ||
3682 | return -1; | ||
3683 | } | ||
3684 | } | ||
3685 | |||
3686 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
3687 | return (wComm == null) ? -1 : wComm.Listen( | ||
3688 | m_host.LocalId, | ||
3689 | m_item.ItemID, | ||
3690 | m_host.UUID, | ||
3691 | channelID, | ||
3692 | name, | ||
3693 | keyID, | ||
3694 | msg, | ||
3695 | regexBitfield | ||
3696 | ); | ||
3697 | } | ||
3698 | |||
3699 | public LSL_Integer osRegexIsMatch(string input, string pattern) | ||
3700 | { | ||
3701 | CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch"); | ||
3702 | m_host.AddScriptLPS(1); | ||
3703 | try | ||
3704 | { | ||
3705 | return Regex.IsMatch(input, pattern) ? 1 : 0; | ||
3706 | } | ||
3707 | catch (Exception) | ||
3708 | { | ||
3709 | OSSLShoutError("Possible invalid regular expression detected."); | ||
3710 | return 0; | ||
3711 | } | ||
3712 | } | ||
3639 | } | 3713 | } |
3640 | } \ No newline at end of file | 3714 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d173db0 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.Api")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("369ed06e-a3ca-40f0-98e3-3cd3ec1443c3")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||