diff options
author | Justin Clark-Casey (justincc) | 2012-07-04 20:57:48 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-07-04 20:57:48 +0100 |
commit | 58b13d51a7eddb442e38e6dc6790a9e7cf68bad7 (patch) | |
tree | 9c074a81d3bd677089e5216dc0f3265227e08a53 /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | refactor: rename Watchdog.WATCHDOG_TIMEOUT_MS to DEFAULT_WATCHDOG_TIMEOUT_MS ... (diff) | |
download | opensim-SC_OLD-58b13d51a7eddb442e38e6dc6790a9e7cf68bad7.zip opensim-SC_OLD-58b13d51a7eddb442e38e6dc6790a9e7cf68bad7.tar.gz opensim-SC_OLD-58b13d51a7eddb442e38e6dc6790a9e7cf68bad7.tar.bz2 opensim-SC_OLD-58b13d51a7eddb442e38e6dc6790a9e7cf68bad7.tar.xz |
refactor: make llGiveInventory() use existing GetInventoryItem() method rather than iterate through TaskInventory itself.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 12eb098..8a3efa7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -3860,11 +3860,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3860 | public void llGiveInventory(string destination, string inventory) | 3860 | public void llGiveInventory(string destination, string inventory) |
3861 | { | 3861 | { |
3862 | m_host.AddScriptLPS(1); | 3862 | m_host.AddScriptLPS(1); |
3863 | bool found = false; | 3863 | |
3864 | UUID destId = UUID.Zero; | 3864 | UUID destId = UUID.Zero; |
3865 | UUID objId = UUID.Zero; | ||
3866 | int assetType = 0; | ||
3867 | string objName = String.Empty; | ||
3868 | 3865 | ||
3869 | if (!UUID.TryParse(destination, out destId)) | 3866 | if (!UUID.TryParse(destination, out destId)) |
3870 | { | 3867 | { |
@@ -3872,28 +3869,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3872 | return; | 3869 | return; |
3873 | } | 3870 | } |
3874 | 3871 | ||
3875 | // move the first object found with this inventory name | 3872 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(inventory); |
3876 | lock (m_host.TaskInventory) | ||
3877 | { | ||
3878 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | ||
3879 | { | ||
3880 | if (inv.Value.Name == inventory) | ||
3881 | { | ||
3882 | found = true; | ||
3883 | objId = inv.Key; | ||
3884 | assetType = inv.Value.Type; | ||
3885 | objName = inv.Value.Name; | ||
3886 | break; | ||
3887 | } | ||
3888 | } | ||
3889 | } | ||
3890 | 3873 | ||
3891 | if (!found) | 3874 | if (item == null) |
3892 | { | 3875 | { |
3893 | llSay(0, String.Format("Could not find object '{0}'", inventory)); | 3876 | llSay(0, String.Format("Could not find object '{0}'", inventory)); |
3894 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); | 3877 | throw new Exception(String.Format("The inventory object '{0}' could not be found", inventory)); |
3895 | } | 3878 | } |
3896 | 3879 | ||
3880 | UUID objId = item.ItemID; | ||
3881 | |||
3897 | // check if destination is an object | 3882 | // check if destination is an object |
3898 | if (World.GetSceneObjectPart(destId) != null) | 3883 | if (World.GetSceneObjectPart(destId) != null) |
3899 | { | 3884 | { |
@@ -3924,21 +3909,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3924 | return; | 3909 | return; |
3925 | 3910 | ||
3926 | byte[] bucket = new byte[17]; | 3911 | byte[] bucket = new byte[17]; |
3927 | bucket[0] = (byte)assetType; | 3912 | bucket[0] = (byte)item.Type; |
3928 | byte[] objBytes = agentItem.ID.GetBytes(); | 3913 | byte[] objBytes = agentItem.ID.GetBytes(); |
3929 | Array.Copy(objBytes, 0, bucket, 1, 16); | 3914 | Array.Copy(objBytes, 0, bucket, 1, 16); |
3930 | 3915 | ||
3931 | GridInstantMessage msg = new GridInstantMessage(World, | 3916 | GridInstantMessage msg = new GridInstantMessage(World, |
3932 | m_host.UUID, m_host.Name+", an object owned by "+ | 3917 | m_host.UUID, m_host.Name + ", an object owned by " + |
3933 | resolveName(m_host.OwnerID)+",", destId, | 3918 | resolveName(m_host.OwnerID) + ",", destId, |
3934 | (byte)InstantMessageDialog.TaskInventoryOffered, | 3919 | (byte)InstantMessageDialog.TaskInventoryOffered, |
3935 | false, objName+"\n"+m_host.Name+" is located at "+ | 3920 | false, item.Name + "\n" + m_host.Name + " is located at " + |
3936 | World.RegionInfo.RegionName+" "+ | 3921 | World.RegionInfo.RegionName+" "+ |
3937 | m_host.AbsolutePosition.ToString(), | 3922 | m_host.AbsolutePosition.ToString(), |
3938 | agentItem.ID, true, m_host.AbsolutePosition, | 3923 | agentItem.ID, true, m_host.AbsolutePosition, |
3939 | bucket); | 3924 | bucket); |
3925 | |||
3940 | if (m_TransferModule != null) | 3926 | if (m_TransferModule != null) |
3941 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 3927 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
3928 | |||
3942 | ScriptSleep(3000); | 3929 | ScriptSleep(3000); |
3943 | } | 3930 | } |
3944 | } | 3931 | } |