Refactor Scene.Inventory.RezScript to use newer script starting code

afrisby
Justin Clarke Casey 2008-01-07 03:02:13 +00:00
parent 7bdc8141d4
commit 6b4b041902
3 changed files with 65 additions and 47 deletions

View File

@ -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;
}
// TODO: do we care about the value of this bool?
group.AddInventoryItem(remoteClient, localID, item, copyID);
group.StartScript(localID, copyID);
group.GetProperites(remoteClient);
AssetBase rezAsset = AssetCache.GetAsset(item.assetID, isTexture);
if (rezAsset != null)
{
string script = Helpers.FieldToUTF8String(rezAsset.Data);
EventManager.TriggerRezScript(localID, copyID, script);
rezzed = true;
}
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);
}

View File

@ -37,7 +37,29 @@ using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Scenes
{
public partial class SceneObjectGroup : EntityBase
{
{
/// <summary>
/// Start a given script.
/// </summary>
/// <param name="localID">
/// A <see cref="System.UInt32"/>
/// </param>
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);
}
}
/// <summary>
/// Start the scripts contained in all the prims in this group.
/// </summary>
@ -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);

View File

@ -97,7 +97,7 @@ namespace OpenSim.Region.Environment.Scenes
}
/// <summary>
/// Start a script in this prim
/// Start a script which is in this prim's inventory.
/// </summary>
/// <param name="item"></param>
/// <returns>true if script asset was found, false if it wasn't</returns>
@ -126,7 +126,29 @@ namespace OpenSim.Region.Environment.Scenes
}
return false;
}
}
/// <summary>
/// Start a script which is in this prim's inventory.
/// </summary>
/// <param name="itemId">
/// A <see cref="LLUUID"/>
/// </param>
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);
}
}
/// <summary>
/// Add an item to this prim's inventory.