change llRequestDisplayName and llGetDisplayName

This commit is contained in:
UbitUmarov
2020-08-15 04:21:54 +01:00
parent 2350bd9250
commit f1cd3aa007
3 changed files with 51 additions and 10 deletions

View File

@@ -15300,19 +15300,60 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return rq.ToString();
}
public LSL_String llGetDisplayName(string id)
public LSL_String llGetDisplayName(LSL_Key id)
{
return llKey2Name(id);
m_host.AddScriptLPS(1);
if (UUID.TryParse(id, out UUID key) && key != UUID.Zero)
{
ScenePresence presence = World.GetScenePresence(key);
if (presence != null)
{
return presence.Name;
}
}
return String.Empty;
}
public LSL_Key llRequestDisplayName(string id)
public LSL_String llRequestDisplayName(LSL_Key id)
{
UUID rq = UUID.Random();
m_host.AddScriptLPS(1);
if (!UUID.TryParse(id, out UUID key) || key == UUID.Zero)
return string.Empty;
m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, rq.ToString());
ScenePresence lpresence = World.GetScenePresence(key);
if (lpresence != null)
{
string lname = lpresence.Name;
string lrq = UUID.Random().ToString();
UUID ltis = m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, lrq);
m_AsyncCommands.DataserverPlugin.DataserverReply(lrq, lname);
return ltis.ToString();
}
m_AsyncCommands.DataserverPlugin.DataserverReply(rq.ToString(), llKey2Name(id));
Action<string> act = eventID =>
{
string name = String.Empty;
ScenePresence presence = World.GetScenePresence(key);
if (presence != null)
{
name = presence.Name;
}
else if (World.TryGetSceneObjectPart(key, out SceneObjectPart sop) && sop != null)
{
name = sop.Name;
}
else
{
UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, key);
if (account != null)
{
name = account.FirstName + " " + account.LastName;
}
}
m_AsyncCommands.DataserverPlugin.DataserverReply(eventID, name);
};
UUID rq = m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, UUID.Random().ToString(), act);
return rq.ToString();
}
/*

View File

@@ -234,8 +234,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_String llKey2Name(LSL_Key id);
LSL_String llGetUsername(LSL_Key id);
LSL_String llRequestUsername(LSL_Key id);
LSL_String llGetDisplayName(string id);
LSL_Key llRequestDisplayName(string id);
LSL_String llGetDisplayName(LSL_Key id);
LSL_String llRequestDisplayName(LSL_Key id);
void llLinkParticleSystem(int linknum, LSL_List rules);
void llLinkSitTarget(LSL_Integer link, LSL_Vector offset, LSL_Rotation rot);
LSL_String llList2CSV(LSL_List src);

View File

@@ -966,12 +966,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return m_LSL_Functions.llRequestUsername(id);
}
public LSL_String llGetDisplayName(string id)
public LSL_String llGetDisplayName(LSL_Key id)
{
return m_LSL_Functions.llGetDisplayName(id);
}
public LSL_Key llRequestDisplayName(string id)
public LSL_String llRequestDisplayName(LSL_Key id)
{
return m_LSL_Functions.llRequestDisplayName(id);
}