aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-04-17 14:34:30 +0000
committerJustin Clarke Casey2008-04-17 14:34:30 +0000
commit15b36498be46412deb085e61538243219317e249 (patch)
treeaa815b366df562bbbb51dbebbb437d77e2e9ba3d /OpenSim/Region
parent* Added "svn load" command to correspond "svn save". Will grab the latest rev... (diff)
downloadopensim-SC_OLD-15b36498be46412deb085e61538243219317e249.zip
opensim-SC_OLD-15b36498be46412deb085e61538243219317e249.tar.gz
opensim-SC_OLD-15b36498be46412deb085e61538243219317e249.tar.bz2
opensim-SC_OLD-15b36498be46412deb085e61538243219317e249.tar.xz
From: Alan M Webb <awebb@vnet.ibm.com>
This provides fixed implementations for llListReplaceList and llList2CSV. llListReplaceList was broken except for simple indices. llList2CSV did not handle processing of an empty list.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs103
1 files changed, 98 insertions, 5 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index 39d8473..d8ad914 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -2549,16 +2549,32 @@ namespace OpenSim.Region.ScriptEngine.Common
2549 2549
2550 } 2550 }
2551 2551
2552 /// <summary>
2553 /// Process the supplied list and return the
2554 /// content of the list formatted as a comma
2555 /// separated list. There is a space after
2556 /// each comma.
2557 /// </summary>
2558
2552 public string llList2CSV(LSL_Types.list src) 2559 public string llList2CSV(LSL_Types.list src)
2553 { 2560 {
2554 m_host.AddScriptLPS(1); 2561
2555 string ret = String.Empty; 2562 string ret = String.Empty;
2556 foreach (object o in src.Data) 2563 int x = 0;
2564
2565 m_host.AddScriptLPS(1);
2566
2567 if(src.Data.Length > 0)
2557 { 2568 {
2558 ret = ret + o.ToString() + ", "; 2569 ret = src.Data[x++].ToString();
2570 for(;x<src.Data.Length;x++)
2571 {
2572 ret += ", "+src.Data[x].ToString();
2573 }
2559 } 2574 }
2560 ret = ret.Substring(0, ret.Length - 2); 2575
2561 return ret; 2576 return ret;
2577
2562 } 2578 }
2563 2579
2564 /// <summary> 2580 /// <summary>
@@ -4463,10 +4479,87 @@ namespace OpenSim.Region.ScriptEngine.Common
4463 return 0; 4479 return 0;
4464 } 4480 }
4465 4481
4482 /// <summary>
4483 /// illListReplaceList removes the sub-list defined by the inclusive indices
4484 /// start and end and inserts the src list in its place. The inclusive
4485 /// nature of the indices means that at least one element must be deleted
4486 /// if the indices are within the bounds of the existing list. I.e. 2,2
4487 /// will remove the element at index 2 and replace it with the source
4488 /// list. Both indices may be negative, with the usual interpretation. An
4489 /// interesting case is where end is lower than start. As these indices
4490 /// bound the list to be removed, then 0->end, and start->lim are removed
4491 /// and the source list is added as a suffix.
4492 /// </summary>
4493
4466 public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end) 4494 public LSL_Types.list llListReplaceList(LSL_Types.list dest, LSL_Types.list src, int start, int end)
4467 { 4495 {
4496
4497 LSL_Types.list pref = null;
4498
4468 m_host.AddScriptLPS(1); 4499 m_host.AddScriptLPS(1);
4469 return dest.GetSublist(0, start - 1) + src + dest.GetSublist(end + 1, -1); 4500
4501 // Note that although we have normalized, both
4502 // indices could still be negative.
4503 if(start < 0)
4504 {
4505 start = start+dest.Length;
4506 }
4507
4508 if(end < 0)
4509 {
4510 end = end+dest.Length;
4511 }
4512 // The comventional case, remove a sequence starting with
4513 // start and ending with end. And then insert the source
4514 // list.
4515 if(start <= end)
4516 {
4517 // If greater than zero, then there is going to be a
4518 // surviving prefix. Otherwise the inclusive nature
4519 // of the indices mean that we're going to add the
4520 // source list as a prefix.
4521 if(start > 0)
4522 {
4523 pref = dest.GetSublist(0,start-1);
4524 // Only add a suffix if there is something
4525 // beyond the end index (it's inclusive too).
4526 if(end+1 < dest.Length)
4527 {
4528 return pref + src + dest.GetSublist(end+1,-1);
4529 }
4530 else
4531 {
4532 return pref + src;
4533 }
4534 }
4535 // If start is less than or equal to zero, then
4536 // the new list is simply a prefix. We still need to
4537 // figure out any necessary surgery to the destination
4538 // based upon end. Note that if end exceeds the upper
4539 // bound in this case, the entire destination list
4540 // is removed.
4541 else
4542 {
4543 if(end+1 < dest.Length)
4544 {
4545 return src + dest.GetSublist(end+1,-1);
4546 }
4547 else
4548 {
4549 return src;
4550 }
4551 }
4552 }
4553 // Finally, if start > end, we strip away a prefix and
4554 // a suffix, to leave the list that sits <between> ens
4555 // and start, and then tag on the src list. AT least
4556 // that's my interpretation. We can get sublist to do
4557 // this for us. Note that one, or both of the indices
4558 // might have been negative.
4559 else
4560 {
4561 return dest.GetSublist(end+1,start-1)+src;
4562 }
4470 } 4563 }
4471 4564
4472 public void llLoadURL(string avatar_id, string message, string url) 4565 public void llLoadURL(string avatar_id, string message, string url)