diff options
author | teravus | 2013-01-21 17:30:38 -0500 |
---|---|---|
committer | teravus | 2013-01-21 17:30:38 -0500 |
commit | 09a3e134e4fd9300899131f13b5be1494a767970 (patch) | |
tree | e5abdaad7a3b1c720a2bdfed0c81623679afbd31 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |
parent | Merge branch 'ubitwork' into avination (diff) | |
download | opensim-SC_OLD-09a3e134e4fd9300899131f13b5be1494a767970.zip opensim-SC_OLD-09a3e134e4fd9300899131f13b5be1494a767970.tar.gz opensim-SC_OLD-09a3e134e4fd9300899131f13b5be1494a767970.tar.bz2 opensim-SC_OLD-09a3e134e4fd9300899131f13b5be1494a767970.tar.xz |
* Fix notecard loading - If the notecard name is formatted like a UUID but isn't an actual asset UUID, then try to load it like an asset id first, then try to load it as a task inventoryitem name. If the passed UUID is a string, try to load it like a task inventory item name.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 51c8c7e..7c2f8ed 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -1821,17 +1821,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1821 | { | 1821 | { |
1822 | UUID assetID = UUID.Zero; | 1822 | UUID assetID = UUID.Zero; |
1823 | 1823 | ||
1824 | if (!UUID.TryParse(notecardNameOrUuid, out assetID)) | 1824 | bool notecardNameIsUUID = UUID.TryParse(notecardNameOrUuid, out assetID); |
1825 | |||
1826 | if (!notecardNameIsUUID) | ||
1825 | { | 1827 | { |
1826 | m_host.TaskInventory.LockItemsForRead(true); | 1828 | assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid); |
1827 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
1828 | { | ||
1829 | if (item.Type == 7 && item.Name == notecardNameOrUuid) | ||
1830 | { | ||
1831 | assetID = item.AssetID; | ||
1832 | } | ||
1833 | } | ||
1834 | m_host.TaskInventory.LockItemsForRead(false); | ||
1835 | } | 1829 | } |
1836 | 1830 | ||
1837 | if (assetID == UUID.Zero) | 1831 | if (assetID == UUID.Zero) |
@@ -1842,7 +1836,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1842 | AssetBase a = World.AssetService.Get(assetID.ToString()); | 1836 | AssetBase a = World.AssetService.Get(assetID.ToString()); |
1843 | 1837 | ||
1844 | if (a == null) | 1838 | if (a == null) |
1845 | return UUID.Zero; | 1839 | { |
1840 | // Whoops, it's still possible here that the notecard name was properly | ||
1841 | // formatted like a UUID but isn't an asset UUID so lets look it up by name after all | ||
1842 | assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid); | ||
1843 | if (assetID == UUID.Zero) | ||
1844 | return UUID.Zero; | ||
1845 | |||
1846 | if (!NotecardCache.IsCached(assetID)) | ||
1847 | { | ||
1848 | a = World.AssetService.Get(assetID.ToString()); | ||
1849 | |||
1850 | if (a == null) | ||
1851 | { | ||
1852 | return UUID.Zero; | ||
1853 | } | ||
1854 | } | ||
1855 | } | ||
1846 | 1856 | ||
1847 | string data = Encoding.UTF8.GetString(a.Data); | 1857 | string data = Encoding.UTF8.GetString(a.Data); |
1848 | NotecardCache.Cache(assetID, data); | 1858 | NotecardCache.Cache(assetID, data); |
@@ -1850,6 +1860,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1850 | 1860 | ||
1851 | return assetID; | 1861 | return assetID; |
1852 | } | 1862 | } |
1863 | protected UUID SearchTaskInventoryForAssetId(string name) | ||
1864 | { | ||
1865 | UUID assetId = UUID.Zero; | ||
1866 | m_host.TaskInventory.LockItemsForRead(true); | ||
1867 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
1868 | { | ||
1869 | if (item.Type == 7 && item.Name == name) | ||
1870 | { | ||
1871 | assetId = item.AssetID; | ||
1872 | } | ||
1873 | } | ||
1874 | m_host.TaskInventory.LockItemsForRead(false); | ||
1875 | return assetId; | ||
1876 | } | ||
1853 | 1877 | ||
1854 | /// <summary> | 1878 | /// <summary> |
1855 | /// Directly get an entire notecard at once. | 1879 | /// Directly get an entire notecard at once. |