aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs64
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs4
-rw-r--r--OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs2
3 files changed, 40 insertions, 30 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 165dd17..71945c5 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 {
@@ -299,12 +299,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
299 sp.ClearAttachments(); 299 sp.ClearAttachments();
300 } 300 }
301 301
302 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp) 302 public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp, bool append)
303 { 303 {
304 if (!Enabled) 304 if (!Enabled)
305 return false; 305 return false;
306 306
307 if (AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, temp)) 307 if (AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, temp, append))
308 { 308 {
309 m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID); 309 m_scene.EventManager.TriggerOnAttach(group.LocalId, group.FromItemID, sp.UUID);
310 return true; 310 return true;
@@ -313,7 +313,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
313 return false; 313 return false;
314 } 314 }
315 315
316 private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp) 316 private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp, bool append)
317 { 317 {
318// m_log.DebugFormat( 318// m_log.DebugFormat(
319// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", 319// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
@@ -348,11 +348,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
348 lock (sp.AttachmentsSyncLock) 348 lock (sp.AttachmentsSyncLock)
349 { 349 {
350 Vector3 attachPos = group.AbsolutePosition; 350 Vector3 attachPos = group.AbsolutePosition;
351 351
352 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
353 // be removed when that functionality is implemented in opensim
354 attachmentPt &= 0x7f;
355
356 // If the attachment point isn't the same as the one previously used 352 // If the attachment point isn't the same as the one previously used
357 // set it's offset position = 0 so that it appears on the attachment point 353 // set it's offset position = 0 so that it appears on the attachment point
358 // and not in a weird location somewhere unknown. 354 // and not in a weird location somewhere unknown.
@@ -398,15 +394,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
398 group.AbsolutePosition = attachPos; 394 group.AbsolutePosition = attachPos;
399 395
400 if (sp.PresenceType != PresenceType.Npc) 396 if (sp.PresenceType != PresenceType.Npc)
401 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp); 397 UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append);
402 398
403 AttachToAgent(sp, group, attachmentPt, attachPos, silent); 399 AttachToAgent(sp, group, attachmentPt, attachPos, silent);
404 } 400 }
405 401
406 return true; 402 return true;
407 } 403 }
408 404
409 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp) 405 private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp, bool append)
410 { 406 {
411 // Add the new attachment to inventory if we don't already have it. 407 // Add the new attachment to inventory if we don't already have it.
412 if (!temp) 408 if (!temp)
@@ -415,7 +411,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
415 if (newAttachmentItemID == UUID.Zero) 411 if (newAttachmentItemID == UUID.Zero)
416 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; 412 newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
417 413
418 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group); 414 ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append);
419 } 415 }
420 } 416 }
421 417
@@ -433,8 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
433// "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2}", 429// "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2}",
434// (AttachmentPoint)AttachmentPt, itemID, sp.Name); 430// (AttachmentPoint)AttachmentPt, itemID, sp.Name);
435 431
436 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 432 bool append = (AttachmentPt & 0x80) != 0;
437 // be removed when that functionality is implemented in opensim
438 AttachmentPt &= 0x7f; 433 AttachmentPt &= 0x7f;
439 434
440 // Viewer 2/3 sometimes asks to re-wear items that are already worn (and show up in it's inventory as such). 435 // Viewer 2/3 sometimes asks to re-wear items that are already worn (and show up in it's inventory as such).
@@ -463,7 +458,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
463 return null; 458 return null;
464 } 459 }
465 460
466 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc); 461 return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc, append);
467 } 462 }
468 463
469 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) 464 public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist)
@@ -860,7 +855,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
860 } 855 }
861 856
862 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( 857 protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
863 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc) 858 IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc, bool append)
864 { 859 {
865 if (m_invAccessModule == null) 860 if (m_invAccessModule == null)
866 return null; 861 return null;
@@ -885,13 +880,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
885 return null; 880 return null;
886 } 881 }
887 882
888 // Remove any previous attachments
889 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); 883 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
890 string previousAttachmentScriptedState = null; 884 string previousAttachmentScriptedState = null;
891 885
892 // At the moment we can only deal with a single attachment 886 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones
893 if (attachments.Count != 0) 887 while (attachments.Count >= 5)
894 DetachSingleAttachmentToInv(sp, attachments[0]); 888 {
889 if (attachments[0].FromItemID != UUID.Zero)
890 DetachSingleAttachmentToInv(sp, attachments[0]);
891 attachments.RemoveAt(0);
892 }
893
894 // If we're not appending, remove the rest as well
895 if (attachments.Count != 0 && !append)
896 {
897 foreach (SceneObjectGroup g in attachments)
898 {
899 if (g.FromItemID != UUID.Zero)
900 DetachSingleAttachmentToInv(sp, g);
901 }
902 }
895 903
896 lock (sp.AttachmentsSyncLock) 904 lock (sp.AttachmentsSyncLock)
897 { 905 {
@@ -913,7 +921,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
913 // This will throw if the attachment fails 921 // This will throw if the attachment fails
914 try 922 try
915 { 923 {
916 AttachObjectInternal(sp, objatt, attachmentPt, false, false, false); 924 AttachObjectInternal(sp, objatt, attachmentPt, false, false, false, append);
917 } 925 }
918 catch (Exception e) 926 catch (Exception e)
919 { 927 {
@@ -955,7 +963,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
955 /// <param name="AttachmentPt"></param> 963 /// <param name="AttachmentPt"></param>
956 /// <param name="itemID"></param> 964 /// <param name="itemID"></param>
957 /// <param name="att"></param> 965 /// <param name="att"></param>
958 private void ShowAttachInUserInventory(IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) 966 private void ShowAttachInUserInventory(IScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att, bool append)
959 { 967 {
960// m_log.DebugFormat( 968// m_log.DebugFormat(
961// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", 969// "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}",
@@ -978,7 +986,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
978 if (item == null) 986 if (item == null)
979 return; 987 return;
980 988
981 bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); 989 int attFlag = append ? 0x80 : 0;
990 bool changed = sp.Appearance.SetAttachment((int)AttachmentPt | attFlag, itemID, item.AssetID);
982 if (changed && m_scene.AvatarFactory != null) 991 if (changed && m_scene.AvatarFactory != null)
983 { 992 {
984// m_log.DebugFormat( 993// m_log.DebugFormat(
@@ -1062,12 +1071,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1062 return; 1071 return;
1063 } 1072 }
1064 1073
1065 // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should 1074 bool append = (AttachmentPt & 0x80) != 0;
1066 // be removed when that functionality is implemented in opensim
1067 AttachmentPt &= 0x7f; 1075 AttachmentPt &= 0x7f;
1068 1076
1069 // Calls attach with a Zero position 1077 // Calls attach with a Zero position
1070 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false)) 1078 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false, append))
1071 { 1079 {
1072// m_log.Debug( 1080// m_log.Debug(
1073// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId 1081// "[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/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
index 6bf50d2..fccf053 100644
--- a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
@@ -262,6 +262,8 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
262 return "modInvokeR"; 262 return "modInvokeR";
263 else if (sid.ReturnType == typeof(object[])) 263 else if (sid.ReturnType == typeof(object[]))
264 return "modInvokeL"; 264 return "modInvokeL";
265 else if (sid.ReturnType == typeof(void))
266 return "modInvokeN";
265 267
266 m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name); 268 m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name);
267 } 269 }