aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authordiva2009-02-09 22:27:27 +0000
committerdiva2009-02-09 22:27:27 +0000
commit2c685bff1493451849580cfb6bf44b88322bf0a4 (patch)
tree4179700c2b1fcbcc7a5ab07f7bc65b3bf97a79d9 /OpenSim/Region/Framework/Scenes
parentThank you kindly, TLaukkan (Timmil) for a patch that: (diff)
downloadopensim-SC-2c685bff1493451849580cfb6bf44b88322bf0a4.zip
opensim-SC-2c685bff1493451849580cfb6bf44b88322bf0a4.tar.gz
opensim-SC-2c685bff1493451849580cfb6bf44b88322bf0a4.tar.bz2
opensim-SC-2c685bff1493451849580cfb6bf44b88322bf0a4.tar.xz
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.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs232
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs83
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs29
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs2
5 files changed, 245 insertions, 102 deletions
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
2011 /// </returns> 2011 /// </returns>
2012 public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent) 2012 public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent)
2013 { 2013 {
2014 //Console.WriteLine(" >>> CrossPrimGroupIntoNewRegion <<<");
2015
2014 bool successYN = false; 2016 bool successYN = false;
2015 grp.RootPart.UpdateFlag = 0; 2017 grp.RootPart.UpdateFlag = 0;
2016 int primcrossingXMLmethod = 0; 2018 //int primcrossingXMLmethod = 0;
2017 2019
2018 if (newRegionHandle != 0) 2020 if (newRegionHandle != 0)
2019 { 2021 {
2020 string objectState = grp.GetStateSnapshot(); 2022 //string objectState = grp.GetStateSnapshot();
2021 2023
2022 successYN 2024 //successYN
2023 = m_sceneGridService.PrimCrossToNeighboringRegion( 2025 // = m_sceneGridService.PrimCrossToNeighboringRegion(
2024 newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod); 2026 // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod);
2025 if (successYN && (objectState != "") && m_allowScriptCrossings) 2027 //if (successYN && (objectState != "") && m_allowScriptCrossings)
2026 { 2028 //{
2027 successYN = m_sceneGridService.PrimCrossToNeighboringRegion( 2029 // successYN = m_sceneGridService.PrimCrossToNeighboringRegion(
2028 newRegionHandle, grp.UUID, objectState, 100); 2030 // newRegionHandle, grp.UUID, objectState, 100);
2029 } 2031 //}
2032
2033 // And the new channel...
2034 successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp);
2030 2035
2031 if (successYN) 2036 if (successYN)
2032 { 2037 {
@@ -2065,6 +2070,7 @@ namespace OpenSim.Region.Framework.Scenes
2065 2070
2066 /// <summary> 2071 /// <summary>
2067 /// Handle a scene object that is crossing into this region from another. 2072 /// Handle a scene object that is crossing into this region from another.
2073 /// NOTE: Unused as of 2009-02-09. Soon to be deleted.
2068 /// </summary> 2074 /// </summary>
2069 /// <param name="regionHandle"></param> 2075 /// <param name="regionHandle"></param>
2070 /// <param name="primID"></param> 2076 /// <param name="primID"></param>
@@ -2079,98 +2085,13 @@ namespace OpenSim.Region.Framework.Scenes
2079 m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID); 2085 m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID);
2080 SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData); 2086 SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData);
2081 2087
2082 // If the user is banned, we won't let any of their objects 2088 return AddSceneObject(primID, sceneObject);
2083 // enter. Period.
2084 //
2085 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID))
2086 {
2087 m_log.Info("[INTERREGION]: Denied prim crossing for "+
2088 "banned avatar");
2089
2090 return false;
2091 }
2092
2093 // Force allocation of new LocalId
2094 //
2095 foreach (SceneObjectPart p in sceneObject.Children.Values)
2096 p.LocalId = 0;
2097
2098 if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim)
2099 {
2100 if (sceneObject.RootPart.Shape.State != 0)
2101 {
2102 // Fix up attachment Parent Local ID
2103 //
2104 ScenePresence sp = GetScenePresence(sceneObject.OwnerID);
2105
2106 uint parentLocalID = 0;
2107 if (sp != null)
2108 parentLocalID = sp.LocalId;
2109
2110 sceneObject.RootPart.IsAttachment = true;
2111 sceneObject.RootPart.SetParentLocalId(parentLocalID);
2112
2113 AddRestoredSceneObject(sceneObject, false, false);
2114 2089
2115 // Handle attachment special case
2116 //
2117 SceneObjectPart RootPrim = GetSceneObjectPart(primID);
2118
2119 if (RootPrim != null)
2120 {
2121 SceneObjectGroup grp = RootPrim.ParentGroup;
2122
2123 RootPrim.SetParentLocalId(parentLocalID);
2124
2125 if (grp != null)
2126 {
2127 m_log.DebugFormat("[ATTACHMENT]: Received "+
2128 "attachment {0}, inworld asset id {1}",
2129 grp.RootPart.LastOwnerID.ToString(),
2130 grp.UUID.ToString());
2131
2132 if (sp != null)
2133 {
2134 grp.SetFromAssetID(grp.RootPart.LastOwnerID);
2135 m_log.DebugFormat("[ATTACHMENT]: Attach "+
2136 "to avatar {0}",
2137 sp.UUID.ToString());
2138 AttachObject(sp.ControllingClient,
2139 grp.LocalId, (uint)0,
2140 grp.GroupRotation,
2141 grp.AbsolutePosition, false);
2142 grp.SendGroupFullUpdate();
2143 }
2144 else
2145 {
2146 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2147 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2148 }
2149 }
2150 }
2151 }
2152 else
2153 {
2154 AddRestoredSceneObject(sceneObject, true, false);
2155
2156 if (!Permissions.CanObjectEntry(sceneObject.UUID,
2157 true, sceneObject.AbsolutePosition))
2158 {
2159 // Deny non attachments based on parcel settings
2160 //
2161 m_log.Info("[INTERREGION]: Denied prim crossing "+
2162 "because of parcel settings");
2163
2164 DeleteSceneObject(sceneObject, false);
2165
2166 return false;
2167 }
2168 }
2169 }
2170 } 2090 }
2171 else if ((XMLMethod == 100) && m_allowScriptCrossings) 2091 else if ((XMLMethod == 100) && m_allowScriptCrossings)
2172 { 2092 {
2173 m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor"); 2093 m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor");
2094
2174 XmlDocument doc = new XmlDocument(); 2095 XmlDocument doc = new XmlDocument();
2175 doc.LoadXml(objXMLData); 2096 doc.LoadXml(objXMLData);
2176 2097
@@ -2244,6 +2165,123 @@ namespace OpenSim.Region.Framework.Scenes
2244 return true; 2165 return true;
2245 } 2166 }
2246 2167
2168 public bool IncomingCreateObject(ISceneObject sog)
2169 {
2170 //Console.WriteLine(" >>> IncomingCreateObject <<<");
2171 SceneObjectGroup newObject;
2172 try
2173 {
2174 newObject = (SceneObjectGroup)sog;
2175 }
2176 catch (Exception e)
2177 {
2178 m_log.WarnFormat("[SCENE]: Problem casting object: {0}", e.Message);
2179 return false;
2180 }
2181
2182 if (!AddSceneObject(newObject.UUID, newObject))
2183 {
2184 m_log.DebugFormat("[SCENE]: Problem adding scene object {0} in {1} ", sog.UUID, RegionInfo.RegionName);
2185 return false;
2186 }
2187 newObject.RootPart.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1);
2188 return true;
2189 }
2190
2191 public bool AddSceneObject(UUID primID, SceneObjectGroup sceneObject)
2192 {
2193 // If the user is banned, we won't let any of their objects
2194 // enter. Period.
2195 //
2196 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID))
2197 {
2198 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2199 "banned avatar");
2200
2201 return false;
2202 }
2203
2204 // Force allocation of new LocalId
2205 //
2206 foreach (SceneObjectPart p in sceneObject.Children.Values)
2207 p.LocalId = 0;
2208
2209 if (sceneObject.RootPart.Shape.PCode == (byte)PCode.Prim)
2210 {
2211 if (sceneObject.RootPart.Shape.State != 0)
2212 {
2213 // Fix up attachment Parent Local ID
2214 //
2215 ScenePresence sp = GetScenePresence(sceneObject.OwnerID);
2216
2217 uint parentLocalID = 0;
2218 if (sp != null)
2219 parentLocalID = sp.LocalId;
2220
2221 sceneObject.RootPart.IsAttachment = true;
2222 sceneObject.RootPart.SetParentLocalId(parentLocalID);
2223
2224 AddRestoredSceneObject(sceneObject, false, false);
2225
2226 // Handle attachment special case
2227 //
2228 SceneObjectPart RootPrim = GetSceneObjectPart(primID);
2229 //SceneObjectPart RootPrim = sceneObject.RootPart;
2230
2231 if (RootPrim != null)
2232 {
2233 SceneObjectGroup grp = RootPrim.ParentGroup;
2234
2235 RootPrim.SetParentLocalId(parentLocalID);
2236
2237 if (grp != null)
2238 {
2239 m_log.DebugFormat("[ATTACHMENT]: Received " +
2240 "attachment {0}, inworld asset id {1}",
2241 //grp.RootPart.LastOwnerID.ToString(),
2242 grp.GetFromAssetID(),
2243 grp.UUID.ToString());
2244
2245 if (sp != null)
2246 {
2247 //grp.SetFromAssetID(grp.RootPart.LastOwnerID);
2248 m_log.DebugFormat("[ATTACHMENT]: Attach " +
2249 "to avatar {0}",
2250 sp.UUID.ToString());
2251 AttachObject(sp.ControllingClient,
2252 grp.LocalId, (uint)0,
2253 grp.GroupRotation,
2254 grp.AbsolutePosition, false);
2255 grp.SendGroupFullUpdate();
2256 }
2257 else
2258 {
2259 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2260 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2261 }
2262 }
2263 }
2264 }
2265 else
2266 {
2267 AddRestoredSceneObject(sceneObject, true, false);
2268
2269 if (!Permissions.CanObjectEntry(sceneObject.UUID,
2270 true, sceneObject.AbsolutePosition))
2271 {
2272 // Deny non attachments based on parcel settings
2273 //
2274 m_log.Info("[INTERREGION]: Denied prim crossing " +
2275 "because of parcel settings");
2276
2277 DeleteSceneObject(sceneObject, false);
2278
2279 return false;
2280 }
2281 }
2282 }
2283 return true;
2284 }
2247 #endregion 2285 #endregion
2248 2286
2249 #region Add/Remove Avatar Methods 2287 #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
590 590
591 // Saves and gets assetID 591 // Saves and gets assetID
592 UUID itemId; 592 UUID itemId;
593
593 if (group.GetFromAssetID() == UUID.Zero) 594 if (group.GetFromAssetID() == UUID.Zero)
594 { 595 {
595 m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId); 596 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
309 309
310 public string GetStateSnapshot() 310 public string GetStateSnapshot()
311 { 311 {
312 Console.WriteLine(" >>> GetStateSnapshot <<<");
313
312 List<string> assemblies = new List<string>(); 314 List<string> assemblies = new List<string>();
313 Dictionary<UUID, string> states = new Dictionary<UUID, string>(); 315 Dictionary<UUID, string> states = new Dictionary<UUID, string>();
314 316
@@ -358,9 +360,16 @@ namespace OpenSim.Region.Framework.Scenes
358 360
359 Byte[] data = new Byte[fi.Length]; 361 Byte[] data = new Byte[fi.Length];
360 362
361 FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read); 363 try
362 fs.Read(data, 0, data.Length); 364 {
363 fs.Close(); 365 FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
366 fs.Read(data, 0, data.Length);
367 fs.Close();
368 }
369 catch (Exception e)
370 {
371 m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message);
372 }
364 373
365 XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", ""); 374 XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
366 XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", ""); 375 XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
@@ -397,5 +406,73 @@ namespace OpenSim.Region.Framework.Scenes
397 406
398 return xmldoc.InnerXml; 407 return xmldoc.InnerXml;
399 } 408 }
409
410 public void SetState(string objXMLData, UUID RegionID)
411 {
412
413 XmlDocument doc = new XmlDocument();
414 doc.LoadXml(objXMLData);
415
416 XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
417 if (rootL.Count == 1)
418 {
419 XmlNode rootNode = rootL[0];
420 if (rootNode != null)
421 {
422 XmlNodeList partL = rootNode.ChildNodes;
423
424 foreach (XmlNode part in partL)
425 {
426 XmlNodeList nodeL = part.ChildNodes;
427
428 switch (part.Name)
429 {
430 case "Assemblies":
431 foreach (XmlNode asm in nodeL)
432 {
433 string fn = asm.Attributes.GetNamedItem("Filename").Value;
434
435 Byte[] filedata = Convert.FromBase64String(asm.InnerText);
436 string path = Path.Combine("ScriptEngines", RegionID.ToString());
437 path = Path.Combine(path, fn);
438
439 if (!File.Exists(path))
440 {
441 FileStream fs = File.Create(path);
442 fs.Write(filedata, 0, filedata.Length);
443 fs.Close();
444 }
445 }
446 break;
447 case "ScriptStates":
448 foreach (XmlNode st in nodeL)
449 {
450 string id = st.Attributes.GetNamedItem("UUID").Value;
451 UUID uuid = new UUID(id);
452 XmlNode state = st.ChildNodes[0];
453
454 XmlDocument sdoc = new XmlDocument();
455 XmlNode sxmlnode = sdoc.CreateNode(
456 XmlNodeType.XmlDeclaration,
457 "", "");
458 sdoc.AppendChild(sxmlnode);
459
460 XmlNode newnode = sdoc.ImportNode(state, true);
461 sdoc.AppendChild(newnode);
462
463 string spath = Path.Combine("ScriptEngines", RegionID.ToString());
464 spath = Path.Combine(spath, uuid.ToString());
465 FileStream sfs = File.Create(spath + ".state");
466 System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
467 Byte[] buf = enc.GetBytes(sdoc.InnerXml);
468 sfs.Write(buf, 0, buf.Length);
469 sfs.Close();
470 }
471 break;
472 }
473 }
474 }
475 }
476 }
400 } 477 }
401} 478}
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;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Drawing; 30using System.Drawing;
31using System.IO; 31using System.IO;
32using System.Threading;
32using System.Xml; 33using System.Xml;
33using System.Xml.Serialization; 34using System.Xml.Serialization;
34using OpenMetaverse; 35using OpenMetaverse;
@@ -84,7 +85,7 @@ namespace OpenSim.Region.Framework.Scenes
84 /// A scene object group is conceptually an object in the scene. The object is constituted of SceneObjectParts 85 /// A scene object group is conceptually an object in the scene. The object is constituted of SceneObjectParts
85 /// (often known as prims), one of which is considered the root part. 86 /// (often known as prims), one of which is considered the root part.
86 /// </summary> 87 /// </summary>
87 public partial class SceneObjectGroup : EntityBase 88 public partial class SceneObjectGroup : EntityBase, ISceneObject
88 { 89 {
89 // private PrimCountTaintedDelegate handlerPrimCountTainted = null; 90 // private PrimCountTaintedDelegate handlerPrimCountTainted = null;
90 91
@@ -3030,5 +3031,31 @@ namespace OpenSim.Region.Framework.Scenes
3030 part.SetAttachmentPoint(point); 3031 part.SetAttachmentPoint(point);
3031 } 3032 }
3032 } 3033 }
3034
3035 #region ISceneObject
3036
3037 public virtual ISceneObject CloneForNewScene()
3038 {
3039 SceneObjectGroup sog = Copy(this.OwnerID, this.GroupID, false);
3040 return sog;
3041 }
3042
3043 public virtual string ExtraToXmlString()
3044 {
3045 return "<ExtraFromAssetID>" + GetFromAssetID().ToString() + "</ExtraFromAssetID>";
3046 }
3047
3048 public virtual void ExtraFromXmlString(string xmlstr)
3049 {
3050 string id = xmlstr.Substring(xmlstr.IndexOf("<ExtraFromAssetID>"));
3051 id = xmlstr.Replace("<ExtraFromAssetID>", "");
3052 id = id.Replace("</ExtraFromAssetID>", "");
3053
3054 UUID uuid = UUID.Zero;
3055 UUID.TryParse(id, out uuid);
3056
3057 SetFromAssetID(uuid);
3058 }
3059 #endregion
3033 } 3060 }
3034} 3061}
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
3036 gobj.RootPart.SetParentLocalId(0); 3036 gobj.RootPart.SetParentLocalId(0);
3037 gobj.RootPart.IsAttachment = false; 3037 gobj.RootPart.IsAttachment = false;
3038 gobj.AbsolutePosition = gobj.RootPart.AttachedPos; 3038 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
3039 gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); 3039 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
3040 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle); 3040 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
3041 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent); 3041 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
3042 } 3042 }