aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2013-03-29 01:58:57 +0000
committerMelanie2013-03-29 01:58:57 +0000
commitc93f67b632815d2d91dcd62bbd0025ead766d85e (patch)
treea101514bdbd26002ddbfcef783a1539d623c26b1 /OpenSim/Region
parentMerge commit 'feffc8081dc5ab2889a7ea4b96b2befaed0c3f95' into careminster (diff)
parentAdd "debug attachments" console command to allow highly verbose attachment lo... (diff)
downloadopensim-SC-c93f67b632815d2d91dcd62bbd0025ead766d85e.zip
opensim-SC-c93f67b632815d2d91dcd62bbd0025ead766d85e.tar.gz
opensim-SC-c93f67b632815d2d91dcd62bbd0025ead766d85e.tar.bz2
opensim-SC-c93f67b632815d2d91dcd62bbd0025ead766d85e.tar.xz
Merge commit '2b142f2f9e888d5cb7317cc51c12ac7152c54459' into careminster
Conflicts: OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs199
1 files changed, 145 insertions, 54 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2556845..207c900 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -49,6 +49,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
49 { 49 {
50 #region INonSharedRegionModule 50 #region INonSharedRegionModule
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 public int DebugLevel { get; set; }
52 54
53 private Scene m_scene; 55 private Scene m_scene;
54 private IInventoryAccessModule m_invAccessModule; 56 private IInventoryAccessModule m_invAccessModule;
@@ -76,10 +78,66 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
76 m_scene.RegisterModuleInterface<IAttachmentsModule>(this); 78 m_scene.RegisterModuleInterface<IAttachmentsModule>(this);
77 79
78 if (Enabled) 80 if (Enabled)
81 {
79 m_scene.EventManager.OnNewClient += SubscribeToClientEvents; 82 m_scene.EventManager.OnNewClient += SubscribeToClientEvents;
83 m_scene.EventManager.OnStartScript += (localID, itemID) => HandleScriptStateChange(localID, true);
84 m_scene.EventManager.OnStopScript += (localID, itemID) => HandleScriptStateChange(localID, false);
85
86 MainConsole.Instance.Commands.AddCommand(
87 "Debug",
88 false,
89 "debug attachments",
90 "debug attachments [0|1]",
91 "Turn on attachments debugging\n"
92 + " <= 0 - turns off debugging\n"
93 + " >= 1 - turns on attachment message logging\n",
94 HandleDebugAttachments);
95 }
80 96
81 // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI 97 // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI
82 } 98 }
99
100 private void HandleDebugAttachments(string module, string[] args)
101 {
102 int debugLevel;
103
104 if (!(args.Length == 3 && int.TryParse(args[2], out debugLevel)))
105 {
106 MainConsole.Instance.OutputFormat("Usage: debug attachments [0|1]");
107 }
108 else
109 {
110 DebugLevel = debugLevel;
111 MainConsole.Instance.OutputFormat(
112 "Set event queue debug level to {0} in {1}", DebugLevel, m_scene.Name);
113 }
114 }
115
116 /// <summary>
117 /// Listen for client triggered running state changes so that we can persist the script's object if necessary.
118 /// </summary>
119 /// <param name='localID'></param>
120 /// <param name='itemID'></param>
121 private void HandleScriptStateChange(uint localID, bool started)
122 {
123 SceneObjectGroup sog = m_scene.GetGroupByPrim(localID);
124 if (sog != null && sog.IsAttachment)
125 {
126 if (!started)
127 {
128 // FIXME: This is a convoluted way for working out whether the script state has changed to stop
129 // because it has been manually stopped or because the stop was called in UpdateDetachedObject() below
130 // This needs to be handled in a less tangled way.
131 ScenePresence sp = m_scene.GetScenePresence(sog.AttachedAvatar);
132 if (sp.ControllingClient.IsActive)
133 sog.HasGroupChanged = true;
134 }
135 else
136 {
137 sog.HasGroupChanged = true;
138 }
139 }
140 }
83 141
84 public void RemoveRegion(Scene scene) 142 public void RemoveRegion(Scene scene)
85 { 143 {
@@ -167,14 +225,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
167 225
168 if (sp.GetAttachments().Count > 0) 226 if (sp.GetAttachments().Count > 0)
169 { 227 {
170// m_log.DebugFormat( 228 if (DebugLevel > 0)
171// "[ATTACHMENTS MODULE]: Not doing simulator-side attachment rez for {0} in {1} as their viewer has already rezzed attachments", 229 m_log.DebugFormat(
172// m_scene.Name, sp.Name); 230 "[ATTACHMENTS MODULE]: Not doing simulator-side attachment rez for {0} in {1} as their viewer has already rezzed attachments",
231 m_scene.Name, sp.Name);
173 232
174 return; 233 return;
175 } 234 }
176 235
177// m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name); 236 if (DebugLevel > 0)
237 m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name);
178 238
179 XmlDocument doc = new XmlDocument(); 239 XmlDocument doc = new XmlDocument();
180 string stateData = String.Empty; 240 string stateData = String.Empty;
@@ -260,7 +320,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
260 if (!Enabled) 320 if (!Enabled)
261 return; 321 return;
262 322
263// m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name); 323 if (DebugLevel > 0)
324 m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);
264 325
265 List<SceneObjectGroup> attachments = sp.GetAttachments(); 326 List<SceneObjectGroup> attachments = sp.GetAttachments();
266 327
@@ -293,9 +354,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
293 if (!Enabled) 354 if (!Enabled)
294 return; 355 return;
295 356
296// m_log.DebugFormat( 357 if (DebugLevel > 0)
297// "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}", 358 m_log.DebugFormat(
298// m_scene.RegionInfo.RegionName, sp.Name, silent); 359 "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}",
360 m_scene.RegionInfo.RegionName, sp.Name, silent);
299 361
300 foreach (SceneObjectGroup sop in sp.GetAttachments()) 362 foreach (SceneObjectGroup sop in sp.GetAttachments())
301 { 363 {
@@ -340,9 +402,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
340 402
341 if (group.GetSittingAvatarsCount() != 0) 403 if (group.GetSittingAvatarsCount() != 0)
342 { 404 {
343// m_log.WarnFormat( 405 if (DebugLevel > 0)
344// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it", 406 m_log.WarnFormat(
345// group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount()); 407 "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it",
408 group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount());
346 409
347 return false; 410 return false;
348 } 411 }
@@ -378,6 +441,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
378 441
379 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); 442 List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
380 443
444 if (attachments.Contains(group))
445 {
446 if (DebugLevel > 0)
447 m_log.WarnFormat(
448 "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
449 group.Name, group.LocalId, sp.Name, attachmentPt);
450
451 return false;
452 }
453
381 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones 454 // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones
382 while (attachments.Count >= 5) 455 while (attachments.Count >= 5)
383 { 456 {
@@ -444,9 +517,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
444 if (!Enabled) 517 if (!Enabled)
445 return null; 518 return null;
446 519
447// m_log.DebugFormat( 520 if (DebugLevel > 0)
448// "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2} in {3}", 521 m_log.DebugFormat(
449// (AttachmentPoint)AttachmentPt, itemID, sp.Name, m_scene.Name); 522 "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2} in {3}",
523 (AttachmentPoint)AttachmentPt, itemID, sp.Name, m_scene.Name);
450 524
451 bool append = (AttachmentPt & 0x80) != 0; 525 bool append = (AttachmentPt & 0x80) != 0;
452 AttachmentPt &= 0x7f; 526 AttachmentPt &= 0x7f;
@@ -470,9 +544,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
470// if (sp.Appearance.GetAttachmentForItem(itemID) != null) 544// if (sp.Appearance.GetAttachmentForItem(itemID) != null)
471 if (alreadyOn) 545 if (alreadyOn)
472 { 546 {
473// m_log.WarnFormat( 547 if (DebugLevel > 0)
474// "[ATTACHMENTS MODULE]: Ignoring request by {0} to wear item {1} at {2} since it is already worn", 548 m_log.DebugFormat(
475// sp.Name, itemID, AttachmentPt); 549 "[ATTACHMENTS MODULE]: Ignoring request by {0} to wear item {1} at {2} since it is already worn",
550 sp.Name, itemID, AttachmentPt);
476 551
477 return null; 552 return null;
478 } 553 }
@@ -485,7 +560,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
485 if (!Enabled) 560 if (!Enabled)
486 return; 561 return;
487 562
488 // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name); 563 if (DebugLevel > 0)
564 m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing multiple attachments from inventory for {0}", sp.Name);
489 565
490 foreach (KeyValuePair<UUID, uint> rez in rezlist) 566 foreach (KeyValuePair<UUID, uint> rez in rezlist)
491 { 567 {
@@ -503,9 +579,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
503 if (!Enabled) 579 if (!Enabled)
504 return; 580 return;
505 581
506// m_log.DebugFormat( 582 if (DebugLevel > 0)
507// "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}", 583 m_log.DebugFormat(
508// sp.UUID, soLocalId); 584 "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}",
585 sp.UUID, soLocalId);
509 586
510 SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId); 587 SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId);
511 588
@@ -521,9 +598,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
521 if (inventoryID == UUID.Zero) 598 if (inventoryID == UUID.Zero)
522 return; 599 return;
523 600
524// m_log.DebugFormat( 601 if (DebugLevel > 0)
525// "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}", 602 m_log.DebugFormat(
526// so.Name, so.LocalId, inventoryID); 603 "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}",
604 so.Name, so.LocalId, inventoryID);
527 605
528 lock (sp.AttachmentsSyncLock) 606 lock (sp.AttachmentsSyncLock)
529 { 607 {
@@ -578,9 +656,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
578 return; 656 return;
579 } 657 }
580 658
581// m_log.DebugFormat( 659 if (DebugLevel > 0)
582// "[ATTACHMENTS MODULE]: Detaching object {0} {1} (FromItemID {2}) for {3} in {4}", 660 m_log.DebugFormat(
583// so.Name, so.LocalId, so.FromItemID, sp.Name, m_scene.Name); 661 "[ATTACHMENTS MODULE]: Detaching object {0} {1} (FromItemID {2}) for {3} in {4}",
662 so.Name, so.LocalId, so.FromItemID, sp.Name, m_scene.Name);
584 663
585 // Scripts MUST be snapshotted before the object is 664 // Scripts MUST be snapshotted before the object is
586 // removed from the scene because doing otherwise will 665 // removed from the scene because doing otherwise will
@@ -706,12 +785,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
706 785
707 grp.HasGroupChanged = false; // Prevent it being saved over and over 786 grp.HasGroupChanged = false; // Prevent it being saved over and over
708 } 787 }
709// else 788 else if (DebugLevel > 0)
710// { 789 {
711// m_log.DebugFormat( 790 m_log.DebugFormat(
712// "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", 791 "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
713// grp.UUID, grp.AttachmentPoint); 792 grp.UUID, grp.AttachmentPoint);
714// } 793 }
715 } 794 }
716 795
717 /// <summary> 796 /// <summary>
@@ -729,9 +808,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
729 private void AttachToAgent( 808 private void AttachToAgent(
730 IScenePresence sp, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent) 809 IScenePresence sp, SceneObjectGroup so, uint attachmentpoint, Vector3 attachOffset, bool silent)
731 { 810 {
732// m_log.DebugFormat( 811 if (DebugLevel > 0)
733// "[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}", 812 m_log.DebugFormat(
734// so.Name, sp.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos); 813 "[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1} in pt {2} pos {3} {4}",
814 so.Name, sp.Name, attachmentpoint, attachOffset, so.RootPart.AttachedPos);
735 815
736 so.DetachFromBackup(); 816 so.DetachFromBackup();
737 817
@@ -756,9 +836,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
756 { 836 {
757 if (so.HasPrivateAttachmentPoint) 837 if (so.HasPrivateAttachmentPoint)
758 { 838 {
759// m_log.DebugFormat( 839 if (DebugLevel > 0)
760// "[ATTACHMENTS MODULE]: Killing private HUD {0} for avatars other than {1} at attachment point {2}", 840 m_log.DebugFormat(
761// so.Name, sp.Name, so.AttachmentPoint); 841 "[ATTACHMENTS MODULE]: Killing private HUD {0} for avatars other than {1} at attachment point {2}",
842 so.Name, sp.Name, so.AttachmentPoint);
762 843
763 // As this scene object can now only be seen by the attaching avatar, tell everybody else in the 844 // As this scene object can now only be seen by the attaching avatar, tell everybody else in the
764 // scene that it's no longer in their awareness. 845 // scene that it's no longer in their awareness.
@@ -792,9 +873,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
792 if (m_invAccessModule == null) 873 if (m_invAccessModule == null)
793 return null; 874 return null;
794 875
795 // m_log.DebugFormat( 876 if (DebugLevel > 0)
796 // "[ATTACHMENTS MODULE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2}", 877 m_log.DebugFormat(
797 // grp.Name, grp.LocalId, remoteClient.Name); 878 "[ATTACHMENTS MODULE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2}",
879 grp.Name, grp.LocalId, sp.Name);
798 880
799 InventoryItemBase newItem 881 InventoryItemBase newItem
800 = m_invAccessModule.CopyToInventory( 882 = m_invAccessModule.CopyToInventory(
@@ -903,6 +985,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
903 return null; 985 return null;
904 } 986 }
905 987
988 if (DebugLevel > 0)
989 m_log.DebugFormat(
990 "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}",
991 objatt.Name, sp.Name, attachmentPt, m_scene.Name);
992
906 // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. 993 // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller.
907 objatt.HasGroupChanged = false; 994 objatt.HasGroupChanged = false;
908 bool tainted = false; 995 bool tainted = false;
@@ -977,9 +1064,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
977 bool changed = sp.Appearance.SetAttachment((int)AttachmentPt | attFlag, itemID, item.AssetID); 1064 bool changed = sp.Appearance.SetAttachment((int)AttachmentPt | attFlag, itemID, item.AssetID);
978 if (changed && m_scene.AvatarFactory != null) 1065 if (changed && m_scene.AvatarFactory != null)
979 { 1066 {
980// m_log.DebugFormat( 1067 if (DebugLevel > 0)
981// "[ATTACHMENTS MODULE]: Queueing appearance save for {0}, attachment {1} point {2} in ShowAttachInUserInventory()", 1068 m_log.DebugFormat(
982// sp.Name, att.Name, AttachmentPt); 1069 "[ATTACHMENTS MODULE]: Queueing appearance save for {0}, attachment {1} point {2} in ShowAttachInUserInventory()",
1070 sp.Name, att.Name, AttachmentPt);
983 1071
984 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); 1072 m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);
985 } 1073 }
@@ -994,9 +1082,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
994 if (!Enabled) 1082 if (!Enabled)
995 return null; 1083 return null;
996 1084
997 // m_log.DebugFormat( 1085 if (DebugLevel > 0)
998 // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", 1086 m_log.DebugFormat(
999 // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); 1087 "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}",
1088 (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name);
1000 1089
1001 ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); 1090 ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
1002 1091
@@ -1027,9 +1116,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1027 1116
1028 private void Client_OnObjectAttach(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) 1117 private void Client_OnObjectAttach(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
1029 { 1118 {
1030// m_log.DebugFormat( 1119 if (DebugLevel > 0)
1031// "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})", 1120 m_log.DebugFormat(
1032// objectLocalID, remoteClient.Name, AttachmentPt, silent); 1121 "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})",
1122 objectLocalID, remoteClient.Name, AttachmentPt, silent);
1033 1123
1034 if (!Enabled) 1124 if (!Enabled)
1035 return; 1125 return;
@@ -1064,9 +1154,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
1064 // Calls attach with a Zero position 1154 // Calls attach with a Zero position
1065 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false, append)) 1155 if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false, append))
1066 { 1156 {
1067// m_log.Debug( 1157 if (DebugLevel > 0)
1068// "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId 1158 m_log.Debug(
1069// + ", AttachmentPoint: " + AttachmentPt); 1159 "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId
1160 + ", AttachmentPoint: " + AttachmentPt);
1070 1161
1071 // Save avatar attachment information 1162 // Save avatar attachment information
1072 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId); 1163 m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.FromItemID, remoteClient.AgentId);