diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3913ce7de5..0301d30b22 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -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 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(); } /* diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index eb86236475..a4f49d5d35 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -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); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 7d53e5caeb..ddac45e9bc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -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); }