aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs12
-rw-r--r--OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs35
-rw-r--r--OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs244
-rw-r--r--OpenSim/Region/Framework/Interfaces/IInterregionComms.cs3
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISceneObject.cs16
-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
10 files changed, 546 insertions, 111 deletions
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
index a2453db..0f6b4c7 100644
--- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
+++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs
@@ -461,6 +461,16 @@ namespace OpenSim.Region.Communications.Hypergrid
461 regInfo = RequestNeighbourInfo(regionHandle); 461 regInfo = RequestNeighbourInfo(regionHandle);
462 if (regInfo != null) 462 if (regInfo != null)
463 { 463 {
464 try
465 {
466 regionHandle = Convert.ToUInt64(regInfo.regionSecret);
467 }
468 catch (Exception)
469 {
470 m_log.Warn("[HGrid]: Invalid hyperlink region.");
471 return false;
472 }
473
464 //don't want to be creating a new link to the remote instance every time like we are here 474 //don't want to be creating a new link to the remote instance every time like we are here
465 bool retValue = false; 475 bool retValue = false;
466 476
@@ -472,6 +482,7 @@ namespace OpenSim.Region.Communications.Hypergrid
472 482
473 if (remObject != null) 483 if (remObject != null)
474 { 484 {
485 m_log.Debug("[HGrid]: Inform region of prim crossing: " + regInfo.RemotingAddress + ":" + regInfo.RemotingPort);
475 retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.Guid, objData, XMLMethod); 486 retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.Guid, objData, XMLMethod);
476 } 487 }
477 else 488 else
@@ -810,6 +821,7 @@ namespace OpenSim.Region.Communications.Hypergrid
810 /// <returns></returns> 821 /// <returns></returns>
811 public bool IncomingPrim(ulong regionHandle, UUID primID, string objData, int XMLMethod) 822 public bool IncomingPrim(ulong regionHandle, UUID primID, string objData, int XMLMethod)
812 { 823 {
824 m_log.Debug("[HGrid]: Incoming Prim");
813 m_localBackend.TriggerExpectPrim(regionHandle, primID, objData, XMLMethod); 825 m_localBackend.TriggerExpectPrim(regionHandle, primID, objData, XMLMethod);
814 826
815 return true; 827 return true;
diff --git a/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs b/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs
index cb60d3f..33ccbf4 100644
--- a/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs
+++ b/OpenSim/Region/Environment/Modules/Communications/Local/LocalInterregionComms.cs
@@ -116,6 +116,10 @@ namespace OpenSim.Region.Environment.Modules.Communications.Local
116 116
117 #region IInterregionComms 117 #region IInterregionComms
118 118
119 /**
120 * Agent-related communications
121 */
122
119 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit) 123 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit)
120 { 124 {
121 foreach (Scene s in m_sceneList) 125 foreach (Scene s in m_sceneList)
@@ -204,6 +208,37 @@ namespace OpenSim.Region.Environment.Modules.Communications.Local
204 return false; 208 return false;
205 } 209 }
206 210
211 /**
212 * Object-related communications
213 */
214
215 public bool SendCreateObject(ulong regionHandle, ISceneObject sog)
216 {
217 foreach (Scene s in m_sceneList)
218 {
219 if (s.RegionInfo.RegionHandle == regionHandle)
220 {
221 //m_log.Debug("[LOCAL COMMS]: Found region to SendCreateObject");
222 return s.IncomingCreateObject(sog);
223 }
224 }
225 return false;
226 }
227
207 #endregion /* IInterregionComms */ 228 #endregion /* IInterregionComms */
229
230 #region Misc
231
232 public UUID GetRegionID(ulong regionhandle)
233 {
234 foreach (Scene s in m_sceneList)
235 {
236 if (s.RegionInfo.RegionHandle == regionhandle)
237 return s.RegionInfo.RegionID;
238 }
239 // ? weird. should not happen
240 return m_sceneList[0].RegionInfo.RegionID;
241 }
242 #endregion
208 } 243 }
209} 244}
diff --git a/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs b/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
index cfcd618..95b95ee 100644
--- a/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
+++ b/OpenSim/Region/Environment/Modules/Communications/REST/RESTInterregionComms.cs
@@ -123,12 +123,17 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
123 protected virtual void AddHTTPHandlers() 123 protected virtual void AddHTTPHandlers()
124 { 124 {
125 m_aScene.CommsManager.HttpServer.AddHTTPHandler("/agent/", AgentHandler); 125 m_aScene.CommsManager.HttpServer.AddHTTPHandler("/agent/", AgentHandler);
126 m_aScene.CommsManager.HttpServer.AddHTTPHandler("/object/", ObjectHandler);
126 } 127 }
127 128
128 #endregion /* IRegionModule */ 129 #endregion /* IRegionModule */
129 130
130 #region IInterregionComms 131 #region IInterregionComms
131 132
133 /**
134 * Agent-related communications
135 */
136
132 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit) 137 public bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit)
133 { 138 {
134 // Try local first 139 // Try local first
@@ -209,7 +214,32 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
209 //else 214 //else
210 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle); 215 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
211 return false; 216 return false;
212 } 217 }
218
219 /**
220 * Object-related communications
221 */
222
223 public bool SendCreateObject(ulong regionHandle, ISceneObject sog)
224 {
225 // Try local first
226 ISceneObject sogClone = sog.CloneForNewScene();
227 if (m_localBackend.SendCreateObject(regionHandle, sogClone))
228 {
229 //m_log.Debug("[REST COMMS]: LocalBackEnd SendCreateObject succeeded");
230 return true;
231 }
232
233 // else do the remote thing
234 RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
235 if (regInfo != null)
236 {
237 return DoCreateObjectCall(regInfo, sog);
238 }
239 //else
240 // m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
241 return false;
242 }
213 243
214 #endregion /* IInterregionComms */ 244 #endregion /* IInterregionComms */
215 245
@@ -454,10 +484,95 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
454 return true; 484 return true;
455 } 485 }
456 486
487 protected bool DoCreateObjectCall(RegionInfo region, ISceneObject sog)
488 {
489 ulong regionHandle = GetRegionHandle(region.RegionHandle);
490 string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/";
491 //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri);
492
493 WebRequest ObjectCreateRequest = WebRequest.Create(uri);
494 ObjectCreateRequest.Method = "POST";
495 ObjectCreateRequest.ContentType = "text/xml";
496 ObjectCreateRequest.Timeout = 10000;
497
498 OSDMap args = new OSDMap(2);
499 args["sog"] = OSD.FromString(sog.ToXmlString2());
500 args["extra"] = OSD.FromString(sog.ExtraToXmlString());
501 if (m_aScene.m_allowScriptCrossings)
502 {
503 string state = sog.GetStateSnapshot();
504 if (state.Length > 0)
505 args["state"] = OSD.FromString(state);
506 }
507
508 string strBuffer = "";
509 byte[] buffer = new byte[1];
510 try
511 {
512 strBuffer = OSDParser.SerializeJsonString(args);
513 System.Text.UTF8Encoding str = new System.Text.UTF8Encoding();
514 buffer = str.GetBytes(strBuffer);
515
516 }
517 catch (Exception e)
518 {
519 m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message);
520 // ignore. buffer will be empty, caller should check.
521 }
522
523 Stream os = null;
524 try
525 { // send the Post
526 ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send
527 os = ObjectCreateRequest.GetRequestStream();
528 os.Write(buffer, 0, strBuffer.Length); //Send it
529 os.Close();
530 m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri);
531 }
532 //catch (WebException ex)
533 catch
534 {
535 // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message);
536
537 return false;
538 }
539
540 // Let's wait for the response
541 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall");
542
543 try
544 {
545 WebResponse webResponse = ObjectCreateRequest.GetResponse();
546 if (webResponse == null)
547 {
548 m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post");
549 }
550
551 StreamReader sr = new StreamReader(webResponse.GetResponseStream());
552 //reply = sr.ReadToEnd().Trim();
553 sr.ReadToEnd().Trim();
554 sr.Close();
555 //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply);
556
557 }
558 catch (WebException ex)
559 {
560 m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message);
561 // ignore, really
562 }
563
564 return true;
565
566 }
567
457 #endregion /* Do Work */ 568 #endregion /* Do Work */
458 569
459 #region Incoming calls from remote instances 570 #region Incoming calls from remote instances
460 571
572 /**
573 * Agent-related incoming calls
574 */
575
461 public Hashtable AgentHandler(Hashtable request) 576 public Hashtable AgentHandler(Hashtable request)
462 { 577 {
463 //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called"); 578 //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called");
@@ -487,17 +602,17 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
487 string method = (string)request["http-method"]; 602 string method = (string)request["http-method"];
488 if (method.Equals("PUT")) 603 if (method.Equals("PUT"))
489 { 604 {
490 DoPut(request, responsedata); 605 DoAgentPut(request, responsedata);
491 return responsedata; 606 return responsedata;
492 } 607 }
493 else if (method.Equals("POST")) 608 else if (method.Equals("POST"))
494 { 609 {
495 DoPost(request, responsedata, agentID); 610 DoAgentPost(request, responsedata, agentID);
496 return responsedata; 611 return responsedata;
497 } 612 }
498 else if (method.Equals("DELETE")) 613 else if (method.Equals("DELETE"))
499 { 614 {
500 DoDelete(request, responsedata, agentID, action, regionHandle); 615 DoAgentDelete(request, responsedata, agentID, action, regionHandle);
501 616
502 return responsedata; 617 return responsedata;
503 } 618 }
@@ -534,12 +649,12 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
534 } 649 }
535 catch (Exception ex) 650 catch (Exception ex)
536 { 651 {
537 m_log.InfoFormat("[REST COMMS]: exception on parse of ChildAgentUpdate message {0}", ex.Message); 652 m_log.InfoFormat("[REST COMMS]: exception on parse of REST message {0}", ex.Message);
538 return null; 653 return null;
539 } 654 }
540 } 655 }
541 656
542 protected virtual void DoPost(Hashtable request, Hashtable responsedata, UUID id) 657 protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
543 { 658 {
544 OSDMap args = GetOSDMap(request); 659 OSDMap args = GetOSDMap(request);
545 if (args == null) 660 if (args == null)
@@ -573,7 +688,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
573 responsedata["str_response_string"] = result.ToString(); 688 responsedata["str_response_string"] = result.ToString();
574 } 689 }
575 690
576 protected virtual void DoPut(Hashtable request, Hashtable responsedata) 691 protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata)
577 { 692 {
578 OSDMap args = GetOSDMap(request); 693 OSDMap args = GetOSDMap(request);
579 if (args == null) 694 if (args == null)
@@ -639,7 +754,7 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
639 responsedata["str_response_string"] = result.ToString(); 754 responsedata["str_response_string"] = result.ToString();
640 } 755 }
641 756
642 protected virtual void DoDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle) 757 protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle)
643 { 758 {
644 //Console.WriteLine(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle); 759 //Console.WriteLine(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle);
645 760
@@ -651,7 +766,118 @@ namespace OpenSim.Region.Environment.Modules.Communications.REST
651 responsedata["int_response_code"] = 200; 766 responsedata["int_response_code"] = 200;
652 responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); 767 responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
653 } 768 }
654 769
770 /**
771 * Object-related incoming calls
772 */
773
774 public Hashtable ObjectHandler(Hashtable request)
775 {
776 //m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called");
777
778 //Console.WriteLine("---------------------------");
779 //Console.WriteLine(" >> uri=" + request["uri"]);
780 //Console.WriteLine(" >> content-type=" + request["content-type"]);
781 //Console.WriteLine(" >> http-method=" + request["http-method"]);
782 //Console.WriteLine("---------------------------\n");
783
784 Hashtable responsedata = new Hashtable();
785 responsedata["content_type"] = "text/html";
786
787 UUID objectID;
788 string action;
789 ulong regionHandle;
790 if (!GetParams((string)request["uri"], out objectID, out regionHandle, out action))
791 {
792 m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]);
793 responsedata["int_response_code"] = 404;
794 responsedata["str_response_string"] = "false";
795
796 return responsedata;
797 }
798
799 // Next, let's parse the verb
800 string method = (string)request["http-method"];
801 if (method.Equals("POST"))
802 {
803 DoObjectPost(request, responsedata, regionHandle);
804 return responsedata;
805 }
806 //else if (method.Equals("PUT"))
807 //{
808 // DoObjectPut(request, responsedata, agentID);
809 // return responsedata;
810 //}
811 //else if (method.Equals("DELETE"))
812 //{
813 // DoObjectDelete(request, responsedata, agentID, action, regionHandle);
814 // return responsedata;
815 //}
816 else
817 {
818 m_log.InfoFormat("[REST COMMS]: method {0} not supported in object message", method);
819 responsedata["int_response_code"] = 404;
820 responsedata["str_response_string"] = "false";
821
822 return responsedata;
823 }
824
825 }
826
827 protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle)
828 {
829 OSDMap args = GetOSDMap(request);
830 if (args == null)
831 {
832 responsedata["int_response_code"] = 400;
833 responsedata["str_response_string"] = "false";
834 return;
835 }
836
837 string sogXmlStr = "", extraStr = "", stateXmlStr = "";
838 if (args["sog"] != null)
839 sogXmlStr = args["sog"].AsString();
840 if (args["extra"] != null)
841 extraStr = args["extra"].AsString();
842
843 UUID regionID = m_localBackend.GetRegionID(regionhandle);
844 SceneObjectGroup sog = null;
845 try
846 {
847 sog = new SceneObjectGroup(sogXmlStr);
848 sog.ExtraFromXmlString(extraStr);
849 }
850 catch (Exception ex)
851 {
852 m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message);
853 responsedata["int_response_code"] = 400;
854 responsedata["str_response_string"] = "false";
855 return;
856 }
857
858 if ((args["state"] != null) && m_aScene.m_allowScriptCrossings)
859 {
860 stateXmlStr = args["state"].AsString();
861 if (stateXmlStr != "")
862 {
863 try
864 {
865 sog.SetState(stateXmlStr, regionID);
866 }
867 catch (Exception ex)
868 {
869 m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message);
870
871 }
872 }
873 }
874 // This is the meaning of POST object
875 bool result = m_localBackend.SendCreateObject(regionhandle, sog);
876
877 responsedata["int_response_code"] = 200;
878 responsedata["str_response_string"] = result.ToString();
879 }
880
655 #endregion 881 #endregion
656 882
657 #region Misc 883 #region Misc
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
70 /// <param name="id"></param> 70 /// <param name="id"></param>
71 /// <returns></returns> 71 /// <returns></returns>
72 bool SendCloseAgent(ulong regionHandle, UUID id); 72 bool SendCloseAgent(ulong regionHandle, UUID id);
73
74 bool SendCreateObject(ulong regionHandle, ISceneObject sog);
75
73 } 76 }
74 77
75 // This may not be needed, but having it here for now. 78 // 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 @@
1using System;
2using OpenMetaverse;
3
4namespace OpenSim.Region.Framework.Interfaces
5{
6 public interface ISceneObject
7 {
8 UUID UUID { get; }
9 ISceneObject CloneForNewScene();
10 string ToXmlString2();
11 string ExtraToXmlString();
12 void ExtraFromXmlString(string xmlstr);
13 string GetStateSnapshot();
14 void SetState(string xmlstr, UUID regionID);
15 }
16}
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 }