mirror of
https://github.com/opensim/opensim.git
synced 2026-08-04 16:22:50 +08:00
Add support for the new display name related functions in LSL. This does not
implement the display names functionality as such, but it allows scripts that are display name aware to function as if the display name were implemented and set to the avatar name.
This commit is contained in:
@@ -10909,6 +10909,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
return GetNumberOfSides(parts[0]);
|
||||
}
|
||||
|
||||
private string Name2Username(string name)
|
||||
{
|
||||
string[] parts = name.Split(new char[] {' '});
|
||||
if (parts.Length < 2)
|
||||
return name.ToLower();
|
||||
if (parts[1] == "Resident")
|
||||
return parts[0].ToLower();
|
||||
|
||||
return name.Replace(" ", ".").ToLower();
|
||||
}
|
||||
|
||||
public LSL_String llGetUsername(string id)
|
||||
{
|
||||
return Name2Username(llKey2Name(id));
|
||||
}
|
||||
|
||||
public LSL_String llRequestUsername(string id)
|
||||
{
|
||||
UUID rq = UUID.Random();
|
||||
|
||||
UUID tid = AsyncCommands.
|
||||
DataserverPlugin.RegisterRequest(m_localID,
|
||||
m_itemID, rq.ToString());
|
||||
|
||||
AsyncCommands.
|
||||
DataserverPlugin.DataserverReply(rq.ToString(), Name2Username(llKey2Name(id)));
|
||||
|
||||
return rq.ToString();
|
||||
}
|
||||
|
||||
public LSL_String llGetDisplayName(string id)
|
||||
{
|
||||
return llKey2Name(id);
|
||||
}
|
||||
|
||||
public LSL_String llRequestDisplayName(string id)
|
||||
{
|
||||
UUID rq = UUID.Random();
|
||||
|
||||
UUID tid = AsyncCommands.
|
||||
DataserverPlugin.RegisterRequest(m_localID,
|
||||
m_itemID, rq.ToString());
|
||||
|
||||
AsyncCommands.
|
||||
DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));
|
||||
|
||||
return rq.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class NotecardCache
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
private Object SenseLock = new Object();
|
||||
|
||||
private const int AGENT = 1;
|
||||
private const int AGENT_BY_USERNAME = 0x10;
|
||||
private const int ACTIVE = 2;
|
||||
private const int PASSIVE = 4;
|
||||
private const int SCRIPTED = 8;
|
||||
@@ -202,7 +203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
List<SensedEntity> sensedEntities = new List<SensedEntity>();
|
||||
|
||||
// Is the sensor type is AGENT and not SCRIPTED then include agents
|
||||
if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0)
|
||||
if ((ts.type & (AGENT | AGENT_BY_USERNAME)) != 0 && (ts.type & SCRIPTED) == 0)
|
||||
{
|
||||
sensedEntities.AddRange(doAgentSensor(ts));
|
||||
}
|
||||
@@ -505,9 +506,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
{
|
||||
ScenePresence sp;
|
||||
// Try lookup by name will return if/when found
|
||||
if (!m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp))
|
||||
return sensedEntities;
|
||||
senseEntity(sp);
|
||||
if (((ts.type & AGENT) != 0) && m_CmdManager.m_ScriptEngine.World.TryGetAvatarByName(ts.name, out sp))
|
||||
senseEntity(sp);
|
||||
if ((ts.type & AGENT_BY_USERNAME) != 0)
|
||||
{
|
||||
m_CmdManager.m_ScriptEngine.World.ForEachScenePresence(
|
||||
delegate (ScenePresence ssp)
|
||||
{
|
||||
if (ssp.Lastname == "Resident")
|
||||
{
|
||||
if (ssp.Firstname.ToLower() == ts.name)
|
||||
senseEntity(ssp);
|
||||
return;
|
||||
}
|
||||
if (ssp.Name.Replace(" ", ".").ToLower() == ts.name)
|
||||
senseEntity(ssp);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return sensedEntities;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user