From 0fa303b1cf244b3066395413e640318b2122c19f Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 20 Jun 2012 00:10:19 +0100
Subject: Log how many scripts are candidates for starting and how many are
actually started.
Adds DebugLevel infrastructure to XEngine though currently commented out and unused.
---
.../Framework/Scenes/SceneObjectPartInventory.cs | 110 +++++++++++----------
1 file changed, 58 insertions(+), 52 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs')
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
}
}
- ///
- /// Start all the scripts contained in this prim's inventory
- ///
- public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
+ public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
{
+ int scriptsValidForStarting = 0;
+
List scripts = GetInventoryItems(InventoryType.LSL);
foreach (TaskInventoryItem item in scripts)
- CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
+ if (CreateScriptInstance(item, startParam, postOnRez, engine, stateSource))
+ scriptsValidForStarting++;
+
+ return scriptsValidForStarting;
}
public ArrayList GetScriptErrors(UUID itemID)
@@ -264,61 +266,65 @@ namespace OpenSim.Region.Framework.Scenes
/// Start a script which is in this prim's inventory.
///
///
- ///
- public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
+ /// true if the script instance was created, false otherwise
+ public bool CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
{
// m_log.DebugFormat("[PRIM INVENTORY]: Starting script {0} {1} in prim {2} {3} in {4}",
// item.Name, item.ItemID, m_part.Name, m_part.UUID, m_part.ParentGroup.Scene.RegionInfo.RegionName);
if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
- return;
+ return false;
m_part.AddFlag(PrimFlags.Scripted);
- if (!m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
+ if (m_part.ParentGroup.Scene.RegionInfo.RegionSettings.DisableScripts)
+ return false;
+
+ if (stateSource == 2 && // Prim crossing
+ m_part.ParentGroup.Scene.m_trustBinaries)
{
- if (stateSource == 2 && // Prim crossing
- m_part.ParentGroup.Scene.m_trustBinaries)
+ lock (m_items)
{
- lock (m_items)
- {
- m_items[item.ItemID].PermsMask = 0;
- m_items[item.ItemID].PermsGranter = UUID.Zero;
- }
-
- m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
- m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
- m_part.ParentGroup.AddActiveScriptCount(1);
- m_part.ScheduleFullUpdate();
- return;
+ m_items[item.ItemID].PermsMask = 0;
+ m_items[item.ItemID].PermsGranter = UUID.Zero;
}
+
+ m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
+ m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
+ m_part.ParentGroup.AddActiveScriptCount(1);
+ m_part.ScheduleFullUpdate();
+ return true;
+ }
- AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
- if (null == asset)
+ AssetBase asset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
+ if (null == asset)
+ {
+ m_log.ErrorFormat(
+ "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
+ item.Name, item.ItemID, m_part.AbsolutePosition,
+ m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
+
+ return false;
+ }
+ else
+ {
+ if (m_part.ParentGroup.m_savedScriptState != null)
+ item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
+
+ lock (m_items)
{
- m_log.ErrorFormat(
- "[PRIM INVENTORY]: Couldn't start script {0}, {1} at {2} in {3} since asset ID {4} could not be found",
- item.Name, item.ItemID, m_part.AbsolutePosition,
- m_part.ParentGroup.Scene.RegionInfo.RegionName, item.AssetID);
+ m_items[item.ItemID].OldItemID = item.OldItemID;
+ m_items[item.ItemID].PermsMask = 0;
+ m_items[item.ItemID].PermsGranter = UUID.Zero;
}
- else
- {
- if (m_part.ParentGroup.m_savedScriptState != null)
- item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
- lock (m_items)
- {
- m_items[item.ItemID].OldItemID = item.OldItemID;
- m_items[item.ItemID].PermsMask = 0;
- m_items[item.ItemID].PermsGranter = UUID.Zero;
- }
+ string script = Utils.BytesToString(asset.Data);
+ m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
+ m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
+ m_part.ParentGroup.AddActiveScriptCount(1);
+ m_part.ScheduleFullUpdate();
- string script = Utils.BytesToString(asset.Data);
- m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
- m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
- m_part.ParentGroup.AddActiveScriptCount(1);
- m_part.ScheduleFullUpdate();
- }
+ return true;
}
}
@@ -384,22 +390,22 @@ namespace OpenSim.Region.Framework.Scenes
return stateID;
}
- ///
- /// Start a script which is in this prim's inventory.
- ///
- ///
- /// A
- ///
- public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
+ public bool CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
{
TaskInventoryItem item = GetInventoryItem(itemId);
if (item != null)
- CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
+ {
+ return CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
+ }
else
+ {
m_log.ErrorFormat(
"[PRIM INVENTORY]: Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
itemId, m_part.Name, m_part.UUID,
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
+
+ return false;
+ }
}
///
--
cgit v1.1