aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorMelanie2013-03-05 12:02:22 +0100
committerMelanie2013-03-05 12:02:22 +0100
commit797bfbfcfaf5485db755ad6a5b19a064210505fd (patch)
treeb17c5faf5fdcc27cbc24150c47c244697337daaa
parentAdd support for void return type (diff)
downloadopensim-SC_OLD-797bfbfcfaf5485db755ad6a5b19a064210505fd.zip
opensim-SC_OLD-797bfbfcfaf5485db755ad6a5b19a064210505fd.tar.gz
opensim-SC_OLD-797bfbfcfaf5485db755ad6a5b19a064210505fd.tar.bz2
opensim-SC_OLD-797bfbfcfaf5485db755ad6a5b19a064210505fd.tar.xz
Multiattach, part 1
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs46
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs4
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs2
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs9
8 files changed, 34 insertions, 38 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 041fb94..ba6d87d 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -497,8 +497,6 @@ namespace OpenSim.Framework
497 /// </remarks> 497 /// </remarks>
498 public List<AvatarAttachment> GetAttachments() 498 public List<AvatarAttachment> GetAttachments()
499 { 499 {
500
501
502 lock (m_attachments) 500 lock (m_attachments)
503 { 501 {
504 List<AvatarAttachment> alist = new List<AvatarAttachment>(); 502 List<AvatarAttachment> alist = new List<AvatarAttachment>();
@@ -508,7 +506,8 @@ namespace OpenSim.Framework
508 alist.Add(new AvatarAttachment(attach)); 506 alist.Add(new AvatarAttachment(attach));
509 } 507 }
510 return alist; 508 return alist;
511 } } 509 }
510 }
512 511
513 internal void AppendAttachment(AvatarAttachment attach) 512 internal void AppendAttachment(AvatarAttachment attach)
514 { 513 {
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));
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index d781eae..eaaf7a3 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.Framework.Interfaces
84 /// <param name="AttachmentPt"></param> 84 /// <param name="AttachmentPt"></param>
85 /// <param name="silent"></param> 85 /// <param name="silent"></param>
86 /// <returns>true if the object was successfully attached, false otherwise</returns> 86 /// <returns>true if the object was successfully attached, false otherwise</returns>
87 bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo, bool temp); 87 bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool useAttachmentInfo, bool temp, bool append);
88 88
89 /// <summary> 89 /// <summary>
90 /// Rez an attachment from user inventory and change inventory status to match. 90 /// Rez an attachment from user inventory and change inventory status to match.
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 05d5ccd..2e64819 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2866,7 +2866,7 @@ namespace OpenSim.Region.Framework.Scenes
2866 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2866 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2867 2867
2868 if (AttachmentsModule != null) 2868 if (AttachmentsModule != null)
2869 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false); 2869 AttachmentsModule.AttachObject(sp, grp, 0, false, false, false, true);
2870 } 2870 }
2871 else 2871 else
2872 { 2872 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
index 17971e3..0b28edd 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
183 hostPart.ParentGroup.RootPart.ScheduleFullUpdate(); 183 hostPart.ParentGroup.RootPart.ScheduleFullUpdate();
184 } 184 }
185 185
186 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true, true) ? 1 : 0; 186 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true, true, true) ? 1 : 0;
187 } 187 }
188 } 188 }
189} 189}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 6685764..7be64eb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3332,7 +3332,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3332 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; 3332 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3333 3333
3334 if (attachmentsModule != null) 3334 if (attachmentsModule != null)
3335 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true, false); 3335 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, true, false, true);
3336 else 3336 else
3337 return false; 3337 return false;
3338 } 3338 }
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs
index c0130f1..6011b1c 100644
--- a/OpenSim/Services/Interfaces/IAvatarService.cs
+++ b/OpenSim/Services/Interfaces/IAvatarService.cs
@@ -180,11 +180,18 @@ namespace OpenSim.Services.Interfaces
180 180
181 // Attachments 181 // Attachments
182 List<AvatarAttachment> attachments = appearance.GetAttachments(); 182 List<AvatarAttachment> attachments = appearance.GetAttachments();
183 Dictionary<int, List<string>> atts = new Dictionary<int, List<string>>();
183 foreach (AvatarAttachment attach in attachments) 184 foreach (AvatarAttachment attach in attachments)
184 { 185 {
185 if (attach.ItemID != UUID.Zero) 186 if (attach.ItemID != UUID.Zero)
186 Data["_ap_" + attach.AttachPoint] = attach.ItemID.ToString(); 187 {
188 if (!atts.ContainsKey(attach.AttachPoint))
189 atts[attach.AttachPoint] = new List<string>();
190 atts[attach.AttachPoint].Add(attach.ItemID.ToString());
191 }
187 } 192 }
193 foreach (KeyValuePair<int, List<string>> kvp in atts)
194 Data["_ap_" + kvp.Key] = string.Join(",", kvp.Value.ToArray());
188 } 195 }
189 196
190 public AvatarAppearance ToAvatarAppearance() 197 public AvatarAppearance ToAvatarAppearance()