Do not allow a script to attach a prim if its being sat upon.

This prevents a stack overflow where a get position on the avatar will refer to the attachment which will in turn refer back to the avatar.
This required recording of all sitting avatars on a prim which is done separately from recording the sit target avatar.
Recording HashSet is null if there are no sitting avatars in order to save memory.
This commit is contained in:
Justin Clark-Casey (justincc)
2012-07-09 21:24:32 +01:00
parent 1a2ab7bc69
commit 2eaa6d5ace
7 changed files with 227 additions and 24 deletions

View File

@@ -412,26 +412,49 @@ namespace OpenSim.Tests.Common
/// <returns></returns>
public static AgentCircuitData GenerateAgentData(UUID agentId)
{
string firstName = "testfirstname";
AgentCircuitData acd = GenerateCommonAgentData();
AgentCircuitData agentData = new AgentCircuitData();
agentData.AgentID = agentId;
agentData.firstname = firstName;
agentData.lastname = "testlastname";
acd.AgentID = agentId;
acd.firstname = "testfirstname";
acd.lastname = "testlastname";
acd.ServiceURLs = new Dictionary<string, object>();
return acd;
}
/// <summary>
/// Generate some standard agent connection data.
/// </summary>
/// <param name="agentId"></param>
/// <returns></returns>
public static AgentCircuitData GenerateAgentData(UserAccount ua)
{
AgentCircuitData acd = GenerateCommonAgentData();
acd.AgentID = ua.PrincipalID;
acd.firstname = ua.FirstName;
acd.lastname = ua.LastName;
acd.ServiceURLs = ua.ServiceURLs;
return acd;
}
private static AgentCircuitData GenerateCommonAgentData()
{
AgentCircuitData acd = new AgentCircuitData();
// XXX: Sessions must be unique, otherwise one presence can overwrite another in NullPresenceData.
agentData.SessionID = UUID.Random();
agentData.SecureSessionID = UUID.Random();
acd.SessionID = UUID.Random();
acd.SecureSessionID = UUID.Random();
agentData.circuitcode = 123;
agentData.BaseFolder = UUID.Zero;
agentData.InventoryFolder = UUID.Zero;
agentData.startpos = Vector3.Zero;
agentData.CapsPath = "http://wibble.com";
agentData.ServiceURLs = new Dictionary<string, object>();
agentData.Appearance = new AvatarAppearance();
acd.circuitcode = 123;
acd.BaseFolder = UUID.Zero;
acd.InventoryFolder = UUID.Zero;
acd.startpos = Vector3.Zero;
acd.CapsPath = "http://wibble.com";
acd.Appearance = new AvatarAppearance();
return agentData;
return acd;
}
/// <summary>
@@ -440,6 +463,9 @@ namespace OpenSim.Tests.Common
/// <remarks>
/// This can be used for tests where there is only one region or where there are multiple non-neighbour regions
/// and teleport doesn't take place.
///
/// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
/// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
/// </remarks>
/// <param name="scene"></param>
/// <param name="agentId"></param>
@@ -452,6 +478,10 @@ namespace OpenSim.Tests.Common
/// <summary>
/// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
/// </summary>
/// <remarks>
/// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
/// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
/// </remarks>
/// <param name="scene"></param>
/// <param name="agentId"></param>
/// <param name="sceneManager"></param>
@@ -461,6 +491,17 @@ namespace OpenSim.Tests.Common
return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager);
}
/// <summary>
/// Add a root agent.
/// </summary>
/// <param name="scene"></param>
/// <param name="ua"></param>
/// <returns></returns>
public static ScenePresence AddScenePresence(Scene scene, UserAccount ua)
{
return AddScenePresence(scene, GenerateAgentData(ua));
}
/// <summary>
/// Add a root agent.
/// </summary>

View File

@@ -138,6 +138,15 @@ namespace OpenSim.Tests.Common
CreateUserWithInventory(scene, ua, pw);
return ua;
}
public static UserAccount CreateUserWithInventory(
Scene scene, string firstName, string lastName, int userId, string pw)
{
UserAccount ua
= new UserAccount(TestHelpers.ParseTail(userId)) { FirstName = firstName, LastName = lastName };
CreateUserWithInventory(scene, ua, pw);
return ua;
}
public static void CreateUserWithInventory(Scene scene, UserAccount ua, string pw)
{