From c9e6b7bd10b2cdaa917e41259ae0d612f2171f7a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Aug 2011 00:45:22 +0100 Subject: Stop NPC's getting hypergrid like names in some circumstances. This meant punching in another AddUser() method in IUserManagement to do a direct name to UUID associated without the account check (since NPCs don't have accounts). May address http://opensimulator.org/mantis/view.php?id=5645 --- .../Region/Framework/Interfaces/IUserManagement.cs | 37 ++++++++++++++++++- OpenSim/Region/Framework/Scenes/Scene.cs | 42 ++++++++++++++-------- 2 files changed, 64 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs index 5d30aa8..c66e053 100644 --- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs +++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs @@ -5,13 +5,48 @@ using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces { + /// + /// This maintains the relationship between a UUID and a user name. + /// public interface IUserManagement { string GetUserName(UUID uuid); string GetUserHomeURL(UUID uuid); string GetUserUUI(UUID uuid); string GetUserServerURL(UUID uuid, string serverType); - void AddUser(UUID uuid, string userData); + + /// + /// Add a user. + /// + /// + /// If an account is found for the UUID, then the names in this will be used rather than any information + /// extracted from creatorData. + /// + /// + /// The creator data for this user. + void AddUser(UUID uuid, string creatorData); + + /// + /// Add a user. + /// + /// + /// The UUID is related to the name without any other checks being performed, such as user account presence. + /// + /// + /// + /// + void AddUser(UUID uuid, string firstName, string lastName); + + /// + /// Add a user. + /// + /// + /// The arguments apart from uuid are formed into a creatorData string and processing proceeds as for the + /// AddUser(UUID uuid, string creatorData) method. + /// + /// + /// + /// void AddUser(UUID uuid, string firstName, string lastName, string profileURL); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ae88a87..513c0ea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2582,12 +2582,13 @@ namespace OpenSim.Region.Framework.Scenes } } - if (GetScenePresence(client.AgentId) != null) + ScenePresence createdSp = GetScenePresence(client.AgentId); + if (createdSp != null) { m_LastLogin = Util.EnvironmentTickCount(); // Cache the user's name - CacheUserName(aCircuit); + CacheUserName(createdSp, aCircuit); EventManager.TriggerOnNewClient(client); if (vialogin) @@ -2595,28 +2596,41 @@ namespace OpenSim.Region.Framework.Scenes } } - private void CacheUserName(AgentCircuitData aCircuit) + /// + /// Cache the user name for later use. + /// + /// + /// + private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) { IUserManagement uMan = RequestModuleInterface(); if (uMan != null) { - string homeURL = string.Empty; string first = aCircuit.firstname, last = aCircuit.lastname; - if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) - homeURL = aCircuit.ServiceURLs["HomeURI"].ToString(); - - if (aCircuit.lastname.StartsWith("@")) + if (sp.PresenceType == PresenceType.Npc) + { + uMan.AddUser(aCircuit.AgentID, first, last); + } + else { - string[] parts = aCircuit.firstname.Split('.'); - if (parts.Length >= 2) + string homeURL = string.Empty; + + if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) + homeURL = aCircuit.ServiceURLs["HomeURI"].ToString(); + + if (aCircuit.lastname.StartsWith("@")) { - first = parts[0]; - last = parts[1]; + string[] parts = aCircuit.firstname.Split('.'); + if (parts.Length >= 2) + { + first = parts[0]; + last = parts[1]; + } } - } - uMan.AddUser(aCircuit.AgentID, first, last, homeURL); + uMan.AddUser(aCircuit.AgentID, first, last, homeURL); + } } } -- cgit v1.1