From 47c6d8ae8f85f07a16390f0130180a1b0521b6a1 Mon Sep 17 00:00:00 2001
From: MW
Date: Wed, 22 Aug 2007 18:36:47 +0000
Subject: Added OnRemoveScript(uint localID, LLUUID itemID) event , trigged
when a script in a primitive is deleted.
---
OpenSim/Framework/General/Interfaces/IClientAPI.cs | 2 ++
OpenSim/Framework/General/NullClientAPI.cs | 1 +
OpenSim/Region/ClientStack/ClientView.API.cs | 1 +
.../ClientStack/ClientView.ProcessPackets.cs | 7 +++++++
.../Region/Environment/Scenes/Scene.Inventory.cs | 20 ++++++++++++++++++++
OpenSim/Region/Environment/Scenes/Scene.cs | 1 +
OpenSim/Region/Environment/Scenes/SceneEvents.cs | 10 ++++++++++
.../Region/Environment/Scenes/SceneObjectGroup.cs | 10 ++++++++++
.../Region/Environment/Scenes/SceneObjectPart.cs | 22 ++++++++++++++++++++--
.../Region/Examples/SimpleApp/MyNpcCharacter.cs | 1 +
10 files changed, 73 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs
index 3c41eb5..4dbe4e7 100644
--- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs
+++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs
@@ -90,6 +90,7 @@ namespace OpenSim.Framework.Interfaces
public delegate void UpdateInventoryItemTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID);
public delegate void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID);
public delegate void UpdateTaskInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID folderID, uint localID);
+ public delegate void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID);
public delegate void UDPAssetUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data);
public delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data);
@@ -152,6 +153,7 @@ namespace OpenSim.Framework.Interfaces
event ConfirmXfer OnConfirmXfer;
event RezScript OnRezScript;
event UpdateTaskInventory OnUpdateTaskInventory;
+ event RemoveTaskInventory OnRemoveTaskItem;
event UUIDNameRequest OnNameFromUUIDRequest;
diff --git a/OpenSim/Framework/General/NullClientAPI.cs b/OpenSim/Framework/General/NullClientAPI.cs
index 6692fde..6794384 100644
--- a/OpenSim/Framework/General/NullClientAPI.cs
+++ b/OpenSim/Framework/General/NullClientAPI.cs
@@ -65,6 +65,7 @@ namespace OpenSim.Framework
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript;
public event UpdateTaskInventory OnUpdateTaskInventory;
+ public event RemoveTaskInventory OnRemoveTaskItem;
public event UUIDNameRequest OnNameFromUUIDRequest;
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs
index 6570a82..6209beb 100644
--- a/OpenSim/Region/ClientStack/ClientView.API.cs
+++ b/OpenSim/Region/ClientStack/ClientView.API.cs
@@ -94,6 +94,7 @@ namespace OpenSim.Region.ClientStack
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript;
public event UpdateTaskInventory OnUpdateTaskInventory;
+ public event RemoveTaskInventory OnRemoveTaskItem;
public event UUIDNameRequest OnNameFromUUIDRequest;
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
index 383c7a9..0163528 100644
--- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
+++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs
@@ -484,6 +484,13 @@ namespace OpenSim.Region.ClientStack
}
}
break;
+ case PacketType.RemoveTaskInventory:
+ RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
+ if (OnRemoveTaskItem != null)
+ {
+ OnRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
+ }
+ break;
case PacketType.MoveTaskInventory:
//Console.WriteLine(Pack.ToString());
break;
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index fa1b865..9cbd65b 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -208,6 +208,26 @@ namespace OpenSim.Region.Environment.Scenes
}
}
+ public void RemoveTaskInventory(IClientAPI remoteClient, LLUUID itemID, uint localID)
+ {
+ bool hasPrim = false;
+ foreach (EntityBase ent in Entities.Values)
+ {
+ if (ent is SceneObjectGroup)
+ {
+ hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
+ if (hasPrim != false)
+ {
+ int type = ((SceneObjectGroup)ent).RemoveInventoryItem(remoteClient, localID, itemID);
+ if (type == 10)
+ {
+ this.EventManager.TriggerRemoveScript(localID, itemID);
+ }
+ }
+ }
+ }
+ }
+
public void RezScript(IClientAPI remoteClient, LLUUID itemID, uint localID)
{
CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 62eb547..91ff0a8 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -716,6 +716,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnRequestXfer += xferManager.RequestXfer;
client.OnConfirmXfer += xferManager.AckPacket;
client.OnRezScript += RezScript;
+ client.OnRemoveTaskItem += RemoveTaskInventory;
client.OnRequestAvatarProperties += RequestAvatarProperty;
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 09a7f21..3c6b277 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -40,6 +40,8 @@ namespace OpenSim.Region.Environment.Scenes
public delegate void NewRezScript(uint localID, LLUUID itemID, string script);
public event NewRezScript OnRezScript;
+ public delegate void RemoveScript(uint localID, LLUUID itemID);
+ public event RemoveScript OnRemoveScript;
public void TriggerPermissionError(LLUUID user, string reason)
{
@@ -117,5 +119,13 @@ namespace OpenSim.Region.Environment.Scenes
OnRezScript(localID, itemID, script);
}
}
+
+ public void TriggerRemoveScript(uint localID, LLUUID itemID)
+ {
+ if (OnRemoveScript != null)
+ {
+ OnRemoveScript(localID, itemID);
+ }
+ }
}
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
index c50809f..c3d70ea 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs
@@ -643,6 +643,16 @@ namespace OpenSim.Region.Environment.Scenes
}
+ public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID)
+ {
+ SceneObjectPart part = this.GetChildPart(localID);
+ if (part != null)
+ {
+ return part.RemoveInventoryItem(remoteClient, localID, itemID);
+ }
+ return -1;
+ }
+
///
///
///
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
index 8a59d88..567681a 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs
@@ -422,10 +422,28 @@ namespace OpenSim.Region.Environment.Scenes
this.m_inventorySerial++;
}
- public void RemoveInventoryItem()
+ public int RemoveInventoryItem(IClientAPI remoteClient, uint localID, LLUUID itemID)
{
-
+ if (localID == this.LocalID)
+ {
+ if (this.TaskInventory.ContainsKey(itemID))
+ {
+ string type = TaskInventory[itemID].inv_type;
+ this.TaskInventory.Remove(itemID);
+ this.m_inventorySerial++;
+ if (type == "lsltext")
+ {
+ return 10;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ }
+ return -1;
}
+
///
///
///
diff --git a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
index 0e898a2..003d3d4 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyNpcCharacter.cs
@@ -79,6 +79,7 @@ namespace SimpleApp
public event ConfirmXfer OnConfirmXfer;
public event RezScript OnRezScript;
public event UpdateTaskInventory OnUpdateTaskInventory;
+ public event RemoveTaskInventory OnRemoveTaskItem;
public event UUIDNameRequest OnNameFromUUIDRequest;
--
cgit v1.1