aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs79
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs10
3 files changed, 93 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 275969a..446a972 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -183,6 +183,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
183 throw new Exception("OSSL Runtime Error: " + msg); 183 throw new Exception("OSSL Runtime Error: " + msg);
184 } 184 }
185 185
186 //
187 //Dumps an error message on the debug console.
188 //
189
190 internal void OSSLShoutError(string message)
191 {
192 if (message.Length > 1023)
193 message = message.Substring(0, 1023);
194
195 World.SimChat(Utils.StringToBytes(message),
196 ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
197
198 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
199 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
200 }
201
186 public void CheckThreatLevel(ThreatLevel level, string function) 202 public void CheckThreatLevel(ThreatLevel level, string function)
187 { 203 {
188 if (!m_OSFunctionsEnabled) 204 if (!m_OSFunctionsEnabled)
@@ -1353,6 +1369,69 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1353 m_host.Inventory.AddInventoryItem(taskItem, false); 1369 m_host.Inventory.AddInventoryItem(taskItem, false);
1354 } 1370 }
1355 1371
1372 /*Instead of using the LSL Dataserver event to pull notecard data,
1373 this will simply read the requested line and return its data as a string.
1374
1375 Warning - due to the synchronous method this function uses to fetch assets, its use
1376 may be dangerous and unreliable while running in grid mode.
1377 */
1378 public string osGetNotecardLine(string name, int line)
1379 {
1380 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine");
1381 m_host.AddScriptLPS(1);
1382
1383 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1384 {
1385 if (item.Type == 7 && item.Name == name)
1386 {
1387 if (NotecardCache.IsCached(item.AssetID)== false)
1388 { AssetBase a = World.CommsManager.AssetCache.GetAsset(item.AssetID, false);
1389 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
1390 string data = enc.GetString(a.Data);
1391 NotecardCache.Cache(item.AssetID, data);
1392 };
1393
1394 return NotecardCache.GetLine(item.AssetID, line, 255);
1395 }
1396 }
1397
1398 //If all else fails just return error.
1399 OSSLShoutError("Notecard '" + name + "' could not be found.");
1400 return "ERROR!";
1401 }
1402
1403 /*Instead of using the LSL Dataserver event to pull notecard data,
1404 this will simply read the number of note card lines and return this data as an integer.
1405
1406 Warning - due to the synchronous method this function uses to fetch assets, its use
1407 may be dangerous and unreliable while running in grid mode.
1408 */
1409 public int osGetNumberOfNotecardLines(string name)
1410 {
1411 CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines");
1412 m_host.AddScriptLPS(1);
1413
1414 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1415 {
1416 if (item.Type == 7 && item.Name == name)
1417 {
1418 if (NotecardCache.IsCached(item.AssetID) == false)
1419 {
1420 AssetBase a = World.CommsManager.AssetCache.GetAsset(item.AssetID, false);
1421 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
1422 string data = enc.GetString(a.Data);
1423 NotecardCache.Cache(item.AssetID, data);
1424 };
1425
1426 return NotecardCache.GetLines(item.AssetID);
1427 }
1428 }
1429
1430 //If all else fails just return error.
1431 OSSLShoutError("Notecard '" + name + "' could not be found.");
1432 return -1;
1433 }
1434
1356 public string osAvatarName2Key(string firstname, string lastname) 1435 public string osAvatarName2Key(string firstname, string lastname)
1357 { 1436 {
1358 CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key"); 1437 CheckThreatLevel(ThreatLevel.Low, "osAvatarName2Key");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index de94224..526c7d0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -122,6 +122,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
122 void osMessageObject(key objectUUID,string message); 122 void osMessageObject(key objectUUID,string message);
123 123
124 void osMakeNotecard(string notecardName, LSL_Types.list contents); 124 void osMakeNotecard(string notecardName, LSL_Types.list contents);
125
126 string osGetNotecardLine(string name, int line);
127 int osGetNumberOfNotecardLines(string name);
128
125 string osAvatarName2Key(string firstname, string lastname); 129 string osAvatarName2Key(string firstname, string lastname);
126 string osKey2Name(string id); 130 string osKey2Name(string id);
127 131
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 625fc97..0f25983 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -307,6 +307,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
307 m_OSSL_Functions.osMakeNotecard(notecardName, contents); 307 m_OSSL_Functions.osMakeNotecard(notecardName, contents);
308 } 308 }
309 309
310 public string osGetNotecardLine(string name, int line)
311 {
312 return m_OSSL_Functions.osGetNotecardLine(name, line);
313 }
314
315 public int osGetNumberOfNotecardLines(string name)
316 {
317 return m_OSSL_Functions.osGetNumberOfNotecardLines(name);
318 }
319
310 public string osAvatarName2Key(string firstname, string lastname) 320 public string osAvatarName2Key(string firstname, string lastname)
311 { 321 {
312 return m_OSSL_Functions.osAvatarName2Key(firstname, lastname); 322 return m_OSSL_Functions.osAvatarName2Key(firstname, lastname);