From 6b4b041902627d9d16f28847b1db7f369b931006 Mon Sep 17 00:00:00 2001
From: Justin Clarke Casey
Date: Mon, 7 Jan 2008 03:02:13 +0000
Subject: Refactor Scene.Inventory.RezScript to use newer script starting code
---
.../Region/Environment/Scenes/Scene.Inventory.cs | 56 ++++++----------------
.../Scenes/SceneObjectGroup.Inventory.cs | 30 ++++++++++--
.../Scenes/SceneObjectPart.Inventory.cs | 26 +++++++++-
3 files changed, 65 insertions(+), 47 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index f3673fc..bfde643 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -559,57 +559,31 @@ namespace OpenSim.Region.Environment.Scenes
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
if (item != null)
{
- bool isTexture = false;
- bool rezzed = false;
- if (item.invType == 0)
+ SceneObjectGroup group = GetGroupByPrim(localID);
+ if (group != null)
{
- isTexture = true;
- }
-
- AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture);
-
- if (rezAsset != null)
- {
- string script = Helpers.FieldToUTF8String(rezAsset.Data);
- EventManager.TriggerRezScript(localID, copyID, script);
- rezzed = true;
- }
+ // TODO: do we care about the value of this bool?
+ group.AddInventoryItem(remoteClient, localID, item, copyID);
+ group.StartScript(localID, copyID);
+ group.GetProperites(remoteClient);
- if (rezzed)
- {
- SceneObjectGroup group = GetGroupByPrim(localID);
- if (group != null)
- {
- // TODO: do we care about the value of this bool?
- group.AddInventoryItem(remoteClient, localID, item, copyID);
- group.GetProperites(remoteClient);
-
- MainLog.Instance.Verbose(
- "PRIMINVENTORY",
- "Rezzed script {0} (asset {1}) into prim {2} for user {3}",
- item.inventoryName, rezAsset.FullID, localID, remoteClient.Name);
- }
- else
- {
- MainLog.Instance.Warn(
- "PRIMINVENTORY",
- "Could not rez script {0} into prim {1} for user {2}"
- + " because the prim could not be found in the region!",
- item.inventoryName, localID, remoteClient.Name);
- }
+ MainLog.Instance.Verbose(
+ "PRIMINVENTORY",
+ "Rezzed script {0} into prim local ID {1} for user {2}",
+ item.inventoryName, localID, remoteClient.Name);
}
else
{
- MainLog.Instance.Warn(
+ MainLog.Instance.Error(
"PRIMINVENTORY",
- "Could not rez script {0} into prim {1} for user {2}"
- + " because the item asset {3} could not be found!",
- item.inventoryName, localID, item.assetID, remoteClient.Name);
+ "Could not rez script {0} into prim local ID {1} for user {2}"
+ + " because the prim could not be found in the region!",
+ item.inventoryName, localID, remoteClient.Name);
}
}
else
{
- MainLog.Instance.Warn(
+ MainLog.Instance.Error(
"PRIMINVENTORY", "Could not find script inventory item {0} to rez for {1}!",
itemID, remoteClient.Name);
}
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
index 50e3fa7..1d382fa 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.Inventory.cs
@@ -37,7 +37,29 @@ using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Scenes
{
public partial class SceneObjectGroup : EntityBase
- {
+ {
+ ///
+ /// Start a given script.
+ ///
+ ///
+ /// A
+ ///
+ public void StartScript(uint localID, LLUUID itemID)
+ {
+ SceneObjectPart part = GetChildPart(localID);
+ if (part != null)
+ {
+ part.StartScript(itemID);
+ }
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "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.
///
@@ -63,8 +85,8 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
- MainLog.Instance.Warn(
- "SCENE",
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
"Couldn't find part {0} in object group {1}, {2} to retreive prim inventory",
localID, Name, UUID);
}
@@ -80,7 +102,7 @@ namespace OpenSim.Region.Environment.Scenes
}
else
{
- MainLog.Instance.Warn(
+ MainLog.Instance.Error(
"PRIMINVENTORY",
"Couldn't find part {0} in object group {1}, {2} to request inventory data",
localID, Name, UUID);
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
index 5f93986..98cd3af 100644
--- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.Inventory.cs
@@ -97,7 +97,7 @@ namespace OpenSim.Region.Environment.Scenes
}
///
- /// Start a script in this prim
+ /// Start a script which is in this prim's inventory.
///
///
/// true if script asset was found, false if it wasn't
@@ -126,7 +126,29 @@ namespace OpenSim.Region.Environment.Scenes
}
return false;
- }
+ }
+
+ ///
+ /// Start a script which is in this prim's inventory.
+ ///
+ ///
+ /// A
+ ///
+ public void StartScript(LLUUID itemId)
+ {
+ if (m_taskInventory.ContainsKey(itemId))
+ {
+ StartScript(m_taskInventory[itemId]);
+ }
+ else
+ {
+ MainLog.Instance.Error(
+ "PRIMINVENTORY",
+ "Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
+ itemId, Name, UUID);
+ }
+
+ }
///
/// Add an item to this prim's inventory.
--
cgit v1.1