diff options
author | Justin Clark-Casey (justincc) | 2010-02-01 20:06:43 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-02-01 20:06:43 +0000 |
commit | 53a01dc42273b9252eb290187e87a47a898af86a (patch) | |
tree | 28e2e2d139c379667a6e6cb337fa9c2326a58b96 /OpenSim/Region | |
parent | apply http://opensimulator.org/mantis/view.php?id=4486 (diff) | |
download | opensim-SC_OLD-53a01dc42273b9252eb290187e87a47a898af86a.zip opensim-SC_OLD-53a01dc42273b9252eb290187e87a47a898af86a.tar.gz opensim-SC_OLD-53a01dc42273b9252eb290187e87a47a898af86a.tar.bz2 opensim-SC_OLD-53a01dc42273b9252eb290187e87a47a898af86a.tar.xz |
Don't try to start attachment scripts or send updates if the attachment itself has been unsuccessful
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneGraph.cs | 77 |
2 files changed, 64 insertions, 27 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 11754ea..7df3e50 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -2376,9 +2376,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2376 | } | 2376 | } |
2377 | } | 2377 | } |
2378 | 2378 | ||
2379 | public void AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent) | 2379 | /// <summary> |
2380 | /// Attach an object. | ||
2381 | /// </summary> | ||
2382 | /// <param name="controllingClient"></param> | ||
2383 | /// <param name="localID"></param> | ||
2384 | /// <param name="attachPoint"></param> | ||
2385 | /// <param name="rot"></param> | ||
2386 | /// <param name="pos"></param> | ||
2387 | /// <param name="silent"></param> | ||
2388 | /// <returns>true if the object was successfully attached, false otherwise</returns> | ||
2389 | public bool AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent) | ||
2380 | { | 2390 | { |
2381 | m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent); | 2391 | return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent); |
2382 | } | 2392 | } |
2383 | 2393 | ||
2384 | public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | 2394 | public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index f74fd5d..fc2798d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -478,46 +478,59 @@ namespace OpenSim.Region.Framework.Scenes | |||
478 | if (part == null) | 478 | if (part == null) |
479 | return; | 479 | return; |
480 | 480 | ||
481 | if (!m_parentScene.Permissions.CanTakeObject( | 481 | if (!m_parentScene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) |
482 | part.UUID, remoteClient.AgentId)) | ||
483 | return; | 482 | return; |
484 | 483 | ||
485 | // Calls attach with a Zero position | 484 | // Calls attach with a Zero position |
486 | AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false); | 485 | if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) |
487 | m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); | ||
488 | |||
489 | // Save avatar attachment information | ||
490 | ScenePresence presence; | ||
491 | if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence)) | ||
492 | { | 486 | { |
493 | m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", AttachmentPoint: " + AttachmentPt); | 487 | m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); |
494 | m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | 488 | |
489 | // Save avatar attachment information | ||
490 | ScenePresence presence; | ||
491 | if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence)) | ||
492 | { | ||
493 | m_log.Info( | ||
494 | "[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | ||
495 | + ", AttachmentPoint: " + AttachmentPt); | ||
496 | |||
497 | m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
498 | } | ||
495 | } | 499 | } |
496 | } | 500 | } |
497 | 501 | ||
498 | public SceneObjectGroup RezSingleAttachment( | 502 | /// <summary> |
499 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 503 | /// Rez an attachment |
504 | /// </summary> | ||
505 | /// <param name="remoteClient"></param> | ||
506 | /// <param name="itemID"></param> | ||
507 | /// <param name="AttachmentPt"></param> | ||
508 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> | ||
509 | public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | ||
500 | { | 510 | { |
501 | SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, | 511 | SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, |
502 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | 512 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, |
503 | false, false, remoteClient.AgentId, true); | 513 | false, false, remoteClient.AgentId, true); |
504 | 514 | ||
505 | |||
506 | if (objatt != null) | 515 | if (objatt != null) |
507 | { | 516 | { |
508 | bool tainted = false; | 517 | bool tainted = false; |
509 | if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) | 518 | if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) |
510 | tainted = true; | 519 | tainted = true; |
511 | 520 | ||
512 | AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false); | 521 | if (AttachObject( |
513 | objatt.ScheduleGroupForFullUpdate(); | 522 | remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false)) |
514 | if (tainted) | 523 | { |
515 | objatt.HasGroupChanged = true; | 524 | objatt.ScheduleGroupForFullUpdate(); |
516 | 525 | if (tainted) | |
517 | // Fire after attach, so we don't get messy perms dialogs | 526 | objatt.HasGroupChanged = true; |
518 | // 3 == AttachedRez | 527 | |
519 | objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); | 528 | // Fire after attach, so we don't get messy perms dialogs |
529 | // 3 == AttachedRez | ||
530 | objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); | ||
531 | } | ||
520 | } | 532 | } |
533 | |||
521 | return objatt; | 534 | return objatt; |
522 | } | 535 | } |
523 | 536 | ||
@@ -554,7 +567,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
554 | } | 567 | } |
555 | } | 568 | } |
556 | 569 | ||
557 | protected internal void AttachObject( | 570 | /// <summary> |
571 | /// Attach a scene object to an avatar. | ||
572 | /// </summary> | ||
573 | /// <param name="remoteClient"></param> | ||
574 | /// <param name="objectLocalID"></param> | ||
575 | /// <param name="AttachmentPt"></param> | ||
576 | /// <param name="rot"></param> | ||
577 | /// <param name="attachPos"></param> | ||
578 | /// <param name="silent"></param> | ||
579 | /// <returns>true if the attachment was successful, false otherwise</returns> | ||
580 | protected internal bool AttachObject( | ||
558 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) | 581 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) |
559 | { | 582 | { |
560 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); | 583 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); |
@@ -583,10 +606,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
583 | // Stick it on left hand with Zero Offset from the attachment point. | 606 | // Stick it on left hand with Zero Offset from the attachment point. |
584 | AttachmentPt = (uint)AttachmentPoint.LeftHand; | 607 | AttachmentPt = (uint)AttachmentPoint.LeftHand; |
585 | attachPos = Vector3.Zero; | 608 | attachPos = Vector3.Zero; |
586 | |||
587 | } | 609 | } |
588 | 610 | ||
589 | |||
590 | group.SetAttachmentPoint((byte)AttachmentPt); | 611 | group.SetAttachmentPoint((byte)AttachmentPt); |
591 | group.AbsolutePosition = attachPos; | 612 | group.AbsolutePosition = attachPos; |
592 | 613 | ||
@@ -609,15 +630,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
609 | // it get cleaned up | 630 | // it get cleaned up |
610 | // | 631 | // |
611 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | 632 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); |
612 | group.HasGroupChanged = false; | 633 | group.HasGroupChanged = false; |
613 | } | 634 | } |
614 | else | 635 | else |
615 | { | 636 | { |
616 | remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false); | 637 | remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false); |
638 | return false; | ||
617 | } | 639 | } |
618 | } | 640 | } |
619 | else | 641 | else |
642 | { | ||
620 | m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID); | 643 | m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID); |
644 | return false; | ||
645 | } | ||
646 | |||
647 | return true; | ||
621 | } | 648 | } |
622 | 649 | ||
623 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) | 650 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) |