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
This commit is contained in:
Justin Clark-Casey (justincc)
2011-08-19 00:45:22 +01:00
parent 3146f4bae0
commit c9e6b7bd10
5 changed files with 103 additions and 30 deletions

View File

@@ -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)
/// <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 (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
if (aCircuit.lastname.StartsWith("@"))
if (sp.PresenceType == PresenceType.Npc)
{
string[] parts = aCircuit.firstname.Split('.');
if (parts.Length >= 2)
{
first = parts[0];
last = parts[1];
}
uMan.AddUser(aCircuit.AgentID, first, last);
}
else
{
string homeURL = string.Empty;
uMan.AddUser(aCircuit.AgentID, first, last, homeURL);
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
homeURL = aCircuit.ServiceURLs["HomeURI"].ToString();
if (aCircuit.lastname.StartsWith("@"))
{
string[] parts = aCircuit.firstname.Split('.');
if (parts.Length >= 2)
{
first = parts[0];
last = parts[1];
}
}
uMan.AddUser(aCircuit.AgentID, first, last, homeURL);
}
}
}