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.cs76
1 files changed, 68 insertions, 8 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 836622d..07d58a1 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -45,6 +45,8 @@ namespace OpenSim.Region.Framework.Scenes
45 45
46 private string m_inventoryFileName = String.Empty; 46 private string m_inventoryFileName = String.Empty;
47 private int m_inventoryFileNameSerial = 0; 47 private int m_inventoryFileNameSerial = 0;
48
49 private Dictionary<UUID, ArrayList> m_scriptErrors = new Dictionary<UUID, ArrayList>();
48 50
49 /// <value> 51 /// <value>
50 /// The part to which the inventory belongs. 52 /// The part to which the inventory belongs.
@@ -210,7 +212,7 @@ namespace OpenSim.Region.Framework.Scenes
210 } 212 }
211 } 213 }
212 214
213 public ArrayList GetScriptErrors(UUID itemID) 215 private ArrayList GetScriptErrors(UUID itemID)
214 { 216 {
215 ArrayList ret = new ArrayList(); 217 ArrayList ret = new ArrayList();
216 218
@@ -269,7 +271,10 @@ namespace OpenSim.Region.Framework.Scenes
269 // item.Name, item.ItemID, Name, UUID); 271 // item.Name, item.ItemID, Name, UUID);
270 272
271 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID)) 273 if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
274 {
275 StoreScriptError(item.ItemID, "no permission");
272 return; 276 return;
277 }
273 278
274 m_part.AddFlag(PrimFlags.Scripted); 279 m_part.AddFlag(PrimFlags.Scripted);
275 280
@@ -284,6 +289,7 @@ namespace OpenSim.Region.Framework.Scenes
284 m_items.LockItemsForWrite(false); 289 m_items.LockItemsForWrite(false);
285 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 290 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
286 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource); 291 m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
292 StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID));
287 m_part.ParentGroup.AddActiveScriptCount(1); 293 m_part.ParentGroup.AddActiveScriptCount(1);
288 m_part.ScheduleFullUpdate(); 294 m_part.ScheduleFullUpdate();
289 return; 295 return;
@@ -293,11 +299,13 @@ namespace OpenSim.Region.Framework.Scenes
293 { 299 {
294 if (null == asset) 300 if (null == asset)
295 { 301 {
302 string msg = String.Format("asset ID {0} could not be found", item.AssetID);
303 StoreScriptError(item.ItemID, msg);
296 m_log.ErrorFormat( 304 m_log.ErrorFormat(
297 "[PRIM INVENTORY]: " + 305 "[PRIM INVENTORY]: " +
298 "Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found", 306 "Couldn't start script {0}, {1} at {2} in {3} since {4}",
299 item.Name, item.ItemID, m_part.AbsolutePosition, 307 item.Name, item.ItemID, m_part.AbsolutePosition,
300 m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID); 308 m_part.ParentGroup.Scene.RegionInfo.RegionName, msg);
301 } 309 }
302 else 310 else
303 { 311 {
@@ -310,11 +318,16 @@ namespace OpenSim.Region.Framework.Scenes
310 string script = Utils.BytesToString(asset.Data); 318 string script = Utils.BytesToString(asset.Data);
311 m_part.ParentGroup.Scene.EventManager.TriggerRezScript( 319 m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
312 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource); 320 m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
321 StoreScriptErrors(item.ItemID, GetScriptErrors(item.ItemID));
313 m_part.ParentGroup.AddActiveScriptCount(1); 322 m_part.ParentGroup.AddActiveScriptCount(1);
314 m_part.ScheduleFullUpdate(); 323 m_part.ScheduleFullUpdate();
315 } 324 }
316 }); 325 });
317 } 326 }
327 else
328 {
329 StoreScriptError(item.ItemID, "scripts disabled");
330 }
318 } 331 }
319 332
320 private void RestoreSavedScriptState(UUID oldID, UUID newID) 333 private void RestoreSavedScriptState(UUID oldID, UUID newID)
@@ -391,24 +404,71 @@ namespace OpenSim.Region.Framework.Scenes
391 else 404 else
392 { 405 {
393 m_items.LockItemsForRead(false); 406 m_items.LockItemsForRead(false);
407 string msg = String.Format("couldn't be found for prim {0}, {1} at {2} in {3}", m_part.Name, m_part.UUID,
408 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
409 StoreScriptError(itemId, msg);
394 m_log.ErrorFormat( 410 m_log.ErrorFormat(
395 "[PRIM INVENTORY]: " + 411 "[PRIM INVENTORY]: " +
396 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}", 412 "Couldn't start script with ID {0} since it {1}", itemId, msg);
397 itemId, m_part.Name, m_part.UUID,
398 m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
399 } 413 }
400 } 414 }
401 else 415 else
402 { 416 {
403 m_items.LockItemsForRead(false); 417 m_items.LockItemsForRead(false);
418 string msg = String.Format("couldn't be found for prim {0}, {1}", m_part.Name, m_part.UUID);
419 StoreScriptError(itemId, msg);
404 m_log.ErrorFormat( 420 m_log.ErrorFormat(
405 "[PRIM INVENTORY]: " + 421 "[PRIM INVENTORY]: " +
406 "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}", 422 "Couldn't start script with ID {0} since it {1}", itemId, msg);
407 itemId, m_part.Name, m_part.UUID);
408 } 423 }
409 424
410 } 425 }
411 426
427 public ArrayList CreateScriptInstanceEr(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
428 {
429 ArrayList errors;
430
431 lock (m_scriptErrors)
432 {
433 m_scriptErrors.Remove(itemId);
434 }
435 CreateScriptInstance(itemId, startParam, postOnRez, engine, stateSource);
436 lock (m_scriptErrors)
437 {
438 while (!m_scriptErrors.TryGetValue(itemId, out errors))
439 {
440 if (!System.Threading.Monitor.Wait(m_scriptErrors, 15000))
441 {
442 m_log.ErrorFormat(
443 "[PRIM INVENTORY]: " +
444 "timedout waiting for script {0} errors", itemId);
445 if (!m_scriptErrors.TryGetValue(itemId, out errors))
446 {
447 errors = new ArrayList(1);
448 errors.Add("timedout waiting for errors");
449 }
450 break;
451 }
452 }
453 m_scriptErrors.Remove(itemId);
454 }
455 return errors;
456 }
457 private void StoreScriptErrors(UUID itemId, ArrayList errors)
458 {
459 lock (m_scriptErrors)
460 {
461 m_scriptErrors[itemId] = errors;
462 System.Threading.Monitor.PulseAll(m_scriptErrors);
463 }
464 }
465 private void StoreScriptError(UUID itemId, string message)
466 {
467 ArrayList errors = new ArrayList(1);
468 errors.Add(message);
469 StoreScriptErrors(itemId, errors);
470 }
471
412 /// <summary> 472 /// <summary>
413 /// Stop a script which is in this prim's inventory. 473 /// Stop a script which is in this prim's inventory.
414 /// </summary> 474 /// </summary>