From 1d38510bd283aa1d4e3ecaa280c68beb8e5aa57c Mon Sep 17 00:00:00 2001 From: mingchen Date: Wed, 28 May 2008 23:20:01 +0000 Subject: *Added a Few External Checks relating to scripts including the seperation of runscript into 3 different situations (Rez, start stop) --- .../Region/Environment/Scenes/Scene.Inventory.cs | 20 +++-- .../Environment/Scenes/Scene.PacketHandlers.cs | 6 +- .../Environment/Scenes/SceneExternalChecks.cs | 89 +++++++++++++++++++++- .../Scenes/SceneObjectGroup.Inventory.cs | 1 + 4 files changed, 107 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index f5cb0b9..18f9148 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -1018,13 +1018,16 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart part = GetSceneObjectPart(localID); if (part != null) { - part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); - part.ParentGroup.StartScript(localID, copyID); - part.GetProperties(remoteClient); + if (ExternalChecks.ExternalChecksCanRunScript(item.ID, part.UUID, remoteClient.AgentId)) + { + part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID); + part.ParentGroup.StartScript(localID, copyID); + part.GetProperties(remoteClient); - // m_log.InfoFormat("[PRIMINVENTORY]: " + - // "Rezzed script {0} into prim local ID {1} for user {2}", - // item.inventoryName, localID, remoteClient.Name); + // m_log.InfoFormat("[PRIMINVENTORY]: " + + // "Rezzed script {0} into prim local ID {1} for user {2}", + // item.inventoryName, localID, remoteClient.Name); + } } else { @@ -1076,7 +1079,10 @@ namespace OpenSim.Region.Environment.Scenes part.AddInventoryItem(taskItem); part.GetProperties(remoteClient); - part.StartScript(taskItem); + if (ExternalChecks.ExternalChecksCanRunScript(taskItem.AssetID, part.UUID, remoteClient.AgentId)) + { + part.StartScript(taskItem); + } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index f5fe561..25e36c5 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -295,7 +295,11 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart part=GetSceneObjectPart(objectID); if (part == null) return; - EventManager.TriggerScriptReset(part.LocalId, itemID); + + if (ExternalChecks.ExternalChecksCanResetScript(itemID, remoteClient.AgentId)) + { + EventManager.TriggerScriptReset(part.LocalId, itemID); + } } } } diff --git a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs index 2be5ab9..47dd0bc 100644 --- a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs +++ b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs @@ -582,7 +582,7 @@ namespace OpenSim.Region.Environment.Scenes #endregion - #region RUN SCRIPT + #region RUN SCRIPT (When Script Placed in Object) public delegate bool CanRunScript(LLUUID script, LLUUID objectID, LLUUID user, Scene scene); private List CanRunScriptCheckFunctions = new List(); @@ -611,6 +611,93 @@ namespace OpenSim.Region.Environment.Scenes #endregion + #region START SCRIPT (When Script run box is Checked after placed in object) + public delegate bool CanStartScript(LLUUID script, LLUUID user, Scene scene); + private List CanStartScriptCheckFunctions = new List(); + + public void addCheckStartScript(CanStartScript delegateFunc) + { + if (!CanStartScriptCheckFunctions.Contains(delegateFunc)) + CanStartScriptCheckFunctions.Add(delegateFunc); + } + public void removeCheckStartScript(CanStartScript delegateFunc) + { + if (CanStartScriptCheckFunctions.Contains(delegateFunc)) + CanStartScriptCheckFunctions.Remove(delegateFunc); + } + + public bool ExternalChecksCanStartScript(LLUUID script, LLUUID user) + { + foreach (CanStartScript check in CanStartScriptCheckFunctions) + { + if (check(script, user, m_scene) == false) + { + return false; + } + } + return true; + } + + #endregion + + #region STOP SCRIPT (When Script run box is unchecked after placed in object) + public delegate bool CanStopScript(LLUUID script, LLUUID user, Scene scene); + private List CanStopScriptCheckFunctions = new List(); + + public void addCheckStopScript(CanStopScript delegateFunc) + { + if (!CanStopScriptCheckFunctions.Contains(delegateFunc)) + CanStopScriptCheckFunctions.Add(delegateFunc); + } + public void removeCheckStopScript(CanStopScript delegateFunc) + { + if (CanStopScriptCheckFunctions.Contains(delegateFunc)) + CanStopScriptCheckFunctions.Remove(delegateFunc); + } + + public bool ExternalChecksCanStopScript(LLUUID script, LLUUID user) + { + foreach (CanStopScript check in CanStopScriptCheckFunctions) + { + if (check(script, user, m_scene) == false) + { + return false; + } + } + return true; + } + + #endregion + + #region RESET SCRIPT + public delegate bool CanResetScript(LLUUID script, LLUUID user, Scene scene); + private List CanResetScriptCheckFunctions = new List(); + + public void addCheckResetScript(CanResetScript delegateFunc) + { + if (!CanResetScriptCheckFunctions.Contains(delegateFunc)) + CanResetScriptCheckFunctions.Add(delegateFunc); + } + public void removeCheckResetScript(CanResetScript delegateFunc) + { + if (CanResetScriptCheckFunctions.Contains(delegateFunc)) + CanResetScriptCheckFunctions.Remove(delegateFunc); + } + + public bool ExternalChecksCanResetScript(LLUUID script, LLUUID user) + { + foreach (CanResetScript check in CanResetScriptCheckFunctions) + { + if (check(script, user, m_scene) == false) + { + return false; + } + } + return true; + } + + #endregion + #region TERRAFORM LAND public delegate bool CanTerraformLand(LLUUID user, LLVector3 position, Scene requestFromScene); private List CanTerraformLandCheckFunctions = new List(); diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs index d35765c..c49970f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs @@ -49,6 +49,7 @@ namespace OpenSim.Region.Environment.Scenes SceneObjectPart part = GetChildPart(localID); if (part != null) { + part.StartScript(itemID); } -- cgit v1.1