aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-09-13 22:13:58 +0100
committerJustin Clark-Casey (justincc)2011-09-13 22:13:58 +0100
commit8880aea728af2ccb95ea2400c7d180aa4dc98112 (patch)
tree76c22d083c04041b05e1dcf57be40970b8969793 /OpenSim/Region
parentComment out attachments code in Scene.IncomingCreateObject(UUID userID, UUID ... (diff)
downloadopensim-SC-8880aea728af2ccb95ea2400c7d180aa4dc98112.zip
opensim-SC-8880aea728af2ccb95ea2400c7d180aa4dc98112.tar.gz
opensim-SC-8880aea728af2ccb95ea2400c7d180aa4dc98112.tar.bz2
opensim-SC-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')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs119
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs5
4 files changed, 97 insertions, 44 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)
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index f03cf7b..36c5c52 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -652,7 +652,7 @@ namespace OpenSim.Region.Framework.Scenes
652 if (!Entities.Remove(agentID)) 652 if (!Entities.Remove(agentID))
653 { 653 {
654 m_log.WarnFormat( 654 m_log.WarnFormat(
655 "[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", 655 "[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list",
656 agentID); 656 agentID);
657 } 657 }
658 658
@@ -675,7 +675,7 @@ namespace OpenSim.Region.Framework.Scenes
675 } 675 }
676 else 676 else
677 { 677 {
678 m_log.WarnFormat("[SCENEGRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); 678 m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID);
679 } 679 }
680 } 680 }
681 } 681 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index 4bca3d0..905ecc9 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -389,5 +389,18 @@ namespace OpenSim.Region.Framework.Scenes
389 for (int i = 0; i < parts.Length; i++) 389 for (int i = 0; i < parts.Length; i++)
390 parts[i].Inventory.ResumeScripts(); 390 parts[i].Inventory.ResumeScripts();
391 } 391 }
392
393 /// <summary>
394 /// Returns true if any part in the scene object contains scripts, false otherwise.
395 /// </summary>
396 /// <returns></returns>
397 public bool ContainsScripts()
398 {
399 foreach (SceneObjectPart part in Parts)
400 if (part.Inventory.ContainsScripts())
401 return true;
402
403 return false;
404 }
392 } 405 }
393} 406}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index e40e57d..57adda7 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -1035,10 +1035,15 @@ namespace OpenSim.Region.Framework.Scenes
1035 item.BasePermissions = perms; 1035 item.BasePermissions = perms;
1036 } 1036 }
1037 } 1037 }
1038
1038 m_inventorySerial++; 1039 m_inventorySerial++;
1039 HasInventoryChanged = true; 1040 HasInventoryChanged = true;
1040 } 1041 }
1041 1042
1043 /// <summary>
1044 /// Returns true if this part inventory contains any scripts. False otherwise.
1045 /// </summary>
1046 /// <returns></returns>
1042 public bool ContainsScripts() 1047 public bool ContainsScripts()
1043 { 1048 {
1044 lock (m_items) 1049 lock (m_items)