aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework')
-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
4 files changed, 106 insertions, 62 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>