aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs24
1 files changed, 16 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 11826bd..52d96bc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5465,27 +5465,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5465 /// Returns the index of the first occurrence of test 5465 /// Returns the index of the first occurrence of test
5466 /// in src. 5466 /// in src.
5467 /// </summary> 5467 /// </summary>
5468 5468 /// <param name="src">Source list</param>
5469 /// <param name="test">List to search for</param>
5470 /// <returns>
5471 /// The index number of the point in src where test was found if it was found.
5472 /// Otherwise returns -1
5473 /// </returns>
5469 public LSL_Integer llListFindList(LSL_List src, LSL_List test) 5474 public LSL_Integer llListFindList(LSL_List src, LSL_List test)
5470 { 5475 {
5471
5472 int index = -1; 5476 int index = -1;
5473 int length = src.Length - test.Length + 1; 5477 int length = src.Length - test.Length + 1;
5474 5478
5475 m_host.AddScriptLPS(1); 5479 m_host.AddScriptLPS(1);
5476 5480
5477 // If either list is empty, do not match 5481 // If either list is empty, do not match
5478
5479 if (src.Length != 0 && test.Length != 0) 5482 if (src.Length != 0 && test.Length != 0)
5480 { 5483 {
5481 for (int i = 0; i < length; i++) 5484 for (int i = 0; i < length; i++)
5482 { 5485 {
5483 if (src.Data[i].Equals(test.Data[0])) 5486 // Why this piece of insanity? This is because most script constants are C# value types (e.g. int)
5487 // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code
5488 // and so the comparison fails even if the LSL_Integer conceptually has the same value.
5489 // Therefore, here we test Equals on both the source and destination objects.
5490 // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)).
5491 if (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i]))
5484 { 5492 {
5485 int j; 5493 int j;
5486 for (j = 1; j < test.Length; j++) 5494 for (j = 1; j < test.Length; j++)
5487 if (!src.Data[i+j].Equals(test.Data[j])) 5495 if (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j])))
5488 break; 5496 break;
5497
5489 if (j == test.Length) 5498 if (j == test.Length)
5490 { 5499 {
5491 index = i; 5500 index = i;
@@ -5496,19 +5505,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5496 } 5505 }
5497 5506
5498 return index; 5507 return index;
5499
5500 } 5508 }
5501 5509
5502 public LSL_String llGetObjectName() 5510 public LSL_String llGetObjectName()
5503 { 5511 {
5504 m_host.AddScriptLPS(1); 5512 m_host.AddScriptLPS(1);
5505 return m_host.Name!=null?m_host.Name:String.Empty; 5513 return m_host.Name !=null ? m_host.Name : String.Empty;
5506 } 5514 }
5507 5515
5508 public void llSetObjectName(string name) 5516 public void llSetObjectName(string name)
5509 { 5517 {
5510 m_host.AddScriptLPS(1); 5518 m_host.AddScriptLPS(1);
5511 m_host.Name = name!=null?name:String.Empty; 5519 m_host.Name = name != null ? name : String.Empty;
5512 } 5520 }
5513 5521
5514 public LSL_String llGetDate() 5522 public LSL_String llGetDate()