aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
authorMelanie2013-03-05 12:02:22 +0100
committerMelanie2013-03-05 12:02:22 +0100
commit797bfbfcfaf5485db755ad6a5b19a064210505fd (patch)
treeb17c5faf5fdcc27cbc24150c47c244697337daaa /OpenSim/Region/CoreModules/Avatar
parentAdd support for void return type (diff)
downloadopensim-SC-797bfbfcfaf5485db755ad6a5b19a064210505fd.zip
opensim-SC-797bfbfcfaf5485db755ad6a5b19a064210505fd.tar.gz
opensim-SC-797bfbfcfaf5485db755ad6a5b19a064210505fd.tar.bz2
opensim-SC-797bfbfcfaf5485db755ad6a5b19a064210505fd.tar.xz
Multiattach, part 1
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs46
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs4
2 files changed, 20 insertions, 30 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index acd156e..9647217 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -236,9 +236,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
236 // If we're an NPC then skip all the item checks and manipulations since we don't have an 236 // If we're an NPC then skip all the item checks and manipulations since we don't have an
237 // inventory right now. 237 // inventory right now.
238 if (sp.PresenceType == PresenceType.Npc) 238 if (sp.PresenceType == PresenceType.Npc)
239 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null); 239 RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null, true);
240 else 240 else
241 RezSingleAttachmentFromInventory(sp, attach.ItemID, p, d); 241 RezSingleAttachmentFromInventory(sp, attach.ItemID, p | (uint)0x80, d);
242 } 242 }
243 catch (Exception e) 243 catch (Exception e)
244 { 244 {
@@ -284,12 +284,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
284 sp.ClearAttachments(); 284 sp.ClearAttachments();
285 } 285 }
286 286
287 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp) 287 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp, bool append)
288 { 288 {
289 if (!Enabled) 289 if (!Enabled)
290 return false; 290 return false;
291 291
292 if (AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, temp)) 292 if (AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, temp, append))
293 { 293 {
294 m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID); 294 m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID);
295 return true; 295 return true;
@@ -298,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
298 return false; 298 return false;
299 } 299 }
300 300
301 private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp) 301 private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp, bool append)
302 { 302 {
303 lock (sp.AttachmentsSyncLock) 303 lock (sp.AttachmentsSyncLock)
304 { 304 {
@@ -326,10 +326,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
326 326
327 Vector3 attachPos = group.AbsolutePosition; 327 Vector3 attachPos = group.AbsolutePosition;
328 328
329 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
330 // be removed when that functionality is implemented in opensim
331 attachmentPt &= 0x7f;
332
333 // If the attachment point isn't the same as the one previously used 329 // If the attachment point isn't the same as the one previously used
334 // set it's offset position = 0 so that it appears on the attachment point 330 // set it's offset position = 0 so that it appears on the attachment point
335 // and not in a weird location somewhere unknown. 331 // and not in a weird location somewhere unknown.
@@ -375,7 +371,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
375 group.AbsolutePosition = attachPos; 371 group.AbsolutePosition = attachPos;
376 372
377 if (sp.PresenceType != PresenceType.Npc) 373 if (sp.PresenceType != PresenceType.Npc)
378 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp); 374 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append);
379 375
380 AttachToAgent(sp, group, attachmentPt, attachPos, silent); 376 AttachToAgent(sp, group, attachmentPt, attachPos, silent);
381 } 377 }
@@ -383,21 +379,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
383 return true; 379 return true;
384 } 380 }
385 381
386 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp) 382 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp, bool append)
387 { 383 {
388 // Remove any previous attachments 384 // Remove any previous attachments
389 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); 385 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
390 386
391 // At the moment we can only deal with a single attachment 387 // At the moment we can only deal with a single attachment
392 if (attachments.Count != 0) 388 if (attachments.Count != 0 && !append)
393 { 389 {
394 if (attachments[0].FromItemID != UUID.Zero) 390 if (attachments[0].FromItemID != UUID.Zero)
395 DetachSingleAttachmentToInvInternal(sp, attachments[0]); 391 DetachSingleAttachmentToInvInternal(sp, attachments[0]);
396 // Error logging commented because UUID.Zero now means temp attachment
397// else
398// m_log.WarnFormat(
399// "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
400// attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
401 } 392 }
402 393
403 // Add the new attachment to inventory if we don't already have it. 394 // Add the new attachment to inventory if we don't already have it.
@@ -407,7 +398,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
407 if (newAttachmentItemID == UUID.Zero) 398 if (newAttachmentItemID == UUID.Zero)
408 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; 399 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
409 400
410 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group); 401 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append);
411 } 402 }
412 } 403 }
413 404
@@ -425,8 +416,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
425// "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2}", 416// "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2}",
426// (AttachmentPoint)AttachmentPt, itemID, sp.Name); 417// (AttachmentPoint)AttachmentPt, itemID, sp.Name);
427 418
428 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 419 bool append = (AttachmentPt & 0x80) != 0;
429 // be removed when that functionality is implemented in opensim
430 AttachmentPt &= 0x7f; 420 AttachmentPt &= 0x7f;
431 421
432 // Viewer 2/3 sometimes asks to re-wear items that are already worn (and show up in it's inventory as such). 422 // Viewer 2/3 sometimes asks to re-wear items that are already worn (and show up in it's inventory as such).
@@ -455,7 +445,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
455 return null; 445 return null;
456 } 446 }
457 447
458 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc); 448 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc, append);
459 } 449 }
460 450
461 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) 451 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist)
@@ -847,7 +837,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
847 } 837 }
848 838
849 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 839 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
850 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc) 840 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc, bool append)
851 { 841 {
852 if (m_invAccessModule == null) 842 if (m_invAccessModule == null)
853 return null; 843 return null;
@@ -885,7 +875,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
885 // This will throw if the attachment fails 875 // This will throw if the attachment fails
886 try 876 try
887 { 877 {
888 AttachObjectInternal(sp, objatt, attachmentPt, false, false, false); 878 AttachObjectInternal(sp, objatt, attachmentPt, false, false, false, append);
889 } 879 }
890 catch (Exception e) 880 catch (Exception e)
891 { 881 {
@@ -936,7 +926,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
936 /// <param name="AttachmentPt"></param> 926 /// <param name="AttachmentPt"></param>
937 /// <param name="itemID"></param> 927 /// <param name="itemID"></param>
938 /// <param name="att"></param> 928 /// <param name="att"></param>
939 private void ShowAttachInUserInventory(IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) 929 private void ShowAttachInUserInventory(IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att, bool append)
940 { 930 {
941// m_log.DebugFormat( 931// m_log.DebugFormat(
942// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", 932// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
@@ -959,7 +949,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
959 if (item == null) 949 if (item == null)
960 return; 950 return;
961 951
962 bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); 952 int attFlag = append ? 0x80 : 0;
953 bool changed = sp.Appearance.SetAttachment((int)AttachmentPt | attFlag, itemID, item.AssetID);
963 if (changed && m_scene.AvatarFactory != null) 954 if (changed && m_scene.AvatarFactory != null)
964 { 955 {
965// m_log.DebugFormat( 956// m_log.DebugFormat(
@@ -1043,12 +1034,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1043 return; 1034 return;
1044 } 1035 }
1045 1036
1046 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 1037 bool append = (AttachmentPt & 0x80) != 0;
1047 // be removed when that functionality is implemented in opensim
1048 AttachmentPt &= 0x7f; 1038 AttachmentPt &= 0x7f;
1049 1039
1050 // Calls attach with a Zero position 1040 // Calls attach with a Zero position
1051 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false)) 1041 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false, append))
1052 { 1042 {
1053// m_log.Debug( 1043// m_log.Debug(
1054// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId 1044// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index 4e9d3f9..545aeda 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -197,7 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
197 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); 197 SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);
198 198
199 m_numberOfAttachEventsFired = 0; 199 m_numberOfAttachEventsFired = 0;
200 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); 200 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false, false);
201 201
202 // Check status on scene presence 202 // Check status on scene presence
203 Assert.That(sp.HasAttachments(), Is.True); 203 Assert.That(sp.HasAttachments(), Is.True);
@@ -254,7 +254,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
254 sp2.AbsolutePosition = new Vector3(0, 0, 0); 254 sp2.AbsolutePosition = new Vector3(0, 0, 0);
255 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); 255 sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);
256 256
257 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); 257 scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false, false);
258 258
259 Assert.That(sp.HasAttachments(), Is.False); 259 Assert.That(sp.HasAttachments(), Is.False);
260 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); 260 Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));