mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 03:45:35 +08:00
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.
This commit is contained in:
@@ -2011,22 +2011,27 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
/// </returns>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Handle a scene object that is crossing into this region from another.
|
||||
/// NOTE: Unused as of 2009-02-09. Soon to be deleted.
|
||||
/// </summary>
|
||||
/// <param name="regionHandle"></param>
|
||||
/// <param name="primID"></param>
|
||||
@@ -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 AddSceneObject(primID, sceneObject);
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -309,6 +309,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public string GetStateSnapshot()
|
||||
{
|
||||
Console.WriteLine(" >>> GetStateSnapshot <<<");
|
||||
|
||||
List<string> assemblies = new List<string>();
|
||||
Dictionary<UUID, string> states = new Dictionary<UUID, string>();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
/// </summary>
|
||||
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 "<ExtraFromAssetID>" + GetFromAssetID().ToString() + "</ExtraFromAssetID>";
|
||||
}
|
||||
|
||||
public virtual void ExtraFromXmlString(string xmlstr)
|
||||
{
|
||||
string id = xmlstr.Substring(xmlstr.IndexOf("<ExtraFromAssetID>"));
|
||||
id = xmlstr.Replace("<ExtraFromAssetID>", "");
|
||||
id = id.Replace("</ExtraFromAssetID>", "");
|
||||
|
||||
UUID uuid = UUID.Zero;
|
||||
UUID.TryParse(id, out uuid);
|
||||
|
||||
SetFromAssetID(uuid);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user