diff options
author | Justin Clark-Casey (justincc) | 2011-09-13 22:13:58 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-09-13 22:13:58 +0100 |
commit | 8880aea728af2ccb95ea2400c7d180aa4dc98112 (patch) | |
tree | 76c22d083c04041b05e1dcf57be40970b8969793 /OpenSim/Region/CoreModules | |
parent | Comment out attachments code in Scene.IncomingCreateObject(UUID userID, UUID ... (diff) | |
download | opensim-SC_OLD-8880aea728af2ccb95ea2400c7d180aa4dc98112.zip opensim-SC_OLD-8880aea728af2ccb95ea2400c7d180aa4dc98112.tar.gz opensim-SC_OLD-8880aea728af2ccb95ea2400c7d180aa4dc98112.tar.bz2 opensim-SC_OLD-8880aea728af2ccb95ea2400c7d180aa4dc98112.tar.xz |
Stop attempts to rewear already worn items from removing and reattaching.
Viewer 2/3 will sometimes attempt to rewear attachments, even though they have already been attached during the main login process.
This change ignores those attempts.
This stops script failures during login, as the rewearing was racing with the script startup code.
It might also help with attachments being abnormally put into deleted state.
Hopefully resolves some more of http://opensimulator.org/mantis/view.php?id=5644
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 119 |
1 files changed, 77 insertions, 42 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index c817559..1e9a001 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -147,18 +147,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
147 | 147 | ||
148 | foreach (SceneObjectGroup grp in sp.GetAttachments()) | 148 | foreach (SceneObjectGroup grp in sp.GetAttachments()) |
149 | { | 149 | { |
150 | if (grp.HasGroupChanged) // Resizer scripts? | 150 | // if (grp.HasGroupChanged) // Resizer scripts? |
151 | { | 151 | // { |
152 | grp.IsAttachment = false; | 152 | grp.IsAttachment = false; |
153 | grp.AbsolutePosition = grp.RootPart.AttachedPos; | 153 | grp.AbsolutePosition = grp.RootPart.AttachedPos; |
154 | UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID); | 154 | UpdateKnownItem(sp.ControllingClient, grp, grp.GetFromItemID(), grp.OwnerID); |
155 | grp.IsAttachment = true; | 155 | grp.IsAttachment = true; |
156 | } | 156 | // } |
157 | } | 157 | } |
158 | } | 158 | } |
159 | 159 | ||
160 | public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) | 160 | public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent) |
161 | { | 161 | { |
162 | // m_log.DebugFormat( | ||
163 | // "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}", | ||
164 | // m_scene.RegionInfo.RegionName, sp.Name, silent); | ||
165 | |||
162 | foreach (SceneObjectGroup sop in sp.GetAttachments()) | 166 | foreach (SceneObjectGroup sop in sp.GetAttachments()) |
163 | { | 167 | { |
164 | sop.Scene.DeleteSceneObject(sop, silent); | 168 | sop.Scene.DeleteSceneObject(sop, silent); |
@@ -214,7 +218,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
214 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); | 218 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); |
215 | 219 | ||
216 | // Save avatar attachment information | 220 | // Save avatar attachment information |
217 | m_log.Info( | 221 | m_log.Debug( |
218 | "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | 222 | "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId |
219 | + ", AttachmentPoint: " + AttachmentPt); | 223 | + ", AttachmentPoint: " + AttachmentPt); |
220 | 224 | ||
@@ -339,6 +343,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
339 | 343 | ||
340 | lock (sp.AttachmentsSyncLock) | 344 | lock (sp.AttachmentsSyncLock) |
341 | { | 345 | { |
346 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name); | ||
347 | |||
342 | foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) | 348 | foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) |
343 | { | 349 | { |
344 | RezSingleAttachmentFromInventory(sp, obj.ItemID, obj.AttachmentPt); | 350 | RezSingleAttachmentFromInventory(sp, obj.ItemID, obj.AttachmentPt); |
@@ -349,7 +355,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
349 | public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 355 | public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) |
350 | { | 356 | { |
351 | // m_log.DebugFormat( | 357 | // m_log.DebugFormat( |
352 | // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", | 358 | // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", |
353 | // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); | 359 | // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); |
354 | 360 | ||
355 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | 361 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); |
@@ -375,6 +381,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
375 | // be removed when that functionality is implemented in opensim | 381 | // be removed when that functionality is implemented in opensim |
376 | AttachmentPt &= 0x7f; | 382 | AttachmentPt &= 0x7f; |
377 | 383 | ||
384 | // Viewer 2/3 sometimes asks to re-wear items that are already worn (and show up in it's inventory as such). | ||
385 | // This often happens during login - not sure the exact reason. | ||
386 | // For now, we will ignore the request. Unfortunately, this means that we need to dig through all the | ||
387 | // ScenePresence attachments. We can't use the data in AvatarAppearance because that's present at login | ||
388 | // before anything has actually been attached. | ||
389 | bool alreadyOn = false; | ||
390 | List<SceneObjectGroup> existingAttachments = sp.GetAttachments(); | ||
391 | foreach (SceneObjectGroup so in existingAttachments) | ||
392 | { | ||
393 | if (so.GetFromItemID() == itemID) | ||
394 | { | ||
395 | alreadyOn = true; | ||
396 | break; | ||
397 | } | ||
398 | } | ||
399 | |||
400 | // if (sp.Appearance.GetAttachmentForItem(itemID) != null) | ||
401 | if (alreadyOn) | ||
402 | { | ||
403 | // m_log.WarnFormat( | ||
404 | // "[ATTACHMENTS MODULE]: Ignoring request by {0} to wear item {1} at {2} since it is already worn", | ||
405 | // sp.Name, itemID, AttachmentPt); | ||
406 | |||
407 | return null; | ||
408 | } | ||
409 | |||
378 | SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); | 410 | SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); |
379 | 411 | ||
380 | if (att == null) | 412 | if (att == null) |
@@ -467,8 +499,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
467 | IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | 499 | IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) |
468 | { | 500 | { |
469 | // m_log.DebugFormat( | 501 | // m_log.DebugFormat( |
470 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", | 502 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", |
471 | // att.Name, remoteClient.Name, AttachmentPt, itemID); | 503 | // att.Name, sp.Name, AttachmentPt, itemID); |
472 | 504 | ||
473 | if (UUID.Zero == itemID) | 505 | if (UUID.Zero == itemID) |
474 | { | 506 | { |
@@ -524,7 +556,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
524 | { | 556 | { |
525 | // m_log.DebugFormat( | 557 | // m_log.DebugFormat( |
526 | // "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}", | 558 | // "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}", |
527 | // remoteClient.Name, sceneObjectID); | 559 | // remoteClient.Name, soLocalId); |
528 | 560 | ||
529 | SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId); | 561 | SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId); |
530 | 562 | ||
@@ -677,45 +709,45 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
677 | { | 709 | { |
678 | if (grp != null) | 710 | if (grp != null) |
679 | { | 711 | { |
680 | if (!grp.HasGroupChanged) | 712 | if (grp.HasGroupChanged || grp.ContainsScripts()) |
681 | { | 713 | { |
682 | m_log.DebugFormat( | 714 | m_log.DebugFormat( |
683 | "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", | 715 | "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", |
684 | grp.UUID, grp.AttachmentPoint); | 716 | grp.UUID, grp.AttachmentPoint); |
685 | 717 | ||
686 | return; | 718 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); |
687 | } | ||
688 | 719 | ||
689 | m_log.DebugFormat( | 720 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); |
690 | "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", | 721 | item = m_scene.InventoryService.GetItem(item); |
691 | grp.UUID, grp.AttachmentPoint); | ||
692 | 722 | ||
693 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); | 723 | if (item != null) |
694 | 724 | { | |
695 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 725 | AssetBase asset = m_scene.CreateAsset( |
696 | item = m_scene.InventoryService.GetItem(item); | 726 | grp.GetPartName(grp.LocalId), |
697 | 727 | grp.GetPartDescription(grp.LocalId), | |
698 | if (item != null) | 728 | (sbyte)AssetType.Object, |
729 | Utils.StringToBytes(sceneObjectXml), | ||
730 | remoteClient.AgentId); | ||
731 | m_scene.AssetService.Store(asset); | ||
732 | |||
733 | item.AssetID = asset.FullID; | ||
734 | item.Description = asset.Description; | ||
735 | item.Name = asset.Name; | ||
736 | item.AssetType = asset.Type; | ||
737 | item.InvType = (int)InventoryType.Object; | ||
738 | |||
739 | m_scene.InventoryService.UpdateItem(item); | ||
740 | |||
741 | // this gets called when the agent logs off! | ||
742 | if (remoteClient != null) | ||
743 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
744 | } | ||
745 | } | ||
746 | else | ||
699 | { | 747 | { |
700 | AssetBase asset = m_scene.CreateAsset( | 748 | m_log.DebugFormat( |
701 | grp.GetPartName(grp.LocalId), | 749 | "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", |
702 | grp.GetPartDescription(grp.LocalId), | 750 | grp.UUID, grp.AttachmentPoint); |
703 | (sbyte)AssetType.Object, | ||
704 | Utils.StringToBytes(sceneObjectXml), | ||
705 | remoteClient.AgentId); | ||
706 | m_scene.AssetService.Store(asset); | ||
707 | |||
708 | item.AssetID = asset.FullID; | ||
709 | item.Description = asset.Description; | ||
710 | item.Name = asset.Name; | ||
711 | item.AssetType = asset.Type; | ||
712 | item.InvType = (int)InventoryType.Object; | ||
713 | |||
714 | m_scene.InventoryService.UpdateItem(item); | ||
715 | |||
716 | // this gets called when the agent logs off! | ||
717 | if (remoteClient != null) | ||
718 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
719 | } | 751 | } |
720 | } | 752 | } |
721 | } | 753 | } |
@@ -735,7 +767,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
735 | private void AttachToAgent( | 767 | private void AttachToAgent( |
736 | IScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) | 768 | IScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) |
737 | { | 769 | { |
738 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", | 770 | // m_log.DebugFormat( |
771 | // "[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", | ||
739 | // so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); | 772 | // so.Name, avatar.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); |
740 | 773 | ||
741 | so.DetachFromBackup(); | 774 | so.DetachFromBackup(); |
@@ -788,7 +821,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
788 | /// <returns>The user inventory item created that holds the attachment.</returns> | 821 | /// <returns>The user inventory item created that holds the attachment.</returns> |
789 | private InventoryItemBase AddSceneObjectAsNewAttachmentInInv(IClientAPI remoteClient, SceneObjectGroup grp) | 822 | private InventoryItemBase AddSceneObjectAsNewAttachmentInInv(IClientAPI remoteClient, SceneObjectGroup grp) |
790 | { | 823 | { |
791 | // m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); | 824 | // m_log.DebugFormat( |
825 | // "[ATTACHMENTS MODULE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2}", | ||
826 | // grp.Name, grp.LocalId, remoteClient.Name); | ||
792 | 827 | ||
793 | Vector3 inventoryStoredPosition = new Vector3 | 828 | Vector3 inventoryStoredPosition = new Vector3 |
794 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) | 829 | (((grp.AbsolutePosition.X > (int)Constants.RegionSize) |