diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 4246dc96df..45aa523560 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -3339,7 +3339,7 @@ namespace OpenSim.Framework return p.WorkingSet64; } - // returns a timestamp in ms as double + // returns a timestamp in seconds as double // using the time resolution avaiable to StopWatch [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] public static double GetTimeStamp() @@ -3347,6 +3347,7 @@ namespace OpenSim.Framework return Stopwatch.GetTimestamp() * TimeStampClockPeriod; } + // returns a timestamp in ms as double [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] public static double GetTimeStampMS() { @@ -3627,16 +3628,99 @@ namespace OpenSim.Framework if (!lastname.Contains("@")) return false; - if (!firstname.Contains(".")) + string[] parts = firstname.Split('.'); + if(parts.Length != 2) return false; - realFirstName = firstname.Split('.')[0]; - realLastName = firstname.Split('.')[1]; + realFirstName = parts[0].Trim(); + realLastName = parts[1].Trim(); + lastname = lastname.Trim(); serverURI = new Uri("http://" + lastname.Replace("@", "")).ToString(); return true; } + public static int ParseAvatarName(string name, out string FirstName, out string LastName, out string serverURI) + { + FirstName = LastName = serverURI = string.Empty; + + if (string.IsNullOrWhiteSpace(name) || name.Length < 1) + return 0; + + int i = 0; + bool havedot = false; + + while (i < name.Length && name[i] == ' ') ++i; + int start = i; + + while (i < name.Length) + { + char c = name[i]; + if (c == '@') + return 0; + + if (c == ' ') + { + if (i >= name.Length - 1 || i == start) + return 0; + break; + } + if (c == '.') + { + if (i >= name.Length - 1 || i == start) + return 0; + havedot = true; + break; + } + ++i; + } + + FirstName = name.Substring(start, i - start); + + if (i >= name.Length - 1) + return 1; + + ++i; + while (i < name.Length && name[i] == ' ') ++i; + if (i == name.Length) + return 1; + + start = i; + while (i < name.Length) + { + char c = name[i]; + if (c == '.') + { + if (havedot || i >= name.Length - 1) + return 0; + else start = i + 1; + } + else if (c == '@') + { + if(i >= name.Length - 1) + return 0; + + int j = i; + while (j > start && name[j - 1] == ' ') --j; + if (j <= start) + return 0; + + LastName = name.Substring(start, j - start); + + ++i; + while (i < name.Length && name[i] == ' ') ++i; + if (i > name.Length - 3) + return 0; + + serverURI = name.Substring(i).TrimEnd(); + return serverURI.Length == 0 ? 2 : 3; + } + ++i; + } + LastName = name.Substring(start).TrimEnd(); + return LastName.Length == 0 ? 1 : 2; + } + /// /// Produces a universal (HG) system-facing identifier given the information /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 932ed9e558..0231fa03a2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6855,7 +6855,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (presence != null) { - return presence.ControllingClient.Name; + return presence.Name; //return presence.Name; } @@ -6874,22 +6874,119 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if(string.IsNullOrWhiteSpace(name)) return ScriptBaseClass.NULL_KEY; + int nc = Util.ParseAvatarName(name, out string firstName, out string lastName, out string server); + if (nc < 2) + return ScriptBaseClass.NULL_KEY; + + string sname; + if (nc == 2) + sname = firstName + " " + lastName; + else + sname = firstName + "." + lastName + " @" + server; + foreach (ScenePresence sp in World.GetScenePresences()) { if (sp.IsDeleted || sp.IsChildAgent) continue; - - string test = sp.ControllingClient.Name; - if (!name.Contains(" ")) - test = test.Replace(" ", "."); - - if (String.Compare(name, test, true) == 0) + if (String.Compare(sname, sp.Name, true) == 0) return sp.UUID.ToString(); } return ScriptBaseClass.NULL_KEY; } + public LSL_Key llRequestUserKey(LSL_String username) + { + m_host.AddScriptLPS(1); + + if (string.IsNullOrWhiteSpace(username)) + return ScriptBaseClass.NULL_KEY; + + int nc = Util.ParseAvatarName(username, out string firstName, out string lastName, out string server); + if (nc < 2) + return ScriptBaseClass.NULL_KEY; + + string sname; + if (nc == 2) + sname = firstName + " " + lastName; + else + sname = firstName + "." + lastName + " @" + server; + + foreach (ScenePresence sp in World.GetScenePresences()) + { + if (sp.IsDeleted || sp.IsChildAgent) + continue; + if (String.Compare(sname, sp.Name, true) == 0) + { + string ftid = m_AsyncCommands.DataserverPlugin.RequestWithImediatePost(m_host.LocalId, + m_item.ItemID, sp.UUID.ToString()); + return ftid; + } + } + + Action act = eventID => + { + string reply = ScriptBaseClass.NULL_KEY; + UUID userID = UUID.Zero; + IUserManagement userManager = World.RequestModuleInterface(); + if (nc == 2) + { + if (userManager != null) + { + userID = userManager.GetUserIdByName(firstName, lastName); + if (userID != UUID.Zero) + reply = userID.ToString(); + } + } + else + { + string url = "http://" + server; + if (Uri.TryCreate(url, UriKind.Absolute, out Uri dummy)) + { + bool notfound = true; + if (userManager != null) + { + string hgfirst = firstName + "." + lastName; + string hglast = "@" + server; + userID = userManager.GetUserIdByName(hgfirst, hglast); + if (userID != UUID.Zero) + { + notfound = false; + reply = userID.ToString(); + } + } + + if(notfound) + { + try + { + UserAgentServiceConnector userConnection = new UserAgentServiceConnector(url); + if (userConnection != null) + { + userID = userConnection.GetUUID(firstName, lastName); + if (userID != UUID.Zero) + { + if (userManager != null) + userManager.AddUser(userID, firstName, lastName, url); + reply = userID.ToString(); + } + } + } + catch + { + reply = ScriptBaseClass.NULL_KEY; + } + } + } + } + m_AsyncCommands.DataserverPlugin.DataserverReply(eventID, reply); + }; + + UUID tid = m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, act); + ScriptSleep(m_sleepMsOnRequestAgentData); + return tid.ToString(); + } + public void llSetTextureAnim(int mode, int face, int sizex, int sizey, double start, double length, double rate) { m_host.AddScriptLPS(1); @@ -15268,6 +15365,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api }; UUID rq = m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, act); + ScriptSleep(m_sleepMsOnRequestAgentData); 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 f6afd1db74..8c6a8069ea 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -308,6 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llRemoveFromLandPassList(string avatar); void llRemoveInventory(string item); void llRemoveVehicleFlags(int flags); + LSL_Key llRequestUserKey(LSL_String username); LSL_Key llRequestAgentData(string id, int data); LSL_Key llRequestInventoryData(LSL_String name); void llRequestPermissions(string agent, int perm); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 10c1a9bb5f..396c8a3c65 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public partial class ScriptBaseClass { // SCRIPTS CONSTANTS - public static readonly LSLInteger OS_APIVERSION = 14; + public static readonly LSLInteger OS_APIVERSION = 15; public static readonly LSLInteger TRUE = 1; public static readonly LSLInteger FALSE = 0; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 31c06dca22..55dd7cc18b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1336,6 +1336,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llRemoveVehicleFlags(flags); } + public LSL_Key llRequestUserKey(LSL_String username) + { + return m_LSL_Functions.llRequestUserKey(username); + } + public LSL_Key llRequestAgentData(string id, int data) { return m_LSL_Functions.llRequestAgentData(id, data); diff --git a/bin/assets/TexturesAssetSet/TexturesAssetSet.xml b/bin/assets/TexturesAssetSet/TexturesAssetSet.xml index ad204a73d9..df985d37e5 100644 --- a/bin/assets/TexturesAssetSet/TexturesAssetSet.xml +++ b/bin/assets/TexturesAssetSet/TexturesAssetSet.xml @@ -414,8 +414,7 @@ - - +