From 2c685bff1493451849580cfb6bf44b88322bf0a4 Mon Sep 17 00:00:00 2001
From: diva
Date: Mon, 9 Feb 2009 22:27:27 +0000
Subject: Moved prim crossing out of OGS1 and into RESTComms and
LocalInterregionComms. This breaks interregion comms with older versions in
what concerns prim crossing. In the process of moving the comms, a few things
seem to be working better, namely this may address mantis #3011, mantis
#1698. Hopefully, this doesn't break anything else. But I'm still seeing
weirdnesses with attchments jumping out of place after a cross/TP. The two
most notable changes in the crossing process were: * Object gets passed in
only one message, not two as done before. * Local object crossings do not get
serialized, as done before.
---
.../Framework/Interfaces/IInterregionComms.cs | 3 +
.../Region/Framework/Interfaces/ISceneObject.cs | 16 ++
OpenSim/Region/Framework/Scenes/Scene.cs | 232 ++++++++++++---------
OpenSim/Region/Framework/Scenes/SceneGraph.cs | 1 +
.../Framework/Scenes/SceneObjectGroup.Inventory.cs | 83 +++++++-
.../Region/Framework/Scenes/SceneObjectGroup.cs | 29 ++-
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +-
7 files changed, 264 insertions(+), 102 deletions(-)
create mode 100644 OpenSim/Region/Framework/Interfaces/ISceneObject.cs
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
index 783b3f9..bfa17fc 100644
--- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
+++ b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs
@@ -70,6 +70,9 @@ namespace OpenSim.Region.Framework.Interfaces
///
///
bool SendCloseAgent(ulong regionHandle, UUID id);
+
+ bool SendCreateObject(ulong regionHandle, ISceneObject sog);
+
}
// This may not be needed, but having it here for now.
diff --git a/OpenSim/Region/Framework/Interfaces/ISceneObject.cs b/OpenSim/Region/Framework/Interfaces/ISceneObject.cs
new file mode 100644
index 0000000..79a43d6
--- /dev/null
+++ b/OpenSim/Region/Framework/Interfaces/ISceneObject.cs
@@ -0,0 +1,16 @@
+using System;
+using OpenMetaverse;
+
+namespace OpenSim.Region.Framework.Interfaces
+{
+ public interface ISceneObject
+ {
+ UUID UUID { get; }
+ ISceneObject CloneForNewScene();
+ string ToXmlString2();
+ string ExtraToXmlString();
+ void ExtraFromXmlString(string xmlstr);
+ string GetStateSnapshot();
+ void SetState(string xmlstr, UUID regionID);
+ }
+}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 2fae8ac..b10acc7 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2011,22 +2011,27 @@ namespace OpenSim.Region.Framework.Scenes
///
public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent)
{
+ //Console.WriteLine(" >>> CrossPrimGroupIntoNewRegion <<<");
+
bool successYN = false;
grp.RootPart.UpdateFlag = 0;
- int primcrossingXMLmethod = 0;
+ //int primcrossingXMLmethod = 0;
if (newRegionHandle != 0)
{
- string objectState = grp.GetStateSnapshot();
+ //string objectState = grp.GetStateSnapshot();
- successYN
- = m_sceneGridService.PrimCrossToNeighboringRegion(
- newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod);
- if (successYN && (objectState != "") && m_allowScriptCrossings)
- {
- successYN = m_sceneGridService.PrimCrossToNeighboringRegion(
- newRegionHandle, grp.UUID, objectState, 100);
- }
+ //successYN
+ // = m_sceneGridService.PrimCrossToNeighboringRegion(
+ // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod);
+ //if (successYN && (objectState != "") && m_allowScriptCrossings)
+ //{
+ // successYN = m_sceneGridService.PrimCrossToNeighboringRegion(
+ // newRegionHandle, grp.UUID, objectState, 100);
+ //}
+
+ // And the new channel...
+ successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp);
if (successYN)
{
@@ -2065,6 +2070,7 @@ namespace OpenSim.Region.Framework.Scenes
///
/// Handle a scene object that is crossing into this region from another.
+ /// NOTE: Unused as of 2009-02-09. Soon to be deleted.
///
///
///
@@ -2079,98 +2085,13 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID);
SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData);
- // If the user is banned, we won't let any of their objects
- // enter. Period.
- //
- if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID))
- {
- m_log.Info("[INTERREGION]: Denied prim crossing for "+
- "banned avatar");
-
- return false;
- }
-
- // Force allocation of new LocalId
- //
- foreach (SceneObjectPart p in sceneObject.Children.Values)
- p.LocalId = 0;
-
- if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim)
- {
- if (sceneObject.RootPart.Shape.State != 0)
- {
- // Fix up attachment Parent Local ID
- //
- ScenePresence sp = GetScenePresence(sceneObject.OwnerID);
-
- uint parentLocalID = 0;
- if (sp != null)
- parentLocalID = sp.LocalId;
-
- sceneObject.RootPart.IsAttachment = true;
- sceneObject.RootPart.SetParentLocalId(parentLocalID);
-
- AddRestoredSceneObject(sceneObject, false, false);
+ return AddSceneObject(primID, sceneObject);
- // Handle attachment special case
- //
- SceneObjectPart RootPrim = GetSceneObjectPart(primID);
-
- if (RootPrim != null)
- {
- SceneObjectGroup grp = RootPrim.ParentGroup;
-
- RootPrim.SetParentLocalId(parentLocalID);
-
- if (grp != null)
- {
- m_log.DebugFormat("[ATTACHMENT]: Received "+
- "attachment {0}, inworld asset id {1}",
- grp.RootPart.LastOwnerID.ToString(),
- grp.UUID.ToString());
-
- if (sp != null)
- {
- grp.SetFromAssetID(grp.RootPart.LastOwnerID);
- m_log.DebugFormat("[ATTACHMENT]: Attach "+
- "to avatar {0}",
- sp.UUID.ToString());
- AttachObject(sp.ControllingClient,
- grp.LocalId, (uint)0,
- grp.GroupRotation,
- grp.AbsolutePosition, false);
- grp.SendGroupFullUpdate();
- }
- else
- {
- RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
- RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
- }
- }
- }
- }
- else
- {
- AddRestoredSceneObject(sceneObject, true, false);
-
- if (!Permissions.CanObjectEntry(sceneObject.UUID,
- true, sceneObject.AbsolutePosition))
- {
- // Deny non attachments based on parcel settings
- //
- m_log.Info("[INTERREGION]: Denied prim crossing "+
- "because of parcel settings");
-
- DeleteSceneObject(sceneObject, false);
-
- return false;
- }
- }
- }
}
else if ((XMLMethod == 100) && m_allowScriptCrossings)
{
m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor");
+
XmlDocument doc = new XmlDocument();
doc.LoadXml(objXMLData);
@@ -2244,6 +2165,123 @@ namespace OpenSim.Region.Framework.Scenes
return true;
}
+ public bool IncomingCreateObject(ISceneObject sog)
+ {
+ //Console.WriteLine(" >>> IncomingCreateObject <<<");
+ SceneObjectGroup newObject;
+ try
+ {
+ newObject = (SceneObjectGroup)sog;
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat("[SCENE]: Problem casting object: {0}", e.Message);
+ return false;
+ }
+
+ if (!AddSceneObject(newObject.UUID, newObject))
+ {
+ m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName);
+ return false;
+ }
+ newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1);
+ return true;
+ }
+
+ public bool AddSceneObject(UUID primID, SceneObjectGroup sceneObject)
+ {
+ // If the user is banned, we won't let any of their objects
+ // enter. Period.
+ //
+ if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID))
+ {
+ m_log.Info("[INTERREGION]: Denied prim crossing for " +
+ "banned avatar");
+
+ return false;
+ }
+
+ // Force allocation of new LocalId
+ //
+ foreach (SceneObjectPart p in sceneObject.Children.Values)
+ p.LocalId = 0;
+
+ if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim)
+ {
+ if (sceneObject.RootPart.Shape.State != 0)
+ {
+ // Fix up attachment Parent Local ID
+ //
+ ScenePresence sp = GetScenePresence(sceneObject.OwnerID);
+
+ uint parentLocalID = 0;
+ if (sp != null)
+ parentLocalID = sp.LocalId;
+
+ sceneObject.RootPart.IsAttachment = true;
+ sceneObject.RootPart.SetParentLocalId(parentLocalID);
+
+ AddRestoredSceneObject(sceneObject, false, false);
+
+ // Handle attachment special case
+ //
+ SceneObjectPart RootPrim = GetSceneObjectPart(primID);
+ //SceneObjectPart RootPrim = sceneObject.RootPart;
+
+ if (RootPrim != null)
+ {
+ SceneObjectGroup grp = RootPrim.ParentGroup;
+
+ RootPrim.SetParentLocalId(parentLocalID);
+
+ if (grp != null)
+ {
+ m_log.DebugFormat("[ATTACHMENT]: Received " +
+ "attachment {0}, inworld asset id {1}",
+ //grp.RootPart.LastOwnerID.ToString(),
+ grp.GetFromAssetID(),
+ grp.UUID.ToString());
+
+ if (sp != null)
+ {
+ //grp.SetFromAssetID(grp.RootPart.LastOwnerID);
+ m_log.DebugFormat("[ATTACHMENT]: Attach " +
+ "to avatar {0}",
+ sp.UUID.ToString());
+ AttachObject(sp.ControllingClient,
+ grp.LocalId, (uint)0,
+ grp.GroupRotation,
+ grp.AbsolutePosition, false);
+ grp.SendGroupFullUpdate();
+ }
+ else
+ {
+ RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
+ RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
+ }
+ }
+ }
+ }
+ else
+ {
+ AddRestoredSceneObject(sceneObject, true, false);
+
+ if (!Permissions.CanObjectEntry(sceneObject.UUID,
+ true, sceneObject.AbsolutePosition))
+ {
+ // Deny non attachments based on parcel settings
+ //
+ m_log.Info("[INTERREGION]: Denied prim crossing " +
+ "because of parcel settings");
+
+ DeleteSceneObject(sceneObject, false);
+
+ return false;
+ }
+ }
+ }
+ return true;
+ }
#endregion
#region Add/Remove Avatar Methods
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 2877dcd..2edfca8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -590,6 +590,7 @@ namespace OpenSim.Region.Framework.Scenes
// Saves and gets assetID
UUID itemId;
+
if (group.GetFromAssetID() == UUID.Zero)
{
m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 5fa6609..c3485ab 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -309,6 +309,8 @@ namespace OpenSim.Region.Framework.Scenes
public string GetStateSnapshot()
{
+ Console.WriteLine(" >>> GetStateSnapshot <<<");
+
List assemblies = new List();
Dictionary states = new Dictionary();
@@ -358,9 +360,16 @@ namespace OpenSim.Region.Framework.Scenes
Byte[] data = new Byte[fi.Length];
- FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
- fs.Read(data, 0, data.Length);
- fs.Close();
+ try
+ {
+ FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
+ fs.Read(data, 0, data.Length);
+ fs.Close();
+ }
+ catch (Exception e)
+ {
+ m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message);
+ }
XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
@@ -397,5 +406,73 @@ namespace OpenSim.Region.Framework.Scenes
return xmldoc.InnerXml;
}
+
+ public void SetState(string objXMLData, UUID RegionID)
+ {
+
+ XmlDocument doc = new XmlDocument();
+ doc.LoadXml(objXMLData);
+
+ XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
+ if (rootL.Count == 1)
+ {
+ XmlNode rootNode = rootL[0];
+ if (rootNode != null)
+ {
+ XmlNodeList partL = rootNode.ChildNodes;
+
+ foreach (XmlNode part in partL)
+ {
+ XmlNodeList nodeL = part.ChildNodes;
+
+ switch (part.Name)
+ {
+ case "Assemblies":
+ foreach (XmlNode asm in nodeL)
+ {
+ string fn = asm.Attributes.GetNamedItem("Filename").Value;
+
+ Byte[] filedata = Convert.FromBase64String(asm.InnerText);
+ string path = Path.Combine("ScriptEngines", RegionID.ToString());
+ path = Path.Combine(path, fn);
+
+ if (!File.Exists(path))
+ {
+ FileStream fs = File.Create(path);
+ fs.Write(filedata, 0, filedata.Length);
+ fs.Close();
+ }
+ }
+ break;
+ case "ScriptStates":
+ foreach (XmlNode st in nodeL)
+ {
+ string id = st.Attributes.GetNamedItem("UUID").Value;
+ UUID uuid = new UUID(id);
+ XmlNode state = st.ChildNodes[0];
+
+ XmlDocument sdoc = new XmlDocument();
+ XmlNode sxmlnode = sdoc.CreateNode(
+ XmlNodeType.XmlDeclaration,
+ "", "");
+ sdoc.AppendChild(sxmlnode);
+
+ XmlNode newnode = sdoc.ImportNode(state, true);
+ sdoc.AppendChild(newnode);
+
+ string spath = Path.Combine("ScriptEngines", RegionID.ToString());
+ spath = Path.Combine(spath, uuid.ToString());
+ FileStream sfs = File.Create(spath + ".state");
+ System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
+ Byte[] buf = enc.GetBytes(sdoc.InnerXml);
+ sfs.Write(buf, 0, buf.Length);
+ sfs.Close();
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
}
}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index d3b9626..e732b42 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -29,6 +29,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
+using System.Threading;
using System.Xml;
using System.Xml.Serialization;
using OpenMetaverse;
@@ -84,7 +85,7 @@ namespace OpenSim.Region.Framework.Scenes
/// A scene object group is conceptually an object in the scene. The object is constituted of SceneObjectParts
/// (often known as prims), one of which is considered the root part.
///
- public partial class SceneObjectGroup : EntityBase
+ public partial class SceneObjectGroup : EntityBase, ISceneObject
{
// private PrimCountTaintedDelegate handlerPrimCountTainted = null;
@@ -3030,5 +3031,31 @@ namespace OpenSim.Region.Framework.Scenes
part.SetAttachmentPoint(point);
}
}
+
+ #region ISceneObject
+
+ public virtual ISceneObject CloneForNewScene()
+ {
+ SceneObjectGroup sog = Copy(this.OwnerID, this.GroupID, false);
+ return sog;
+ }
+
+ public virtual string ExtraToXmlString()
+ {
+ return "" + GetFromAssetID().ToString() + "";
+ }
+
+ public virtual void ExtraFromXmlString(string xmlstr)
+ {
+ string id = xmlstr.Substring(xmlstr.IndexOf(""));
+ id = xmlstr.Replace("", "");
+ id = id.Replace("", "");
+
+ UUID uuid = UUID.Zero;
+ UUID.TryParse(id, out uuid);
+
+ SetFromAssetID(uuid);
+ }
+ #endregion
}
}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index e9f93a6..0ed35af 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3036,7 +3036,7 @@ namespace OpenSim.Region.Framework.Scenes
gobj.RootPart.SetParentLocalId(0);
gobj.RootPart.IsAttachment = false;
gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
- gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
+ //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
}
--
cgit v1.1