From 6b27587bc7631d6fd083f3b4f752d9ddcfda4830 Mon Sep 17 00:00:00 2001 From: Tom Date: Wed, 26 Jan 2011 16:25:08 -0800 Subject: Add a "useCached" parameter to GetUserAccount. Add a function to Scene to get the user flags. It has to be here due to access restrictions :/ --- .../Agent/Capabilities/CapabilitiesModule.cs | 7 +--- .../LocalUserAccountServiceConnector.cs | 17 ++++++--- OpenSim/Region/Framework/Scenes/Scene.cs | 42 +++++++++++----------- 3 files changed, 34 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs index cbc2fd6..5c5cb70 100644 --- a/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Capabilities/CapabilitiesModule.cs @@ -88,12 +88,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities public void AddCapsHandler(UUID agentId) { - int flags = 0; - ScenePresence sp; - if (m_scene.TryGetScenePresence(agentId, out sp)) - { - flags = sp.UserFlags; - } + int flags = m_scene.GetUserFlags(agentId); if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) return; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 9ecbcc6..54340e6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs @@ -142,10 +142,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts public UserAccount GetUserAccount(UUID scopeID, UUID userID) { - bool inCache = false; - UserAccount account = m_Cache.Get(userID, out inCache); - if (inCache) - return account; + return GetUserAccount(scopeID, userID, true); + } + + public UserAccount GetUserAccount(UUID scopeID, UUID userID, bool useCache) + { + UserAccount account; + if (useCache) + { + bool inCache = false; + account = m_Cache.Get(userID, out inCache); + if (inCache) + return account; + } account = m_UserService.GetUserAccount(scopeID, userID); m_Cache.Cache(userID, account); diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2ca82ca..99248c1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2443,14 +2443,7 @@ namespace OpenSim.Region.Framework.Scenes // If the user is banned, we won't let any of their objects // enter. Period. // - int flags = 0; - ScenePresence sp; - if (TryGetScenePresence(sceneObject.OwnerID, out sp)) - { - flags = sp.UserFlags; - } - - + int flags = GetUserFlags(sceneObject.OwnerID); if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) { m_log.Info("[INTERREGION]: Denied prim crossing for " + @@ -2480,7 +2473,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart RootPrim = sceneObject.RootPart; // Fix up attachment Parent Local ID - sp = GetScenePresence(sceneObject.OwnerID); + ScenePresence sp = GetScenePresence(sceneObject.OwnerID); if (sp != null) { @@ -2554,7 +2547,22 @@ namespace OpenSim.Region.Framework.Scenes } return 2; // StateSource.PrimCrossing } - + public int GetUserFlags(UUID user) + { + //Unfortunately the SP approach means that the value is cached until region is restarted + /* + ScenePresence sp; + if (TryGetScenePresence(user, out sp)) + { + return sp.UserFlags; + } + else + { + */ + UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user, false); + return uac.UserFlags; + //} + } #endregion #region Add/Remove Avatar Methods @@ -3625,12 +3633,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_regInfo.EstateSettings != null) { - int flags = 0; - ScenePresence sp; - if (TryGetScenePresence(agent.AgentID, out sp)) - { - flags = sp.UserFlags; - } + int flags = GetUserFlags(agent.AgentID); if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID, flags)) { //Add some more info to help users @@ -3836,12 +3839,7 @@ namespace OpenSim.Region.Framework.Scenes // We have to wait until the viewer contacts this region after receiving EAC. // That calls AddNewClient, which finally creates the ScenePresence - int flags = 0; - ScenePresence sp; - if (TryGetScenePresence(cAgentData.AgentID, out sp)) - { - flags = sp.UserFlags; - } + int flags = GetUserFlags(cAgentData.AgentID); if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) { m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); -- cgit v1.1