diff options
Diffstat (limited to '')
20 files changed, 303 insertions, 104 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2bb60d5..394b90a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -237,7 +237,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
237 | if (sp.PresenceType == PresenceType.Npc) | 237 | if (sp.PresenceType == PresenceType.Npc) |
238 | RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null); | 238 | RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null); |
239 | else | 239 | else |
240 | RezSingleAttachmentFromInventory(sp, attach.ItemID, p, true, d); | 240 | RezSingleAttachmentFromInventory(sp, attach.ItemID, p, d); |
241 | } | 241 | } |
242 | catch (Exception e) | 242 | catch (Exception e) |
243 | { | 243 | { |
@@ -405,10 +405,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
405 | 405 | ||
406 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) | 406 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) |
407 | { | 407 | { |
408 | return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, true, null); | 408 | return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, null); |
409 | } | 409 | } |
410 | 410 | ||
411 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc) | 411 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, XmlDocument doc) |
412 | { | 412 | { |
413 | if (!Enabled) | 413 | if (!Enabled) |
414 | return null; | 414 | return null; |
@@ -596,6 +596,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
596 | /// </remarks> | 596 | /// </remarks> |
597 | /// <param name="sp"></param> | 597 | /// <param name="sp"></param> |
598 | /// <param name="grp"></param> | 598 | /// <param name="grp"></param> |
599 | /// <param name="saveAllScripted"></param> | ||
599 | private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted) | 600 | private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, bool saveAllScripted) |
600 | { | 601 | { |
601 | // Saving attachments for NPCs messes them up for the real owner! | 602 | // Saving attachments for NPCs messes them up for the real owner! |
@@ -789,18 +790,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
789 | null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | 790 | null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, |
790 | false, false, sp.UUID, true); | 791 | false, false, sp.UUID, true); |
791 | 792 | ||
792 | // m_log.DebugFormat( | ||
793 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", | ||
794 | // objatt.Name, remoteClient.Name, AttachmentPt); | ||
795 | |||
796 | if (objatt != null) | 793 | if (objatt != null) |
797 | { | 794 | { |
795 | // m_log.DebugFormat( | ||
796 | // "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}", | ||
797 | // objatt.Name, sp.Name, attachmentPt, m_scene.Name); | ||
798 | |||
798 | // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. | 799 | // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. |
799 | objatt.HasGroupChanged = false; | 800 | objatt.HasGroupChanged = false; |
800 | bool tainted = false; | 801 | bool tainted = false; |
801 | if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) | 802 | if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) |
802 | tainted = true; | 803 | tainted = true; |
803 | 804 | ||
805 | // FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal | ||
806 | // course of events. If not, then it's probably not worth trying to recover the situation | ||
807 | // since this is more likely to trigger further exceptions and confuse later debugging. If | ||
808 | // exceptions can be thrown in expected error conditions (not NREs) then make this consistent | ||
809 | // since other normal error conditions will simply return false instead. | ||
804 | // This will throw if the attachment fails | 810 | // This will throw if the attachment fails |
805 | try | 811 | try |
806 | { | 812 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 8423d43..cd1e1c1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -31,6 +31,7 @@ using System.Reflection; | |||
31 | using System.Text; | 31 | using System.Text; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using System.Timers; | 33 | using System.Timers; |
34 | using System.Xml; | ||
34 | using Timer=System.Timers.Timer; | 35 | using Timer=System.Timers.Timer; |
35 | using Nini.Config; | 36 | using Nini.Config; |
36 | using NUnit.Framework; | 37 | using NUnit.Framework; |
@@ -41,10 +42,12 @@ using OpenSim.Region.CoreModules.Avatar.Attachments; | |||
41 | using OpenSim.Region.CoreModules.Framework; | 42 | using OpenSim.Region.CoreModules.Framework; |
42 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; | 43 | using OpenSim.Region.CoreModules.Framework.EntityTransfer; |
43 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | 44 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; |
44 | using OpenSim.Region.CoreModules.World.Serialiser; | 45 | using OpenSim.Region.CoreModules.Scripting.WorldComm; |
45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | 46 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
47 | using OpenSim.Region.CoreModules.World.Serialiser; | ||
46 | using OpenSim.Region.Framework.Scenes; | 48 | using OpenSim.Region.Framework.Scenes; |
47 | using OpenSim.Region.Framework.Interfaces; | 49 | using OpenSim.Region.Framework.Interfaces; |
50 | using OpenSim.Region.ScriptEngine.XEngine; | ||
48 | using OpenSim.Services.Interfaces; | 51 | using OpenSim.Services.Interfaces; |
49 | using OpenSim.Tests.Common; | 52 | using OpenSim.Tests.Common; |
50 | using OpenSim.Tests.Common.Mock; | 53 | using OpenSim.Tests.Common.Mock; |
@@ -57,6 +60,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
57 | [TestFixture] | 60 | [TestFixture] |
58 | public class AttachmentsModuleTests : OpenSimTestCase | 61 | public class AttachmentsModuleTests : OpenSimTestCase |
59 | { | 62 | { |
63 | private AutoResetEvent m_chatEvent = new AutoResetEvent(false); | ||
64 | private OSChatMessage m_osChatMessageReceived; | ||
65 | |||
60 | [TestFixtureSetUp] | 66 | [TestFixtureSetUp] |
61 | public void FixtureInit() | 67 | public void FixtureInit() |
62 | { | 68 | { |
@@ -72,16 +78,74 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
72 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | 78 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; |
73 | } | 79 | } |
74 | 80 | ||
75 | private Scene CreateDefaultTestScene() | 81 | private void OnChatFromWorld(object sender, OSChatMessage oscm) |
82 | { | ||
83 | // Console.WriteLine("Got chat [{0}]", oscm.Message); | ||
84 | |||
85 | m_osChatMessageReceived = oscm; | ||
86 | m_chatEvent.Set(); | ||
87 | } | ||
88 | |||
89 | private Scene CreateTestScene() | ||
90 | { | ||
91 | IConfigSource config = new IniConfigSource(); | ||
92 | List<object> modules = new List<object>(); | ||
93 | |||
94 | AddCommonConfig(config, modules); | ||
95 | |||
96 | Scene scene | ||
97 | = new SceneHelpers().SetupScene( | ||
98 | "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config); | ||
99 | SceneHelpers.SetupSceneModules(scene, config, modules.ToArray()); | ||
100 | |||
101 | return scene; | ||
102 | } | ||
103 | |||
104 | private Scene CreateScriptingEnabledTestScene() | ||
76 | { | 105 | { |
77 | IConfigSource config = new IniConfigSource(); | 106 | IConfigSource config = new IniConfigSource(); |
107 | List<object> modules = new List<object>(); | ||
108 | |||
109 | AddCommonConfig(config, modules); | ||
110 | AddScriptingConfig(config, modules); | ||
111 | |||
112 | Scene scene | ||
113 | = new SceneHelpers().SetupScene( | ||
114 | "attachments-test-scene", TestHelpers.ParseTail(999), 1000, 1000, config); | ||
115 | SceneHelpers.SetupSceneModules(scene, config, modules.ToArray()); | ||
116 | |||
117 | scene.StartScripts(); | ||
118 | |||
119 | return scene; | ||
120 | } | ||
121 | |||
122 | private void AddCommonConfig(IConfigSource config, List<object> modules) | ||
123 | { | ||
78 | config.AddConfig("Modules"); | 124 | config.AddConfig("Modules"); |
79 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); | 125 | config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); |
80 | 126 | ||
81 | Scene scene = new SceneHelpers().SetupScene(); | 127 | modules.Add(new AttachmentsModule()); |
82 | SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); | 128 | modules.Add(new BasicInventoryAccessModule()); |
129 | } | ||
130 | |||
131 | private void AddScriptingConfig(IConfigSource config, List<object> modules) | ||
132 | { | ||
133 | IConfig startupConfig = config.AddConfig("Startup"); | ||
134 | startupConfig.Set("DefaultScriptEngine", "XEngine"); | ||
135 | |||
136 | IConfig xEngineConfig = config.AddConfig("XEngine"); | ||
137 | xEngineConfig.Set("Enabled", "true"); | ||
138 | xEngineConfig.Set("StartDelay", "0"); | ||
83 | 139 | ||
84 | return scene; | 140 | // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call |
141 | // to AssemblyResolver.OnAssemblyResolve fails. | ||
142 | xEngineConfig.Set("AppDomainLoading", "false"); | ||
143 | |||
144 | modules.Add(new XEngine()); | ||
145 | |||
146 | // Necessary to stop serialization complaining | ||
147 | // FIXME: Stop this being necessary if at all possible | ||
148 | // modules.Add(new WorldCommModule()); | ||
85 | } | 149 | } |
86 | 150 | ||
87 | /// <summary> | 151 | /// <summary> |
@@ -116,7 +180,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
116 | TestHelpers.InMethod(); | 180 | TestHelpers.InMethod(); |
117 | // TestHelpers.EnableLogging(); | 181 | // TestHelpers.EnableLogging(); |
118 | 182 | ||
119 | Scene scene = CreateDefaultTestScene(); | 183 | Scene scene = CreateTestScene(); |
120 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 184 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
121 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | 185 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); |
122 | 186 | ||
@@ -163,7 +227,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
163 | TestHelpers.InMethod(); | 227 | TestHelpers.InMethod(); |
164 | // TestHelpers.EnableLogging(); | 228 | // TestHelpers.EnableLogging(); |
165 | 229 | ||
166 | Scene scene = CreateDefaultTestScene(); | 230 | Scene scene = CreateTestScene(); |
167 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 231 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
168 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | 232 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); |
169 | 233 | ||
@@ -185,12 +249,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
185 | } | 249 | } |
186 | 250 | ||
187 | [Test] | 251 | [Test] |
188 | public void TestAddAttachmentFromInventory() | 252 | public void TestRezAttachmentFromInventory() |
189 | { | 253 | { |
190 | TestHelpers.InMethod(); | 254 | TestHelpers.InMethod(); |
191 | // log4net.Config.XmlConfigurator.Configure(); | 255 | // log4net.Config.XmlConfigurator.Configure(); |
192 | 256 | ||
193 | Scene scene = CreateDefaultTestScene(); | 257 | Scene scene = CreateTestScene(); |
194 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 258 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
195 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | 259 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); |
196 | 260 | ||
@@ -217,13 +281,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
217 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 281 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
218 | } | 282 | } |
219 | 283 | ||
284 | /// <summary> | ||
285 | /// Test specific conditions associated with rezzing a scripted attachment from inventory. | ||
286 | /// </summary> | ||
287 | [Test] | ||
288 | public void TestRezScriptedAttachmentFromInventory() | ||
289 | { | ||
290 | TestHelpers.InMethod(); | ||
291 | |||
292 | Scene scene = CreateTestScene(); | ||
293 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | ||
294 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | ||
295 | |||
296 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); | ||
297 | TaskInventoryHelpers.AddScript(scene, so.RootPart); | ||
298 | InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000); | ||
299 | |||
300 | scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | ||
301 | |||
302 | // TODO: Need to have a test that checks the script is actually started but this involves a lot more | ||
303 | // plumbing of the script engine and either pausing for events or more infrastructure to turn off various | ||
304 | // script engine delays/asychronicity that isn't helpful in an automated regression testing context. | ||
305 | SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.Name); | ||
306 | Assert.That(attSo.ContainsScripts(), Is.True); | ||
307 | } | ||
308 | |||
220 | [Test] | 309 | [Test] |
221 | public void TestDetachAttachmentToGround() | 310 | public void TestDetachAttachmentToGround() |
222 | { | 311 | { |
223 | TestHelpers.InMethod(); | 312 | TestHelpers.InMethod(); |
224 | // log4net.Config.XmlConfigurator.Configure(); | 313 | // log4net.Config.XmlConfigurator.Configure(); |
225 | 314 | ||
226 | Scene scene = CreateDefaultTestScene(); | 315 | Scene scene = CreateTestScene(); |
227 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 316 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
228 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | 317 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); |
229 | 318 | ||
@@ -253,9 +342,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
253 | public void TestDetachAttachmentToInventory() | 342 | public void TestDetachAttachmentToInventory() |
254 | { | 343 | { |
255 | TestHelpers.InMethod(); | 344 | TestHelpers.InMethod(); |
256 | // log4net.Config.XmlConfigurator.Configure(); | ||
257 | 345 | ||
258 | Scene scene = CreateDefaultTestScene(); | 346 | Scene scene = CreateTestScene(); |
259 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 347 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
260 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | 348 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); |
261 | 349 | ||
@@ -278,6 +366,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
278 | } | 366 | } |
279 | 367 | ||
280 | /// <summary> | 368 | /// <summary> |
369 | /// Test specific conditions associated with detaching a scripted attachment from inventory. | ||
370 | /// </summary> | ||
371 | [Test] | ||
372 | public void TestDetachScriptedAttachmentToInventory() | ||
373 | { | ||
374 | TestHelpers.InMethod(); | ||
375 | // TestHelpers.EnableLogging(); | ||
376 | |||
377 | Scene scene = CreateScriptingEnabledTestScene(); | ||
378 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | ||
379 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | ||
380 | |||
381 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, sp.UUID, "att-name", 0x10); | ||
382 | TaskInventoryHelpers.AddScript(scene, so.RootPart); | ||
383 | InventoryItemBase userItem = UserInventoryHelpers.AddInventoryItem(scene, so, 0x100, 0x1000); | ||
384 | |||
385 | // FIXME: Right now, we have to do a tricksy chat listen to make sure we know when the script is running. | ||
386 | // In the future, we need to be able to do this programatically more predicably. | ||
387 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | ||
388 | |||
389 | SceneObjectGroup soRezzed | ||
390 | = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | ||
391 | |||
392 | // Wait for chat to signal rezzed script has been started. | ||
393 | m_chatEvent.WaitOne(60000); | ||
394 | |||
395 | scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, soRezzed); | ||
396 | |||
397 | InventoryItemBase userItemUpdated = scene.InventoryService.GetItem(userItem); | ||
398 | AssetBase asset = scene.AssetService.Get(userItemUpdated.AssetID.ToString()); | ||
399 | |||
400 | XmlDocument soXml = new XmlDocument(); | ||
401 | soXml.LoadXml(Encoding.UTF8.GetString(asset.Data)); | ||
402 | |||
403 | XmlNodeList scriptStateNodes = soXml.GetElementsByTagName("ScriptState"); | ||
404 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); | ||
405 | } | ||
406 | |||
407 | /// <summary> | ||
281 | /// Test that attachments don't hang about in the scene when the agent is closed | 408 | /// Test that attachments don't hang about in the scene when the agent is closed |
282 | /// </summary> | 409 | /// </summary> |
283 | [Test] | 410 | [Test] |
@@ -286,7 +413,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
286 | TestHelpers.InMethod(); | 413 | TestHelpers.InMethod(); |
287 | // log4net.Config.XmlConfigurator.Configure(); | 414 | // log4net.Config.XmlConfigurator.Configure(); |
288 | 415 | ||
289 | Scene scene = CreateDefaultTestScene(); | 416 | Scene scene = CreateTestScene(); |
290 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 417 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
291 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); | 418 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); |
292 | 419 | ||
@@ -309,7 +436,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
309 | TestHelpers.InMethod(); | 436 | TestHelpers.InMethod(); |
310 | // log4net.Config.XmlConfigurator.Configure(); | 437 | // log4net.Config.XmlConfigurator.Configure(); |
311 | 438 | ||
312 | Scene scene = CreateDefaultTestScene(); | 439 | Scene scene = CreateTestScene(); |
313 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 440 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
314 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); | 441 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); |
315 | 442 | ||
@@ -345,7 +472,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
345 | { | 472 | { |
346 | TestHelpers.InMethod(); | 473 | TestHelpers.InMethod(); |
347 | 474 | ||
348 | Scene scene = CreateDefaultTestScene(); | 475 | Scene scene = CreateTestScene(); |
349 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | 476 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
350 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); | 477 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); |
351 | 478 | ||
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs index 2c04008..8c0ef88 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsDearchiver.cs | |||
@@ -46,8 +46,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
46 | { | 46 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 48 | ||
49 | protected static ASCIIEncoding m_asciiEncoding = new ASCIIEncoding(); | ||
50 | |||
51 | /// <summary> | 49 | /// <summary> |
52 | /// Store for asset data we received before we get the metadata | 50 | /// Store for asset data we received before we get the metadata |
53 | /// </summary> | 51 | /// </summary> |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs index 7a0db26..b5c7d33 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
252 | if (horizontalScale < 0.01d) | 252 | if (horizontalScale < 0.01d) |
253 | horizontalScale = 0.01d; | 253 | horizontalScale = 0.01d; |
254 | 254 | ||
255 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | 255 | Encoding enc = Encoding.ASCII; |
256 | 256 | ||
257 | bs.Write(enc.GetBytes("TERRAGENTERRAIN ")); | 257 | bs.Write(enc.GetBytes("TERRAGENTERRAIN ")); |
258 | 258 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index e7b9ba5..410eda0 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | |||
@@ -97,7 +97,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
97 | 97 | ||
98 | // Same as above, but also load script states from a separate doc | 98 | // Same as above, but also load script states from a separate doc |
99 | ISceneEntity RezSingleAttachmentFromInventory( | 99 | ISceneEntity RezSingleAttachmentFromInventory( |
100 | IScenePresence presence, UUID itemID, uint AttachmentPt, bool updateInventoryStatus, XmlDocument doc); | 100 | IScenePresence presence, UUID itemID, uint AttachmentPt, XmlDocument doc); |
101 | 101 | ||
102 | /// <summary> | 102 | /// <summary> |
103 | /// Rez multiple attachments from a user's inventory | 103 | /// Rez multiple attachments from a user's inventory |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index cc7d0fb..33a2cc5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -646,6 +646,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
646 | return; | 646 | return; |
647 | } | 647 | } |
648 | } | 648 | } |
649 | |||
650 | // Restuff the new GroupPosition into each SOP of the linkset. | ||
651 | // This has the affect of resetting and tainting the physics actors. | ||
649 | SceneObjectPart[] parts = m_parts.GetArray(); | 652 | SceneObjectPart[] parts = m_parts.GetArray(); |
650 | bool triggerScriptEvent = m_rootPart.GroupPosition != val; | 653 | bool triggerScriptEvent = m_rootPart.GroupPosition != val; |
651 | if (m_dupeInProgress) | 654 | if (m_dupeInProgress) |
@@ -1755,6 +1758,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1755 | 1758 | ||
1756 | public void ResetChildPrimPhysicsPositions() | 1759 | public void ResetChildPrimPhysicsPositions() |
1757 | { | 1760 | { |
1761 | // Setting this SOG's absolute position also loops through and sets the positions | ||
1762 | // of the SOP's in this SOG's linkset. This has the side affect of making sure | ||
1763 | // the physics world matches the simulated world. | ||
1758 | AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? | 1764 | AbsolutePosition = AbsolutePosition; // could someone in the know please explain how this works? |
1759 | 1765 | ||
1760 | // teravus: AbsolutePosition is NOT a normal property! | 1766 | // teravus: AbsolutePosition is NOT a normal property! |
@@ -2714,6 +2720,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2714 | LinkToGroup(objectGroup, false); | 2720 | LinkToGroup(objectGroup, false); |
2715 | } | 2721 | } |
2716 | 2722 | ||
2723 | // Link an existing group to this group. | ||
2724 | // The group being linked need not be a linkset -- it can have just one prim. | ||
2717 | public void LinkToGroup(SceneObjectGroup objectGroup, bool insert) | 2725 | public void LinkToGroup(SceneObjectGroup objectGroup, bool insert) |
2718 | { | 2726 | { |
2719 | // m_log.DebugFormat( | 2727 | // m_log.DebugFormat( |
@@ -2724,6 +2732,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2724 | if (objectGroup == this) | 2732 | if (objectGroup == this) |
2725 | return; | 2733 | return; |
2726 | 2734 | ||
2735 | // 'linkPart' == the root of the group being linked into this group | ||
2727 | SceneObjectPart linkPart = objectGroup.m_rootPart; | 2736 | SceneObjectPart linkPart = objectGroup.m_rootPart; |
2728 | 2737 | ||
2729 | if (m_rootPart.PhysActor != null) | 2738 | if (m_rootPart.PhysActor != null) |
@@ -2735,31 +2744,44 @@ namespace OpenSim.Region.Framework.Scenes | |||
2735 | bool grpusephys = UsesPhysics; | 2744 | bool grpusephys = UsesPhysics; |
2736 | bool grptemporary = IsTemporary; | 2745 | bool grptemporary = IsTemporary; |
2737 | 2746 | ||
2747 | // Remember where the group being linked thought it was | ||
2738 | Vector3 oldGroupPosition = linkPart.GroupPosition; | 2748 | Vector3 oldGroupPosition = linkPart.GroupPosition; |
2739 | Quaternion oldRootRotation = linkPart.RotationOffset; | 2749 | Quaternion oldRootRotation = linkPart.RotationOffset; |
2740 | 2750 | ||
2741 | linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; | 2751 | // A linked SOP remembers its location and rotation relative to the root of a group. |
2752 | // Convert the root of the group being linked to be relative to the | ||
2753 | // root of the group being linked to. | ||
2754 | // Note: Some of the assignments have complex side effects. | ||
2742 | 2755 | ||
2756 | // First move the new group's root SOP's position to be relative to ours | ||
2757 | // (radams1: Not sure if the multiple setting of OffsetPosition is required. If not, | ||
2758 | // this code can be reordered to have a more logical flow.) | ||
2759 | linkPart.OffsetPosition = linkPart.GroupPosition - AbsolutePosition; | ||
2760 | // Assign the new parent to the root of the old group | ||
2743 | linkPart.ParentID = m_rootPart.LocalId; | 2761 | linkPart.ParentID = m_rootPart.LocalId; |
2744 | 2762 | // Now that it's a child, it's group position is our root position | |
2745 | linkPart.GroupPosition = AbsolutePosition; | 2763 | linkPart.GroupPosition = AbsolutePosition; |
2746 | 2764 | ||
2747 | Vector3 axPos = linkPart.OffsetPosition; | 2765 | Vector3 axPos = linkPart.OffsetPosition; |
2766 | // Rotate the linking root SOP's position to be relative to the new root prim | ||
2748 | Quaternion parentRot = m_rootPart.RotationOffset; | 2767 | Quaternion parentRot = m_rootPart.RotationOffset; |
2749 | axPos *= Quaternion.Conjugate(parentRot); | 2768 | axPos *= Quaternion.Conjugate(parentRot); |
2750 | linkPart.OffsetPosition = axPos; | 2769 | linkPart.OffsetPosition = axPos; |
2751 | 2770 | ||
2771 | // Make the linking root SOP's rotation relative to the new root prim | ||
2752 | Quaternion oldRot = linkPart.RotationOffset; | 2772 | Quaternion oldRot = linkPart.RotationOffset; |
2753 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; | 2773 | Quaternion newRot = Quaternion.Conjugate(parentRot) * oldRot; |
2754 | linkPart.RotationOffset = newRot; | 2774 | linkPart.RotationOffset = newRot; |
2755 | 2775 | ||
2756 | // linkPart.ParentID = m_rootPart.LocalId; done above | 2776 | // If there is only one SOP in a SOG, the LinkNum is zero. I.e., not a linkset. |
2757 | 2777 | // Now that we know this SOG has at least two SOPs in it, the new root | |
2778 | // SOP becomes the first in the linkset. | ||
2758 | if (m_rootPart.LinkNum == 0) | 2779 | if (m_rootPart.LinkNum == 0) |
2759 | m_rootPart.LinkNum = 1; | 2780 | m_rootPart.LinkNum = 1; |
2760 | 2781 | ||
2761 | lock (m_parts.SyncRoot) | 2782 | lock (m_parts.SyncRoot) |
2762 | { | 2783 | { |
2784 | // Calculate the new link number for the old root SOP | ||
2763 | int linkNum; | 2785 | int linkNum; |
2764 | if (insert) | 2786 | if (insert) |
2765 | { | 2787 | { |
@@ -2775,6 +2797,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2775 | linkNum = PrimCount + 1; | 2797 | linkNum = PrimCount + 1; |
2776 | } | 2798 | } |
2777 | 2799 | ||
2800 | // Add the old root SOP as a part in our group's list | ||
2778 | m_parts.Add(linkPart.UUID, linkPart); | 2801 | m_parts.Add(linkPart.UUID, linkPart); |
2779 | 2802 | ||
2780 | linkPart.SetParent(this); | 2803 | linkPart.SetParent(this); |
@@ -2782,6 +2805,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2782 | 2805 | ||
2783 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now | 2806 | // let physics know preserve part volume dtc messy since UpdatePrimFlags doesn't look to parent changes for now |
2784 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); | 2807 | linkPart.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (linkPart.Flags & PrimFlags.Phantom) != 0), linkPart.VolumeDetectActive, true); |
2808 | |||
2809 | // If the added SOP is physical, also tell the physics engine about the link relationship. | ||
2785 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2810 | if (linkPart.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
2786 | { | 2811 | { |
2787 | linkPart.PhysActor.link(m_rootPart.PhysActor); | 2812 | linkPart.PhysActor.link(m_rootPart.PhysActor); |
@@ -2791,20 +2816,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
2791 | linkPart.LinkNum = linkNum++; | 2816 | linkPart.LinkNum = linkNum++; |
2792 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | 2817 | linkPart.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); |
2793 | 2818 | ||
2819 | // Get a list of the SOP's in the old group in order of their linknum's. | ||
2794 | SceneObjectPart[] ogParts = objectGroup.Parts; | 2820 | SceneObjectPart[] ogParts = objectGroup.Parts; |
2795 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) | 2821 | Array.Sort(ogParts, delegate(SceneObjectPart a, SceneObjectPart b) |
2796 | { | 2822 | { |
2797 | return a.LinkNum - b.LinkNum; | 2823 | return a.LinkNum - b.LinkNum; |
2798 | }); | 2824 | }); |
2799 | 2825 | ||
2826 | // Add each of the SOP's from the old linkset to our linkset | ||
2800 | for (int i = 0; i < ogParts.Length; i++) | 2827 | for (int i = 0; i < ogParts.Length; i++) |
2801 | { | 2828 | { |
2802 | SceneObjectPart part = ogParts[i]; | 2829 | SceneObjectPart part = ogParts[i]; |
2803 | if (part.UUID != objectGroup.m_rootPart.UUID) | 2830 | if (part.UUID != objectGroup.m_rootPart.UUID) |
2804 | { | 2831 | { |
2805 | LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); | 2832 | LinkNonRootPart(part, oldGroupPosition, oldRootRotation, linkNum++); |
2806 | // let physics know | 2833 | |
2834 | // Update the physics flags for the newly added SOP | ||
2835 | // (Is this necessary? LinkNonRootPart() has already called UpdatePrimFlags but with different flags!??) | ||
2807 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); | 2836 | part.UpdatePrimFlags(grpusephys, grptemporary, (IsPhantom || (part.Flags & PrimFlags.Phantom) != 0), part.VolumeDetectActive, true); |
2837 | |||
2838 | // If the added SOP is physical, also tell the physics engine about the link relationship. | ||
2808 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) | 2839 | if (part.PhysActor != null && m_rootPart.PhysActor != null && m_rootPart.PhysActor.IsPhysical) |
2809 | { | 2840 | { |
2810 | part.PhysActor.link(m_rootPart.PhysActor); | 2841 | part.PhysActor.link(m_rootPart.PhysActor); |
@@ -2815,6 +2846,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2815 | } | 2846 | } |
2816 | } | 2847 | } |
2817 | 2848 | ||
2849 | // Now that we've aquired all of the old SOG's parts, remove the old SOG from the scene. | ||
2818 | m_scene.UnlinkSceneObject(objectGroup, true); | 2850 | m_scene.UnlinkSceneObject(objectGroup, true); |
2819 | objectGroup.IsDeleted = true; | 2851 | objectGroup.IsDeleted = true; |
2820 | 2852 | ||
@@ -2890,7 +2922,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2890 | /// <remarks> | 2922 | /// <remarks> |
2891 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race | 2923 | /// FIXME: This method should not be called directly since it bypasses update locking, allowing a potential race |
2892 | /// condition. But currently there is no | 2924 | /// condition. But currently there is no |
2893 | /// alternative method that does take a lonk to delink a single prim. | 2925 | /// alternative method that does take a lock to delink a single prim. |
2894 | /// </remarks> | 2926 | /// </remarks> |
2895 | /// <param name="partID"></param> | 2927 | /// <param name="partID"></param> |
2896 | /// <param name="sendEvents"></param> | 2928 | /// <param name="sendEvents"></param> |
@@ -2906,6 +2938,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2906 | 2938 | ||
2907 | linkPart.ClearUndoState(); | 2939 | linkPart.ClearUndoState(); |
2908 | 2940 | ||
2941 | Vector3 worldPos = linkPart.GetWorldPosition(); | ||
2909 | Quaternion worldRot = linkPart.GetWorldRotation(); | 2942 | Quaternion worldRot = linkPart.GetWorldRotation(); |
2910 | 2943 | ||
2911 | // Remove the part from this object | 2944 | // Remove the part from this object |
@@ -2915,6 +2948,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2915 | 2948 | ||
2916 | SceneObjectPart[] parts = m_parts.GetArray(); | 2949 | SceneObjectPart[] parts = m_parts.GetArray(); |
2917 | 2950 | ||
2951 | // Rejigger the linknum's of the remaining SOP's to fill any gap | ||
2918 | if (parts.Length == 1 && RootPart != null) | 2952 | if (parts.Length == 1 && RootPart != null) |
2919 | { | 2953 | { |
2920 | // Single prim left | 2954 | // Single prim left |
@@ -2936,22 +2970,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
2936 | 2970 | ||
2937 | PhysicsActor linkPartPa = linkPart.PhysActor; | 2971 | PhysicsActor linkPartPa = linkPart.PhysActor; |
2938 | 2972 | ||
2973 | // Remove the SOP from the physical scene. | ||
2974 | // If the new SOG is physical, it is re-created later. | ||
2975 | // (There is a problem here in that we have not yet told the physics | ||
2976 | // engine about the delink. Someday, linksets should be made first | ||
2977 | // class objects in the physics engine interface). | ||
2939 | if (linkPartPa != null) | 2978 | if (linkPartPa != null) |
2940 | m_scene.PhysicsScene.RemovePrim(linkPartPa); | 2979 | m_scene.PhysicsScene.RemovePrim(linkPartPa); |
2941 | 2980 | ||
2942 | // We need to reset the child part's position | 2981 | // We need to reset the child part's position |
2943 | // ready for life as a separate object after being a part of another object | 2982 | // ready for life as a separate object after being a part of another object |
2944 | Quaternion parentRot = m_rootPart.RotationOffset; | ||
2945 | 2983 | ||
2984 | /* This commented out code seems to recompute what GetWorldPosition already does. | ||
2985 | * Replace with a call to GetWorldPosition (before unlinking) | ||
2986 | Quaternion parentRot = m_rootPart.RotationOffset; | ||
2946 | Vector3 axPos = linkPart.OffsetPosition; | 2987 | Vector3 axPos = linkPart.OffsetPosition; |
2947 | |||
2948 | axPos *= parentRot; | 2988 | axPos *= parentRot; |
2949 | linkPart.OffsetPosition = new Vector3(axPos.X, axPos.Y, axPos.Z); | 2989 | linkPart.OffsetPosition = new Vector3(axPos.X, axPos.Y, axPos.Z); |
2950 | linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; | 2990 | linkPart.GroupPosition = AbsolutePosition + linkPart.OffsetPosition; |
2951 | linkPart.OffsetPosition = new Vector3(0, 0, 0); | 2991 | linkPart.OffsetPosition = new Vector3(0, 0, 0); |
2952 | 2992 | */ | |
2993 | linkPart.GroupPosition = worldPos; | ||
2994 | linkPart.OffsetPosition = Vector3.Zero; | ||
2953 | linkPart.RotationOffset = worldRot; | 2995 | linkPart.RotationOffset = worldRot; |
2954 | 2996 | ||
2997 | // Create a new SOG to go around this unlinked and unattached SOP | ||
2955 | SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); | 2998 | SceneObjectGroup objectGroup = new SceneObjectGroup(linkPart); |
2956 | 2999 | ||
2957 | m_scene.AddNewSceneObject(objectGroup, true); | 3000 | m_scene.AddNewSceneObject(objectGroup, true); |
@@ -2989,43 +3032,57 @@ namespace OpenSim.Region.Framework.Scenes | |||
2989 | m_isBackedUp = false; | 3032 | m_isBackedUp = false; |
2990 | } | 3033 | } |
2991 | 3034 | ||
3035 | // This links an SOP from a previous linkset into my linkset. | ||
3036 | // The trick is that the SOP's position and rotation are relative to the old root SOP's | ||
3037 | // so we are passed in the position and rotation of the old linkset so this can | ||
3038 | // unjigger this SOP's position and rotation from the previous linkset and | ||
3039 | // then make them relative to my linkset root. | ||
2992 | private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum) | 3040 | private void LinkNonRootPart(SceneObjectPart part, Vector3 oldGroupPosition, Quaternion oldGroupRotation, int linkNum) |
2993 | { | 3041 | { |
2994 | Quaternion parentRot = oldGroupRotation; | 3042 | Quaternion parentRot = oldGroupRotation; |
2995 | Quaternion oldRot = part.RotationOffset; | 3043 | Quaternion oldRot = part.RotationOffset; |
2996 | Quaternion worldRot = parentRot * oldRot; | ||
2997 | |||
2998 | parentRot = oldGroupRotation; | ||
2999 | 3044 | ||
3045 | // Move our position to not be relative to the old parent | ||
3000 | Vector3 axPos = part.OffsetPosition; | 3046 | Vector3 axPos = part.OffsetPosition; |
3001 | |||
3002 | axPos *= parentRot; | 3047 | axPos *= parentRot; |
3003 | part.OffsetPosition = axPos; | 3048 | part.OffsetPosition = axPos; |
3004 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; | 3049 | Vector3 newPos = oldGroupPosition + part.OffsetPosition; |
3005 | part.GroupPosition = newPos; | 3050 | part.GroupPosition = newPos; |
3006 | part.OffsetPosition = Vector3.Zero; | 3051 | part.OffsetPosition = Vector3.Zero; |
3052 | |||
3053 | // Compution our rotation to be not relative to the old parent | ||
3054 | Quaternion worldRot = parentRot * oldRot; | ||
3007 | part.RotationOffset = worldRot; | 3055 | part.RotationOffset = worldRot; |
3008 | 3056 | ||
3057 | // Add this SOP to our linkset | ||
3009 | part.SetParent(this); | 3058 | part.SetParent(this); |
3010 | part.ParentID = m_rootPart.LocalId; | 3059 | part.ParentID = m_rootPart.LocalId; |
3011 | |||
3012 | m_parts.Add(part.UUID, part); | 3060 | m_parts.Add(part.UUID, part); |
3013 | 3061 | ||
3014 | part.LinkNum = linkNum; | 3062 | part.LinkNum = linkNum; |
3015 | 3063 | ||
3016 | part.OffsetPosition = newPos - AbsolutePosition; | 3064 | // Compute the new position of this SOP relative to the group position |
3065 | part.OffsetPosition = part.GroupPosition - AbsolutePosition; | ||
3017 | 3066 | ||
3018 | Quaternion rootRotation = m_rootPart.RotationOffset; | 3067 | // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. |
3068 | // It would have the affect of setting the physics engine position multiple | ||
3069 | // times. In theory, that is not necessary but I don't have a good linkset | ||
3070 | // test to know that cleaning up this code wouldn't break things.) | ||
3019 | 3071 | ||
3072 | // Rotate the relative position by the rotation of the group | ||
3073 | Quaternion rootRotation = m_rootPart.RotationOffset; | ||
3020 | Vector3 pos = part.OffsetPosition; | 3074 | Vector3 pos = part.OffsetPosition; |
3021 | pos *= Quaternion.Conjugate(rootRotation); | 3075 | pos *= Quaternion.Conjugate(rootRotation); |
3022 | part.OffsetPosition = pos; | 3076 | part.OffsetPosition = pos; |
3023 | 3077 | ||
3078 | // Compute the SOP's rotation relative to the rotation of the group. | ||
3024 | parentRot = m_rootPart.RotationOffset; | 3079 | parentRot = m_rootPart.RotationOffset; |
3025 | oldRot = part.RotationOffset; | 3080 | oldRot = part.RotationOffset; |
3026 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; | 3081 | Quaternion newRot = Quaternion.Conjugate(parentRot) * worldRot; |
3027 | part.RotationOffset = newRot; | 3082 | part.RotationOffset = newRot; |
3028 | 3083 | ||
3084 | // Since this SOP's state has changed, push those changes into the physics engine | ||
3085 | // and the simulator. | ||
3029 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); | 3086 | part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); |
3030 | } | 3087 | } |
3031 | 3088 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 2410970..b038876 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -752,6 +752,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
752 | return m_groupPosition; | 752 | return m_groupPosition; |
753 | } | 753 | } |
754 | 754 | ||
755 | // If I'm an attachment, my position is reported as the position of who I'm attached to | ||
755 | if (ParentGroup.IsAttachment) | 756 | if (ParentGroup.IsAttachment) |
756 | { | 757 | { |
757 | ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); | 758 | ScenePresence sp = ParentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); |
@@ -779,7 +780,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
779 | } | 780 | } |
780 | else | 781 | else |
781 | { | 782 | { |
782 | // To move the child prim in respect to the group position and rotation we have to calculate | 783 | // The physics engine always sees all objects (root or linked) in world coordinates. |
783 | actor.Position = GetWorldPosition(); | 784 | actor.Position = GetWorldPosition(); |
784 | actor.Orientation = GetWorldRotation(); | 785 | actor.Orientation = GetWorldRotation(); |
785 | } | 786 | } |
@@ -858,6 +859,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
858 | { | 859 | { |
859 | // We don't want the physics engine mucking up the rotations in a linkset | 860 | // We don't want the physics engine mucking up the rotations in a linkset |
860 | PhysicsActor actor = PhysActor; | 861 | PhysicsActor actor = PhysActor; |
862 | // If this is a root of a linkset, the real rotation is what the physics engine thinks. | ||
863 | // If not a root prim, the offset rotation is computed by SOG and is relative to the root. | ||
861 | if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) | 864 | if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) |
862 | { | 865 | { |
863 | if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f | 866 | if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f |
@@ -2529,14 +2532,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
2529 | /// <returns>A Linked Child Prim objects position in world</returns> | 2532 | /// <returns>A Linked Child Prim objects position in world</returns> |
2530 | public Vector3 GetWorldPosition() | 2533 | public Vector3 GetWorldPosition() |
2531 | { | 2534 | { |
2532 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; | 2535 | Vector3 ret; |
2533 | Vector3 axPos = OffsetPosition; | 2536 | if (_parentID == 0) |
2534 | axPos *= parentRot; | 2537 | // if a root SOP, my position is what it is |
2535 | Vector3 translationOffsetPosition = axPos; | 2538 | ret = GroupPosition; |
2536 | if(_parentID == 0) | ||
2537 | return GroupPosition; | ||
2538 | else | 2539 | else |
2539 | return ParentGroup.AbsolutePosition + translationOffsetPosition; | 2540 | { |
2541 | // If a child SOP, my position is relative to the root SOP so take | ||
2542 | // my info and add the root's position and rotation to | ||
2543 | // get my world position. | ||
2544 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; | ||
2545 | Vector3 translationOffsetPosition = OffsetPosition * parentRot; | ||
2546 | ret = ParentGroup.AbsolutePosition + translationOffsetPosition; | ||
2547 | } | ||
2548 | return ret; | ||
2540 | } | 2549 | } |
2541 | 2550 | ||
2542 | /// <summary> | 2551 | /// <summary> |
@@ -2553,6 +2562,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2553 | } | 2562 | } |
2554 | else | 2563 | else |
2555 | { | 2564 | { |
2565 | // A child SOP's rotation is relative to the root SOP's rotation. | ||
2566 | // Combine them to get my absolute rotation. | ||
2556 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; | 2567 | Quaternion parentRot = ParentGroup.RootPart.RotationOffset; |
2557 | Quaternion oldRot = RotationOffset; | 2568 | Quaternion oldRot = RotationOffset; |
2558 | newRot = parentRot * oldRot; | 2569 | newRot = parentRot * oldRot; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index e5e29d0..1c9a17e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -1453,6 +1453,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1453 | { | 1453 | { |
1454 | if (e != null) | 1454 | if (e != null) |
1455 | { | 1455 | { |
1456 | // m_log.DebugFormat( | ||
1457 | // "[PRIM INVENTORY]: Getting script state from engine {0} for {1} in part {2} in group {3} in {4}", | ||
1458 | // e.Name, item.Name, m_part.Name, m_part.ParentGroup.Name, m_part.ParentGroup.Scene.Name); | ||
1459 | |||
1456 | string n = e.GetXMLState(item.ItemID); | 1460 | string n = e.GetXMLState(item.ItemID); |
1457 | if (n != String.Empty) | 1461 | if (n != String.Empty) |
1458 | { | 1462 | { |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index 6c53d95..7b20446 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | |||
@@ -823,11 +823,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
823 | m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", | 823 | m_log.DebugFormat("[FreeSwitchVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", |
824 | landName, land.LocalID, landUUID); | 824 | landName, land.LocalID, landUUID); |
825 | } | 825 | } |
826 | System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); | ||
827 | 826 | ||
828 | // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables | 827 | // slvoice handles the sip address differently if it begins with confctl, hiding it from the user in the friends list. however it also disables |
829 | // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. | 828 | // the personal speech indicators as well unless some siren14-3d codec magic happens. we dont have siren143d so we'll settle for the personal speech indicator. |
830 | channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(encoding.GetBytes(landUUID)), m_freeSwitchRealm); | 829 | channelUri = String.Format("sip:conf-{0}@{1}", "x" + Convert.ToBase64String(Encoding.ASCII.GetBytes(landUUID)), m_freeSwitchRealm); |
831 | 830 | ||
832 | lock (m_ParcelAddress) | 831 | lock (m_ParcelAddress) |
833 | { | 832 | { |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index 52fc27d..61aaf04 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs | |||
@@ -1120,7 +1120,6 @@ namespace Nwc.XmlRpc | |||
1120 | /// <summary>Class supporting the request side of an XML-RPC transaction.</summary> | 1120 | /// <summary>Class supporting the request side of an XML-RPC transaction.</summary> |
1121 | public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest | 1121 | public class ConfigurableKeepAliveXmlRpcRequest : XmlRpcRequest |
1122 | { | 1122 | { |
1123 | private Encoding _encoding = new ASCIIEncoding(); | ||
1124 | private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer(); | 1123 | private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer(); |
1125 | private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer(); | 1124 | private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer(); |
1126 | private bool _disableKeepAlive = true; | 1125 | private bool _disableKeepAlive = true; |
@@ -1153,7 +1152,7 @@ namespace Nwc.XmlRpc | |||
1153 | request.KeepAlive = !_disableKeepAlive; | 1152 | request.KeepAlive = !_disableKeepAlive; |
1154 | 1153 | ||
1155 | Stream stream = request.GetRequestStream(); | 1154 | Stream stream = request.GetRequestStream(); |
1156 | XmlTextWriter xml = new XmlTextWriter(stream, _encoding); | 1155 | XmlTextWriter xml = new XmlTextWriter(stream, Encoding.ASCII); |
1157 | _serializer.Serialize(xml, this); | 1156 | _serializer.Serialize(xml, this); |
1158 | xml.Flush(); | 1157 | xml.Flush(); |
1159 | xml.Close(); | 1158 | xml.Close(); |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 4949097..eaba816 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -425,10 +425,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
425 | 425 | ||
426 | try | 426 | try |
427 | { | 427 | { |
428 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | 428 | string jsondata = SLUtil.ParseNotecardToString(Encoding.UTF8.GetString(a.Data)); |
429 | string jsondata = SLUtil.ParseNotecardToString(enc.GetString(a.Data)); | 429 | int result = m_store.SetValue(storeID, path, jsondata,true) ? 1 : 0; |
430 | int result = m_store.SetValue(storeID,path,jsondata,true) ? 1 : 0; | 430 | m_comms.DispatchReply(scriptID,result, "", reqID.ToString()); |
431 | m_comms.DispatchReply(scriptID,result,"",reqID.ToString()); | ||
432 | return; | 431 | return; |
433 | } | 432 | } |
434 | catch (Exception e) | 433 | catch (Exception e) |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 74f5208..03481d2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | |||
@@ -482,10 +482,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
482 | // Convert to base64 | 482 | // Convert to base64 |
483 | // | 483 | // |
484 | string filetext = Convert.ToBase64String(data); | 484 | string filetext = Convert.ToBase64String(data); |
485 | 485 | Byte[] buf = Encoding.ASCII.GetBytes(filetext); | |
486 | ASCIIEncoding enc = new ASCIIEncoding(); | ||
487 | |||
488 | Byte[] buf = enc.GetBytes(filetext); | ||
489 | 486 | ||
490 | m_log.Info("MRM 9"); | 487 | m_log.Info("MRM 9"); |
491 | 488 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 3cbdde5..693992a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -233,17 +233,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
233 | m_Timer[engine].UnSetTimerEvents(localID, itemID); | 233 | m_Timer[engine].UnSetTimerEvents(localID, itemID); |
234 | 234 | ||
235 | // Remove from: HttpRequest | 235 | // Remove from: HttpRequest |
236 | IHttpRequestModule iHttpReq = | 236 | IHttpRequestModule iHttpReq = engine.World.RequestModuleInterface<IHttpRequestModule>(); |
237 | engine.World.RequestModuleInterface<IHttpRequestModule>(); | 237 | if (iHttpReq != null) |
238 | iHttpReq.StopHttpRequest(localID, itemID); | 238 | iHttpReq.StopHttpRequest(localID, itemID); |
239 | 239 | ||
240 | IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); | 240 | IWorldComm comms = engine.World.RequestModuleInterface<IWorldComm>(); |
241 | if (comms != null) | 241 | if (comms != null) |
242 | comms.DeleteListener(itemID); | 242 | comms.DeleteListener(itemID); |
243 | 243 | ||
244 | IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); | 244 | IXMLRPC xmlrpc = engine.World.RequestModuleInterface<IXMLRPC>(); |
245 | xmlrpc.DeleteChannels(itemID); | 245 | if (xmlrpc != null) |
246 | xmlrpc.CancelSRDRequests(itemID); | 246 | { |
247 | xmlrpc.DeleteChannels(itemID); | ||
248 | xmlrpc.CancelSRDRequests(itemID); | ||
249 | } | ||
247 | 250 | ||
248 | // Remove Sensors | 251 | // Remove Sensors |
249 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); | 252 | m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); |
@@ -325,7 +328,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
325 | { | 328 | { |
326 | List<Object> data = new List<Object>(); | 329 | List<Object> data = new List<Object>(); |
327 | 330 | ||
328 | Object[] listeners=m_Listener[engine].GetSerializationData(itemID); | 331 | Object[] listeners = m_Listener[engine].GetSerializationData(itemID); |
329 | if (listeners.Length > 0) | 332 | if (listeners.Length > 0) |
330 | { | 333 | { |
331 | data.Add("listener"); | 334 | data.Add("listener"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e9db5d5..fed3122 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -11918,9 +11918,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11918 | return; | 11918 | return; |
11919 | } | 11919 | } |
11920 | 11920 | ||
11921 | System.Text.UTF8Encoding enc = | 11921 | string data = Encoding.UTF8.GetString(a.Data); |
11922 | new System.Text.UTF8Encoding(); | ||
11923 | string data = enc.GetString(a.Data); | ||
11924 | //m_log.Debug(data); | 11922 | //m_log.Debug(data); |
11925 | NotecardCache.Cache(id, data); | 11923 | NotecardCache.Cache(id, data); |
11926 | AsyncCommands. | 11924 | AsyncCommands. |
@@ -11973,9 +11971,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11973 | return; | 11971 | return; |
11974 | } | 11972 | } |
11975 | 11973 | ||
11976 | System.Text.UTF8Encoding enc = | 11974 | string data = Encoding.UTF8.GetString(a.Data); |
11977 | new System.Text.UTF8Encoding(); | ||
11978 | string data = enc.GetString(a.Data); | ||
11979 | //m_log.Debug(data); | 11975 | //m_log.Debug(data); |
11980 | NotecardCache.Cache(id, data); | 11976 | NotecardCache.Cache(id, data); |
11981 | AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(), | 11977 | AsyncCommands.DataserverPlugin.DataserverReply(id.ToString(), |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index b639d36..4d20f7b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -1822,8 +1822,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1822 | if (a == null) | 1822 | if (a == null) |
1823 | return UUID.Zero; | 1823 | return UUID.Zero; |
1824 | 1824 | ||
1825 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | 1825 | string data = Encoding.UTF8.GetString(a.Data); |
1826 | string data = enc.GetString(a.Data); | ||
1827 | NotecardCache.Cache(assetID, data); | 1826 | NotecardCache.Cache(assetID, data); |
1828 | }; | 1827 | }; |
1829 | 1828 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs index 93e0261..efa86fc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Listener.cs | |||
@@ -88,13 +88,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
88 | 88 | ||
89 | public Object[] GetSerializationData(UUID itemID) | 89 | public Object[] GetSerializationData(UUID itemID) |
90 | { | 90 | { |
91 | return m_commsPlugin.GetSerializationData(itemID); | 91 | if (m_commsPlugin != null) |
92 | return m_commsPlugin.GetSerializationData(itemID); | ||
93 | else | ||
94 | return new Object[]{}; | ||
92 | } | 95 | } |
93 | 96 | ||
94 | public void CreateFromData(uint localID, UUID itemID, UUID hostID, | 97 | public void CreateFromData(uint localID, UUID itemID, UUID hostID, |
95 | Object[] data) | 98 | Object[] data) |
96 | { | 99 | { |
97 | m_commsPlugin.CreateFromData(localID, itemID, hostID, data); | 100 | if (m_commsPlugin != null) |
101 | m_commsPlugin.CreateFromData(localID, itemID, hostID, data); | ||
98 | } | 102 | } |
99 | } | 103 | } |
100 | } \ No newline at end of file | 104 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 8f2ec49..17a0d69 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Globalization; | 31 | using System.Globalization; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.IO; | 33 | using System.IO; |
34 | using System.Text; | ||
34 | using Microsoft.CSharp; | 35 | using Microsoft.CSharp; |
35 | //using Microsoft.JScript; | 36 | //using Microsoft.JScript; |
36 | using Microsoft.VisualBasic; | 37 | using Microsoft.VisualBasic; |
@@ -711,9 +712,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
711 | // | 712 | // |
712 | string filetext = System.Convert.ToBase64String(data); | 713 | string filetext = System.Convert.ToBase64String(data); |
713 | 714 | ||
714 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | 715 | Byte[] buf = Encoding.ASCII.GetBytes(filetext); |
715 | |||
716 | Byte[] buf = enc.GetBytes(filetext); | ||
717 | 716 | ||
718 | FileStream sfs = File.Create(assembly + ".text"); | 717 | FileStream sfs = File.Create(assembly + ".text"); |
719 | sfs.Write(buf, 0, buf.Length); | 718 | sfs.Write(buf, 0, buf.Length); |
@@ -804,8 +803,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
804 | mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value); | 803 | mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value); |
805 | } | 804 | } |
806 | 805 | ||
807 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | 806 | Byte[] mapbytes = Encoding.ASCII.GetBytes(mapstring); |
808 | Byte[] mapbytes = enc.GetBytes(mapstring); | ||
809 | FileStream mfs = File.Create(filename); | 807 | FileStream mfs = File.Create(filename); |
810 | mfs.Write(mapbytes, 0, mapbytes.Length); | 808 | mfs.Write(mapbytes, 0, mapbytes.Length); |
811 | mfs.Close(); | 809 | mfs.Close(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 3797683..3ddf1d4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -26,16 +26,17 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Globalization; | ||
29 | using System.IO; | 32 | using System.IO; |
30 | using System.Diagnostics; //for [DebuggerNonUserCode] | 33 | using System.Diagnostics; //for [DebuggerNonUserCode] |
34 | using System.Reflection; | ||
31 | using System.Runtime.Remoting; | 35 | using System.Runtime.Remoting; |
32 | using System.Runtime.Remoting.Lifetime; | 36 | using System.Runtime.Remoting.Lifetime; |
33 | using System.Threading; | ||
34 | using System.Collections; | ||
35 | using System.Collections.Generic; | ||
36 | using System.Security.Policy; | 37 | using System.Security.Policy; |
37 | using System.Reflection; | 38 | using System.Text; |
38 | using System.Globalization; | 39 | using System.Threading; |
39 | using System.Xml; | 40 | using System.Xml; |
40 | using OpenMetaverse; | 41 | using OpenMetaverse; |
41 | using log4net; | 42 | using log4net; |
@@ -298,13 +299,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
298 | using (FileStream fs = File.Open(savedState, | 299 | using (FileStream fs = File.Open(savedState, |
299 | FileMode.Open, FileAccess.Read, FileShare.None)) | 300 | FileMode.Open, FileAccess.Read, FileShare.None)) |
300 | { | 301 | { |
301 | System.Text.UTF8Encoding enc = | ||
302 | new System.Text.UTF8Encoding(); | ||
303 | |||
304 | Byte[] data = new Byte[size]; | 302 | Byte[] data = new Byte[size]; |
305 | fs.Read(data, 0, size); | 303 | fs.Read(data, 0, size); |
306 | 304 | ||
307 | xml = enc.GetString(data); | 305 | xml = Encoding.UTF8.GetString(data); |
308 | 306 | ||
309 | ScriptSerializer.Deserialize(xml, this); | 307 | ScriptSerializer.Deserialize(xml, this); |
310 | 308 | ||
@@ -956,8 +954,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
956 | try | 954 | try |
957 | { | 955 | { |
958 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state")); | 956 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), ItemID.ToString() + ".state")); |
959 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | 957 | Byte[] buf = (new UTF8Encoding()).GetBytes(xml); |
960 | Byte[] buf = enc.GetBytes(xml); | ||
961 | fs.Write(buf, 0, buf.Length); | 958 | fs.Write(buf, 0, buf.Length); |
962 | fs.Close(); | 959 | fs.Close(); |
963 | } | 960 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index a3f848c..f247a0b 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | |||
@@ -58,9 +58,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
58 | // Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); | 58 | // Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory); |
59 | m_xEngine = new XEngine(); | 59 | m_xEngine = new XEngine(); |
60 | 60 | ||
61 | // Necessary to stop serialization complaining | ||
62 | WorldCommModule wcModule = new WorldCommModule(); | ||
63 | |||
64 | IniConfigSource configSource = new IniConfigSource(); | 61 | IniConfigSource configSource = new IniConfigSource(); |
65 | 62 | ||
66 | IConfig startupConfig = configSource.AddConfig("Startup"); | 63 | IConfig startupConfig = configSource.AddConfig("Startup"); |
@@ -68,13 +65,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
68 | 65 | ||
69 | IConfig xEngineConfig = configSource.AddConfig("XEngine"); | 66 | IConfig xEngineConfig = configSource.AddConfig("XEngine"); |
70 | xEngineConfig.Set("Enabled", "true"); | 67 | xEngineConfig.Set("Enabled", "true"); |
68 | xEngineConfig.Set("StartDelay", "0"); | ||
71 | 69 | ||
72 | // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call | 70 | // These tests will not run with AppDomainLoading = true, at least on mono. For unknown reasons, the call |
73 | // to AssemblyResolver.OnAssemblyResolve fails. | 71 | // to AssemblyResolver.OnAssemblyResolve fails. |
74 | xEngineConfig.Set("AppDomainLoading", "false"); | 72 | xEngineConfig.Set("AppDomainLoading", "false"); |
75 | 73 | ||
76 | m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); | 74 | m_scene = new SceneHelpers().SetupScene("My Test", UUID.Random(), 1000, 1000, configSource); |
77 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine, wcModule); | 75 | SceneHelpers.SetupSceneModules(m_scene, configSource, m_xEngine); |
78 | m_scene.StartScripts(); | 76 | m_scene.StartScripts(); |
79 | } | 77 | } |
80 | 78 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index cc783aa..d763063 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -78,7 +78,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
78 | private IConfigSource m_ConfigSource = null; | 78 | private IConfigSource m_ConfigSource = null; |
79 | private ICompiler m_Compiler; | 79 | private ICompiler m_Compiler; |
80 | private int m_MinThreads; | 80 | private int m_MinThreads; |
81 | private int m_MaxThreads ; | 81 | private int m_MaxThreads; |
82 | |||
83 | /// <summary> | ||
84 | /// Amount of time to delay before starting. | ||
85 | /// </summary> | ||
86 | private int m_StartDelay; | ||
87 | |||
82 | private int m_IdleTimeout; | 88 | private int m_IdleTimeout; |
83 | private int m_StackSize; | 89 | private int m_StackSize; |
84 | private int m_SleepTime; | 90 | private int m_SleepTime; |
@@ -299,6 +305,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
299 | m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); | 305 | m_MaxThreads = m_ScriptConfig.GetInt("MaxThreads", 100); |
300 | m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60); | 306 | m_IdleTimeout = m_ScriptConfig.GetInt("IdleTimeout", 60); |
301 | string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); | 307 | string priority = m_ScriptConfig.GetString("Priority", "BelowNormal"); |
308 | m_StartDelay = m_ScriptConfig.GetInt("StartDelay", 15000); | ||
302 | m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); | 309 | m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300); |
303 | m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); | 310 | m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144); |
304 | m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; | 311 | m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000; |
@@ -957,7 +964,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
957 | { | 964 | { |
958 | // This delay exists to stop mono problems where script compilation and startup would stop the sim | 965 | // This delay exists to stop mono problems where script compilation and startup would stop the sim |
959 | // working properly for the session. | 966 | // working properly for the session. |
960 | System.Threading.Thread.Sleep(15000); | 967 | System.Threading.Thread.Sleep(m_StartDelay); |
961 | } | 968 | } |
962 | 969 | ||
963 | object[] o; | 970 | object[] o; |
@@ -1768,12 +1775,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1768 | 1775 | ||
1769 | public string GetXMLState(UUID itemID) | 1776 | public string GetXMLState(UUID itemID) |
1770 | { | 1777 | { |
1771 | // m_log.DebugFormat("[XEngine]: Getting XML state for {0}", itemID); | 1778 | // m_log.DebugFormat("[XEngine]: Getting XML state for script instance {0}", itemID); |
1772 | 1779 | ||
1773 | IScriptInstance instance = GetInstance(itemID); | 1780 | IScriptInstance instance = GetInstance(itemID); |
1774 | if (instance == null) | 1781 | if (instance == null) |
1775 | { | 1782 | { |
1776 | // m_log.DebugFormat("[XEngine]: Found no script for {0}, returning empty string", itemID); | 1783 | // m_log.DebugFormat("[XEngine]: Found no script instance for {0}, returning empty string", itemID); |
1777 | return ""; | 1784 | return ""; |
1778 | } | 1785 | } |
1779 | 1786 | ||
@@ -1848,7 +1855,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1848 | tfs.Read(tdata, 0, tdata.Length); | 1855 | tfs.Read(tdata, 0, tdata.Length); |
1849 | } | 1856 | } |
1850 | 1857 | ||
1851 | assem = new System.Text.ASCIIEncoding().GetString(tdata); | 1858 | assem = Encoding.ASCII.GetString(tdata); |
1852 | } | 1859 | } |
1853 | catch (Exception e) | 1860 | catch (Exception e) |
1854 | { | 1861 | { |