Merge branch 'master' into presence-refactor

slimupdates
Melanie 2009-12-30 22:24:14 +00:00
commit a21ce9151b
16 changed files with 173 additions and 37 deletions

View File

@ -268,7 +268,7 @@ namespace OpenSim.Client.Linden
else
{
string reason;
if (scene.NewUserConnection(agentData, out reason))
if (scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason))
{
success = true;
}

View File

@ -199,7 +199,7 @@ namespace OpenSim.Client.Linden
Scene scene;
if (TryGetRegion(regionHandle, out scene))
{
return scene.NewUserConnection(agent, out reason);
return scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
}
reason = "Region not found.";
return false;

View File

@ -609,7 +609,7 @@ namespace OpenSim.Client.MXP.PacketHandler
agent.Appearance = new AvatarAppearance();
}
return scene.NewUserConnection(agent, out reason);
return scene.NewUserConnection(agent, 0, out reason);
}
public void PrintDebugInformation()

View File

@ -45,7 +45,7 @@ namespace OpenSim.Framework.Communications.Clients
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, out string reason)
public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, uint teleportFlags, out string reason)
{
reason = String.Empty;
@ -83,7 +83,8 @@ namespace OpenSim.Framework.Communications.Clients
}
// Add the regionhandle of the destination region
ulong regionHandle = GetRegionHandle(region.RegionHandle);
args["destination_handle"] = OSD.FromString(regionHandle.ToString());
args["destination_handle"] = OSD.FromString(regionHandle.ToString());
args["teleport_flags"] = OSD.FromString(teleportFlags.ToString());
string strBuffer = "";
byte[] buffer = new byte[1];

View File

@ -557,7 +557,7 @@ namespace OpenSim.Region.CoreModules.InterGrid
// Call 'new user' event handler
string reason;
if (!homeScene.NewUserConnection(agentData, out reason))
if (!homeScene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason))
{
responseMap["connect"] = OSD.FromBoolean(false);
responseMap["message"] = OSD.FromString(String.Format("Connection refused: {0}", reason));

View File

@ -144,7 +144,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
* Agent-related communications
*/
public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason)
public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
{
foreach (Scene s in m_sceneList)
@ -152,7 +152,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
if (s.RegionInfo.RegionHandle == regionHandle)
{
// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle);
return s.NewUserConnection(aCircuit, out reason);
return s.NewUserConnection(aCircuit, teleportFlags, out reason);
}
}

View File

@ -157,10 +157,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
* Agent-related communications
*/
public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason)
public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason)
{
// Try local first
if (m_localBackend.SendCreateChildAgent(regionHandle, aCircuit, out reason))
if (m_localBackend.SendCreateChildAgent(regionHandle, aCircuit, teleportFlags, out reason))
return true;
// else do the remote thing
@ -173,7 +173,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
{
m_regionClient.SendUserInformation(regInfo, aCircuit);
return m_regionClient.DoCreateChildAgentCall(regInfo, aCircuit, "None", out reason);
return m_regionClient.DoCreateChildAgentCall(regInfo, aCircuit, "None", teleportFlags, out reason);
}
//else
// m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
@ -436,11 +436,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
}
OSDMap resp = new OSDMap(2);
string reason = String.Empty;
string reason = String.Empty;
uint teleportFlags = 0;
if (args.ContainsKey("teleport_flags"))
{
teleportFlags = args["teleport_flags"].AsUInteger();
}
// This is the meaning of POST agent
m_regionClient.AdjustUserInformation(aCircuit);
bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, out reason);
bool result = m_localBackend.SendCreateChildAgent(regionhandle, aCircuit, teleportFlags, out reason);
resp["reason"] = OSD.FromString(reason);
resp["success"] = OSD.FromBoolean(result);

View File

@ -37,7 +37,7 @@ namespace OpenSim.Region.Framework.Interfaces
{
#region Agents
bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason);
bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason);
/// <summary>
/// Full child agent update.

View File

@ -146,7 +146,10 @@ namespace OpenSim.Region.Framework.Scenes.Animation
const float PREJUMP_DELAY = 0.25f;
#region Inputs
if (m_scenePresence.SitGround)
{
return "SIT_GROUND_CONSTRAINED";
}
AgentManager.ControlFlags controlFlags = (AgentManager.ControlFlags)m_scenePresence.AgentControlFlags;
PhysicsActor actor = m_scenePresence.PhysicsActor;
@ -156,7 +159,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
Vector3 left = Vector3.Transform(Vector3.UnitY, rotMatrix);
// Check control flags
bool heldForward = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
bool heldForward =
(((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) || ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS));
bool heldBack = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG;
bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;

View File

@ -203,7 +203,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
string reason = String.Empty;
//if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, out reason))
if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
{
avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
reason));

View File

