aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/IRegionLoader.cs82
-rw-r--r--OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs144
-rw-r--r--OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs196
-rw-r--r--OpenSim/Framework/Servers/BaseRequestHandler.cs68
-rw-r--r--OpenSim/Framework/Servers/RestDeserialiseHandler.cs74
-rw-r--r--OpenSim/Framework/Servers/RestObjectPoster.cs96
-rw-r--r--OpenSim/Region/Environment/Scenes/InnerScene.cs1310
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs424
8 files changed, 1197 insertions, 1197 deletions
diff --git a/OpenSim/Framework/IRegionLoader.cs b/OpenSim/Framework/IRegionLoader.cs
index 516a886..078a0f5 100644
--- a/OpenSim/Framework/IRegionLoader.cs
+++ b/OpenSim/Framework/IRegionLoader.cs
@@ -1,41 +1,41 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text; 31using System.Text;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using Nini.Config; 33using Nini.Config;
34namespace OpenSim.Framework 34namespace OpenSim.Framework
35{ 35{
36 public interface IRegionLoader 36 public interface IRegionLoader
37 { 37 {
38 void SetIniConfigSource(IniConfigSource configSource); 38 void SetIniConfigSource(IniConfigSource configSource);
39 RegionInfo[] LoadRegions(); 39 RegionInfo[] LoadRegions();
40 } 40 }
41} 41}
diff --git a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs
index 5ebcb64..7179a7f 100644
--- a/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs
+++ b/OpenSim/Framework/RegionLoader/Filesystem/RegionLoaderFileSystem.cs
@@ -1,72 +1,72 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Text;
31using Nini.Config; 31using Nini.Config;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using System.IO; 33using System.IO;
34 34
35namespace OpenSim.Framework.RegionLoader.Filesystem 35namespace OpenSim.Framework.RegionLoader.Filesystem
36{ 36{
37 public class RegionLoaderFileSystem : IRegionLoader 37 public class RegionLoaderFileSystem : IRegionLoader
38 { 38 {
39 public void SetIniConfigSource(IniConfigSource configSource) 39 public void SetIniConfigSource(IniConfigSource configSource)
40 { 40 {
41 } 41 }
42 public RegionInfo[] LoadRegions() 42 public RegionInfo[] LoadRegions()
43 { 43 {
44 string regionConfigPath = Path.Combine(Util.configDir(), "Regions"); 44 string regionConfigPath = Path.Combine(Util.configDir(), "Regions");
45 45
46 if (!Directory.Exists(regionConfigPath)) 46 if (!Directory.Exists(regionConfigPath))
47 { 47 {
48 Directory.CreateDirectory(regionConfigPath); 48 Directory.CreateDirectory(regionConfigPath);
49 } 49 }
50 50
51 string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); 51 string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
52 52
53 if (configFiles.Length == 0) 53 if (configFiles.Length == 0)
54 { 54 {
55 new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "default.xml")); 55 new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "default.xml"));
56 configFiles = Directory.GetFiles(regionConfigPath, "*.xml"); 56 configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
57 } 57 }
58 58
59 RegionInfo[] regionInfos = new RegionInfo[configFiles.Length]; 59 RegionInfo[] regionInfos = new RegionInfo[configFiles.Length];
60 for (int i = 0; i < configFiles.Length; i++) 60 for (int i = 0; i < configFiles.Length; i++)
61 { 61 {
62 62
63 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]); 63 RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), configFiles[i]);
64 regionInfos[i] = regionInfo; 64 regionInfos[i] = regionInfo;
65 } 65 }
66 66
67 67
68 return regionInfos; 68 return regionInfos;
69 } 69 }
70 70
71 } 71 }
72} 72}
diff --git a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
index 6a52a43..f7835e3 100644
--- a/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
+++ b/OpenSim/Framework/RegionLoader/Web/RegionLoaderWebServer.cs
@@ -1,98 +1,98 @@
1/* 1/*
2* Copyright (c) Contributors, http://opensimulator.org/ 2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders. 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4* 4*
5* Redistribution and use in source and binary forms, with or without 5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met: 6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright 7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer. 8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright 9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the 10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution. 11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the 12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products 13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission. 14* derived from this software without specific prior written permission.
15* 15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY 16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26* 26*
27*/ 27*/
28using System; 28using System;
29using System.Net; 29using System.Net;
30using System.IO; 30using System.IO;
31using System.Xml; 31using System.Xml;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using System.Text; 33using System.Text;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36 36
37namespace OpenSim.Framework.RegionLoader.Web 37namespace OpenSim.Framework.RegionLoader.Web
38{ 38{
39 public class RegionLoaderWebServer : IRegionLoader 39 public class RegionLoaderWebServer : IRegionLoader
40 { 40 {
41 private IniConfigSource m_configSouce; 41 private IniConfigSource m_configSouce;
42 public void SetIniConfigSource(IniConfigSource configSource) 42 public void SetIniConfigSource(IniConfigSource configSource)
43 { 43 {
44 m_configSouce = configSource; 44 m_configSouce = configSource;
45 } 45 }
46 public RegionInfo[] LoadRegions() 46 public RegionInfo[] LoadRegions()
47 { 47 {
48 if (m_configSouce == null) 48 if (m_configSouce == null)
49 { 49 {
50 Console.MainLog.Instance.Error("Unable to load configuration source! (WebServer Region Loader)"); 50 Console.MainLog.Instance.Error("Unable to load configuration source! (WebServer Region Loader)");
51 return null; 51 return null;
52 } 52 }
53 else 53 else
54 { 54 {
55 IniConfig startupConfig = (IniConfig)m_configSouce.Configs["Startup"]; 55 IniConfig startupConfig = (IniConfig)m_configSouce.Configs["Startup"];
56 string url = startupConfig.GetString("regionload_webserver_url","").Trim(); 56 string url = startupConfig.GetString("regionload_webserver_url","").Trim();
57 if (url == "") 57 if (url == "")
58 { 58 {
59 Console.MainLog.Instance.Error("Unable to load webserver URL - URL was empty (WebServer Region Loader"); 59 Console.MainLog.Instance.Error("Unable to load webserver URL - URL was empty (WebServer Region Loader");
60 return null; 60 return null;
61 } 61 }
62 else 62 else
63 { 63 {
64 64
65 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url); 65 HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
66 webRequest.Timeout = 30000; //30 Second Timeout 66 webRequest.Timeout = 30000; //30 Second Timeout
67 Console.MainLog.Instance.Debug("Sending Download Request..."); 67 Console.MainLog.Instance.Debug("Sending Download Request...");
68 HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse(); 68 HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
69 Console.MainLog.Instance.Debug("Downloading Region Information From Remote Server..."); 69 Console.MainLog.Instance.Debug("Downloading Region Information From Remote Server...");
70 StreamReader reader = new StreamReader(webResponse.GetResponseStream()); 70 StreamReader reader = new StreamReader(webResponse.GetResponseStream());
71 string xmlSource = ""; 71 string xmlSource = "";
72 string tempStr = reader.ReadLine(); 72 string tempStr = reader.ReadLine();
73 while (tempStr != null) 73 while (tempStr != null)
74 { 74 {
75 xmlSource = xmlSource + tempStr; 75 xmlSource = xmlSource + tempStr;
76 tempStr = reader.ReadLine(); 76 tempStr = reader.ReadLine();
77 } 77 }
78 Console.MainLog.Instance.Debug("Done downloading region information from server. Total Bytes: " + xmlSource.Length); 78 Console.MainLog.Instance.Debug("Done downloading region information from server. Total Bytes: " + xmlSource.Length);
79 XmlDocument xmlDoc = new XmlDocument(); 79 XmlDocument xmlDoc = new XmlDocument();
80 xmlDoc.LoadXml(xmlSource); 80 xmlDoc.LoadXml(xmlSource);
81 if (xmlDoc.FirstChild.Name == "Regions") 81 if (xmlDoc.FirstChild.Name == "Regions")
82 { 82 {
83 RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count]; 83 RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count];
84 int i; 84 int i;
85 for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++) 85 for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
86 { 86 {
87 Console.MainLog.Instance.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml); 87 Console.MainLog.Instance.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml);
88 regionInfos[i] = new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i]); 88 regionInfos[i] = new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i]);
89 } 89 }
90 90
91 return regionInfos; 91 return regionInfos;
92 } 92 }
93 return null; 93 return null;
94 } 94 }
95 } 95 }
96 } 96 }
97 } 97 }
98} 98}
diff --git a/OpenSim/Framework/Servers/BaseRequestHandler.cs b/OpenSim/Framework/Servers/BaseRequestHandler.cs
index b357763..155a283 100644
--- a/OpenSim/Framework/Servers/BaseRequestHandler.cs
+++ b/OpenSim/Framework/Servers/BaseRequestHandler.cs
@@ -1,35 +1,35 @@
1namespace OpenSim.Framework.Servers 1namespace OpenSim.Framework.Servers
2{ 2{
3 public class BaseRequestHandler 3 public class BaseRequestHandler
4 { 4 {
5 public virtual string ContentType 5 public virtual string ContentType
6 { 6 {
7 get { return "application/xml"; } 7 get { return "application/xml"; }
8 } 8 }
9 9
10 private readonly string m_httpMethod; 10 private readonly string m_httpMethod;
11 11
12 public virtual string HttpMethod 12 public virtual string HttpMethod
13 { 13 {
14 get { return m_httpMethod; } 14 get { return m_httpMethod; }
15 } 15 }
16 16
17 private readonly string m_path; 17 private readonly string m_path;
18 18
19 protected BaseRequestHandler(string httpMethod, string path) 19 protected BaseRequestHandler(string httpMethod, string path)
20 { 20 {
21 m_httpMethod = httpMethod; 21 m_httpMethod = httpMethod;
22 m_path = path; 22 m_path = path;
23 } 23 }
24 24
25 public virtual string Path 25 public virtual string Path
26 { 26 {
27 get { return m_path; } 27 get { return m_path; }
28 } 28 }
29 29
30 protected string GetParam(string path) 30 protected string GetParam(string path)
31 { 31 {
32 return path.Substring(m_path.Length); 32 return path.Substring(m_path.Length);
33 } 33 }
34 } 34 }
35} \ No newline at end of file 35} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/RestDeserialiseHandler.cs
index adf5c3f..a47d3d3 100644
--- a/OpenSim/Framework/Servers/RestDeserialiseHandler.cs
+++ b/OpenSim/Framework/Servers/RestDeserialiseHandler.cs
@@ -1,38 +1,38 @@
1using System.IO; 1using System.IO;
2using System.Xml; 2using System.Xml;
3using System.Xml.Serialization; 3using System.Xml.Serialization;
4 4
5namespace OpenSim.Framework.Servers 5namespace OpenSim.Framework.Servers
6{ 6{
7 public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request); 7 public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request);
8 8
9 public class RestDeserialisehandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler 9 public class RestDeserialisehandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler
10 where TRequest : new() 10 where TRequest : new()
11 { 11 {
12 private RestDeserialiseMethod<TRequest, TResponse> m_method; 12 private RestDeserialiseMethod<TRequest, TResponse> m_method;
13 13
14 public RestDeserialisehandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method) 14 public RestDeserialisehandler(string httpMethod, string path, RestDeserialiseMethod<TRequest, TResponse> method)
15 : base(httpMethod, path) 15 : base(httpMethod, path)
16 { 16 {
17 m_method = method; 17 m_method = method;
18 } 18 }
19 19
20 public void Handle(string path, Stream request, Stream responseStream) 20 public void Handle(string path, Stream request, Stream responseStream)
21 { 21 {
22 TRequest deserial; 22 TRequest deserial;
23 using (XmlTextReader xmlReader = new XmlTextReader(request)) 23 using (XmlTextReader xmlReader = new XmlTextReader(request))
24 { 24 {
25 XmlSerializer deserializer = new XmlSerializer(typeof (TRequest)); 25 XmlSerializer deserializer = new XmlSerializer(typeof (TRequest));
26 deserial = (TRequest) deserializer.Deserialize(xmlReader); 26 deserial = (TRequest) deserializer.Deserialize(xmlReader);
27 } 27 }
28 28
29 TResponse response = m_method(deserial); 29 TResponse response = m_method(deserial);
30 30
31 using (XmlWriter xmlWriter = XmlTextWriter.Create(responseStream)) 31 using (XmlWriter xmlWriter = XmlTextWriter.Create(responseStream))
32 { 32 {
33 XmlSerializer serializer = new XmlSerializer(typeof (TResponse)); 33 XmlSerializer serializer = new XmlSerializer(typeof (TResponse));
34 serializer.Serialize(xmlWriter, response); 34 serializer.Serialize(xmlWriter, response);
35 } 35 }
36 } 36 }
37 } 37 }
38} \ No newline at end of file 38} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/RestObjectPoster.cs b/OpenSim/Framework/Servers/RestObjectPoster.cs
index 77660a0..b77cbcc 100644
--- a/OpenSim/Framework/Servers/RestObjectPoster.cs
+++ b/OpenSim/Framework/Servers/RestObjectPoster.cs
@@ -1,49 +1,49 @@
1using System; 1using System;
2using System.IO; 2using System.IO;
3using System.Net; 3using System.Net;
4using System.Text; 4using System.Text;
5using System.Xml; 5using System.Xml;
6using System.Xml.Serialization; 6using System.Xml.Serialization;
7 7
8 8
9namespace OpenSim.Framework.Servers 9namespace OpenSim.Framework.Servers
10{ 10{
11 public class RestObjectPoster 11 public class RestObjectPoster
12 { 12 {
13 public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj) 13 public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
14 { 14 {
15 Type type = typeof(TRequest); 15 Type type = typeof(TRequest);
16 16
17 WebRequest request = WebRequest.Create(requestUrl); 17 WebRequest request = WebRequest.Create(requestUrl);
18 request.Method = "POST"; 18 request.Method = "POST";
19 request.ContentType = "text/xml"; 19 request.ContentType = "text/xml";
20 20
21 MemoryStream buffer = new MemoryStream(); 21 MemoryStream buffer = new MemoryStream();
22 22
23 XmlWriterSettings settings = new XmlWriterSettings(); 23 XmlWriterSettings settings = new XmlWriterSettings();
24 settings.Encoding = Encoding.UTF8; 24 settings.Encoding = Encoding.UTF8;
25 25
26 using (XmlWriter writer = XmlWriter.Create(buffer, settings)) 26 using (XmlWriter writer = XmlWriter.Create(buffer, settings))
27 { 27 {
28 XmlSerializer serializer = new XmlSerializer(type); 28 XmlSerializer serializer = new XmlSerializer(type);
29 serializer.Serialize(writer, obj); 29 serializer.Serialize(writer, obj);
30 writer.Flush(); 30 writer.Flush();
31 } 31 }
32 32
33 int length = (int)buffer.Length; 33 int length = (int)buffer.Length;
34 request.ContentLength = length; 34 request.ContentLength = length;
35 35
36 Stream requestStream = request.GetRequestStream(); 36 Stream requestStream = request.GetRequestStream();
37 requestStream.Write(buffer.ToArray(), 0, length); 37 requestStream.Write(buffer.ToArray(), 0, length);
38 IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); 38 IAsyncResult result = request.BeginGetResponse(AsyncCallback, request);
39 } 39 }
40 40
41 private static void AsyncCallback(IAsyncResult result) 41 private static void AsyncCallback(IAsyncResult result)
42 { 42 {
43 WebRequest request = (WebRequest)result.AsyncState; 43 WebRequest request = (WebRequest)result.AsyncState;
44 using (WebResponse resp = request.EndGetResponse(result)) 44 using (WebResponse resp = request.EndGetResponse(result))
45 { 45 {
46 } 46 }
47 } 47 }
48 } 48 }
49} \ No newline at end of file 49} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs
index 5d85c1d..3195991 100644
--- a/OpenSim/Region/Environment/Scenes/InnerScene.cs
+++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs
@@ -1,655 +1,655 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using libsecondlife; 4using libsecondlife;
5using libsecondlife.Packets; 5using libsecondlife.Packets;
6using OpenSim.Framework; 6using OpenSim.Framework;
7using OpenSim.Framework.Console; 7using OpenSim.Framework.Console;
8using OpenSim.Region.Environment.Types; 8using OpenSim.Region.Environment.Types;
9using OpenSim.Region.Physics.Manager; 9using OpenSim.Region.Physics.Manager;
10 10
11namespace OpenSim.Region.Environment.Scenes 11namespace OpenSim.Region.Environment.Scenes
12{ 12{
13 public class InnerScene 13 public class InnerScene
14 { 14 {
15 public Dictionary<LLUUID, ScenePresence> ScenePresences; 15 public Dictionary<LLUUID, ScenePresence> ScenePresences;
16 public Dictionary<LLUUID, SceneObjectGroup> SceneObjects; 16 public Dictionary<LLUUID, SceneObjectGroup> SceneObjects;
17 public Dictionary<LLUUID, EntityBase> Entities; 17 public Dictionary<LLUUID, EntityBase> Entities;
18 18
19 public BasicQuadTreeNode QuadTree; 19 public BasicQuadTreeNode QuadTree;
20 20
21 protected RegionInfo m_regInfo; 21 protected RegionInfo m_regInfo;
22 22
23 protected Scene m_parentScene; 23 protected Scene m_parentScene;
24 public PhysicsScene PhyScene; 24 public PhysicsScene PhyScene;
25 25
26 private PermissionManager PermissionsMngr; 26 private PermissionManager PermissionsMngr;
27 27
28 public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr) 28 public InnerScene(Scene parent, RegionInfo regInfo, PermissionManager permissionsMngr)
29 { 29 {
30 m_parentScene = parent; 30 m_parentScene = parent;
31 m_regInfo = regInfo; 31 m_regInfo = regInfo;
32 PermissionsMngr = permissionsMngr; 32 PermissionsMngr = permissionsMngr;
33 QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256); 33 QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256);
34 QuadTree.Subdivide(); 34 QuadTree.Subdivide();
35 QuadTree.Subdivide(); 35 QuadTree.Subdivide();
36 } 36 }
37 37
38 public void Close() 38 public void Close()
39 { 39 {
40 ScenePresences.Clear(); 40 ScenePresences.Clear();
41 SceneObjects.Clear(); 41 SceneObjects.Clear();
42 Entities.Clear(); 42 Entities.Clear();
43 } 43 }
44 44
45 public void AddEntityFromStorage(SceneObjectGroup sceneObject) 45 public void AddEntityFromStorage(SceneObjectGroup sceneObject)
46 { 46 {
47 sceneObject.RegionHandle = m_regInfo.RegionHandle; 47 sceneObject.RegionHandle = m_regInfo.RegionHandle;
48 sceneObject.SetScene(m_parentScene); 48 sceneObject.SetScene(m_parentScene);
49 foreach (SceneObjectPart part in sceneObject.Children.Values) 49 foreach (SceneObjectPart part in sceneObject.Children.Values)
50 { 50 {
51 part.LocalID = m_parentScene.PrimIDAllocate(); 51 part.LocalID = m_parentScene.PrimIDAllocate();
52 } 52 }
53 sceneObject.UpdateParentIDs(); 53 sceneObject.UpdateParentIDs();
54 AddEntity(sceneObject); 54 AddEntity(sceneObject);
55 } 55 }
56 56
57 public void AddEntity(SceneObjectGroup sceneObject) 57 public void AddEntity(SceneObjectGroup sceneObject)
58 { 58 {
59 if (!Entities.ContainsKey(sceneObject.UUID)) 59 if (!Entities.ContainsKey(sceneObject.UUID))
60 { 60 {
61 // QuadTree.AddObject(sceneObject); 61 // QuadTree.AddObject(sceneObject);
62 Entities.Add(sceneObject.UUID, sceneObject); 62 Entities.Add(sceneObject.UUID, sceneObject);
63 } 63 }
64 } 64 }
65 65
66 public void RemovePrim(uint localID, LLUUID avatar_deleter) 66 public void RemovePrim(uint localID, LLUUID avatar_deleter)
67 { 67 {
68 foreach (EntityBase obj in Entities.Values) 68 foreach (EntityBase obj in Entities.Values)
69 { 69 {
70 if (obj is SceneObjectGroup) 70 if (obj is SceneObjectGroup)
71 { 71 {
72 if (((SceneObjectGroup)obj).LocalId == localID) 72 if (((SceneObjectGroup)obj).LocalId == localID)
73 { 73 {
74 m_parentScene.RemoveEntity((SceneObjectGroup)obj); 74 m_parentScene.RemoveEntity((SceneObjectGroup)obj);
75 return; 75 return;
76 } 76 }
77 } 77 }
78 } 78 }
79 } 79 }
80 80
81 public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarWearable[] wearables, byte[] visualParams) 81 public ScenePresence CreateAndAddScenePresence(IClientAPI client, bool child, AvatarWearable[] wearables, byte[] visualParams)
82 { 82 {
83 ScenePresence newAvatar = null; 83 ScenePresence newAvatar = null;
84 84
85 newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, visualParams, wearables); 85 newAvatar = new ScenePresence(client, m_parentScene, m_regInfo, visualParams, wearables);
86 newAvatar.IsChildAgent = child; 86 newAvatar.IsChildAgent = child;
87 87
88 if (child) 88 if (child)
89 { 89 {
90 MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new child agent."); 90 MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new child agent.");
91 } 91 }
92 else 92 else
93 { 93 {
94 MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new root agent."); 94 MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Creating new root agent.");
95 MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Adding Physical agent."); 95 MainLog.Instance.Verbose("SCENE", m_regInfo.RegionName + ": Adding Physical agent.");
96 96
97 newAvatar.AddToPhysicalScene(); 97 newAvatar.AddToPhysicalScene();
98 } 98 }
99 99
100 lock (Entities) 100 lock (Entities)
101 { 101 {
102 if (!Entities.ContainsKey(client.AgentId)) 102 if (!Entities.ContainsKey(client.AgentId))
103 { 103 {
104 Entities.Add(client.AgentId, newAvatar); 104 Entities.Add(client.AgentId, newAvatar);
105 } 105 }
106 else 106 else
107 { 107 {
108 Entities[client.AgentId] = newAvatar; 108 Entities[client.AgentId] = newAvatar;
109 } 109 }
110 } 110 }
111 lock (ScenePresences) 111 lock (ScenePresences)
112 { 112 {
113 if (ScenePresences.ContainsKey(client.AgentId)) 113 if (ScenePresences.ContainsKey(client.AgentId))
114 { 114 {
115 ScenePresences[client.AgentId] = newAvatar; 115 ScenePresences[client.AgentId] = newAvatar;
116 } 116 }
117 else 117 else
118 { 118 {
119 ScenePresences.Add(client.AgentId, newAvatar); 119 ScenePresences.Add(client.AgentId, newAvatar);
120 } 120 }
121 } 121 }
122 122
123 return newAvatar; 123 return newAvatar;
124 } 124 }
125 125
126 /// <summary> 126 /// <summary>
127 /// Request a List of all m_scenePresences in this World 127 /// Request a List of all m_scenePresences in this World
128 /// </summary> 128 /// </summary>
129 /// <returns></returns> 129 /// <returns></returns>
130 public List<ScenePresence> GetScenePresences() 130 public List<ScenePresence> GetScenePresences()
131 { 131 {
132 List<ScenePresence> result = new List<ScenePresence>(ScenePresences.Values); 132 List<ScenePresence> result = new List<ScenePresence>(ScenePresences.Values);
133 133
134 return result; 134 return result;
135 } 135 }
136 136
137 public List<ScenePresence> GetAvatars() 137 public List<ScenePresence> GetAvatars()
138 { 138 {
139 List<ScenePresence> result = 139 List<ScenePresence> result =
140 GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; }); 140 GetScenePresences(delegate(ScenePresence scenePresence) { return !scenePresence.IsChildAgent; });
141 141
142 return result; 142 return result;
143 } 143 }
144 144
145 /// <summary> 145 /// <summary>
146 /// Request a filtered list of m_scenePresences in this World 146 /// Request a filtered list of m_scenePresences in this World
147 /// </summary> 147 /// </summary>
148 /// <returns></returns> 148 /// <returns></returns>
149 public List<ScenePresence> GetScenePresences(FilterAvatarList filter) 149 public List<ScenePresence> GetScenePresences(FilterAvatarList filter)
150 { 150 {
151 List<ScenePresence> result = new List<ScenePresence>(); 151 List<ScenePresence> result = new List<ScenePresence>();
152 152
153 foreach (ScenePresence avatar in ScenePresences.Values) 153 foreach (ScenePresence avatar in ScenePresences.Values)
154 { 154 {
155 if (filter(avatar)) 155 if (filter(avatar))
156 { 156 {
157 result.Add(avatar); 157 result.Add(avatar);
158 } 158 }
159 } 159 }
160 160
161 return result; 161 return result;
162 } 162 }
163 163
164 /// <summary> 164 /// <summary>
165 /// Request a Avatar by UUID 165 /// Request a Avatar by UUID
166 /// </summary> 166 /// </summary>
167 /// <param name="avatarID"></param> 167 /// <param name="avatarID"></param>
168 /// <returns></returns> 168 /// <returns></returns>
169 public ScenePresence GetScenePresence(LLUUID avatarID) 169 public ScenePresence GetScenePresence(LLUUID avatarID)
170 { 170 {
171 if (ScenePresences.ContainsKey(avatarID)) 171 if (ScenePresences.ContainsKey(avatarID))
172 { 172 {
173 return ScenePresences[avatarID]; 173 return ScenePresences[avatarID];
174 } 174 }
175 return null; 175 return null;
176 } 176 }
177 177
178 178
179 public LLUUID ConvertLocalIDToFullID(uint localID) 179 public LLUUID ConvertLocalIDToFullID(uint localID)
180 { 180 {
181 bool hasPrim = false; 181 bool hasPrim = false;
182 foreach (EntityBase ent in Entities.Values) 182 foreach (EntityBase ent in Entities.Values)
183 { 183 {
184 if (ent is SceneObjectGroup) 184 if (ent is SceneObjectGroup)
185 { 185 {
186 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 186 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
187 if (hasPrim != false) 187 if (hasPrim != false)
188 { 188 {
189 return ((SceneObjectGroup)ent).GetPartsFullID(localID); 189 return ((SceneObjectGroup)ent).GetPartsFullID(localID);
190 } 190 }
191 } 191 }
192 } 192 }
193 return LLUUID.Zero; 193 return LLUUID.Zero;
194 } 194 }
195 195
196 public void SendAllSceneObjectsToClient(ScenePresence presence) 196 public void SendAllSceneObjectsToClient(ScenePresence presence)
197 { 197 {
198 foreach (EntityBase ent in Entities.Values) 198 foreach (EntityBase ent in Entities.Values)
199 { 199 {
200 if (ent is SceneObjectGroup) 200 if (ent is SceneObjectGroup)
201 { 201 {
202 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence); 202 ((SceneObjectGroup)ent).ScheduleFullUpdateToAvatar(presence);
203 } 203 }
204 } 204 }
205 } 205 }
206 206
207 public SceneObjectPart GetSceneObjectPart(uint localID) 207 public SceneObjectPart GetSceneObjectPart(uint localID)
208 { 208 {
209 bool hasPrim = false; 209 bool hasPrim = false;
210 foreach (EntityBase ent in Entities.Values) 210 foreach (EntityBase ent in Entities.Values)
211 { 211 {
212 if (ent is SceneObjectGroup) 212 if (ent is SceneObjectGroup)
213 { 213 {
214 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 214 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
215 if (hasPrim != false) 215 if (hasPrim != false)
216 { 216 {
217 return ((SceneObjectGroup)ent).GetChildPart(localID); 217 return ((SceneObjectGroup)ent).GetChildPart(localID);
218 } 218 }
219 } 219 }
220 } 220 }
221 return null; 221 return null;
222 } 222 }
223 223
224 public SceneObjectPart GetSceneObjectPart(LLUUID fullID) 224 public SceneObjectPart GetSceneObjectPart(LLUUID fullID)
225 { 225 {
226 bool hasPrim = false; 226 bool hasPrim = false;
227 foreach (EntityBase ent in Entities.Values) 227 foreach (EntityBase ent in Entities.Values)
228 { 228 {
229 if (ent is SceneObjectGroup) 229 if (ent is SceneObjectGroup)
230 { 230 {
231 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID); 231 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(fullID);
232 if (hasPrim != false) 232 if (hasPrim != false)
233 { 233 {
234 return ((SceneObjectGroup)ent).GetChildPart(fullID); 234 return ((SceneObjectGroup)ent).GetChildPart(fullID);
235 } 235 }
236 } 236 }
237 } 237 }
238 return null; 238 return null;
239 } 239 }
240 240
241 internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar) 241 internal bool TryGetAvatar(LLUUID avatarId, out ScenePresence avatar)
242 { 242 {
243 ScenePresence presence; 243 ScenePresence presence;
244 if (ScenePresences.TryGetValue(avatarId, out presence)) 244 if (ScenePresences.TryGetValue(avatarId, out presence))
245 { 245 {
246 if (!presence.IsChildAgent) 246 if (!presence.IsChildAgent)
247 { 247 {
248 avatar = presence; 248 avatar = presence;
249 return true; 249 return true;
250 } 250 }
251 } 251 }
252 252
253 avatar = null; 253 avatar = null;
254 return false; 254 return false;
255 } 255 }
256 256
257 internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar) 257 internal bool TryGetAvatarByName(string avatarName, out ScenePresence avatar)
258 { 258 {
259 foreach (ScenePresence presence in ScenePresences.Values) 259 foreach (ScenePresence presence in ScenePresences.Values)
260 { 260 {
261 if (!presence.IsChildAgent) 261 if (!presence.IsChildAgent)
262 { 262 {
263 string name = presence.ControllingClient.FirstName + " " + presence.ControllingClient.LastName; 263 string name = presence.ControllingClient.FirstName + " " + presence.ControllingClient.LastName;
264 264
265 if (String.Compare(avatarName, name, true) == 0) 265 if (String.Compare(avatarName, name, true) == 0)
266 { 266 {
267 avatar = presence; 267 avatar = presence;
268 return true; 268 return true;
269 } 269 }
270 } 270 }
271 } 271 }
272 272
273 avatar = null; 273 avatar = null;
274 return false; 274 return false;
275 } 275 }
276 276
277 277
278 internal void ForEachClient(Action<IClientAPI> action) 278 internal void ForEachClient(Action<IClientAPI> action)
279 { 279 {
280 foreach (ScenePresence presence in ScenePresences.Values) 280 foreach (ScenePresence presence in ScenePresences.Values)
281 { 281 {
282 action(presence.ControllingClient); 282 action(presence.ControllingClient);
283 } 283 }
284 } 284 }
285 285
286 #region Client Event handlers 286 #region Client Event handlers
287 /// <summary> 287 /// <summary>
288 /// 288 ///
289 /// </summary> 289 /// </summary>
290 /// <param name="localID"></param> 290 /// <param name="localID"></param>
291 /// <param name="scale"></param> 291 /// <param name="scale"></param>
292 /// <param name="remoteClient"></param> 292 /// <param name="remoteClient"></param>
293 public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient) 293 public void UpdatePrimScale(uint localID, LLVector3 scale, IClientAPI remoteClient)
294 { 294 {
295 bool hasPrim = false; 295 bool hasPrim = false;
296 foreach (EntityBase ent in Entities.Values) 296 foreach (EntityBase ent in Entities.Values)
297 { 297 {
298 if (ent is SceneObjectGroup) 298 if (ent is SceneObjectGroup)
299 { 299 {
300 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 300 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
301 if (hasPrim != false) 301 if (hasPrim != false)
302 { 302 {
303 ((SceneObjectGroup)ent).Resize(scale, localID); 303 ((SceneObjectGroup)ent).Resize(scale, localID);
304 break; 304 break;
305 } 305 }
306 } 306 }
307 } 307 }
308 } 308 }
309 309
310 310
311 /// <summary> 311 /// <summary>
312 /// 312 ///
313 /// </summary> 313 /// </summary>
314 /// <param name="localID"></param> 314 /// <param name="localID"></param>
315 /// <param name="rot"></param> 315 /// <param name="rot"></param>
316 /// <param name="remoteClient"></param> 316 /// <param name="remoteClient"></param>
317 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) 317 public void UpdatePrimSingleRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
318 { 318 {
319 bool hasPrim = false; 319 bool hasPrim = false;
320 foreach (EntityBase ent in Entities.Values) 320 foreach (EntityBase ent in Entities.Values)
321 { 321 {
322 if (ent is SceneObjectGroup) 322 if (ent is SceneObjectGroup)
323 { 323 {
324 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 324 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
325 if (hasPrim != false) 325 if (hasPrim != false)
326 { 326 {
327 ((SceneObjectGroup)ent).UpdateSingleRotation(rot, localID); 327 ((SceneObjectGroup)ent).UpdateSingleRotation(rot, localID);
328 break; 328 break;
329 } 329 }
330 } 330 }
331 } 331 }
332 } 332 }
333 333
334 /// <summary> 334 /// <summary>
335 /// 335 ///
336 /// </summary> 336 /// </summary>
337 /// <param name="localID"></param> 337 /// <param name="localID"></param>
338 /// <param name="rot"></param> 338 /// <param name="rot"></param>
339 /// <param name="remoteClient"></param> 339 /// <param name="remoteClient"></param>
340 public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient) 340 public void UpdatePrimRotation(uint localID, LLQuaternion rot, IClientAPI remoteClient)
341 { 341 {
342 bool hasPrim = false; 342 bool hasPrim = false;
343 foreach (EntityBase ent in Entities.Values) 343 foreach (EntityBase ent in Entities.Values)
344 { 344 {
345 if (ent is SceneObjectGroup) 345 if (ent is SceneObjectGroup)
346 { 346 {
347 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 347 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
348 if (hasPrim != false) 348 if (hasPrim != false)
349 { 349 {
350 ((SceneObjectGroup)ent).UpdateGroupRotation(rot); 350 ((SceneObjectGroup)ent).UpdateGroupRotation(rot);
351 break; 351 break;
352 } 352 }
353 } 353 }
354 } 354 }
355 } 355 }
356 356
357 /// <summary> 357 /// <summary>
358 /// 358 ///
359 /// </summary> 359 /// </summary>
360 /// <param name="localID"></param> 360 /// <param name="localID"></param>
361 /// <param name="pos"></param> 361 /// <param name="pos"></param>
362 /// <param name="rot"></param> 362 /// <param name="rot"></param>
363 /// <param name="remoteClient"></param> 363 /// <param name="remoteClient"></param>
364 public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient) 364 public void UpdatePrimRotation(uint localID, LLVector3 pos, LLQuaternion rot, IClientAPI remoteClient)
365 { 365 {
366 bool hasPrim = false; 366 bool hasPrim = false;
367 foreach (EntityBase ent in Entities.Values) 367 foreach (EntityBase ent in Entities.Values)
368 { 368 {
369 if (ent is SceneObjectGroup) 369 if (ent is SceneObjectGroup)
370 { 370 {
371 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 371 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
372 if (hasPrim != false) 372 if (hasPrim != false)
373 { 373 {
374 ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot); 374 ((SceneObjectGroup)ent).UpdateGroupRotation(pos, rot);
375 break; 375 break;
376 } 376 }
377 } 377 }
378 } 378 }
379 } 379 }
380 380
381 public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient) 381 public void UpdatePrimSinglePosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
382 { 382 {
383 bool hasPrim = false; 383 bool hasPrim = false;
384 foreach (EntityBase ent in Entities.Values) 384 foreach (EntityBase ent in Entities.Values)
385 { 385 {
386 if (ent is SceneObjectGroup) 386 if (ent is SceneObjectGroup)
387 { 387 {
388 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 388 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
389 if (hasPrim != false) 389 if (hasPrim != false)
390 { 390 {
391 ((SceneObjectGroup)ent).UpdateSinglePosition(pos, localID); 391 ((SceneObjectGroup)ent).UpdateSinglePosition(pos, localID);
392 break; 392 break;
393 } 393 }
394 } 394 }
395 } 395 }
396 } 396 }
397 397
398 398
399 /// <summary> 399 /// <summary>
400 /// 400 ///
401 /// </summary> 401 /// </summary>
402 /// <param name="localID"></param> 402 /// <param name="localID"></param>
403 /// <param name="pos"></param> 403 /// <param name="pos"></param>
404 /// <param name="remoteClient"></param> 404 /// <param name="remoteClient"></param>
405 public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient) 405 public void UpdatePrimPosition(uint localID, LLVector3 pos, IClientAPI remoteClient)
406 { 406 {
407 bool hasPrim = false; 407 bool hasPrim = false;
408 foreach (EntityBase ent in Entities.Values) 408 foreach (EntityBase ent in Entities.Values)
409 { 409 {
410 if (ent is SceneObjectGroup) 410 if (ent is SceneObjectGroup)
411 { 411 {
412 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 412 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
413 if (hasPrim != false) 413 if (hasPrim != false)
414 { 414 {
415 ((SceneObjectGroup)ent).UpdateGroupPosition(pos); 415 ((SceneObjectGroup)ent).UpdateGroupPosition(pos);
416 break; 416 break;
417 } 417 }
418 } 418 }
419 } 419 }
420 } 420 }
421 421
422 /// <summary> 422 /// <summary>
423 /// 423 ///
424 /// </summary> 424 /// </summary>
425 /// <param name="localID"></param> 425 /// <param name="localID"></param>
426 /// <param name="texture"></param> 426 /// <param name="texture"></param>
427 /// <param name="remoteClient"></param> 427 /// <param name="remoteClient"></param>
428 public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) 428 public void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient)
429 { 429 {
430 bool hasPrim = false; 430 bool hasPrim = false;
431 foreach (EntityBase ent in Entities.Values) 431 foreach (EntityBase ent in Entities.Values)
432 { 432 {
433 if (ent is SceneObjectGroup) 433 if (ent is SceneObjectGroup)
434 { 434 {
435 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID); 435 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(localID);
436 if (hasPrim != false) 436 if (hasPrim != false)
437 { 437 {
438 ((SceneObjectGroup)ent).UpdateTextureEntry(localID, texture); 438 ((SceneObjectGroup)ent).UpdateTextureEntry(localID, texture);
439 break; 439 break;
440 } 440 }
441 } 441 }
442 } 442 }
443 } 443 }
444 444
445 /// <summary> 445 /// <summary>
446 /// 446 ///
447 /// </summary> 447 /// </summary>
448 /// <param name="localID"></param> 448 /// <param name="localID"></param>
449 /// <param name="packet"></param> 449 /// <param name="packet"></param>
450 /// <param name="remoteClient"></param> 450 /// <param name="remoteClient"></param>
451 public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient) 451 public void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient)
452 { 452 {
453 bool hasprim = false; 453 bool hasprim = false;
454 foreach (EntityBase ent in Entities.Values) 454 foreach (EntityBase ent in Entities.Values)
455 { 455 {
456 if (ent is SceneObjectGroup) 456 if (ent is SceneObjectGroup)
457 { 457 {
458 hasprim = ((SceneObjectGroup)ent).HasChildPrim(localID); 458 hasprim = ((SceneObjectGroup)ent).HasChildPrim(localID);
459 if (hasprim != false) 459 if (hasprim != false)
460 { 460 {
461 ((SceneObjectGroup)ent).UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes()); 461 ((SceneObjectGroup)ent).UpdatePrimFlags(localID, (ushort)packet.Type, true, packet.ToBytes());
462 } 462 }
463 } 463 }
464 } 464 }
465 465
466 //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString()); 466 //System.Console.WriteLine("Got primupdate packet: " + packet.UsePhysics.ToString());
467 } 467 }
468 468
469 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient) 469 public void MoveObject(LLUUID objectID, LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
470 { 470 {
471 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID)) 471 if (PermissionsMngr.CanEditObject(remoteClient.AgentId, objectID))
472 { 472 {
473 bool hasPrim = false; 473 bool hasPrim = false;
474 foreach (EntityBase ent in Entities.Values) 474 foreach (EntityBase ent in Entities.Values)
475 { 475 {
476 if (ent is SceneObjectGroup) 476 if (ent is SceneObjectGroup)
477 { 477 {
478 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID); 478 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(objectID);
479 if (hasPrim != false) 479 if (hasPrim != false)
480 { 480 {
481 ((SceneObjectGroup)ent).GrabMovement(offset, pos, remoteClient); 481 ((SceneObjectGroup)ent).GrabMovement(offset, pos, remoteClient);
482 break; 482 break;
483 } 483 }
484 } 484 }
485 } 485 }
486 } 486 }
487 } 487 }
488 488
489 /// <summary> 489 /// <summary>
490 /// 490 ///
491 /// </summary> 491 /// </summary>
492 /// <param name="primLocalID"></param> 492 /// <param name="primLocalID"></param>
493 /// <param name="description"></param> 493 /// <param name="description"></param>
494 public void PrimName(uint primLocalID, string name) 494 public void PrimName(uint primLocalID, string name)
495 { 495 {
496 bool hasPrim = false; 496 bool hasPrim = false;
497 foreach (EntityBase ent in Entities.Values) 497 foreach (EntityBase ent in Entities.Values)
498 { 498 {
499 if (ent is SceneObjectGroup) 499 if (ent is SceneObjectGroup)
500 { 500 {
501 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); 501 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
502 if (hasPrim != false) 502 if (hasPrim != false)
503 { 503 {
504 ((SceneObjectGroup)ent).SetPartName(name, primLocalID); 504 ((SceneObjectGroup)ent).SetPartName(name, primLocalID);
505 break; 505 break;
506 } 506 }
507 } 507 }
508 } 508 }
509 } 509 }
510 510
511 /// <summary> 511 /// <summary>
512 /// 512 ///
513 /// </summary> 513 /// </summary>
514 /// <param name="primLocalID"></param> 514 /// <param name="primLocalID"></param>
515 /// <param name="description"></param> 515 /// <param name="description"></param>
516 public void PrimDescription(uint primLocalID, string description) 516 public void PrimDescription(uint primLocalID, string description)
517 { 517 {
518 bool hasPrim = false; 518 bool hasPrim = false;
519 foreach (EntityBase ent in Entities.Values) 519 foreach (EntityBase ent in Entities.Values)
520 { 520 {
521 if (ent is SceneObjectGroup) 521 if (ent is SceneObjectGroup)
522 { 522 {
523 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); 523 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
524 if (hasPrim != false) 524 if (hasPrim != false)
525 { 525 {
526 ((SceneObjectGroup)ent).SetPartDescription(description, primLocalID); 526 ((SceneObjectGroup)ent).SetPartDescription(description, primLocalID);
527 break; 527 break;
528 } 528 }
529 } 529 }
530 } 530 }
531 } 531 }
532 532
533 public void UpdateExtraParam(uint primLocalID, ushort type, bool inUse, byte[] data) 533 public void UpdateExtraParam(uint primLocalID, ushort type, bool inUse, byte[] data)
534 { 534 {
535 bool hasPrim = false; 535 bool hasPrim = false;
536 foreach (EntityBase ent in Entities.Values) 536 foreach (EntityBase ent in Entities.Values)
537 { 537 {
538 if (ent is SceneObjectGroup) 538 if (ent is SceneObjectGroup)
539 { 539 {
540 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); 540 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
541 if (hasPrim != false) 541 if (hasPrim != false)
542 { 542 {
543 ((SceneObjectGroup)ent).UpdateExtraParam(primLocalID, type, inUse, data); 543 ((SceneObjectGroup)ent).UpdateExtraParam(primLocalID, type, inUse, data);
544 break; 544 break;
545 } 545 }
546 } 546 }
547 } 547 }
548 } 548 }
549 549
550 /// <summary> 550 /// <summary>
551 /// 551 ///
552 /// </summary> 552 /// </summary>
553 /// <param name="primLocalID"></param> 553 /// <param name="primLocalID"></param>
554 /// <param name="shapeBlock"></param> 554 /// <param name="shapeBlock"></param>
555 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock) 555 public void UpdatePrimShape(uint primLocalID, ObjectShapePacket.ObjectDataBlock shapeBlock)
556 { 556 {
557 bool hasPrim = false; 557 bool hasPrim = false;
558 foreach (EntityBase ent in Entities.Values) 558 foreach (EntityBase ent in Entities.Values)
559 { 559 {
560 if (ent is SceneObjectGroup) 560 if (ent is SceneObjectGroup)
561 { 561 {
562 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID); 562 hasPrim = ((SceneObjectGroup)ent).HasChildPrim(primLocalID);
563 if (hasPrim != false) 563 if (hasPrim != false)
564 { 564 {
565 ((SceneObjectGroup)ent).UpdateShape(shapeBlock, primLocalID); 565 ((SceneObjectGroup)ent).UpdateShape(shapeBlock, primLocalID);
566 break; 566 break;
567 } 567 }
568 } 568 }
569 } 569 }
570 } 570 }
571 571
572 /// <summary> 572 /// <summary>
573 /// 573 ///
574 /// </summary> 574 /// </summary>
575 /// <param name="parentPrim"></param> 575 /// <param name="parentPrim"></param>
576 /// <param name="childPrims"></param> 576 /// <param name="childPrims"></param>
577 public void LinkObjects(uint parentPrim, List<uint> childPrims) 577 public void LinkObjects(uint parentPrim, List<uint> childPrims)
578 { 578 {
579 SceneObjectGroup parenPrim = null; 579 SceneObjectGroup parenPrim = null;
580 foreach (EntityBase ent in Entities.Values) 580 foreach (EntityBase ent in Entities.Values)
581 { 581 {
582 if (ent is SceneObjectGroup) 582 if (ent is SceneObjectGroup)
583 { 583 {
584 if (((SceneObjectGroup)ent).LocalId == parentPrim) 584 if (((SceneObjectGroup)ent).LocalId == parentPrim)
585 { 585 {
586 parenPrim = (SceneObjectGroup)ent; 586 parenPrim = (SceneObjectGroup)ent;
587 break; 587 break;
588 } 588 }
589 } 589 }
590 } 590 }
591 591
592 List<SceneObjectGroup> children = new List<SceneObjectGroup>(); 592 List<SceneObjectGroup> children = new List<SceneObjectGroup>();
593 if (parenPrim != null) 593 if (parenPrim != null)
594 { 594 {
595 for (int i = 0; i < childPrims.Count; i++) 595 for (int i = 0; i < childPrims.Count; i++)
596 { 596 {
597 foreach (EntityBase ent in Entities.Values) 597 foreach (EntityBase ent in Entities.Values)
598 { 598 {
599 if (ent is SceneObjectGroup) 599 if (ent is SceneObjectGroup)
600 { 600 {
601 if (((SceneObjectGroup)ent).LocalId == childPrims[i]) 601 if (((SceneObjectGroup)ent).LocalId == childPrims[i])
602 { 602 {
603 children.Add((SceneObjectGroup)ent); 603 children.Add((SceneObjectGroup)ent);
604 } 604 }
605 } 605 }
606 } 606 }
607 } 607 }
608 } 608 }
609 609
610 foreach (SceneObjectGroup sceneObj in children) 610 foreach (SceneObjectGroup sceneObj in children)
611 { 611 {
612 parenPrim.LinkToGroup(sceneObj); 612 parenPrim.LinkToGroup(sceneObj);
613 } 613 }
614 } 614 }
615 615
616 /// <summary> 616 /// <summary>
617 /// 617 ///
618 /// </summary> 618 /// </summary>
619 /// <param name="originalPrim"></param> 619 /// <param name="originalPrim"></param>
620 /// <param name="offset"></param> 620 /// <param name="offset"></param>
621 /// <param name="flags"></param> 621 /// <param name="flags"></param>
622 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags) 622 public void DuplicateObject(uint originalPrim, LLVector3 offset, uint flags)
623 { 623 {
624 SceneObjectGroup originPrim = null; 624 SceneObjectGroup originPrim = null;
625 foreach (EntityBase ent in Entities.Values) 625 foreach (EntityBase ent in Entities.Values)
626 { 626 {
627 if (ent is SceneObjectGroup) 627 if (ent is SceneObjectGroup)
628 { 628 {
629 if (((SceneObjectGroup)ent).LocalId == originalPrim) 629 if (((SceneObjectGroup)ent).LocalId == originalPrim)
630 { 630 {
631 originPrim = (SceneObjectGroup)ent; 631 originPrim = (SceneObjectGroup)ent;
632 break; 632 break;
633 } 633 }
634 } 634 }
635 } 635 }
636 636
637 if (originPrim != null) 637 if (originPrim != null)
638 { 638 {
639 SceneObjectGroup copy = originPrim.Copy(); 639 SceneObjectGroup copy = originPrim.Copy();
640 copy.AbsolutePosition = copy.AbsolutePosition + offset; 640 copy.AbsolutePosition = copy.AbsolutePosition + offset;
641 Entities.Add(copy.UUID, copy); 641 Entities.Add(copy.UUID, copy);
642 642
643 copy.ScheduleGroupForFullUpdate(); 643 copy.ScheduleGroupForFullUpdate();
644 644
645 } 645 }
646 else 646 else
647 { 647 {
648 MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim"); 648 MainLog.Instance.Warn("client", "Attempted to duplicate nonexistant prim");
649 } 649 }
650 } 650 }
651 651
652 652
653 #endregion 653 #endregion
654 } 654 }
655} 655}
diff --git a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
index 2ade989..e67d413 100644
--- a/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneCommunicationService.cs
@@ -1,212 +1,212 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Net; 3using System.Net;
4using System.Text; 4using System.Text;
5using libsecondlife; 5using libsecondlife;
6using OpenSim.Framework; 6using OpenSim.Framework;
7using OpenSim.Framework.Console; 7using OpenSim.Framework.Console;
8using OpenSim.Framework.Communications; 8using OpenSim.Framework.Communications;
9 9
10 10
11namespace OpenSim.Region.Environment.Scenes 11namespace OpenSim.Region.Environment.Scenes
12{ 12{
13 public class SceneCommunicationService //one instance per region 13 public class SceneCommunicationService //one instance per region
14 { 14 {
15 protected CommunicationsManager m_commsProvider; 15 protected CommunicationsManager m_commsProvider;
16 protected RegionInfo m_regionInfo; 16 protected RegionInfo m_regionInfo;
17 17
18 protected RegionCommsListener regionCommsHost; 18 protected RegionCommsListener regionCommsHost;
19 19
20 public event AgentCrossing OnAvatarCrossingIntoRegion; 20 public event AgentCrossing OnAvatarCrossingIntoRegion;
21 public event ExpectUserDelegate OnExpectUser; 21 public event ExpectUserDelegate OnExpectUser;
22 22
23 23
24 public SceneCommunicationService(CommunicationsManager commsMan) 24 public SceneCommunicationService(CommunicationsManager commsMan)
25 { 25 {
26 m_commsProvider = commsMan; 26 m_commsProvider = commsMan;
27 } 27 }
28 28
29 public void RegisterRegion(RegionInfo regionInfos) 29 public void RegisterRegion(RegionInfo regionInfos)
30 { 30 {
31 m_regionInfo = regionInfos; 31 m_regionInfo = regionInfos;
32 regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); 32 regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
33 if (regionCommsHost != null) 33 if (regionCommsHost != null)
34 { 34 {
35 regionCommsHost.OnExpectUser += NewUserConnection; 35 regionCommsHost.OnExpectUser += NewUserConnection;
36 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; 36 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
37 } 37 }
38 } 38 }
39 39
40 public void Close() 40 public void Close()
41 { 41 {
42 regionCommsHost.OnExpectUser -= NewUserConnection; 42 regionCommsHost.OnExpectUser -= NewUserConnection;
43 regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; 43 regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
44 //regionCommsHost.RemoveRegion(m_regionInfo); //TODO add to method to commsManager 44 //regionCommsHost.RemoveRegion(m_regionInfo); //TODO add to method to commsManager
45 regionCommsHost = null; 45 regionCommsHost = null;
46 } 46 }
47 47
48 #region CommsManager Event handlers 48 #region CommsManager Event handlers
49 /// <summary> 49 /// <summary>
50 /// 50 ///
51 /// </summary> 51 /// </summary>
52 /// <param name="regionHandle"></param> 52 /// <param name="regionHandle"></param>
53 /// <param name="agent"></param> 53 /// <param name="agent"></param>
54 public void NewUserConnection(ulong regionHandle, AgentCircuitData agent) 54 public void NewUserConnection(ulong regionHandle, AgentCircuitData agent)
55 { 55 {
56 if (OnExpectUser != null) 56 if (OnExpectUser != null)
57 { 57 {
58 OnExpectUser(regionHandle, agent); 58 OnExpectUser(regionHandle, agent);
59 } 59 }
60 } 60 }
61 61
62 public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying) 62 public void AgentCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position, bool isFlying)
63 { 63 {
64 if (OnAvatarCrossingIntoRegion != null) 64 if (OnAvatarCrossingIntoRegion != null)
65 { 65 {
66 OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying); 66 OnAvatarCrossingIntoRegion(regionHandle, agentID, position, isFlying);
67 } 67 }
68 } 68 }
69 #endregion 69 #endregion
70 70
71 #region Inform Client of Neighbours 71 #region Inform Client of Neighbours
72 private delegate void InformClientOfNeighbourDelegate( 72 private delegate void InformClientOfNeighbourDelegate(
73 ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint); 73 ScenePresence avatar, AgentCircuitData a, ulong regionHandle, IPEndPoint endPoint);
74 74
75 private void InformClientOfNeighbourCompleted(IAsyncResult iar) 75 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
76 { 76 {
77 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState; 77 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate)iar.AsyncState;
78 icon.EndInvoke(iar); 78 icon.EndInvoke(iar);
79 } 79 }
80 80
81 /// <summary> 81 /// <summary>
82 /// Async compnent for informing client of which neighbours exists 82 /// Async compnent for informing client of which neighbours exists
83 /// </summary> 83 /// </summary>
84 /// <remarks> 84 /// <remarks>
85 /// This needs to run asynchronesously, as a network timeout may block the thread for a long while 85 /// This needs to run asynchronesously, as a network timeout may block the thread for a long while
86 /// </remarks> 86 /// </remarks>
87 /// <param name="remoteClient"></param> 87 /// <param name="remoteClient"></param>
88 /// <param name="a"></param> 88 /// <param name="a"></param>
89 /// <param name="regionHandle"></param> 89 /// <param name="regionHandle"></param>
90 /// <param name="endPoint"></param> 90 /// <param name="endPoint"></param>
91 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, ulong regionHandle, 91 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, ulong regionHandle,
92 IPEndPoint endPoint) 92 IPEndPoint endPoint)
93 { 93 {
94 MainLog.Instance.Notice("INTERGRID", "Starting to inform client about neighbours"); 94 MainLog.Instance.Notice("INTERGRID", "Starting to inform client about neighbours");
95 bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, a); 95 bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, a);
96 96
97 if (regionAccepted) 97 if (regionAccepted)
98 { 98 {
99 avatar.ControllingClient.InformClientOfNeighbour(regionHandle, endPoint); 99 avatar.ControllingClient.InformClientOfNeighbour(regionHandle, endPoint);
100 avatar.AddNeighbourRegion(regionHandle); 100 avatar.AddNeighbourRegion(regionHandle);
101 MainLog.Instance.Notice("INTERGRID", "Completed inform client about neighbours"); 101 MainLog.Instance.Notice("INTERGRID", "Completed inform client about neighbours");
102 } 102 }
103 } 103 }
104 104
105 /// <summary> 105 /// <summary>
106 /// 106 ///
107 /// </summary> 107 /// </summary>
108 public void InformClientOfNeighbours(ScenePresence avatar) 108 public void InformClientOfNeighbours(ScenePresence avatar)
109 { 109 {
110 List<SimpleRegionInfo> neighbours = 110 List<SimpleRegionInfo> neighbours =
111 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 111 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
112 if (neighbours != null) 112 if (neighbours != null)
113 { 113 {
114 for (int i = 0; i < neighbours.Count; i++) 114 for (int i = 0; i < neighbours.Count; i++)
115 { 115 {
116 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); 116 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
117 agent.BaseFolder = LLUUID.Zero; 117 agent.BaseFolder = LLUUID.Zero;
118 agent.InventoryFolder = LLUUID.Zero; 118 agent.InventoryFolder = LLUUID.Zero;
119 agent.startpos = new LLVector3(128, 128, 70); 119 agent.startpos = new LLVector3(128, 128, 70);
120 agent.child = true; 120 agent.child = true;
121 121
122 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; 122 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
123 d.BeginInvoke(avatar, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint, 123 d.BeginInvoke(avatar, agent, neighbours[i].RegionHandle, neighbours[i].ExternalEndPoint,
124 InformClientOfNeighbourCompleted, 124 InformClientOfNeighbourCompleted,
125 d); 125 d);
126 } 126 }
127 } 127 }
128 } 128 }
129 #endregion 129 #endregion
130 130
131 /// <summary> 131 /// <summary>
132 /// 132 ///
133 /// </summary> 133 /// </summary>
134 /// <param name="regionHandle"></param> 134 /// <param name="regionHandle"></param>
135 /// <returns></returns> 135 /// <returns></returns>
136 public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle) 136 public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
137 { 137 {
138 return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle); 138 return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
139 } 139 }
140 140
141 /// <summary> 141 /// <summary>
142 /// 142 ///
143 /// </summary> 143 /// </summary>
144 /// <param name="minX"></param> 144 /// <param name="minX"></param>
145 /// <param name="minY"></param> 145 /// <param name="minY"></param>
146 /// <param name="maxX"></param> 146 /// <param name="maxX"></param>
147 /// <param name="maxY"></param> 147 /// <param name="maxY"></param>
148 public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY) 148 public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
149 { 149 {
150 List<MapBlockData> mapBlocks; 150 List<MapBlockData> mapBlocks;
151 mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY); 151 mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
152 remoteClient.SendMapBlock(mapBlocks); 152 remoteClient.SendMapBlock(mapBlocks);
153 } 153 }
154 154
155 /// <summary> 155 /// <summary>
156 /// 156 ///
157 /// </summary> 157 /// </summary>
158 /// <param name="remoteClient"></param> 158 /// <param name="remoteClient"></param>
159 /// <param name="RegionHandle"></param> 159 /// <param name="RegionHandle"></param>
160 /// <param name="position"></param> 160 /// <param name="position"></param>
161 /// <param name="lookAt"></param> 161 /// <param name="lookAt"></param>
162 /// <param name="flags"></param> 162 /// <param name="flags"></param>
163 public virtual void RequestTeleportLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position, 163 public virtual void RequestTeleportLocation(ScenePresence avatar, ulong regionHandle, LLVector3 position,
164 LLVector3 lookAt, uint flags) 164 LLVector3 lookAt, uint flags)
165 { 165 {
166 if (regionHandle == m_regionInfo.RegionHandle) 166 if (regionHandle == m_regionInfo.RegionHandle)
167 { 167 {
168 168
169 avatar.ControllingClient.SendTeleportLocationStart(); 169 avatar.ControllingClient.SendTeleportLocationStart();
170 avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags); 170 avatar.ControllingClient.SendLocalTeleport(position, lookAt, flags);
171 avatar.Teleport(position); 171 avatar.Teleport(position);
172 172
173 } 173 }
174 else 174 else
175 { 175 {
176 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); 176 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle);
177 if (reg != null) 177 if (reg != null)
178 { 178 {
179 avatar.ControllingClient.SendTeleportLocationStart(); 179 avatar.ControllingClient.SendTeleportLocationStart();
180 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); 180 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
181 agent.BaseFolder = LLUUID.Zero; 181 agent.BaseFolder = LLUUID.Zero;
182 agent.InventoryFolder = LLUUID.Zero; 182 agent.InventoryFolder = LLUUID.Zero;
183 agent.startpos = position; 183 agent.startpos = position;
184 agent.child = true; 184 agent.child = true;
185 avatar.Close(); 185 avatar.Close();
186 m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent); 186 m_commsProvider.InterRegion.InformRegionOfChildAgent(regionHandle, agent);
187 m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, position, false); 187 m_commsProvider.InterRegion.ExpectAvatarCrossing(regionHandle, avatar.ControllingClient.AgentId, position, false);
188 AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo(); 188 AgentCircuitData circuitdata = avatar.ControllingClient.RequestClientInfo();
189 string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId); 189 string capsPath = Util.GetCapsURL(avatar.ControllingClient.AgentId);
190 avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath); 190 avatar.ControllingClient.SendRegionTeleport(regionHandle, 13, reg.ExternalEndPoint, 4, (1 << 4), capsPath);
191 avatar.MakeChildAgent(); 191 avatar.MakeChildAgent();
192 } 192 }
193 } 193 }
194 } 194 }
195 195
196 /// <summary> 196 /// <summary>
197 /// 197 ///
198 /// </summary> 198 /// </summary>
199 /// <param name="regionhandle"></param> 199 /// <param name="regionhandle"></param>
200 /// <param name="agentID"></param> 200 /// <param name="agentID"></param>
201 /// <param name="position"></param> 201 /// <param name="position"></param>
202 public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying) 202 public bool InformNeighbourOfCrossing(ulong regionhandle, LLUUID agentID, LLVector3 position, bool isFlying)
203 { 203 {
204 return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying); 204 return m_commsProvider.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position, isFlying);
205 } 205 }
206 206
207 public void CloseAgentConnection(ScenePresence presence) 207 public void CloseAgentConnection(ScenePresence presence)
208 { 208 {
209 throw new Exception("The method or operation is not implemented."); 209 throw new Exception("The method or operation is not implemented.");
210 } 210 }
211 } 211 }
212} 212}