aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs112
1 files changed, 62 insertions, 50 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 81477e7..14ef0fb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -260,14 +260,16 @@ namespace OpenSim.Region.Framework.Scenes
260 Items.LockItemsForRead(false); 260 Items.LockItemsForRead(false);
261 } 261 }
262 262
263 /// <summary> 263 public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
264 /// Start all the scripts contained in this prim's inventory
265 /// </summary>
266 public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
267 { 264 {
265 int scriptsValidForStarting = 0;
266
268 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL); 267 List<TaskInventoryItem> scripts = GetInventoryItems(InventoryType.LSL);
269 foreach (TaskInventoryItem item in scripts) 268 foreach (TaskInventoryItem item in scripts)
270 CreateScriptInstance(item, startParam, postOnRez, engine, stateSource); 269 if (CreateScriptInstance(item, startParam, postOnRez, engine, stateSource))
270 scriptsValidForStarting++;
271
272 return scriptsValidForStarting;
271 } 273 }
272 274
273 public ArrayList GetScriptErrors(UUID itemID) 275 public ArrayList GetScriptErrors(UUID itemID)
@@ -310,8 +312,8 @@ namespace OpenSim.Region.Framework.Scenes
310 /// Start a script which is in this prim's inventory. 312 /// Start a script which is in this prim's inventory.
311 /// </summary> 313 /// </summary>
312 /// <param name="item"></param> 314 /// <param name="item"></param>
313 /// <returns></returns> 315 /// <returns>true if the script instance was created, false otherwise</returns>
314 public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource) 316 public bool CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
315 { 317 {
316// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}", 318// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
317// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName); 319// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
@@ -319,61 +321,70 @@ namespace OpenSim.Region.Framework.Scenes
319 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 321 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
320 { 322 {
321 StoreScriptError(item.ItemID, "no permission"); 323 StoreScriptError(item.ItemID, "no permission");
322 return; 324 return false;
323 } 325 }
324 326
325 m_part.AddFlag(PrimFlags.Scripted); 327 m_part.AddFlag(PrimFlags.Scripted);
326 328
327 if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts) 329 if (m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
330 return false;
331
332 if (stateSource == 2 && // Prim crossing
333 m_part.ParentGroup.Scene.m_trustBinaries)
328 { 334 {
329 if (stateSource == 2 && // Prim crossing 335 m_items.LockItemsForWrite(true);
330 m_part.ParentGroup.Scene.m_trustBinaries) 336 m_items[item.ItemID].PermsMask = 0;
331 { 337 m_items[item.ItemID].PermsGranter = UUID.Zero;
332 m_items.LockItemsForWrite(true); 338 m_items.LockItemsForWrite(false);
333 m_items[item.ItemID].PermsMask = 0; 339 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
334 m_items[item.ItemID].PermsGranter = UUID.Zero; 340 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
335 m_items.LockItemsForWrite(false); 341 StoreScriptErrors(item.ItemID, null);
336 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 342 m_part.ParentGroup.AddActiveScriptCount(1);
337 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); 343 m_part.ScheduleFullUpdate();
338 StoreScriptErrors(item.ItemID, null); 344 return true;
339 m_part.ParentGroup.AddActiveScriptCount(1); 345 }
340 m_part.ScheduleFullUpdate();
341 return;
342 }
343 346
344 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString()); 347 AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
345 if (null == asset) 348 if (null == asset)
346 { 349 {
347 string msg = String.Format("asset ID {0} could not be found", item.AssetID); 350 m_log.ErrorFormat(
348 StoreScriptError(item.ItemID, msg); 351 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
349 m_log.ErrorFormat( 352 item.Name, item.ItemID, m_part.AbsolutePosition,
353 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
354
355 return false;
356 }
357 else
358 {
359 if (m_part.ParentGroup.m_savedScriptState != null)
360 item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
361
362 string msg = String.Format("asset ID {0} could not be found", item.AssetID);
363 StoreScriptError(item.ItemID, msg);
364 m_log.ErrorFormat(
350 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 365 "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
351 item.Name, item.ItemID, m_part.AbsolutePosition, 366 item.Name, item.ItemID, m_part.AbsolutePosition,
352 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); 367 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
353 }
354 else
355 {
356 if (m_part.ParentGroup.m_savedScriptState != null)
357 item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
358 368
359 m_items.LockItemsForWrite(true); 369 m_items.LockItemsForWrite(true);
360 370
361 m_items[item.ItemID].OldItemID = item.OldItemID; 371 m_items[item.ItemID].OldItemID = item.OldItemID;
362 m_items[item.ItemID].PermsMask = 0; 372 m_items[item.ItemID].PermsMask = 0;
363 m_items[item.ItemID].PermsGranter = UUID.Zero; 373 m_items[item.ItemID].PermsGranter = UUID.Zero;
364 374
365 m_items.LockItemsForWrite(false); 375 m_items.LockItemsForWrite(false);
366 376
367 string script = Utils.BytesToString(asset.Data); 377 string script = Utils.BytesToString(asset.Data);
368 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 378 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
369 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); 379 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
370 StoreScriptErrors(item.ItemID, null); 380 StoreScriptErrors(item.ItemID, null);
371 if (!item.ScriptRunning) 381 if (!item.ScriptRunning)
372 m_part.ParentGroup.Scene.EventManager.TriggerStopScript( 382 m_part.ParentGroup.Scene.EventManager.TriggerStopScript(
373 m_part.LocalId, item.ItemID); 383 m_part.LocalId, item.ItemID);
374 m_part.ParentGroup.AddActiveScriptCount(1); 384 m_part.ParentGroup.AddActiveScriptCount(1);
375 m_part.ScheduleFullUpdate(); 385 m_part.ScheduleFullUpdate();
376 } 386
387 return true;
377 } 388 }
378 } 389 }
379 390
@@ -446,7 +457,7 @@ namespace OpenSim.Region.Framework.Scenes
446 /// <param name="itemId"> 457 /// <param name="itemId">
447 /// A <see cref="UUID"/> 458 /// A <see cref="UUID"/>
448 /// </param> 459 /// </param>
449 public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 460 public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
450 { 461 {
451 lock (m_scriptErrors) 462 lock (m_scriptErrors)
452 { 463 {
@@ -454,6 +465,7 @@ namespace OpenSim.Region.Framework.Scenes
454 m_scriptErrors.Remove(itemId); 465 m_scriptErrors.Remove(itemId);
455 } 466 }
456 CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource); 467 CreateScriptInstanceInternal(itemId, startParam, postOnRez, engine, stateSource);
468 return true;
457 } 469 }
458 470
459 private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource) 471 private void CreateScriptInstanceInternal(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)