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.
0.7.1-dev
Melanie 2011-04-08 04:19:17 +01:00
parent d31175060f
commit abea0c74c2
5 changed files with 97 additions and 4 deletions

View File

@ -10268,6 +10268,55 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_log.Info("LSL print():" + str);
}
}
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

View File

@ -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));
}
@ -493,9 +494,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
{

View File

@ -209,6 +209,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
void llInstantMessage(string user, string message);
LSL_String llIntegerToBase64(int number);
LSL_String llKey2Name(string id);
LSL_String llGetUsername(string id);
LSL_String llRequestUsername(string id);
LSL_String llGetDisplayName(string id);
LSL_String llRequestDisplayName(string id);
void llLinkParticleSystem(int linknum, LSL_List rules);
LSL_String llList2CSV(LSL_List src);
LSL_Float llList2Float(LSL_List src, int index);

View File

@ -50,6 +50,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int STATUS_CAST_SHADOWS = 512;
public const int AGENT = 1;
public const int AGENT_BY_LEGACY_NAME = 1;
public const int AGENT_BY_USERNAME = 0x10;
public const int ACTIVE = 2;
public const int PASSIVE = 4;
public const int SCRIPTED = 8;

View File

@ -894,6 +894,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_LSL_Functions.llKey2Name(id);
}
public LSL_String llGetUsername(string id)
{
return m_LSL_Functions.llGetUsername(id);
}
public LSL_String llRequestUsername(string id)
{
return m_LSL_Functions.llRequestUsername(id);
}
public LSL_String llGetDisplayName(string id)
{
return m_LSL_Functions.llGetDisplayName(id);
}
public LSL_String llRequestDisplayName(string id)
{
return m_LSL_Functions.llRequestDisplayName(id);
}
public void llLinkParticleSystem(int linknum, LSL_List rules)
{
m_LSL_Functions.llLinkParticleSystem(linknum, rules);