aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs55
1 files changed, 48 insertions, 7 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index ed63aee..d5ad5b6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -68,6 +68,14 @@ using System.Reflection;
68 68
69namespace OpenSim.Region.ScriptEngine.Shared.Api 69namespace OpenSim.Region.ScriptEngine.Shared.Api
70{ 70{
71 // MUST be a ref type
72 public class UserInfoCacheEntry
73 {
74 public int time;
75 public UserAccount account;
76 public PresenceInfo pinfo;
77 }
78
71 /// <summary> 79 /// <summary>
72 /// Contains all LSL ll-functions. This class will be in Default AppDomain. 80 /// Contains all LSL ll-functions. This class will be in Default AppDomain.
73 /// </summary> 81 /// </summary>
@@ -92,6 +100,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
92 protected int m_scriptConsoleChannel = 0; 100 protected int m_scriptConsoleChannel = 0;
93 protected bool m_scriptConsoleChannelEnabled = false; 101 protected bool m_scriptConsoleChannelEnabled = false;
94 protected IUrlModule m_UrlModule = null; 102 protected IUrlModule m_UrlModule = null;
103 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
104 new Dictionary<UUID, UserInfoCacheEntry>();
95 105
96 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 106 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
97 { 107 {
@@ -3908,16 +3918,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3908 m_host.AddScriptLPS(1); 3918 m_host.AddScriptLPS(1);
3909 3919
3910 UUID uuid = (UUID)id; 3920 UUID uuid = (UUID)id;
3921 PresenceInfo pinfo = null;
3922 UserAccount account;
3911 3923
3912 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); 3924 UserInfoCacheEntry ce;
3913 if (account == null) 3925 if (!m_userInfoCache.TryGetValue(uuid, out ce))
3914 return UUID.Zero.ToString(); 3926 {
3927 account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
3928 if (account == null)
3929 {
3930 m_userInfoCache[uuid] = null; // Cache negative
3931 return UUID.Zero.ToString();
3932 }
3915 3933
3916 3934
3917 PresenceInfo pinfo = null; 3935 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
3918 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); 3936 if (pinfos != null && pinfos.Length > 0)
3919 if (pinfos != null && pinfos.Length > 0) 3937 pinfo = pinfos[0];
3920 pinfo = pinfos[0]; 3938
3939 ce = new UserInfoCacheEntry();
3940 ce.time = Util.EnvironmentTickCount();
3941 ce.account = account;
3942 ce.pinfo = pinfo;
3943 }
3944 else
3945 {
3946 if (ce == null)
3947 return UUID.Zero.ToString();
3948
3949 account = ce.account;
3950 pinfo = ce.pinfo;
3951 }
3952
3953 if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000)
3954 {
3955 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
3956 if (pinfos != null && pinfos.Length > 0)
3957 pinfo = pinfos[0];
3958
3959 ce.time = Util.EnvironmentTickCount();
3960 ce.pinfo = pinfo;
3961 }
3921 3962
3922 string reply = String.Empty; 3963 string reply = String.Empty;
3923 3964