@ -3316,12 +3316,16 @@ namespace OpenSim.Region.Framework.Scenes
/// Use NewUserConnection() directly if possible so the return type can refuse connections.
/// At the moment nothing actually seems to use this event,
/// as everything is switching to calling the NewUserConnection method directly.
///
/// Now obsoleting this because it doesn't handle teleportFlags propertly
///
/// </summary>
/// <param name="agent"></param>
[Obsolete("Please call NewUserConnection directly.")]
public void HandleNewUserConnection(AgentCircuitData agent)
{
string reason;
NewUserConnection(agent, out reason);
NewUserConnection(agent, 0, out reason);
}
/// <summary>
@ -3334,8 +3338,16 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="reason">Outputs the reason for the false response on this string</param>
/// <returns>True if the region accepts this agent. False if it does not. False will
/// also return a reason.</returns>
public bool NewUserConnection(AgentCircuitData agent, out string reason)
public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason)
{
//Teleport flags:
//
// TeleportFlags.ViaGodlikeLure - Border Crossing
// TeleportFlags.ViaLogin - Login
// TeleportFlags.TeleportFlags.ViaLure - Teleport request sent by another user
// TeleportFlags.ViaLandmark | TeleportFlags.ViaLocation | TeleportFlags.ViaLandmark | TeleportFlags.Default - Regular Teleport
if (loginsdisabled)
{
reason = "Logins Disabled";
@ -3343,9 +3355,9 @@ namespace OpenSim.Region.Framework.Scenes
}
// Don't disable this log message - it's too helpful
m_log.InfoFormat(
"[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5})",
"[CONNECTION BEGIN]: Region {0} told of incoming {1} agent {2} {3} {4} (circuit code {5}, teleportflags {6})",
RegionInfo.RegionName, (agent.child ? "child" : "root"), agent.firstname, agent.lastname,
agent.AgentID, agent.circuitcode);
agent.AgentID, agent.circuitcode, teleportFlags);
reason = String.Empty;
if (!AuthenticateUser(agent, out reason))

View File

@ -286,7 +286,7 @@ namespace OpenSim.Region.Framework.Scenes
string reason = String.Empty;
bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason);
if (regionAccepted && newAgent)
{
@ -810,7 +810,7 @@ namespace OpenSim.Region.Framework.Scenes
// Let's create an agent there if one doesn't exist yet.
//if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, out reason))
if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
{
avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
reason));

View File

