From 9a0ef22ed979433f4d017a252173f38fe5e56892 Mon Sep 17 00:00:00 2001
From: Charles Krinke
Date: Sat, 28 Jun 2008 16:08:12 +0000
Subject: Mantis#1616. Applied Melanie's patch. This may or may not break
trunk.
---
.../Region/Environment/Interfaces/IScriptModule.cs | 38 +++++++++
.../Environment/Modules/World/NPC/NPCAvatar.cs | 6 ++
.../Modules/World/Permissions/PermissionsModule.cs | 3 +-
OpenSim/Region/Environment/Scenes/EventManager.cs | 37 ++++++---
OpenSim/Region/Environment/Scenes/InnerScene.cs | 2 +-
.../Region/Environment/Scenes/Scene.Inventory.cs | 60 ++++++++++----
OpenSim/Region/Environment/Scenes/Scene.cs | 6 +-
.../Environment/Scenes/SceneExternalChecks.cs | 1 +
.../Scenes/SceneObjectGroup.Inventory.cs | 91 +---------------------
.../Region/Environment/Scenes/SceneObjectGroup.cs | 14 +---
.../Scenes/SceneObjectPart.Inventory.cs | 70 +++++++++--------
11 files changed, 164 insertions(+), 164 deletions(-)
create mode 100644 OpenSim/Region/Environment/Interfaces/IScriptModule.cs
(limited to 'OpenSim/Region/Environment')
diff --git a/OpenSim/Region/Environment/Interfaces/IScriptModule.cs b/OpenSim/Region/Environment/Interfaces/IScriptModule.cs
new file mode 100644
index 0000000..7aecaf7
--- /dev/null
+++ b/OpenSim/Region/Environment/Interfaces/IScriptModule.cs
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSim Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using OpenSim.Framework;
+using libsecondlife;
+
+namespace OpenSim.Region.Environment.Interfaces
+{
+ public interface IScriptModule : IRegionModule
+ {
+ bool GetScriptRunning(LLUUID objectID, LLUUID itemID);
+ }
+}
diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
index 83d4603..5d94407 100644
--- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs
@@ -291,6 +291,8 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
public event ScriptReset OnScriptReset;
+ public event GetScriptRunning OnGetScriptRunning;
+ public event SetScriptRunning OnSetScriptRunning;
public event UpdateVector OnAutoPilotGo;
#pragma warning restore 67
@@ -783,6 +785,10 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
{
}
+ public void SendScriptRunningReply(LLUUID objectID, LLUUID itemID, bool running)
+ {
+ }
+
public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
{
}
diff --git a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
index d6ee739..6cf2f29 100644
--- a/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Permissions/PermissionsModule.cs
@@ -300,6 +300,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
LLObject.ObjectFlags.ObjectMove | // tells client that you can move the object (only, no mod)
LLObject.ObjectFlags.ObjectTransfer | // tells the client that you can /take/ the object if you don't own it
LLObject.ObjectFlags.ObjectYouOwner | // Tells client that you're the owner of the object
+ LLObject.ObjectFlags.ObjectAnyOwner | // Tells client that someone owns the object
LLObject.ObjectFlags.ObjectOwnerModify | // Tells client that you're the owner of the object
LLObject.ObjectFlags.ObjectYouOfficer // Tells client that you've got group object editing permission. Used when ObjectGroupOwned is set
);
@@ -307,7 +308,7 @@ namespace OpenSim.Region.Environment.Modules.World.Permissions
// Creating the three ObjectFlags options for this method to choose from.
// Customize the OwnerMask
uint objectOwnerMask = ApplyObjectModifyMasks(task.OwnerMask, objflags);
- objectOwnerMask |= (uint)LLObject.ObjectFlags.ObjectYouOwner | (uint)LLObject.ObjectFlags.ObjectOwnerModify;
+ objectOwnerMask |= (uint)LLObject.ObjectFlags.ObjectYouOwner | (uint)LLObject.ObjectFlags.ObjectAnyOwner | (uint)LLObject.ObjectFlags.ObjectOwnerModify;
// Customize the GroupMask
// uint objectGroupMask = ApplyObjectModifyMasks(task.GroupMask, objflags);
diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs
index 5c750e4..f3af0d1 100644
--- a/OpenSim/Region/Environment/Scenes/EventManager.cs
+++ b/OpenSim/Region/Environment/Scenes/EventManager.cs
@@ -95,17 +95,22 @@ namespace OpenSim.Region.Environment.Scenes
public event OnPermissionErrorDelegate OnPermissionError;
- public delegate void NewRezScript(uint localID, LLUUID itemID, string script);
- public delegate void RezEvent(uint localID, LLUUID itemID, int param);
+ public delegate void NewRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez);
public event NewRezScript OnRezScript;
- public event RezEvent OnRezEvent;
-
public delegate void RemoveScript(uint localID, LLUUID itemID);
public event RemoveScript OnRemoveScript;
+ public delegate void StartScript(uint localID, LLUUID itemID);
+
+ public event StartScript OnStartScript;
+
+ public delegate void StopScript(uint localID, LLUUID itemID);
+
+ public event StopScript OnStopScript;
+
public delegate bool SceneGroupMoved(LLUUID groupID, LLVector3 delta);
public event SceneGroupMoved OnSceneGroupMove;
@@ -332,8 +337,9 @@ namespace OpenSim.Region.Environment.Scenes
private ObjectDeGrabDelegate handlerObjectDeGrab = null; //OnObjectDeGrab;
private ScriptResetDelegate handlerScriptReset = null; // OnScriptReset
private NewRezScript handlerRezScript = null; //OnRezScript;
- private RezEvent handlerOnRezEvent = null; //OnRezEvent;
private RemoveScript handlerRemoveScript = null; //OnRemoveScript;
+ private StartScript handlerStartScript = null; //OnStartScript;
+ private StopScript handlerStopScript = null; //OnStopScript;
private SceneGroupMoved handlerSceneGroupMove = null; //OnSceneGroupMove;
private SceneGroupGrabed handlerSceneGroupGrab = null; //OnSceneGroupGrab;
private LandObjectAdded handlerLandObjectAdded = null; //OnLandObjectAdded;
@@ -523,21 +529,30 @@ namespace OpenSim.Region.Environment.Scenes
}
}
- public void TriggerRezScript(uint localID, LLUUID itemID, string script)
+ public void TriggerRezScript(uint localID, LLUUID itemID, string script, int startParam, bool postOnRez)
{
handlerRezScript = OnRezScript;
if (handlerRezScript != null)
{
- handlerRezScript(localID, itemID, script);
+ handlerRezScript(localID, itemID, script, startParam, postOnRez);
+ }
+ }
+
+ public void TriggerStartScript(uint localID, LLUUID itemID)
+ {
+ handlerStartScript = OnStartScript;
+ if (handlerStartScript != null)
+ {
+ handlerStartScript(localID, itemID);
}
}
- public void TriggerOnRezEvent(uint localID, LLUUID itemID, int param)
+ public void TriggerStopScript(uint localID, LLUUID itemID)
{
- handlerOnRezEvent = OnRezEvent;
- if (handlerOnRezEvent != null)
+ handlerStopScript = OnStopScript;
+ if (handlerStopScript != null)
{
- handlerOnRezEvent(localID, itemID, param);
+ handlerStopScript(localID, itemID);
}
}
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index fd8e2f8..d553f4b 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -1522,7 +1522,7 @@ namespace OpenSim.Region.Environment.Scenes
copy.UpdateGroupRotation(new LLQuaternion(rot.x, rot.y, rot.z, rot.w));
}
- copy.StartScripts();
+ copy.CreateScriptInstances(0, false);
copy.HasGroupChanged = true;
copy.ScheduleGroupForFullUpdate();
return copy;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index f030e12..d134ea3 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Region.Environment.Scenes
///
/// Start all the scripts in the scene which should be started.
///
- public void StartScripts()
+ public void CreateScriptInstances()
{
m_log.Info("[PRIM INVENTORY]: Starting scripts in scene");
@@ -54,7 +54,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (group is SceneObjectGroup)
{
- ((SceneObjectGroup) group).StartScripts();
+ ((SceneObjectGroup) group).CreateScriptInstances(0, false);
}
}
}
@@ -234,6 +234,10 @@ namespace OpenSim.Region.Environment.Scenes
AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data);
AssetCache.AddAsset(asset);
+ if (isScriptRunning)
+ {
+ part.RemoveScriptInstance(item.ItemID);
+ }
// Update item with new asset
item.AssetID = asset.FullID;
group.UpdateInventoryItem(item);
@@ -242,8 +246,7 @@ namespace OpenSim.Region.Environment.Scenes
// Trigger rerunning of script (use TriggerRezScript event, see RezScript)
if (isScriptRunning)
{
- group.StopScript(part.LocalId, item.ItemID);
- group.StartScript(part.LocalId, item.ItemID);
+ part.CreateScriptInstance(item.ItemID, 0, false);
}
}
@@ -1219,7 +1222,8 @@ namespace OpenSim.Region.Environment.Scenes
if (ExternalChecks.ExternalChecksCanRunScript(item.ID, part.UUID, remoteClient.AgentId))
{
part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID);
- part.ParentGroup.StartScript(localID, copyID);
+ // TODO: set this to "true" when scripts in inventory have persistent state to fire on_rez
+ part.CreateScriptInstance(copyID, 0, false);
part.GetProperties(remoteClient);
// m_log.InfoFormat("[PRIMINVENTORY]: " +
@@ -1280,7 +1284,7 @@ namespace OpenSim.Region.Environment.Scenes
if (ExternalChecks.ExternalChecksCanRunScript(taskItem.AssetID, part.UUID, remoteClient.AgentId))
{
- part.StartScript(taskItem);
+ part.CreateScriptInstance(taskItem, 0, false);
}
}
}
@@ -1312,6 +1316,13 @@ namespace OpenSim.Region.Environment.Scenes
return;
}
+ // Must own the object, and have modify rights
+ if(srcPart.OwnerID != destPart.OwnerID)
+ return;
+
+ if((destPart.OwnerMask & (uint)PermissionMask.Modify) == 0)
+ return;
+
if (destPart.ScriptAccessPin != pin)
{
m_log.WarnFormat(
@@ -1362,17 +1373,13 @@ namespace OpenSim.Region.Environment.Scenes
destTaskItem.InvType = srcTaskItem.InvType;
destTaskItem.Type = srcTaskItem.Type;
- // need something like destPart.AddInventoryItemExclusive(destTaskItem);
- // this function is supposed to silently overwrite an existing script with the same name
-
- destPart.AddInventoryItem(destTaskItem);
+ destPart.AddInventoryItemExclusive(destTaskItem);
if ( running > 0 )
{
if (ExternalChecks.ExternalChecksCanRunScript(destTaskItem.AssetID, destPart.UUID, destPart.OwnerID))
{
- // why doesn't the start_param propogate?
- destPart.StartScript(destTaskItem, start_param);
+ destPart.CreateScriptInstance(destTaskItem, 0, false);
}
}
@@ -1874,7 +1881,8 @@ namespace OpenSim.Region.Environment.Scenes
//group.ApplyPhysics(m_physicalPrim);
}
- group.StartScripts();
+ // TODO: make this true to fire on_rez when scripts have state while in inventory
+ group.CreateScriptInstances(0, false);
if (!attachment)
rootPart.ScheduleFullUpdate();
@@ -1919,9 +1927,6 @@ namespace OpenSim.Region.Environment.Scenes
AddNewSceneObject(group, true);
- // Set the startup parameter for on_rez event and llGetStartParameter() function
- group.StartParameter = param;
-
// we set it's position in world.
group.AbsolutePosition = pos;
@@ -1970,7 +1975,7 @@ namespace OpenSim.Region.Environment.Scenes
group.UpdateGroupRotation(rot);
group.ApplyPhysics(m_physicalPrim);
group.Velocity = vel;
- group.StartScripts(param);
+ group.CreateScriptInstances(param, true);
rootPart.ScheduleFullUpdate();
return rootPart.ParentGroup;
}
@@ -2120,5 +2125,26 @@ namespace OpenSim.Region.Environment.Scenes
}
+ public void GetScriptRunning(IClientAPI controllingClient, LLUUID objectID, LLUUID itemID)
+ {
+ IScriptModule scriptModule = RequestModuleInterface();
+ if(scriptModule == null)
+ return;
+
+ controllingClient.SendScriptRunningReply(objectID, itemID,
+ scriptModule.GetScriptRunning(objectID, itemID));
+ }
+
+ public void SetScriptRunning(IClientAPI controllingClient, LLUUID objectID, LLUUID itemID, bool running)
+ {
+ SceneObjectPart part = GetSceneObjectPart(objectID);
+ if(part == null)
+ return;
+
+ if(running)
+ EventManager.TriggerStartScript(part.LocalId, itemID);
+ else
+ EventManager.TriggerStopScript(part.LocalId, itemID);
+ }
}
}
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index b7117df..291a7ae 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -553,7 +553,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (ent is SceneObjectGroup)
{
- ((SceneObjectGroup)ent).StopScripts();
+ ((SceneObjectGroup)ent).RemoveScriptInstances();
}
}
}
@@ -567,7 +567,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (ent is SceneObjectGroup)
{
- ((SceneObjectGroup)ent).StartScripts();
+ ((SceneObjectGroup)ent).CreateScriptInstances(0, false);
}
}
}
@@ -2029,6 +2029,8 @@ namespace OpenSim.Region.Environment.Scenes
client.OnObjectGroupRequest += m_innerScene.HandleObjectGroupUpdate;
client.OnParcelReturnObjectsRequest += LandChannel.ReturnObjectsInParcel;
client.OnScriptReset += ProcessScriptReset;
+ client.OnGetScriptRunning += GetScriptRunning;
+ client.OnSetScriptRunning += SetScriptRunning;
// EventManager.TriggerOnNewClient(client);
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
index dba10df..c7d1ce2 100644
--- a/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneExternalChecks.cs
@@ -72,6 +72,7 @@ namespace OpenSim.Region.Environment.Scenes
(uint)LLObject.ObjectFlags.ObjectMove |
(uint)LLObject.ObjectFlags.ObjectTransfer |
(uint)LLObject.ObjectFlags.ObjectYouOwner |
+ (uint)LLObject.ObjectFlags.ObjectAnyOwner |
(uint)LLObject.ObjectFlags.ObjectOwnerModify |
(uint)LLObject.ObjectFlags.ObjectYouOfficer;
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index aea433e..799cb41 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -39,115 +39,32 @@ namespace OpenSim.Region.Environment.Scenes
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
///
- /// Start a given script.
- ///
- ///
- /// A
- ///
- public void StartScript(uint localID, LLUUID itemID)
- {
- SceneObjectPart part = GetChildPart(localID);
- if (part != null)
- {
-
- part.StartScript(itemID);
-
- }
- else
- {
- m_log.ErrorFormat(
- "[PRIM INVENTORY]: " +
- "Couldn't find part {0} in object group {1}, {2} to start script with ID {3}",
- localID, Name, UUID, itemID);
- }
- }
-
-// /// Start a given script.
-// ///
-// ///
-// /// A
-// ///
-// public void StartScript(LLUUID partID, LLUUID itemID)
-// {
-// SceneObjectPart part = GetChildPart(partID);
-// if (part != null)
-// {
-// part.StartScript(itemID);
-// }
-// else
-// {
-// m_log.ErrorFormat(
-// "[PRIM INVENTORY]: " +
-// "Couldn't find part {0} in object group {1}, {2} to start script with ID {3}",
-// localID, Name, UUID, itemID);
-// }
-// }
-
- ///
/// Start the scripts contained in all the prims in this group.
///
- public void StartScripts()
+ public void CreateScriptInstances(int startParam, bool postOnRez)
{
// Don't start scripts if they're turned off in the region!
if (!((m_scene.RegionInfo.EstateSettings.regionFlags & Simulator.RegionFlags.SkipScripts) == Simulator.RegionFlags.SkipScripts))
{
foreach (SceneObjectPart part in m_parts.Values)
{
- part.StartScripts();
+ part.CreateScriptInstances(startParam, postOnRez);
}
}
}
- ///
- /// Start the scripts contained in all the prims in this group.
- ///
- public void StartScripts(int param)
- {
- // Don't start scripts if they're turned off in the region!
- if (!((m_scene.RegionInfo.EstateSettings.regionFlags & Simulator.RegionFlags.SkipScripts) == Simulator.RegionFlags.SkipScripts))
- {
- foreach (SceneObjectPart part in m_parts.Values)
- {
- part.StartScripts(param);
- }
- }
- }
-
- public void StopScripts()
+ public void RemoveScriptInstances()
{
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
{
- part.StopScripts();
+ part.RemoveScriptInstances();
}
}
}
///
- /// Start a given script.
- ///
- ///
- /// A
- ///
- public void StopScript(uint partID, LLUUID itemID)
- {
- SceneObjectPart part = GetChildPart(partID);
- if (part != null)
- {
- part.StopScript(itemID);
- part.RemoveScriptEvents(itemID);
- }
- else
- {
- m_log.ErrorFormat(
- "[PRIM INVENTORY]: " +
- "Couldn't find part {0} in object group {1}, {2} to stop script with ID {3}",
- partID, Name, UUID, itemID);
- }
- }
-
- ///
///
///
///
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index 4a24dad..ebefdce 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -114,8 +114,6 @@ namespace OpenSim.Region.Environment.Scenes
private bool m_scriptListens_atTarget = false;
private bool m_scriptListens_notAtTarget = false;
- private int m_startparameter = 0;
-
#region Properties
///
@@ -137,16 +135,6 @@ namespace OpenSim.Region.Environment.Scenes
protected bool m_isSelected = false;
///
- /// Set start parameter for on_rez event and llGetStartParameter()
- ///
- [XmlIgnore]
- public int StartParameter
- {
- get { return m_startparameter; }
- set { m_startparameter = value; }
- }
-
- ///
/// Number of prims in this group
///
public int PrimCount
@@ -937,7 +925,7 @@ namespace OpenSim.Region.Environment.Scenes
{
foreach (SceneObjectPart part in m_parts.Values)
{
- part.StopScripts();
+ part.RemoveScriptInstances();
List avatars = Scene.GetScenePresences();
for (int i = 0; i < avatars.Count; i++)
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index fbf2794..dc195f8 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -137,7 +137,7 @@ namespace OpenSim.Region.Environment.Scenes
///
/// Start all the scripts contained in this prim's inventory
///
- public void StartScripts()
+ public void CreateScriptInstances(int startParam, bool postOnRez)
{
lock (m_taskInventory)
{
@@ -146,25 +146,7 @@ namespace OpenSim.Region.Environment.Scenes
// XXX more hardcoding badness. Should be an enum in TaskInventoryItem
if (10 == item.Type)
{
- StartScript(item);
- }
- }
- }
- }
-
- ///
- /// Start all the scripts contained in this prim's inventory
- ///
- public void StartScripts(int param)
- {
- lock (m_taskInventory)
- {
- foreach (TaskInventoryItem item in m_taskInventory.Values)
- {
- // XXX more hardcoding badness. Should be an enum in TaskInventoryItem
- if (10 == item.Type)
- {
- StartScript(item, param);
+ CreateScriptInstance(item, startParam, postOnRez);
}
}
}
@@ -173,7 +155,7 @@ namespace OpenSim.Region.Environment.Scenes
///
/// Stop all the scripts in this prim.
///
- public void StopScripts()
+ public void RemoveScriptInstances()
{
lock (m_taskInventory)
{
@@ -181,7 +163,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (10 == item.Type)
{
- StopScript(item.ItemID);
+ RemoveScriptInstance(item.ItemID);
RemoveScriptEvents(item.ItemID);
}
}
@@ -193,13 +175,8 @@ namespace OpenSim.Region.Environment.Scenes
///
///
///
- public void StartScript(TaskInventoryItem item, int param)
- {
- StartScript(item);
- m_parentGroup.Scene.EventManager.TriggerOnRezEvent(LocalId, item.ItemID, param);
- }
- public void StartScript(TaskInventoryItem item)
+ public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez)
{
// m_log.InfoFormat(
// "[PRIM INVENTORY]: " +
@@ -223,7 +200,7 @@ namespace OpenSim.Region.Environment.Scenes
else
{
string script = Helpers.FieldToUTF8String(asset.Data);
- m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId,item.ItemID,script);
+ m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId,item.ItemID,script, startParam, postOnRez);
m_parentGroup.AddActiveScriptCount(1);
ScheduleFullUpdate();
}
@@ -237,13 +214,13 @@ namespace OpenSim.Region.Environment.Scenes
///
/// A
///
- public void StartScript(LLUUID itemId)
+ public void CreateScriptInstance(LLUUID itemId, int startParam, bool postOnRez)
{
lock (m_taskInventory)
{
if (m_taskInventory.ContainsKey(itemId))
{
- StartScript(m_taskInventory[itemId]);
+ CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez);
}
else
@@ -260,7 +237,7 @@ namespace OpenSim.Region.Environment.Scenes
/// Stop a script which is in this prim's inventory.
///
///
- public void StopScript(LLUUID itemId)
+ public void RemoveScriptInstance(LLUUID itemId)
{
if (m_taskInventory.ContainsKey(itemId))
{
@@ -330,6 +307,35 @@ namespace OpenSim.Region.Environment.Scenes
ParentGroup.HasGroupChanged = true;
}
+ public void AddInventoryItemExclusive(TaskInventoryItem item)
+ {
+ item.ParentID = UUID;
+ item.ParentPartID = UUID;
+
+ List il = new List(m_taskInventory.Values);
+ foreach(TaskInventoryItem i in il)
+ {
+ if(i.Name == item.Name)
+ {
+ if(i.Type == 10)
+ RemoveScriptInstance(i.ItemID);
+ RemoveInventoryItem(i.ItemID);
+ break;
+ }
+ }
+
+ lock (m_taskInventory)
+ {
+ m_taskInventory.Add(item.ItemID, item);
+ TriggerScriptChangedEvent(Changed.INVENTORY);
+ }
+
+ m_inventorySerial++;
+ //m_inventorySerial += 2;
+ HasInventoryChanged = true;
+ ParentGroup.HasGroupChanged = true;
+ }
+
///
/// Restore a whole collection of items to the prim's inventory at once.
/// We assume that the items already have all their fields correctly filled out.
--
cgit v1.1