aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Interfaces/IEntityInventory.cs19
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs110
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs64
5 files changed, 166 insertions, 66 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
index 4370fcc..1c9bdce 100644
--- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
+++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs
@@ -81,7 +81,12 @@ namespace OpenSim.Region.Framework.Interfaces
81 /// <summary> 81 /// <summary>
82 /// Start all the scripts contained in this entity's inventory 82 /// Start all the scripts contained in this entity's inventory
83 /// </summary> 83 /// </summary>
84 void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource); 84 /// <param name="startParam"></param>
85 /// <param name="postOnRez"></param>
86 /// <param name="engine"></param>
87 /// <param name="stateSource"></param>
88 /// <returns>Number of scripts started.</returns>
89 int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource);
85 90
86 ArrayList GetScriptErrors(UUID itemID); 91 ArrayList GetScriptErrors(UUID itemID);
87 void ResumeScripts(); 92 void ResumeScripts();
@@ -102,7 +107,11 @@ namespace OpenSim.Region.Framework.Interfaces
102 /// <param name="postOnRez"></param> 107 /// <param name="postOnRez"></param>
103 /// <param name="engine"></param> 108 /// <param name="engine"></param>
104 /// <param name="stateSource"></param> 109 /// <param name="stateSource"></param>
105 void CreateScriptInstance( 110 /// <returns>
111 /// true if the script instance was valid for starting, false otherwise. This does not guarantee
112 /// that the script was actually started, just that the script was valid (i.e. its asset data could be found, etc.)
113 /// </returns>
114 bool CreateScriptInstance(
106 TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource); 115 TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource);
107 116
108 /// <summary> 117 /// <summary>
@@ -113,7 +122,11 @@ namespace OpenSim.Region.Framework.Interfaces
113 /// <param name="postOnRez"></param> 122 /// <param name="postOnRez"></param>
114 /// <param name="engine"></param> 123 /// <param name="engine"></param>
115 /// <param name="stateSource"></param> 124 /// <param name="stateSource"></param>
116 void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource); 125 /// <returns>
126 /// true if the script instance was valid for starting, false otherwise. This does not guarantee
127 /// that the script was actually started, just that the script was valid (i.e. its asset data could be found, etc.)
128 /// </returns>
129 bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource);
117 130
118 /// <summary> 131 /// <summary>
119 /// Stop a script which is in this prim's inventory. 132 /// Stop a script which is in this prim's inventory.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index b59fd05..e413281 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -60,19 +60,32 @@ namespace OpenSim.Region.Framework.Scenes
60 /// <summary> 60 /// <summary>
61 /// Creates all the scripts in the scene which should be started. 61 /// Creates all the scripts in the scene which should be started.
62 /// </summary> 62 /// </summary>
63 public void CreateScriptInstances() 63 /// <returns>
64 /// Number of scripts that were valid for starting. This does not guarantee that all these scripts
65 /// were actually started, but just that the start could be attempt (e.g. the asset data for the script could be found)
66 /// </returns>
67 public int CreateScriptInstances()
64 { 68 {
65 m_log.Info("[PRIM INVENTORY]: Creating scripts in scene"); 69 m_log.InfoFormat("[SCENE]: Initializing script instances in {0}", RegionInfo.RegionName);
70
71 int scriptsValidForStarting = 0;
66 72
67 EntityBase[] entities = Entities.GetEntities(); 73 EntityBase[] entities = Entities.GetEntities();
68 foreach (EntityBase group in entities) 74 foreach (EntityBase group in entities)
69 { 75 {
70 if (group is SceneObjectGroup) 76 if (group is SceneObjectGroup)
71 { 77 {
72 ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0); 78 scriptsValidForStarting
79 += ((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
73 ((SceneObjectGroup) group).ResumeScripts(); 80 ((SceneObjectGroup) group).ResumeScripts();
74 } 81 }
75 } 82 }
83
84 m_log.InfoFormat(
85 "[SCENE]: Initialized {0} script instances in {1}",
86 scriptsValidForStarting, RegionInfo.RegionName);
87
88 return scriptsValidForStarting;
76 } 89 }
77 90
78 /// <summary> 91 /// <summary>
@@ -80,7 +93,7 @@ namespace OpenSim.Region.Framework.Scenes
80 /// </summary> 93 /// </summary>
81 public void StartScripts() 94 public void StartScripts()
82 { 95 {
83 m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); 96 m_log.InfoFormat("[SCENE]: Starting scripts in {0}, please wait.", RegionInfo.RegionName);
84 97
85 IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>(); 98 IScriptModule[] engines = RequestModuleInterfaces<IScriptModule>();
86 99
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 10012d0..2866b54 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -54,16 +54,28 @@ namespace OpenSim.Region.Framework.Scenes
54 /// <summary> 54 /// <summary>
55 /// Start the scripts contained in all the prims in this group. 55 /// Start the scripts contained in all the prims in this group.
56 /// </summary> 56 /// </summary>
57 public void CreateScriptInstances(int startParam, bool postOnRez, 57 /// <param name="startParam"></param>
58 string engine, int stateSource) 58 /// <param name="postOnRez"></param>
59 /// <param name="engine"></param>
60 /// <param name="stateSource"></param>
61 /// <returns>
62 /// Number of scripts that were valid for starting. This does not guarantee that all these scripts
63 /// were actually started, but just that the start could be attempt (e.g. the asset data for the script could be found)
64 /// </returns>
65 public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
59 { 66 {
67 int scriptsStarted = 0;
68
60 // Don't start scripts if they're turned off in the region! 69 // Don't start scripts if they're turned off in the region!
61 if (!m_scene.RegionInfo.RegionSettings.DisableScripts) 70 if (!m_scene.RegionInfo.RegionSettings.DisableScripts)
62 { 71 {
63 SceneObjectPart[] parts = m_parts.GetArray(); 72 SceneObjectPart[] parts = m_parts.GetArray();
64 for (int i = 0; i < parts.Length; i++) 73 for (int i = 0; i < parts.Length; i++)
65 parts[i].Inventory.CreateScriptInstances(startParam, postOnRez, engine, stateSource); 74 scriptsStarted
75 += parts[i].Inventory.CreateScriptInstances(startParam, postOnRez, engine, stateSource);
66 } 76 }
77
78 return scriptsStarted;
67 } 79 }
68 80
69 /// <summary> 81 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 8810903..c223474 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -217,14 +217,16 @@ namespace OpenSim.Region.Framework.Scenes
217 } 217 }
218 } 218 }
219 219
220 /// <summary> 220 public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
221 /// Start all the scripts contained in this prim's inventory
222 /// </summary>
223 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
224 { 221 {
222 int scriptsValidForStarting = 0;
223
225 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); 224 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
226 foreach (TaskInventoryItem item in scripts) 225 foreach (TaskInventoryItem item in scripts)
227 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); 226 if (CreateScriptInstance(item, startParam, postOnRez, engine, stateSource))
227 scriptsValidForStarting++;
228
229 return scriptsValidForStarting;
228 } 230 }
229 231
230 public ArrayList GetScriptErrors(UUID itemID) 232 public ArrayList GetScriptErrors(UUID itemID)
@@ -264,61 +266,65 @@ namespace OpenSim.Region.Framework.Scenes
264 /// Start a script which is in this prim's inventory. 266 /// Start a script which is in this prim's inventory.
265 /// </summary> 267 /// </summary>
266 /// <param name="item"></param> 268 /// <param name="item"></param>
267 /// <returns></returns> 269 /// <returns>true if the script instance was created, false otherwise</returns>
268 public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource) 270 public bool CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
269 { 271 {
270// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}", 272// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
271// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); 273// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
272 274
273 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 275 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
274 return; 276 return false;
275 277
276 m_part.AddFlag(PrimFlags.Scripted); 278 m_part.AddFlag(PrimFlags.Scripted);
277 279
278 if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) 280 if (m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
281 return false;
282
283 if (stateSource == 2 && // Prim crossing
284 m_part.ParentGroup.Scene.m_trustBinaries)
279 { 285 {
280 if (stateSource == 2 && // Prim crossing 286 lock (m_items)
281 m_part.ParentGroup.Scene.m_trustBinaries)
282 { 287 {
283 lock (m_items) 288 m_items[item.ItemID].PermsMask = 0;
284 { 289 m_items[item.ItemID].PermsGranter = UUID.Zero;
285 m_items[item.ItemID].PermsMask = 0;
286 m_items[item.ItemID].PermsGranter = UUID.Zero;
287 }
288
289 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
290 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
291 m_part.ParentGroup.AddActiveScriptCount(1);
292 m_part.ScheduleFullUpdate();
293 return;
294 } 290 }
291
292 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
293 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
294 m_part.ParentGroup.AddActiveScriptCount(1);
295 m_part.ScheduleFullUpdate();
296 return true;
297 }
295 298
296 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); 299 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
297 if (null == asset) 300 if (null == asset)
301 {
302 m_log.ErrorFormat(
303 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
304 item.Name, item.ItemID, m_part.AbsolutePosition,
305 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
306
307 return false;
308 }
309 else
310 {
311 if (m_part.ParentGroup.m_savedScriptState != null)
312 item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
313
314 lock (m_items)
298 { 315 {
299 m_log.ErrorFormat( 316 m_items[item.ItemID].OldItemID = item.OldItemID;
300 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 317 m_items[item.ItemID].PermsMask = 0;
301 item.Name, item.ItemID, m_part.AbsolutePosition, 318 m_items[item.ItemID].PermsGranter = UUID.Zero;
302 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
303 } 319 }
304 else
305 {
306 if (m_part.ParentGroup.m_savedScriptState != null)
307 item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
308 320
309 lock (m_items) 321 string script = Utils.BytesToString(asset.Data);
310 { 322 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
311 m_items[item.ItemID].OldItemID = item.OldItemID; 323 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
312 m_items[item.ItemID].PermsMask = 0; 324 m_part.ParentGroup.AddActiveScriptCount(1);
313 m_items[item.ItemID].PermsGranter = UUID.Zero; 325 m_part.ScheduleFullUpdate();
314 }
315 326
316 string script = Utils.BytesToString(asset.Data); 327 return true;
317 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
318 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
319 m_part.ParentGroup.AddActiveScriptCount(1);
320 m_part.ScheduleFullUpdate();
321 }
322 } 328 }
323 } 329 }
324 330
@@ -384,22 +390,22 @@ namespace OpenSim.Region.Framework.Scenes
384 return stateID; 390 return stateID;
385 } 391 }
386 392
387 /// <summary> 393 public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
388 /// Start a script which is in this prim's inventory.
389 /// </summary>
390 /// <param name="itemId">
391 /// A <see cref="UUID"/>
392 /// </param>
393 public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
394 { 394 {
395 TaskInventoryItem item = GetInventoryItem(itemId); 395 TaskInventoryItem item = GetInventoryItem(itemId);
396 if (item != null) 396 if (item != null)
397 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); 397 {
398 return CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
399 }
398 else 400 else
401 {
399 m_log.ErrorFormat( 402 m_log.ErrorFormat(
400 "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", 403 "[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
401 itemId, m_part.Name, m_part.UUID, 404 itemId, m_part.Name, m_part.UUID,
402 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName); 405 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
406
407 return false;
408 }
403 } 409 }
404 410
405 /// <summary> 411 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index aedf2c1..3f623de 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -62,6 +62,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
62 { 62 {
63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 63 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
64 64
65 /// <summary>
66 /// Control the printing of certain debug messages.
67 /// </summary>
68 /// <remarks>
69 /// If DebugLevel >= 1, then we log every time that a script is started.
70 /// </remarks>
71// public int DebugLevel { get; set; }
72
65 private SmartThreadPool m_ThreadPool; 73 private SmartThreadPool m_ThreadPool;
66 private int m_MaxScriptQueue; 74 private int m_MaxScriptQueue;
67 private Scene m_Scene; 75 private Scene m_Scene;
@@ -216,9 +224,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
216 AppDomain.CurrentDomain.AssemblyResolve += 224 AppDomain.CurrentDomain.AssemblyResolve +=
217 OnAssemblyResolve; 225 OnAssemblyResolve;
218 226
219 m_log.InfoFormat("[XEngine] Initializing scripts in region {0}",
220 scene.RegionInfo.RegionName);
221 m_Scene = scene; 227 m_Scene = scene;
228 m_log.InfoFormat("[XEngine]: Initializing scripts in region {0}", m_Scene.RegionInfo.RegionName);
222 229
223 m_MinThreads = m_ScriptConfig.GetInt("MinThreads", 2); 230 m_MinThreads = m_ScriptConfig.GetInt("MinThreads", 2);
224 m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); 231 m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100);
@@ -321,9 +328,42 @@ namespace OpenSim.Region.ScriptEngine.XEngine
321 "Starts all stopped scripts." 328 "Starts all stopped scripts."
322 + "If a <script-item-uuid> is given then only that script will be started. Otherwise, all suitable scripts are started.", 329 + "If a <script-item-uuid> is given then only that script will be started. Otherwise, all suitable scripts are started.",
323 (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); 330 (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript));
331
332// MainConsole.Instance.Commands.AddCommand(
333// "Debug", false, "debug xengine", "debug xengine [<level>]",
334// "Turn on detailed xengine debugging.",
335// "If level <= 0, then no extra logging is done.\n"
336// + "If level >= 1, then we log every time that a script is started.",
337// HandleDebugLevelCommand);
324 } 338 }
325 339
326 /// <summary> 340 /// <summary>
341 /// Change debug level
342 /// </summary>
343 /// <param name="module"></param>
344 /// <param name="args"></param>
345// private void HandleDebugLevelCommand(string module, string[] args)
346// {
347// if (args.Length == 3)
348// {
349// int newDebug;
350// if (int.TryParse(args[2], out newDebug))
351// {
352// DebugLevel = newDebug;
353// MainConsole.Instance.OutputFormat("Debug level set to {0}", newDebug);
354// }
355// }
356// else if (args.Length == 2)
357// {
358// MainConsole.Instance.OutputFormat("Current debug level is {0}", DebugLevel);
359// }
360// else
361// {
362// MainConsole.Instance.Output("Usage: debug xengine 0..1");
363// }
364// }
365
366 /// <summary>
327 /// Parse the raw item id into a script instance from the command params if it's present. 367 /// Parse the raw item id into a script instance from the command params if it's present.
328 /// </summary> 368 /// </summary>
329 /// <param name="cmdparams"></param> 369 /// <param name="cmdparams"></param>
@@ -825,8 +865,23 @@ namespace OpenSim.Region.ScriptEngine.XEngine
825 } 865 }
826 866
827 object[] o; 867 object[] o;
868
869 int scriptsStarted = 0;
870
828 while (m_CompileQueue.Dequeue(out o)) 871 while (m_CompileQueue.Dequeue(out o))
829 DoOnRezScript(o); 872 {
873 if (DoOnRezScript(o))
874 {
875 scriptsStarted++;
876
877// if (scriptsStarted % 50 == 0)
878// m_log.DebugFormat(
879// "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
880 }
881 }
882
883 m_log.DebugFormat(
884 "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName);
830 885
831 // NOTE: Despite having a lockless queue, this lock is required 886 // NOTE: Despite having a lockless queue, this lock is required
832 // to make sure there is never no compile thread while there 887 // to make sure there is never no compile thread while there
@@ -1066,7 +1121,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1066 part.ParentGroup.RootPart.Name, 1121 part.ParentGroup.RootPart.Name,
1067 item.Name, startParam, postOnRez, 1122 item.Name, startParam, postOnRez,
1068 stateSource, m_MaxScriptQueue); 1123 stateSource, m_MaxScriptQueue);
1069 1124
1125// if (DebugLevel >= 1)
1070 m_log.DebugFormat( 1126 m_log.DebugFormat(
1071 "[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", 1127 "[XEngine] Loaded script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
1072 part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, 1128 part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,