refactor: decompose most of RezScript() into RezScriptFromAgentInventory(), RezNewScript() and rename one RezScript() to RezScriptFromPrim()
parent
2e7c1bcfd9
commit
2de3a1b9da
|
@ -1560,23 +1560,34 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory
|
/// Rez a script into a prim's inventory, either ex nihilo or from an existing avatar inventory
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="remoteClient"></param>
|
/// <param name="remoteClient"></param>
|
||||||
/// <param name="itemID"> </param>
|
/// <param name="itemBase"> </param>
|
||||||
|
/// <param name="transactionID"></param>
|
||||||
/// <param name="localID"></param>
|
/// <param name="localID"></param>
|
||||||
public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID)
|
public void RezScript(IClientAPI remoteClient, InventoryItemBase itemBase, UUID transactionID, uint localID)
|
||||||
{
|
{
|
||||||
UUID itemID = itemBase.ID;
|
if (itemBase.ID != UUID.Zero)
|
||||||
UUID copyID = UUID.Random();
|
RezScriptFromAgentInventory(remoteClient, itemBase.ID, localID);
|
||||||
|
else
|
||||||
|
RezNewScript(remoteClient, itemBase);
|
||||||
|
}
|
||||||
|
|
||||||
if (itemID != UUID.Zero) // transferred from an avatar inventory to the prim's inventory
|
/// <summary>
|
||||||
|
/// Rez a script into a prim from an agent inventory.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteClient"></param>
|
||||||
|
/// <param name="fromItemID"></param>
|
||||||
|
/// <param name="localID"></param>
|
||||||
|
public void RezScriptFromAgentInventory(IClientAPI remoteClient, UUID fromItemID, uint localID)
|
||||||
{
|
{
|
||||||
InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
|
UUID copyID = UUID.Random();
|
||||||
|
InventoryItemBase item = new InventoryItemBase(fromItemID, remoteClient.AgentId);
|
||||||
item = InventoryService.GetItem(item);
|
item = InventoryService.GetItem(item);
|
||||||
|
|
||||||
// Try library
|
// Try library
|
||||||
// XXX clumsy, possibly should be one call
|
// XXX clumsy, possibly should be one call
|
||||||
if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
|
if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
|
||||||
{
|
{
|
||||||
item = LibraryService.LibraryRootFolder.FindItem(itemID);
|
item = LibraryService.LibraryRootFolder.FindItem(fromItemID);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
|
@ -1611,10 +1622,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
m_log.ErrorFormat(
|
m_log.ErrorFormat(
|
||||||
"[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!",
|
"[PRIM INVENTORY]: Could not find script inventory item {0} to rez for {1}!",
|
||||||
itemID, remoteClient.Name);
|
fromItemID, remoteClient.Name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // script has been rezzed directly into a prim's inventory
|
|
||||||
|
/// <summary>
|
||||||
|
/// Rez a new script from nothing.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteClient"></param>
|
||||||
|
/// <param name="itemBase"></param>
|
||||||
|
public void RezNewScript(IClientAPI remoteClient, InventoryItemBase itemBase)
|
||||||
{
|
{
|
||||||
SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
|
SceneObjectPart part = GetSceneObjectPart(itemBase.Folder);
|
||||||
if (part == null)
|
if (part == null)
|
||||||
|
@ -1658,7 +1675,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
|
part.Inventory.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
|
||||||
part.ParentGroup.ResumeScripts();
|
part.ParentGroup.ResumeScripts();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Rez a script into a prim's inventory from another prim
|
/// Rez a script into a prim's inventory from another prim
|
||||||
|
@ -1666,7 +1682,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// <param name="remoteClient"></param>
|
/// <param name="remoteClient"></param>
|
||||||
/// <param name="itemID"> </param>
|
/// <param name="itemID"> </param>
|
||||||
/// <param name="localID"></param>
|
/// <param name="localID"></param>
|
||||||
public void RezScript(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param)
|
public void RezScriptFromPrim(UUID srcId, SceneObjectPart srcPart, UUID destId, int pin, int running, int start_param)
|
||||||
{
|
{
|
||||||
TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId);
|
TaskInventoryItem srcTaskItem = srcPart.Inventory.GetInventoryItem(srcId);
|
||||||
|
|
||||||
|
|
|
@ -6603,7 +6603,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
}
|
}
|
||||||
|
|
||||||
// the rest of the permission checks are done in RezScript, so check the pin there as well
|
// the rest of the permission checks are done in RezScript, so check the pin there as well
|
||||||
World.RezScript(srcId, m_host, destId, pin, running, start_param);
|
World.RezScriptFromPrim(srcId, m_host, destId, pin, running, start_param);
|
||||||
|
|
||||||
// this will cause the delay even if the script pin or permissions were wrong - seems ok
|
// this will cause the delay even if the script pin or permissions were wrong - seems ok
|
||||||
ScriptSleep(3000);
|
ScriptSleep(3000);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue