Merge branch 'master' of ssh://opensimulator.org/var/git/opensim

user_profiles
Diva Canto 2013-03-07 06:41:03 -08:00
commit fdebee25db
26 changed files with 720 additions and 315 deletions

View File

@ -1912,6 +1912,12 @@ namespace OpenSim.Framework.Servers.HttpServer
m_rpcHandlers.Remove(method); m_rpcHandlers.Remove(method);
} }
public void RemoveJsonRPCHandler(string method)
{
lock(jsonRpcHandlers)
jsonRpcHandlers.Remove(method);
}
public bool RemoveLLSDHandler(string path, LLSDMethod handler) public bool RemoveLLSDHandler(string path, LLSDMethod handler)
{ {
lock (m_llsdHandlers) lock (m_llsdHandlers)

View File

@ -141,6 +141,8 @@ namespace OpenSim.Framework.Servers.HttpServer
void RemoveXmlRPCHandler(string method); void RemoveXmlRPCHandler(string method);
void RemoveJsonRPCHandler(string method);
string GetHTTP404(string host); string GetHTTP404(string host);
string GetHTTP500(); string GetHTTP500();

View File

@ -108,6 +108,7 @@ namespace OpenSim.Framework.Servers.HttpServer
private int _bufferLength; private int _bufferLength;
private bool _closing; private bool _closing;
private bool _upgraded; private bool _upgraded;
private int _maxPayloadBytes = 41943040;
private const string HandshakeAcceptText = private const string HandshakeAcceptText =
"HTTP/1.1 101 Switching Protocols\r\n" + "HTTP/1.1 101 Switching Protocols\r\n" +
@ -195,6 +196,15 @@ namespace OpenSim.Framework.Servers.HttpServer
HandshakeAndUpgrade(); HandshakeAndUpgrade();
} }
/// <summary>
/// Max Payload Size in bytes. Defaults to 40MB, but could be set upon connection before calling handshake and upgrade.
/// </summary>
public int MaxPayloadSize
{
get { return _maxPayloadBytes; }
set { _maxPayloadBytes = value; }
}
/// <summary> /// <summary>
/// This triggers the websocket start the upgrade process /// This triggers the websocket start the upgrade process
/// </summary> /// </summary>
@ -367,7 +377,12 @@ namespace OpenSim.Framework.Servers.HttpServer
if (headerread) if (headerread)
{ {
_socketState.FrameComplete = false; _socketState.FrameComplete = false;
if (pheader.PayloadLen > (ulong) _maxPayloadBytes)
{
Close("Invalid Payload size");
return;
}
if (pheader.PayloadLen > 0) if (pheader.PayloadLen > 0)
{ {
if ((int) pheader.PayloadLen > _bufferPosition - offset) if ((int) pheader.PayloadLen > _bufferPosition - offset)

View File

@ -57,7 +57,6 @@ namespace OpenSim.Region.ClientStack.Linden
public bool Enabled { get; private set; } public bool Enabled { get; private set; }
private Scene m_scene; private Scene m_scene;
private UUID m_agentID;
#region ISharedRegionModule Members #region ISharedRegionModule Members
@ -118,25 +117,26 @@ namespace OpenSim.Region.ClientStack.Linden
public void RegisterCaps(UUID agentID, Caps caps) public void RegisterCaps(UUID agentID, Caps caps)
{ {
IRequestHandler reqHandler IRequestHandler reqHandler
= new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), MeshUploadFlag, "MeshUploadFlag", agentID.ToString()); = new RestHTTPHandler(
"GET", "/CAPS/" + UUID.Random(), ht => MeshUploadFlag(ht, agentID), "MeshUploadFlag", agentID.ToString());
caps.RegisterHandler("MeshUploadFlag", reqHandler); caps.RegisterHandler("MeshUploadFlag", reqHandler);
m_agentID = agentID;
} }
private Hashtable MeshUploadFlag(Hashtable mDhttpMethod) private Hashtable MeshUploadFlag(Hashtable mDhttpMethod, UUID agentID)
{ {
// m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request"); // m_log.DebugFormat("[MESH UPLOAD FLAG MODULE]: MeshUploadFlag request");
OSDMap data = new OSDMap(); OSDMap data = new OSDMap();
ScenePresence sp = m_scene.GetScenePresence(m_agentID); ScenePresence sp = m_scene.GetScenePresence(agentID);
data["username"] = sp.Firstname + "." + sp.Lastname; data["username"] = sp.Firstname + "." + sp.Lastname;
data["display_name_next_update"] = new OSDDate(DateTime.Now); data["display_name_next_update"] = new OSDDate(DateTime.Now);
data["legacy_first_name"] = sp.Firstname; data["legacy_first_name"] = sp.Firstname;
data["mesh_upload_status"] = "valid"; data["mesh_upload_status"] = "valid";
data["display_name"] = sp.Firstname + " " + sp.Lastname; data["display_name"] = sp.Firstname + " " + sp.Lastname;
data["legacy_last_name"] = sp.Lastname; data["legacy_last_name"] = sp.Lastname;
data["id"] = m_agentID; data["id"] = agentID;
data["is_display_name_default"] = true; data["is_display_name_default"] = true;
//Send back data //Send back data

View File

@ -790,6 +790,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
handshake.RegionInfo3.ColoName = Utils.EmptyBytes; handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType); handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes; handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[0];
OutPacket(handshake, ThrottleOutPacketType.Task); OutPacket(handshake, ThrottleOutPacketType.Task);
} }
@ -3571,6 +3572,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
avp.Sender.IsTrial = false; avp.Sender.IsTrial = false;
avp.Sender.ID = agentID; avp.Sender.ID = agentID;
avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
//m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
OutPacket(avp, ThrottleOutPacketType.Task); OutPacket(avp, ThrottleOutPacketType.Task);
} }
@ -4192,7 +4194,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
pack.Stat = stats.StatsBlock; pack.Stat = stats.StatsBlock;
pack.Header.Reliable = false; pack.Header.Reliable = false;
pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0];
OutPacket(pack, ThrottleOutPacketType.Task); OutPacket(pack, ThrottleOutPacketType.Task);
} }

View File

@ -241,12 +241,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); // m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
List<SceneObjectGroup> attachments = sp.GetAttachments();
if (attachments.Count <= 0)
return;
Dictionary<SceneObjectGroup, string> scriptStates = new Dictionary<SceneObjectGroup, string>();
foreach (SceneObjectGroup so in attachments)
{
// Scripts MUST be snapshotted before the object is
// removed from the scene because doing otherwise will
// clobber the run flag
// This must be done outside the sp.AttachmentSyncLock so that there is no risk of a deadlock from
// scripts performing attachment operations at the same time. Getting object states stops the scripts.
scriptStates[so] = PrepareScriptInstanceForSave(so, false);
}
lock (sp.AttachmentsSyncLock) lock (sp.AttachmentsSyncLock)
{ {
foreach (SceneObjectGroup so in sp.GetAttachments()) foreach (SceneObjectGroup so in attachments)
{ UpdateDetachedObject(sp, so, scriptStates[so]);
UpdateDetachedObject(sp, so);
}
sp.ClearAttachments(); sp.ClearAttachments();
} }
@ -285,30 +300,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp)
{ {
lock (sp.AttachmentsSyncLock)
{
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
// group.Name, group.LocalId, sp.Name, attachmentPt, silent); // group.Name, group.LocalId, sp.Name, attachmentPt, silent);
if (group.GetSittingAvatarsCount() != 0) if (group.GetSittingAvatarsCount() != 0)
{ {
// m_log.WarnFormat( // m_log.WarnFormat(
// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it", // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it",
// group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount()); // group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount());
return false; return false;
} }
if (sp.GetAttachments(attachmentPt).Contains(group)) if (sp.GetAttachments(attachmentPt).Contains(group))
{ {
// m_log.WarnFormat( // m_log.WarnFormat(
// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
// group.Name, group.LocalId, sp.Name, AttachmentPt); // group.Name, group.LocalId, sp.Name, AttachmentPt);
return false; return false;
} }
// Remove any previous attachments
List<SceneObjectGroup> existingAttachments = sp.GetAttachments(attachmentPt);
// At the moment we can only deal with a single attachment
if (existingAttachments.Count != 0 && existingAttachments[0].FromItemID != UUID.Zero)
DetachSingleAttachmentToInv(sp, group);
lock (sp.AttachmentsSyncLock)
{
Vector3 attachPos = group.AbsolutePosition; Vector3 attachPos = group.AbsolutePosition;
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
@ -352,21 +374,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp) private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp)
{ {
// Remove any previous attachments
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
// At the moment we can only deal with a single attachment
if (attachments.Count != 0)
{
if (attachments[0].FromItemID != UUID.Zero)
DetachSingleAttachmentToInvInternal(sp, attachments[0]);
// Error logging commented because UUID.Zero now means temp attachment
// else
// m_log.WarnFormat(
// "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
// attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
}
// Add the new attachment to inventory if we don't already have it. // Add the new attachment to inventory if we don't already have it.
if (!temp) if (!temp)
{ {
@ -426,12 +433,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return; return;
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name); // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name);
lock (sp.AttachmentsSyncLock)
foreach (KeyValuePair<UUID, uint> rez in rezlist)
{ {
foreach (KeyValuePair<UUID, uint> rez in rezlist) RezSingleAttachmentFromInventory(sp, rez.Key, rez.Value);
{
RezSingleAttachmentFromInventory(sp, rez.Key, rez.Value);
}
} }
} }
@ -511,25 +516,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so) public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so)
{ {
if (so.AttachedAvatar != sp.UUID)
{
m_log.WarnFormat(
"[ATTACHMENTS MODULE]: Tried to detach object {0} from {1} {2} but attached avatar id was {3} in {4}",
so.Name, sp.Name, sp.UUID, so.AttachedAvatar, m_scene.RegionInfo.RegionName);
return;
}
// Scripts MUST be snapshotted before the object is
// removed from the scene because doing otherwise will
// clobber the run flag
// This must be done outside the sp.AttachmentSyncLock so that there is no risk of a deadlock from
// scripts performing attachment operations at the same time. Getting object states stops the scripts.
string scriptedState = PrepareScriptInstanceForSave(so, true);
lock (sp.AttachmentsSyncLock) lock (sp.AttachmentsSyncLock)
{ {
// Save avatar attachment information // Save avatar attachment information
// m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID); // m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID);
if (so.AttachedAvatar != sp.UUID)
{
m_log.WarnFormat(
"[ATTACHMENTS MODULE]: Tried to detach object {0} from {1} {2} but attached avatar id was {3} in {4}",
so.Name, sp.Name, sp.UUID, so.AttachedAvatar, m_scene.RegionInfo.RegionName);
return;
}
bool changed = sp.Appearance.DetachAttachment(so.FromItemID); bool changed = sp.Appearance.DetachAttachment(so.FromItemID);
if (changed && m_scene.AvatarFactory != null) if (changed && m_scene.AvatarFactory != null)
m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
DetachSingleAttachmentToInvInternal(sp, so); sp.RemoveAttachment(so);
UpdateDetachedObject(sp, so, scriptedState);
} }
} }
@ -739,8 +752,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
return newItem; return newItem;
} }
private string GetObjectScriptStates(SceneObjectGroup grp) /// <summary>
/// Prepares the script instance for save.
/// </summary>
/// <remarks>
/// This involves triggering the detach event and getting the script state (which also stops the script)
/// This MUST be done outside sp.AttachmentsSyncLock, since otherwise there is a chance of deadlock if a
/// running script is performing attachment operations.
/// </remarks>
/// <returns>
/// The script state ready for persistence.
/// </returns>
/// <param name='grp'>
/// </param>
/// <param name='fireDetachEvent'>
/// If true, then fire the script event before we save its state.
/// </param>
private string PrepareScriptInstanceForSave(SceneObjectGroup grp, bool fireDetachEvent)
{ {
if (fireDetachEvent)
m_scene.EventManager.TriggerOnAttach(grp.LocalId, grp.FromItemID, UUID.Zero);
using (StringWriter sw = new StringWriter()) using (StringWriter sw = new StringWriter())
{ {
using (XmlTextWriter writer = new XmlTextWriter(sw)) using (XmlTextWriter writer = new XmlTextWriter(sw))
@ -752,7 +784,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
} }
} }
private void UpdateDetachedObject(IScenePresence sp, SceneObjectGroup so) private void UpdateDetachedObject(IScenePresence sp, SceneObjectGroup so, string scriptedState)
{ {
// Don't save attachments for HG visitors, it // Don't save attachments for HG visitors, it
// messes up their inventory. When a HG visitor logs // messes up their inventory. When a HG visitor logs
@ -765,11 +797,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
&& (m_scene.UserManagementModule == null && (m_scene.UserManagementModule == null
|| m_scene.UserManagementModule.IsLocalGridUser(sp.UUID)); || m_scene.UserManagementModule.IsLocalGridUser(sp.UUID));
// Scripts MUST be snapshotted before the object is
// removed from the scene because doing otherwise will
// clobber the run flag
string scriptedState = GetObjectScriptStates(so);
// Remove the object from the scene so no more updates // Remove the object from the scene so no more updates
// are sent. Doing this before the below changes will ensure // are sent. Doing this before the below changes will ensure
// updates can't cause "HUD artefacts" // updates can't cause "HUD artefacts"
@ -793,91 +820,86 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
so.RemoveScriptInstances(true); so.RemoveScriptInstances(true);
} }
private void DetachSingleAttachmentToInvInternal(IScenePresence sp, SceneObjectGroup so)
{
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Detaching item {0} to inventory for {1}", itemID, sp.Name);
m_scene.EventManager.TriggerOnAttach(so.LocalId, so.FromItemID, UUID.Zero);
sp.RemoveAttachment(so);
UpdateDetachedObject(sp, so);
}
private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt) IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt)
{ {
if (m_invAccessModule == null) if (m_invAccessModule == null)
return null; return null;
SceneObjectGroup objatt;
if (itemID != UUID.Zero)
objatt = m_invAccessModule.RezObject(sp.ControllingClient,
itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, sp.UUID, true);
else
objatt = m_invAccessModule.RezObject(sp.ControllingClient,
null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, sp.UUID, true);
if (objatt == null)
{
m_log.WarnFormat(
"[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
itemID, sp.Name, attachmentPt);
return null;
}
// Remove any previous attachments
List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
// At the moment we can only deal with a single attachment
if (attachments.Count != 0)
DetachSingleAttachmentToInv(sp, attachments[0]);
lock (sp.AttachmentsSyncLock) lock (sp.AttachmentsSyncLock)
{ {
SceneObjectGroup objatt;
if (itemID != UUID.Zero)
objatt = m_invAccessModule.RezObject(sp.ControllingClient,
itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, sp.UUID, true);
else
objatt = m_invAccessModule.RezObject(sp.ControllingClient,
null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
false, false, sp.UUID, true);
if (objatt != null)
{
// m_log.DebugFormat( // m_log.DebugFormat(
// "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}", // "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}",
// objatt.Name, sp.Name, attachmentPt, m_scene.Name); // objatt.Name, sp.Name, attachmentPt, m_scene.Name);
// HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
objatt.HasGroupChanged = false; objatt.HasGroupChanged = false;
bool tainted = false; bool tainted = false;
if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
tainted = true; tainted = true;
// FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal // FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal
// course of events. If not, then it's probably not worth trying to recover the situation // course of events. If not, then it's probably not worth trying to recover the situation
// since this is more likely to trigger further exceptions and confuse later debugging. If // since this is more likely to trigger further exceptions and confuse later debugging. If
// exceptions can be thrown in expected error conditions (not NREs) then make this consistent // exceptions can be thrown in expected error conditions (not NREs) then make this consistent
// since other normal error conditions will simply return false instead. // since other normal error conditions will simply return false instead.
// This will throw if the attachment fails // This will throw if the attachment fails
try try
{
AttachObjectInternal(sp, objatt, attachmentPt, false, false);
}
catch (Exception e)
{
m_log.ErrorFormat(
"[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}",
objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace);
// Make sure the object doesn't stick around and bail
sp.RemoveAttachment(objatt);
m_scene.DeleteSceneObject(objatt, false);
return null;
}
if (tainted)
objatt.HasGroupChanged = true;
// Fire after attach, so we don't get messy perms dialogs
// 4 == AttachedRez
objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
objatt.ResumeScripts();
// Do this last so that event listeners have access to all the effects of the attachment
m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID);
return objatt;
}
else
{ {
m_log.WarnFormat( AttachObjectInternal(sp, objatt, attachmentPt, false, false);
"[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
itemID, sp.Name, attachmentPt);
} }
} catch (Exception e)
{
m_log.ErrorFormat(
"[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}",
objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace);
return null; // Make sure the object doesn't stick around and bail
sp.RemoveAttachment(objatt);
m_scene.DeleteSceneObject(objatt, false);
return null;
}
if (tainted)
objatt.HasGroupChanged = true;
// Fire after attach, so we don't get messy perms dialogs
// 4 == AttachedRez
objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
objatt.ResumeScripts();
// Do this last so that event listeners have access to all the effects of the attachment
m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID);
return objatt;
}
} }
/// <summary> /// <summary>
@ -1027,17 +1049,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
if (sp != null) if (sp != null)
{ {
lock (sp.AttachmentsSyncLock) List<SceneObjectGroup> attachments = sp.GetAttachments();
{
List<SceneObjectGroup> attachments = sp.GetAttachments();
foreach (SceneObjectGroup group in attachments) foreach (SceneObjectGroup group in attachments)
{
if (group.FromItemID == itemID && group.FromItemID != UUID.Zero)
{ {
if (group.FromItemID == itemID && group.FromItemID != UUID.Zero) DetachSingleAttachmentToInv(sp, group);
{ return;
DetachSingleAttachmentToInv(sp, group);
return;
}
} }
} }
} }

View File

@ -1206,6 +1206,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
// region doesn't take it // region doesn't take it
m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp);
m_log.WarnFormat(
"[ENTITY TRANSFER MODULE]: Region {0} would not accept update for agent {1} on cross attempt. Returning to original region.",
neighbourRegion.RegionName, agent.Name);
ReInstantiateScripts(agent); ReInstantiateScripts(agent);
agent.AddToPhysicalScene(isFlying); agent.AddToPhysicalScene(isFlying);
@ -1225,6 +1229,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
neighbourRegion.RegionHandle); neighbourRegion.RegionHandle);
return agent; return agent;
} }
// No turning back // No turning back
agent.IsChildAgent = true; agent.IsChildAgent = true;

View File

@ -414,8 +414,6 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring
} }
private void RegisterStatsManagerRegionStatistics() private void RegisterStatsManagerRegionStatistics()
{ {
string regionName = m_scene.RegionInfo.RegionName;
MakeStat("RootAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetRootAgentCount(); }); MakeStat("RootAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetRootAgentCount(); });
MakeStat("ChildAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetChildAgentCount(); }); MakeStat("ChildAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetChildAgentCount(); });
MakeStat("TotalPrims", "objects", (s) => { s.Value = m_scene.SceneGraph.GetTotalObjectsCount(); }); MakeStat("TotalPrims", "objects", (s) => { s.Value = m_scene.SceneGraph.GetTotalObjectsCount(); });

View File

@ -219,12 +219,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
{ {
// m_log.DebugFormat( // m_log.DebugFormat(
// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
// s.RegionInfo.RegionName, destination.RegionHandle); // destination.RegionName, destination.RegionID);
return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData); return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData);
} }
// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); // m_log.DebugFormat(
// "[LOCAL COMMS]: Did not find region {0} {1} for ChildAgentUpdate",
// destination.RegionName, destination.RegionID);
return false; return false;
} }
@ -239,7 +242,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
// note that we really don't need the GridRegion for this call // note that we really don't need the GridRegion for this call
foreach (Scene s in m_scenes.Values) foreach (Scene s in m_scenes.Values)
{ {
//m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); // m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate");
s.IncomingChildAgentDataUpdate(cAgentData); s.IncomingChildAgentDataUpdate(cAgentData);
} }

View File

@ -41,6 +41,16 @@ namespace OpenSim.Region.Framework.Interfaces
Value = 3 Value = 3
} }
public enum JsonStoreValueType
{
Undefined = 0,
Boolean = 1,
Integer = 2,
Float = 3,
String = 4,
UUID = 5
}
public delegate void TakeValueCallback(string s); public delegate void TakeValueCallback(string s);
public interface IJsonStoreModule public interface IJsonStoreModule
@ -49,7 +59,9 @@ namespace OpenSim.Region.Framework.Interfaces
bool CreateStore(string value, ref UUID result); bool CreateStore(string value, ref UUID result);
bool DestroyStore(UUID storeID); bool DestroyStore(UUID storeID);
JsonStoreNodeType GetPathType(UUID storeID, string path); JsonStoreNodeType GetNodeType(UUID storeID, string path);
JsonStoreValueType GetValueType(UUID storeID, string path);
bool TestStore(UUID storeID); bool TestStore(UUID storeID);
bool SetValue(UUID storeID, string path, string value, bool useJson); bool SetValue(UUID storeID, string path, string value, bool useJson);

View File

@ -1613,33 +1613,29 @@ namespace OpenSim.Region.Framework.Scenes
bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
//m_log.Debug("[CONTROL]: " +flags); //m_log.Debug("[CONTROL]: " +flags);
// Applies a satisfying roll effect to the avatar when flying. // Applies a satisfying roll effect to the avatar when flying.
if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0) && ((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)) if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) != 0 && (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
{ {
ApplyFlyingRoll(
ApplyFlyingRoll(FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); FLY_ROLL_RADIANS_PER_UPDATE,
(flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
(flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
} }
else if (((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0) && else if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) != 0 &&
((flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)) (flags & AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
{ {
ApplyFlyingRoll(-FLY_ROLL_RADIANS_PER_UPDATE, ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0), ((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0)); ApplyFlyingRoll(
-FLY_ROLL_RADIANS_PER_UPDATE,
(flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0,
(flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0);
} }
else else
{ {
if (m_AngularVelocity.Z != 0) if (m_AngularVelocity.Z != 0)
m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE); m_AngularVelocity.Z += CalculateFlyingRollResetToZero(FLY_ROLL_RESET_RADIANS_PER_UPDATE);
} }
if (Flying && IsColliding && controlland) if (Flying && IsColliding && controlland)
{ {
// nesting this check because LengthSquared() is expensive and we don't // nesting this check because LengthSquared() is expensive and we don't
@ -2400,7 +2396,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="vec">The vector in which to move. This is relative to the rotation argument</param> /// <param name="vec">The vector in which to move. This is relative to the rotation argument</param>
public void AddNewMovement(Vector3 vec) public void AddNewMovement(Vector3 vec)
{ {
// m_log.DebugFormat("[SCENE PRESENCE]: Adding new movement {0} for {1}", vec, Name); // m_log.DebugFormat(
// "[SCENE PRESENCE]: Adding new movement {0} with rotation {1} for {2}", vec, Rotation, Name);
Vector3 direc = vec * Rotation; Vector3 direc = vec * Rotation;
direc.Normalize(); direc.Normalize();
@ -2420,6 +2417,8 @@ namespace OpenSim.Region.Framework.Scenes
direc *= 0.03f * 128f * SpeedModifier; direc *= 0.03f * 128f * SpeedModifier;
// m_log.DebugFormat("[SCENE PRESENCE]: Force to apply before modification was {0} for {1}", direc, Name);
if (PhysicsActor != null) if (PhysicsActor != null)
{ {
if (Flying) if (Flying)
@ -2453,6 +2452,8 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
// m_log.DebugFormat("[SCENE PRESENCE]: Setting force to apply to {0} for {1}", direc, Name);
// TODO: Add the force instead of only setting it to support multiple forces per frame? // TODO: Add the force instead of only setting it to support multiple forces per frame?
m_forceToApply = direc; m_forceToApply = direc;
} }

View File

@ -288,109 +288,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
// ScenePresence presence = scene.GetScenePresence(agent1); // ScenePresence presence = scene.GetScenePresence(agent1);
// //
// Assert.That(presence, Is.Null, "presence is not null"); // Assert.That(presence, Is.Null, "presence is not null");
// }
// I'm commenting this test because it does not represent
// crossings. The Thread.Sleep's in here are not meaningful mocks,
// and they sometimes fail in panda.
// We need to talk in order to develop a test
// that really tests region crossings. There are 3 async components,
// but things are synchronous among them. So there should be
// 3 threads in here.
//[Test]
// public void T021_TestCrossToNewRegion()
// {
// TestHelpers.InMethod();
//
// scene.RegisterRegionWithGrid();
// scene2.RegisterRegionWithGrid();
//
// // Adding child agent to region 1001
// string reason;
// scene2.NewUserConnection(acd1,0, out reason);
// scene2.AddNewClient(testclient, PresenceType.User);
//
// ScenePresence presence = scene.GetScenePresence(agent1);
// presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true);
//
// ScenePresence presence2 = scene2.GetScenePresence(agent1);
//
// // Adding neighbour region caps info to presence2
//
// string cap = presence.ControllingClient.RequestClientInfo().CapsPath;
// presence2.AddNeighbourRegion(region1, cap);
//
// Assert.That(presence.IsChildAgent, Is.False, "Did not start root in origin region.");
// Assert.That(presence2.IsChildAgent, Is.True, "Is not a child on destination region.");
//
// // Cross to x+1
// presence.AbsolutePosition = new Vector3(Constants.RegionSize+1,3,100);
// presence.Update();
//
// EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
//
// // Mimicking communication between client and server, by waiting OK from client
// // sent by TestClient.CrossRegion call. Originally, this is network comm.
// if (!wh.WaitOne(5000,false))
// {
// presence.Update();
// if (!wh.WaitOne(8000,false))
// throw new ArgumentException("1 - Timeout waiting for signal/variable.");
// }
//
// // This is a TestClient specific method that fires OnCompleteMovementToRegion event, which
// // would normally be fired after receiving the reply packet from comm. done on the last line.
// testclient.CompleteMovement();
//
// // Crossings are asynchronous
// int timer = 10;
//
// // Make sure cross hasn't already finished
// if (!presence.IsInTransit && !presence.IsChildAgent)
// {
// // If not and not in transit yet, give it some more time
// Thread.Sleep(5000);
// }
//
// // Enough time, should at least be in transit by now.
// while (presence.IsInTransit && timer > 0)
// {
// Thread.Sleep(1000);
// timer-=1;
// }
//
// Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 2->1.");
// Assert.That(presence.IsChildAgent, Is.True, "Did not complete region cross as expected.");
// Assert.That(presence2.IsChildAgent, Is.False, "Did not receive root status after receiving agent.");
//
// // Cross Back
// presence2.AbsolutePosition = new Vector3(-10, 3, 100);
// presence2.Update();
//
// if (!wh.WaitOne(5000,false))
// {
// presence2.Update();
// if (!wh.WaitOne(8000,false))
// throw new ArgumentException("2 - Timeout waiting for signal/variable.");
// }
// testclient.CompleteMovement();
//
// if (!presence2.IsInTransit && !presence2.IsChildAgent)
// {
// // If not and not in transit yet, give it some more time
// Thread.Sleep(5000);
// }
//
// // Enough time, should at least be in transit by now.
// while (presence2.IsInTransit && timer > 0)
// {
// Thread.Sleep(1000);
// timer-=1;
// }
//
// Assert.That(timer,Is.GreaterThan(0),"Timed out waiting to cross 1->2.");
// Assert.That(presence2.IsChildAgent, Is.True, "Did not return from region as expected.");
// Assert.That(presence.IsChildAgent, Is.False, "Presence was not made root in old region again.");
// } // }
} }
} }

View File

@ -0,0 +1,157 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Reflection;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using OpenSim.Framework.Servers;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.CoreModules.Framework;
using OpenSim.Region.CoreModules.Framework.EntityTransfer;
using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.Framework.Scenes.Tests
{
[TestFixture]
public class ScenePresenceCrossingTests : OpenSimTestCase
{
[TestFixtureSetUp]
public void FixtureInit()
{
// Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest;
}
[TestFixtureTearDown]
public void TearDown()
{
// We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
// threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression
// tests really shouldn't).
Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
}
[Test]
public void TestCrossOnSameSimulator()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID userId = TestHelpers.ParseTail(0x1);
// TestEventQueueGetModule eqmA = new TestEventQueueGetModule();
EntityTransferModule etmA = new EntityTransferModule();
EntityTransferModule etmB = new EntityTransferModule();
LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
IConfigSource config = new IniConfigSource();
IConfig modulesConfig = config.AddConfig("Modules");
modulesConfig.Set("EntityTransferModule", etmA.Name);
modulesConfig.Set("SimulationServices", lscm.Name);
// IConfig entityTransferConfig = config.AddConfig("EntityTransfer");
// In order to run a single threaded regression test we do not want the entity transfer module waiting
// for a callback from the destination scene before removing its avatar data.
// entityTransferConfig.Set("wait_for_callback", false);
SceneHelpers sh = new SceneHelpers();
TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);
SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
// SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA);
SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);
ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
originalSp.AbsolutePosition = new Vector3(128, 32, 10);
// originalSp.Flying = true;
// Console.WriteLine("First pos {0}", originalSp.AbsolutePosition);
// eqmA.ClearEvents();
AgentUpdateArgs moveArgs = new AgentUpdateArgs();
//moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
sceneA.Update(1);
// Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);
// FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
// But really we want to do this in a more robust way.
for (int i = 0; i < 100; i++)
{
sceneA.Update(1);
// Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
}
// Need to sort processing of EnableSimulator message on adding scene presences before we can test eqm
// messages
// Dictionary<UUID, List<TestEventQueueGetModule.Event>> eqmEvents = eqmA.Events;
//
// Assert.That(eqmEvents.Count, Is.EqualTo(1));
// Assert.That(eqmEvents.ContainsKey(originalSp.UUID), Is.True);
//
// List<TestEventQueueGetModule.Event> spEqmEvents = eqmEvents[originalSp.UUID];
//
// Assert.That(spEqmEvents.Count, Is.EqualTo(1));
// Assert.That(spEqmEvents[0].Name, Is.EqualTo("CrossRegion"));
// sceneA should now only have a child agent
ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True);
ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);
// Agent remains a child until the client triggers complete movement
Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);
int agentMovementCompleteReceived = 0;
sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;
sceneBTc.CompleteMovement();
Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
}
}
}

View File

@ -145,7 +145,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
/// ///
/// </summary> /// </summary>
// ----------------------------------------------------------------- // -----------------------------------------------------------------
public JsonStoreNodeType PathType(string expr) public JsonStoreNodeType GetNodeType(string expr)
{ {
Stack<string> path; Stack<string> path;
if (! ParsePathExpression(expr,out path)) if (! ParsePathExpression(expr,out path))
@ -168,6 +168,43 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
return JsonStoreNodeType.Undefined; return JsonStoreNodeType.Undefined;
} }
// -----------------------------------------------------------------
/// <summary>
///
/// </summary>
// -----------------------------------------------------------------
public JsonStoreValueType GetValueType(string expr)
{
Stack<string> path;
if (! ParsePathExpression(expr,out path))
return JsonStoreValueType.Undefined;
OSD result = ProcessPathExpression(ValueStore,path);
if (result == null)
return JsonStoreValueType.Undefined;
if (result is OSDMap)
return JsonStoreValueType.Undefined;
if (result is OSDArray)
return JsonStoreValueType.Undefined;
if (result is OSDBoolean)
return JsonStoreValueType.Boolean;
if (result is OSDInteger)
return JsonStoreValueType.Integer;
if (result is OSDReal)
return JsonStoreValueType.Float;
if (result is OSDString)
return JsonStoreValueType.String;
return JsonStoreValueType.Undefined;
}
// ----------------------------------------------------------------- // -----------------------------------------------------------------
/// <summary> /// <summary>
/// ///

View File

@ -270,7 +270,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
/// ///
/// </summary> /// </summary>
// ----------------------------------------------------------------- // -----------------------------------------------------------------
public JsonStoreNodeType GetPathType(UUID storeID, string path) public JsonStoreNodeType GetNodeType(UUID storeID, string path)
{ {
if (! m_enabled) return JsonStoreNodeType.Undefined; if (! m_enabled) return JsonStoreNodeType.Undefined;
@ -287,7 +287,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
try try
{ {
lock (map) lock (map)
return map.PathType(path); return map.GetNodeType(path);
} }
catch (Exception e) catch (Exception e)
{ {
@ -297,6 +297,38 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
return JsonStoreNodeType.Undefined; return JsonStoreNodeType.Undefined;
} }
// -----------------------------------------------------------------
/// <summary>
///
/// </summary>
// -----------------------------------------------------------------
public JsonStoreValueType GetValueType(UUID storeID, string path)
{
if (! m_enabled) return JsonStoreValueType.Undefined;
JsonStore map = null;
lock (m_JsonValueStore)
{
if (! m_JsonValueStore.TryGetValue(storeID,out map))
{
m_log.InfoFormat("[JsonStore] Missing store {0}",storeID);
return JsonStoreValueType.Undefined;
}
}
try
{
lock (map)
return map.GetValueType(path);
}
catch (Exception e)
{
m_log.Error(string.Format("[JsonStore]: Path test failed for {0} in {1}", path, storeID), e);
}
return JsonStoreValueType.Undefined;
}
// ----------------------------------------------------------------- // -----------------------------------------------------------------
/// <summary> /// <summary>
/// ///

View File

@ -192,16 +192,32 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
#region ScriptConstantsInterface #region ScriptConstantsInterface
[ScriptConstant] [ScriptConstant]
public static readonly int JSON_TYPE_UNDEF = (int)JsonStoreNodeType.Undefined; public static readonly int JSON_NODETYPE_UNDEF = (int)JsonStoreNodeType.Undefined;
[ScriptConstant] [ScriptConstant]
public static readonly int JSON_TYPE_OBJECT = (int)JsonStoreNodeType.Object; public static readonly int JSON_NODETYPE_OBJECT = (int)JsonStoreNodeType.Object;
[ScriptConstant] [ScriptConstant]
public static readonly int JSON_TYPE_ARRAY = (int)JsonStoreNodeType.Array; public static readonly int JSON_NODETYPE_ARRAY = (int)JsonStoreNodeType.Array;
[ScriptConstant] [ScriptConstant]
public static readonly int JSON_TYPE_VALUE = (int)JsonStoreNodeType.Value; public static readonly int JSON_NODETYPE_VALUE = (int)JsonStoreNodeType.Value;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_UNDEF = (int)JsonStoreValueType.Undefined;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_BOOLEAN = (int)JsonStoreValueType.Boolean;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_INTEGER = (int)JsonStoreValueType.Integer;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_FLOAT = (int)JsonStoreValueType.Float;
[ScriptConstant]
public static readonly int JSON_VALUETYPE_STRING = (int)JsonStoreValueType.String;
#endregion #endregion
@ -310,9 +326,20 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
/// </summary> /// </summary>
// ----------------------------------------------------------------- // -----------------------------------------------------------------
[ScriptInvocation] [ScriptInvocation]
public int JsonGetPathType(UUID hostID, UUID scriptID, UUID storeID, string path) public int JsonGetNodeType(UUID hostID, UUID scriptID, UUID storeID, string path)
{ {
return (int)m_store.GetPathType(storeID,path); return (int)m_store.GetNodeType(storeID,path);
}
// -----------------------------------------------------------------
/// <summary>
///
/// </summary>
// -----------------------------------------------------------------
[ScriptInvocation]
public int JsonGetValueType(UUID hostID, UUID scriptID, UUID storeID, string path)
{
return (int)m_store.GetValueType(storeID,path);
} }
// ----------------------------------------------------------------- // -----------------------------------------------------------------

View File

@ -158,8 +158,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
Assert.That(dsrv, Is.EqualTo(1)); Assert.That(dsrv, Is.EqualTo(1));
int tprv = (int)InvokeOp("JsonGetPathType", storeId, "Hello"); int tprv = (int)InvokeOp("JsonGetNodeType", storeId, "Hello");
Assert.That(tprv, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); Assert.That(tprv, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
} }
[Test] [Test]
@ -277,8 +277,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
Assert.That(returnValue, Is.EqualTo(1)); Assert.That(returnValue, Is.EqualTo(1));
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello"); int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello"); string returnValue2 = (string)InvokeOp("JsonGetValue", storeId, "Hello");
Assert.That(returnValue2, Is.EqualTo("")); Assert.That(returnValue2, Is.EqualTo(""));
@ -291,8 +291,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
Assert.That(returnValue, Is.EqualTo(1)); Assert.That(returnValue, Is.EqualTo(1));
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello"); int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
string returnValue2 = (string)InvokeOp("JsonGetJson", storeId, "Hello"); string returnValue2 = (string)InvokeOp("JsonGetJson", storeId, "Hello");
Assert.That(returnValue2, Is.EqualTo("")); Assert.That(returnValue2, Is.EqualTo(""));
@ -306,11 +306,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello[0]"); int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello[0]");
Assert.That(returnValue, Is.EqualTo(1)); Assert.That(returnValue, Is.EqualTo(1));
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello[0]"); int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello[0]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_VALUE));
result = (int)InvokeOp("JsonGetPathType", storeId, "Hello[1]"); result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello[1]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]"); string stringReturnValue = (string)InvokeOp("JsonGetValue", storeId, "Hello[0]");
Assert.That(stringReturnValue, Is.EqualTo("value2")); Assert.That(stringReturnValue, Is.EqualTo("value2"));
@ -433,7 +433,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
} }
[Test] [Test]
public void TestJsonGetPathType() public void TestJsonGetNodeType()
{ {
TestHelpers.InMethod(); TestHelpers.InMethod();
// TestHelpers.EnableLogging(); // TestHelpers.EnableLogging();
@ -441,41 +441,41 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }"); UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }");
{ {
int result = (int)InvokeOp("JsonGetPathType", storeId, "."); int result = (int)InvokeOp("JsonGetNodeType", storeId, ".");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_OBJECT));
} }
{ {
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello"); int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_OBJECT)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_OBJECT));
} }
{ {
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World"); int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello.World");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_ARRAY)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_ARRAY));
} }
{ {
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[0]"); int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello.World[0]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_VALUE));
} }
{ {
int result = (int)InvokeOp("JsonGetPathType", storeId, "Hello.World[1]"); int result = (int)InvokeOp("JsonGetNodeType", storeId, "Hello.World[1]");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_VALUE)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_VALUE));
} }
// Test for non-existant path // Test for non-existant path
{ {
int result = (int)InvokeOp("JsonGetPathType", storeId, "foo"); int result = (int)InvokeOp("JsonGetNodeType", storeId, "foo");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
} }
// Test for non-existant store // Test for non-existant store
{ {
UUID fakeStoreId = TestHelpers.ParseTail(0x500); UUID fakeStoreId = TestHelpers.ParseTail(0x500);
int result = (int)InvokeOp("JsonGetPathType", fakeStoreId, "."); int result = (int)InvokeOp("JsonGetNodeType", fakeStoreId, ".");
Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_TYPE_UNDEF)); Assert.That(result, Is.EqualTo(JsonStoreScriptModule.JSON_NODETYPE_UNDEF));
} }
} }

View File

@ -102,6 +102,8 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
public override float Simulate(float timeStep) public override float Simulate(float timeStep)
{ {
// Console.WriteLine("Simulating");
float fps = 0; float fps = 0;
for (int i = 0; i < _actors.Count; ++i) for (int i = 0; i < _actors.Count; ++i)
{ {
@ -109,8 +111,11 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
Vector3 actorPosition = actor.Position; Vector3 actorPosition = actor.Position;
Vector3 actorVelocity = actor.Velocity; Vector3 actorVelocity = actor.Velocity;
actorPosition.X += actor.Velocity.X*timeStep; // Console.WriteLine(
actorPosition.Y += actor.Velocity.Y*timeStep; // "Processing actor {0}, starting pos {1}, starting vel {2}", i, actorPosition, actorVelocity);
actorPosition.X += actor.Velocity.X * timeStep;
actorPosition.Y += actor.Velocity.Y * timeStep;
if (actor.Position.Y < 0) if (actor.Position.Y < 0)
{ {

View File

@ -10920,7 +10920,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_List result = new LSL_List(); LSL_List result = new LSL_List();
if (obj != null && obj.OwnerID != m_host.OwnerID) if (obj != null && obj.OwnerID == m_host.OwnerID)
{ {
LSL_List remaining = GetPrimParams(obj, rules, ref result); LSL_List remaining = GetPrimParams(obj, rules, ref result);

View File

@ -266,6 +266,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
llist[i] = new LSL_Float((float)result[i]); llist[i] = new LSL_Float((float)result[i]);
} }
else if (result[i] is double)
{
llist[i] = new LSL_Float((double)result[i]);
}
else if (result[i] is UUID) else if (result[i] is UUID)
{ {
llist[i] = new LSL_Key(result[i].ToString()); llist[i] = new LSL_Key(result[i].ToString());

View File

@ -60,6 +60,8 @@ namespace OpenSim.Tests.Common.Mock
public List<ImagePacketPacket> SentImagePacketPackets { get; private set; } public List<ImagePacketPacket> SentImagePacketPackets { get; private set; }
public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; } public List<ImageNotInDatabasePacket> SentImageNotInDatabasePackets { get; private set; }
public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion;
// disable warning: public events, part of the public API // disable warning: public events, part of the public API
#pragma warning disable 67 #pragma warning disable 67
@ -566,6 +568,8 @@ namespace OpenSim.Tests.Common.Mock
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
{ {
if (OnReceivedMoveAgentIntoRegion != null)
OnReceivedMoveAgentIntoRegion(regInfo, pos, look);
} }
public virtual AgentCircuitData RequestClientInfo() public virtual AgentCircuitData RequestClientInfo()

View File

@ -0,0 +1,178 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Reflection;
using System.Threading;
using log4net;
using Nini.Config;
using Mono.Addins;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Tests.Common
{
public class TestEventQueueGetModule : IEventQueue, INonSharedRegionModule
{
public class Event
{
public string Name { get; set; }
public object[] Args { get; set; }
public Event(string name, object[] args)
{
name = Name;
args = Args;
}
}
public Dictionary<UUID, List<Event>> Events { get; set; }
public void Initialise(IConfigSource source) {}
public void Close() {}
public void AddRegion(Scene scene)
{
Events = new Dictionary<UUID, List<Event>>();
scene.RegisterModuleInterface<IEventQueue>(this);
}
public void RemoveRegion (Scene scene) {}
public void RegionLoaded (Scene scene) {}
public string Name { get { return "TestEventQueueGetModule"; } }
public Type ReplaceableInterface { get { return null; } }
private void AddEvent(UUID avatarID, string name, params object[] args)
{
Console.WriteLine("Adding event {0} for {1}", name, avatarID);
List<Event> avEvents;
if (!Events.ContainsKey(avatarID))
{
avEvents = new List<Event>();
Events[avatarID] = avEvents;
}
else
{
avEvents = Events[avatarID];
}
avEvents.Add(new Event(name, args));
}
public void ClearEvents()
{
if (Events != null)
Events.Clear();
}
public bool Enqueue(OSD o, UUID avatarID)
{
AddEvent(avatarID, "Enqueue", o);
return true;
}
public void DisableSimulator(ulong handle, UUID avatarID)
{
AddEvent(avatarID, "DisableSimulator", handle);
}
public void EnableSimulator (ulong handle, IPEndPoint endPoint, UUID avatarID)
{
AddEvent(avatarID, "EnableSimulator", handle);
}
public void EstablishAgentCommunication (UUID avatarID, IPEndPoint endPoint, string capsPath)
{
AddEvent(avatarID, "EstablishAgentCommunication", endPoint, capsPath);
}
public void TeleportFinishEvent (ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL, UUID agentID)
{
AddEvent(agentID, "TeleportFinishEvent", regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL);
}
public void CrossRegion (ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL, UUID avatarID, UUID sessionID)
{
AddEvent(avatarID, "CrossRegion", handle, pos, lookAt, newRegionExternalEndPoint, capsURL, sessionID);
}
public void ChatterboxInvitation(
UUID sessionID, string sessionName, UUID fromAgent, string message, UUID toAgent, string fromName,
byte dialog, uint timeStamp, bool offline, int parentEstateID, Vector3 position, uint ttl,
UUID transactionID, bool fromGroup, byte[] binaryBucket)
{
AddEvent(
toAgent, "ChatterboxInvitation", sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog,
timeStamp, offline, parentEstateID, position, ttl, transactionID, fromGroup, binaryBucket);
}
public void ChatterBoxSessionAgentListUpdates (UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, bool isModerator, bool textMute)
{
AddEvent(toAgent, "ChatterBoxSessionAgentListUpdates", sessionID, fromAgent, canVoiceChat, isModerator, textMute);
}
public void ParcelProperties (OpenMetaverse.Messages.Linden.ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID)
{
AddEvent(avatarID, "ParcelProperties", parcelPropertiesMessage);
}
public void GroupMembership (OpenMetaverse.Packets.AgentGroupDataUpdatePacket groupUpdate, UUID avatarID)
{
AddEvent(avatarID, "GroupMembership", groupUpdate);
}
public OSD ScriptRunningEvent (UUID objectID, UUID itemID, bool running, bool mono)
{
Console.WriteLine("ONE");
throw new System.NotImplementedException ();
}
public OSD BuildEvent (string eventName, OSD eventBody)
{
Console.WriteLine("TWO");
throw new System.NotImplementedException ();
}
public void partPhysicsProperties (uint localID, byte physhapetype, float density, float friction, float bounce, float gravmod, UUID avatarID)
{
AddEvent(avatarID, "partPhysicsProperties", localID, physhapetype, density, friction, bounce, gravmod);
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2833,6 +2833,7 @@
<Reference name="Nini" path="../../../bin/"/> <Reference name="Nini" path="../../../bin/"/>
<Reference name="nunit.framework" path="../../../bin/"/> <Reference name="nunit.framework" path="../../../bin/"/>
<Reference name="OpenMetaverse" path="../../../bin/"/> <Reference name="OpenMetaverse" path="../../../bin/"/>
<Reference name="OpenMetaverse.StructuredData" path="../../../bin/"/>
<Reference name="OpenMetaverseTypes" path="../../../bin/"/> <Reference name="OpenMetaverseTypes" path="../../../bin/"/>
<Reference name="OpenSim.Data"/> <Reference name="OpenSim.Data"/>
<Reference name="OpenSim.Data.Null"/> <Reference name="OpenSim.Data.Null"/>