diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 574 |
1 files changed, 424 insertions, 150 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 8093502..d791885 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -28,11 +28,16 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | ||
32 | using System.Reflection; | ||
31 | using System.Runtime.Remoting.Lifetime; | 33 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 34 | using System.Text; |
33 | using System.Net; | 35 | using System.Net; |
34 | using System.Threading; | 36 | using System.Threading; |
37 | using System.Xml; | ||
38 | using log4net; | ||
35 | using OpenMetaverse; | 39 | using OpenMetaverse; |
40 | using OpenMetaverse.StructuredData; | ||
36 | using Nini.Config; | 41 | using Nini.Config; |
37 | using OpenSim; | 42 | using OpenSim; |
38 | using OpenSim.Framework; | 43 | using OpenSim.Framework; |
@@ -119,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
119 | [Serializable] | 124 | [Serializable] |
120 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi | 125 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi |
121 | { | 126 | { |
127 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
128 | |||
122 | internal IScriptEngine m_ScriptEngine; | 129 | internal IScriptEngine m_ScriptEngine; |
123 | internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there | 130 | internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there |
124 | internal SceneObjectPart m_host; | 131 | internal SceneObjectPart m_host; |
@@ -348,20 +355,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
348 | System.Threading.Thread.Sleep(delay); | 355 | System.Threading.Thread.Sleep(delay); |
349 | } | 356 | } |
350 | 357 | ||
351 | // | ||
352 | // OpenSim functions | ||
353 | // | ||
354 | public LSL_Integer osSetTerrainHeight(int x, int y, double val) | 358 | public LSL_Integer osSetTerrainHeight(int x, int y, double val) |
355 | { | 359 | { |
356 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); | 360 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); |
357 | return SetTerrainHeight(x, y, val); | 361 | return SetTerrainHeight(x, y, val); |
358 | } | 362 | } |
363 | |||
359 | public LSL_Integer osTerrainSetHeight(int x, int y, double val) | 364 | public LSL_Integer osTerrainSetHeight(int x, int y, double val) |
360 | { | 365 | { |
361 | CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); | 366 | CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); |
362 | OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); | 367 | OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); |
363 | return SetTerrainHeight(x, y, val); | 368 | return SetTerrainHeight(x, y, val); |
364 | } | 369 | } |
370 | |||
365 | private LSL_Integer SetTerrainHeight(int x, int y, double val) | 371 | private LSL_Integer SetTerrainHeight(int x, int y, double val) |
366 | { | 372 | { |
367 | m_host.AddScriptLPS(1); | 373 | m_host.AddScriptLPS(1); |
@@ -384,12 +390,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
384 | CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight"); | 390 | CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight"); |
385 | return GetTerrainHeight(x, y); | 391 | return GetTerrainHeight(x, y); |
386 | } | 392 | } |
393 | |||
387 | public LSL_Float osTerrainGetHeight(int x, int y) | 394 | public LSL_Float osTerrainGetHeight(int x, int y) |
388 | { | 395 | { |
389 | CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); | 396 | CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); |
390 | OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); | 397 | OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); |
391 | return GetTerrainHeight(x, y); | 398 | return GetTerrainHeight(x, y); |
392 | } | 399 | } |
400 | |||
393 | private LSL_Float GetTerrainHeight(int x, int y) | 401 | private LSL_Float GetTerrainHeight(int x, int y) |
394 | { | 402 | { |
395 | m_host.AddScriptLPS(1); | 403 | m_host.AddScriptLPS(1); |
@@ -862,7 +870,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
862 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; | 870 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; |
863 | if (target != null) | 871 | if (target != null) |
864 | { | 872 | { |
865 | UUID animID=UUID.Zero; | 873 | UUID animID = UUID.Zero; |
866 | lock (m_host.TaskInventory) | 874 | lock (m_host.TaskInventory) |
867 | { | 875 | { |
868 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 876 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) |
@@ -1021,6 +1029,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1021 | drawList += "PenColor " + color + "; "; | 1029 | drawList += "PenColor " + color + "; "; |
1022 | return drawList; | 1030 | return drawList; |
1023 | } | 1031 | } |
1032 | |||
1024 | // Deprecated | 1033 | // Deprecated |
1025 | public string osSetPenColour(string drawList, string colour) | 1034 | public string osSetPenColour(string drawList, string colour) |
1026 | { | 1035 | { |
@@ -1182,11 +1191,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1182 | OSSLDeprecated("osSunGetParam", "osGetSunParam"); | 1191 | OSSLDeprecated("osSunGetParam", "osGetSunParam"); |
1183 | return GetSunParam(param); | 1192 | return GetSunParam(param); |
1184 | } | 1193 | } |
1194 | |||
1185 | public double osGetSunParam(string param) | 1195 | public double osGetSunParam(string param) |
1186 | { | 1196 | { |
1187 | CheckThreatLevel(ThreatLevel.None, "osGetSunParam"); | 1197 | CheckThreatLevel(ThreatLevel.None, "osGetSunParam"); |
1188 | return GetSunParam(param); | 1198 | return GetSunParam(param); |
1189 | } | 1199 | } |
1200 | |||
1190 | private double GetSunParam(string param) | 1201 | private double GetSunParam(string param) |
1191 | { | 1202 | { |
1192 | m_host.AddScriptLPS(1); | 1203 | m_host.AddScriptLPS(1); |
@@ -1208,11 +1219,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1208 | OSSLDeprecated("osSunSetParam", "osSetSunParam"); | 1219 | OSSLDeprecated("osSunSetParam", "osSetSunParam"); |
1209 | SetSunParam(param, value); | 1220 | SetSunParam(param, value); |
1210 | } | 1221 | } |
1222 | |||
1211 | public void osSetSunParam(string param, double value) | 1223 | public void osSetSunParam(string param, double value) |
1212 | { | 1224 | { |
1213 | CheckThreatLevel(ThreatLevel.None, "osSetSunParam"); | 1225 | CheckThreatLevel(ThreatLevel.None, "osSetSunParam"); |
1214 | SetSunParam(param, value); | 1226 | SetSunParam(param, value); |
1215 | } | 1227 | } |
1228 | |||
1216 | private void SetSunParam(string param, double value) | 1229 | private void SetSunParam(string param, double value) |
1217 | { | 1230 | { |
1218 | m_host.AddScriptLPS(1); | 1231 | m_host.AddScriptLPS(1); |
@@ -1222,10 +1235,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1222 | { | 1235 | { |
1223 | module.SetSunParameter(param, value); | 1236 | module.SetSunParameter(param, value); |
1224 | } | 1237 | } |
1225 | |||
1226 | } | 1238 | } |
1227 | 1239 | ||
1228 | |||
1229 | public string osWindActiveModelPluginName() | 1240 | public string osWindActiveModelPluginName() |
1230 | { | 1241 | { |
1231 | CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); | 1242 | CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); |
@@ -1304,12 +1315,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1304 | OSSLDeprecated(functionName, "osSetParcelDetails"); | 1315 | OSSLDeprecated(functionName, "osSetParcelDetails"); |
1305 | SetParcelDetails(pos, rules, functionName); | 1316 | SetParcelDetails(pos, rules, functionName); |
1306 | } | 1317 | } |
1318 | |||
1307 | public void osSetParcelDetails(LSL_Vector pos, LSL_List rules) | 1319 | public void osSetParcelDetails(LSL_Vector pos, LSL_List rules) |
1308 | { | 1320 | { |
1309 | const string functionName = "osSetParcelDetails"; | 1321 | const string functionName = "osSetParcelDetails"; |
1310 | CheckThreatLevel(ThreatLevel.High, functionName); | 1322 | CheckThreatLevel(ThreatLevel.High, functionName); |
1311 | SetParcelDetails(pos, rules, functionName); | 1323 | SetParcelDetails(pos, rules, functionName); |
1312 | } | 1324 | } |
1325 | |||
1313 | private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) | 1326 | private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) |
1314 | { | 1327 | { |
1315 | m_host.AddScriptLPS(1); | 1328 | m_host.AddScriptLPS(1); |
@@ -1429,8 +1442,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1429 | voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); | 1442 | voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); |
1430 | else | 1443 | else |
1431 | OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); | 1444 | OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); |
1432 | |||
1433 | |||
1434 | } | 1445 | } |
1435 | 1446 | ||
1436 | public string osGetScriptEngineName() | 1447 | public string osGetScriptEngineName() |
@@ -1683,8 +1694,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1683 | return jsondata; | 1694 | return jsondata; |
1684 | } | 1695 | } |
1685 | 1696 | ||
1686 | // send a message to to object identified by the given UUID, a script in the object must implement the dataserver function | 1697 | /// <summary> |
1687 | // the dataserver function is passed the ID of the calling function and a string message | 1698 | /// Send a message to to object identified by the given UUID |
1699 | /// </summary> | ||
1700 | /// <remarks> | ||
1701 | /// A script in the object must implement the dataserver function | ||
1702 | /// the dataserver function is passed the ID of the calling function and a string message | ||
1703 | /// </remarks> | ||
1704 | /// <param name="objectUUID"></param> | ||
1705 | /// <param name="message"></param> | ||
1688 | public void osMessageObject(LSL_Key objectUUID, string message) | 1706 | public void osMessageObject(LSL_Key objectUUID, string message) |
1689 | { | 1707 | { |
1690 | CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); | 1708 | CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); |
@@ -1699,34 +1717,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1699 | "dataserver", resobj, new DetectParams[0])); | 1717 | "dataserver", resobj, new DetectParams[0])); |
1700 | } | 1718 | } |
1701 | 1719 | ||
1702 | 1720 | /// <summary> | |
1703 | // This needs ThreatLevel high. It is an excellent griefer tool, | 1721 | /// Write a notecard directly to the prim's inventory. |
1704 | // In a loop, it can cause asset bloat and DOS levels of asset | 1722 | /// </summary> |
1705 | // writes. | 1723 | /// <remarks> |
1706 | // | 1724 | /// This needs ThreatLevel high. It is an excellent griefer tool, |
1725 | /// In a loop, it can cause asset bloat and DOS levels of asset | ||
1726 | /// writes. | ||
1727 | /// </remarks> | ||
1728 | /// <param name="notecardName">The name of the notecard to write.</param> | ||
1729 | /// <param name="contents">The contents of the notecard.</param> | ||
1707 | public void osMakeNotecard(string notecardName, LSL_Types.list contents) | 1730 | public void osMakeNotecard(string notecardName, LSL_Types.list contents) |
1708 | { | 1731 | { |
1709 | CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); | 1732 | CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); |
1710 | m_host.AddScriptLPS(1); | 1733 | m_host.AddScriptLPS(1); |
1711 | 1734 | ||
1712 | // Create new asset | 1735 | StringBuilder notecardData = new StringBuilder(); |
1713 | AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); | ||
1714 | asset.Description = "Script Generated Notecard"; | ||
1715 | string notecardData = String.Empty; | ||
1716 | 1736 | ||
1717 | for (int i = 0; i < contents.Length; i++) { | 1737 | for (int i = 0; i < contents.Length; i++) |
1718 | notecardData += contents.GetLSLStringItem(i) + "\n"; | 1738 | notecardData.Append((string)(contents.GetLSLStringItem(i) + "\n")); |
1719 | } | 1739 | |
1740 | SaveNotecard(notecardName, "Script generated notecard", notecardData.ToString(), false); | ||
1741 | } | ||
1720 | 1742 | ||
1721 | int textLength = notecardData.Length; | 1743 | /// <summary> |
1722 | notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " | 1744 | /// Save a notecard to prim inventory. |
1723 | + textLength.ToString() + "\n" + notecardData + "}\n"; | 1745 | /// </summary> |
1746 | /// <param name="name"></param> | ||
1747 | /// <param name="description">Description of notecard</param> | ||
1748 | /// <param name="notecardData"></param> | ||
1749 | /// <param name="forceSameName"> | ||
1750 | /// If true, then if an item exists with the same name, it is replaced. | ||
1751 | /// If false, then a new item is created witha slightly different name (e.g. name 1) | ||
1752 | /// </param> | ||
1753 | /// <returns>Prim inventory item created.</returns> | ||
1754 | protected TaskInventoryItem SaveNotecard(string name, string description, string data, bool forceSameName) | ||
1755 | { | ||
1756 | // Create new asset | ||
1757 | AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); | ||
1758 | asset.Description = description; | ||
1724 | 1759 | ||
1725 | asset.Data = Util.UTF8.GetBytes(notecardData); | 1760 | int textLength = data.Length; |
1761 | data | ||
1762 | = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " | ||
1763 | + textLength.ToString() + "\n" + data + "}\n"; | ||
1764 | |||
1765 | asset.Data = Util.UTF8.GetBytes(data); | ||
1726 | World.AssetService.Store(asset); | 1766 | World.AssetService.Store(asset); |
1727 | 1767 | ||
1728 | // Create Task Entry | 1768 | // Create Task Entry |
1729 | TaskInventoryItem taskItem=new TaskInventoryItem(); | 1769 | TaskInventoryItem taskItem = new TaskInventoryItem(); |
1730 | 1770 | ||
1731 | taskItem.ResetIDs(m_host.UUID); | 1771 | taskItem.ResetIDs(m_host.UUID); |
1732 | taskItem.ParentID = m_host.UUID; | 1772 | taskItem.ParentID = m_host.UUID; |
@@ -1748,28 +1788,53 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1748 | taskItem.PermsMask = 0; | 1788 | taskItem.PermsMask = 0; |
1749 | taskItem.AssetID = asset.FullID; | 1789 | taskItem.AssetID = asset.FullID; |
1750 | 1790 | ||
1751 | m_host.Inventory.AddInventoryItem(taskItem, false); | 1791 | if (forceSameName) |
1792 | m_host.Inventory.AddInventoryItemExclusive(taskItem, false); | ||
1793 | else | ||
1794 | m_host.Inventory.AddInventoryItem(taskItem, false); | ||
1795 | |||
1796 | return taskItem; | ||
1752 | } | 1797 | } |
1753 | 1798 | ||
1799 | /// <summary> | ||
1800 | /// Load the notecard data found at the given prim inventory item name or asset uuid. | ||
1801 | /// </summary> | ||
1802 | /// <param name="notecardNameOrUuid"></param> | ||
1803 | /// <returns>The text loaded. Null if no notecard was found.</returns> | ||
1804 | protected string LoadNotecard(string notecardNameOrUuid) | ||
1805 | { | ||
1806 | UUID assetID = CacheNotecard(notecardNameOrUuid); | ||
1807 | StringBuilder notecardData = new StringBuilder(); | ||
1808 | |||
1809 | for (int count = 0; count < NotecardCache.GetLines(assetID); count++) | ||
1810 | { | ||
1811 | string line = NotecardCache.GetLine(assetID, count) + "\n"; | ||
1812 | |||
1813 | // m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line); | ||
1754 | 1814 | ||
1755 | /*Instead of using the LSL Dataserver event to pull notecard data, | 1815 | notecardData.Append(line); |
1756 | this will simply read the requested line and return its data as a string. | 1816 | } |
1757 | 1817 | ||
1758 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1818 | return notecardData.ToString(); |
1759 | may be dangerous and unreliable while running in grid mode. | 1819 | } |
1760 | */ | ||
1761 | public string osGetNotecardLine(string name, int line) | ||
1762 | { | ||
1763 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); | ||
1764 | m_host.AddScriptLPS(1); | ||
1765 | 1820 | ||
1821 | /// <summary> | ||
1822 | /// Cache a notecard's contents. | ||
1823 | /// </summary> | ||
1824 | /// <param name="notecardNameOrUuid"></param> | ||
1825 | /// <returns> | ||
1826 | /// The asset id of the notecard, which is used for retrieving the cached data. | ||
1827 | /// UUID.Zero if no asset could be found. | ||
1828 | /// </returns> | ||
1829 | protected UUID CacheNotecard(string notecardNameOrUuid) | ||
1830 | { | ||
1766 | UUID assetID = UUID.Zero; | 1831 | UUID assetID = UUID.Zero; |
1767 | 1832 | ||
1768 | if (!UUID.TryParse(name, out assetID)) | 1833 | if (!UUID.TryParse(notecardNameOrUuid, out assetID)) |
1769 | { | 1834 | { |
1770 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1835 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1771 | { | 1836 | { |
1772 | if (item.Type == 7 && item.Name == name) | 1837 | if (item.Type == 7 && item.Name == notecardNameOrUuid) |
1773 | { | 1838 | { |
1774 | assetID = item.AssetID; | 1839 | assetID = item.AssetID; |
1775 | } | 1840 | } |
@@ -1777,114 +1842,100 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1777 | } | 1842 | } |
1778 | 1843 | ||
1779 | if (assetID == UUID.Zero) | 1844 | if (assetID == UUID.Zero) |
1780 | { | 1845 | return UUID.Zero; |
1781 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1782 | return "ERROR!"; | ||
1783 | } | ||
1784 | 1846 | ||
1785 | if (!NotecardCache.IsCached(assetID)) | 1847 | if (!NotecardCache.IsCached(assetID)) |
1786 | { | 1848 | { |
1787 | AssetBase a = World.AssetService.Get(assetID.ToString()); | 1849 | AssetBase a = World.AssetService.Get(assetID.ToString()); |
1788 | if (a != null) | ||
1789 | { | ||
1790 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | ||
1791 | string data = enc.GetString(a.Data); | ||
1792 | NotecardCache.Cache(assetID, data); | ||
1793 | } | ||
1794 | else | ||
1795 | { | ||
1796 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1797 | return "ERROR!"; | ||
1798 | } | ||
1799 | }; | ||
1800 | 1850 | ||
1801 | return NotecardCache.GetLine(assetID, line, 255); | 1851 | if (a == null) |
1852 | return UUID.Zero; | ||
1802 | 1853 | ||
1854 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | ||
1855 | string data = enc.GetString(a.Data); | ||
1856 | NotecardCache.Cache(assetID, data); | ||
1857 | }; | ||
1803 | 1858 | ||
1859 | return assetID; | ||
1804 | } | 1860 | } |
1805 | 1861 | ||
1806 | /*Instead of using the LSL Dataserver event to pull notecard data line by line, | 1862 | /// <summary> |
1807 | this will simply read the entire notecard and return its data as a string. | 1863 | /// Directly get an entire notecard at once. |
1864 | /// </summary> | ||
1865 | /// <remarks> | ||
1866 | /// Instead of using the LSL Dataserver event to pull notecard data | ||
1867 | /// this will simply read the entire notecard and return its data as a string. | ||
1868 | /// | ||
1869 | /// Warning - due to the synchronous method this function uses to fetch assets, its use | ||
1870 | /// may be dangerous and unreliable while running in grid mode. | ||
1871 | /// </remarks> | ||
1872 | /// <param name="name">Name of the notecard or its asset id</param> | ||
1873 | /// <param name="line">The line number to read. The first line is line 0</param> | ||
1874 | /// <returns>Notecard line</returns> | ||
1875 | public string osGetNotecardLine(string name, int line) | ||
1876 | { | ||
1877 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); | ||
1878 | m_host.AddScriptLPS(1); | ||
1879 | |||
1880 | UUID assetID = CacheNotecard(name); | ||
1881 | |||
1882 | if (assetID == UUID.Zero) | ||
1883 | { | ||
1884 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1885 | return "ERROR!"; | ||
1886 | } | ||
1808 | 1887 | ||
1809 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1888 | return NotecardCache.GetLine(assetID, line); |
1810 | may be dangerous and unreliable while running in grid mode. | 1889 | } |
1811 | */ | ||
1812 | 1890 | ||
1891 | /// <summary> | ||
1892 | /// Get an entire notecard at once. | ||
1893 | /// </summary> | ||
1894 | /// <remarks> | ||
1895 | /// Instead of using the LSL Dataserver event to pull notecard data line by line, | ||
1896 | /// this will simply read the entire notecard and return its data as a string. | ||
1897 | /// | ||
1898 | /// Warning - due to the synchronous method this function uses to fetch assets, its use | ||
1899 | /// may be dangerous and unreliable while running in grid mode. | ||
1900 | /// </remarks> | ||
1901 | /// <param name="name">Name of the notecard or its asset id</param> | ||
1902 | /// <returns>Notecard text</returns> | ||
1813 | public string osGetNotecard(string name) | 1903 | public string osGetNotecard(string name) |
1814 | { | 1904 | { |
1815 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); | 1905 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); |
1816 | m_host.AddScriptLPS(1); | 1906 | m_host.AddScriptLPS(1); |
1817 | 1907 | ||
1818 | UUID assetID = UUID.Zero; | 1908 | string text = LoadNotecard(name); |
1819 | string NotecardData = ""; | ||
1820 | |||
1821 | if (!UUID.TryParse(name, out assetID)) | ||
1822 | { | ||
1823 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
1824 | { | ||
1825 | if (item.Type == 7 && item.Name == name) | ||
1826 | { | ||
1827 | assetID = item.AssetID; | ||
1828 | } | ||
1829 | } | ||
1830 | } | ||
1831 | 1909 | ||
1832 | if (assetID == UUID.Zero) | 1910 | if (text == null) |
1833 | { | 1911 | { |
1834 | OSSLShoutError("Notecard '" + name + "' could not be found."); | 1912 | OSSLShoutError("Notecard '" + name + "' could not be found."); |
1835 | return "ERROR!"; | 1913 | return "ERROR!"; |
1836 | } | 1914 | } |
1837 | 1915 | else | |
1838 | if (!NotecardCache.IsCached(assetID)) | ||
1839 | { | ||
1840 | AssetBase a = World.AssetService.Get(assetID.ToString()); | ||
1841 | if (a != null) | ||
1842 | { | ||
1843 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | ||
1844 | string data = enc.GetString(a.Data); | ||
1845 | NotecardCache.Cache(assetID, data); | ||
1846 | } | ||
1847 | else | ||
1848 | { | ||
1849 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1850 | return "ERROR!"; | ||
1851 | } | ||
1852 | }; | ||
1853 | |||
1854 | for (int count = 0; count < NotecardCache.GetLines(assetID); count++) | ||
1855 | { | 1916 | { |
1856 | NotecardData += NotecardCache.GetLine(assetID, count, 255) + "\n"; | 1917 | return text; |
1857 | } | 1918 | } |
1858 | |||
1859 | return NotecardData; | ||
1860 | |||
1861 | |||
1862 | } | 1919 | } |
1863 | 1920 | ||
1864 | /*Instead of using the LSL Dataserver event to pull notecard data, | 1921 | /// <summary> |
1865 | this will simply read the number of note card lines and return this data as an integer. | 1922 | /// Get the number of lines in the given notecard. |
1866 | 1923 | /// </summary> | |
1867 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1924 | /// <remarks> |
1868 | may be dangerous and unreliable while running in grid mode. | 1925 | /// Instead of using the LSL Dataserver event to pull notecard data, |
1869 | */ | 1926 | /// this will simply read the number of note card lines and return this data as an integer. |
1870 | 1927 | /// | |
1928 | /// Warning - due to the synchronous method this function uses to fetch assets, its use | ||
1929 | /// may be dangerous and unreliable while running in grid mode. | ||
1930 | /// </remarks> | ||
1931 | /// <param name="name">Name of the notecard or its asset id</param> | ||
1932 | /// <returns></returns> | ||
1871 | public int osGetNumberOfNotecardLines(string name) | 1933 | public int osGetNumberOfNotecardLines(string name) |
1872 | { | 1934 | { |
1873 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); | 1935 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); |
1874 | m_host.AddScriptLPS(1); | 1936 | m_host.AddScriptLPS(1); |
1875 | 1937 | ||
1876 | UUID assetID = UUID.Zero; | 1938 | UUID assetID = CacheNotecard(name); |
1877 | |||
1878 | if (!UUID.TryParse(name, out assetID)) | ||
1879 | { | ||
1880 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
1881 | { | ||
1882 | if (item.Type == 7 && item.Name == name) | ||
1883 | { | ||
1884 | assetID = item.AssetID; | ||
1885 | } | ||
1886 | } | ||
1887 | } | ||
1888 | 1939 | ||
1889 | if (assetID == UUID.Zero) | 1940 | if (assetID == UUID.Zero) |
1890 | { | 1941 | { |
@@ -1892,22 +1943,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1892 | return -1; | 1943 | return -1; |
1893 | } | 1944 | } |
1894 | 1945 | ||
1895 | if (!NotecardCache.IsCached(assetID)) | ||
1896 | { | ||
1897 | AssetBase a = World.AssetService.Get(assetID.ToString()); | ||
1898 | if (a != null) | ||
1899 | { | ||
1900 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | ||
1901 | string data = enc.GetString(a.Data); | ||
1902 | NotecardCache.Cache(assetID, data); | ||
1903 | } | ||
1904 | else | ||
1905 | { | ||
1906 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1907 | return -1; | ||
1908 | } | ||
1909 | }; | ||
1910 | |||
1911 | return NotecardCache.GetLines(assetID); | 1946 | return NotecardCache.GetLines(assetID); |
1912 | } | 1947 | } |
1913 | 1948 | ||
@@ -1947,15 +1982,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1947 | { | 1982 | { |
1948 | return ""; | 1983 | return ""; |
1949 | } | 1984 | } |
1950 | |||
1951 | } | 1985 | } |
1952 | 1986 | ||
1987 | /// <summary> | ||
1988 | /// Get the nickname of this grid, as set in the [GridInfo] config section. | ||
1989 | /// </summary> | ||
1990 | /// <remarks> | ||
1953 | /// Threat level is Moderate because intentional abuse, for instance | 1991 | /// Threat level is Moderate because intentional abuse, for instance |
1954 | /// scripts that are written to be malicious only on one grid, | 1992 | /// scripts that are written to be malicious only on one grid, |
1955 | /// for instance in a HG scenario, are a distinct possibility. | 1993 | /// for instance in a HG scenario, are a distinct possibility. |
1956 | /// | 1994 | /// </remarks> |
1957 | /// Use value from the config file and return it. | 1995 | /// <returns></returns> |
1958 | /// | ||
1959 | public string osGetGridNick() | 1996 | public string osGetGridNick() |
1960 | { | 1997 | { |
1961 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); | 1998 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); |
@@ -2063,12 +2100,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2063 | return World.RegionInfo.RegionSettings.LoadedCreationID; | 2100 | return World.RegionInfo.RegionSettings.LoadedCreationID; |
2064 | } | 2101 | } |
2065 | 2102 | ||
2066 | // Threat level is 'Low' because certain users could possibly be tricked into | 2103 | /// <summary> |
2067 | // dropping an unverified script into one of their own objects, which could | 2104 | /// Get the primitive parameters of a linked prim. |
2068 | // then gather the physical construction details of the object and transmit it | 2105 | /// </summary> |
2069 | // to an unscrupulous third party, thus permitting unauthorized duplication of | 2106 | /// <remarks> |
2070 | // the object's form. | 2107 | /// Threat level is 'Low' because certain users could possibly be tricked into |
2071 | // | 2108 | /// dropping an unverified script into one of their own objects, which could |
2109 | /// then gather the physical construction details of the object and transmit it | ||
2110 | /// to an unscrupulous third party, thus permitting unauthorized duplication of | ||
2111 | /// the object's form. | ||
2112 | /// </remarks> | ||
2113 | /// <param name="linknumber"></param> | ||
2114 | /// <param name="rules"></param> | ||
2115 | /// <returns></returns> | ||
2072 | public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) | 2116 | public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) |
2073 | { | 2117 | { |
2074 | CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); | 2118 | CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); |
@@ -2083,25 +2127,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2083 | return retVal; | 2127 | return retVal; |
2084 | } | 2128 | } |
2085 | 2129 | ||
2086 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) | 2130 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) |
2087 | { | 2131 | { |
2088 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | 2132 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); |
2089 | //QueueUserWorkItem | ||
2090 | 2133 | ||
2091 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2134 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2092 | if (module != null) | 2135 | if (module != null) |
2093 | { | 2136 | { |
2137 | AvatarAppearance appearance = null; | ||
2138 | |||
2139 | UUID id; | ||
2140 | if (UUID.TryParse(notecard, out id)) | ||
2141 | { | ||
2142 | ScenePresence clonePresence = World.GetScenePresence(id); | ||
2143 | if (clonePresence != null) | ||
2144 | appearance = clonePresence.Appearance; | ||
2145 | } | ||
2146 | |||
2147 | if (appearance == null) | ||
2148 | { | ||
2149 | string appearanceSerialized = LoadNotecard(notecard); | ||
2150 | |||
2151 | if (appearanceSerialized != null) | ||
2152 | { | ||
2153 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | ||
2154 | appearance = new AvatarAppearance(); | ||
2155 | appearance.Unpack(appearanceOsd); | ||
2156 | } | ||
2157 | } | ||
2158 | |||
2159 | if (appearance == null) | ||
2160 | return new LSL_Key(UUID.Zero.ToString()); | ||
2161 | |||
2094 | UUID x = module.CreateNPC(firstname, | 2162 | UUID x = module.CreateNPC(firstname, |
2095 | lastname, | 2163 | lastname, |
2096 | new Vector3((float) position.x, (float) position.y, (float) position.z), | 2164 | new Vector3((float) position.x, (float) position.y, (float) position.z), |
2097 | World, | 2165 | World, |
2098 | new UUID(cloneFrom)); | 2166 | appearance); |
2099 | 2167 | ||
2100 | return new LSL_Key(x.ToString()); | 2168 | return new LSL_Key(x.ToString()); |
2101 | } | 2169 | } |
2170 | |||
2102 | return new LSL_Key(UUID.Zero.ToString()); | 2171 | return new LSL_Key(UUID.Zero.ToString()); |
2103 | } | 2172 | } |
2104 | 2173 | ||
2174 | /// <summary> | ||
2175 | /// Save the current appearance of the NPC permanently to the named notecard. | ||
2176 | /// </summary> | ||
2177 | /// <param name="avatar"></param> | ||
2178 | /// <param name="notecard">The name of the notecard to which to save the appearance.</param> | ||
2179 | /// <returns>The asset ID of the notecard saved.</returns> | ||
2180 | public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard) | ||
2181 | { | ||
2182 | CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); | ||
2183 | |||
2184 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2185 | |||
2186 | if (npcModule != null) | ||
2187 | { | ||
2188 | UUID npcId; | ||
2189 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2190 | return new LSL_Key(UUID.Zero.ToString()); | ||
2191 | |||
2192 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2193 | return new LSL_Key(UUID.Zero.ToString()); | ||
2194 | |||
2195 | return SaveAppearanceToNotecard(npcId, notecard); | ||
2196 | } | ||
2197 | |||
2198 | return new LSL_Key(UUID.Zero.ToString()); | ||
2199 | } | ||
2200 | |||
2201 | public void osNpcLoadAppearance(LSL_Key npc, string notecard) | ||
2202 | { | ||
2203 | CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); | ||
2204 | |||
2205 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2206 | |||
2207 | if (npcModule != null) | ||
2208 | { | ||
2209 | UUID npcId; | ||
2210 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2211 | return; | ||
2212 | |||
2213 | string appearanceSerialized = LoadNotecard(notecard); | ||
2214 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | ||
2215 | // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); | ||
2216 | // Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); | ||
2217 | // Console.WriteLine("a.Type {0}, a.ToString() {1}", a.Type, a); | ||
2218 | AvatarAppearance appearance = new AvatarAppearance(); | ||
2219 | appearance.Unpack(appearanceOsd); | ||
2220 | |||
2221 | npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene); | ||
2222 | } | ||
2223 | } | ||
2224 | |||
2225 | public LSL_Vector osNpcGetPos(LSL_Key npc) | ||
2226 | { | ||
2227 | CheckThreatLevel(ThreatLevel.High, "osNpcGetPos"); | ||
2228 | |||
2229 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2230 | if (npcModule != null) | ||
2231 | { | ||
2232 | UUID npcId; | ||
2233 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2234 | return new LSL_Vector(0, 0, 0); | ||
2235 | |||
2236 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2237 | return new LSL_Vector(0, 0, 0); | ||
2238 | |||
2239 | Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition; | ||
2240 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | ||
2241 | } | ||
2242 | |||
2243 | return new LSL_Vector(0, 0, 0); | ||
2244 | } | ||
2245 | |||
2105 | public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) | 2246 | public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) |
2106 | { | 2247 | { |
2107 | CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); | 2248 | CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); |
@@ -2109,11 +2250,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2109 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2250 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2110 | if (module != null) | 2251 | if (module != null) |
2111 | { | 2252 | { |
2253 | UUID npcId; | ||
2254 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2255 | return; | ||
2256 | |||
2112 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); | 2257 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); |
2113 | module.MoveToTarget(new UUID(npc.m_string), World, pos); | 2258 | module.MoveToTarget(npcId, World, pos, false, true); |
2114 | } | 2259 | } |
2115 | } | 2260 | } |
2116 | 2261 | ||
2262 | public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options) | ||
2263 | { | ||
2264 | CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); | ||
2265 | |||
2266 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2267 | if (module != null) | ||
2268 | { | ||
2269 | UUID npcId; | ||
2270 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2271 | return; | ||
2272 | |||
2273 | Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z); | ||
2274 | module.MoveToTarget( | ||
2275 | new UUID(npc.m_string), | ||
2276 | World, | ||
2277 | pos, | ||
2278 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, | ||
2279 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); | ||
2280 | } | ||
2281 | } | ||
2282 | |||
2283 | public LSL_Rotation osNpcGetRot(LSL_Key npc) | ||
2284 | { | ||
2285 | CheckThreatLevel(ThreatLevel.High, "osNpcGetRot"); | ||
2286 | |||
2287 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2288 | if (npcModule != null) | ||
2289 | { | ||
2290 | UUID npcId; | ||
2291 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2292 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | ||
2293 | |||
2294 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2295 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | ||
2296 | |||
2297 | ScenePresence sp = World.GetScenePresence(npcId); | ||
2298 | Quaternion rot = sp.Rotation; | ||
2299 | |||
2300 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | ||
2301 | } | ||
2302 | |||
2303 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | ||
2304 | } | ||
2305 | |||
2306 | public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) | ||
2307 | { | ||
2308 | CheckThreatLevel(ThreatLevel.High, "osNpcSetRot"); | ||
2309 | |||
2310 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2311 | if (npcModule != null) | ||
2312 | { | ||
2313 | UUID npcId; | ||
2314 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2315 | return; | ||
2316 | |||
2317 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2318 | return; | ||
2319 | |||
2320 | ScenePresence sp = World.GetScenePresence(npcId); | ||
2321 | sp.Rotation = LSL_Api.Rot2Quaternion(rotation); | ||
2322 | } | ||
2323 | } | ||
2324 | |||
2325 | public void osNpcStopMoveToTarget(LSL_Key npc) | ||
2326 | { | ||
2327 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); | ||
2328 | |||
2329 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2330 | if (module != null) | ||
2331 | module.StopMoveToTarget(new UUID(npc.m_string), World); | ||
2332 | } | ||
2333 | |||
2117 | public void osNpcSay(LSL_Key npc, string message) | 2334 | public void osNpcSay(LSL_Key npc, string message) |
2118 | { | 2335 | { |
2119 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); | 2336 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); |
@@ -2135,6 +2352,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2135 | module.DeleteNPC(new UUID(npc.m_string), World); | 2352 | module.DeleteNPC(new UUID(npc.m_string), World); |
2136 | } | 2353 | } |
2137 | } | 2354 | } |
2355 | |||
2356 | /// <summary> | ||
2357 | /// Save the current appearance of the script owner permanently to the named notecard. | ||
2358 | /// </summary> | ||
2359 | /// <param name="notecard">The name of the notecard to which to save the appearance.</param> | ||
2360 | /// <returns>The asset ID of the notecard saved.</returns> | ||
2361 | public LSL_Key osOwnerSaveAppearance(string notecard) | ||
2362 | { | ||
2363 | CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance"); | ||
2364 | |||
2365 | return SaveAppearanceToNotecard(m_host.OwnerID, notecard); | ||
2366 | } | ||
2367 | |||
2368 | public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard) | ||
2369 | { | ||
2370 | CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance"); | ||
2371 | |||
2372 | return SaveAppearanceToNotecard(avatarId, notecard); | ||
2373 | } | ||
2374 | |||
2375 | protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard) | ||
2376 | { | ||
2377 | IAvatarFactory appearanceModule = World.RequestModuleInterface<IAvatarFactory>(); | ||
2378 | |||
2379 | if (appearanceModule != null) | ||
2380 | { | ||
2381 | appearanceModule.SaveBakedTextures(sp.UUID); | ||
2382 | OSDMap appearancePacked = sp.Appearance.Pack(); | ||
2383 | |||
2384 | TaskInventoryItem item | ||
2385 | = SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true); | ||
2386 | |||
2387 | return new LSL_Key(item.AssetID.ToString()); | ||
2388 | } | ||
2389 | else | ||
2390 | { | ||
2391 | return new LSL_Key(UUID.Zero.ToString()); | ||
2392 | } | ||
2393 | } | ||
2394 | |||
2395 | protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecard) | ||
2396 | { | ||
2397 | ScenePresence sp = World.GetScenePresence(avatarId); | ||
2398 | |||
2399 | if (sp == null || sp.IsChildAgent) | ||
2400 | return new LSL_Key(UUID.Zero.ToString()); | ||
2401 | |||
2402 | return SaveAppearanceToNotecard(sp, notecard); | ||
2403 | } | ||
2404 | |||
2405 | protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard) | ||
2406 | { | ||
2407 | UUID avatarId; | ||
2408 | if (!UUID.TryParse(rawAvatarId, out avatarId)) | ||
2409 | return new LSL_Key(UUID.Zero.ToString()); | ||
2410 | |||
2411 | return SaveAppearanceToNotecard(avatarId, notecard); | ||
2412 | } | ||
2138 | 2413 | ||
2139 | /// <summary> | 2414 | /// <summary> |
2140 | /// Get current region's map texture UUID | 2415 | /// Get current region's map texture UUID |
@@ -2344,10 +2619,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2344 | obj.Shape.ProjectionFocus = (float)focus; | 2619 | obj.Shape.ProjectionFocus = (float)focus; |
2345 | obj.Shape.ProjectionAmbiance = (float)amb; | 2620 | obj.Shape.ProjectionAmbiance = (float)amb; |
2346 | 2621 | ||
2347 | |||
2348 | obj.ParentGroup.HasGroupChanged = true; | 2622 | obj.ParentGroup.HasGroupChanged = true; |
2349 | obj.ScheduleFullUpdate(); | 2623 | obj.ScheduleFullUpdate(); |
2350 | |||
2351 | } | 2624 | } |
2352 | 2625 | ||
2353 | /// <summary> | 2626 | /// <summary> |
@@ -2372,6 +2645,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2372 | } | 2645 | } |
2373 | } | 2646 | } |
2374 | }); | 2647 | }); |
2648 | |||
2375 | return result; | 2649 | return result; |
2376 | } | 2650 | } |
2377 | 2651 | ||
@@ -2391,4 +2665,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2391 | return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); | 2665 | return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); |
2392 | } | 2666 | } |
2393 | } | 2667 | } |
2394 | } | 2668 | } \ No newline at end of file |