@ -124,6 +124,7 @@ namespace OpenSim.Region.Framework.Scenes
private Vector3? m_forceToApply;
private uint m_requestedSitTargetID;
private UUID m_requestedSitTargetUUID;
public bool SitGround = false;
private SendCourseLocationsMethod m_sendCourseLocationsMethod;
@ -169,7 +170,7 @@ namespace OpenSim.Region.Framework.Scenes
protected RegionInfo m_regionInfo;
protected ulong crossingFromRegion;
private readonly Vector3[] Dir_Vectors = new Vector3[6];
private readonly Vector3[] Dir_Vectors = new Vector3[9];
// Position of agent's camera in world (region cordinates)
protected Vector3 m_CameraCenter;
@ -233,6 +234,8 @@ namespace OpenSim.Region.Framework.Scenes
DIR_CONTROL_FLAG_RIGHT = AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG,
DIR_CONTROL_FLAG_UP = AgentManager.ControlFlags.AGENT_CONTROL_UP_POS,
DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS,
DIR_CONTROL_FLAG_BACKWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
}
@ -717,19 +720,23 @@ namespace OpenSim.Region.Framework.Scenes
Dir_Vectors[3] = -Vector3.UnitY; //RIGHT
Dir_Vectors[4] = Vector3.UnitZ; //UP
Dir_Vectors[5] = -Vector3.UnitZ; //DOWN
Dir_Vectors[5] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
Dir_Vectors[6] = Vector3.UnitX*2; //FORWARD
Dir_Vectors[7] = -Vector3.UnitX; //BACK
}
private Vector3[] GetWalkDirectionVectors()
{
Vector3[] vector = new Vector3[6];
Vector3[] vector = new Vector3[9];
vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD
vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK
vector[2] = Vector3.UnitY; //LEFT
vector[3] = -Vector3.UnitY; //RIGHT
vector[4] = new Vector3(m_CameraAtAxis.Z, 0f, m_CameraUpAxis.Z); //UP
vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN
vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
vector[6] = (new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z) * 2); //FORWARD Nudge
vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK Nudge
return vector;
}
@ -1248,7 +1255,9 @@ namespace OpenSim.Region.Framework.Scenes
// TODO: This doesn't prevent the user from walking yet.
// Setting parent ID would fix this, if we knew what value
// to use. Or we could add a m_isSitting variable.
Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
//Animator.TrySetMovementAnimation("SIT_GROUND_CONSTRAINED");
SitGround = true;
}
// In the future, these values might need to go global.
@ -1306,6 +1315,9 @@ namespace OpenSim.Region.Framework.Scenes
else
dirVectors = Dir_Vectors;
// The fact that m_movementflag is a byte needs to be fixed
// it really should be a uint
uint nudgehack = 250;
foreach (Dir_ControlFlags DCF in DIR_CONTROL_FLAGS)
{
if (((uint)flags & (uint)DCF) != 0)
@ -1315,24 +1327,40 @@ namespace OpenSim.Region.Framework.Scenes
try
{
agent_control_v3 += dirVectors[i];
//m_log.DebugFormat("[Motion]: {0}, {1}",i, dirVectors[i]);
}
catch (IndexOutOfRangeException)
{
// Why did I get this?
}
if ((m_movementflag & (uint)DCF) == 0)
if ((m_movementflag & (byte)(uint)DCF) == 0)
{
if (DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
{
m_movementflag |= (byte)nudgehack;
}
m_movementflag += (byte)(uint)DCF;
update_movementflag = true;
}
}
else
{
if ((m_movementflag & (uint)DCF) != 0)
if ((m_movementflag & (byte)(uint)DCF) != 0 ||
((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
&& ((m_movementflag & (byte)nudgehack) == nudgehack))
) // This or is for Nudge forward
{
m_movementflag -= (byte)(uint)DCF;
m_movementflag -= ((byte)(uint)DCF);
update_movementflag = true;
/*
if ((DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_FORWARD_NUDGE || DCF == Dir_ControlFlags.DIR_CONTROL_FLAG_BACKWARD_NUDGE)
&& ((m_movementflag & (byte)nudgehack) == nudgehack))
{
m_log.Debug("Removed Hack flag");
}
*/
}
else
{
@ -1470,7 +1498,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
if (update_movementflag)
if (update_movementflag && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) == 0) && (m_parentID == 0) && !SitGround)
Animator.UpdateMovementAnimations();
m_scene.EventManager.TriggerOnClientMovement(this);
@ -1582,8 +1610,12 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public void StandUp()
{
if (SitGround)
SitGround = false;
if (m_parentID != 0)
{
m_log.Debug("StandupCode Executed");
SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
if (part != null)
{

View File

@ -117,7 +117,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
agent.child = true;
string reason;
scene.NewUserConnection(agent, out reason);
scene.NewUserConnection(agent, (uint)TeleportFlags.ViaLogin, out reason);
testclient = new TestClient(agent, scene);
scene.AddNewClient(testclient);
@ -153,7 +153,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
if (acd1 == null)
fixNullPresence();
scene.NewUserConnection(acd1, out reason);
scene.NewUserConnection(acd1, 0, out reason);
if (testclient == null)
testclient = new TestClient(acd1, scene);
scene.AddNewClient(testclient);
@ -242,7 +242,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// Adding child agent to region 1001
string reason;
scene2.NewUserConnection(acd1, out reason);
scene2.NewUserConnection(acd1,0, out reason);
scene2.AddNewClient(testclient);
ScenePresence presence = scene.GetScenePresence(agent1);

View File

@ -88,7 +88,89 @@ namespace OpenSim.Region.RegionCombinerModule
public void RegionLoaded(Scene scene)
{
if (enabledYN)
{
RegionLoadedDoWork(scene);
scene.EventManager.OnNewPresence += NewPresence;
}
}
private void NewPresence(ScenePresence presence)
{
if (presence.IsChildAgent)
{
byte[] throttleData;
try
{
throttleData = presence.ControllingClient.GetThrottlesPacked(1);
}
catch (NotImplementedException)
{
return;
}
if (throttleData == null)
return;
if (throttleData.Length == 0)
return;
if (throttleData.Length != 28)
return;
byte[] adjData;
int pos = 0;
if (!BitConverter.IsLittleEndian)
{
byte[] newData = new byte[7 * 4];
Buffer.BlockCopy(throttleData, 0, newData, 0, 7 * 4);
for (int i = 0; i < 7; i++)
Array.Reverse(newData, i * 4, 4);
adjData = newData;
}
else
{
adjData = throttleData;
}
// 0.125f converts from bits to bytes
int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
// State is a subcategory of task that we allocate a percentage to
//int total = resend + land + wind + cloud + task + texture + asset;
byte[] data = new byte[7 * 4];
int ii = 0;
Buffer.BlockCopy(Utils.FloatToBytes(resend), 0, data, ii, 4); ii += 4;
Buffer.BlockCopy(Utils.FloatToBytes(land * 50), 0, data, ii, 4); ii += 4;
Buffer.BlockCopy(Utils.FloatToBytes(wind), 0, data, ii, 4); ii += 4;
Buffer.BlockCopy(Utils.FloatToBytes(cloud), 0, data, ii, 4); ii += 4;
Buffer.BlockCopy(Utils.FloatToBytes(task), 0, data, ii, 4); ii += 4;
Buffer.BlockCopy(Utils.FloatToBytes(texture), 0, data, ii, 4); ii += 4;
Buffer.BlockCopy(Utils.FloatToBytes(asset), 0, data, ii, 4);
try
{
presence.ControllingClient.SetChildAgentThrottle(data);
}
catch (NotImplementedException)
{
return;
}
}
}
private void RegionLoadedDoWork(Scene scene)

View File

@ -382,7 +382,7 @@ namespace OpenSim.Tests.Common.Setup
// We emulate the proper login sequence here by doing things in three stages
// Stage 1: simulate login by telling the scene to expect a new user connection
scene.NewUserConnection(agentData, out reason);
scene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason);
// Stage 2: add the new client as a child agent to the scene
TestClient client = new TestClient(agentData, scene);