aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorBlueWall2012-11-25 17:03:14 -0500
committerBlueWall2012-11-25 17:03:14 -0500
commitc754003944d0166bf50b4f94b0c0eea642503bb0 (patch)
treedfa1c2020d5500d510519d5b2b3236600692f277 /OpenSim/Region/ScriptEngine/Shared
parentMerge branch 'master' into connector_plugin (diff)
parentCombine TestDeleteSceneObjectAsync() with TestDeRezSceneObject() as they are ... (diff)
downloadopensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.zip
opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.gz
opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.bz2
opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.xz
Merge branch 'master' into connector_plugin
Conflicts: OpenSim/Server/Base/ServicesServerBase.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs229
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs100
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/ScriptException.cs44
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs72
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs184
27 files changed, 701 insertions, 220 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 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using 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")]
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index e97ff9d..98f8be7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -333,6 +333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
333 void llSetBuoyancy(double buoyancy); 333 void llSetBuoyancy(double buoyancy);
334 void llSetCameraAtOffset(LSL_Vector offset); 334 void llSetCameraAtOffset(LSL_Vector offset);
335 void llSetCameraEyeOffset(LSL_Vector offset); 335 void llSetCameraEyeOffset(LSL_Vector offset);
336 void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at);
336 void llSetCameraParams(LSL_List rules); 337 void llSetCameraParams(LSL_List rules);
337 void llSetClickAction(int action); 338 void llSetClickAction(int action);
338 void llSetColor(LSL_Vector color, int face); 339 void llSetColor(LSL_Vector color, int face);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 93188c9..cdd9ea8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -418,5 +418,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
418 /// <param name="pos"></param> 418 /// <param name="pos"></param>
419 /// <param name="rot"></param> 419 /// <param name="rot"></param>
420 void osForceDropAttachmentAt(vector pos, rotation rot); 420 void osForceDropAttachmentAt(vector pos, rotation rot);
421
422 /// <summary>
423 /// Identical to llListen except for a bitfield which indicates which
424 /// string parameters should be parsed as regex patterns.
425 /// </summary>
426 /// <param name="channelID"></param>
427 /// <param name="name"></param>
428 /// <param name="ID"></param>
429 /// <param name="msg"></param>
430 /// <param name="regexBitfield">
431 /// OS_LISTEN_REGEX_NAME
432 /// OS_LISTEN_REGEX_MESSAGE
433 /// </param>
434 /// <returns></returns>
435 LSL_Integer osListenRegex(int channelID, string name, string ID,
436 string msg, int regexBitfield);
437
438 /// <summary>
439 /// Wraps to bool Regex.IsMatch(string input, string pattern)
440 /// </summary>
441 /// <param name="input">string to test for match</param>
442 /// <param name="regex">string to use as pattern</param>
443 /// <returns>boolean</returns>
444 LSL_Integer osRegexIsMatch(string input, string pattern);
421 } 445 }
422} 446}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index 62bd6b8..880841b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -716,5 +716,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
716 public static readonly LSLInteger RCERR_UNKNOWN = -1; 716 public static readonly LSLInteger RCERR_UNKNOWN = -1;
717 public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; 717 public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2;
718 public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; 718 public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3;
719
720 /// <summary>
721 /// process name parameter as regex
722 /// </summary>
723 public const int OS_LISTEN_REGEX_NAME = 0x1;
724
725 /// <summary>
726 /// process message parameter as regex
727 /// </summary>
728 public const int OS_LISTEN_REGEX_MESSAGE = 0x2;
719 } 729 }
720} 730}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index c457880..36803a4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -1498,6 +1498,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1498 m_LSL_Functions.llSetCameraEyeOffset(offset); 1498 m_LSL_Functions.llSetCameraEyeOffset(offset);
1499 } 1499 }
1500 1500
1501 public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at)
1502 {
1503 m_LSL_Functions.llSetLinkCamera(link, eye, at);
1504 }
1505
1501 public void llSetCameraParams(LSL_List rules) 1506 public void llSetCameraParams(LSL_List rules)
1502 { 1507 {
1503 m_LSL_Functions.llSetCameraParams(rules); 1508 m_LSL_Functions.llSetCameraParams(rules);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index dee1b28..afa9ae0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -992,5 +992,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
992 { 992 {
993 m_OSSL_Functions.osForceDropAttachmentAt(pos, rot); 993 m_OSSL_Functions.osForceDropAttachmentAt(pos, rot);
994 } 994 }
995
996 public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield)
997 {
998 return m_OSSL_Functions.osListenRegex(channelID, name, ID, msg, regexBitfield);
999 }
1000
1001 public LSL_Integer osRegexIsMatch(string input, string pattern)
1002 {
1003 return m_OSSL_Functions.osRegexIsMatch(input, pattern);
1004 }
995 } 1005 }
996} 1006}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..573a803
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using 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.Runtime")]
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("ac60ce7e-7c35-4431-b294-fe6ca26b5b50")]
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")]
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..f6d5d41
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using 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.YieldProlog")]
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("8df98e6b-0425-44d6-8d91-2b3b4c56acdf")]
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")]
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..c65caa8
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using 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.CodeTools")]
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("fd446fb3-3a21-471b-951c-68b9eb6ef8e5")]
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")]
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
index 7763619..77e087c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
39 /// The generated C# code is compared against the expected C# code. 39 /// The generated C# code is compared against the expected C# code.
40 /// </summary> 40 /// </summary>
41 [TestFixture] 41 [TestFixture]
42 public class CSCodeGeneratorTest 42 public class CSCodeGeneratorTest : OpenSimTestCase
43 { 43 {
44 [Test] 44 [Test]
45 public void TestDefaultState() 45 public void TestDefaultState()
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
index 1fa6954..05a8756 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
41 /// the LSL source. 41 /// the LSL source.
42 /// </summary> 42 /// </summary>
43 [TestFixture] 43 [TestFixture]
44 public class CompilerTest 44 public class CompilerTest : OpenSimTestCase
45 { 45 {
46 private string m_testDir; 46 private string m_testDir;
47 private CSharpCodeProvider m_CSCodeProvider; 47 private CSharpCodeProvider m_CSCodeProvider;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..470e1a1
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using 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.Instance")]
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("b776d846-68c1-43a2-9e72-9bd1fe20fd41")]
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")]
diff --git a/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..e6e8777
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using 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")]
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("5fe331de-bc53-4ca7-b080-2a5a5ce2d380")]
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")]
diff --git a/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs
new file mode 100644
index 0000000..f55ba7e
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs
@@ -0,0 +1,44 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Runtime.Serialization;
30
31namespace OpenSim.Region.ScriptEngine.Shared
32{
33 [Serializable]
34 public class ScriptException : Exception
35 {
36 public ScriptException() : base() {}
37
38 public ScriptException(string message) : base(message) {}
39
40 public ScriptException(string message, Exception innerException) : base(message, innerException) {}
41
42 public ScriptException(SerializationInfo info, StreamingContext context) :base(info, context) {}
43 }
44} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
index c73e22f..2c9d9e8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
51 /// Tests for inventory functions in LSL 51 /// Tests for inventory functions in LSL
52 /// </summary> 52 /// </summary>
53 [TestFixture] 53 [TestFixture]
54 public class LSL_ApiInventoryTests 54 public class LSL_ApiInventoryTests : OpenSimTestCase
55 { 55 {
56 protected Scene m_scene; 56 protected Scene m_scene;
57 protected XEngine.XEngine m_engine; 57 protected XEngine.XEngine m_engine;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
index 2565ae7..57f19b9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
56 /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests. 56 /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests.
57 /// </remarks> 57 /// </remarks>
58 [TestFixture] 58 [TestFixture]
59 public class LSL_ApiLinkingTests 59 public class LSL_ApiLinkingTests : OpenSimTestCase
60 { 60 {
61 protected Scene m_scene; 61 protected Scene m_scene;
62 protected XEngine.XEngine m_engine; 62 protected XEngine.XEngine m_engine;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
index dd23be8..182b07b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
@@ -46,7 +46,7 @@ using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
46namespace OpenSim.Region.ScriptEngine.Shared.Tests 46namespace OpenSim.Region.ScriptEngine.Shared.Tests
47{ 47{
48 [TestFixture] 48 [TestFixture]
49 public class LSL_ApiListTests 49 public class LSL_ApiListTests : OpenSimTestCase
50 { 50 {
51 private LSL_Api m_lslApi; 51 private LSL_Api m_lslApi;
52 52
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs
index 3ed2562..c8c7f82 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs
@@ -33,7 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared;
33namespace OpenSim.Region.ScriptEngine.Shared.Tests 33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{ 34{
35 [TestFixture] 35 [TestFixture]
36 public class LSL_TypesTestLSLFloat 36 public class LSL_TypesTestLSLFloat : OpenSimTestCase
37 { 37 {
38 // Used for testing equality of two floats. 38 // Used for testing equality of two floats.
39 private double _lowPrecisionTolerance = 0.000001; 39 private double _lowPrecisionTolerance = 0.000001;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs
index 8d1169a..c664108 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs
@@ -33,7 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared;
33namespace OpenSim.Region.ScriptEngine.Shared.Tests 33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{ 34{
35 [TestFixture] 35 [TestFixture]
36 public class LSL_TypesTestLSLInteger 36 public class LSL_TypesTestLSLInteger : OpenSimTestCase
37 { 37 {
38 private Dictionary<double, int> m_doubleIntSet; 38 private Dictionary<double, int> m_doubleIntSet;
39 private Dictionary<string, int> m_stringIntSet; 39 private Dictionary<string, int> m_stringIntSet;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
index c4ca1a8..8550f2d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
@@ -33,7 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared;
33namespace OpenSim.Region.ScriptEngine.Shared.Tests 33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{ 34{
35 [TestFixture] 35 [TestFixture]
36 public class LSL_TypesTestLSLString 36 public class LSL_TypesTestLSLString : OpenSimTestCase
37 { 37 {
38 private Dictionary<double, string> m_doubleStringSet; 38 private Dictionary<double, string> m_doubleStringSet;
39 39
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs
index b81225f..71b88bc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
36 /// Tests the LSL_Types.list class. 36 /// Tests the LSL_Types.list class.
37 /// </summary> 37 /// </summary>
38 [TestFixture] 38 [TestFixture]
39 public class LSL_TypesTestList 39 public class LSL_TypesTestList : OpenSimTestCase
40 { 40 {
41 /// <summary> 41 /// <summary>
42 /// Tests concatenating a string to a list. 42 /// Tests concatenating a string to a list.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs
index ebf8001..0c838af 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
36 /// Tests for Vector3 36 /// Tests for Vector3
37 /// </summary> 37 /// </summary>
38 [TestFixture] 38 [TestFixture]
39 public class LSL_TypesTestVector3 39 public class LSL_TypesTestVector3 : OpenSimTestCase
40 { 40 {
41 [Test] 41 [Test]
42 public void TestDotProduct() 42 public void TestDotProduct()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index c8718d9..213f33f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
51 /// Tests for OSSL_Api 51 /// Tests for OSSL_Api
52 /// </summary> 52 /// </summary>
53 [TestFixture] 53 [TestFixture]
54 public class OSSL_ApiAppearanceTest 54 public class OSSL_ApiAppearanceTest : OpenSimTestCase
55 { 55 {
56 protected Scene m_scene; 56 protected Scene m_scene;
57 protected XEngine.XEngine m_engine; 57 protected XEngine.XEngine m_engine;
@@ -75,76 +75,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
75 m_engine.AddRegion(m_scene); 75 m_engine.AddRegion(m_scene);
76 } 76 }
77 77
78 /// <summary>
79 /// Test creation of an NPC where the appearance data comes from a notecard
80 /// </summary>
81 [Test]
82 public void TestOsNpcCreateUsingAppearanceFromNotecard()
83 {
84 TestHelpers.InMethod();
85// log4net.Config.XmlConfigurator.Configure();
86
87 // Store an avatar with a different height from default in a notecard.
88 UUID userId = TestHelpers.ParseTail(0x1);
89 float newHeight = 1.9f;
90
91 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
92 sp.Appearance.AvatarHeight = newHeight;
93 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
94 SceneObjectPart part = so.RootPart;
95 m_scene.AddSceneObject(so);
96
97 OSSL_Api osslApi = new OSSL_Api();
98 osslApi.Initialize(m_engine, part, null);
99
100 string notecardName = "appearanceNc";
101 osslApi.osOwnerSaveAppearance(notecardName);
102
103 // Try creating a bot using the appearance in the notecard.
104 string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName);
105 Assert.That(npcRaw, Is.Not.Null);
106
107 UUID npcId = new UUID(npcRaw);
108 ScenePresence npc = m_scene.GetScenePresence(npcId);
109 Assert.That(npc, Is.Not.Null);
110 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
111 }
112
113 /// <summary>
114 /// Test creation of an NPC where the appearance data comes from an avatar already in the region.
115 /// </summary>
116 [Test]
117 public void TestOsNpcCreateUsingAppearanceFromAvatar()
118 {
119 TestHelpers.InMethod();
120// TestHelpers.EnableLogging();
121
122 // Store an avatar with a different height from default in a notecard.
123 UUID userId = TestHelpers.ParseTail(0x1);
124 float newHeight = 1.9f;
125
126 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
127 sp.Appearance.AvatarHeight = newHeight;
128 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
129 SceneObjectPart part = so.RootPart;
130 m_scene.AddSceneObject(so);
131
132 OSSL_Api osslApi = new OSSL_Api();
133 osslApi.Initialize(m_engine, part, null);
134
135 string notecardName = "appearanceNc";
136 osslApi.osOwnerSaveAppearance(notecardName);
137
138 // Try creating a bot using the existing avatar's appearance
139 string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString());
140 Assert.That(npcRaw, Is.Not.Null);
141
142 UUID npcId = new UUID(npcRaw);
143 ScenePresence npc = m_scene.GetScenePresence(npcId);
144 Assert.That(npc, Is.Not.Null);
145 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
146 }
147
148 [Test] 78 [Test]
149 public void TestOsOwnerSaveAppearance() 79 public void TestOsOwnerSaveAppearance()
150 { 80 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index 25679a6..b49bcc2 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -36,6 +36,7 @@ using OpenMetaverse;
36using OpenMetaverse.Assets; 36using OpenMetaverse.Assets;
37using OpenMetaverse.StructuredData; 37using OpenMetaverse.StructuredData;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Region.CoreModules.Avatar.Attachments;
39using OpenSim.Region.CoreModules.Avatar.AvatarFactory; 40using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
40using OpenSim.Region.OptionalModules.World.NPC; 41using OpenSim.Region.OptionalModules.World.NPC;
41using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
@@ -71,7 +72,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
71 config.Set("Enabled", "true"); 72 config.Set("Enabled", "true");
72 73
73 m_scene = new SceneHelpers().SetupScene(); 74 m_scene = new SceneHelpers().SetupScene();
74 SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); 75 SceneHelpers.SetupSceneModules(
76 m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule());
75 77
76 m_engine = new XEngine.XEngine(); 78 m_engine = new XEngine.XEngine();
77 m_engine.Initialise(initConfigSource); 79 m_engine.Initialise(initConfigSource);
@@ -79,13 +81,191 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
79 } 81 }
80 82
81 /// <summary> 83 /// <summary>
84 /// Test creation of an NPC where the appearance data comes from a notecard
85 /// </summary>
86 [Test]
87 public void TestOsNpcCreateUsingAppearanceFromNotecard()
88 {
89 TestHelpers.InMethod();
90
91 // Store an avatar with a different height from default in a notecard.
92 UUID userId = TestHelpers.ParseTail(0x1);
93 float newHeight = 1.9f;
94
95 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
96 sp.Appearance.AvatarHeight = newHeight;
97 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
98 SceneObjectPart part = so.RootPart;
99 m_scene.AddSceneObject(so);
100
101 OSSL_Api osslApi = new OSSL_Api();
102 osslApi.Initialize(m_engine, part, null);
103
104 string notecardName = "appearanceNc";
105 osslApi.osOwnerSaveAppearance(notecardName);
106
107 // Try creating a bot using the appearance in the notecard.
108 string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName);
109 Assert.That(npcRaw, Is.Not.Null);
110
111 UUID npcId = new UUID(npcRaw);
112 ScenePresence npc = m_scene.GetScenePresence(npcId);
113 Assert.That(npc, Is.Not.Null);
114 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
115 }
116
117 [Test]
118 public void TestOsNpcCreateNotExistingNotecard()
119 {
120 TestHelpers.InMethod();
121
122 UUID userId = TestHelpers.ParseTail(0x1);
123
124 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
125 m_scene.AddSceneObject(so);
126
127 OSSL_Api osslApi = new OSSL_Api();
128 osslApi.Initialize(m_engine, so.RootPart, null);
129
130 string npcRaw;
131 bool gotExpectedException = false;
132 try
133 {
134 npcRaw
135 = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
136 }
137 catch (ScriptException)
138 {
139 gotExpectedException = true;
140 }
141
142 Assert.That(gotExpectedException, Is.True);
143 }
144
145 /// <summary>
146 /// Test creation of an NPC where the appearance data comes from an avatar already in the region.
147 /// </summary>
148 [Test]
149 public void TestOsNpcCreateUsingAppearanceFromAvatar()
150 {
151 TestHelpers.InMethod();
152// TestHelpers.EnableLogging();
153
154 // Store an avatar with a different height from default in a notecard.
155 UUID userId = TestHelpers.ParseTail(0x1);
156 float newHeight = 1.9f;
157
158 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
159 sp.Appearance.AvatarHeight = newHeight;
160 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
161 SceneObjectPart part = so.RootPart;
162 m_scene.AddSceneObject(so);
163
164 OSSL_Api osslApi = new OSSL_Api();
165 osslApi.Initialize(m_engine, part, null);
166
167 string notecardName = "appearanceNc";
168 osslApi.osOwnerSaveAppearance(notecardName);
169
170 // Try creating a bot using the existing avatar's appearance
171 string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString());
172 Assert.That(npcRaw, Is.Not.Null);
173
174 UUID npcId = new UUID(npcRaw);
175 ScenePresence npc = m_scene.GetScenePresence(npcId);
176 Assert.That(npc, Is.Not.Null);
177 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight));
178 }
179
180 [Test]
181 public void TestOsNpcLoadAppearance()
182 {
183 TestHelpers.InMethod();
184
185 // Store an avatar with a different height from default in a notecard.
186 UUID userId = TestHelpers.ParseTail(0x1);
187 float firstHeight = 1.9f;
188 float secondHeight = 2.1f;
189 string firstAppearanceNcName = "appearanceNc1";
190 string secondAppearanceNcName = "appearanceNc2";
191
192 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
193 sp.Appearance.AvatarHeight = firstHeight;
194 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
195 SceneObjectPart part = so.RootPart;
196 m_scene.AddSceneObject(so);
197
198 OSSL_Api osslApi = new OSSL_Api();
199 osslApi.Initialize(m_engine, part, null);
200
201 osslApi.osOwnerSaveAppearance(firstAppearanceNcName);
202
203 string npcRaw
204 = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
205
206 // Create a second appearance notecard with a different height
207 sp.Appearance.AvatarHeight = secondHeight;
208 osslApi.osOwnerSaveAppearance(secondAppearanceNcName);
209
210 osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
211
212 UUID npcId = new UUID(npcRaw);
213 ScenePresence npc = m_scene.GetScenePresence(npcId);
214 Assert.That(npc, Is.Not.Null);
215 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight));
216 }
217
218 [Test]
219 public void TestOsNpcLoadAppearanceNotExistingNotecard()
220 {
221 TestHelpers.InMethod();
222
223 // Store an avatar with a different height from default in a notecard.
224 UUID userId = TestHelpers.ParseTail(0x1);
225 float firstHeight = 1.9f;
226 float secondHeight = 2.1f;
227 string firstAppearanceNcName = "appearanceNc1";
228 string secondAppearanceNcName = "appearanceNc2";
229
230 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
231 sp.Appearance.AvatarHeight = firstHeight;
232 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10);
233 SceneObjectPart part = so.RootPart;
234 m_scene.AddSceneObject(so);
235
236 OSSL_Api osslApi = new OSSL_Api();
237 osslApi.Initialize(m_engine, part, null);
238
239 osslApi.osOwnerSaveAppearance(firstAppearanceNcName);
240
241 string npcRaw
242 = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName);
243
244 bool gotExpectedException = false;
245 try
246 {
247 osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName);
248 }
249 catch (ScriptException)
250 {
251 gotExpectedException = true;
252 }
253
254 Assert.That(gotExpectedException, Is.True);
255
256 UUID npcId = new UUID(npcRaw);
257 ScenePresence npc = m_scene.GetScenePresence(npcId);
258 Assert.That(npc, Is.Not.Null);
259 Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(firstHeight));
260 }
261
262 /// <summary>
82 /// Test removal of an owned NPC. 263 /// Test removal of an owned NPC.
83 /// </summary> 264 /// </summary>
84 [Test] 265 [Test]
85 public void TestOsNpcRemoveOwned() 266 public void TestOsNpcRemoveOwned()
86 { 267 {
87 TestHelpers.InMethod(); 268 TestHelpers.InMethod();
88// log4net.Config.XmlConfigurator.Configure();
89 269
90 // Store an avatar with a different height from default in a notecard. 270 // Store an avatar with a different height from default in a notecard.
91 UUID userId = TestHelpers.ParseTail(0x1); 271 UUID userId = TestHelpers.ParseTail(0x1);