mirror of
https://github.com/opensim/opensim.git
synced 2026-05-15 03:15:41 +08:00
change llName2Key and add llRequestUserKey (not the patch on mantis 8369, now utdated). some testing needed..
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Produces a universal (HG) system-facing identifier given the information
|
||||
/// </summary>
|
||||
|
||||
@@ -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<string> act = eventID =>
|
||||
{
|
||||
string reply = ScriptBaseClass.NULL_KEY;
|
||||
UUID userID = UUID.Zero;
|
||||
IUserManagement userManager = World.RequestModuleInterface<IUserManagement>();
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -414,8 +414,7 @@
|
||||
<Key Name="fileName" Value="transparency.jp2" />
|
||||
</Section>
|
||||
|
||||
<!-- 3a367d1c-bef1-6d43-7595-e88c1e3aadb3 is a UUID that viewers assume exists in the asset server -->
|
||||
<!-- See http://opensimulator.org/mantis/bug_view_advanced_page.php?bug_id=4751 for more details -->
|
||||
|
||||
<Section Name="Default Alpha Layer Texture">
|
||||
<Key Name="assetID" Value="3a367d1c-bef1-6d43-7595-e88c1e3aadb3"/>
|
||||
<Key Name="name" Value="Default Alpha Layer Texture"/>
|
||||
|
||||
Reference in New Issue
Block a user