aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs13
-rw-r--r--OpenSim/Framework/MultipartForm.cs117
-rw-r--r--OpenSim/Framework/RegionCommsListener.cs2
-rw-r--r--OpenSim/Framework/RegionInfo.cs18
-rw-r--r--OpenSim/Framework/UntrustedWebRequest.cs203
-rw-r--r--OpenSim/Framework/WebUtil.cs330
-rw-r--r--OpenSim/Framework/sLLVector3.cs51
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs16
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs16
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs44
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs40
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs46
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs76
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs55
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs53
-rw-r--r--OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs32
-rw-r--r--OpenSim/Services/Base/ServiceBase.cs20
-rw-r--r--OpenSim/Services/Friends/FriendsServiceBase.cs9
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs1
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs9
22 files changed, 940 insertions, 227 deletions
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index fee71f0..a1ac84c 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -41,14 +41,14 @@ namespace OpenSim.Framework
41 public Guid AgentID; 41 public Guid AgentID;
42 public bool alwaysrun; 42 public bool alwaysrun;
43 public float AVHeight; 43 public float AVHeight;
44 public sLLVector3 cameraPosition; 44 public Vector3 cameraPosition;
45 public float drawdistance; 45 public float drawdistance;
46 public float godlevel; 46 public float godlevel;
47 public uint GroupAccess; 47 public uint GroupAccess;
48 public sLLVector3 Position; 48 public Vector3 Position;
49 public ulong regionHandle; 49 public ulong regionHandle;
50 public byte[] throttles; 50 public byte[] throttles;
51 public sLLVector3 Velocity; 51 public Vector3 Velocity;
52 52
53 public ChildAgentDataUpdate() 53 public ChildAgentDataUpdate()
54 { 54 {
@@ -177,14 +177,13 @@ namespace OpenSim.Framework
177 Size = new Vector3(); 177 Size = new Vector3();
178 Size.Z = cAgent.AVHeight; 178 Size.Z = cAgent.AVHeight;
179 179
180 Center = new Vector3(cAgent.cameraPosition.x, cAgent.cameraPosition.y, cAgent.cameraPosition.z); 180 Center = cAgent.cameraPosition;
181 Far = cAgent.drawdistance; 181 Far = cAgent.drawdistance;
182 Position = new Vector3(cAgent.Position.x, cAgent.Position.y, cAgent.Position.z); 182 Position = cAgent.Position;
183 RegionHandle = cAgent.regionHandle; 183 RegionHandle = cAgent.regionHandle;
184 Throttles = cAgent.throttles; 184 Throttles = cAgent.throttles;
185 Velocity = new Vector3(cAgent.Velocity.x, cAgent.Velocity.y, cAgent.Velocity.z); 185 Velocity = cAgent.Velocity;
186 } 186 }
187
188 } 187 }
189 188
190 public class AgentGroupData 189 public class AgentGroupData
diff --git a/OpenSim/Framework/MultipartForm.cs b/OpenSim/Framework/MultipartForm.cs
new file mode 100644
index 0000000..8ba6d22
--- /dev/null
+++ b/OpenSim/Framework/MultipartForm.cs
@@ -0,0 +1,117 @@
1using System;
2using System.Collections.Generic;
3using System.Net;
4using System.IO;
5using System.Text;
6
7namespace OpenSim.Framework
8{
9 public static class MultipartForm
10 {
11 #region Helper Classes
12
13 public abstract class Element
14 {
15 public string Name;
16 }
17
18 public class File : Element
19 {
20 public string Filename;
21 public string ContentType;
22 public byte[] Data;
23
24 public File(string name, string filename, string contentType, byte[] data)
25 {
26 Name = name;
27 Filename = filename;
28 ContentType = contentType;
29 Data = data;
30 }
31 }
32
33 public class Parameter : Element
34 {
35 public string Value;
36
37 public Parameter(string name, string value)
38 {
39 Name = name;
40 Value = value;
41 }
42 }
43
44 #endregion Helper Classes
45
46 public static HttpWebResponse Post(HttpWebRequest request, List<Element> postParameters)
47 {
48 string boundary = Boundary();
49
50 // Set up the request properties
51 request.Method = "POST";
52 request.ContentType = "multipart/form-data; boundary=" + boundary;
53
54 #region Stream Writing
55
56 using (MemoryStream formDataStream = new MemoryStream())
57 {
58 foreach (var param in postParameters)
59 {
60 if (param is File)
61 {
62 File file = (File)param;
63
64 // Add just the first part of this param, since we will write the file data directly to the Stream
65 string header = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"; filename=\"{2}\";\r\nContent-Type: {3}\r\n\r\n",
66 boundary,
67 file.Name,
68 !String.IsNullOrEmpty(file.Filename) ? file.Filename : "tempfile",
69 file.ContentType);
70
71 formDataStream.Write(Encoding.UTF8.GetBytes(header), 0, header.Length);
72 formDataStream.Write(file.Data, 0, file.Data.Length);
73 }
74 else
75 {
76 Parameter parameter = (Parameter)param;
77
78 string postData = string.Format("--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}\r\n",
79 boundary,
80 parameter.Name,
81 parameter.Value);
82 formDataStream.Write(Encoding.UTF8.GetBytes(postData), 0, postData.Length);
83 }
84 }
85
86 // Add the end of the request
87 byte[] footer = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n");
88 formDataStream.Write(footer, 0, footer.Length);
89
90 request.ContentLength = formDataStream.Length;
91
92 // Copy the temporary stream to the network stream
93 formDataStream.Seek(0, SeekOrigin.Begin);
94 using (Stream requestStream = request.GetRequestStream())
95 formDataStream.CopyTo(requestStream, (int)formDataStream.Length);
96 }
97
98 #endregion Stream Writing
99
100 return request.GetResponse() as HttpWebResponse;
101 }
102
103 private static string Boundary()
104 {
105 Random rnd = new Random();
106 string formDataBoundary = String.Empty;
107
108 while (formDataBoundary.Length < 15)
109 formDataBoundary = formDataBoundary + rnd.Next();
110
111 formDataBoundary = formDataBoundary.Substring(0, 15);
112 formDataBoundary = "-----------------------------" + formDataBoundary;
113
114 return formDataBoundary;
115 }
116 }
117}
diff --git a/OpenSim/Framework/RegionCommsListener.cs b/OpenSim/Framework/RegionCommsListener.cs
index 718a556..3e0955d 100644
--- a/OpenSim/Framework/RegionCommsListener.cs
+++ b/OpenSim/Framework/RegionCommsListener.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Framework
45 private GenericCall2 handlerExpectChildAgent = null; // OnExpectChildAgent; 45 private GenericCall2 handlerExpectChildAgent = null; // OnExpectChildAgent;
46 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser 46 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
47 private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate; 47 private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
48 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 48// private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
49 private LogOffUser handlerLogOffUser = null; 49 private LogOffUser handlerLogOffUser = null;
50 private GetLandData handlerGetLandData = null; 50 private GetLandData handlerGetLandData = null;
51 51
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index ac38ac2..5d63da7 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -351,7 +351,7 @@ namespace OpenSim.Framework
351 351
352 private void ReadNiniConfig(IConfigSource source, string name) 352 private void ReadNiniConfig(IConfigSource source, string name)
353 { 353 {
354 bool creatingNew = false; 354// bool creatingNew = false;
355 355
356 if (source.Configs.Count == 0) 356 if (source.Configs.Count == 0)
357 { 357 {
@@ -368,7 +368,7 @@ namespace OpenSim.Framework
368 368
369 source.AddConfig(name); 369 source.AddConfig(name);
370 370
371 creatingNew = true; 371// creatingNew = true;
372 } 372 }
373 373
374 if (name == String.Empty) 374 if (name == String.Empty)
@@ -378,7 +378,7 @@ namespace OpenSim.Framework
378 { 378 {
379 source.AddConfig(name); 379 source.AddConfig(name);
380 380
381 creatingNew = true; 381// creatingNew = true;
382 } 382 }
383 383
384 IConfig config = source.Configs[name]; 384 IConfig config = source.Configs[name];
@@ -397,15 +397,8 @@ namespace OpenSim.Framework
397 397
398 RegionID = new UUID(regionUUID); 398 RegionID = new UUID(regionUUID);
399 originRegionID = RegionID; // What IS this?! 399 originRegionID = RegionID; // What IS this?!
400 400
401
402 // Region name
403 //
404 RegionName = name; 401 RegionName = name;
405
406
407 // Region location
408 //
409 string location = config.GetString("Location", String.Empty); 402 string location = config.GetString("Location", String.Empty);
410 403
411 if (location == String.Empty) 404 if (location == String.Empty)
@@ -421,12 +414,9 @@ namespace OpenSim.Framework
421 414
422 415
423 // Datastore (is this implemented? Omitted from example!) 416 // Datastore (is this implemented? Omitted from example!)
424 //
425 DataStore = config.GetString("Datastore", String.Empty); 417 DataStore = config.GetString("Datastore", String.Empty);
426 418
427
428 // Internal IP 419 // Internal IP
429 //
430 IPAddress address; 420 IPAddress address;
431 421
432 if (config.Contains("InternalAddress")) 422 if (config.Contains("InternalAddress"))
diff --git a/OpenSim/Framework/UntrustedWebRequest.cs b/OpenSim/Framework/UntrustedWebRequest.cs
new file mode 100644
index 0000000..1af7c41
--- /dev/null
+++ b/OpenSim/Framework/UntrustedWebRequest.cs
@@ -0,0 +1,203 @@
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Net;
5using System.Net.Security;
6using System.Text;
7using log4net;
8
9namespace OpenSim.Framework
10{
11 /// <summary>
12 /// Used for requests to untrusted endpoints that may potentially be
13 /// malicious
14 /// </summary>
15 public static class UntrustedHttpWebRequest
16 {
17 /// <summary>Setting this to true will allow HTTP connections to localhost</summary>
18 private const bool DEBUG = true;
19
20 private static readonly ILog m_log =
21 LogManager.GetLogger(
22 System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
23
24 private static readonly ICollection<string> allowableSchemes = new List<string> { "http", "https" };
25
26 /// <summary>
27 /// Creates an HttpWebRequest that is hardened against malicious
28 /// endpoints after ensuring the given Uri is safe to retrieve
29 /// </summary>
30 /// <param name="uri">Web location to request</param>
31 /// <returns>A hardened HttpWebRequest if the uri was determined to be safe</returns>
32 /// <exception cref="ArgumentNullException">If uri is null</exception>
33 /// <exception cref="ArgumentException">If uri is unsafe</exception>
34 public static HttpWebRequest Create(Uri uri)
35 {
36 return Create(uri, DEBUG, 1000 * 5, 1000 * 20, 10);
37 }
38
39 /// <summary>
40 /// Creates an HttpWebRequest that is hardened against malicious
41 /// endpoints after ensuring the given Uri is safe to retrieve
42 /// </summary>
43 /// <param name="uri">Web location to request</param>
44 /// <param name="allowLoopback">True to allow connections to localhost, otherwise false</param>
45 /// <param name="readWriteTimeoutMS">Read write timeout, in milliseconds</param>
46 /// <param name="timeoutMS">Connection timeout, in milliseconds</param>
47 /// <param name="maximumRedirects">Maximum number of allowed redirects</param>
48 /// <returns>A hardened HttpWebRequest if the uri was determined to be safe</returns>
49 /// <exception cref="ArgumentNullException">If uri is null</exception>
50 /// <exception cref="ArgumentException">If uri is unsafe</exception>
51 public static HttpWebRequest Create(Uri uri, bool allowLoopback, int readWriteTimeoutMS, int timeoutMS, int maximumRedirects)
52 {
53 if (uri == null)
54 throw new ArgumentNullException("uri");
55
56 if (!IsUriAllowable(uri, allowLoopback))
57 throw new ArgumentException("Uri " + uri + " was rejected");
58
59 HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(uri);
60 httpWebRequest.MaximumAutomaticRedirections = maximumRedirects;
61 httpWebRequest.ReadWriteTimeout = readWriteTimeoutMS;
62 httpWebRequest.Timeout = timeoutMS;
63 httpWebRequest.KeepAlive = false;
64
65 return httpWebRequest;
66 }
67
68 public static string PostToUntrustedUrl(Uri url, string data)
69 {
70 try
71 {
72 byte[] requestData = System.Text.Encoding.UTF8.GetBytes(data);
73
74 HttpWebRequest request = Create(url);
75 request.Method = "POST";
76 request.ContentLength = requestData.Length;
77 request.ContentType = "application/x-www-form-urlencoded";
78
79 using (Stream requestStream = request.GetRequestStream())
80 requestStream.Write(requestData, 0, requestData.Length);
81
82 using (WebResponse response = request.GetResponse())
83 {
84 using (Stream responseStream = response.GetResponseStream())
85 return responseStream.GetStreamString();
86 }
87 }
88 catch (Exception ex)
89 {
90 m_log.Warn("POST to untrusted URL " + url + " failed: " + ex.Message);
91 return null;
92 }
93 }
94
95 public static string GetUntrustedUrl(Uri url)
96 {
97 try
98 {
99 HttpWebRequest request = Create(url);
100
101 using (WebResponse response = request.GetResponse())
102 {
103 using (Stream responseStream = response.GetResponseStream())
104 return responseStream.GetStreamString();
105 }
106 }
107 catch (Exception ex)
108 {
109 m_log.Warn("GET from untrusted URL " + url + " failed: " + ex.Message);
110 return null;
111 }
112 }
113
114 /// <summary>
115 /// Determines whether a URI is allowed based on scheme and host name.
116 /// No requireSSL check is done here
117 /// </summary>
118 /// <param name="allowLoopback">True to allow loopback addresses to be used</param>
119 /// <param name="uri">The URI to test for whether it should be allowed.</param>
120 /// <returns>
121 /// <c>true</c> if [is URI allowable] [the specified URI]; otherwise, <c>false</c>.
122 /// </returns>
123 private static bool IsUriAllowable(Uri uri, bool allowLoopback)
124 {
125 if (!allowableSchemes.Contains(uri.Scheme))
126 {
127 m_log.WarnFormat("Rejecting URL {0} because it uses a disallowed scheme.", uri);
128 return false;
129 }
130
131 // Try to interpret the hostname as an IP address so we can test for internal
132 // IP address ranges. Note that IP addresses can appear in many forms
133 // (e.g. http://127.0.0.1, http://2130706433, http://0x0100007f, http://::1
134 // So we convert them to a canonical IPAddress instance, and test for all
135 // non-routable IP ranges: 10.*.*.*, 127.*.*.*, ::1
136 // Note that Uri.IsLoopback is very unreliable, not catching many of these variants.
137 IPAddress hostIPAddress;
138 if (IPAddress.TryParse(uri.DnsSafeHost, out hostIPAddress))
139 {
140 byte[] addressBytes = hostIPAddress.GetAddressBytes();
141
142 // The host is actually an IP address.
143 switch (hostIPAddress.AddressFamily)
144 {
145 case System.Net.Sockets.AddressFamily.InterNetwork:
146 if (!allowLoopback && (addressBytes[0] == 127 || addressBytes[0] == 10))
147 {
148 m_log.WarnFormat("Rejecting URL {0} because it is a loopback address.", uri);
149 return false;
150 }
151 break;
152 case System.Net.Sockets.AddressFamily.InterNetworkV6:
153 if (!allowLoopback && IsIPv6Loopback(hostIPAddress))
154 {
155 m_log.WarnFormat("Rejecting URL {0} because it is a loopback address.", uri);
156 return false;
157 }
158 break;
159 default:
160 m_log.WarnFormat("Rejecting URL {0} because it does not use an IPv4 or IPv6 address.", uri);
161 return false;
162 }
163 }
164 else
165 {
166 // The host is given by name. We require names to contain periods to
167 // help make sure it's not an internal address.
168 if (!allowLoopback && !uri.Host.Contains("."))
169 {
170 m_log.WarnFormat("Rejecting URL {0} because it does not contain a period in the host name.", uri);
171 return false;
172 }
173 }
174
175 return true;
176 }
177
178 /// <summary>
179 /// Determines whether an IP address is the IPv6 equivalent of "localhost/127.0.0.1".
180 /// </summary>
181 /// <param name="ip">The ip address to check.</param>
182 /// <returns>
183 /// <c>true</c> if this is a loopback IP address; <c>false</c> otherwise.
184 /// </returns>
185 private static bool IsIPv6Loopback(IPAddress ip)
186 {
187 if (ip == null)
188 throw new ArgumentNullException("ip");
189
190 byte[] addressBytes = ip.GetAddressBytes();
191 for (int i = 0; i < addressBytes.Length - 1; i++)
192 {
193 if (addressBytes[i] != 0)
194 return false;
195 }
196
197 if (addressBytes[addressBytes.Length - 1] != 1)
198 return false;
199
200 return true;
201 }
202 }
203}
diff --git a/OpenSim/Framework/WebUtil.cs b/OpenSim/Framework/WebUtil.cs
new file mode 100644
index 0000000..d9782ff
--- /dev/null
+++ b/OpenSim/Framework/WebUtil.cs
@@ -0,0 +1,330 @@
1using System;
2using System.Collections.Generic;
3using System.Collections.Specialized;
4using System.IO;
5using System.Net;
6using System.Net.Security;
7using System.Reflection;
8using System.Text;
9using System.Web;
10using log4net;
11using OpenSim.Framework.Servers.HttpServer;
12using OpenMetaverse.StructuredData;
13
14namespace OpenSim.Framework
15{
16 /// <summary>
17 /// Miscellaneous static methods and extension methods related to the web
18 /// </summary>
19 public static class WebUtil
20 {
21 private static readonly ILog m_log =
22 LogManager.GetLogger(
23 MethodBase.GetCurrentMethod().DeclaringType);
24
25 /// <summary>
26 /// Send LLSD to an HTTP client in application/llsd+json form
27 /// </summary>
28 /// <param name="response">HTTP response to send the data in</param>
29 /// <param name="body">LLSD to send to the client</param>
30 public static void SendJSONResponse(OSHttpResponse response, OSDMap body)
31 {
32 byte[] responseData = Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(body));
33
34 response.ContentEncoding = Encoding.UTF8;
35 response.ContentLength = responseData.Length;
36 response.ContentType = "application/llsd+json";
37 response.Body.Write(responseData, 0, responseData.Length);
38 }
39
40 /// <summary>
41 /// Send LLSD to an HTTP client in application/llsd+xml form
42 /// </summary>
43 /// <param name="response">HTTP response to send the data in</param>
44 /// <param name="body">LLSD to send to the client</param>
45 public static void SendXMLResponse(OSHttpResponse response, OSDMap body)
46 {
47 byte[] responseData = OSDParser.SerializeLLSDXmlBytes(body);
48
49 response.ContentEncoding = Encoding.UTF8;
50 response.ContentLength = responseData.Length;
51 response.ContentType = "application/llsd+xml";
52 response.Body.Write(responseData, 0, responseData.Length);
53 }
54
55 /// <summary>
56 /// Make a GET or GET-like request to a web service that returns LLSD
57 /// or JSON data
58 /// </summary>
59 public static OSDMap ServiceRequest(string url, string httpVerb)
60 {
61 string errorMessage;
62
63 try
64 {
65 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
66 request.Method = httpVerb;
67
68 using (WebResponse response = request.GetResponse())
69 {
70 using (Stream responseStream = response.GetResponseStream())
71 {
72 try
73 {
74 string responseStr = responseStream.GetStreamString();
75 OSD responseOSD = OSDParser.Deserialize(responseStr);
76 if (responseOSD.Type == OSDType.Map)
77 return (OSDMap)responseOSD;
78 else
79 errorMessage = "Response format was invalid.";
80 }
81 catch
82 {
83 errorMessage = "Failed to parse the response.";
84 }
85 }
86 }
87 }
88 catch (Exception ex)
89 {
90 m_log.Warn("GET from URL " + url + " failed: " + ex.Message);
91 errorMessage = ex.Message;
92 }
93
94 return new OSDMap { { "Message", OSD.FromString("Service request failed. " + errorMessage) } };
95 }
96
97 /// <summary>
98 /// POST URL-encoded form data to a web service that returns LLSD or
99 /// JSON data
100 /// </summary>
101 public static OSDMap PostToService(string url, NameValueCollection data)
102 {
103 string errorMessage;
104
105 try
106 {
107 string queryString = BuildQueryString(data);
108 byte[] requestData = System.Text.Encoding.UTF8.GetBytes(queryString);
109
110 HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
111 request.Method = "POST";
112 request.ContentLength = requestData.Length;
113 request.ContentType = "application/x-www-form-urlencoded";
114
115 using (Stream requestStream = request.GetRequestStream())
116 requestStream.Write(requestData, 0, requestData.Length);
117
118 using (WebResponse response = request.GetResponse())
119 {
120 using (Stream responseStream = response.GetResponseStream())
121 {
122 try
123 {
124 string responseStr = responseStream.GetStreamString();
125 OSD responseOSD = OSDParser.Deserialize(responseStr);
126 if (responseOSD.Type == OSDType.Map)
127 return (OSDMap)responseOSD;
128 else
129 errorMessage = "Response format was invalid.";
130 }
131 catch
132 {
133 errorMessage = "Failed to parse the response.";
134 }
135 }
136 }
137 }
138 catch (Exception ex)
139 {
140 m_log.Warn("POST to URL " + url + " failed: " + ex.Message);
141 errorMessage = ex.Message;
142 }
143
144 return new OSDMap { { "Message", OSD.FromString("Service request failed. " + errorMessage) } };
145 }
146
147 #region Uri
148
149 /// <summary>
150 /// Combines a Uri that can contain both a base Uri and relative path
151 /// with a second relative path fragment
152 /// </summary>
153 /// <param name="uri">Starting (base) Uri</param>
154 /// <param name="fragment">Relative path fragment to append to the end
155 /// of the Uri</param>
156 /// <returns>The combined Uri</returns>
157 /// <remarks>This is similar to the Uri constructor that takes a base
158 /// Uri and the relative path, except this method can append a relative
159 /// path fragment on to an existing relative path</remarks>
160 public static Uri Combine(this Uri uri, string fragment)
161 {
162 string fragment1 = uri.Fragment;
163 string fragment2 = fragment;
164
165 if (!fragment1.EndsWith("/"))
166 fragment1 = fragment1 + '/';
167 if (fragment2.StartsWith("/"))
168 fragment2 = fragment2.Substring(1);
169
170 return new Uri(uri, fragment1 + fragment2);
171 }
172
173 /// <summary>
174 /// Combines a Uri that can contain both a base Uri and relative path
175 /// with a second relative path fragment. If the fragment is absolute,
176 /// it will be returned without modification
177 /// </summary>
178 /// <param name="uri">Starting (base) Uri</param>
179 /// <param name="fragment">Relative path fragment to append to the end
180 /// of the Uri, or an absolute Uri to return unmodified</param>
181 /// <returns>The combined Uri</returns>
182 public static Uri Combine(this Uri uri, Uri fragment)
183 {
184 if (fragment.IsAbsoluteUri)
185 return fragment;
186
187 string fragment1 = uri.Fragment;
188 string fragment2 = fragment.ToString();
189
190 if (!fragment1.EndsWith("/"))
191 fragment1 = fragment1 + '/';
192 if (fragment2.StartsWith("/"))
193 fragment2 = fragment2.Substring(1);
194
195 return new Uri(uri, fragment1 + fragment2);
196 }
197
198 /// <summary>
199 /// Appends a query string to a Uri that may or may not have existing
200 /// query parameters
201 /// </summary>
202 /// <param name="uri">Uri to append the query to</param>
203 /// <param name="query">Query string to append. Can either start with ?
204 /// or just containg key/value pairs</param>
205 /// <returns>String representation of the Uri with the query string
206 /// appended</returns>
207 public static string AppendQuery(this Uri uri, string query)
208 {
209 if (String.IsNullOrEmpty(query))
210 return uri.ToString();
211
212 if (query[0] == '?' || query[0] == '&')
213 query = query.Substring(1);
214
215 string uriStr = uri.ToString();
216
217 if (uriStr.Contains("?"))
218 return uriStr + '&' + query;
219 else
220 return uriStr + '?' + query;
221 }
222
223 #endregion Uri
224
225 #region NameValueCollection
226
227 /// <summary>
228 /// Convert a NameValueCollection into a query string. This is the
229 /// inverse of HttpUtility.ParseQueryString()
230 /// </summary>
231 /// <param name="parameters">Collection of key/value pairs to convert</param>
232 /// <returns>A query string with URL-escaped values</returns>
233 public static string BuildQueryString(NameValueCollection parameters)
234 {
235 List<string> items = new List<string>(parameters.Count);
236
237 foreach (string key in parameters.Keys)
238 {
239 foreach (string value in parameters.GetValues(key))
240 items.Add(String.Concat(key, "=", HttpUtility.UrlEncode(value ?? String.Empty)));
241 }
242
243 return String.Join("&", items.ToArray());
244 }
245
246 /// <summary>
247 ///
248 /// </summary>
249 /// <param name="collection"></param>
250 /// <param name="key"></param>
251 /// <returns></returns>
252 public static string GetOne(this NameValueCollection collection, string key)
253 {
254 string[] values = collection.GetValues(key);
255 if (values != null && values.Length > 0)
256 return values[0];
257
258 return null;
259 }
260
261 #endregion NameValueCollection
262
263 #region Stream
264
265 /// <summary>
266 /// Copies the contents of one stream to another, starting at the
267 /// current position of each stream
268 /// </summary>
269 /// <param name="copyFrom">The stream to copy from, at the position
270 /// where copying should begin</param>
271 /// <param name="copyTo">The stream to copy to, at the position where
272 /// bytes should be written</param>
273 /// <param name="maximumBytesToCopy">The maximum bytes to copy</param>
274 /// <returns>The total number of bytes copied</returns>
275 /// <remarks>
276 /// Copying begins at the streams' current positions. The positions are
277 /// NOT reset after copying is complete.
278 /// </remarks>
279 public static int CopyTo(this Stream copyFrom, Stream copyTo, int maximumBytesToCopy)
280 {
281 byte[] buffer = new byte[4096];
282 int readBytes;
283 int totalCopiedBytes = 0;
284
285 while ((readBytes = copyFrom.Read(buffer, 0, Math.Min(4096, maximumBytesToCopy))) > 0)
286 {
287 int writeBytes = Math.Min(maximumBytesToCopy, readBytes);
288 copyTo.Write(buffer, 0, writeBytes);
289 totalCopiedBytes += writeBytes;
290 maximumBytesToCopy -= writeBytes;
291 }
292
293 return totalCopiedBytes;
294 }
295
296 /// <summary>
297 /// Converts an entire stream to a string, regardless of current stream
298 /// position
299 /// </summary>
300 /// <param name="stream">The stream to convert to a string</param>
301 /// <returns></returns>
302 /// <remarks>When this method is done, the stream position will be
303 /// reset to its previous position before this method was called</remarks>
304 public static string GetStreamString(this Stream stream)
305 {
306 string value = null;
307
308 if (stream != null && stream.CanRead)
309 {
310 long rewindPos = -1;
311
312 if (stream.CanSeek)
313 {
314 rewindPos = stream.Position;
315 stream.Seek(0, SeekOrigin.Begin);
316 }
317
318 StreamReader reader = new StreamReader(stream);
319 value = reader.ReadToEnd();
320
321 if (rewindPos >= 0)
322 stream.Seek(rewindPos, SeekOrigin.Begin);
323 }
324
325 return value;
326 }
327
328 #endregion Stream
329 }
330}
diff --git a/OpenSim/Framework/sLLVector3.cs b/OpenSim/Framework/sLLVector3.cs
deleted file mode 100644
index 49940c4..0000000
--- a/OpenSim/Framework/sLLVector3.cs
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
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
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
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using OpenMetaverse;
30
31namespace OpenSim.Framework
32{
33 [Serializable]
34 public class sLLVector3
35 {
36 public float x = 0;
37 public float y = 0;
38 public float z = 0;
39
40 public sLLVector3()
41 {
42 }
43
44 public sLLVector3(Vector3 v)
45 {
46 x = v.X;
47 y = v.Y;
48 z = v.Z;
49 }
50 }
51} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index ef49205..569dc8d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -97,6 +97,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
97 /// </summary> 97 /// </summary>
98 public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector 98 public class LLClientView : IClientAPI, IClientCore, IClientIM, IClientChat, IClientIPEndpoint, IStatsCollector
99 { 99 {
100 /// <value>
101 /// Debug packet level. At the moment, only 255 does anything (prints out all in and out packets).
102 /// </value>
103 protected int m_debugPacketLevel = 0;
104
100 #region Events 105 #region Events
101 106
102 public event GenericMessage OnGenericMessage; 107 public event GenericMessage OnGenericMessage;
@@ -472,6 +477,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
472 477
473 public void SetDebugPacketLevel(int newDebug) 478 public void SetDebugPacketLevel(int newDebug)
474 { 479 {
480 m_debugPacketLevel = newDebug;
475 } 481 }
476 482
477 #region Client Methods 483 #region Client Methods
@@ -10952,7 +10958,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10952 LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length); 10958 LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
10953 #endregion BinaryStats 10959 #endregion BinaryStats
10954 10960
10955 m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true); 10961 OutPacket(packet, throttlePacketType, true);
10956 } 10962 }
10957 10963
10958 /// <summary> 10964 /// <summary>
@@ -10965,6 +10971,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10965 /// handles splitting manually</param> 10971 /// handles splitting manually</param>
10966 protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting) 10972 protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
10967 { 10973 {
10974 if (m_debugPacketLevel >= 255)
10975 m_log.DebugFormat("[CLIENT]: Packet OUT {0}", packet.Type);
10976
10968 m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting); 10977 m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting);
10969 } 10978 }
10970 10979
@@ -11036,10 +11045,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11036 /// <param name="Pack">OpenMetaverse.packet</param> 11045 /// <param name="Pack">OpenMetaverse.packet</param>
11037 public void ProcessInPacket(Packet Pack) 11046 public void ProcessInPacket(Packet Pack)
11038 { 11047 {
11039// m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack); 11048 if (m_debugPacketLevel >= 255)
11049 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type);
11040 11050
11041 if (!ProcessPacketMethod(Pack)) 11051 if (!ProcessPacketMethod(Pack))
11042 m_log.Warn("[CLIENT]: unhandled packet " + Pack); 11052 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type);
11043 11053
11044 PacketPool.Instance.ReturnPacket(Pack); 11054 PacketPool.Instance.ReturnPacket(Pack);
11045 } 11055 }
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index e0df288..0fc467b 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -411,6 +411,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
411 /// <summary> 411 /// <summary>
412 /// Rez an object into the scene from the user's inventory 412 /// Rez an object into the scene from the user's inventory
413 /// </summary> 413 /// </summary>
414 /// FIXME: It would be really nice if inventory access modules didn't also actually do the work of rezzing
415 /// things to the scene. The caller should be doing that, I think.
414 /// <param name="remoteClient"></param> 416 /// <param name="remoteClient"></param>
415 /// <param name="itemID"></param> 417 /// <param name="itemID"></param>
416 /// <param name="RayEnd"></param> 418 /// <param name="RayEnd"></param>
@@ -500,13 +502,17 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
500 group.RootPart.IsAttachment = true; 502 group.RootPart.IsAttachment = true;
501 } 503 }
502 504
503 m_Scene.AddNewSceneObject(group, true); 505 // For attachments, we must make sure that only a single object update occurs after we've finished
506 // all the necessary operations.
507 m_Scene.AddNewSceneObject(group, true, false);
504 508
505 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); 509 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
506 // if attachment we set it's asset id so object updates can reflect that 510 // if attachment we set it's asset id so object updates can reflect that
507 // if not, we set it's position in world. 511 // if not, we set it's position in world.
508 if (!attachment) 512 if (!attachment)
509 { 513 {
514 group.ScheduleGroupForFullUpdate();
515
510 float offsetHeight = 0; 516 float offsetHeight = 0;
511 pos = m_Scene.GetNewRezLocation( 517 pos = m_Scene.GetNewRezLocation(
512 RayStart, RayEnd, RayTargetID, Quaternion.Identity, 518 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
@@ -562,6 +568,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
562 part.GroupMask = 0; // DO NOT propagate here 568 part.GroupMask = 0; // DO NOT propagate here
563 } 569 }
564 } 570 }
571
565 group.ApplyNextOwnerPermissions(); 572 group.ApplyNextOwnerPermissions();
566 } 573 }
567 } 574 }
@@ -569,7 +576,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
569 foreach (SceneObjectPart part in partList) 576 foreach (SceneObjectPart part in partList)
570 { 577 {
571 if (part.OwnerID != item.Owner) 578 if (part.OwnerID != item.Owner)
572 { 579 {
573 part.LastOwnerID = part.OwnerID; 580 part.LastOwnerID = part.OwnerID;
574 part.OwnerID = item.Owner; 581 part.OwnerID = item.Owner;
575 part.Inventory.ChangeInventoryOwner(item.Owner); 582 part.Inventory.ChangeInventoryOwner(item.Owner);
@@ -591,10 +598,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
591 { 598 {
592 group.ClearPartAttachmentData(); 599 group.ClearPartAttachmentData();
593 } 600 }
594 } 601
595
596 if (!attachment)
597 {
598 // Fire on_rez 602 // Fire on_rez
599 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 0); 603 group.CreateScriptInstances(0, true, m_Scene.DefaultScriptEngine, 0);
600 604
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 6df25d6..5f3cd8c 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1842,9 +1842,18 @@ namespace OpenSim.Region.Framework.Scenes
1842 EventManager.TriggerOnAttach(localID, itemID, avatarID); 1842 EventManager.TriggerOnAttach(localID, itemID, avatarID);
1843 } 1843 }
1844 1844
1845 public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, 1845 /// <summary>
1846 uint AttachmentPt) 1846 /// Called when the client receives a request to rez a single attachment on to the avatar from inventory
1847 /// (RezSingleAttachmentFromInv packet).
1848 /// </summary>
1849 /// <param name="remoteClient"></param>
1850 /// <param name="itemID"></param>
1851 /// <param name="AttachmentPt"></param>
1852 /// <returns></returns>
1853 public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
1847 { 1854 {
1855 m_log.DebugFormat("[USER INVENTORY]: Rezzing single attachment from item {0} for {1}", itemID, remoteClient.Name);
1856
1848 SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt); 1857 SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt);
1849 1858
1850 if (att == null) 1859 if (att == null)
@@ -1856,9 +1865,20 @@ namespace OpenSim.Region.Framework.Scenes
1856 return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt); 1865 return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt);
1857 } 1866 }
1858 1867
1859 public UUID RezSingleAttachment(SceneObjectGroup att, 1868 /// <summary>
1860 IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 1869 /// Update the user inventory to reflect an attachment
1870 /// </summary>
1871 /// <param name="att"></param>
1872 /// <param name="remoteClient"></param>
1873 /// <param name="itemID"></param>
1874 /// <param name="AttachmentPt"></param>
1875 /// <returns></returns>
1876 public UUID RezSingleAttachment(SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
1861 { 1877 {
1878 m_log.DebugFormat(
1879 "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})",
1880 remoteClient.Name, att.Name, itemID);
1881
1862 if (!att.IsDeleted) 1882 if (!att.IsDeleted)
1863 AttachmentPt = att.RootPart.AttachmentPoint; 1883 AttachmentPt = att.RootPart.AttachmentPoint;
1864 1884
@@ -1897,8 +1917,19 @@ namespace OpenSim.Region.Framework.Scenes
1897 return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent); 1917 return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent);
1898 } 1918 }
1899 1919
1920 /// <summary>
1921 /// This registers the item as attached in a user's inventory
1922 /// </summary>
1923 /// <param name="remoteClient"></param>
1924 /// <param name="AttachmentPt"></param>
1925 /// <param name="itemID"></param>
1926 /// <param name="att"></param>
1900 public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) 1927 public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att)
1901 { 1928 {
1929// m_log.DebugFormat(
1930// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
1931// att.Name, remoteClient.Name, AttachmentPt, itemID);
1932
1902 if (UUID.Zero == itemID) 1933 if (UUID.Zero == itemID)
1903 { 1934 {
1904 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID."); 1935 m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID.");
@@ -1926,10 +1957,7 @@ namespace OpenSim.Region.Framework.Scenes
1926 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */); 1957 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
1927 1958
1928 if (m_AvatarFactory != null) 1959 if (m_AvatarFactory != null)
1929 {
1930 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); 1960 m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
1931 }
1932
1933 } 1961 }
1934 } 1962 }
1935 1963
@@ -2012,6 +2040,7 @@ namespace OpenSim.Region.Framework.Scenes
2012 { 2040 {
2013 sog.SetOwnerId(ownerID); 2041 sog.SetOwnerId(ownerID);
2014 sog.SetGroup(groupID, remoteClient); 2042 sog.SetGroup(groupID, remoteClient);
2043 sog.ScheduleGroupForFullUpdate();
2015 2044
2016 foreach (SceneObjectPart child in sog.Children.Values) 2045 foreach (SceneObjectPart child in sog.Children.Values)
2017 child.Inventory.ChangeInventoryOwner(ownerID); 2046 child.Inventory.ChangeInventoryOwner(ownerID);
@@ -2033,6 +2062,7 @@ namespace OpenSim.Region.Framework.Scenes
2033 sog.SetOwnerId(groupID); 2062 sog.SetOwnerId(groupID);
2034 sog.ApplyNextOwnerPermissions(); 2063 sog.ApplyNextOwnerPermissions();
2035 } 2064 }
2065
2036 } 2066 }
2037 2067
2038 foreach (uint localID in localIDs) 2068 foreach (uint localID in localIDs)
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 5e5a52e..a880fe7 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1906,14 +1906,22 @@ namespace OpenSim.Region.Framework.Scenes
1906 //m_log.DebugFormat( 1906 //m_log.DebugFormat(
1907 // "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName); 1907 // "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);
1908 1908
1909 SceneObjectGroup sceneObject = null;
1910
1909 // If an entity creator has been registered for this prim type then use that 1911 // If an entity creator has been registered for this prim type then use that
1910 if (m_entityCreators.ContainsKey((PCode)shape.PCode)) 1912 if (m_entityCreators.ContainsKey((PCode)shape.PCode))
1911 return m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape); 1913 {
1914 sceneObject = m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape);
1915 }
1916 else
1917 {
1918 // Otherwise, use this default creation code;
1919 sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
1920 AddNewSceneObject(sceneObject, true);
1921 sceneObject.SetGroup(groupID, null);
1922 }
1912 1923
1913 // Otherwise, use this default creation code; 1924 sceneObject.ScheduleGroupForFullUpdate();
1914 SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
1915 AddNewSceneObject(sceneObject, true);
1916 sceneObject.SetGroup(groupID, null);
1917 1925
1918 return sceneObject; 1926 return sceneObject;
1919 } 1927 }
@@ -1941,7 +1949,7 @@ namespace OpenSim.Region.Framework.Scenes
1941 } 1949 }
1942 1950
1943 /// <summary> 1951 /// <summary>
1944 /// Add a newly created object to the scene 1952 /// Add a newly created object to the scene. Updates are also sent to viewers.
1945 /// </summary> 1953 /// </summary>
1946 /// <param name="sceneObject"></param> 1954 /// <param name="sceneObject"></param>
1947 /// <param name="attachToBackup"> 1955 /// <param name="attachToBackup">
@@ -1950,8 +1958,25 @@ namespace OpenSim.Region.Framework.Scenes
1950 /// </param> 1958 /// </param>
1951 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) 1959 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup)
1952 { 1960 {
1953 return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup); 1961 return AddNewSceneObject(sceneObject, attachToBackup, true);
1954 } 1962 }
1963
1964 /// <summary>
1965 /// Add a newly created object to the scene
1966 /// </summary>
1967 /// <param name="sceneObject"></param>
1968 /// <param name="attachToBackup">
1969 /// If true, the object is made persistent into the scene.
1970 /// If false, the object will not persist over server restarts
1971 /// </param>
1972 /// <param name="sendClientUpdates">
1973 /// If true, updates for the new scene object are sent to all viewers in range.
1974 /// If false, it is left to the caller to schedule the update
1975 /// </param>
1976 public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
1977 {
1978 return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates);
1979 }
1955 1980
1956 /// <summary> 1981 /// <summary>
1957 /// Delete every object from the scene 1982 /// Delete every object from the scene
@@ -3143,7 +3168,6 @@ namespace OpenSim.Region.Framework.Scenes
3143 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3168 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3144 m_sceneGridService.KiPrimitive += SendKillObject; 3169 m_sceneGridService.KiPrimitive += SendKillObject;
3145 m_sceneGridService.OnGetLandData += GetLandData; 3170 m_sceneGridService.OnGetLandData += GetLandData;
3146
3147 } 3171 }
3148 3172
3149 /// <summary> 3173 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index e87f7ca..bd8ccce 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -103,15 +103,15 @@ namespace OpenSim.Region.Framework.Scenes
103 /// </summary> 103 /// </summary>
104 public event GetLandData OnGetLandData; 104 public event GetLandData OnGetLandData;
105 105
106 private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; 106// private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
107 private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; 107// private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
108 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; 108// private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
109 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 109// private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
110 //private RegionUp handlerRegionUp = null; // OnRegionUp; 110 //private RegionUp handlerRegionUp = null; // OnRegionUp;
111 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; 111// private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
112 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; 112 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
113 private LogOffUser handlerLogOffUser = null; 113// private LogOffUser handlerLogOffUser = null;
114 private GetLandData handlerGetLandData = null; // OnGetLandData 114// private GetLandData handlerGetLandData = null; // OnGetLandData
115 115
116 public KiPrimitiveDelegate KiPrimitive; 116 public KiPrimitiveDelegate KiPrimitive;
117 117
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 369552f..22613e9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -229,7 +229,7 @@ namespace OpenSim.Region.Framework.Scenes
229 sceneObject.HasGroupChanged = true; 229 sceneObject.HasGroupChanged = true;
230 } 230 }
231 231
232 return AddSceneObject(sceneObject, attachToBackup); 232 return AddSceneObject(sceneObject, attachToBackup, true);
233 } 233 }
234 234
235 /// <summary> 235 /// <summary>
@@ -244,12 +244,12 @@ namespace OpenSim.Region.Framework.Scenes
244 /// <returns> 244 /// <returns>
245 /// true if the object was added, false if an object with the same uuid was already in the scene 245 /// true if the object was added, false if an object with the same uuid was already in the scene
246 /// </returns> 246 /// </returns>
247 protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) 247 protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
248 { 248 {
249 // Ensure that we persist this new scene object 249 // Ensure that we persist this new scene object
250 sceneObject.HasGroupChanged = true; 250 sceneObject.HasGroupChanged = true;
251 251
252 return AddSceneObject(sceneObject, attachToBackup); 252 return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates);
253 } 253 }
254 254
255 /// <summary> 255 /// <summary>
@@ -261,12 +261,19 @@ namespace OpenSim.Region.Framework.Scenes
261 /// If true, the object is made persistent into the scene. 261 /// If true, the object is made persistent into the scene.
262 /// If false, the object will not persist over server restarts 262 /// If false, the object will not persist over server restarts
263 /// </param> 263 /// </param>
264 /// <returns>true if the object was added, false if an object with the same uuid was already in the scene 264 /// <param name="sendClientUpdates">
265 /// If true, updates for the new scene object are sent to all viewers in range.
266 /// If false, it is left to the caller to schedule the update
267 /// </param>
268 /// <returns>
269 /// true if the object was added, false if an object with the same uuid was already in the scene
265 /// </returns> 270 /// </returns>
266 protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) 271 protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates)
267 { 272 {
268 if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero) 273 if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero)
269 return false; 274 return false;
275
276 bool alreadyExisted = false;
270 277
271 if (m_parentScene.m_clampPrimSize) 278 if (m_parentScene.m_clampPrimSize)
272 { 279 {
@@ -287,6 +294,9 @@ namespace OpenSim.Region.Framework.Scenes
287 294
288 sceneObject.AttachToScene(m_parentScene); 295 sceneObject.AttachToScene(m_parentScene);
289 296
297 if (sendClientUpdates)
298 sceneObject.ScheduleGroupForFullUpdate();
299
290 lock (sceneObject) 300 lock (sceneObject)
291 { 301 {
292 if (!Entities.ContainsKey(sceneObject.UUID)) 302 if (!Entities.ContainsKey(sceneObject.UUID))
@@ -310,12 +320,14 @@ namespace OpenSim.Region.Framework.Scenes
310 SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; 320 SceneObjectGroupsByLocalID[part.LocalId] = sceneObject;
311 } 321 }
312 } 322 }
313 323 }
314 return true; 324 else
325 {
326 alreadyExisted = true;
315 } 327 }
316 } 328 }
317 329
318 return false; 330 return alreadyExisted;
319 } 331 }
320 332
321 /// <summary> 333 /// <summary>
@@ -525,7 +537,10 @@ namespace OpenSim.Region.Framework.Scenes
525 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 537 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
526 false, false, remoteClient.AgentId, true); 538 false, false, remoteClient.AgentId, true);
527 539
528 540// m_log.DebugFormat(
541// "[SCENE GRAPH]: Retrieved single object {0} for attachment to {1} on point {2}",
542// objatt.Name, remoteClient.Name, AttachmentPt);
543
529 if (objatt != null) 544 if (objatt != null)
530 { 545 {
531 bool tainted = false; 546 bool tainted = false;
@@ -533,16 +548,27 @@ namespace OpenSim.Region.Framework.Scenes
533 tainted = true; 548 tainted = true;
534 549
535 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false); 550 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
536 objatt.ScheduleGroupForFullUpdate(); 551 //objatt.ScheduleGroupForFullUpdate();
537 if (tainted) 552 if (tainted)
538 objatt.HasGroupChanged = true; 553 objatt.HasGroupChanged = true;
539 554
540 // Fire after attach, so we don't get messy perms dialogs 555 // Fire after attach, so we don't get messy perms dialogs
541 // 3 == AttachedRez 556 // 3 == AttachedRez
542 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); 557 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
558
559 // Do this last so that event listeners have access to all the effects of the attachment
560 m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
543 } 561 }
562 else
563 {
564 m_log.WarnFormat(
565 "[SCENE GRAPH]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
566 itemID, remoteClient.Name, AttachmentPt);
567 }
568
544 return objatt; 569 return objatt;
545 } 570 }
571
546 return null; 572 return null;
547 } 573 }
548 574
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index 6395d98..680c39a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -422,7 +422,7 @@ namespace OpenSim.Region.Framework.Scenes
422 422
423 if (!scenePresence.IsChildAgent) 423 if (!scenePresence.IsChildAgent)
424 { 424 {
425 m_log.ErrorFormat("Packet debug for {0} {1} set to {2}", 425 m_log.DebugFormat("Packet debug for {0} {1} set to {2}",
426 scenePresence.Firstname, 426 scenePresence.Firstname,
427 scenePresence.Lastname, 427 scenePresence.Lastname,
428 newDebug); 428 newDebug);
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index c5a6171..37b4fd6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -417,8 +417,8 @@ namespace OpenSim.Region.Framework.Scenes
417 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); 417 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
418 public List<SceneObjectPart> PlaySoundSlavePrims 418 public List<SceneObjectPart> PlaySoundSlavePrims
419 { 419 {
420 get { return m_LoopSoundSlavePrims; } 420 get { return m_PlaySoundSlavePrims; }
421 set { m_LoopSoundSlavePrims = value; } 421 set { m_PlaySoundSlavePrims = value; }
422 } 422 }
423 423
424 private SceneObjectPart m_LoopSoundMasterPrim = null; 424 private SceneObjectPart m_LoopSoundMasterPrim = null;
@@ -567,8 +567,10 @@ namespace OpenSim.Region.Framework.Scenes
567 } 567 }
568 568
569 ApplyPhysics(m_scene.m_physicalPrim); 569 ApplyPhysics(m_scene.m_physicalPrim);
570 570
571 ScheduleGroupForFullUpdate(); 571 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
572 // for the same object with very different properties. The caller must schedule the update.
573 //ScheduleGroupForFullUpdate();
572 } 574 }
573 575
574 public Vector3 GroupScale() 576 public Vector3 GroupScale()
@@ -956,10 +958,11 @@ namespace OpenSim.Region.Framework.Scenes
956 // don't attach attachments to child agents 958 // don't attach attachments to child agents
957 if (avatar.IsChildAgent) return; 959 if (avatar.IsChildAgent) return;
958 960
961// m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
962
959 DetachFromBackup(); 963 DetachFromBackup();
960 964
961 // Remove from database and parcel prim count 965 // Remove from database and parcel prim count
962 //
963 m_scene.DeleteFromStorage(UUID); 966 m_scene.DeleteFromStorage(UUID);
964 m_scene.EventManager.TriggerParcelPrimCountTainted(); 967 m_scene.EventManager.TriggerParcelPrimCountTainted();
965 968
@@ -985,7 +988,6 @@ namespace OpenSim.Region.Framework.Scenes
985 SetAttachmentPoint(Convert.ToByte(attachmentpoint)); 988 SetAttachmentPoint(Convert.ToByte(attachmentpoint));
986 989
987 avatar.AddAttachment(this); 990 avatar.AddAttachment(this);
988 m_log.Debug("[SOG]: Added attachment " + UUID + " to avatar " + avatar.UUID);
989 991
990 if (!silent) 992 if (!silent)
991 { 993 {
@@ -1002,6 +1004,12 @@ namespace OpenSim.Region.Framework.Scenes
1002 ScheduleGroupForFullUpdate(); 1004 ScheduleGroupForFullUpdate();
1003 } 1005 }
1004 } 1006 }
1007 else
1008 {
1009 m_log.WarnFormat(
1010 "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present",
1011 UUID, agentID, Scene.RegionInfo.RegionName);
1012 }
1005 } 1013 }
1006 1014
1007 public byte GetAttachmentPoint() 1015 public byte GetAttachmentPoint()
@@ -1482,51 +1490,22 @@ namespace OpenSim.Region.Framework.Scenes
1482 1490
1483 #endregion 1491 #endregion
1484 1492
1485 #region Client Updating
1486
1487 public void SendFullUpdateToClient(IClientAPI remoteClient) 1493 public void SendFullUpdateToClient(IClientAPI remoteClient)
1488 { 1494 {
1489 SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); 1495 RootPart.SendFullUpdate(
1496 remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID));
1490 1497
1491 lock (m_parts) 1498 lock (m_parts)
1492 { 1499 {
1493 foreach (SceneObjectPart part in m_parts.Values) 1500 foreach (SceneObjectPart part in m_parts.Values)
1494 { 1501 {
1495 if (part != RootPart) 1502 if (part != RootPart)
1496 SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); 1503 part.SendFullUpdate(
1497 } 1504 remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID));
1498 }
1499 }
1500
1501 /// <summary>
1502 /// Send a full update to the client for the given part
1503 /// </summary>
1504 /// <param name="remoteClient"></param>
1505 /// <param name="part"></param>
1506 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
1507 {
1508// m_log.DebugFormat(
1509// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
1510
1511 if (m_rootPart.UUID == part.UUID)
1512 {
1513 if (IsAttachment)
1514 {
1515 part.SendFullUpdateToClient(remoteClient, m_rootPart.AttachedPos, clientFlags);
1516 }
1517 else
1518 {
1519 part.SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags);
1520 } 1505 }
1521 } 1506 }
1522 else
1523 {
1524 part.SendFullUpdateToClient(remoteClient, clientFlags);
1525 }
1526 } 1507 }
1527 1508
1528 #endregion
1529
1530 #region Copying 1509 #region Copying
1531 1510
1532 /// <summary> 1511 /// <summary>
@@ -1986,6 +1965,8 @@ namespace OpenSim.Region.Framework.Scenes
1986 1965
1987 public void ScheduleFullUpdateToAvatar(ScenePresence presence) 1966 public void ScheduleFullUpdateToAvatar(ScenePresence presence)
1988 { 1967 {
1968// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name);
1969
1989 RootPart.AddFullUpdateToAvatar(presence); 1970 RootPart.AddFullUpdateToAvatar(presence);
1990 1971
1991 lock (m_parts) 1972 lock (m_parts)
@@ -2000,6 +1981,8 @@ namespace OpenSim.Region.Framework.Scenes
2000 1981
2001 public void ScheduleTerseUpdateToAvatar(ScenePresence presence) 1982 public void ScheduleTerseUpdateToAvatar(ScenePresence presence)
2002 { 1983 {
1984// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1} just to avatar {2}", Name, UUID, presence.Name);
1985
2003 lock (m_parts) 1986 lock (m_parts)
2004 { 1987 {
2005 foreach (SceneObjectPart part in m_parts.Values) 1988 foreach (SceneObjectPart part in m_parts.Values)
@@ -2014,6 +1997,8 @@ namespace OpenSim.Region.Framework.Scenes
2014 /// </summary> 1997 /// </summary>
2015 public void ScheduleGroupForFullUpdate() 1998 public void ScheduleGroupForFullUpdate()
2016 { 1999 {
2000// m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID);
2001
2017 checkAtTargets(); 2002 checkAtTargets();
2018 RootPart.ScheduleFullUpdate(); 2003 RootPart.ScheduleFullUpdate();
2019 2004
@@ -2032,6 +2017,8 @@ namespace OpenSim.Region.Framework.Scenes
2032 /// </summary> 2017 /// </summary>
2033 public void ScheduleGroupForTerseUpdate() 2018 public void ScheduleGroupForTerseUpdate()
2034 { 2019 {
2020// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID);
2021
2035 lock (m_parts) 2022 lock (m_parts)
2036 { 2023 {
2037 foreach (SceneObjectPart part in m_parts.Values) 2024 foreach (SceneObjectPart part in m_parts.Values)
@@ -2045,9 +2032,11 @@ namespace OpenSim.Region.Framework.Scenes
2045 /// Immediately send a full update for this scene object. 2032 /// Immediately send a full update for this scene object.
2046 /// </summary> 2033 /// </summary>
2047 public void SendGroupFullUpdate() 2034 public void SendGroupFullUpdate()
2048 { 2035 {
2049 if (IsDeleted) 2036 if (IsDeleted)
2050 return; 2037 return;
2038
2039// m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID);
2051 2040
2052 RootPart.SendFullUpdateToAllClients(); 2041 RootPart.SendFullUpdateToAllClients();
2053 2042
@@ -2064,7 +2053,7 @@ namespace OpenSim.Region.Framework.Scenes
2064 /// <summary> 2053 /// <summary>
2065 /// Immediately send an update for this scene object's root prim only. 2054 /// Immediately send an update for this scene object's root prim only.
2066 /// This is for updates regarding the object as a whole, and none of its parts in particular. 2055 /// This is for updates regarding the object as a whole, and none of its parts in particular.
2067 /// Note: this may not be cused by opensim (it probably should) but it's used by 2056 /// Note: this may not be used by opensim (it probably should) but it's used by
2068 /// external modules. 2057 /// external modules.
2069 /// </summary> 2058 /// </summary>
2070 public void SendGroupRootTerseUpdate() 2059 public void SendGroupRootTerseUpdate()
@@ -2079,6 +2068,7 @@ namespace OpenSim.Region.Framework.Scenes
2079 { 2068 {
2080 if (m_scene == null) // Need to check here as it's null during object creation 2069 if (m_scene == null) // Need to check here as it's null during object creation
2081 return; 2070 return;
2071
2082 m_scene.SceneGraph.AddToUpdateList(this); 2072 m_scene.SceneGraph.AddToUpdateList(this);
2083 } 2073 }
2084 2074
@@ -3557,7 +3547,9 @@ namespace OpenSim.Region.Framework.Scenes
3557 HasGroupChanged = true; 3547 HasGroupChanged = true;
3558 } 3548 }
3559 3549
3560 ScheduleGroupForFullUpdate(); 3550 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
3551 // for the same object with very different properties. The caller must schedule the update.
3552 //ScheduleGroupForFullUpdate();
3561 } 3553 }
3562 3554
3563 public void TriggerScriptChangedEvent(Changed val) 3555 public void TriggerScriptChangedEvent(Changed val)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 5c283bc..10a186e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -568,8 +568,8 @@ namespace OpenSim.Region.Framework.Scenes
568 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); 568 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
569 public List<SceneObjectPart> PlaySoundSlavePrims 569 public List<SceneObjectPart> PlaySoundSlavePrims
570 { 570 {
571 get { return m_LoopSoundSlavePrims; } 571 get { return m_PlaySoundSlavePrims; }
572 set { m_LoopSoundSlavePrims = value; } 572 set { m_PlaySoundSlavePrims = value; }
573 } 573 }
574 574
575 private SceneObjectPart m_LoopSoundMasterPrim = null; 575 private SceneObjectPart m_LoopSoundMasterPrim = null;
@@ -2834,29 +2834,59 @@ namespace OpenSim.Region.Framework.Scenes
2834 } 2834 }
2835 } 2835 }
2836 2836
2837// /// <summary>
2838// ///
2839// /// </summary>
2840// /// <param name="remoteClient"></param>
2841// public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
2842// {
2843// m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags);
2844// }
2845
2846
2837 /// <summary> 2847 /// <summary>
2838 /// 2848 /// Send a full update to the client for the given part
2839 /// </summary> 2849 /// </summary>
2840 /// <param name="remoteClient"></param> 2850 /// <param name="remoteClient"></param>
2841 public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags) 2851 /// <param name="clientFlags"></param>
2852 protected internal void SendFullUpdate(IClientAPI remoteClient, uint clientFlags)
2842 { 2853 {
2843 m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags); 2854// m_log.DebugFormat(
2844 } 2855// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
2856
2857 if (IsRoot)
2858 {
2859 if (IsAttachment)
2860 {
2861 SendFullUpdateToClient(remoteClient, AttachedPos, clientFlags);
2862 }
2863 else
2864 {
2865 SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags);
2866 }
2867 }
2868 else
2869 {
2870 SendFullUpdateToClient(remoteClient, clientFlags);
2871 }
2872 }
2845 2873
2846 /// <summary> 2874 /// <summary>
2847 /// 2875 /// Send a full update for this part to all clients.
2848 /// </summary> 2876 /// </summary>
2849 public void SendFullUpdateToAllClients() 2877 public void SendFullUpdateToAllClients()
2850 { 2878 {
2851 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2879 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
2852 for (int i = 0; i < avatars.Length; i++) 2880 for (int i = 0; i < avatars.Length; i++)
2853 { 2881 {
2854 // Ugly reference :( 2882 SendFullUpdate(avatars[i].ControllingClient, avatars[i].GenerateClientFlags(UUID));
2855 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
2856 avatars[i].GenerateClientFlags(UUID));
2857 } 2883 }
2858 } 2884 }
2859 2885
2886 /// <summary>
2887 /// Send a full update to all clients except the one nominated.
2888 /// </summary>
2889 /// <param name="agentID"></param>
2860 public void SendFullUpdateToAllClientsExcept(UUID agentID) 2890 public void SendFullUpdateToAllClientsExcept(UUID agentID)
2861 { 2891 {
2862 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); 2892 ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences();
@@ -2864,10 +2894,7 @@ namespace OpenSim.Region.Framework.Scenes
2864 { 2894 {
2865 // Ugly reference :( 2895 // Ugly reference :(
2866 if (avatars[i].UUID != agentID) 2896 if (avatars[i].UUID != agentID)
2867 { 2897 SendFullUpdate(avatars[i].ControllingClient, avatars[i].GenerateClientFlags(UUID));
2868 m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this,
2869 avatars[i].GenerateClientFlags(UUID));
2870 }
2871 } 2898 }
2872 } 2899 }
2873 2900
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index f83a4d2..465e916 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -830,41 +830,15 @@ namespace OpenSim.Region.Framework.Scenes
830 pos.Y = crossedBorder.BorderLine.Z - 1; 830 pos.Y = crossedBorder.BorderLine.Z - 1;
831 } 831 }
832 832
833 833 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
834 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0)
835 { 834 {
836 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128);
837
838 if (pos.X < 0)
839 {
840 emergencyPos.X = (int)Constants.RegionSize + pos.X;
841 if (!(pos.Y < 0))
842 emergencyPos.Y = pos.Y;
843 if (!(pos.Z < 0))
844 emergencyPos.X = pos.X;
845 }
846 if (pos.Y < 0)
847 {
848 emergencyPos.Y = (int)Constants.RegionSize + pos.Y;
849 if (!(pos.X < 0))
850 emergencyPos.X = pos.X;
851 if (!(pos.Z < 0))
852 emergencyPos.Z = pos.Z;
853 }
854 if (pos.Z < 0)
855 {
856 if (!(pos.X < 0))
857 emergencyPos.X = pos.X;
858 if (!(pos.Y < 0))
859 emergencyPos.Y = pos.Y;
860 //Leave as 128
861 }
862
863 m_log.WarnFormat( 835 m_log.WarnFormat(
864 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", 836 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping",
865 pos, Name, UUID, emergencyPos); 837 pos, Name, UUID);
866 838
867 pos = emergencyPos; 839 if (pos.X < 0f) pos.X = 0f;
840 if (pos.Y < 0f) pos.Y = 0f;
841 if (pos.Z < 0f) pos.Z = 0f;
868 } 842 }
869 843
870 float localAVHeight = 1.56f; 844 float localAVHeight = 1.56f;
@@ -875,7 +849,7 @@ namespace OpenSim.Region.Framework.Scenes
875 849
876 float posZLimit = 0; 850 float posZLimit = 0;
877 851
878 if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize) 852 if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
879 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; 853 posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
880 854
881 float newPosZ = posZLimit + localAVHeight / 2; 855 float newPosZ = posZLimit + localAVHeight / 2;
@@ -2685,7 +2659,12 @@ namespace OpenSim.Region.Framework.Scenes
2685 /// </summary> 2659 /// </summary>
2686 protected void CheckForSignificantMovement() 2660 protected void CheckForSignificantMovement()
2687 { 2661 {
2688 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) 2662 // Movement updates for agents in neighboring regions are sent directly to clients.
2663 // This value only affects how often agent positions are sent to neighbor regions
2664 // for things such as distance-based update prioritization
2665 const float SIGNIFICANT_MOVEMENT = 2.0f;
2666
2667 if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT)
2689 { 2668 {
2690 posLastSignificantMove = AbsolutePosition; 2669 posLastSignificantMove = AbsolutePosition;
2691 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); 2670 m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient);
@@ -2701,13 +2680,13 @@ namespace OpenSim.Region.Framework.Scenes
2701 cadu.AgentID = UUID.Guid; 2680 cadu.AgentID = UUID.Guid;
2702 cadu.alwaysrun = m_setAlwaysRun; 2681 cadu.alwaysrun = m_setAlwaysRun;
2703 cadu.AVHeight = m_avHeight; 2682 cadu.AVHeight = m_avHeight;
2704 sLLVector3 tempCameraCenter = new sLLVector3(new Vector3(m_CameraCenter.X, m_CameraCenter.Y, m_CameraCenter.Z)); 2683 Vector3 tempCameraCenter = m_CameraCenter;
2705 cadu.cameraPosition = tempCameraCenter; 2684 cadu.cameraPosition = tempCameraCenter;
2706 cadu.drawdistance = m_DrawDistance; 2685 cadu.drawdistance = m_DrawDistance;
2707 if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID))) 2686 if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID)))
2708 cadu.godlevel = m_godlevel; 2687 cadu.godlevel = m_godlevel;
2709 cadu.GroupAccess = 0; 2688 cadu.GroupAccess = 0;
2710 cadu.Position = new sLLVector3(AbsolutePosition); 2689 cadu.Position = AbsolutePosition;
2711 cadu.regionHandle = m_rootRegionHandle; 2690 cadu.regionHandle = m_rootRegionHandle;
2712 float multiplier = 1; 2691 float multiplier = 1;
2713 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); 2692 int innacurateNeighbors = m_scene.GetInaccurateNeighborCount();
@@ -2722,7 +2701,7 @@ namespace OpenSim.Region.Framework.Scenes
2722 2701
2723 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); 2702 //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString());
2724 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); 2703 cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier);
2725 cadu.Velocity = new sLLVector3(Velocity); 2704 cadu.Velocity = Velocity;
2726 2705
2727 AgentPosition agentpos = new AgentPosition(); 2706 AgentPosition agentpos = new AgentPosition();
2728 agentpos.CopyFrom(cadu); 2707 agentpos.CopyFrom(cadu);
diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
index 021dcf3..2fc9248 100644
--- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
+++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs
@@ -47,9 +47,9 @@ namespace OpenSim.Services.AuthenticationService
47 public class PasswordAuthenticationService : 47 public class PasswordAuthenticationService :
48 AuthenticationServiceBase, IAuthenticationService 48 AuthenticationServiceBase, IAuthenticationService
49 { 49 {
50 //private static readonly ILog m_log = 50 private static readonly ILog m_log =
51 // LogManager.GetLogger( 51 LogManager.GetLogger(
52 // MethodBase.GetCurrentMethod().DeclaringType); 52 MethodBase.GetCurrentMethod().DeclaringType);
53 53
54 public PasswordAuthenticationService(IConfigSource config) : 54 public PasswordAuthenticationService(IConfigSource config) :
55 base(config) 55 base(config)
@@ -59,23 +59,27 @@ namespace OpenSim.Services.AuthenticationService
59 public string Authenticate(UUID principalID, string password, int lifetime) 59 public string Authenticate(UUID principalID, string password, int lifetime)
60 { 60 {
61 AuthenticationData data = m_Database.Get(principalID); 61 AuthenticationData data = m_Database.Get(principalID);
62 62
63 if (!data.Data.ContainsKey("passwordHash") || 63 if (data != null && data.Data != null)
64 !data.Data.ContainsKey("passwordSalt"))
65 { 64 {
66 return String.Empty; 65 if (!data.Data.ContainsKey("passwordHash") ||
67 } 66 !data.Data.ContainsKey("passwordSalt"))
67 {
68 return String.Empty;
69 }
68 70
69 string hashed = Util.Md5Hash(password + ":" + 71 string hashed = Util.Md5Hash(password + ":" +
70 data.Data["passwordSalt"].ToString()); 72 data.Data["passwordSalt"].ToString());
71 73
72 //m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); 74 //m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString());
73 75
74 if (data.Data["passwordHash"].ToString() == hashed) 76 if (data.Data["passwordHash"].ToString() == hashed)
75 { 77 {
76 return GetToken(principalID, lifetime); 78 return GetToken(principalID, lifetime);
79 }
77 } 80 }
78 81
82 m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
79 return String.Empty; 83 return String.Empty;
80 } 84 }
81 } 85 }
diff --git a/OpenSim/Services/Base/ServiceBase.cs b/OpenSim/Services/Base/ServiceBase.cs
index 8e24d85..91d5c56 100644
--- a/OpenSim/Services/Base/ServiceBase.cs
+++ b/OpenSim/Services/Base/ServiceBase.cs
@@ -26,7 +26,9 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using System.Reflection; 30using System.Reflection;
31using log4net;
30using Nini.Config; 32using Nini.Config;
31using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
32 34
@@ -34,6 +36,8 @@ namespace OpenSim.Services.Base
34{ 36{
35 public class ServiceBase 37 public class ServiceBase
36 { 38 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
37 public T LoadPlugin<T>(string dllName) where T:class 41 public T LoadPlugin<T>(string dllName) where T:class
38 { 42 {
39 return LoadPlugin<T>(dllName, new Object[0]); 43 return LoadPlugin<T>(dllName, new Object[0]);
@@ -61,8 +65,12 @@ namespace OpenSim.Services.Base
61 { 65 {
62 Assembly pluginAssembly = Assembly.LoadFrom(dllName); 66 Assembly pluginAssembly = Assembly.LoadFrom(dllName);
63 67
68// m_log.DebugFormat("[SERVICE BASE]: Found assembly {0}", dllName);
69
64 foreach (Type pluginType in pluginAssembly.GetTypes()) 70 foreach (Type pluginType in pluginAssembly.GetTypes())
65 { 71 {
72// m_log.DebugFormat("[SERVICE BASE]: Found type {0}", pluginType);
73
66 if (pluginType.IsPublic) 74 if (pluginType.IsPublic)
67 { 75 {
68 if (className != String.Empty && 76 if (className != String.Empty &&
@@ -86,7 +94,15 @@ namespace OpenSim.Services.Base
86 } 94 }
87 catch (Exception e) 95 catch (Exception e)
88 { 96 {
89 Console.WriteLine("XXX Exception " + e.StackTrace); 97 List<string> strArgs = new List<string>();
98 foreach (Object arg in args)
99 strArgs.Add(arg.ToString());
100
101 m_log.Error(
102 string.Format(
103 "[SERVICE BASE]: Failed to load plugin {0} from {1} with args {2}",
104 interfaceName, dllName, string.Join(", ", strArgs.ToArray())), e);
105
90 return null; 106 return null;
91 } 107 }
92 } 108 }
@@ -95,4 +111,4 @@ namespace OpenSim.Services.Base
95 { 111 {
96 } 112 }
97 } 113 }
98} 114} \ No newline at end of file
diff --git a/OpenSim/Services/Friends/FriendsServiceBase.cs b/OpenSim/Services/Friends/FriendsServiceBase.cs
index 9858972..6ab0bff 100644
--- a/OpenSim/Services/Friends/FriendsServiceBase.cs
+++ b/OpenSim/Services/Friends/FriendsServiceBase.cs
@@ -27,13 +27,12 @@
27 27
28using System; 28using System;
29using System.Reflection; 29using System.Reflection;
30using log4net;
30using Nini.Config; 31using Nini.Config;
31using OpenSim.Framework; 32using OpenSim.Framework;
32using OpenSim.Data; 33using OpenSim.Data;
33using OpenSim.Services.Interfaces; 34using OpenSim.Services.Interfaces;
34using OpenSim.Services.Base; 35using OpenSim.Services.Base;
35using Nini.Config;
36using log4net;
37 36
38namespace OpenSim.Services.Friends 37namespace OpenSim.Services.Friends
39{ 38{
@@ -80,7 +79,11 @@ namespace OpenSim.Services.Friends
80 79
81 m_Database = LoadPlugin<IFriendsData>(dllName, new Object[] { connString, realm }); 80 m_Database = LoadPlugin<IFriendsData>(dllName, new Object[] { connString, realm });
82 if (m_Database == null) 81 if (m_Database == null)
83 throw new Exception("Could not find a storage interface in the given module"); 82 {
83 throw new Exception(
84 string.Format(
85 "Could not find a storage interface {0} in the given StorageProvider {1}", "IFriendsData", dllName));
86 }
84 } 87 }
85 } 88 }
86} 89}
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 1d734eb..ee93f73 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -247,6 +247,7 @@ namespace OpenSim.Services.LLLoginService
247 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, friendsList, m_LibraryService, 247 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, friendsList, m_LibraryService,
248 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP); 248 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
249 249
250 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to client.");
250 return response; 251 return response;
251 } 252 }
252 catch (Exception e) 253 catch (Exception e)
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index e498bd5..ca6e44a 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -280,6 +280,15 @@ namespace OpenSim.Services.UserAccountService
280 if (null == account) 280 if (null == account)
281 { 281 {
282 account = new UserAccount(UUID.Zero, firstName, lastName, email); 282 account = new UserAccount(UUID.Zero, firstName, lastName, email);
283 if (account.ServiceURLs == null)
284 {
285 account.ServiceURLs = new Dictionary<string, object>();
286 account.ServiceURLs["HomeURI"] = string.Empty;
287 account.ServiceURLs["GatekeeperURI"] = string.Empty;
288 account.ServiceURLs["InventoryServerURI"] = string.Empty;
289 account.ServiceURLs["AssetServerURI"] = string.Empty;
290 }
291
283 if (StoreUserAccount(account)) 292 if (StoreUserAccount(account))
284 { 293 {
285 bool success = false; 294 bool success = false;