aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Watchdog.cs6
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs34
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs65
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs23
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs22
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs24
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs9
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs425
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs60
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs178
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs6
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs56
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs10
-rw-r--r--OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs47
25 files changed, 672 insertions, 340 deletions
diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Watchdog.cs
index 68bf477..e091ea0 100644
--- a/OpenSim/Framework/Watchdog.cs
+++ b/OpenSim/Framework/Watchdog.cs
@@ -41,8 +41,8 @@ namespace OpenSim.Framework
41 /// <summary>Timer interval in milliseconds for the watchdog timer</summary> 41 /// <summary>Timer interval in milliseconds for the watchdog timer</summary>
42 const double WATCHDOG_INTERVAL_MS = 2500.0d; 42 const double WATCHDOG_INTERVAL_MS = 2500.0d;
43 43
44 /// <summary>Maximum timeout in milliseconds before a thread is considered dead</summary> 44 /// <summary>Default timeout in milliseconds before a thread is considered dead</summary>
45 public const int WATCHDOG_TIMEOUT_MS = 5000; 45 public const int DEFAULT_WATCHDOG_TIMEOUT_MS = 5000;
46 46
47 [System.Diagnostics.DebuggerDisplay("{Thread.Name}")] 47 [System.Diagnostics.DebuggerDisplay("{Thread.Name}")]
48 public class ThreadWatchdogInfo 48 public class ThreadWatchdogInfo
@@ -122,7 +122,7 @@ namespace OpenSim.Framework
122 public static Thread StartThread( 122 public static Thread StartThread(
123 ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout) 123 ThreadStart start, string name, ThreadPriority priority, bool isBackground, bool alarmIfTimeout)
124 { 124 {
125 return StartThread(start, name, priority, isBackground, alarmIfTimeout, null, WATCHDOG_TIMEOUT_MS); 125 return StartThread(start, name, priority, isBackground, alarmIfTimeout, null, DEFAULT_WATCHDOG_TIMEOUT_MS);
126 } 126 }
127 127
128 /// <summary> 128 /// <summary>
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 9cce725..e55e2c5 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -270,7 +270,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
270 false, 270 false,
271 true, 271 true,
272 GetWatchdogIncomingAlarmData, 272 GetWatchdogIncomingAlarmData,
273 Watchdog.WATCHDOG_TIMEOUT_MS); 273 Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
274 274
275 Watchdog.StartThread( 275 Watchdog.StartThread(
276 OutgoingPacketHandler, 276 OutgoingPacketHandler,
@@ -279,7 +279,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
279 false, 279 false,
280 true, 280 true,
281 GetWatchdogOutgoingAlarmData, 281 GetWatchdogOutgoingAlarmData,
282 Watchdog.WATCHDOG_TIMEOUT_MS); 282 Watchdog.DEFAULT_WATCHDOG_TIMEOUT_MS);
283 283
284 m_elapsedMSSinceLastStatReport = Environment.TickCount; 284 m_elapsedMSSinceLastStatReport = Environment.TickCount;
285 } 285 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index df99d0c..2eb0ac5 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -122,7 +122,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
122 122
123 string attName = "att"; 123 string attName = "att";
124 124
125 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID).ParentGroup; 125 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
126 126
127 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); 127 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false);
128 128
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
index 0545250..396095a 100644
--- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
+++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs
@@ -63,7 +63,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
63 TestHelpers.InMethod(); 63 TestHelpers.InMethod();
64// log4net.Config.XmlConfigurator.Configure(); 64// log4net.Config.XmlConfigurator.Configure();
65 65
66 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 66 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
67 MediaEntry me = new MediaEntry(); 67 MediaEntry me = new MediaEntry();
68 68
69 m_module.SetMediaEntry(part, 1, me); 69 m_module.SetMediaEntry(part, 1, me);
@@ -88,7 +88,7 @@ namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests
88 88
89 string homeUrl = "opensimulator.org"; 89 string homeUrl = "opensimulator.org";
90 90
91 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 91 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
92 MediaEntry me = new MediaEntry() { HomeURL = homeUrl }; 92 MediaEntry me = new MediaEntry() { HomeURL = homeUrl };
93 93
94 m_module.SetMediaEntry(part, 1, me); 94 m_module.SetMediaEntry(part, 1, me);
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 5b03ac7..402b9fb 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -1110,6 +1110,32 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1110 CheckForTerrainUpdates(); 1110 CheckForTerrainUpdates();
1111 } 1111 }
1112 1112
1113 private void InterfaceMinTerrain(Object[] args)
1114 {
1115 int x, y;
1116 for (x = 0; x < m_channel.Width; x++)
1117 {
1118 for (y = 0; y < m_channel.Height; y++)
1119 {
1120 m_channel[x, y] = Math.Max((double)args[0], m_channel[x, y]);
1121 }
1122 }
1123 CheckForTerrainUpdates();
1124 }
1125
1126 private void InterfaceMaxTerrain(Object[] args)
1127 {
1128 int x, y;
1129 for (x = 0; x < m_channel.Width; x++)
1130 {
1131 for (y = 0; y < m_channel.Height; y++)
1132 {
1133 m_channel[x, y] = Math.Min((double)args[0], m_channel[x, y]);
1134 }
1135 }
1136 CheckForTerrainUpdates();
1137 }
1138
1113 private void InterfaceShowDebugStats(Object[] args) 1139 private void InterfaceShowDebugStats(Object[] args)
1114 { 1140 {
1115 double max = Double.MinValue; 1141 double max = Double.MinValue;
@@ -1250,6 +1276,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1250 rescaleCommand.AddArgument("min", "min terrain height after rescaling", "Double"); 1276 rescaleCommand.AddArgument("min", "min terrain height after rescaling", "Double");
1251 rescaleCommand.AddArgument("max", "max terrain height after rescaling", "Double"); 1277 rescaleCommand.AddArgument("max", "max terrain height after rescaling", "Double");
1252 1278
1279 Command minCommand = new Command("min", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMinTerrain, "Sets the minimum terrain height to the specified value.");
1280 minCommand.AddArgument("min", "terrain height to use as minimum", "Double");
1281
1282 Command maxCommand = new Command("max", CommandIntentions.COMMAND_HAZARDOUS, InterfaceMaxTerrain, "Sets the maximum terrain height to the specified value.");
1283 maxCommand.AddArgument("min", "terrain height to use as maximum", "Double");
1284
1253 1285
1254 // Debug 1286 // Debug
1255 Command showDebugStatsCommand = 1287 Command showDebugStatsCommand =
@@ -1281,6 +1313,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1281 m_commander.RegisterCommand("effect", pluginRunCommand); 1313 m_commander.RegisterCommand("effect", pluginRunCommand);
1282 m_commander.RegisterCommand("flip", flipCommand); 1314 m_commander.RegisterCommand("flip", flipCommand);
1283 m_commander.RegisterCommand("rescale", rescaleCommand); 1315 m_commander.RegisterCommand("rescale", rescaleCommand);
1316 m_commander.RegisterCommand("min", minCommand);
1317 m_commander.RegisterCommand("max", maxCommand);
1284 1318
1285 // Add this to our scene so scripts can call these functions 1319 // Add this to our scene so scripts can call these functions
1286 m_scene.RegisterModuleCommander(m_commander); 1320 m_scene.RegisterModuleCommander(m_commander);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 78edeb0..a63ed13 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -120,6 +120,9 @@ namespace OpenSim.Region.Framework.Scenes
120 { 120 {
121 get { return m_defaultDrawDistance; } 121 get { return m_defaultDrawDistance; }
122 } 122 }
123
124 private List<string> m_AllowedViewers = new List<string>();
125 private List<string> m_BannedViewers = new List<string>();
123 126
124 // TODO: need to figure out how allow client agents but deny 127 // TODO: need to figure out how allow client agents but deny
125 // root agents when ACL denies access to root agent 128 // root agents when ACL denies access to root agent
@@ -808,6 +811,24 @@ namespace OpenSim.Region.Framework.Scenes
808 } 811 }
809 } 812 }
810 813
814 string grant = startupConfig.GetString("AllowedViewerList", String.Empty);
815 if (grant.Length > 0)
816 {
817 foreach (string viewer in grant.Split(','))
818 {
819 m_AllowedViewers.Add(viewer.Trim().ToLower());
820 }
821 }
822
823 grant = startupConfig.GetString("BannedViewerList", String.Empty);
824 if (grant.Length > 0)
825 {
826 foreach (string viewer in grant.Split(','))
827 {
828 m_BannedViewers.Add(viewer.Trim().ToLower());
829 }
830 }
831
811 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime); 832 MinFrameTime = startupConfig.GetFloat( "MinFrameTime", MinFrameTime);
812 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup); 833 m_update_backup = startupConfig.GetInt( "UpdateStorageEveryNFrames", m_update_backup);
813 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations); 834 m_update_coarse_locations = startupConfig.GetInt( "UpdateCoarseLocationsEveryNFrames", m_update_coarse_locations);
@@ -3571,6 +3592,50 @@ namespace OpenSim.Region.Framework.Scenes
3571 return false; 3592 return false;
3572 } 3593 }
3573 3594
3595 //Check if the viewer is banned or in the viewer access list
3596 //We check if the substring is listed for higher flexebility
3597 bool ViewerDenied = true;
3598
3599 //Check if the specific viewer is listed in the allowed viewer list
3600 if (m_AllowedViewers.Count > 0)
3601 {
3602 foreach (string viewer in m_AllowedViewers)
3603 {
3604 if (viewer == agent.Viewer.Substring(0, viewer.Length).Trim().ToLower())
3605 {
3606 ViewerDenied = false;
3607 break;
3608 }
3609 }
3610 }
3611 else
3612 {
3613 ViewerDenied = false;
3614 }
3615
3616 //Check if the viewer is in the banned list
3617 if (m_BannedViewers.Count > 0)
3618 {
3619 foreach (string viewer in m_BannedViewers)
3620 {
3621 if (viewer == agent.Viewer.Substring(0, viewer.Length).Trim().ToLower())
3622 {
3623 ViewerDenied = true;
3624 break;
3625 }
3626 }
3627 }
3628
3629 if (ViewerDenied)
3630 {
3631 m_log.DebugFormat(
3632 "[SCENE]: Access denied for {0} {1} using {2}",
3633 agent.firstname, agent.lastname, agent.Viewer);
3634 reason = "Access denied, your viewer is banned by the region owner";
3635 return false;
3636 }
3637
3638
3574 ScenePresence sp = GetScenePresence(agent.AgentID); 3639 ScenePresence sp = GetScenePresence(agent.AgentID);
3575 3640
3576 if (sp != null && !sp.IsChildAgent) 3641 if (sp != null && !sp.IsChildAgent)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 11d703a..3db6710 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -131,6 +131,15 @@ namespace OpenSim.Region.Framework.Scenes
131 } 131 }
132 } 132 }
133 133
134 /// <summary>
135 /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage
136 /// (the database).
137 /// </summary>
138 /// <remarks>
139 /// Ultimately, this should be managed such that region modules can change it at the end of a set of operations
140 /// so that either all changes are preserved or none at all. However, currently, a large amount of internal
141 /// code will set this anyway when some object properties are changed.
142 /// </remarks>
134 public bool HasGroupChanged 143 public bool HasGroupChanged
135 { 144 {
136 set 145 set
@@ -2536,8 +2545,13 @@ namespace OpenSim.Region.Framework.Scenes
2536 } 2545 }
2537 2546
2538 /// <summary> 2547 /// <summary>
2539 /// Schedule a full update for this scene object 2548 /// Schedule a full update for this scene object to all interested viewers.
2540 /// </summary> 2549 /// </summary>
2550 /// <remarks>
2551 /// Ultimately, this should be managed such that region modules can invoke it at the end of a set of operations
2552 /// so that either all changes are sent at once. However, currently, a large amount of internal
2553 /// code will set this anyway when some object properties are changed.
2554 /// </remarks>
2541 public void ScheduleGroupForFullUpdate() 2555 public void ScheduleGroupForFullUpdate()
2542 { 2556 {
2543// if (IsAttachment) 2557// if (IsAttachment)
@@ -2556,8 +2570,13 @@ namespace OpenSim.Region.Framework.Scenes
2556 } 2570 }
2557 2571
2558 /// <summary> 2572 /// <summary>
2559 /// Schedule a terse update for this scene object 2573 /// Schedule a terse update for this scene object to all interested viewers.
2560 /// </summary> 2574 /// </summary>
2575 /// <remarks>
2576 /// Ultimately, this should be managed such that region modules can invoke it at the end of a set of operations
2577 /// so that either all changes are sent at once. However, currently, a large amount of internal
2578 /// code will set this anyway when some object properties are changed.
2579 /// </remarks>
2561 public void ScheduleGroupForTerseUpdate() 2580 public void ScheduleGroupForTerseUpdate()
2562 { 2581 {
2563// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID); 2582// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 14ef0fb..1dff088 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -232,7 +232,7 @@ namespace OpenSim.Region.Framework.Scenes
232 232
233 private void QueryScriptStates() 233 private void QueryScriptStates()
234 { 234 {
235 if (m_part == null || m_part.ParentGroup == null) 235 if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null)
236 return; 236 return;
237 237
238 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 238 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 81add43..3398a53 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -186,15 +186,15 @@ namespace OpenSim.Region.Framework.Scenes.Tests
186 TestHelpers.InMethod(); 186 TestHelpers.InMethod();
187 187
188 TestScene scene = new SceneHelpers().SetupScene(); 188 TestScene scene = new SceneHelpers().SetupScene();
189 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 189 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene);
190 190
191 Assert.That(part.ParentGroup.IsDeleted, Is.False); 191 Assert.That(so.IsDeleted, Is.False);
192 192
193 scene.DeleteSceneObject(part.ParentGroup, false); 193 scene.DeleteSceneObject(so, false);
194 194
195 Assert.That(part.ParentGroup.IsDeleted, Is.True); 195 Assert.That(so.IsDeleted, Is.True);
196 196
197 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 197 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
198 Assert.That(retrievedPart, Is.Null); 198 Assert.That(retrievedPart, Is.Null);
199 } 199 }
200 200
@@ -215,22 +215,22 @@ namespace OpenSim.Region.Framework.Scenes.Tests
215 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 215 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
216 sogd.Enabled = false; 216 sogd.Enabled = false;
217 217
218 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 218 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene);
219 219
220 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; 220 IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient;
221 scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { part.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero); 221 scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero);
222 222
223 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 223 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId);
224 224
225 Assert.That(retrievedPart, Is.Not.Null); 225 Assert.That(retrievedPart, Is.Not.Null);
226 226
227 Assert.That(part.ParentGroup.IsDeleted, Is.False); 227 Assert.That(so.IsDeleted, Is.False);
228 228
229 sogd.InventoryDeQueueAndDelete(); 229 sogd.InventoryDeQueueAndDelete();
230 230
231 Assert.That(part.ParentGroup.IsDeleted, Is.True); 231 Assert.That(so.IsDeleted, Is.True);
232 232
233 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 233 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId);
234 Assert.That(retrievedPart2, Is.Null); 234 Assert.That(retrievedPart2, Is.Null);
235 } 235 }
236 236
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index 1add3dd..0e525c9 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -72,10 +72,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests
72 bool debugtest = false; 72 bool debugtest = false;
73 73
74 Scene scene = new SceneHelpers().SetupScene(); 74 Scene scene = new SceneHelpers().SetupScene();
75 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); 75 SceneObjectGroup grp1 = SceneHelpers.AddSceneObject(scene);
76 SceneObjectGroup grp1 = part1.ParentGroup; 76 SceneObjectPart part1 = grp1.RootPart;
77 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); 77 SceneObjectGroup grp2 = SceneHelpers.AddSceneObject(scene);
78 SceneObjectGroup grp2 = part2.ParentGroup; 78 SceneObjectPart part2 = grp2.RootPart;
79 79
80 grp1.AbsolutePosition = new Vector3(10, 10, 10); 80 grp1.AbsolutePosition = new Vector3(10, 10, 10);
81 grp2.AbsolutePosition = Vector3.Zero; 81 grp2.AbsolutePosition = Vector3.Zero;
@@ -154,14 +154,14 @@ namespace OpenSim.Region.Framework.Scenes.Tests
154 bool debugtest = false; 154 bool debugtest = false;
155 155
156 Scene scene = new SceneHelpers().SetupScene(); 156 Scene scene = new SceneHelpers().SetupScene();
157 SceneObjectPart part1 = SceneHelpers.AddSceneObject(scene); 157 SceneObjectGroup grp1 = SceneHelpers.AddSceneObject(scene);
158 SceneObjectGroup grp1 = part1.ParentGroup; 158 SceneObjectPart part1 = grp1.RootPart;
159 SceneObjectPart part2 = SceneHelpers.AddSceneObject(scene); 159 SceneObjectGroup grp2 = SceneHelpers.AddSceneObject(scene);
160 SceneObjectGroup grp2 = part2.ParentGroup; 160 SceneObjectPart part2 = grp2.RootPart;
161 SceneObjectPart part3 = SceneHelpers.AddSceneObject(scene); 161 SceneObjectGroup grp3 = SceneHelpers.AddSceneObject(scene);
162 SceneObjectGroup grp3 = part3.ParentGroup; 162 SceneObjectPart part3 = grp3.RootPart;
163 SceneObjectPart part4 = SceneHelpers.AddSceneObject(scene); 163 SceneObjectGroup grp4 = SceneHelpers.AddSceneObject(scene);
164 SceneObjectGroup grp4 = part4.ParentGroup; 164 SceneObjectPart part4 = grp4.RootPart;
165 165
166 grp1.AbsolutePosition = new Vector3(10, 10, 10); 166 grp1.AbsolutePosition = new Vector3(10, 10, 10);
167 grp2.AbsolutePosition = Vector3.Zero; 167 grp2.AbsolutePosition = Vector3.Zero;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
index 0a94c19..e931859 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs
@@ -53,7 +53,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
53// log4net.Config.XmlConfigurator.Configure(); 53// log4net.Config.XmlConfigurator.Configure();
54 54
55 Scene scene = new SceneHelpers().SetupScene(); 55 Scene scene = new SceneHelpers().SetupScene();
56 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene).ParentGroup; 56 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene);
57 57
58 g1.GroupResize(new Vector3(2, 3, 4)); 58 g1.GroupResize(new Vector3(2, 3, 4));
59 59
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
index 313e350..ed39be1 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
64 Vector3 startPos = new Vector3(10.1f, 0, 0); 64 Vector3 startPos = new Vector3(10.1f, 0, 0);
65 m_sp.AbsolutePosition = startPos; 65 m_sp.AbsolutePosition = startPos;
66 66
67 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 67 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
68 68
69 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 69 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
70 70
@@ -82,7 +82,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
82 Vector3 startPos = new Vector3(9.9f, 0, 0); 82 Vector3 startPos = new Vector3(9.9f, 0, 0);
83 m_sp.AbsolutePosition = startPos; 83 m_sp.AbsolutePosition = startPos;
84 84
85 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 85 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
86 86
87 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 87 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
88 88
@@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
100 Vector3 startPos = new Vector3(1, 1, 1); 100 Vector3 startPos = new Vector3(1, 1, 1);
101 m_sp.AbsolutePosition = startPos; 101 m_sp.AbsolutePosition = startPos;
102 102
103 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 103 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
104 104
105 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 105 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
106 106
@@ -133,7 +133,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
133 Vector3 startPos = new Vector3(128, 128, 30); 133 Vector3 startPos = new Vector3(128, 128, 30);
134 m_sp.AbsolutePosition = startPos; 134 m_sp.AbsolutePosition = startPos;
135 135
136 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 136 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
137 part.SitTargetPosition = new Vector3(0, 0, 1); 137 part.SitTargetPosition = new Vector3(0, 0, 1);
138 138
139 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero); 139 m_sp.HandleAgentRequestSit(m_sp.ControllingClient, m_sp.UUID, part.UUID, Vector3.Zero);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
index d15141b..a51e4e3 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -128,7 +128,9 @@ namespace OpenSim.Region.Framework.Tests
128 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 128 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
129 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 129 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
130 SceneObjectPart sop1 = sog1.RootPart; 130 SceneObjectPart sop1 = sog1.RootPart;
131 TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); 131 TaskInventoryItem sopItem1
132 = TaskInventoryHelpers.AddNotecard(
133 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900));
132 134
133 InventoryFolderBase folder 135 InventoryFolderBase folder
134 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; 136 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0];
@@ -156,8 +158,11 @@ namespace OpenSim.Region.Framework.Tests
156 Scene scene = new SceneHelpers().SetupScene(); 158 Scene scene = new SceneHelpers().SetupScene();
157 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); 159 UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene);
158 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID); 160 SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, user1.PrincipalID);
161
159 SceneObjectPart sop1 = sog1.RootPart; 162 SceneObjectPart sop1 = sog1.RootPart;
160 TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); 163 TaskInventoryItem sopItem1
164 = TaskInventoryHelpers.AddNotecard(
165 scene, sop1, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900));
161 166
162 // Perform test 167 // Perform test
163 scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); 168 scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID);
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 65dad2d..9179966 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -301,7 +301,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
301 UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); 301 UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
302 302
303 ScenePresence npc = m_scene.GetScenePresence(npcId); 303 ScenePresence npc = m_scene.GetScenePresence(npcId);
304 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 304 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
305 305
306 part.SitTargetPosition = new Vector3(0, 0, 1); 306 part.SitTargetPosition = new Vector3(0, 0, 1);
307 m_npcMod.Sit(npc.UUID, part.UUID, m_scene); 307 m_npcMod.Sit(npc.UUID, part.UUID, m_scene);
@@ -333,7 +333,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
333 UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); 333 UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
334 334
335 ScenePresence npc = m_scene.GetScenePresence(npcId); 335 ScenePresence npc = m_scene.GetScenePresence(npcId);
336 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); 336 SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
337 337
338 m_npcMod.Sit(npc.UUID, part.UUID, m_scene); 338 m_npcMod.Sit(npc.UUID, part.UUID, m_scene);
339 339
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 04c4c00..14dd2ad 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -231,7 +231,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
231 231
232 m_host.AddScriptLPS(1); 232 m_host.AddScriptLPS(1);
233 233
234 if ((item = ScriptByName(name)) != UUID.Zero) 234 if ((item = GetScriptByName(name)) != UUID.Zero)
235 m_ScriptEngine.ResetScript(item); 235 m_ScriptEngine.ResetScript(item);
236 else 236 else
237 ShoutError("llResetOtherScript: script "+name+" not found"); 237 ShoutError("llResetOtherScript: script "+name+" not found");
@@ -243,7 +243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
243 243
244 m_host.AddScriptLPS(1); 244 m_host.AddScriptLPS(1);
245 245
246 if ((item = ScriptByName(name)) != UUID.Zero) 246 if ((item = GetScriptByName(name)) != UUID.Zero)
247 { 247 {
248 return m_ScriptEngine.GetScriptState(item) ?1:0; 248 return m_ScriptEngine.GetScriptState(item) ?1:0;
249 } 249 }
@@ -265,7 +265,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
265 // These functions are supposed to be robust, 265 // These functions are supposed to be robust,
266 // so get the state one step at a time. 266 // so get the state one step at a time.
267 267
268 if ((item = ScriptByName(name)) != UUID.Zero) 268 if ((item = GetScriptByName(name)) != UUID.Zero)
269 { 269 {
270 m_ScriptEngine.SetScriptState(item, run == 0 ? false : true); 270 m_ScriptEngine.SetScriptState(item, run == 0 ? false : true);
271 } 271 }
@@ -3003,68 +3003,72 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3003 { 3003 {
3004 m_host.AddScriptLPS(1); 3004 m_host.AddScriptLPS(1);
3005 3005
3006 Util.FireAndForget(delegate (object x) 3006 Util.FireAndForget(x =>
3007 { 3007 {
3008 if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s)) 3008 if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s))
3009 return; 3009 return;
3010
3010 float dist = (float)llVecDist(llGetPos(), pos); 3011 float dist = (float)llVecDist(llGetPos(), pos);
3011 3012
3012 if (dist > m_ScriptDistanceFactor * 10.0f) 3013 if (dist > m_ScriptDistanceFactor * 10.0f)
3013 return; 3014 return;
3014 3015
3015 //Clone is thread-safe 3016 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory);
3016 TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
3017 3017
3018 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory) 3018 if (item == null)
3019 { 3019 {
3020 if (inv.Value.Name == inventory) 3020 llSay(0, "Could not find object " + inventory);
3021 { 3021 return;
3022 // make sure we're an object. 3022 }
3023 if (inv.Value.InvType != (int)InventoryType.Object)
3024 {
3025 llSay(0, "Unable to create requested object. Object is missing from database.");
3026 return;
3027 }
3028 3023
3029 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); 3024 if (item.InvType != (int)InventoryType.Object)
3030 Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); 3025 {
3026 llSay(0, "Unable to create requested object. Object is missing from database.");
3027 return;
3028 }
3031 3029
3032 // need the magnitude later 3030 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
3033 // float velmag = (float)Util.GetMagnitude(llvel); 3031 Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z);
3034 3032
3035 SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param); 3033 // need the magnitude later
3034 // float velmag = (float)Util.GetMagnitude(llvel);
3036 3035
3037 // If either of these are null, then there was an unknown error. 3036 SceneObjectGroup new_group = World.RezObject(m_host, item, llpos, Rot2Quaternion(rot), llvel, param);
3038 if (new_group == null)
3039 continue;
3040 3037
3041 // objects rezzed with this method are die_at_edge by default. 3038 // If either of these are null, then there was an unknown error.
3042 new_group.RootPart.SetDieAtEdge(true); 3039 if (new_group == null)
3040 return;
3043 3041
3044 new_group.ResumeScripts(); 3042 // objects rezzed with this method are die_at_edge by default.
3043 new_group.RootPart.SetDieAtEdge(true);
3045 3044
3046 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( 3045 new_group.ResumeScripts();
3047 "object_rez", new Object[] {
3048 new LSL_String(
3049 new_group.RootPart.UUID.ToString()) },
3050 new DetectParams[0]));
3051 3046
3052 float groupmass = new_group.GetMass(); 3047 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
3048 "object_rez", new Object[] {
3049 new LSL_String(
3050 new_group.RootPart.UUID.ToString()) },
3051 new DetectParams[0]));
3053 3052
3054 PhysicsActor pa = new_group.RootPart.PhysActor; 3053 // do recoil
3054 SceneObjectGroup hostgrp = m_host.ParentGroup;
3055 if (hostgrp == null)
3056 return;
3055 3057
3056 if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) 3058 if (hostgrp.IsAttachment) // don't recoil avatars
3057 { 3059 return;
3058 // recoil 3060
3059 llvel *= -groupmass; 3061 PhysicsActor pa = new_group.RootPart.PhysActor;
3060 llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); 3062
3061 } 3063 if (pa != null && pa.IsPhysical && llvel != Vector3.Zero)
3062 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) 3064 {
3063 return; 3065 float groupmass = new_group.GetMass();
3064 } 3066 llvel *= -groupmass;
3067 llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0);
3065 } 3068 }
3069 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3070 return;
3066 3071
3067 llSay(0, "Could not find object " + inventory);
3068 }); 3072 });
3069 3073
3070 //ScriptSleep((int)((groupmass * velmag) / 10)); 3074 //ScriptSleep((int)((groupmass * velmag) / 10));
@@ -4213,11 +4217,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4213 public void llGiveInventory(string destination, string inventory) 4217 public void llGiveInventory(string destination, string inventory)
4214 { 4218 {
4215 m_host.AddScriptLPS(1); 4219 m_host.AddScriptLPS(1);
4216 bool found = false; 4220
4217 UUID destId = UUID.Zero; 4221 UUID destId = UUID.Zero;
4218 UUID objId = UUID.Zero;
4219 int assetType = 0;
4220 string objName = String.Empty;
4221 4222
4222 if (!UUID.TryParse(destination, out destId)) 4223 if (!UUID.TryParse(destination, out destId))
4223 { 4224 {
@@ -4225,28 +4226,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4225 return; 4226 return;
4226 } 4227 }
4227 4228
4228 // move the first object found with this inventory name 4229 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory);
4229 m_host.TaskInventory.LockItemsForRead(true);
4230 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
4231 {
4232 if (inv.Value.Name == inventory)
4233 {
4234 found = true;
4235 objId = inv.Key;
4236 assetType = inv.Value.Type;
4237 objName = inv.Value.Name;
4238 break;
4239 }
4240 }
4241 m_host.TaskInventory.LockItemsForRead(false);
4242 4230
4243 if (!found) 4231 if (item == null)
4244 { 4232 {
4245 llSay(0, String.Format("Could not find object '{0}'", inventory)); 4233 llSay(0, String.Format("Could not find object '{0}'", inventory));
4246 return; 4234 return;
4247// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); 4235// throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory));
4248 } 4236 }
4249 4237
4238 UUID objId = item.ItemID;
4239
4250 // check if destination is an object 4240 // check if destination is an object
4251 if (World.GetSceneObjectPart(destId) != null) 4241 if (World.GetSceneObjectPart(destId) != null)
4252 { 4242 {
@@ -4278,14 +4268,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4278 return; 4268 return;
4279 4269
4280 byte[] bucket = new byte[1]; 4270 byte[] bucket = new byte[1];
4281 bucket[0] = (byte)assetType; 4271 bucket[0] = (byte)item.Type;
4282 //byte[] objBytes = agentItem.ID.GetBytes(); 4272 //byte[] objBytes = agentItem.ID.GetBytes();
4283 //Array.Copy(objBytes, 0, bucket, 1, 16); 4273 //Array.Copy(objBytes, 0, bucket, 1, 16);
4284 4274
4285 GridInstantMessage msg = new GridInstantMessage(World, 4275 GridInstantMessage msg = new GridInstantMessage(World,
4286 m_host.OwnerID, m_host.Name, destId, 4276 m_host.OwnerID, m_host.Name, destId,
4287 (byte)InstantMessageDialog.TaskInventoryOffered, 4277 (byte)InstantMessageDialog.TaskInventoryOffered,
4288 false, objName+". "+m_host.Name+" is located at "+ 4278 false, item.Name+". "+m_host.Name+" is located at "+
4289 World.RegionInfo.RegionName+" "+ 4279 World.RegionInfo.RegionName+" "+
4290 m_host.AbsolutePosition.ToString(), 4280 m_host.AbsolutePosition.ToString(),
4291 agentItem.ID, true, m_host.AbsolutePosition, 4281 agentItem.ID, true, m_host.AbsolutePosition,
@@ -4313,27 +4303,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4313 { 4303 {
4314 m_host.AddScriptLPS(1); 4304 m_host.AddScriptLPS(1);
4315 4305
4316 List<TaskInventoryItem> inv; 4306 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
4317 try 4307
4318 { 4308 if (item == null)
4319 m_host.TaskInventory.LockItemsForRead(true); 4309 return;
4320 inv = new List<TaskInventoryItem>(m_host.TaskInventory.Values); 4310
4321 } 4311 if (item.ItemID == m_item.ItemID)
4322 finally 4312 throw new ScriptDeleteException();
4323 { 4313 else
4324 m_host.TaskInventory.LockItemsForRead(false); 4314 m_host.Inventory.RemoveInventoryItem(item.ItemID);
4325 }
4326 foreach (TaskInventoryItem item in inv)
4327 {
4328 if (item.Name == name)
4329 {
4330 if (item.ItemID == m_item.ItemID)
4331 throw new ScriptDeleteException();
4332 else
4333 m_host.Inventory.RemoveInventoryItem(item.ItemID);
4334 return;
4335 }
4336 }
4337 } 4315 }
4338 4316
4339 public void llSetText(string text, LSL_Vector color, double alpha) 4317 public void llSetText(string text, LSL_Vector color, double alpha)
@@ -4481,10 +4459,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4481 { 4459 {
4482 m_host.AddScriptLPS(1); 4460 m_host.AddScriptLPS(1);
4483 4461
4484 //Clone is thread safe 4462 foreach (TaskInventoryItem item in m_host.Inventory.GetInventoryItems())
4485 TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
4486
4487 foreach (TaskInventoryItem item in itemDictionary.Values)
4488 { 4463 {
4489 if (item.Type == 3 && item.Name == name) 4464 if (item.Type == 3 && item.Name == name)
4490 { 4465 {
@@ -4516,6 +4491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4516 return tid.ToString(); 4491 return tid.ToString();
4517 } 4492 }
4518 } 4493 }
4494
4519 ScriptSleep(1000); 4495 ScriptSleep(1000);
4520 return String.Empty; 4496 return String.Empty;
4521 } 4497 }
@@ -4708,19 +4684,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4708 UUID soundId = UUID.Zero; 4684 UUID soundId = UUID.Zero;
4709 if (!UUID.TryParse(impact_sound, out soundId)) 4685 if (!UUID.TryParse(impact_sound, out soundId))
4710 { 4686 {
4711 m_host.TaskInventory.LockItemsForRead(true); 4687 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(impact_sound);
4712 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 4688
4713 { 4689 if (item != null && item.Type == (int)AssetType.Sound)
4714 if (item.Type == (int)AssetType.Sound && item.Name == impact_sound) 4690 soundId = item.AssetID;
4715 {
4716 soundId = item.AssetID;
4717 break;
4718 }
4719 }
4720 m_host.TaskInventory.LockItemsForRead(false);
4721 } 4691 }
4722 m_host.CollisionSoundVolume = (float)impact_volume; 4692
4723 m_host.CollisionSound = soundId; 4693 m_host.CollisionSound = soundId;
4694 m_host.CollisionSoundVolume = (float)impact_volume;
4724 m_host.CollisionSoundType = 1; 4695 m_host.CollisionSoundType = 1;
4725 } 4696 }
4726 4697
@@ -4762,10 +4733,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4762 UUID partItemID; 4733 UUID partItemID;
4763 foreach (SceneObjectPart part in parts) 4734 foreach (SceneObjectPart part in parts)
4764 { 4735 {
4765 //Clone is thread safe 4736 foreach (TaskInventoryItem item in part.Inventory.GetInventoryItems())
4766 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
4767
4768 foreach (TaskInventoryItem item in itemsDictionary.Values)
4769 { 4737 {
4770 if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT) 4738 if (item.Type == ScriptBaseClass.INVENTORY_SCRIPT)
4771 { 4739 {
@@ -5136,22 +5104,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5136 { 5104 {
5137 m_host.AddScriptLPS(1); 5105 m_host.AddScriptLPS(1);
5138 5106
5139 m_host.TaskInventory.LockItemsForRead(true); 5107 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
5140 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 5108
5109 if (item == null)
5110 return UUID.Zero.ToString();
5111
5112 if ((item.CurrentPermissions
5113 & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
5114 == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
5141 { 5115 {
5142 if (inv.Value.Name == name) 5116 return item.AssetID.ToString();
5143 {
5144 if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
5145 {
5146 m_host.TaskInventory.LockItemsForRead(false);
5147 return inv.Value.AssetID.ToString();
5148 }
5149 else
5150 {
5151 m_host.TaskInventory.LockItemsForRead(false);
5152 return UUID.Zero.ToString();
5153 }
5154 }
5155 } 5117 }
5156 m_host.TaskInventory.LockItemsForRead(false); 5118 m_host.TaskInventory.LockItemsForRead(false);
5157 5119
@@ -6774,22 +6736,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6774 } 6736 }
6775 } 6737 }
6776 6738
6777 protected UUID GetTaskInventoryItem(string name)
6778 {
6779 m_host.TaskInventory.LockItemsForRead(true);
6780 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
6781 {
6782 if (inv.Value.Name == name)
6783 {
6784 m_host.TaskInventory.LockItemsForRead(false);
6785 return inv.Key;
6786 }
6787 }
6788 m_host.TaskInventory.LockItemsForRead(false);
6789
6790 return UUID.Zero;
6791 }
6792
6793 public void llGiveInventoryList(string destination, string category, LSL_List inventory) 6739 public void llGiveInventoryList(string destination, string category, LSL_List inventory)
6794 { 6740 {
6795 m_host.AddScriptLPS(1); 6741 m_host.AddScriptLPS(1);
@@ -6802,16 +6748,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6802 6748
6803 foreach (Object item in inventory.Data) 6749 foreach (Object item in inventory.Data)
6804 { 6750 {
6751 string rawItemString = item.ToString();
6752
6805 UUID itemID; 6753 UUID itemID;
6806 if (UUID.TryParse(item.ToString(), out itemID)) 6754 if (UUID.TryParse(rawItemString, out itemID))
6807 { 6755 {
6808 itemList.Add(itemID); 6756 itemList.Add(itemID);
6809 } 6757 }
6810 else 6758 else
6811 { 6759 {
6812 itemID = GetTaskInventoryItem(item.ToString()); 6760 TaskInventoryItem taskItem = m_host.Inventory.GetInventoryItem(rawItemString);
6813 if (itemID != UUID.Zero) 6761
6814 itemList.Add(itemID); 6762 if (taskItem != null)
6763 itemList.Add(taskItem.ItemID);
6815 } 6764 }
6816 } 6765 }
6817 6766
@@ -7133,9 +7082,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7133 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param) 7082 public void llRemoteLoadScriptPin(string target, string name, int pin, int running, int start_param)
7134 { 7083 {
7135 m_host.AddScriptLPS(1); 7084 m_host.AddScriptLPS(1);
7136 bool found = false; 7085
7137 UUID destId = UUID.Zero; 7086 UUID destId = UUID.Zero;
7138 UUID srcId = UUID.Zero;
7139 7087
7140 if (!UUID.TryParse(target, out destId)) 7088 if (!UUID.TryParse(target, out destId))
7141 { 7089 {
@@ -7150,25 +7098,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7150 } 7098 }
7151 7099
7152 // copy the first script found with this inventory name 7100 // copy the first script found with this inventory name
7153 TaskInventoryItem scriptItem = null; 7101 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
7154 m_host.TaskInventory.LockItemsForRead(true);
7155 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
7156 {
7157 if (inv.Value.Name == name)
7158 {
7159 // make sure the object is a script
7160 if (10 == inv.Value.Type)
7161 {
7162 found = true;
7163 srcId = inv.Key;
7164 scriptItem = inv.Value;
7165 break;
7166 }
7167 }
7168 }
7169 m_host.TaskInventory.LockItemsForRead(false);
7170 7102
7171 if (!found) 7103 // make sure the object is a script
7104 if (item == null || item.Type != 10)
7172 { 7105 {
7173 llSay(0, "Could not find script " + name); 7106 llSay(0, "Could not find script " + name);
7174 return; 7107 return;
@@ -7177,13 +7110,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7177 SceneObjectPart dest = World.GetSceneObjectPart(destId); 7110 SceneObjectPart dest = World.GetSceneObjectPart(destId);
7178 if (dest != null) 7111 if (dest != null)
7179 { 7112 {
7180 if ((scriptItem.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID) 7113 if ((item.BasePermissions & (uint)PermissionMask.Transfer) != 0 || dest.ParentGroup.RootPart.OwnerID == m_host.ParentGroup.RootPart.OwnerID)
7181 { 7114 {
7182 // the rest of the permission checks are done in RezScript, so check the pin there as well 7115 // the rest of the permission checks are done in RezScript, so check the pin there as well
7183 World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param); 7116 World.RezScriptFromPrim(item.ItemID, m_host, destId, pin, running, start_param);
7184 7117
7185 if ((scriptItem.BasePermissions & (uint)PermissionMask.Copy) == 0) 7118 if ((item.BasePermissions & (uint)PermissionMask.Copy) == 0)
7186 m_host.Inventory.RemoveInventoryItem(srcId); 7119 m_host.Inventory.RemoveInventoryItem(item.ItemID);
7187 } 7120 }
7188 } 7121 }
7189 // this will cause the delay even if the script pin or permissions were wrong - seems ok 7122 // this will cause the delay even if the script pin or permissions were wrong - seems ok
@@ -10224,92 +10157,82 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10224 } 10157 }
10225 } 10158 }
10226 10159
10227 public LSL_Integer llGetInventoryPermMask(string item, int mask) 10160 public LSL_Integer llGetInventoryPermMask(string itemName, int mask)
10228 { 10161 {
10229 m_host.AddScriptLPS(1); 10162 m_host.AddScriptLPS(1);
10230 10163
10231 m_host.TaskInventory.LockItemsForRead(true); 10164 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
10232 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 10165
10166 if (item == null)
10167 return -1;
10168
10169 switch (mask)
10233 { 10170 {
10234 if (inv.Value.Name == item) 10171 case 0:
10235 { 10172 return (int)item.BasePermissions;
10236 m_host.TaskInventory.LockItemsForRead(false); 10173 case 1:
10237 switch (mask) 10174 return (int)item.CurrentPermissions;
10238 { 10175 case 2:
10239 case 0: 10176 return (int)item.GroupPermissions;
10240 return (int)inv.Value.BasePermissions; 10177 case 3:
10241 case 1: 10178 return (int)item.EveryonePermissions;
10242 return (int)inv.Value.CurrentPermissions; 10179 case 4:
10243 case 2: 10180 return (int)item.NextPermissions;
10244 return (int)inv.Value.GroupPermissions;
10245 case 3:
10246 return (int)inv.Value.EveryonePermissions;
10247 case 4:
10248 return (int)inv.Value.NextPermissions;
10249 }
10250 }
10251 } 10181 }
10252 m_host.TaskInventory.LockItemsForRead(false); 10182 m_host.TaskInventory.LockItemsForRead(false);
10253 10183
10254 return -1; 10184 return -1;
10255 } 10185 }
10256 10186
10257 public void llSetInventoryPermMask(string item, int mask, int value) 10187 public void llSetInventoryPermMask(string itemName, int mask, int value)
10258 { 10188 {
10259 m_host.AddScriptLPS(1); 10189 m_host.AddScriptLPS(1);
10190
10260 if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false)) 10191 if (m_ScriptEngine.Config.GetBoolean("AllowGodFunctions", false))
10261 { 10192 {
10262 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID)) 10193 if (World.Permissions.CanRunConsoleCommand(m_host.OwnerID))
10263 { 10194 {
10264 lock (m_host.TaskInventory) 10195 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
10196
10197 if (item != null)
10265 { 10198 {
10266 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 10199 switch (mask)
10267 { 10200 {
10268 if (inv.Value.Name == item) 10201 case 0:
10269 { 10202 item.BasePermissions = (uint)value;
10270 switch (mask) 10203 break;
10271 { 10204 case 1:
10272 case 0: 10205 item.CurrentPermissions = (uint)value;
10273 inv.Value.BasePermissions = (uint)value; 10206 break;
10274 break; 10207 case 2:
10275 case 1: 10208 item.GroupPermissions = (uint)value;
10276 inv.Value.CurrentPermissions = (uint)value; 10209 break;
10277 break; 10210 case 3:
10278 case 2: 10211 item.EveryonePermissions = (uint)value;
10279 inv.Value.GroupPermissions = (uint)value; 10212 break;
10280 break; 10213 case 4:
10281 case 3: 10214 item.NextPermissions = (uint)value;
10282 inv.Value.EveryonePermissions = (uint)value; 10215 break;
10283 break;
10284 case 4:
10285 inv.Value.NextPermissions = (uint)value;
10286 break;
10287 }
10288 }
10289 } 10216 }
10290 } 10217 }
10291 } 10218 }
10292 } 10219 }
10293 } 10220 }
10294 10221
10295 public LSL_String llGetInventoryCreator(string item) 10222 public LSL_String llGetInventoryCreator(string itemName)
10296 { 10223 {
10297 m_host.AddScriptLPS(1); 10224 m_host.AddScriptLPS(1);
10298 10225
10299 m_host.TaskInventory.LockItemsForRead(true); 10226 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
10300 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 10227
10228 if (item == null)
10301 { 10229 {
10302 if (inv.Value.Name == item) 10230 llSay(0, "No item name '" + item + "'");
10303 {
10304 m_host.TaskInventory.LockItemsForRead(false);
10305 return inv.Value.CreatorID.ToString();
10306 }
10307 }
10308 m_host.TaskInventory.LockItemsForRead(false);
10309 10231
10310 llSay(0, "No item name '" + item + "'"); 10232 return String.Empty;
10233 }
10311 10234
10312 return String.Empty; 10235 return item.CreatorID.ToString();
10313 } 10236 }
10314 10237
10315 public void llOwnerSay(string msg) 10238 public void llOwnerSay(string msg)
@@ -10869,18 +10792,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10869 { 10792 {
10870 m_host.AddScriptLPS(1); 10793 m_host.AddScriptLPS(1);
10871 10794
10872 m_host.TaskInventory.LockItemsForRead(true); 10795 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
10873 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
10874 {
10875 if (inv.Value.Name == name)
10876 {
10877 m_host.TaskInventory.LockItemsForRead(false);
10878 return inv.Value.Type;
10879 }
10880 }
10881 m_host.TaskInventory.LockItemsForRead(false);
10882 10796
10883 return -1; 10797 if (item == null)
10798 return -1;
10799
10800 return item.Type;
10884 } 10801 }
10885 10802
10886 public void llSetPayPrice(int price, LSL_List quick_pay_buttons) 10803 public void llSetPayPrice(int price, LSL_List quick_pay_buttons)
@@ -11766,22 +11683,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11766 return new LSL_List(); 11683 return new LSL_List();
11767 } 11684 }
11768 11685
11769 internal UUID ScriptByName(string name) 11686 internal UUID GetScriptByName(string name)
11770 { 11687 {
11771 m_host.TaskInventory.LockItemsForRead(true); 11688 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
11772
11773 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
11774 {
11775 if (item.Type == 10 && item.Name == name)
11776 {
11777 m_host.TaskInventory.LockItemsForRead(false);
11778 return item.ItemID;
11779 }
11780 }
11781 11689
11782 m_host.TaskInventory.LockItemsForRead(false); 11690 if (item == null || item.Type != 10)
11691 return UUID.Zero;
11783 11692
11784 return UUID.Zero; 11693 return item.ItemID;
11785 } 11694 }
11786 11695
11787 internal void ShoutError(string msg) 11696 internal void ShoutError(string msg)
@@ -11821,21 +11730,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11821 { 11730 {
11822 m_host.AddScriptLPS(1); 11731 m_host.AddScriptLPS(1);
11823 11732
11824 //Clone is thread safe
11825 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
11826
11827 UUID assetID = UUID.Zero; 11733 UUID assetID = UUID.Zero;
11828 11734
11829 if (!UUID.TryParse(name, out assetID)) 11735 if (!UUID.TryParse(name, out assetID))
11830 { 11736 {
11831 foreach (TaskInventoryItem item in itemsDictionary.Values) 11737 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
11832 { 11738
11833 if (item.Type == 7 && item.Name == name) 11739 if (item != null && item.Type == 7)
11834 { 11740 assetID = item.AssetID;
11835 assetID = item.AssetID;
11836 break;
11837 }
11838 }
11839 } 11741 }
11840 11742
11841 if (assetID == UUID.Zero) 11743 if (assetID == UUID.Zero)
@@ -11884,21 +11786,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11884 { 11786 {
11885 m_host.AddScriptLPS(1); 11787 m_host.AddScriptLPS(1);
11886 11788
11887 //Clone is thread safe
11888 TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
11889
11890 UUID assetID = UUID.Zero; 11789 UUID assetID = UUID.Zero;
11891 11790
11892 if (!UUID.TryParse(name, out assetID)) 11791 if (!UUID.TryParse(name, out assetID))
11893 { 11792 {
11894 foreach (TaskInventoryItem item in itemsDictionary.Values) 11793 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(name);
11895 { 11794
11896 if (item.Type == 7 && item.Name == name) 11795 if (item != null && item.Type == 7)
11897 { 11796 assetID = item.AssetID;
11898 assetID = item.AssetID;
11899 break;
11900 }
11901 }
11902 } 11797 }
11903 11798
11904 if (assetID == UUID.Zero) 11799 if (assetID == UUID.Zero)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 795376b..77b659b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -126,7 +126,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
126 [Serializable] 126 [Serializable]
127 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi 127 public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi
128 { 128 {
129// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 129 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
130 130
131 public const string GridInfoServiceConfigSectionName = "GridInfoService"; 131 public const string GridInfoServiceConfigSectionName = "GridInfoService";
132 132
@@ -2136,7 +2136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2136 2136
2137 public LSL_String osFormatString(string str, LSL_List strings) 2137 public LSL_String osFormatString(string str, LSL_List strings)
2138 { 2138 {
2139 CheckThreatLevel(ThreatLevel.Low, "osFormatString"); 2139 CheckThreatLevel(ThreatLevel.VeryLow, "osFormatString");
2140 m_host.AddScriptLPS(1); 2140 m_host.AddScriptLPS(1);
2141 2141
2142 return String.Format(str, strings.Data); 2142 return String.Format(str, strings.Data);
@@ -2144,7 +2144,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2144 2144
2145 public LSL_List osMatchString(string src, string pattern, int start) 2145 public LSL_List osMatchString(string src, string pattern, int start)
2146 { 2146 {
2147 CheckThreatLevel(ThreatLevel.High, "osMatchString"); 2147 CheckThreatLevel(ThreatLevel.VeryLow, "osMatchString");
2148 m_host.AddScriptLPS(1); 2148 m_host.AddScriptLPS(1);
2149 2149
2150 LSL_List result = new LSL_List(); 2150 LSL_List result = new LSL_List();
@@ -2186,7 +2186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2186 2186
2187 public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start) 2187 public LSL_String osReplaceString(string src, string pattern, string replace, int count, int start)
2188 { 2188 {
2189 CheckThreatLevel(ThreatLevel.High, "osReplaceString"); 2189 CheckThreatLevel(ThreatLevel.VeryLow, "osReplaceString");
2190 m_host.AddScriptLPS(1); 2190 m_host.AddScriptLPS(1);
2191 2191
2192 // Normalize indices (if negative). 2192 // Normalize indices (if negative).
@@ -3199,6 +3199,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3199 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint); 3199 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3200 } 3200 }
3201 3201
3202 public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
3203 {
3204 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatarFromInventory");
3205
3206 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3207
3208 if (attachmentsModule == null)
3209 return;
3210
3211 m_host.AddScriptLPS(1);
3212
3213 InitLSL();
3214
3215 TaskInventoryItem item = m_host.Inventory.GetInventoryItem(itemName);
3216
3217 if (item == null)
3218 {
3219 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Could not find object '{0}'", itemName));
3220 throw new Exception(String.Format("The inventory item '{0}' could not be found", itemName));
3221 }
3222
3223 if (item.InvType != (int)InventoryType.Object)
3224 {
3225 // FIXME: Temporary null check for regression tests since they dont' have the infrastructure to set
3226 // up the api reference.
3227 if (m_LSL_Api != null)
3228 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName));
3229
3230 throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName));
3231
3232 return;
3233 }
3234
3235 ScenePresence sp = World.GetScenePresence(m_host.OwnerID);
3236
3237 if (sp == null)
3238 return;
3239
3240 InventoryItemBase newItem = World.MoveTaskInventoryItem(sp.UUID, UUID.Zero, m_host, item.ItemID);
3241
3242 if (newItem == null)
3243 {
3244 m_log.ErrorFormat(
3245 "[OSSL API]: Could not create user inventory item {0} for {1}, attach point {2} in {3}",
3246 itemName, m_host.Name, attachmentPoint, World.Name);
3247
3248 return;
3249 }
3250
3251 attachmentsModule.RezSingleAttachmentFromInventory(sp, newItem.ID, (uint)attachmentPoint);
3252 }
3253
3202 public void osForceDetachFromAvatar() 3254 public void osForceDetachFromAvatar()
3203 { 3255 {
3204 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar"); 3256 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 7382495..a790cdc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -107,6 +107,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
107 void osForceAttachToAvatar(int attachment); 107 void osForceAttachToAvatar(int attachment);
108 108
109 /// <summary> 109 /// <summary>
110 /// Attach the inventory item in the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH
111 /// </summary>
112 /// <param name='itemName'>Tha name of the item. If this is not found then a warning is said to the owner</param>
113 /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
114 void osForceAttachToAvatarFromInventory(string itemName, int attachment);
115
116 /// <summary>
110 /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH 117 /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
111 /// </summary> 118 /// </summary>
112 /// <remarks>Nothing happens if the object is not attached.</remarks> 119 /// <remarks>Nothing happens if the object is not attached.</remarks>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index d230662..500ed96 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -296,6 +296,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
296 m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint); 296 m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint);
297 } 297 }
298 298
299 public void osForceAttachToAvatarFromInventory(string itemName, int attachmentPoint)
300 {
301 m_OSSL_Functions.osForceAttachToAvatarFromInventory(itemName, attachmentPoint);
302 }
303
299 public void osForceDetachFromAvatar() 304 public void osForceDetachFromAvatar()
300 { 305 {
301 m_OSSL_Functions.osForceDetachFromAvatar(); 306 m_OSSL_Functions.osForceDetachFromAvatar();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
index bc3b790..2565ae7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
@@ -89,7 +89,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
89 89
90 // FIXME: This should really be a script item (with accompanying script) 90 // FIXME: This should really be a script item (with accompanying script)
91 TaskInventoryItem grp1Item 91 TaskInventoryItem grp1Item
92 = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart); 92 = TaskInventoryHelpers.AddNotecard(
93 m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900));
93 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 94 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
94 95
95 SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20); 96 SceneObjectGroup grp2 = SceneHelpers.CreateSceneObject(2, ownerId, "grp2-", 0x20);
@@ -122,7 +123,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
122 123
123 // FIXME: This should really be a script item (with accompanying script) 124 // FIXME: This should really be a script item (with accompanying script)
124 TaskInventoryItem grp1Item 125 TaskInventoryItem grp1Item
125 = TaskInventoryHelpers.AddNotecard(m_scene, grp1.RootPart); 126 = TaskInventoryHelpers.AddNotecard(
127 m_scene, grp1.RootPart, "ncItem", TestHelpers.ParseTail(0x800), TestHelpers.ParseTail(0x900));
128
126 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS; 129 grp1Item.PermsMask |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
127 130
128 LSL_Api apiGrp1 = new LSL_Api(); 131 LSL_Api apiGrp1 = new LSL_Api();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index f96a156..c41d1e7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
59 config.Set("Enabled", "true"); 59 config.Set("Enabled", "true");
60 60
61 Scene scene = new SceneHelpers().SetupScene(); 61 Scene scene = new SceneHelpers().SetupScene();
62 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 62 SceneObjectPart part = SceneHelpers.AddSceneObject(scene).RootPart;
63 63
64 XEngine.XEngine engine = new XEngine.XEngine(); 64 XEngine.XEngine engine = new XEngine.XEngine();
65 engine.Initialise(initConfigSource); 65 engine.Initialise(initConfigSource);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs
new file mode 100644
index 0000000..537b8aa
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAttachmentTests.cs
@@ -0,0 +1,178 @@
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.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using log4net;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Assets;
37using OpenMetaverse.StructuredData;
38using OpenSim.Framework;
39using OpenSim.Region.CoreModules.Avatar.Attachments;
40using OpenSim.Region.CoreModules.Framework.InventoryAccess;
41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.ScriptEngine.Shared;
43using OpenSim.Region.ScriptEngine.Shared.Api;
44using OpenSim.Services.Interfaces;
45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock;
47
48namespace OpenSim.Region.ScriptEngine.Shared.Tests
49{
50 /// <summary>
51 /// Tests for OSSL attachment functions
52 /// </summary>
53 /// <remarks>
54 /// TODO: Add tests for all functions
55 /// </remarks>
56 [TestFixture]
57 public class OSSL_ApiAttachmentTests : OpenSimTestCase
58 {
59 protected Scene m_scene;
60 protected XEngine.XEngine m_engine;
61
62 [SetUp]
63 public override void SetUp()
64 {
65 base.SetUp();
66
67 IConfigSource initConfigSource = new IniConfigSource();
68
69 IConfig xengineConfig = initConfigSource.AddConfig("XEngine");
70 xengineConfig.Set("Enabled", "true");
71 xengineConfig.Set("AllowOSFunctions", "true");
72 xengineConfig.Set("OSFunctionThreatLevel", "Severe");
73
74 IConfig modulesConfig = initConfigSource.AddConfig("Modules");
75 modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");
76
77 m_scene = new SceneHelpers().SetupScene();
78 SceneHelpers.SetupSceneModules(
79 m_scene, initConfigSource, new AttachmentsModule(), new BasicInventoryAccessModule());
80
81 m_engine = new XEngine.XEngine();
82 m_engine.Initialise(initConfigSource);
83 m_engine.AddRegion(m_scene);
84 }
85
86 [Test]
87 public void TestOsForceAttachToAvatarFromInventory()
88 {
89 TestHelpers.InMethod();
90// TestHelpers.EnableLogging();
91
92 string taskInvObjItemName = "sphere";
93 UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
94 AttachmentPoint attachPoint = AttachmentPoint.Chin;
95
96 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1);
97 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID);
98 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID);
99 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart);
100
101 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem);
102 OSSL_Api osslApi = new OSSL_Api();
103 osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem);
104
105// SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID);
106
107 // Create an object embedded inside the first
108 TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID);
109
110 osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint);
111
112 // Check scene presence status
113 Assert.That(sp.HasAttachments(), Is.True);
114 List<SceneObjectGroup> attachments = sp.GetAttachments();
115 Assert.That(attachments.Count, Is.EqualTo(1));
116 SceneObjectGroup attSo = attachments[0];
117 Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName));
118 Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint));
119 Assert.That(attSo.IsAttachment);
120 Assert.That(attSo.UsesPhysics, Is.False);
121 Assert.That(attSo.IsTemporary, Is.False);
122
123 // Check appearance status
124 List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments();
125 Assert.That(attachmentsInAppearance.Count, Is.EqualTo(1));
126 Assert.That(sp.Appearance.GetAttachpoint(attachmentsInAppearance[0].ItemID), Is.EqualTo((uint)attachPoint));
127 }
128
129 /// <summary>
130 /// Make sure we can't force attach anything other than objects.
131 /// </summary>
132 [Test]
133 public void TestOsForceAttachToAvatarFromInventoryNotObject()
134 {
135 TestHelpers.InMethod();
136// TestHelpers.EnableLogging();
137
138 string taskInvObjItemName = "sphere";
139 UUID taskInvObjItemId = UUID.Parse("00000000-0000-0000-0000-100000000000");
140 AttachmentPoint attachPoint = AttachmentPoint.Chin;
141
142 UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1);
143 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID);
144 SceneObjectGroup inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID);
145 TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart);
146
147 new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem);
148 OSSL_Api osslApi = new OSSL_Api();
149 osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem);
150
151 // Create an object embedded inside the first
152 TaskInventoryHelpers.AddNotecard(
153 m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900));
154
155 bool exceptionCaught = false;
156
157 try
158 {
159 osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint);
160 }
161 catch (Exception e)
162 {
163 exceptionCaught = true;
164 }
165
166 Assert.That(exceptionCaught, Is.True);
167
168 // Check scene presence status
169 Assert.That(sp.HasAttachments(), Is.False);
170 List<SceneObjectGroup> attachments = sp.GetAttachments();
171 Assert.That(attachments.Count, Is.EqualTo(0));
172
173 // Check appearance status
174 List<AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments();
175 Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0));
176 }
177 }
178} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index 0ccd889..813e53b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -52,14 +52,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
52 /// Tests for OSSL NPC API 52 /// Tests for OSSL NPC API
53 /// </summary> 53 /// </summary>
54 [TestFixture] 54 [TestFixture]
55 public class OSSL_NpcApiAppearanceTest 55 public class OSSL_NpcApiAppearanceTest : OpenSimTestCase
56 { 56 {
57 protected Scene m_scene; 57 protected Scene m_scene;
58 protected XEngine.XEngine m_engine; 58 protected XEngine.XEngine m_engine;
59 59
60 [SetUp] 60 [SetUp]
61 public void SetUp() 61 public override void SetUp()
62 { 62 {
63 base.SetUp();
64
63 IConfigSource initConfigSource = new IniConfigSource(); 65 IConfigSource initConfigSource = new IniConfigSource();
64 IConfig config = initConfigSource.AddConfig("XEngine"); 66 IConfig config = initConfigSource.AddConfig("XEngine");
65 config.Set("Enabled", "true"); 67 config.Set("Enabled", "true");
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 06e05a9..ed887d9 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -258,7 +258,9 @@ namespace OpenSim.Services.LLLoginService
258 258
259 if (!am.Success) 259 if (!am.Success)
260 { 260 {
261 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: client {0} is not allowed", clientVersion); 261 m_log.InfoFormat(
262 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: client {2} is not allowed",
263 firstName, lastName, clientVersion);
262 return LLFailedLoginResponse.LoginBlockedProblem; 264 return LLFailedLoginResponse.LoginBlockedProblem;
263 } 265 }
264 } 266 }
@@ -270,7 +272,9 @@ namespace OpenSim.Services.LLLoginService
270 272
271 if (dm.Success) 273 if (dm.Success)
272 { 274 {
273 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: client {0} is denied", clientVersion); 275 m_log.InfoFormat(
276 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: client {2} is denied",
277 firstName, lastName, clientVersion);
274 return LLFailedLoginResponse.LoginBlockedProblem; 278 return LLFailedLoginResponse.LoginBlockedProblem;
275 } 279 }
276 } 280 }
@@ -281,7 +285,8 @@ namespace OpenSim.Services.LLLoginService
281 UserAccount account = m_UserAccountService.GetUserAccount(scopeID, firstName, lastName); 285 UserAccount account = m_UserAccountService.GetUserAccount(scopeID, firstName, lastName);
282 if (account == null) 286 if (account == null)
283 { 287 {
284 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); 288 m_log.InfoFormat(
289 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: user not found", firstName, lastName);
285 return LLFailedLoginResponse.UserProblem; 290 return LLFailedLoginResponse.UserProblem;
286 } 291 }
287 292
@@ -293,7 +298,9 @@ namespace OpenSim.Services.LLLoginService
293 298
294 if (account.UserLevel < m_MinLoginLevel) 299 if (account.UserLevel < m_MinLoginLevel)
295 { 300 {
296 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: login is blocked for user level {0}", account.UserLevel); 301 m_log.InfoFormat(
302 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: user level is {2} but minimum login level is {3}",
303 firstName, lastName, m_MinLoginLevel, account.UserLevel);
297 return LLFailedLoginResponse.LoginBlockedProblem; 304 return LLFailedLoginResponse.LoginBlockedProblem;
298 } 305 }
299 306
@@ -304,7 +311,8 @@ namespace OpenSim.Services.LLLoginService
304 { 311 {
305 if (account.ScopeID != scopeID && account.ScopeID != UUID.Zero) 312 if (account.ScopeID != scopeID && account.ScopeID != UUID.Zero)
306 { 313 {
307 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); 314 m_log.InfoFormat(
315 "[LLOGIN SERVICE]: Login failed, reason: user {0} {1} not found", firstName, lastName);
308 return LLFailedLoginResponse.UserProblem; 316 return LLFailedLoginResponse.UserProblem;
309 } 317 }
310 } 318 }
@@ -323,7 +331,9 @@ namespace OpenSim.Services.LLLoginService
323 UUID secureSession = UUID.Zero; 331 UUID secureSession = UUID.Zero;
324 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) 332 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
325 { 333 {
326 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed"); 334 m_log.InfoFormat(
335 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: authentication failed",
336 firstName, lastName);
327 return LLFailedLoginResponse.UserProblem; 337 return LLFailedLoginResponse.UserProblem;
328 } 338 }
329 339
@@ -332,13 +342,18 @@ namespace OpenSim.Services.LLLoginService
332 // 342 //
333 if (m_RequireInventory && m_InventoryService == null) 343 if (m_RequireInventory && m_InventoryService == null)
334 { 344 {
335 m_log.WarnFormat("[LLOGIN SERVICE]: Login failed, reason: inventory service not set up"); 345 m_log.WarnFormat(
346 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: inventory service not set up",
347 firstName, lastName);
336 return LLFailedLoginResponse.InventoryProblem; 348 return LLFailedLoginResponse.InventoryProblem;
337 } 349 }
350
338 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); 351 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
339 if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0))) 352 if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
340 { 353 {
341 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory"); 354 m_log.InfoFormat(
355 "[LLOGIN SERVICE]: Login failed, for {0} {1}, reason: unable to retrieve user inventory",
356 firstName, lastName);
342 return LLFailedLoginResponse.InventoryProblem; 357 return LLFailedLoginResponse.InventoryProblem;
343 } 358 }
344 359
@@ -352,9 +367,12 @@ namespace OpenSim.Services.LLLoginService
352 if (m_PresenceService != null) 367 if (m_PresenceService != null)
353 { 368 {
354 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); 369 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
370
355 if (!success) 371 if (!success)
356 { 372 {
357 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence"); 373 m_log.InfoFormat(
374 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: could not login presence",
375 firstName, lastName);
358 return LLFailedLoginResponse.GridProblem; 376 return LLFailedLoginResponse.GridProblem;
359 } 377 }
360 } 378 }
@@ -387,9 +405,18 @@ namespace OpenSim.Services.LLLoginService
387 if (destination == null) 405 if (destination == null)
388 { 406 {
389 m_PresenceService.LogoutAgent(session); 407 m_PresenceService.LogoutAgent(session);
390 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found"); 408
409 m_log.InfoFormat(
410 "[LLOGIN SERVICE]: Login failed for {0} {1}, reason: destination not found",
411 firstName, lastName);
391 return LLFailedLoginResponse.GridProblem; 412 return LLFailedLoginResponse.GridProblem;
392 } 413 }
414 else
415 {
416 m_log.DebugFormat(
417 "[LLOGIN SERVICE]: Found destination {0}, endpoint {1} for {2} {3}",
418 destination.RegionName, destination.ExternalEndPoint, firstName, lastName);
419 }
393 420
394 if (account.UserLevel >= 200) 421 if (account.UserLevel >= 200)
395 flags |= TeleportFlags.Godlike; 422 flags |= TeleportFlags.Godlike;
@@ -413,7 +440,7 @@ namespace OpenSim.Services.LLLoginService
413 if (aCircuit == null) 440 if (aCircuit == null)
414 { 441 {
415 m_PresenceService.LogoutAgent(session); 442 m_PresenceService.LogoutAgent(session);
416 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason); 443 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed for {0} {1}, reason: {2}", firstName, lastName, reason);
417 return new LLFailedLoginResponse("key", reason, "false"); 444 return new LLFailedLoginResponse("key", reason, "false");
418 445
419 } 446 }
@@ -434,7 +461,8 @@ namespace OpenSim.Services.LLLoginService
434 where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, 461 where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP,
435 m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone); 462 m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency, m_DSTZone);
436 463
437 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to client."); 464 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to {0} {1}", firstName, lastName);
465
438 return response; 466 return response;
439 } 467 }
440 catch (Exception e) 468 catch (Exception e)
@@ -453,7 +481,9 @@ namespace OpenSim.Services.LLLoginService
453 { 481 {
454 flags = TeleportFlags.ViaLogin; 482 flags = TeleportFlags.ViaLogin;
455 483
456 m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); 484 m_log.DebugFormat(
485 "[LLOGIN SERVICE]: Finding destination matching start location {0} for {1}",
486 startLocation, account.Name);
457 487
458 gatekeeper = null; 488 gatekeeper = null;
459 where = "home"; 489 where = "home";
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index 239afc0..3a2e420 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -564,7 +564,7 @@ namespace OpenSim.Tests.Common
564 /// </summary> 564 /// </summary>
565 /// <param name="scene"></param> 565 /// <param name="scene"></param>
566 /// <returns></returns> 566 /// <returns></returns>
567 public static SceneObjectPart AddSceneObject(Scene scene) 567 public static SceneObjectGroup AddSceneObject(Scene scene)
568 { 568 {
569 return AddSceneObject(scene, "Test Object", UUID.Zero); 569 return AddSceneObject(scene, "Test Object", UUID.Zero);
570 } 570 }
@@ -576,16 +576,16 @@ namespace OpenSim.Tests.Common
576 /// <param name="name"></param> 576 /// <param name="name"></param>
577 /// <param name="ownerId"></param> 577 /// <param name="ownerId"></param>
578 /// <returns></returns> 578 /// <returns></returns>
579 public static SceneObjectPart AddSceneObject(Scene scene, string name, UUID ownerId) 579 public static SceneObjectGroup AddSceneObject(Scene scene, string name, UUID ownerId)
580 { 580 {
581 SceneObjectPart part = CreateSceneObjectPart(name, UUID.Random(), ownerId); 581 SceneObjectGroup so = new SceneObjectGroup(CreateSceneObjectPart(name, UUID.Random(), ownerId));
582 582
583 //part.UpdatePrimFlags(false, false, true); 583 //part.UpdatePrimFlags(false, false, true);
584 //part.ObjectFlags |= (uint)PrimFlags.Phantom; 584 //part.ObjectFlags |= (uint)PrimFlags.Phantom;
585 585
586 scene.AddNewSceneObject(new SceneObjectGroup(part), false); 586 scene.AddNewSceneObject(so, false);
587 587
588 return part; 588 return so;
589 } 589 }
590 590
591 /// <summary> 591 /// <summary>
diff --git a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
index 7058d1e..9607f1f 100644
--- a/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/TaskInventoryHelpers.cs
@@ -45,20 +45,23 @@ namespace OpenSim.Tests.Common
45 /// </summary> 45 /// </summary>
46 /// <param name="scene"></param> 46 /// <param name="scene"></param>
47 /// <param name="part"></param> 47 /// <param name="part"></param>
48 /// <param name="itemName"></param>
49 /// <param name="itemID"></param>
50 /// <param name="assetID"></param>
48 /// <returns>The item that was added</returns> 51 /// <returns>The item that was added</returns>
49 public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part) 52 public static TaskInventoryItem AddNotecard(Scene scene, SceneObjectPart part, string itemName, UUID itemID, UUID assetID)
50 { 53 {
51 AssetNotecard nc = new AssetNotecard(); 54 AssetNotecard nc = new AssetNotecard();
52 nc.BodyText = "Hello World!"; 55 nc.BodyText = "Hello World!";
53 nc.Encode(); 56 nc.Encode();
54 UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); 57
55 UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
56 AssetBase ncAsset 58 AssetBase ncAsset
57 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); 59 = AssetHelpers.CreateAsset(assetID, AssetType.Notecard, nc.AssetData, UUID.Zero);
58 scene.AssetService.Store(ncAsset); 60 scene.AssetService.Store(ncAsset);
61
59 TaskInventoryItem ncItem 62 TaskInventoryItem ncItem
60 = new TaskInventoryItem 63 = new TaskInventoryItem
61 { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, 64 { Name = itemName, AssetID = assetID, ItemID = itemID,
62 Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; 65 Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard };
63 part.Inventory.AddInventoryItem(ncItem, true); 66 part.Inventory.AddInventoryItem(ncItem, true);
64 67
@@ -66,8 +69,42 @@ namespace OpenSim.Tests.Common
66 } 69 }
67 70
68 /// <summary> 71 /// <summary>
72 /// Add a blank script to the given part.
73 /// </summary>
74 /// <remarks>
75 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
76 /// functions more than once in a test.
77 /// </remarks>
78 /// <param name="scene"></param>
79 /// <param name="part"></param>
80 /// <returns>The item that was added</returns>
81 public static TaskInventoryItem AddScript(Scene scene, SceneObjectPart part)
82 {
83 AssetScriptText ast = new AssetScriptText();
84 ast.Encode();
85
86 UUID assetUuid = new UUID("00000000-0000-0000-1000-000000000000");
87 UUID itemUuid = new UUID("00000000-0000-0000-1100-000000000000");
88 AssetBase asset
89 = AssetHelpers.CreateAsset(assetUuid, AssetType.LSLText, ast.AssetData, UUID.Zero);
90 scene.AssetService.Store(asset);
91 TaskInventoryItem item
92 = new TaskInventoryItem
93 { Name = "scriptItem", AssetID = assetUuid, ItemID = itemUuid,
94 Type = (int)AssetType.LSLText, InvType = (int)InventoryType.LSL };
95 part.Inventory.AddInventoryItem(item, true);
96
97 return item;
98 }
99
100 /// <summary>
69 /// Add a scene object item to the given part. 101 /// Add a scene object item to the given part.
70 /// </summary> 102 /// </summary>
103 /// <remarks>
104 /// TODO: Accept input for item and asset IDs to avoid mysterious script failures that try to use any of these
105 /// functions more than once in a test.
106 /// </remarks>
107 ///
71 /// <param name="scene"></param> 108 /// <param name="scene"></param>
72 /// <param name="sop"></param> 109 /// <param name="sop"></param>
73 /// <param name="itemName"></param> 110 /// <param name="itemName"></param>