aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-08 23:22:47 +0100
committerJustin Clark-Casey (justincc)2011-08-08 23:22:47 +0100
commit78d8ce3816cde8702cfd4f5d198e2c69aff0a7be (patch)
treeedf8e4b0f08d7e0b178e3126340c1b66c5f759bf /OpenSim
parentget rid of bogus log message (diff)
downloadopensim-SC-78d8ce3816cde8702cfd4f5d198e2c69aff0a7be.zip
opensim-SC-78d8ce3816cde8702cfd4f5d198e2c69aff0a7be.tar.gz
opensim-SC-78d8ce3816cde8702cfd4f5d198e2c69aff0a7be.tar.bz2
opensim-SC-78d8ce3816cde8702cfd4f5d198e2c69aff0a7be.tar.xz
refactor: split out generic parts of osMakeNotecard() into a separate. Add method doc. Other minor tidies.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs157
1 files changed, 99 insertions, 58 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..32ad21f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -348,20 +348,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
348 System.Threading.Thread.Sleep(delay); 348 System.Threading.Thread.Sleep(delay);
349 } 349 }
350 350
351 //
352 // OpenSim functions
353 //
354 public LSL_Integer osSetTerrainHeight(int x, int y, double val) 351 public LSL_Integer osSetTerrainHeight(int x, int y, double val)
355 { 352 {
356 CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); 353 CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight");
357 return SetTerrainHeight(x, y, val); 354 return SetTerrainHeight(x, y, val);
358 } 355 }
356
359 public LSL_Integer osTerrainSetHeight(int x, int y, double val) 357 public LSL_Integer osTerrainSetHeight(int x, int y, double val)
360 { 358 {
361 CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); 359 CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight");
362 OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); 360 OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight");
363 return SetTerrainHeight(x, y, val); 361 return SetTerrainHeight(x, y, val);
364 } 362 }
363
365 private LSL_Integer SetTerrainHeight(int x, int y, double val) 364 private LSL_Integer SetTerrainHeight(int x, int y, double val)
366 { 365 {
367 m_host.AddScriptLPS(1); 366 m_host.AddScriptLPS(1);
@@ -384,12 +383,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
384 CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight"); 383 CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight");
385 return GetTerrainHeight(x, y); 384 return GetTerrainHeight(x, y);
386 } 385 }
386
387 public LSL_Float osTerrainGetHeight(int x, int y) 387 public LSL_Float osTerrainGetHeight(int x, int y)
388 { 388 {
389 CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); 389 CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight");
390 OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); 390 OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight");
391 return GetTerrainHeight(x, y); 391 return GetTerrainHeight(x, y);
392 } 392 }
393
393 private LSL_Float GetTerrainHeight(int x, int y) 394 private LSL_Float GetTerrainHeight(int x, int y)
394 { 395 {
395 m_host.AddScriptLPS(1); 396 m_host.AddScriptLPS(1);
@@ -1021,6 +1022,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1021 drawList += "PenColor " + color + "; "; 1022 drawList += "PenColor " + color + "; ";
1022 return drawList; 1023 return drawList;
1023 } 1024 }
1025
1024 // Deprecated 1026 // Deprecated
1025 public string osSetPenColour(string drawList, string colour) 1027 public string osSetPenColour(string drawList, string colour)
1026 { 1028 {
@@ -1182,11 +1184,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1182 OSSLDeprecated("osSunGetParam", "osGetSunParam"); 1184 OSSLDeprecated("osSunGetParam", "osGetSunParam");
1183 return GetSunParam(param); 1185 return GetSunParam(param);
1184 } 1186 }
1187
1185 public double osGetSunParam(string param) 1188 public double osGetSunParam(string param)
1186 { 1189 {
1187 CheckThreatLevel(ThreatLevel.None, "osGetSunParam"); 1190 CheckThreatLevel(ThreatLevel.None, "osGetSunParam");
1188 return GetSunParam(param); 1191 return GetSunParam(param);
1189 } 1192 }
1193
1190 private double GetSunParam(string param) 1194 private double GetSunParam(string param)
1191 { 1195 {
1192 m_host.AddScriptLPS(1); 1196 m_host.AddScriptLPS(1);
@@ -1208,11 +1212,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1208 OSSLDeprecated("osSunSetParam", "osSetSunParam"); 1212 OSSLDeprecated("osSunSetParam", "osSetSunParam");
1209 SetSunParam(param, value); 1213 SetSunParam(param, value);
1210 } 1214 }
1215
1211 public void osSetSunParam(string param, double value) 1216 public void osSetSunParam(string param, double value)
1212 { 1217 {
1213 CheckThreatLevel(ThreatLevel.None, "osSetSunParam"); 1218 CheckThreatLevel(ThreatLevel.None, "osSetSunParam");
1214 SetSunParam(param, value); 1219 SetSunParam(param, value);
1215 } 1220 }
1221
1216 private void SetSunParam(string param, double value) 1222 private void SetSunParam(string param, double value)
1217 { 1223 {
1218 m_host.AddScriptLPS(1); 1224 m_host.AddScriptLPS(1);
@@ -1222,10 +1228,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1222 { 1228 {
1223 module.SetSunParameter(param, value); 1229 module.SetSunParameter(param, value);
1224 } 1230 }
1225
1226 } 1231 }
1227 1232
1228
1229 public string osWindActiveModelPluginName() 1233 public string osWindActiveModelPluginName()
1230 { 1234 {
1231 CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); 1235 CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName");
@@ -1304,12 +1308,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1304 OSSLDeprecated(functionName, "osSetParcelDetails"); 1308 OSSLDeprecated(functionName, "osSetParcelDetails");
1305 SetParcelDetails(pos, rules, functionName); 1309 SetParcelDetails(pos, rules, functionName);
1306 } 1310 }
1311
1307 public void osSetParcelDetails(LSL_Vector pos, LSL_List rules) 1312 public void osSetParcelDetails(LSL_Vector pos, LSL_List rules)
1308 { 1313 {
1309 const string functionName = "osSetParcelDetails"; 1314 const string functionName = "osSetParcelDetails";
1310 CheckThreatLevel(ThreatLevel.High, functionName); 1315 CheckThreatLevel(ThreatLevel.High, functionName);
1311 SetParcelDetails(pos, rules, functionName); 1316 SetParcelDetails(pos, rules, functionName);
1312 } 1317 }
1318
1313 private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) 1319 private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName)
1314 { 1320 {
1315 m_host.AddScriptLPS(1); 1321 m_host.AddScriptLPS(1);
@@ -1429,8 +1435,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1429 voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); 1435 voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID);
1430 else 1436 else
1431 OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); 1437 OSSLError("osSetParcelSIPAddress: No voice module enabled for this land");
1432
1433
1434 } 1438 }
1435 1439
1436 public string osGetScriptEngineName() 1440 public string osGetScriptEngineName()
@@ -1683,8 +1687,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1683 return jsondata; 1687 return jsondata;
1684 } 1688 }
1685 1689
1686 // send a message to to object identified by the given UUID, a script in the object must implement the dataserver function 1690 /// <summary>
1687 // the dataserver function is passed the ID of the calling function and a string message 1691 /// Send a message to to object identified by the given UUID
1692 /// </summary>
1693 /// <remarks>
1694 /// A script in the object must implement the dataserver function
1695 /// the dataserver function is passed the ID of the calling function and a string message
1696 /// </remarks>
1697 /// <param name="objectUUID"></param>
1698 /// <param name="message"></param>
1688 public void osMessageObject(LSL_Key objectUUID, string message) 1699 public void osMessageObject(LSL_Key objectUUID, string message)
1689 { 1700 {
1690 CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); 1701 CheckThreatLevel(ThreatLevel.Low, "osMessageObject");
@@ -1699,24 +1710,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1699 "dataserver", resobj, new DetectParams[0])); 1710 "dataserver", resobj, new DetectParams[0]));
1700 } 1711 }
1701 1712
1702 1713 /// <summary>
1703 // This needs ThreatLevel high. It is an excellent griefer tool, 1714 /// Write a notecard directly to the prim's inventory.
1704 // In a loop, it can cause asset bloat and DOS levels of asset 1715 /// </summary>
1705 // writes. 1716 /// <remarks>
1706 // 1717 /// This needs ThreatLevel high. It is an excellent griefer tool,
1718 /// In a loop, it can cause asset bloat and DOS levels of asset
1719 /// writes.
1720 /// </remarks>
1721 /// <param name="notecardName">The name of the notecard to write.</param>
1722 /// <param name="contents">The contents of the notecard.</param>
1707 public void osMakeNotecard(string notecardName, LSL_Types.list contents) 1723 public void osMakeNotecard(string notecardName, LSL_Types.list contents)
1708 { 1724 {
1709 CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); 1725 CheckThreatLevel(ThreatLevel.High, "osMakeNotecard");
1710 m_host.AddScriptLPS(1); 1726 m_host.AddScriptLPS(1);
1711 1727
1728 StringBuilder notecardData = new StringBuilder();
1729
1730 for (int i = 0; i < contents.Length; i++)
1731 notecardData.Append((string)(contents.GetLSLStringItem(i) + "\n"));
1732
1733 SaveNotecard(notecardName, notecardData.ToString());
1734 }
1735
1736 protected void SaveNotecard(string notecardName, string notecardData)
1737 {
1712 // Create new asset 1738 // Create new asset
1713 AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); 1739 AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString());
1714 asset.Description = "Script Generated Notecard"; 1740 asset.Description = "Script Generated Notecard";
1715 string notecardData = String.Empty;
1716
1717 for (int i = 0; i < contents.Length; i++) {
1718 notecardData += contents.GetLSLStringItem(i) + "\n";
1719 }
1720 1741
1721 int textLength = notecardData.Length; 1742 int textLength = notecardData.Length;
1722 notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " 1743 notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length "
@@ -1726,7 +1747,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1726 World.AssetService.Store(asset); 1747 World.AssetService.Store(asset);
1727 1748
1728 // Create Task Entry 1749 // Create Task Entry
1729 TaskInventoryItem taskItem=new TaskInventoryItem(); 1750 TaskInventoryItem taskItem = new TaskInventoryItem();
1730 1751
1731 taskItem.ResetIDs(m_host.UUID); 1752 taskItem.ResetIDs(m_host.UUID);
1732 taskItem.ParentID = m_host.UUID; 1753 taskItem.ParentID = m_host.UUID;
@@ -1751,13 +1772,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1751 m_host.Inventory.AddInventoryItem(taskItem, false); 1772 m_host.Inventory.AddInventoryItem(taskItem, false);
1752 } 1773 }
1753 1774
1754 1775 /// <summary>
1755 /*Instead of using the LSL Dataserver event to pull notecard data, 1776 /// Directly get an entire notecard at once.
1756 this will simply read the requested line and return its data as a string. 1777 /// </summary>
1757 1778 /// <remarks>
1758 Warning - due to the synchronous method this function uses to fetch assets, its use 1779 /// Instead of using the LSL Dataserver event to pull notecard data
1759 may be dangerous and unreliable while running in grid mode. 1780 /// this will simply read the entire notecard and return its data as a string.
1760 */ 1781 ///
1782 /// Warning - due to the synchronous method this function uses to fetch assets, its use
1783 /// may be dangerous and unreliable while running in grid mode.
1784 /// </remarks>
1785 /// <param name="name">Name of the notecard or its asset id</param>
1786 /// <param name="line">The line number to read. The first line is line 0</param>
1787 /// <returns>Notecard line</returns>
1761 public string osGetNotecardLine(string name, int line) 1788 public string osGetNotecardLine(string name, int line)
1762 { 1789 {
1763 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); 1790 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine");
@@ -1799,17 +1826,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1799 }; 1826 };
1800 1827
1801 return NotecardCache.GetLine(assetID, line, 255); 1828 return NotecardCache.GetLine(assetID, line, 255);
1802
1803
1804 } 1829 }
1805 1830
1806 /*Instead of using the LSL Dataserver event to pull notecard data line by line, 1831 /// <summary>
1807 this will simply read the entire notecard and return its data as a string. 1832 /// Get an entire notecard at once.
1808 1833 /// </summary>
1809 Warning - due to the synchronous method this function uses to fetch assets, its use 1834 /// <remarks>
1810 may be dangerous and unreliable while running in grid mode. 1835 /// Instead of using the LSL Dataserver event to pull notecard data line by line,
1811 */ 1836 /// this will simply read the entire notecard and return its data as a string.
1812 1837 ///
1838 /// Warning - due to the synchronous method this function uses to fetch assets, its use
1839 /// may be dangerous and unreliable while running in grid mode.
1840 /// </remarks>
1841 /// <param name="name">Name of the notecard or its asset id</param>
1842 /// <returns>Notecard text</returns>
1813 public string osGetNotecard(string name) 1843 public string osGetNotecard(string name)
1814 { 1844 {
1815 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); 1845 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard");
@@ -1857,17 +1887,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1857 } 1887 }
1858 1888
1859 return NotecardData; 1889 return NotecardData;
1860
1861
1862 } 1890 }
1863 1891
1864 /*Instead of using the LSL Dataserver event to pull notecard data, 1892 /// <summary>
1865 this will simply read the number of note card lines and return this data as an integer. 1893 /// Get the number of lines in the given notecard.
1866 1894 /// </summary>
1867 Warning - due to the synchronous method this function uses to fetch assets, its use 1895 /// <remarks>
1868 may be dangerous and unreliable while running in grid mode. 1896 /// Instead of using the LSL Dataserver event to pull notecard data,
1869 */ 1897 /// this will simply read the number of note card lines and return this data as an integer.
1870 1898 ///
1899 /// Warning - due to the synchronous method this function uses to fetch assets, its use
1900 /// may be dangerous and unreliable while running in grid mode.
1901 /// </remarks>
1902 /// <param name="name">Name of the notecard or its asset id</param>
1903 /// <returns></returns>
1871 public int osGetNumberOfNotecardLines(string name) 1904 public int osGetNumberOfNotecardLines(string name)
1872 { 1905 {
1873 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); 1906 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines");
@@ -1947,15 +1980,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1947 { 1980 {
1948 return ""; 1981 return "";
1949 } 1982 }
1950
1951 } 1983 }
1952 1984
1985 /// <summary>
1986 /// Get the nickname of this grid, as set in the [GridInfo] config section.
1987 /// </summary>
1988 /// <remarks>
1953 /// Threat level is Moderate because intentional abuse, for instance 1989 /// Threat level is Moderate because intentional abuse, for instance
1954 /// scripts that are written to be malicious only on one grid, 1990 /// scripts that are written to be malicious only on one grid,
1955 /// for instance in a HG scenario, are a distinct possibility. 1991 /// for instance in a HG scenario, are a distinct possibility.
1956 /// 1992 /// </remarks>
1957 /// Use value from the config file and return it. 1993 /// <returns></returns>
1958 ///
1959 public string osGetGridNick() 1994 public string osGetGridNick()
1960 { 1995 {
1961 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); 1996 CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
@@ -2063,12 +2098,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2063 return World.RegionInfo.RegionSettings.LoadedCreationID; 2098 return World.RegionInfo.RegionSettings.LoadedCreationID;
2064 } 2099 }
2065 2100
2066 // Threat level is 'Low' because certain users could possibly be tricked into 2101 /// <summary>
2067 // dropping an unverified script into one of their own objects, which could 2102 /// Get the primitive parameters of a linked prim.
2068 // then gather the physical construction details of the object and transmit it 2103 /// </summary>
2069 // to an unscrupulous third party, thus permitting unauthorized duplication of 2104 /// <remarks>
2070 // the object's form. 2105 /// Threat level is 'Low' because certain users could possibly be tricked into
2071 // 2106 /// dropping an unverified script into one of their own objects, which could
2107 /// then gather the physical construction details of the object and transmit it
2108 /// to an unscrupulous third party, thus permitting unauthorized duplication of
2109 /// the object's form.
2110 /// </remarks>
2111 /// <param name="linknumber"></param>
2112 /// <param name="rules"></param>
2113 /// <returns></returns>
2072 public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) 2114 public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
2073 { 2115 {
2074 CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); 2116 CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
@@ -2344,10 +2386,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2344 obj.Shape.ProjectionFocus = (float)focus; 2386 obj.Shape.ProjectionFocus = (float)focus;
2345 obj.Shape.ProjectionAmbiance = (float)amb; 2387 obj.Shape.ProjectionAmbiance = (float)amb;
2346 2388
2347
2348 obj.ParentGroup.HasGroupChanged = true; 2389 obj.ParentGroup.HasGroupChanged = true;
2349 obj.ScheduleFullUpdate(); 2390 obj.ScheduleFullUpdate();
2350
2351 } 2391 }
2352 2392
2353 /// <summary> 2393 /// <summary>
@@ -2372,6 +2412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2372 } 2412 }
2373 } 2413 }
2374 }); 2414 });
2415
2375 return result; 2416 return result;
2376 } 2417 }
2377 2418
@@ -2391,4 +2432,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2391 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); 2432 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
2392 } 2433 }
2393 } 2434 }
2394} 2435} \ No newline at end of file