From 859bc717a4fe4cd5810ad9889cfb9b1e7f5c2046 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Fri, 19 Mar 2010 05:51:16 -0700 Subject: Cleaned up access to scenepresences in scenegraph. GetScenePresences and GetAvatars have been removed to consolidate locking and iteration within SceneGraph. All callers which used these to then iterate over presences have been refactored to instead pass their delegates to Scene.ForEachScenePresence(Action). --- OpenSim/Region/Framework/Scenes/Scene.cs | 81 ++++++++++---------------------- 1 file changed, 25 insertions(+), 56 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a86a33c..4b97e39 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -3269,7 +3269,7 @@ namespace OpenSim.Region.Framework.Scenes } } - ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); + ScenePresence sp = GetScenePresence(agent.AgentID); if (sp != null) { m_log.DebugFormat( @@ -3561,8 +3561,7 @@ namespace OpenSim.Region.Framework.Scenes /// message to display to the user. Reason for being logged off public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message) { - ScenePresence loggingOffUser = null; - loggingOffUser = GetScenePresence(AvatarID); + ScenePresence loggingOffUser = GetScenePresence(AvatarID); if (loggingOffUser != null) { UUID localRegionSecret = UUID.Zero; @@ -3598,8 +3597,8 @@ namespace OpenSim.Region.Framework.Scenes /// public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) { - ScenePresence presence; - if(m_sceneGraph.TryGetAvatar(agentID, out presence)) + ScenePresence presence = GetScenePresence(agentID); + if(presence != null) { try { @@ -3773,8 +3772,8 @@ namespace OpenSim.Region.Framework.Scenes public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) { - ScenePresence sp; - if(m_sceneGraph.TryGetAvatar(remoteClient.AgentId, out sp)) + ScenePresence sp = GetScenePresence(remoteClient.AgentId); + if (sp != null) { uint regionX = m_regInfo.RegionLocX; uint regionY = m_regInfo.RegionLocY; @@ -3952,17 +3951,17 @@ namespace OpenSim.Region.Framework.Scenes m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16}{5,-16}{6,-16}", "Firstname", "Lastname", "Agent ID", "Session ID", "Circuit", "IP", "World"); - foreach (ScenePresence scenePresence in GetAvatars()) + ForEachScenePresence(delegate(ScenePresence sp) { m_log.ErrorFormat("{0,-16}{1,-16}{2,-25}{3,-25}{4,-16},{5,-16}{6,-16}", - scenePresence.Firstname, - scenePresence.Lastname, - scenePresence.UUID, - scenePresence.ControllingClient.AgentId, + sp.Firstname, + sp.Lastname, + sp.UUID, + sp.ControllingClient.AgentId, "Unknown", "Unknown", RegionInfo.RegionName); - } + }); break; } @@ -4128,72 +4127,42 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.RemovePhysicalPrim(num); } - //The idea is to have a group of method that return a list of avatars meeting some requirement - // ie it could be all m_scenePresences within a certain range of the calling prim/avatar. - // - // GetAvatars returns a new list of all root agent presences in the scene - // GetScenePresences returns a new list of all presences in the scene or a filter may be passed. - // GetScenePresence returns the presence with matching UUID or first/last name. - // ForEachScenePresence requests the Scene to run a delegate function against all presences. - - /// - /// Return a list of all avatars in this region. - /// This list is a new object, so it can be iterated over without locking. - /// - /// - public List GetAvatars() - { - return m_sceneGraph.GetAvatars(); - } - - /// - /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. - /// This list is a new object, so it can be iterated over without locking. - /// - /// - public List GetScenePresences() + public int GetRootAgentCount() { - return m_sceneGraph.GetScenePresences(); + return m_sceneGraph.GetRootAgentCount(); } - /// - /// Request a filtered list of ScenePresences in this region. - /// This list is a new object, so it can be iterated over without locking. - /// - /// - /// - public List GetScenePresences(FilterAvatarList filter) + public int GetChildAgentCount() { - return m_sceneGraph.GetScenePresences(filter); + return m_sceneGraph.GetChildAgentCount(); } /// - /// Request a scene presence by UUID + /// Request a scene presence by UUID. Fast, indexed lookup. /// - /// - /// - public ScenePresence GetScenePresence(UUID avatarID) + /// + /// null if the presence was not found + public ScenePresence GetScenePresence(UUID agentID) { - return m_sceneGraph.GetScenePresence(avatarID); + return m_sceneGraph.GetScenePresence(agentID); } /// - /// Request the ScenePresence in this region by first/last name. - /// Should normally only be a single match, but first is always returned + /// Request the scene presence by name. /// /// /// - /// + /// null if the presence was not found public ScenePresence GetScenePresence(string firstName, string lastName) { return m_sceneGraph.GetScenePresence(firstName, lastName); } /// - /// Request the ScenePresence in this region by localID. + /// Request the scene presence by localID. /// /// - /// + /// null if the presence was not found public ScenePresence GetScenePresence(uint localID) { return m_sceneGraph.GetScenePresence(localID); -- cgit v1.1 From 62e0b53ca4697a852ee1e36e86da6a32e93bd55e Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Fri, 19 Mar 2010 05:58:34 -0700 Subject: Renamed TryGetAvatar to TryGetScenePresence on SceneManager, SceneBase, Scene and SceneGraph. This was the only change in this patch to keep it isolated from other recent changes to the same set of files. --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 4b97e39..2080687 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4254,9 +4254,9 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGraph.GetGroupByPrim(localID); } - public override bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) + public override bool TryGetScenePresence(UUID avatarId, out ScenePresence avatar) { - return m_sceneGraph.TryGetAvatar(avatarId, out avatar); + return m_sceneGraph.TryGetScenePresence(avatarId, out avatar); } public bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) -- cgit v1.1 From 70b0e07d1ea99f8bd88f2be12bf9b53a39187f60 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 22 Mar 2010 18:49:56 +0000 Subject: Remove the reading of estate_settings.xml and the associated processing of defaults. Adding code to facilitate estate creation / managemment as part of first time start up --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 2080687..078cf03 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -604,7 +604,7 @@ namespace OpenSim.Region.Framework.Scenes m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); if (m_storageManager.EstateDataStore != null) { - m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID); + m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); } //Bind Storage Manager functions to some land manager functions for this scene -- cgit v1.1 From dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 23 Mar 2010 02:05:56 +0000 Subject: First stage of the new interactive region creation. This will allow creation of a region and joining it to an existing estate or creating a new estate, as well as creating an estate owner if in standalone, and assigning estate owners. In Grid mode, existing users must be used. MySQL ONLY!!!! so far, as I can't develop or test for either SQLite or MSSQL. --- OpenSim/Region/Framework/Scenes/Scene.cs | 115 ++++++++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 078cf03..da81c03 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -604,7 +604,44 @@ namespace OpenSim.Region.Framework.Scenes m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); if (m_storageManager.EstateDataStore != null) { - m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); + m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); + if (m_regInfo.EstateSettings.EstateID == 0) // No record at all + { + MainConsole.Instance.Output("Your region is not part of an estate."); + while (true) + { + string response = MainConsole.Instance.CmdPrompt("Do you wish to join an existing estate?", "no", new List() {"yes", "no"}); + if (response == "no") + { + // Create a new estate + m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, true); + + m_regInfo.EstateSettings.EstateName = MainConsole.Instance.CmdPrompt("New estate name", m_regInfo.EstateSettings.EstateName); + m_regInfo.EstateSettings.Save(); + break; + } + else + { + response = MainConsole.Instance.CmdPrompt("Estate name to join", "None"); + if (response == "None") + continue; + + List estateIDs = m_storageManager.EstateDataStore.GetEstates(response); + if (estateIDs.Count < 1) + { + MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again"); + continue; + } + + int estateID = estateIDs[0]; + + if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) + break; + + MainConsole.Instance.Output("Joining the estate failed. Please try again."); + } + } + } } //Bind Storage Manager functions to some land manager functions for this scene @@ -1215,6 +1252,82 @@ namespace OpenSim.Region.Framework.Scenes m_dialogModule = RequestModuleInterface(); m_capsModule = RequestModuleInterface(); m_teleportModule = RequestModuleInterface(); + + // Shoving this in here for now, because we have the needed + // interfaces at this point + // + // TODO: Find a better place for this + // + while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero) + { + MainConsole.Instance.Output("The current estate has no owner set."); + string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test"); + string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User"); + + UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); + + if (account == null) + { + account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); + if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) + { + account.ServiceURLs = new Dictionary(); + account.ServiceURLs["HomeURI"] = string.Empty; + account.ServiceURLs["GatekeeperURI"] = string.Empty; + account.ServiceURLs["InventoryServerURI"] = string.Empty; + account.ServiceURLs["AssetServerURI"] = string.Empty; + } + + if (UserAccountService.StoreUserAccount(account)) + { + string password = MainConsole.Instance.PasswdPrompt("Password"); + string email = MainConsole.Instance.CmdPrompt("Email", ""); + + account.Email = email; + UserAccountService.StoreUserAccount(account); + + bool success = false; + success = AuthenticationService.SetPassword(account.PrincipalID, password); + if (!success) + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set password for account {0} {1}.", + first, last); + + GridRegion home = null; + if (GridService != null) + { + List defaultRegions = GridService.GetDefaultRegions(UUID.Zero); + if (defaultRegions != null && defaultRegions.Count >= 1) + home = defaultRegions[0]; + + if (PresenceService != null && home != null) + PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); + else + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", + first, last); + + } + else + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to retrieve home region for account {0} {1}.", + first, last); + + if (InventoryService != null) + success = InventoryService.CreateUserInventory(account.PrincipalID); + if (!success) + m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to create inventory for account {0} {1}.", + first, last); + + + m_log.InfoFormat("[USER ACCOUNT SERVICE]: Account {0} {1} created successfully", first, last); + + m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; + m_regInfo.EstateSettings.Save(); + } + } + else + { + MainConsole.Instance.Output("You appear to be connected to a grid and can't create users from here. Please enter the name of an existing user"); + } + } } #endregion -- cgit v1.1 From 19c659ca99349a974564d87fcdf42a2c66d2a875 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 25 Mar 2010 21:46:23 +0000 Subject: fix unit tests broken by commit dcf18689b9ab29d4ceb2348bb56fc1f77a7a8912 can't prompt for estate owner in unit tests --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index da81c03..6495899 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1258,7 +1258,7 @@ namespace OpenSim.Region.Framework.Scenes // // TODO: Find a better place for this // - while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero) + while (m_regInfo.EstateSettings.EstateOwner == UUID.Zero && MainConsole.Instance != null) { MainConsole.Instance.Output("The current estate has no owner set."); string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test"); -- cgit v1.1 From dd1c1b3bcd89daf2cd47b79d8f46d70a9970f773 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 26 Mar 2010 11:08:14 -0700 Subject: Fixed a backwards null check that was preventing estate owner from being set and a misleading error message (in grid mode it tries to get a user, not create one) --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6495899..7fed1ea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1266,7 +1266,7 @@ namespace OpenSim.Region.Framework.Scenes UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); - if (account == null) + if (account != null) { account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) @@ -1325,7 +1325,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - MainConsole.Instance.Output("You appear to be connected to a grid and can't create users from here. Please enter the name of an existing user"); + MainConsole.Instance.Output("User account not found. Please enter the name of an existing user"); } } } -- cgit v1.1 From 5a2315c68c7ccac2fafeb7e2cd51ecda863a9fa7 Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 26 Mar 2010 12:21:05 -0700 Subject: * Fixed a bug with null value handling in WebUtil.BuildQueryString() * Changed the null check back in estate manager setup but fixed the case for an existing account being found * Implemented SetPassword() in the SimianGrid auth connector --- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7fed1ea..8a583c1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1266,8 +1266,9 @@ namespace OpenSim.Region.Framework.Scenes UserAccount account = UserAccountService.GetUserAccount(m_regInfo.ScopeID, first, last); - if (account != null) + if (account == null) { + // Create a new account account = new UserAccount(m_regInfo.ScopeID, first, last, String.Empty); if (account.ServiceURLs == null || (account.ServiceURLs != null && account.ServiceURLs.Count == 0)) { @@ -1325,7 +1326,8 @@ namespace OpenSim.Region.Framework.Scenes } else { - MainConsole.Instance.Output("User account not found. Please enter the name of an existing user"); + m_regInfo.EstateSettings.EstateOwner = account.PrincipalID; + m_regInfo.EstateSettings.Save(); } } } -- cgit v1.1 From 607ed61ec2f7b5c3428522ab1b50de640b510dfd Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 28 Mar 2010 23:18:25 +0100 Subject: Stab one bug. When joining an estate with a new region, make sure it's also used on first run and not only later. --- OpenSim/Region/Framework/Scenes/Scene.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8a583c1..0085df3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -635,6 +635,8 @@ namespace OpenSim.Region.Framework.Scenes int estateID = estateIDs[0]; + m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(estateID); + if (m_storageManager.EstateDataStore.LinkRegion(m_regInfo.RegionID, estateID)) break; -- cgit v1.1