diff options
author | Diva Canto | 2013-07-12 12:54:29 -0700 |
---|---|---|
committer | Diva Canto | 2013-07-12 12:54:29 -0700 |
commit | 3d700bb42c1c376c94146b993b495ebae206ceff (patch) | |
tree | 620dcc1ab30a37b1fe308dfaf5a582d7fa8e296b | |
parent | Changed UploadBakedTextureModule so that it uses the same pattern as the othe... (diff) | |
parent | Enhance NullEstateData to remember stored estate values and return (diff) | |
download | opensim-SC_OLD-3d700bb42c1c376c94146b993b495ebae206ceff.zip opensim-SC_OLD-3d700bb42c1c376c94146b993b495ebae206ceff.tar.gz opensim-SC_OLD-3d700bb42c1c376c94146b993b495ebae206ceff.tar.bz2 opensim-SC_OLD-3d700bb42c1c376c94146b993b495ebae206ceff.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
8 files changed, 313 insertions, 106 deletions
diff --git a/OpenSim/Data/Null/NullEstateData.cs b/OpenSim/Data/Null/NullEstateData.cs index d64136d..1df397d 100755 --- a/OpenSim/Data/Null/NullEstateData.cs +++ b/OpenSim/Data/Null/NullEstateData.cs | |||
@@ -42,6 +42,22 @@ namespace OpenSim.Data.Null | |||
42 | 42 | ||
43 | // private string m_connectionString; | 43 | // private string m_connectionString; |
44 | 44 | ||
45 | private Dictionary<uint, EstateSettings> m_knownEstates = new Dictionary<uint, EstateSettings>(); | ||
46 | private EstateSettings m_estate = null; | ||
47 | |||
48 | private EstateSettings GetEstate() | ||
49 | { | ||
50 | if (m_estate == null) | ||
51 | { | ||
52 | // This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase). | ||
53 | // The estate info is pretty empty so don't try banning anyone. | ||
54 | m_estate = new EstateSettings(); | ||
55 | m_estate.EstateID = 1; | ||
56 | m_estate.OnSave += StoreEstateSettings; | ||
57 | } | ||
58 | return m_estate; | ||
59 | } | ||
60 | |||
45 | protected virtual Assembly Assembly | 61 | protected virtual Assembly Assembly |
46 | { | 62 | { |
47 | get { return GetType().Assembly; } | 63 | get { return GetType().Assembly; } |
@@ -68,21 +84,18 @@ namespace OpenSim.Data.Null | |||
68 | 84 | ||
69 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) | 85 | public EstateSettings LoadEstateSettings(UUID regionID, bool create) |
70 | { | 86 | { |
71 | // This fools the initialization caller into thinking an estate was fetched (a check in OpenSimBase). | 87 | return GetEstate(); |
72 | // The estate info is pretty empty so don't try banning anyone. | ||
73 | EstateSettings oneEstate = new EstateSettings(); | ||
74 | oneEstate.EstateID = 1; | ||
75 | return oneEstate; | ||
76 | } | 88 | } |
77 | 89 | ||
78 | public void StoreEstateSettings(EstateSettings es) | 90 | public void StoreEstateSettings(EstateSettings es) |
79 | { | 91 | { |
92 | m_estate = es; | ||
80 | return; | 93 | return; |
81 | } | 94 | } |
82 | 95 | ||
83 | public EstateSettings LoadEstateSettings(int estateID) | 96 | public EstateSettings LoadEstateSettings(int estateID) |
84 | { | 97 | { |
85 | return new EstateSettings(); | 98 | return GetEstate(); |
86 | } | 99 | } |
87 | 100 | ||
88 | public EstateSettings CreateNewEstate() | 101 | public EstateSettings CreateNewEstate() |
@@ -93,13 +106,14 @@ namespace OpenSim.Data.Null | |||
93 | public List<EstateSettings> LoadEstateSettingsAll() | 106 | public List<EstateSettings> LoadEstateSettingsAll() |
94 | { | 107 | { |
95 | List<EstateSettings> allEstateSettings = new List<EstateSettings>(); | 108 | List<EstateSettings> allEstateSettings = new List<EstateSettings>(); |
96 | allEstateSettings.Add(new EstateSettings()); | 109 | allEstateSettings.Add(GetEstate()); |
97 | return allEstateSettings; | 110 | return allEstateSettings; |
98 | } | 111 | } |
99 | 112 | ||
100 | public List<int> GetEstatesAll() | 113 | public List<int> GetEstatesAll() |
101 | { | 114 | { |
102 | List<int> result = new List<int>(); | 115 | List<int> result = new List<int>(); |
116 | result.Add((int)GetEstate().EstateID); | ||
103 | return result; | 117 | return result; |
104 | } | 118 | } |
105 | 119 | ||
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index ba6cc75..cafe103 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -141,6 +141,11 @@ namespace OpenSim.Framework | |||
141 | public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool; | 141 | public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool; |
142 | public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod; | 142 | public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod; |
143 | 143 | ||
144 | public static bool IsPlatformMono | ||
145 | { | ||
146 | get { return Type.GetType("Mono.Runtime") != null; } | ||
147 | } | ||
148 | |||
144 | /// <summary> | 149 | /// <summary> |
145 | /// Gets the name of the directory where the current running executable | 150 | /// Gets the name of the directory where the current running executable |
146 | /// is located | 151 | /// is located |
@@ -1326,7 +1331,7 @@ namespace OpenSim.Framework | |||
1326 | ru = "OSX/Mono"; | 1331 | ru = "OSX/Mono"; |
1327 | else | 1332 | else |
1328 | { | 1333 | { |
1329 | if (Type.GetType("Mono.Runtime") != null) | 1334 | if (IsPlatformMono) |
1330 | ru = "Win/Mono"; | 1335 | ru = "Win/Mono"; |
1331 | else | 1336 | else |
1332 | ru = "Win/.NET"; | 1337 | ru = "Win/.NET"; |
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index 6793fc8..1a62405 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -419,7 +419,7 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
419 | get { return _reqID; } | 419 | get { return _reqID; } |
420 | set { _reqID = value; } | 420 | set { _reqID = value; } |
421 | } | 421 | } |
422 | public HttpWebRequest Request; | 422 | public WebRequest Request; |
423 | public string ResponseBody; | 423 | public string ResponseBody; |
424 | public List<string> ResponseMetadata; | 424 | public List<string> ResponseMetadata; |
425 | public Dictionary<string, string> ResponseHeaders; | 425 | public Dictionary<string, string> ResponseHeaders; |
@@ -431,18 +431,11 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
431 | SendRequest(); | 431 | SendRequest(); |
432 | } | 432 | } |
433 | 433 | ||
434 | /* | ||
435 | * TODO: More work on the response codes. Right now | ||
436 | * returning 200 for success or 499 for exception | ||
437 | */ | ||
438 | |||
439 | public void SendRequest() | 434 | public void SendRequest() |
440 | { | 435 | { |
441 | HttpWebResponse response = null; | ||
442 | |||
443 | try | 436 | try |
444 | { | 437 | { |
445 | Request = (HttpWebRequest) WebRequest.Create(Url); | 438 | Request = WebRequest.Create(Url); |
446 | Request.Method = HttpMethod; | 439 | Request.Method = HttpMethod; |
447 | Request.ContentType = HttpMIMEType; | 440 | Request.ContentType = HttpMIMEType; |
448 | 441 | ||
@@ -480,14 +473,17 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
480 | } | 473 | } |
481 | } | 474 | } |
482 | 475 | ||
483 | foreach (KeyValuePair<string, string> entry in ResponseHeaders) | 476 | if (ResponseHeaders != null) |
484 | if (entry.Key.ToLower().Equals("user-agent")) | 477 | { |
485 | Request.UserAgent = entry.Value; | 478 | foreach (KeyValuePair<string, string> entry in ResponseHeaders) |
486 | else | 479 | if (entry.Key.ToLower().Equals("user-agent") && Request is HttpWebRequest) |
487 | Request.Headers[entry.Key] = entry.Value; | 480 | ((HttpWebRequest)Request).UserAgent = entry.Value; |
481 | else | ||
482 | Request.Headers[entry.Key] = entry.Value; | ||
483 | } | ||
488 | 484 | ||
489 | // Encode outbound data | 485 | // Encode outbound data |
490 | if (OutboundBody.Length > 0) | 486 | if (OutboundBody != null && OutboundBody.Length > 0) |
491 | { | 487 | { |
492 | byte[] data = Util.UTF8.GetBytes(OutboundBody); | 488 | byte[] data = Util.UTF8.GetBytes(OutboundBody); |
493 | 489 | ||
@@ -510,12 +506,19 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
510 | { | 506 | { |
511 | throw; | 507 | throw; |
512 | } | 508 | } |
513 | response = (HttpWebResponse)e.Response; | 509 | |
510 | HttpWebResponse response = (HttpWebResponse)e.Response; | ||
511 | |||
512 | Status = (int)response.StatusCode; | ||
513 | ResponseBody = response.StatusDescription; | ||
514 | _finished = true; | 514 | _finished = true; |
515 | } | 515 | } |
516 | } | 516 | } |
517 | catch (Exception e) | 517 | catch (Exception e) |
518 | { | 518 | { |
519 | // m_log.Debug( | ||
520 | // string.Format("[SCRIPTS HTTP REQUESTS]: Exception on request to {0} for {1} ", Url, ItemID), e); | ||
521 | |||
519 | Status = (int)OSHttpStatusCode.ClientErrorJoker; | 522 | Status = (int)OSHttpStatusCode.ClientErrorJoker; |
520 | ResponseBody = e.Message; | 523 | ResponseBody = e.Message; |
521 | _finished = true; | 524 | _finished = true; |
@@ -528,33 +531,27 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
528 | 531 | ||
529 | try | 532 | try |
530 | { | 533 | { |
531 | response = (HttpWebResponse)Request.EndGetResponse(ar); | 534 | try |
532 | Status = (int)response.StatusCode; | ||
533 | |||
534 | Stream resStream = response.GetResponseStream(); | ||
535 | StringBuilder sb = new StringBuilder(); | ||
536 | byte[] buf = new byte[8192]; | ||
537 | string tempString = null; | ||
538 | int count = 0; | ||
539 | |||
540 | do | ||
541 | { | 535 | { |
542 | // fill the buffer with data | 536 | response = (HttpWebResponse)Request.EndGetResponse(ar); |
543 | count = resStream.Read(buf, 0, buf.Length); | 537 | } |
544 | 538 | catch (WebException e) | |
545 | // make sure we read some data | 539 | { |
546 | if (count != 0) | 540 | if (e.Status != WebExceptionStatus.ProtocolError) |
547 | { | 541 | { |
548 | // translate from bytes to ASCII text | 542 | throw; |
549 | tempString = Util.UTF8.GetString(buf, 0, count); | ||
550 | |||
551 | // continue building the string | ||
552 | sb.Append(tempString); | ||
553 | } | 543 | } |
554 | } | ||
555 | while (count > 0); // any more data to read? | ||
556 | 544 | ||
557 | ResponseBody = sb.ToString(); | 545 | response = (HttpWebResponse)e.Response; |
546 | } | ||
547 | |||
548 | Status = (int)response.StatusCode; | ||
549 | |||
550 | using (Stream stream = response.GetResponseStream()) | ||
551 | { | ||
552 | StreamReader reader = new StreamReader(stream, Encoding.UTF8); | ||
553 | ResponseBody = reader.ReadToEnd(); | ||
554 | } | ||
558 | } | 555 | } |
559 | catch (Exception e) | 556 | catch (Exception e) |
560 | { | 557 | { |
@@ -587,4 +584,4 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
587 | Request.Abort(); | 584 | Request.Abort(); |
588 | } | 585 | } |
589 | } | 586 | } |
590 | } | 587 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/Tests/ScriptsHttpRequestsTests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/Tests/ScriptsHttpRequestsTests.cs new file mode 100644 index 0000000..e812d81 --- /dev/null +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/Tests/ScriptsHttpRequestsTests.cs | |||
@@ -0,0 +1,198 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Runtime.Serialization; | ||
34 | using System.Text; | ||
35 | using System.Threading; | ||
36 | using log4net.Config; | ||
37 | using NUnit.Framework; | ||
38 | using OpenMetaverse; | ||
39 | using OpenMetaverse.Assets; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Region.CoreModules.Scripting.HttpRequest; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Tests.Common; | ||
44 | using OpenSim.Tests.Common.Mock; | ||
45 | |||
46 | namespace OpenSim.Region.CoreModules.Scripting.HttpRequest.Tests | ||
47 | { | ||
48 | class TestWebRequestCreate : IWebRequestCreate | ||
49 | { | ||
50 | public TestWebRequest NextRequest { get; set; } | ||
51 | |||
52 | public WebRequest Create(Uri uri) | ||
53 | { | ||
54 | // NextRequest.RequestUri = uri; | ||
55 | |||
56 | return NextRequest; | ||
57 | |||
58 | // return new TestWebRequest(new SerializationInfo(typeof(TestWebRequest), new FormatterConverter()), new StreamingContext()); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | class TestWebRequest : WebRequest | ||
63 | { | ||
64 | public override string ContentType { get; set; } | ||
65 | public override string Method { get; set; } | ||
66 | |||
67 | public Func<IAsyncResult, WebResponse> OnEndGetResponse { get; set; } | ||
68 | |||
69 | public TestWebRequest() : base() | ||
70 | { | ||
71 | // Console.WriteLine("created"); | ||
72 | } | ||
73 | |||
74 | // public TestWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext) | ||
75 | // : base(serializationInfo, streamingContext) | ||
76 | // { | ||
77 | // Console.WriteLine("created"); | ||
78 | // } | ||
79 | |||
80 | public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state) | ||
81 | { | ||
82 | // Console.WriteLine("bish"); | ||
83 | TestAsyncResult tasr = new TestAsyncResult(); | ||
84 | callback(tasr); | ||
85 | |||
86 | return tasr; | ||
87 | } | ||
88 | |||
89 | public override WebResponse EndGetResponse(IAsyncResult asyncResult) | ||
90 | { | ||
91 | // Console.WriteLine("bosh"); | ||
92 | return OnEndGetResponse(asyncResult); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | class TestHttpWebResponse : HttpWebResponse | ||
97 | { | ||
98 | public string Response { get; set; } | ||
99 | |||
100 | public TestHttpWebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext) | ||
101 | : base(serializationInfo, streamingContext) {} | ||
102 | |||
103 | public override Stream GetResponseStream() | ||
104 | { | ||
105 | return new MemoryStream(Encoding.UTF8.GetBytes(Response)); | ||
106 | } | ||
107 | } | ||
108 | |||
109 | class TestAsyncResult : IAsyncResult | ||
110 | { | ||
111 | WaitHandle m_wh = new ManualResetEvent(true); | ||
112 | |||
113 | object IAsyncResult.AsyncState | ||
114 | { | ||
115 | get { | ||
116 | throw new System.NotImplementedException (); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | WaitHandle IAsyncResult.AsyncWaitHandle | ||
121 | { | ||
122 | get { return m_wh; } | ||
123 | } | ||
124 | |||
125 | bool IAsyncResult.CompletedSynchronously | ||
126 | { | ||
127 | get { return false; } | ||
128 | } | ||
129 | |||
130 | bool IAsyncResult.IsCompleted | ||
131 | { | ||
132 | get { return true; } | ||
133 | } | ||
134 | } | ||
135 | |||
136 | /// <summary> | ||
137 | /// Test script http request code. | ||
138 | /// </summary> | ||
139 | /// <remarks> | ||
140 | /// This class uses some very hacky workarounds in order to mock HttpWebResponse which are Mono dependent (though | ||
141 | /// alternative code can be written to make this work for Windows). However, the value of being able to | ||
142 | /// regression test this kind of code is very high. | ||
143 | /// </remarks> | ||
144 | [TestFixture] | ||
145 | public class ScriptsHttpRequestsTests : OpenSimTestCase | ||
146 | { | ||
147 | /// <summary> | ||
148 | /// Test what happens when we get a 404 response from a call. | ||
149 | /// </summary> | ||
150 | [Test] | ||
151 | public void Test404Response() | ||
152 | { | ||
153 | TestHelpers.InMethod(); | ||
154 | // TestHelpers.EnableLogging(); | ||
155 | |||
156 | if (!Util.IsPlatformMono) | ||
157 | Assert.Ignore("Ignoring test since can only currently run on Mono"); | ||
158 | |||
159 | string rawResponse = "boom"; | ||
160 | |||
161 | TestWebRequestCreate twrc = new TestWebRequestCreate(); | ||
162 | |||
163 | TestWebRequest twr = new TestWebRequest(); | ||
164 | //twr.OnEndGetResponse += ar => new TestHttpWebResponse(null, new StreamingContext()); | ||
165 | twr.OnEndGetResponse += ar => | ||
166 | { | ||
167 | SerializationInfo si = new SerializationInfo(typeof(HttpWebResponse), new FormatterConverter()); | ||
168 | StreamingContext sc = new StreamingContext(); | ||
169 | // WebHeaderCollection headers = new WebHeaderCollection(); | ||
170 | // si.AddValue("m_HttpResponseHeaders", headers); | ||
171 | si.AddValue("uri", new Uri("test://arrg")); | ||
172 | // si.AddValue("m_Certificate", null); | ||
173 | si.AddValue("version", HttpVersion.Version11); | ||
174 | si.AddValue("statusCode", HttpStatusCode.NotFound); | ||
175 | si.AddValue("contentLength", 0); | ||
176 | si.AddValue("method", "GET"); | ||
177 | si.AddValue("statusDescription", "Not Found"); | ||
178 | si.AddValue("contentType", null); | ||
179 | si.AddValue("cookieCollection", new CookieCollection()); | ||
180 | |||
181 | TestHttpWebResponse thwr = new TestHttpWebResponse(si, sc); | ||
182 | thwr.Response = rawResponse; | ||
183 | |||
184 | throw new WebException("no message", null, WebExceptionStatus.ProtocolError, thwr); | ||
185 | }; | ||
186 | |||
187 | twrc.NextRequest = twr; | ||
188 | |||
189 | WebRequest.RegisterPrefix("test", twrc); | ||
190 | HttpRequestClass hr = new HttpRequestClass(); | ||
191 | hr.Url = "test://something"; | ||
192 | hr.SendRequest(); | ||
193 | |||
194 | Assert.That(hr.Status, Is.EqualTo((int)HttpStatusCode.NotFound)); | ||
195 | Assert.That(hr.ResponseBody, Is.EqualTo(rawResponse)); | ||
196 | } | ||
197 | } | ||
198 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index f361acb..830fe31 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -4213,31 +4213,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4213 | AddToPhysics(UsePhysics, SetPhantom, false); | 4213 | AddToPhysics(UsePhysics, SetPhantom, false); |
4214 | pa = PhysActor; | 4214 | pa = PhysActor; |
4215 | 4215 | ||
4216 | |||
4217 | if (pa != null) | 4216 | if (pa != null) |
4218 | { | 4217 | { |
4219 | pa.SetMaterial(Material); | 4218 | pa.SetMaterial(Material); |
4220 | DoPhysicsPropertyUpdate(UsePhysics, true); | 4219 | DoPhysicsPropertyUpdate(UsePhysics, true); |
4221 | 4220 | ||
4222 | if ( | 4221 | SubscribeForCollisionEvents(); |
4223 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4224 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4225 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4226 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4227 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4228 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4229 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4230 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4231 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4232 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4233 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4234 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4235 | (CollisionSound != UUID.Zero) | ||
4236 | ) | ||
4237 | { | ||
4238 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4239 | pa.SubscribeEvents(1000); | ||
4240 | } | ||
4241 | } | 4222 | } |
4242 | } | 4223 | } |
4243 | else // it already has a physical representation | 4224 | else // it already has a physical representation |
@@ -4291,6 +4272,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
4291 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); | 4272 | // m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); |
4292 | } | 4273 | } |
4293 | 4274 | ||
4275 | // Subscribe for physics collision events if needed for scripts and sounds | ||
4276 | public void SubscribeForCollisionEvents() | ||
4277 | { | ||
4278 | if (PhysActor != null) | ||
4279 | { | ||
4280 | if ( | ||
4281 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4282 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4283 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4284 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4285 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4286 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4287 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4288 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4289 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4290 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4291 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4292 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4293 | (CollisionSound != UUID.Zero) | ||
4294 | ) | ||
4295 | { | ||
4296 | if (!PhysActor.SubscribedEvents()) | ||
4297 | { | ||
4298 | // If not already subscribed for event, set up for a collision event. | ||
4299 | PhysActor.OnCollisionUpdate += PhysicsCollision; | ||
4300 | PhysActor.SubscribeEvents(1000); | ||
4301 | } | ||
4302 | } | ||
4303 | else | ||
4304 | { | ||
4305 | // There is no need to be subscribed to collisions so, if subscribed, remove subscription | ||
4306 | if (PhysActor.SubscribedEvents()) | ||
4307 | { | ||
4308 | PhysActor.OnCollisionUpdate -= PhysicsCollision; | ||
4309 | PhysActor.UnSubscribeEvents(); | ||
4310 | } | ||
4311 | } | ||
4312 | } | ||
4313 | } | ||
4314 | |||
4294 | /// <summary> | 4315 | /// <summary> |
4295 | /// Adds this part to the physics scene. | 4316 | /// Adds this part to the physics scene. |
4296 | /// </summary> | 4317 | /// </summary> |
@@ -4680,39 +4701,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4680 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; | 4701 | objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; |
4681 | } | 4702 | } |
4682 | 4703 | ||
4683 | PhysicsActor pa = PhysActor; | 4704 | SubscribeForCollisionEvents(); |
4684 | |||
4685 | if ( | ||
4686 | ((AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4687 | ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4688 | ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4689 | ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4690 | ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4691 | ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4692 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) || | ||
4693 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) || | ||
4694 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) || | ||
4695 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || | ||
4696 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) || | ||
4697 | ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || | ||
4698 | (CollisionSound != UUID.Zero) | ||
4699 | ) | ||
4700 | { | ||
4701 | // subscribe to physics updates. | ||
4702 | if (pa != null) | ||
4703 | { | ||
4704 | pa.OnCollisionUpdate += PhysicsCollision; | ||
4705 | pa.SubscribeEvents(1000); | ||
4706 | } | ||
4707 | } | ||
4708 | else | ||
4709 | { | ||
4710 | if (pa != null) | ||
4711 | { | ||
4712 | pa.UnSubscribeEvents(); | ||
4713 | pa.OnCollisionUpdate -= PhysicsCollision; | ||
4714 | } | ||
4715 | } | ||
4716 | 4705 | ||
4717 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) | 4706 | //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) |
4718 | //{ | 4707 | //{ |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs index 5714042..b6fb730 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
59 | public void TestChildAgentSingleRegionCapabilities() | 59 | public void TestChildAgentSingleRegionCapabilities() |
60 | { | 60 | { |
61 | TestHelpers.InMethod(); | 61 | TestHelpers.InMethod(); |
62 | TestHelpers.EnableLogging(); | 62 | // TestHelpers.EnableLogging(); |
63 | 63 | ||
64 | UUID spUuid = TestHelpers.ParseTail(0x1); | 64 | UUID spUuid = TestHelpers.ParseTail(0x1); |
65 | 65 | ||
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs index 088eb0f..d8f5563 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs | |||
@@ -139,18 +139,21 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule | |||
139 | { | 139 | { |
140 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | 140 | string capsBase = "/CAPS/" + caps.CapsObjectPath; |
141 | 141 | ||
142 | IRequestHandler renderMaterialsPostHandler = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap); | 142 | IRequestHandler renderMaterialsPostHandler |
143 | = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); | ||
143 | caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); | 144 | caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); |
144 | 145 | ||
145 | // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET | 146 | // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET |
146 | // and POST handlers, (at least at the time this was originally written), so we first set up a POST | 147 | // and POST handlers, (at least at the time this was originally written), so we first set up a POST |
147 | // handler normally and then add a GET handler via MainServer | 148 | // handler normally and then add a GET handler via MainServer |
148 | 149 | ||
149 | IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap); | 150 | IRequestHandler renderMaterialsGetHandler |
151 | = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterials", null); | ||
150 | MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); | 152 | MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); |
151 | 153 | ||
152 | // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well | 154 | // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well |
153 | IRequestHandler renderMaterialsPutHandler = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap); | 155 | IRequestHandler renderMaterialsPutHandler |
156 | = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null); | ||
154 | MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); | 157 | MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); |
155 | } | 158 | } |
156 | 159 | ||
diff --git a/prebuild.xml b/prebuild.xml index c7463e4..91c326c 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -3129,6 +3129,7 @@ | |||
3129 | <Match path="Avatar/Inventory/Transfer/Tests" pattern="*.cs" recurse="true"/> | 3129 | <Match path="Avatar/Inventory/Transfer/Tests" pattern="*.cs" recurse="true"/> |
3130 | <Match path="Framework/InventoryAccess/Tests" pattern="*.cs" recurse="true"/> | 3130 | <Match path="Framework/InventoryAccess/Tests" pattern="*.cs" recurse="true"/> |
3131 | <Match path="Framework/UserManagement/Tests" pattern="*.cs" recurse="true"/> | 3131 | <Match path="Framework/UserManagement/Tests" pattern="*.cs" recurse="true"/> |
3132 | <Match path="Scripting/HttpRequest/Tests" pattern="*.cs" recurse="true"/> | ||
3132 | <Match path="Scripting/VectorRender/Tests" pattern="*.cs" recurse="true"/> | 3133 | <Match path="Scripting/VectorRender/Tests" pattern="*.cs" recurse="true"/> |
3133 | <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true"/> | 3134 | <Match path="World/Archiver/Tests" pattern="*.cs" recurse="true"/> |
3134 | <Match buildAction="EmbeddedResource" path="World/Archiver/Tests/Resources" pattern="*"/> | 3135 | <Match buildAction="EmbeddedResource" path="World/Archiver/Tests/Resources" pattern="*"/> |