aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs65
1 files changed, 52 insertions, 13 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index d61715e..236458c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -69,6 +69,14 @@ using System.Reflection;
69 69
70namespace OpenSim.Region.ScriptEngine.Shared.Api 70namespace OpenSim.Region.ScriptEngine.Shared.Api
71{ 71{
72 // MUST be a ref type
73 public class UserInfoCacheEntry
74 {
75 public int time;
76 public UserAccount account;
77 public PresenceInfo pinfo;
78 }
79
72 /// <summary> 80 /// <summary>
73 /// Contains all LSL ll-functions. This class will be in Default AppDomain. 81 /// Contains all LSL ll-functions. This class will be in Default AppDomain.
74 /// </summary> 82 /// </summary>
@@ -93,6 +101,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
93 protected int m_scriptConsoleChannel = 0; 101 protected int m_scriptConsoleChannel = 0;
94 protected bool m_scriptConsoleChannelEnabled = false; 102 protected bool m_scriptConsoleChannelEnabled = false;
95 protected IUrlModule m_UrlModule = null; 103 protected IUrlModule m_UrlModule = null;
104 protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache =
105 new Dictionary<UUID, UserInfoCacheEntry>();
96 106
97 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) 107 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
98 { 108 {
@@ -1173,12 +1183,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1173 public virtual void llDie() 1183 public virtual void llDie()
1174 { 1184 {
1175 m_host.AddScriptLPS(1); 1185 m_host.AddScriptLPS(1);
1176 if (!m_host.IsAttachment) 1186 if (!m_host.IsAttachment) throw new SelfDeleteException();
1177 {
1178 //Enforce a sleep here to avoid ghost prims
1179 llSleep(0.2d);
1180 throw new SelfDeleteException();
1181 }
1182 } 1187 }
1183 1188
1184 public LSL_Float llGround(LSL_Vector offset) 1189 public LSL_Float llGround(LSL_Vector offset)
@@ -4249,16 +4254,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4249 m_host.AddScriptLPS(1); 4254 m_host.AddScriptLPS(1);
4250 4255
4251 UUID uuid = (UUID)id; 4256 UUID uuid = (UUID)id;
4257 PresenceInfo pinfo = null;
4258 UserAccount account;
4252 4259
4253 UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); 4260 UserInfoCacheEntry ce;
4254 if (account == null) 4261 if (!m_userInfoCache.TryGetValue(uuid, out ce))
4255 return UUID.Zero.ToString(); 4262 {
4263 account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid);
4264 if (account == null)
4265 {
4266 m_userInfoCache[uuid] = null; // Cache negative
4267 return UUID.Zero.ToString();
4268 }
4256 4269
4257 4270
4258 PresenceInfo pinfo = null; 4271 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
4259 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); 4272 if (pinfos != null && pinfos.Length > 0)
4260 if (pinfos != null && pinfos.Length > 0) 4273 pinfo = pinfos[0];
4261 pinfo = pinfos[0]; 4274
4275 ce = new UserInfoCacheEntry();
4276 ce.time = Util.EnvironmentTickCount();
4277 ce.account = account;
4278 ce.pinfo = pinfo;
4279 m_userInfoCache[uuid] = ce;
4280 }
4281 else
4282 {
4283 if (ce == null)
4284 return UUID.Zero.ToString();
4285
4286 account = ce.account;
4287 pinfo = ce.pinfo;
4288 }
4289
4290 if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000)
4291 {
4292 PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() });
4293 if (pinfos != null && pinfos.Length > 0)
4294 pinfo = pinfos[0];
4295 else
4296 pinfo = null;
4297
4298 ce.time = Util.EnvironmentTickCount();
4299 ce.pinfo = pinfo;
4300 }
4262 4301
4263 string reply = String.Empty; 4302 string reply = String.Empty;
4264 4303