diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 129 |
1 files changed, 46 insertions, 83 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 01c026e..a6ca171 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -3956,7 +3956,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3956 | } | 3956 | } |
3957 | 3957 | ||
3958 | 3958 | ||
3959 | pinfo = World.PresenceService.GetAgent(uuid); | 3959 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
3960 | if (pinfos != null && pinfos.Length > 0) | ||
3961 | { | ||
3962 | foreach (PresenceInfo p in pinfos) | ||
3963 | { | ||
3964 | if (p.RegionID != UUID.Zero) | ||
3965 | { | ||
3966 | pinfo = p; | ||
3967 | } | ||
3968 | } | ||
3969 | } | ||
3960 | 3970 | ||
3961 | ce = new UserInfoCacheEntry(); | 3971 | ce = new UserInfoCacheEntry(); |
3962 | ce.time = Util.EnvironmentTickCount(); | 3972 | ce.time = Util.EnvironmentTickCount(); |
@@ -3974,7 +3984,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3974 | 3984 | ||
3975 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) | 3985 | if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) |
3976 | { | 3986 | { |
3977 | pinfo = World.PresenceService.GetAgent(uuid); | 3987 | PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); |
3988 | if (pinfos != null && pinfos.Length > 0) | ||
3989 | { | ||
3990 | foreach (PresenceInfo p in pinfos) | ||
3991 | { | ||
3992 | if (p.RegionID != UUID.Zero) | ||
3993 | { | ||
3994 | pinfo = p; | ||
3995 | } | ||
3996 | } | ||
3997 | } | ||
3998 | else | ||
3999 | pinfo = null; | ||
3978 | 4000 | ||
3979 | ce.time = Util.EnvironmentTickCount(); | 4001 | ce.time = Util.EnvironmentTickCount(); |
3980 | ce.pinfo = pinfo; | 4002 | ce.pinfo = pinfo; |
@@ -5579,78 +5601,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5579 | ScriptSleep(5000); | 5601 | ScriptSleep(5000); |
5580 | } | 5602 | } |
5581 | 5603 | ||
5582 | public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) | ||
5583 | { | ||
5584 | m_host.AddScriptLPS(1); | ||
5585 | LSL_List ret = new LSL_List(); | ||
5586 | LSL_List spacers = new LSL_List(); | ||
5587 | if (in_spacers.Length > 0 && separators.Length > 0) | ||
5588 | { | ||
5589 | for (int i = 0; i < in_spacers.Length; i++) | ||
5590 | { | ||
5591 | object s = in_spacers.Data[i]; | ||
5592 | for (int j = 0; j < separators.Length; j++) | ||
5593 | { | ||
5594 | if (separators.Data[j].ToString() == s.ToString()) | ||
5595 | { | ||
5596 | s = null; | ||
5597 | break; | ||
5598 | } | ||
5599 | } | ||
5600 | if (s != null) | ||
5601 | { | ||
5602 | spacers.Add(s); | ||
5603 | } | ||
5604 | } | ||
5605 | } | ||
5606 | object[] delimiters = new object[separators.Length + spacers.Length]; | ||
5607 | separators.Data.CopyTo(delimiters, 0); | ||
5608 | spacers.Data.CopyTo(delimiters, separators.Length); | ||
5609 | bool dfound = false; | ||
5610 | do | ||
5611 | { | ||
5612 | dfound = false; | ||
5613 | int cindex = -1; | ||
5614 | string cdeli = ""; | ||
5615 | for (int i = 0; i < delimiters.Length; i++) | ||
5616 | { | ||
5617 | int index = str.IndexOf(delimiters[i].ToString()); | ||
5618 | bool found = index != -1; | ||
5619 | if (found && String.Empty != delimiters[i].ToString()) | ||
5620 | { | ||
5621 | if ((cindex > index) || (cindex == -1)) | ||
5622 | { | ||
5623 | cindex = index; | ||
5624 | cdeli = delimiters[i].ToString(); | ||
5625 | } | ||
5626 | dfound = dfound || found; | ||
5627 | } | ||
5628 | } | ||
5629 | if (cindex != -1) | ||
5630 | { | ||
5631 | if (cindex > 0) | ||
5632 | { | ||
5633 | ret.Add(new LSL_String(str.Substring(0, cindex))); | ||
5634 | } | ||
5635 | // Cannot use spacers.Contains() because spacers may be either type String or LSLString | ||
5636 | for (int j = 0; j < spacers.Length; j++) | ||
5637 | { | ||
5638 | if (spacers.Data[j].ToString() == cdeli) | ||
5639 | { | ||
5640 | ret.Add(new LSL_String(cdeli)); | ||
5641 | break; | ||
5642 | } | ||
5643 | } | ||
5644 | str = str.Substring(cindex + cdeli.Length); | ||
5645 | } | ||
5646 | } while (dfound); | ||
5647 | if (str != "") | ||
5648 | { | ||
5649 | ret.Add(new LSL_String(str)); | ||
5650 | } | ||
5651 | return ret; | ||
5652 | } | ||
5653 | |||
5654 | public LSL_Integer llOverMyLand(string id) | 5604 | public LSL_Integer llOverMyLand(string id) |
5655 | { | 5605 | { |
5656 | m_host.AddScriptLPS(1); | 5606 | m_host.AddScriptLPS(1); |
@@ -8414,7 +8364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8414 | // of arrays or other objects. | 8364 | // of arrays or other objects. |
8415 | // </remarks> | 8365 | // </remarks> |
8416 | 8366 | ||
8417 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | 8367 | private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) |
8418 | { | 8368 | { |
8419 | int beginning = 0; | 8369 | int beginning = 0; |
8420 | int srclen = src.Length; | 8370 | int srclen = src.Length; |
@@ -8434,8 +8384,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8434 | 8384 | ||
8435 | LSL_List tokens = new LSL_List(); | 8385 | LSL_List tokens = new LSL_List(); |
8436 | 8386 | ||
8437 | m_host.AddScriptLPS(1); | ||
8438 | |||
8439 | // All entries are initially valid | 8387 | // All entries are initially valid |
8440 | 8388 | ||
8441 | for (int i = 0; i < mlen; i++) | 8389 | for (int i = 0; i < mlen; i++) |
@@ -8507,14 +8455,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8507 | { | 8455 | { |
8508 | // no markers were found on this pass | 8456 | // no markers were found on this pass |
8509 | // so we're pretty much done | 8457 | // so we're pretty much done |
8510 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | 8458 | if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) |
8459 | tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); | ||
8511 | break; | 8460 | break; |
8512 | } | 8461 | } |
8513 | 8462 | ||
8514 | // Otherwise we just add the newly delimited token | 8463 | // Otherwise we just add the newly delimited token |
8515 | // and recalculate where the search should continue. | 8464 | // and recalculate where the search should continue. |
8516 | 8465 | if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) | |
8517 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); | 8466 | tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); |
8518 | 8467 | ||
8519 | if (best < seplen) | 8468 | if (best < seplen) |
8520 | { | 8469 | { |
@@ -8523,7 +8472,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8523 | else | 8472 | else |
8524 | { | 8473 | { |
8525 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; | 8474 | beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; |
8526 | tokens.Add(new LSL_String(spcarray[best - seplen].ToString())); | 8475 | string str = spcarray[best - seplen].ToString(); |
8476 | if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) | ||
8477 | tokens.Add(new LSL_String(str)); | ||
8527 | } | 8478 | } |
8528 | } | 8479 | } |
8529 | 8480 | ||
@@ -8533,7 +8484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8533 | // arduous. Alternatively the 'break' could be replced with a return | 8484 | // arduous. Alternatively the 'break' could be replced with a return |
8534 | // but that's shabby programming. | 8485 | // but that's shabby programming. |
8535 | 8486 | ||
8536 | if (beginning == srclen) | 8487 | if ((beginning == srclen) && (keepNulls)) |
8537 | { | 8488 | { |
8538 | if (srclen != 0) | 8489 | if (srclen != 0) |
8539 | tokens.Add(new LSL_String("")); | 8490 | tokens.Add(new LSL_String("")); |
@@ -8541,7 +8492,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8541 | 8492 | ||
8542 | return tokens; | 8493 | return tokens; |
8543 | } | 8494 | } |
8544 | 8495 | ||
8496 | public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) | ||
8497 | { | ||
8498 | m_host.AddScriptLPS(1); | ||
8499 | return this.ParseString(src, separators, spacers, false); | ||
8500 | } | ||
8501 | |||
8502 | public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) | ||
8503 | { | ||
8504 | m_host.AddScriptLPS(1); | ||
8505 | return this.ParseString(src, separators, spacers, true); | ||
8506 | } | ||
8507 | |||
8545 | public LSL_Integer llGetObjectPermMask(int mask) | 8508 | public LSL_Integer llGetObjectPermMask(int mask) |
8546 | { | 8509 | { |
8547 | m_host.AddScriptLPS(1); | 8510 | m_host.AddScriptLPS(1); |