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=5645bulletsim
parent
3146f4bae0
commit
c9e6b7bd10
|
@ -186,7 +186,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private string[] GetUserNames(UUID uuid)
|
||||
{
|
||||
string[] returnstring = new string[2];
|
||||
|
@ -292,6 +291,25 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
|||
return userID.ToString();
|
||||
}
|
||||
|
||||
public void AddUser(UUID uuid, string first, string last)
|
||||
{
|
||||
if (m_UserCache.ContainsKey(uuid))
|
||||
return;
|
||||
|
||||
UserData user = new UserData();
|
||||
user.Id = uuid;
|
||||
user.FirstName = first;
|
||||
user.LastName = last;
|
||||
// user.ProfileURL = we should initialize this to the default
|
||||
|
||||
AddUserInternal(user);
|
||||
}
|
||||
|
||||
public void AddUser(UUID uuid, string first, string last, string profileURL)
|
||||
{
|
||||
AddUser(uuid, profileURL + ";" + first + " " + last);
|
||||
}
|
||||
|
||||
public void AddUser(UUID id, string creatorData)
|
||||
{
|
||||
if (m_UserCache.ContainsKey(id))
|
||||
|
@ -299,18 +317,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
|||
|
||||
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData);
|
||||
|
||||
UserData user = new UserData();
|
||||
user.Id = id;
|
||||
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id);
|
||||
|
||||
if (account != null)
|
||||
{
|
||||
user.FirstName = account.FirstName;
|
||||
user.LastName = account.LastName;
|
||||
// user.ProfileURL = we should initialize this to the default
|
||||
AddUser(id, account.FirstName, account.LastName);
|
||||
}
|
||||
else
|
||||
{
|
||||
UserData user = new UserData();
|
||||
user.Id = id;
|
||||
|
||||
if (creatorData != null && creatorData != string.Empty)
|
||||
{
|
||||
//creatorData = <endpoint>;<name>
|
||||
|
@ -338,17 +355,19 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
|
|||
user.FirstName = "Unknown";
|
||||
user.LastName = "User";
|
||||
}
|
||||
|
||||
AddUserInternal(user);
|
||||
}
|
||||
}
|
||||
|
||||
lock (m_UserCache)
|
||||
m_UserCache[id] = user;
|
||||
|
||||
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.HomeURL);
|
||||
}
|
||||
|
||||
public void AddUser(UUID uuid, string first, string last, string profileURL)
|
||||
void AddUserInternal(UserData user)
|
||||
{
|
||||
AddUser(uuid, profileURL + ";" + first + " " + last);
|
||||
lock (m_UserCache)
|
||||
m_UserCache[user.Id] = user;
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}",
|
||||
user.Id, user.FirstName, user.LastName, user.HomeURL);
|
||||
}
|
||||
|
||||
//public void AddUser(UUID uuid, string userData)
|
||||
|
|
|
@ -5,13 +5,48 @@ using OpenMetaverse;
|
|||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// This maintains the relationship between a UUID and a user name.
|
||||
/// </summary>
|
||||
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);
|
||||
|
||||
/// <summary>
|
||||
/// Add a user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If an account is found for the UUID, then the names in this will be used rather than any information
|
||||
/// extracted from creatorData.
|
||||
/// </remarks>
|
||||
/// <param name="uuid"></param>
|
||||
/// <param name="creatorData">The creator data for this user.</param>
|
||||
void AddUser(UUID uuid, string creatorData);
|
||||
|
||||
/// <summary>
|
||||
/// Add a user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The UUID is related to the name without any other checks being performed, such as user account presence.
|
||||
/// </remarks>
|
||||
/// <param name="uuid"></param>
|
||||
/// <param name="firstName"></param>
|
||||
/// <param name="lastName"></param>
|
||||
void AddUser(UUID uuid, string firstName, string lastName);
|
||||
|
||||
/// <summary>
|
||||
/// Add a user.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The arguments apart from uuid are formed into a creatorData string and processing proceeds as for the
|
||||
/// AddUser(UUID uuid, string creatorData) method.
|
||||
/// </remarks>
|
||||
/// <param name="uuid"></param>
|
||||
/// <param name="firstName"></param>
|
||||
/// <param name="profileURL"></param>
|
||||
void AddUser(UUID uuid, string firstName, string lastName, string profileURL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,14 +2596,26 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
private void CacheUserName(AgentCircuitData aCircuit)
|
||||
/// <summary>
|
||||
/// Cache the user name for later use.
|
||||
/// </summary>
|
||||
/// <param name="sp"></param>
|
||||
/// <param name="aCircuit"></param>
|
||||
private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit)
|
||||
{
|
||||
IUserManagement uMan = RequestModuleInterface<IUserManagement>();
|
||||
if (uMan != null)
|
||||
{
|
||||
string homeURL = string.Empty;
|
||||
string first = aCircuit.firstname, last = aCircuit.lastname;
|
||||
|
||||
if (sp.PresenceType == PresenceType.Npc)
|
||||
{
|
||||
uMan.AddUser(aCircuit.AgentID, first, last);
|
||||
}
|
||||
else
|
||||
{
|
||||
string homeURL = string.Empty;
|
||||
|
||||
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
|
||||
homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
|
||||
|
||||
|
@ -2619,6 +2632,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
uMan.AddUser(aCircuit.AgentID, first, last, homeURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool VerifyClient(AgentCircuitData aCircuit, System.Net.IPEndPoint ep, out bool vialogin)
|
||||
{
|
||||
|
|
|
@ -34,6 +34,7 @@ using OpenMetaverse;
|
|||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications;
|
||||
using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
|
||||
using OpenSim.Region.CoreModules.Framework.UserManagement;
|
||||
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
@ -57,8 +58,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
|
|||
config.Configs["NPC"].Set("Enabled", "true");
|
||||
|
||||
AvatarFactoryModule afm = new AvatarFactoryModule();
|
||||
UserManagementModule umm = new UserManagementModule();
|
||||
|
||||
TestScene scene = SceneHelpers.SetupScene();
|
||||
SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule());
|
||||
SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule());
|
||||
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
|
||||
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
|
||||
|
||||
|
@ -81,6 +84,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
|
|||
|
||||
Assert.That(npc, Is.Not.Null);
|
||||
Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
|
||||
Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
@ -331,6 +331,7 @@ namespace OpenSim.Tests.Common
|
|||
agentData.InventoryFolder = UUID.Zero;
|
||||
agentData.startpos = Vector3.Zero;
|
||||
agentData.CapsPath = "http://wibble.com";
|
||||
agentData.ServiceURLs = new Dictionary<string, object>();
|
||||
|
||||
return agentData;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue