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

@ -558,58 +558,32 @@ 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;
bool rezzed = false;
if (item.invType == 0)
{
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;
}
if (rezzed)
{ {
SceneObjectGroup group = GetGroupByPrim(localID); SceneObjectGroup group = GetGroupByPrim(localID);
if (group != null) if (group != null)
{ {
// TODO: do we care about the value of this bool? // TODO: do we care about the value of this bool?
group.AddInventoryItem(remoteClient, localID, item, copyID); group.AddInventoryItem(remoteClient, localID, item, copyID);
group.StartScript(localID, copyID);
group.GetProperites(remoteClient); group.GetProperites(remoteClient);
MainLog.Instance.Verbose( MainLog.Instance.Verbose(
"PRIMINVENTORY", "PRIMINVENTORY",
"Rezzed script {0} (asset {1}) into prim {2} for user {3}", "Rezzed script {0} into prim local ID {1} for user {2}",
item.inventoryName, rezAsset.FullID, localID, remoteClient.Name); 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 prim could not be found in the region!", + " because the prim could not be found in the region!",
item.inventoryName, localID, remoteClient.Name); item.inventoryName, localID, remoteClient.Name);
} }
} }
else 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);
}
}
else
{
MainLog.Instance.Warn(
"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

@ -38,6 +38,28 @@ 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>
@ -128,6 +128,28 @@ 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.
/// </summary> /// </summary>