diff options
Merge branch 'master' into newmultiattach
Conflicts:
OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
Diffstat (limited to 'OpenSim/Region/CoreModules')
10 files changed, 655 insertions, 131 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index ab7e932..2dea14d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -289,21 +289,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
289 | if (!Enabled) | 289 | if (!Enabled) |
290 | return false; | 290 | return false; |
291 | 291 | ||
292 | if (AttachObjectInternal(sp, group, attachmentPt, silent, temp, append)) | 292 | return AttachObjectInternal(sp, group, attachmentPt, silent, temp, append); |
293 | { | ||
294 | m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID); | ||
295 | return true; | ||
296 | } | ||
297 | |||
298 | return false; | ||
299 | } | 293 | } |
300 | |||
301 | private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool append) | ||
302 | { | ||
303 | // m_log.DebugFormat( | ||
304 | // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", | ||
305 | // group.Name, group.LocalId, sp.Name, attachmentPt, silent); | ||
306 | 294 | ||
295 | /// <summary> | ||
296 | /// Internal method which actually does all the work for attaching an object. | ||
297 | /// </summary> | ||
298 | /// <returns>The object attached.</returns> | ||
299 | /// <param name='sp'></param> | ||
300 | /// <param name='group'>The object to attach.</param> | ||
301 | /// <param name='attachmentPt'></param> | ||
302 | /// <param name='silent'></param> | ||
303 | /// <param name='temp'></param> | ||
304 | /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> | ||
305 | private bool AttachObjectInternal( | ||
306 | IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool resumeScripts) | ||
307 | { | ||
307 | if (group.GetSittingAvatarsCount() != 0) | 308 | if (group.GetSittingAvatarsCount() != 0) |
308 | { | 309 | { |
309 | // m_log.WarnFormat( | 310 | // m_log.WarnFormat( |
@@ -314,6 +315,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
314 | } | 315 | } |
315 | 316 | ||
316 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); | 317 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); |
318 | |||
317 | if (attachments.Contains(group)) | 319 | if (attachments.Contains(group)) |
318 | { | 320 | { |
319 | // m_log.WarnFormat( | 321 | // m_log.WarnFormat( |
@@ -374,6 +376,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
374 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append); | 376 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append); |
375 | 377 | ||
376 | AttachToAgent(sp, group, attachmentPt, attachPos, silent); | 378 | AttachToAgent(sp, group, attachmentPt, attachPos, silent); |
379 | |||
380 | if (resumeScripts) | ||
381 | { | ||
382 | // Fire after attach, so we don't get messy perms dialogs | ||
383 | // 4 == AttachedRez | ||
384 | group.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); | ||
385 | group.ResumeScripts(); | ||
386 | } | ||
387 | |||
388 | // Do this last so that event listeners have access to all the effects of the attachment | ||
389 | m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID); | ||
377 | } | 390 | } |
378 | 391 | ||
379 | return true; | 392 | return true; |
@@ -400,8 +413,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
400 | return null; | 413 | return null; |
401 | 414 | ||
402 | // m_log.DebugFormat( | 415 | // m_log.DebugFormat( |
403 | // "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2}", | 416 | // "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2} in {3}", |
404 | // (AttachmentPoint)AttachmentPt, itemID, sp.Name); | 417 | // (AttachmentPoint)AttachmentPt, itemID, sp.Name, m_scene.Name); |
405 | 418 | ||
406 | bool append = (AttachmentPt & 0x80) != 0; | 419 | bool append = (AttachmentPt & 0x80) != 0; |
407 | AttachmentPt &= 0x7f; | 420 | AttachmentPt &= 0x7f; |
@@ -533,6 +546,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
533 | return; | 546 | return; |
534 | } | 547 | } |
535 | 548 | ||
549 | // m_log.DebugFormat( | ||
550 | // "[ATTACHMENTS MODULE]: Detaching object {0} {1} for {2} in {3}", | ||
551 | // so.Name, so.LocalId, sp.Name, m_scene.Name); | ||
552 | |||
536 | // Scripts MUST be snapshotted before the object is | 553 | // Scripts MUST be snapshotted before the object is |
537 | // removed from the scene because doing otherwise will | 554 | // removed from the scene because doing otherwise will |
538 | // clobber the run flag | 555 | // clobber the run flag |
@@ -854,61 +871,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
854 | return null; | 871 | return null; |
855 | } | 872 | } |
856 | 873 | ||
857 | // Remove any previous attachments | ||
858 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); | ||
859 | string previousAttachmentScriptedState = null; | ||
860 | |||
861 | // At the moment we can only deal with a single attachment | ||
862 | if (attachments.Count != 0) | ||
863 | DetachSingleAttachmentToInv(sp, attachments[0]); | ||
864 | |||
865 | lock (sp.AttachmentsSyncLock) | ||
866 | { | ||
867 | // m_log.DebugFormat( | 874 | // m_log.DebugFormat( |
868 | // "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}", | 875 | // "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}", |
869 | // objatt.Name, sp.Name, attachmentPt, m_scene.Name); | 876 | // objatt.Name, sp.Name, attachmentPt, m_scene.Name); |
870 | 877 | ||
871 | // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. | 878 | // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. |
872 | objatt.HasGroupChanged = false; | 879 | objatt.HasGroupChanged = false; |
873 | bool tainted = false; | 880 | bool tainted = false; |
874 | if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) | 881 | if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint) |
875 | tainted = true; | 882 | tainted = true; |
876 | 883 | ||
877 | // FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal | 884 | // FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal |
878 | // course of events. If not, then it's probably not worth trying to recover the situation | 885 | // course of events. If not, then it's probably not worth trying to recover the situation |
879 | // since this is more likely to trigger further exceptions and confuse later debugging. If | 886 | // since this is more likely to trigger further exceptions and confuse later debugging. If |
880 | // exceptions can be thrown in expected error conditions (not NREs) then make this consistent | 887 | // exceptions can be thrown in expected error conditions (not NREs) then make this consistent |
881 | // since other normal error conditions will simply return false instead. | 888 | // since other normal error conditions will simply return false instead. |
882 | // This will throw if the attachment fails | 889 | // This will throw if the attachment fails |
883 | try | 890 | try |
884 | { | 891 | { |
885 | AttachObjectInternal(sp, objatt, attachmentPt, false, false, append); | 892 | AttachObjectInternal(sp, objatt, attachmentPt, false, false, append); |
886 | } | 893 | } |
887 | catch (Exception e) | 894 | catch (Exception e) |
888 | { | 895 | { |
889 | m_log.ErrorFormat( | 896 | m_log.ErrorFormat( |
890 | "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", | 897 | "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", |
891 | objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); | 898 | objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); |
892 | |||
893 | // Make sure the object doesn't stick around and bail | ||
894 | sp.RemoveAttachment(objatt); | ||
895 | m_scene.DeleteSceneObject(objatt, false); | ||
896 | return null; | ||
897 | } | ||
898 | |||
899 | if (tainted) | ||
900 | objatt.HasGroupChanged = true; | ||
901 | 899 | ||
902 | // Fire after attach, so we don't get messy perms dialogs | 900 | // Make sure the object doesn't stick around and bail |
903 | // 4 == AttachedRez | 901 | sp.RemoveAttachment(objatt); |
904 | objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); | 902 | m_scene.DeleteSceneObject(objatt, false); |
905 | objatt.ResumeScripts(); | 903 | return null; |
904 | } | ||
906 | 905 | ||
907 | // Do this last so that event listeners have access to all the effects of the attachment | 906 | if (tainted) |
908 | m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); | 907 | objatt.HasGroupChanged = true; |
909 | 908 | ||
910 | return objatt; | 909 | return objatt; |
911 | } | ||
912 | } | 910 | } |
913 | 911 | ||
914 | /// <summary> | 912 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index f48bb6f..0c1df6a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -228,6 +228,120 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
228 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | 228 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); |
229 | } | 229 | } |
230 | 230 | ||
231 | [Test] | ||
232 | public void TestWearAttachmentFromGround() | ||
233 | { | ||
234 | TestHelpers.InMethod(); | ||
235 | // TestHelpers.EnableLogging(); | ||
236 | |||
237 | Scene scene = CreateTestScene(); | ||
238 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); | ||
239 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1); | ||
240 | |||
241 | SceneObjectGroup so2 = SceneHelpers.AddSceneObject(scene, "att2", sp.UUID); | ||
242 | |||
243 | { | ||
244 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); | ||
245 | |||
246 | m_numberOfAttachEventsFired = 0; | ||
247 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, false); | ||
248 | |||
249 | // Check status on scene presence | ||
250 | Assert.That(sp.HasAttachments(), Is.True); | ||
251 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
252 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
253 | SceneObjectGroup attSo = attachments[0]; | ||
254 | Assert.That(attSo.Name, Is.EqualTo(so.Name)); | ||
255 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); | ||
256 | Assert.That(attSo.IsAttachment); | ||
257 | Assert.That(attSo.UsesPhysics, Is.False); | ||
258 | Assert.That(attSo.IsTemporary, Is.False); | ||
259 | |||
260 | // Check item status | ||
261 | Assert.That( | ||
262 | sp.Appearance.GetAttachpoint(attSo.FromItemID), | ||
263 | Is.EqualTo((int)AttachmentPoint.LeftHand)); | ||
264 | |||
265 | InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); | ||
266 | Assert.That(attachmentItem, Is.Not.Null); | ||
267 | Assert.That(attachmentItem.Name, Is.EqualTo(so.Name)); | ||
268 | |||
269 | InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object); | ||
270 | Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); | ||
271 | |||
272 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(2)); | ||
273 | |||
274 | // Check events | ||
275 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
276 | } | ||
277 | |||
278 | // Test wearing a different attachment from the ground. | ||
279 | { | ||
280 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false); | ||
281 | |||
282 | // Check status on scene presence | ||
283 | Assert.That(sp.HasAttachments(), Is.True); | ||
284 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
285 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
286 | SceneObjectGroup attSo = attachments[0]; | ||
287 | Assert.That(attSo.Name, Is.EqualTo(so2.Name)); | ||
288 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); | ||
289 | Assert.That(attSo.IsAttachment); | ||
290 | Assert.That(attSo.UsesPhysics, Is.False); | ||
291 | Assert.That(attSo.IsTemporary, Is.False); | ||
292 | |||
293 | // Check item status | ||
294 | Assert.That( | ||
295 | sp.Appearance.GetAttachpoint(attSo.FromItemID), | ||
296 | Is.EqualTo((int)AttachmentPoint.LeftHand)); | ||
297 | |||
298 | InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); | ||
299 | Assert.That(attachmentItem, Is.Not.Null); | ||
300 | Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name)); | ||
301 | |||
302 | InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object); | ||
303 | Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); | ||
304 | |||
305 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | ||
306 | |||
307 | // Check events | ||
308 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3)); | ||
309 | } | ||
310 | |||
311 | // Test rewearing an already worn attachment from ground. Nothing should happen. | ||
312 | { | ||
313 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false); | ||
314 | |||
315 | // Check status on scene presence | ||
316 | Assert.That(sp.HasAttachments(), Is.True); | ||
317 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
318 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
319 | SceneObjectGroup attSo = attachments[0]; | ||
320 | Assert.That(attSo.Name, Is.EqualTo(so2.Name)); | ||
321 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); | ||
322 | Assert.That(attSo.IsAttachment); | ||
323 | Assert.That(attSo.UsesPhysics, Is.False); | ||
324 | Assert.That(attSo.IsTemporary, Is.False); | ||
325 | |||
326 | // Check item status | ||
327 | Assert.That( | ||
328 | sp.Appearance.GetAttachpoint(attSo.FromItemID), | ||
329 | Is.EqualTo((int)AttachmentPoint.LeftHand)); | ||
330 | |||
331 | InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID)); | ||
332 | Assert.That(attachmentItem, Is.Not.Null); | ||
333 | Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name)); | ||
334 | |||
335 | InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object); | ||
336 | Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID)); | ||
337 | |||
338 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | ||
339 | |||
340 | // Check events | ||
341 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3)); | ||
342 | } | ||
343 | } | ||
344 | |||
231 | /// <summary> | 345 | /// <summary> |
232 | /// Test that we do not attempt to attach an in-world object that someone else is sitting on. | 346 | /// Test that we do not attempt to attach an in-world object that someone else is sitting on. |
233 | /// </summary> | 347 | /// </summary> |
@@ -275,29 +389,140 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
275 | 389 | ||
276 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); | 390 | InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20); |
277 | 391 | ||
278 | m_numberOfAttachEventsFired = 0; | 392 | { |
279 | scene.AttachmentsModule.RezSingleAttachmentFromInventory( | 393 | scene.AttachmentsModule.RezSingleAttachmentFromInventory( |
280 | sp, attItem.ID, (uint)AttachmentPoint.Chest); | 394 | sp, attItem.ID, (uint)AttachmentPoint.Chest); |
281 | 395 | ||
282 | // Check scene presence status | 396 | // Check scene presence status |
283 | Assert.That(sp.HasAttachments(), Is.True); | 397 | Assert.That(sp.HasAttachments(), Is.True); |
284 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | 398 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
285 | Assert.That(attachments.Count, Is.EqualTo(1)); | 399 | Assert.That(attachments.Count, Is.EqualTo(1)); |
286 | SceneObjectGroup attSo = attachments[0]; | 400 | SceneObjectGroup attSo = attachments[0]; |
287 | Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); | 401 | Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); |
288 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); | 402 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); |
289 | Assert.That(attSo.IsAttachment); | 403 | Assert.That(attSo.IsAttachment); |
290 | Assert.That(attSo.UsesPhysics, Is.False); | 404 | Assert.That(attSo.UsesPhysics, Is.False); |
291 | Assert.That(attSo.IsTemporary, Is.False); | 405 | Assert.That(attSo.IsTemporary, Is.False); |
406 | |||
407 | // Check appearance status | ||
408 | Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); | ||
409 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | ||
410 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | ||
411 | |||
412 | // Check events | ||
413 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
414 | } | ||
415 | |||
416 | // Test attaching an already attached attachment | ||
417 | { | ||
418 | scene.AttachmentsModule.RezSingleAttachmentFromInventory( | ||
419 | sp, attItem.ID, (uint)AttachmentPoint.Chest); | ||
292 | 420 | ||
293 | // Check appearance status | 421 | // Check scene presence status |
294 | Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); | 422 | Assert.That(sp.HasAttachments(), Is.True); |
295 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | 423 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
424 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
425 | SceneObjectGroup attSo = attachments[0]; | ||
426 | Assert.That(attSo.Name, Is.EqualTo(attItem.Name)); | ||
427 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest)); | ||
428 | Assert.That(attSo.IsAttachment); | ||
429 | Assert.That(attSo.UsesPhysics, Is.False); | ||
430 | Assert.That(attSo.IsTemporary, Is.False); | ||
431 | |||
432 | // Check appearance status | ||
433 | Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); | ||
434 | Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); | ||
435 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | ||
436 | |||
437 | // Check events | ||
438 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
439 | } | ||
440 | } | ||
296 | 441 | ||
297 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 442 | /// <summary> |
443 | /// Test wearing an attachment from inventory, as opposed to explicit choosing the rez point | ||
444 | /// </summary> | ||
445 | [Test] | ||
446 | public void TestWearAttachmentFromInventory() | ||
447 | { | ||
448 | TestHelpers.InMethod(); | ||
449 | // TestHelpers.EnableLogging(); | ||
298 | 450 | ||
299 | // Check events | 451 | Scene scene = CreateTestScene(); |
300 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | 452 | UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(scene, 0x1); |
453 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID); | ||
454 | |||
455 | InventoryItemBase attItem1 = CreateAttachmentItem(scene, ua1.PrincipalID, "att1", 0x10, 0x20); | ||
456 | InventoryItemBase attItem2 = CreateAttachmentItem(scene, ua1.PrincipalID, "att2", 0x11, 0x21); | ||
457 | |||
458 | { | ||
459 | m_numberOfAttachEventsFired = 0; | ||
460 | scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem1.ID, (uint)AttachmentPoint.Default); | ||
461 | |||
462 | // default attachment point is currently the left hand. | ||
463 | Assert.That(sp.HasAttachments(), Is.True); | ||
464 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
465 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
466 | SceneObjectGroup attSo = attachments[0]; | ||
467 | Assert.That(attSo.Name, Is.EqualTo(attItem1.Name)); | ||
468 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); | ||
469 | Assert.That(attSo.IsAttachment); | ||
470 | |||
471 | // Check appearance status | ||
472 | Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); | ||
473 | Assert.That(sp.Appearance.GetAttachpoint(attItem1.ID), Is.EqualTo((int)AttachmentPoint.LeftHand)); | ||
474 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | ||
475 | |||
476 | // Check events | ||
477 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1)); | ||
478 | } | ||
479 | |||
480 | // Test wearing a second attachment at the same position | ||
481 | // Until multiple attachments at one point is implemented, this will remove the first attachment | ||
482 | // This test relies on both attachments having the same default attachment point (in this case LeftHand | ||
483 | // since none other has been set). | ||
484 | { | ||
485 | scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default); | ||
486 | |||
487 | // default attachment point is currently the left hand. | ||
488 | Assert.That(sp.HasAttachments(), Is.True); | ||
489 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
490 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
491 | SceneObjectGroup attSo = attachments[0]; | ||
492 | Assert.That(attSo.Name, Is.EqualTo(attItem2.Name)); | ||
493 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); | ||
494 | Assert.That(attSo.IsAttachment); | ||
495 | |||
496 | // Check appearance status | ||
497 | Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); | ||
498 | Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand)); | ||
499 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | ||
500 | |||
501 | // Check events | ||
502 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3)); | ||
503 | } | ||
504 | |||
505 | // Test wearing an already attached attachment | ||
506 | { | ||
507 | scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default); | ||
508 | |||
509 | // default attachment point is currently the left hand. | ||
510 | Assert.That(sp.HasAttachments(), Is.True); | ||
511 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | ||
512 | Assert.That(attachments.Count, Is.EqualTo(1)); | ||
513 | SceneObjectGroup attSo = attachments[0]; | ||
514 | Assert.That(attSo.Name, Is.EqualTo(attItem2.Name)); | ||
515 | Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand)); | ||
516 | Assert.That(attSo.IsAttachment); | ||
517 | |||
518 | // Check appearance status | ||
519 | Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1)); | ||
520 | Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand)); | ||
521 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | ||
522 | |||
523 | // Check events | ||
524 | Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3)); | ||
525 | } | ||
301 | } | 526 | } |
302 | 527 | ||
303 | /// <summary> | 528 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs index 37131b9..1f1568f 100644 --- a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs +++ b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DAExampleModule.cs | |||
@@ -39,7 +39,7 @@ using OpenSim.Region.Framework; | |||
39 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | 41 | ||
42 | namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule | 42 | namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule |
43 | { | 43 | { |
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")] | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")] |
45 | public class DAExampleModule : INonSharedRegionModule | 45 | public class DAExampleModule : INonSharedRegionModule |
@@ -48,6 +48,8 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule | |||
48 | 48 | ||
49 | private static readonly bool ENABLED = false; // enable for testing | 49 | private static readonly bool ENABLED = false; // enable for testing |
50 | 50 | ||
51 | public const string DANamespace = "DAExample Module"; | ||
52 | |||
51 | protected Scene m_scene; | 53 | protected Scene m_scene; |
52 | protected IDialogModule m_dialogMod; | 54 | protected IDialogModule m_dialogMod; |
53 | 55 | ||
@@ -85,19 +87,29 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule | |||
85 | { | 87 | { |
86 | OSDMap attrs = null; | 88 | OSDMap attrs = null; |
87 | SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId); | 89 | SceneObjectPart sop = m_scene.GetSceneObjectPart(groupId); |
88 | if (!sop.DynAttrs.TryGetValue(Name, out attrs)) | 90 | |
91 | if (sop == null) | ||
92 | return true; | ||
93 | |||
94 | if (!sop.DynAttrs.TryGetValue(DANamespace, out attrs)) | ||
89 | attrs = new OSDMap(); | 95 | attrs = new OSDMap(); |
90 | 96 | ||
91 | OSDInteger newValue; | 97 | OSDInteger newValue; |
92 | |||
93 | if (!attrs.ContainsKey("moves")) | ||
94 | newValue = new OSDInteger(1); | ||
95 | else | ||
96 | newValue = new OSDInteger(((OSDInteger)attrs["moves"]).AsInteger() + 1); | ||
97 | |||
98 | attrs["moves"] = newValue; | ||
99 | 98 | ||
100 | sop.DynAttrs[Name] = attrs; | 99 | // We have to lock on the entire dynamic attributes map to avoid race conditions with serialization code. |
100 | lock (sop.DynAttrs) | ||
101 | { | ||
102 | if (!attrs.ContainsKey("moves")) | ||
103 | newValue = new OSDInteger(1); | ||
104 | else | ||
105 | newValue = new OSDInteger(attrs["moves"].AsInteger() + 1); | ||
106 | |||
107 | attrs["moves"] = newValue; | ||
108 | |||
109 | sop.DynAttrs[DANamespace] = attrs; | ||
110 | } | ||
111 | |||
112 | sop.ParentGroup.HasGroupChanged = true; | ||
101 | 113 | ||
102 | m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue)); | 114 | m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue)); |
103 | 115 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DOExampleModule.cs b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DOExampleModule.cs new file mode 100644 index 0000000..650aa35 --- /dev/null +++ b/OpenSim/Region/CoreModules/Framework/DynamicAttributes/DOExampleModule.cs | |||
@@ -0,0 +1,139 @@ | |||
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.Reflection; | ||
31 | using log4net; | ||
32 | using Mono.Addins; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenMetaverse.Packets; | ||
36 | using OpenMetaverse.StructuredData; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.Framework; | ||
39 | using OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Region.Framework.Scenes; | ||
42 | |||
43 | namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule | ||
44 | { | ||
45 | /// <summary> | ||
46 | /// Example module for experimenting with and demonstrating dynamic object ideas. | ||
47 | /// </summary> | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DOExampleModule")] | ||
49 | public class DOExampleModule : INonSharedRegionModule | ||
50 | { | ||
51 | public class MyObject | ||
52 | { | ||
53 | public int Moves { get; set; } | ||
54 | |||
55 | public MyObject(int moves) | ||
56 | { | ||
57 | Moves = moves; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
62 | |||
63 | private static readonly bool ENABLED = false; // enable for testing | ||
64 | |||
65 | private Scene m_scene; | ||
66 | private IDialogModule m_dialogMod; | ||
67 | |||
68 | public string Name { get { return "DOExample Module"; } } | ||
69 | public Type ReplaceableInterface { get { return null; } } | ||
70 | |||
71 | public void Initialise(IConfigSource source) {} | ||
72 | |||
73 | public void AddRegion(Scene scene) | ||
74 | { | ||
75 | if (ENABLED) | ||
76 | { | ||
77 | m_scene = scene; | ||
78 | m_scene.EventManager.OnObjectAddedToScene += OnObjectAddedToScene; | ||
79 | m_scene.EventManager.OnSceneGroupMove += OnSceneGroupMove; | ||
80 | m_dialogMod = m_scene.RequestModuleInterface<IDialogModule>(); | ||
81 | } | ||
82 | } | ||
83 | |||
84 | public void RemoveRegion(Scene scene) | ||
85 | { | ||
86 | if (ENABLED) | ||
87 | { | ||
88 | m_scene.EventManager.OnSceneGroupMove -= OnSceneGroupMove; | ||
89 | } | ||
90 | } | ||
91 | |||
92 | public void RegionLoaded(Scene scene) {} | ||
93 | |||
94 | public void Close() | ||
95 | { | ||
96 | RemoveRegion(m_scene); | ||
97 | } | ||
98 | |||
99 | private void OnObjectAddedToScene(SceneObjectGroup so) | ||
100 | { | ||
101 | SceneObjectPart rootPart = so.RootPart; | ||
102 | |||
103 | OSDMap attrs; | ||
104 | |||
105 | int movesSoFar = 0; | ||
106 | |||
107 | // Console.WriteLine("Here for {0}", so.Name); | ||
108 | |||
109 | if (rootPart.DynAttrs.TryGetValue(DAExampleModule.DANamespace, out attrs)) | ||
110 | { | ||
111 | movesSoFar = attrs["moves"].AsInteger(); | ||
112 | |||
113 | m_log.DebugFormat( | ||
114 | "[DO EXAMPLE MODULE]: Found saved moves {0} for {1} in {2}", movesSoFar, so.Name, m_scene.Name); | ||
115 | } | ||
116 | |||
117 | rootPart.DynObjs.Add(Name, new MyObject(movesSoFar)); | ||
118 | } | ||
119 | |||
120 | private bool OnSceneGroupMove(UUID groupId, Vector3 delta) | ||
121 | { | ||
122 | SceneObjectGroup so = m_scene.GetSceneObjectGroup(groupId); | ||
123 | |||
124 | if (so == null) | ||
125 | return true; | ||
126 | |||
127 | object rawObj = so.RootPart.DynObjs.Get(Name); | ||
128 | |||
129 | if (rawObj != null) | ||
130 | { | ||
131 | MyObject myObj = (MyObject)rawObj; | ||
132 | |||
133 | m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", so.Name, so.UUID, ++myObj.Moves)); | ||
134 | } | ||
135 | |||
136 | return true; | ||
137 | } | ||
138 | } | ||
139 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 07c3666..9b1b69a 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -66,6 +66,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
66 | /// </summary> | 66 | /// </summary> |
67 | public bool WaitForAgentArrivedAtDestination { get; set; } | 67 | public bool WaitForAgentArrivedAtDestination { get; set; } |
68 | 68 | ||
69 | /// <summary> | ||
70 | /// If true then we ask the viewer to disable teleport cancellation and ignore teleport requests. | ||
71 | /// </summary> | ||
72 | /// <remarks> | ||
73 | /// This is useful in situations where teleport is very likely to always succeed and we want to avoid a | ||
74 | /// situation where avatars can be come 'stuck' due to a failed teleport cancellation. Unfortunately, the | ||
75 | /// nature of the teleport protocol makes it extremely difficult (maybe impossible) to make teleport | ||
76 | /// cancellation consistently suceed. | ||
77 | /// </remarks> | ||
78 | public bool DisableInterRegionTeleportCancellation { get; set; } | ||
79 | |||
69 | protected bool m_Enabled = false; | 80 | protected bool m_Enabled = false; |
70 | 81 | ||
71 | public Scene Scene { get; private set; } | 82 | public Scene Scene { get; private set; } |
@@ -116,6 +127,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
116 | IConfig transferConfig = source.Configs["EntityTransfer"]; | 127 | IConfig transferConfig = source.Configs["EntityTransfer"]; |
117 | if (transferConfig != null) | 128 | if (transferConfig != null) |
118 | { | 129 | { |
130 | DisableInterRegionTeleportCancellation | ||
131 | = transferConfig.GetBoolean("DisableInterRegionTeleportCancellation", false); | ||
132 | |||
119 | WaitForAgentArrivedAtDestination | 133 | WaitForAgentArrivedAtDestination |
120 | = transferConfig.GetBoolean("wait_for_callback", WaitForAgentArrivedAtDestinationDefault); | 134 | = transferConfig.GetBoolean("wait_for_callback", WaitForAgentArrivedAtDestinationDefault); |
121 | 135 | ||
@@ -150,6 +164,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
150 | { | 164 | { |
151 | client.OnTeleportHomeRequest += TeleportHome; | 165 | client.OnTeleportHomeRequest += TeleportHome; |
152 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; | 166 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; |
167 | |||
168 | if (!DisableInterRegionTeleportCancellation) | ||
169 | client.OnTeleportCancel += OnClientCancelTeleport; | ||
153 | } | 170 | } |
154 | 171 | ||
155 | public virtual void Close() {} | 172 | public virtual void Close() {} |
@@ -168,6 +185,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
168 | 185 | ||
169 | #region Agent Teleports | 186 | #region Agent Teleports |
170 | 187 | ||
188 | private void OnClientCancelTeleport(IClientAPI client) | ||
189 | { | ||
190 | m_entityTransferStateMachine.UpdateInTransit(client.AgentId, AgentTransferState.Cancelling); | ||
191 | |||
192 | m_log.DebugFormat( | ||
193 | "[ENTITY TRANSFER MODULE]: Received teleport cancel request from {0} in {1}", client.Name, Scene.Name); | ||
194 | } | ||
195 | |||
171 | public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) | 196 | public void Teleport(ScenePresence sp, ulong regionHandle, Vector3 position, Vector3 lookAt, uint teleportFlags) |
172 | { | 197 | { |
173 | if (sp.Scene.Permissions.IsGridGod(sp.UUID)) | 198 | if (sp.Scene.Permissions.IsGridGod(sp.UUID)) |
@@ -519,6 +544,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
519 | if (sp.ParentID != (uint)0) | 544 | if (sp.ParentID != (uint)0) |
520 | sp.StandUp(); | 545 | sp.StandUp(); |
521 | 546 | ||
547 | if (DisableInterRegionTeleportCancellation) | ||
548 | teleportFlags |= (uint)TeleportFlags.DisableCancel; | ||
549 | |||
522 | // At least on LL 3.3.4, this is not strictly necessary - a teleport will succeed without sending this to | 550 | // At least on LL 3.3.4, this is not strictly necessary - a teleport will succeed without sending this to |
523 | // the viewer. However, it might mean that the viewer does not see the black teleport screen (untested). | 551 | // the viewer. However, it might mean that the viewer does not see the black teleport screen (untested). |
524 | sp.ControllingClient.SendTeleportStart(teleportFlags); | 552 | sp.ControllingClient.SendTeleportStart(teleportFlags); |
@@ -567,6 +595,15 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
567 | return; | 595 | return; |
568 | } | 596 | } |
569 | 597 | ||
598 | if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Cancelling) | ||
599 | { | ||
600 | m_log.DebugFormat( | ||
601 | "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after CreateAgent on client request", | ||
602 | sp.Name, finalDestination.RegionName, sp.Scene.Name); | ||
603 | |||
604 | return; | ||
605 | } | ||
606 | |||
570 | // Past this point we have to attempt clean up if the teleport fails, so update transfer state. | 607 | // Past this point we have to attempt clean up if the teleport fails, so update transfer state. |
571 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); | 608 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.Transferring); |
572 | 609 | ||
@@ -631,7 +668,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
631 | return; | 668 | return; |
632 | } | 669 | } |
633 | 670 | ||
634 | sp.ControllingClient.SendTeleportProgress(teleportFlags | (uint)TeleportFlags.DisableCancel, "sending_dest"); | 671 | if (m_entityTransferStateMachine.GetAgentTransferState(sp.UUID) == AgentTransferState.Cancelling) |
672 | { | ||
673 | m_log.DebugFormat( | ||
674 | "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request", | ||
675 | sp.Name, finalDestination.RegionName, sp.Scene.Name); | ||
676 | |||
677 | CleanupAbortedInterRegionTeleport(sp, finalDestination); | ||
678 | |||
679 | return; | ||
680 | } | ||
635 | 681 | ||
636 | m_log.DebugFormat( | 682 | m_log.DebugFormat( |
637 | "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}", | 683 | "[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} from {1} to {2}", |
@@ -714,14 +760,19 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
714 | // } | 760 | // } |
715 | } | 761 | } |
716 | 762 | ||
717 | protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout) | 763 | /// <summary> |
764 | /// Clean up an inter-region teleport that did not complete, either because of simulator failure or cancellation. | ||
765 | /// </summary> | ||
766 | /// <remarks> | ||
767 | /// All operations here must be idempotent so that we can call this method at any point in the teleport process | ||
768 | /// up until we send the TeleportFinish event quene event to the viewer. | ||
769 | /// <remarks> | ||
770 | /// <param name='sp'> </param> | ||
771 | /// <param name='finalDestination'></param> | ||
772 | protected virtual void CleanupAbortedInterRegionTeleport(ScenePresence sp, GridRegion finalDestination) | ||
718 | { | 773 | { |
719 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); | 774 | m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); |
720 | 775 | ||
721 | // Client never contacted destination. Let's restore everything back | ||
722 | sp.ControllingClient.SendTeleportFailed("Problems connecting to destination."); | ||
723 | |||
724 | // Fail. Reset it back | ||
725 | sp.IsChildAgent = false; | 776 | sp.IsChildAgent = false; |
726 | ReInstantiateScripts(sp); | 777 | ReInstantiateScripts(sp); |
727 | 778 | ||
@@ -729,7 +780,20 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
729 | 780 | ||
730 | // Finally, kill the agent we just created at the destination. | 781 | // Finally, kill the agent we just created at the destination. |
731 | Scene.SimulationService.CloseAgent(finalDestination, sp.UUID); | 782 | Scene.SimulationService.CloseAgent(finalDestination, sp.UUID); |
783 | } | ||
732 | 784 | ||
785 | /// <summary> | ||
786 | /// Signal that the inter-region teleport failed and perform cleanup. | ||
787 | /// </summary> | ||
788 | /// <param name='sp'></param> | ||
789 | /// <param name='finalDestination'></param> | ||
790 | /// <param name='logout'></param> | ||
791 | protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout) | ||
792 | { | ||
793 | CleanupAbortedInterRegionTeleport(sp, finalDestination); | ||
794 | |||
795 | sp.ControllingClient.SendTeleportFailed( | ||
796 | string.Format("Problems connecting to destination {0}", finalDestination.RegionName)); | ||
733 | sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout); | 797 | sp.Scene.EventManager.TriggerTeleportFail(sp.ControllingClient, logout); |
734 | } | 798 | } |
735 | 799 | ||
@@ -1206,6 +1270,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1206 | // region doesn't take it | 1270 | // region doesn't take it |
1207 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); | 1271 | m_entityTransferStateMachine.UpdateInTransit(agent.UUID, AgentTransferState.CleaningUp); |
1208 | 1272 | ||
1273 | m_log.WarnFormat( | ||
1274 | "[ENTITY TRANSFER MODULE]: Region {0} would not accept update for agent {1} on cross attempt. Returning to original region.", | ||
1275 | neighbourRegion.RegionName, agent.Name); | ||
1276 | |||
1209 | ReInstantiateScripts(agent); | 1277 | ReInstantiateScripts(agent); |
1210 | agent.AddToPhysicalScene(isFlying); | 1278 | agent.AddToPhysicalScene(isFlying); |
1211 | 1279 | ||
@@ -1225,6 +1293,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1225 | neighbourRegion.RegionHandle); | 1293 | neighbourRegion.RegionHandle); |
1226 | return agent; | 1294 | return agent; |
1227 | } | 1295 | } |
1296 | |||
1228 | // No turning back | 1297 | // No turning back |
1229 | agent.IsChildAgent = true; | 1298 | agent.IsChildAgent = true; |
1230 | 1299 | ||
@@ -2092,7 +2161,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
2092 | 2161 | ||
2093 | public bool IsInTransit(UUID id) | 2162 | public bool IsInTransit(UUID id) |
2094 | { | 2163 | { |
2095 | return m_entityTransferStateMachine.IsInTransit(id); | 2164 | return m_entityTransferStateMachine.GetAgentTransferState(id) != null; |
2096 | } | 2165 | } |
2097 | 2166 | ||
2098 | protected void ReInstantiateScripts(ScenePresence sp) | 2167 | protected void ReInstantiateScripts(ScenePresence sp) |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs index d0cab49..24d81d9 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferStateMachine.cs | |||
@@ -51,8 +51,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
51 | /// This is a state machine. | 51 | /// This is a state machine. |
52 | /// | 52 | /// |
53 | /// [Entry] => Preparing | 53 | /// [Entry] => Preparing |
54 | /// Preparing => { Transferring || CleaningUp || [Exit] } | 54 | /// Preparing => { Transferring || Cancelling || CleaningUp || [Exit] } |
55 | /// Transferring => { ReceivedAtDestination || CleaningUp } | 55 | /// Transferring => { ReceivedAtDestination || Cancelling || CleaningUp } |
56 | /// Cancelling => CleaningUp | ||
56 | /// ReceivedAtDestination => CleaningUp | 57 | /// ReceivedAtDestination => CleaningUp |
57 | /// CleaningUp => [Exit] | 58 | /// CleaningUp => [Exit] |
58 | /// | 59 | /// |
@@ -64,7 +65,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
64 | Preparing, // The agent is being prepared for transfer | 65 | Preparing, // The agent is being prepared for transfer |
65 | Transferring, // The agent is in the process of being transferred to a destination | 66 | Transferring, // The agent is in the process of being transferred to a destination |
66 | ReceivedAtDestination, // The destination has notified us that the agent has been successfully received | 67 | ReceivedAtDestination, // The destination has notified us that the agent has been successfully received |
67 | CleaningUp // The agent is being changed to child/removed after a transfer | 68 | CleaningUp, // The agent is being changed to child/removed after a transfer |
69 | Cancelling // The user has cancelled the teleport but we have yet to act upon this. | ||
68 | } | 70 | } |
69 | 71 | ||
70 | /// <summary> | 72 | /// <summary> |
@@ -115,42 +117,110 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
115 | /// <param name='newState'></param> | 117 | /// <param name='newState'></param> |
116 | /// <returns></returns> | 118 | /// <returns></returns> |
117 | /// <exception cref='Exception'>Illegal transitions will throw an Exception</exception> | 119 | /// <exception cref='Exception'>Illegal transitions will throw an Exception</exception> |
118 | internal void UpdateInTransit(UUID id, AgentTransferState newState) | 120 | internal bool UpdateInTransit(UUID id, AgentTransferState newState) |
119 | { | 121 | { |
122 | bool transitionOkay = false; | ||
123 | |||
124 | // We don't want to throw an exception on cancel since this can come it at any time. | ||
125 | bool failIfNotOkay = true; | ||
126 | |||
127 | // Should be a failure message if failure is not okay. | ||
128 | string failureMessage = null; | ||
129 | |||
130 | AgentTransferState? oldState = null; | ||
131 | |||
120 | lock (m_agentsInTransit) | 132 | lock (m_agentsInTransit) |
121 | { | 133 | { |
122 | // Illegal to try and update an agent that's not actually in transit. | 134 | // Illegal to try and update an agent that's not actually in transit. |
123 | if (!m_agentsInTransit.ContainsKey(id)) | 135 | if (!m_agentsInTransit.ContainsKey(id)) |
124 | throw new Exception( | 136 | { |
125 | string.Format( | 137 | if (newState != AgentTransferState.Cancelling) |
126 | "Agent with ID {0} is not registered as in transit in {1}", | 138 | failureMessage = string.Format( |
127 | id, m_mod.Scene.RegionInfo.RegionName)); | 139 | "Agent with ID {0} is not registered as in transit in {1}", |
128 | 140 | id, m_mod.Scene.RegionInfo.RegionName); | |
129 | AgentTransferState oldState = m_agentsInTransit[id]; | 141 | else |
142 | failIfNotOkay = false; | ||
143 | } | ||
144 | else | ||
145 | { | ||
146 | oldState = m_agentsInTransit[id]; | ||
130 | 147 | ||
131 | bool transitionOkay = false; | 148 | if (newState == AgentTransferState.CleaningUp && oldState != AgentTransferState.CleaningUp) |
149 | { | ||
150 | transitionOkay = true; | ||
151 | } | ||
152 | else if (newState == AgentTransferState.Transferring && oldState == AgentTransferState.Preparing) | ||
153 | { | ||
154 | transitionOkay = true; | ||
155 | } | ||
156 | else if (newState == AgentTransferState.ReceivedAtDestination && oldState == AgentTransferState.Transferring) | ||
157 | { | ||
158 | transitionOkay = true; | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | if (newState == AgentTransferState.Cancelling | ||
163 | && (oldState == AgentTransferState.Preparing || oldState == AgentTransferState.Transferring)) | ||
164 | { | ||
165 | transitionOkay = true; | ||
166 | } | ||
167 | else | ||
168 | { | ||
169 | failIfNotOkay = false; | ||
170 | } | ||
171 | } | ||
132 | 172 | ||
133 | if (newState == AgentTransferState.CleaningUp && oldState != AgentTransferState.CleaningUp) | 173 | if (!transitionOkay) |
134 | transitionOkay = true; | 174 | failureMessage |
135 | else if (newState == AgentTransferState.Transferring && oldState == AgentTransferState.Preparing) | 175 | = string.Format( |
136 | transitionOkay = true; | 176 | "Agent with ID {0} is not allowed to move from old transit state {1} to new state {2} in {3}", |
137 | else if (newState == AgentTransferState.ReceivedAtDestination && oldState == AgentTransferState.Transferring) | 177 | id, oldState, newState, m_mod.Scene.RegionInfo.RegionName); |
138 | transitionOkay = true; | 178 | } |
139 | 179 | ||
140 | if (transitionOkay) | 180 | if (transitionOkay) |
181 | { | ||
141 | m_agentsInTransit[id] = newState; | 182 | m_agentsInTransit[id] = newState; |
142 | else | 183 | |
143 | throw new Exception( | 184 | // m_log.DebugFormat( |
144 | string.Format( | 185 | // "[ENTITY TRANSFER STATE MACHINE]: Changed agent with id {0} from state {1} to {2} in {3}", |
145 | "Agent with ID {0} is not allowed to move from old transit state {1} to new state {2} in {3}", | 186 | // id, oldState, newState, m_mod.Scene.Name); |
146 | id, oldState, newState, m_mod.Scene.RegionInfo.RegionName)); | 187 | } |
188 | else if (failIfNotOkay) | ||
189 | { | ||
190 | throw new Exception(failureMessage); | ||
191 | } | ||
192 | // else | ||
193 | // { | ||
194 | // if (oldState != null) | ||
195 | // m_log.DebugFormat( | ||
196 | // "[ENTITY TRANSFER STATE MACHINE]: Ignored change of agent with id {0} from state {1} to {2} in {3}", | ||
197 | // id, oldState, newState, m_mod.Scene.Name); | ||
198 | // else | ||
199 | // m_log.DebugFormat( | ||
200 | // "[ENTITY TRANSFER STATE MACHINE]: Ignored change of agent with id {0} to state {1} in {2} since agent not in transit", | ||
201 | // id, newState, m_mod.Scene.Name); | ||
202 | // } | ||
147 | } | 203 | } |
204 | |||
205 | return transitionOkay; | ||
148 | } | 206 | } |
149 | 207 | ||
150 | internal bool IsInTransit(UUID id) | 208 | /// <summary> |
209 | /// Gets the current agent transfer state. | ||
210 | /// </summary> | ||
211 | /// <returns>Null if the agent is not in transit</returns> | ||
212 | /// <param name='id'> | ||
213 | /// Identifier. | ||
214 | /// </param> | ||
215 | internal AgentTransferState? GetAgentTransferState(UUID id) | ||
151 | { | 216 | { |
152 | lock (m_agentsInTransit) | 217 | lock (m_agentsInTransit) |
153 | return m_agentsInTransit.ContainsKey(id); | 218 | { |
219 | if (!m_agentsInTransit.ContainsKey(id)) | ||
220 | return null; | ||
221 | else | ||
222 | return m_agentsInTransit[id]; | ||
223 | } | ||
154 | } | 224 | } |
155 | 225 | ||
156 | /// <summary> | 226 | /// <summary> |
@@ -203,14 +273,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
203 | 273 | ||
204 | lock (m_agentsInTransit) | 274 | lock (m_agentsInTransit) |
205 | { | 275 | { |
206 | if (!IsInTransit(id)) | 276 | AgentTransferState? currentState = GetAgentTransferState(id); |
277 | |||
278 | if (currentState == null) | ||
207 | throw new Exception( | 279 | throw new Exception( |
208 | string.Format( | 280 | string.Format( |
209 | "Asked to wait for destination callback for agent with ID {0} in {1} but agent is not in transit", | 281 | "Asked to wait for destination callback for agent with ID {0} in {1} but agent is not in transit", |
210 | id, m_mod.Scene.RegionInfo.RegionName)); | 282 | id, m_mod.Scene.RegionInfo.RegionName)); |
211 | 283 | ||
212 | AgentTransferState currentState = m_agentsInTransit[id]; | ||
213 | |||
214 | if (currentState != AgentTransferState.Transferring && currentState != AgentTransferState.ReceivedAtDestination) | 284 | if (currentState != AgentTransferState.Transferring && currentState != AgentTransferState.ReceivedAtDestination) |
215 | throw new Exception( | 285 | throw new Exception( |
216 | string.Format( | 286 | string.Format( |
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index 4c9ee06..64feec1 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs | |||
@@ -414,8 +414,6 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
414 | } | 414 | } |
415 | private void RegisterStatsManagerRegionStatistics() | 415 | private void RegisterStatsManagerRegionStatistics() |
416 | { | 416 | { |
417 | string regionName = m_scene.RegionInfo.RegionName; | ||
418 | |||
419 | MakeStat("RootAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetRootAgentCount(); }); | 417 | MakeStat("RootAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetRootAgentCount(); }); |
420 | MakeStat("ChildAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetChildAgentCount(); }); | 418 | MakeStat("ChildAgents", "avatars", (s) => { s.Value = m_scene.SceneGraph.GetChildAgentCount(); }); |
421 | MakeStat("TotalPrims", "objects", (s) => { s.Value = m_scene.SceneGraph.GetTotalObjectsCount(); }); | 419 | MakeStat("TotalPrims", "objects", (s) => { s.Value = m_scene.SceneGraph.GetTotalObjectsCount(); }); |
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index f04fabe..4cecd85 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | |||
@@ -516,6 +516,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
516 | foreach (string line in GetLines(data, dataDelim)) | 516 | foreach (string line in GetLines(data, dataDelim)) |
517 | { | 517 | { |
518 | string nextLine = line.Trim(); | 518 | string nextLine = line.Trim(); |
519 | |||
520 | // m_log.DebugFormat("[VECTOR RENDER MODULE]: Processing line '{0}'", nextLine); | ||
521 | |||
519 | //replace with switch, or even better, do some proper parsing | 522 | //replace with switch, or even better, do some proper parsing |
520 | if (nextLine.StartsWith("MoveTo")) | 523 | if (nextLine.StartsWith("MoveTo")) |
521 | { | 524 | { |
@@ -829,6 +832,8 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
829 | float y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture); | 832 | float y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture); |
830 | PointF point = new PointF(x, y); | 833 | PointF point = new PointF(x, y); |
831 | points[i / 2] = point; | 834 | points[i / 2] = point; |
835 | |||
836 | // m_log.DebugFormat("[VECTOR RENDER MODULE]: Got point {0}", points[i / 2]); | ||
832 | } | 837 | } |
833 | } | 838 | } |
834 | } | 839 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 3c18074..a413546 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -219,12 +219,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
219 | { | 219 | { |
220 | // m_log.DebugFormat( | 220 | // m_log.DebugFormat( |
221 | // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", | 221 | // "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", |
222 | // s.RegionInfo.RegionName, destination.RegionHandle); | 222 | // destination.RegionName, destination.RegionID); |
223 | 223 | ||
224 | return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData); | 224 | return m_scenes[destination.RegionID].IncomingChildAgentDataUpdate(cAgentData); |
225 | } | 225 | } |
226 | 226 | ||
227 | // m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle); | 227 | // m_log.DebugFormat( |
228 | // "[LOCAL COMMS]: Did not find region {0} {1} for ChildAgentUpdate", | ||
229 | // destination.RegionName, destination.RegionID); | ||
230 | |||
228 | return false; | 231 | return false; |
229 | } | 232 | } |
230 | 233 | ||
@@ -239,7 +242,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
239 | // note that we really don't need the GridRegion for this call | 242 | // note that we really don't need the GridRegion for this call |
240 | foreach (Scene s in m_scenes.Values) | 243 | foreach (Scene s in m_scenes.Values) |
241 | { | 244 | { |
242 | //m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); | 245 | // m_log.Debug("[LOCAL COMMS]: Found region to send ChildAgentUpdate"); |
243 | s.IncomingChildAgentDataUpdate(cAgentData); | 246 | s.IncomingChildAgentDataUpdate(cAgentData); |
244 | } | 247 | } |
245 | 248 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs index 7fc358d..73c592d 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandChannel.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandChannel.cs | |||
@@ -95,6 +95,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
95 | return null; | 95 | return null; |
96 | } | 96 | } |
97 | 97 | ||
98 | public ILandObject GetLandObject(Vector3 position) | ||
99 | { | ||
100 | return GetLandObject(position.X, position.Y); | ||
101 | } | ||
102 | |||
98 | public ILandObject GetLandObject(int x, int y) | 103 | public ILandObject GetLandObject(int x, int y) |
99 | { | 104 | { |
100 | if (m_landManagementModule != null) | 105 | if (m_landManagementModule != null) |