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); InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
if (item != null) if (item != null)
{ {
bool isTexture = false; SceneObjectGroup group = GetGroupByPrim(localID);
bool rezzed = false; if (group != null)
if (item.invType == 0)
{ {
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); MainLog.Instance.Verbose(
"PRIMINVENTORY",
if (rezAsset != null) "Rezzed script {0} into prim local ID {1} for user {2}",
{ item.inventoryName, localID, remoteClient.Name);
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);
}
} }
else else
{ {
MainLog.Instance.Warn( MainLog.Instance.Error(
"PRIMINVENTORY", "PRIMINVENTORY",
"Could not rez script {0} into prim {1} for user {2}" "Could not rez script {0} into prim local ID {1} for user {2}"
+ " because the item asset {3} could not be found!", + " because the prim could not be found in the region!",
item.inventoryName, localID, item.assetID, remoteClient.Name); item.inventoryName, localID, remoteClient.Name);
} }
} }
else else
{ {
MainLog.Instance.Warn( MainLog.Instance.Error(
"PRIMINVENTORY", "Could not find script inventory item {0} to rez for {1}!", "PRIMINVENTORY", "Could not find script inventory item {0} to rez for {1}!",
itemID, remoteClient.Name); itemID, remoteClient.Name);
} }

View File

@ -37,7 +37,29 @@ using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
public partial class SceneObjectGroup : EntityBase 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> /// <summary>
/// Start the scripts contained in all the prims in this group. /// Start the scripts contained in all the prims in this group.
/// </summary> /// </summary>
@ -63,8 +85,8 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
MainLog.Instance.Warn( MainLog.Instance.Error(
"SCENE", "PRIMINVENTORY",
"Couldn't find part {0} in object group {1}, {2} to retreive prim inventory", "Couldn't find part {0} in object group {1}, {2} to retreive prim inventory",
localID, Name, UUID); localID, Name, UUID);
} }
@ -80,7 +102,7 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
MainLog.Instance.Warn( MainLog.Instance.Error(
"PRIMINVENTORY", "PRIMINVENTORY",
"Couldn't find part {0} in object group {1}, {2} to request inventory data", "Couldn't find part {0} in object group {1}, {2} to request inventory data",
localID, Name, UUID); localID, Name, UUID);

View File

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