aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-06-27 00:41:46 +0100
committerJustin Clark-Casey (justincc)2012-06-27 00:41:46 +0100
commitd0432133172f4147f7401f214c703611978423cd (patch)
tree3677b37a4525fc5165c5b5378abe9fbff671aa0e
parentAutomatically disable log4net before each regression test so that logging is ... (diff)
downloadopensim-SC-d0432133172f4147f7401f214c703611978423cd.zip
opensim-SC-d0432133172f4147f7401f214c703611978423cd.tar.gz
opensim-SC-d0432133172f4147f7401f214c703611978423cd.tar.bz2
opensim-SC-d0432133172f4147f7401f214c703611978423cd.tar.xz
refactor: Move ScenePresence <-> AgentData attachments copying code into AttachmentsModule.
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs50
-rw-r--r--OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs14
-rw-r--r--OpenSim/Region/Framework/Interfaces/IScenePresence.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs41
4 files changed, 74 insertions, 37 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
index 2b0e4ab..4a7fbce 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs
@@ -100,6 +100,56 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
100 100
101 #region IAttachmentsModule 101 #region IAttachmentsModule
102 102
103 public void CopyAttachments(IScenePresence sp, AgentData ad)
104 {
105 lock (sp.AttachmentsSyncLock)
106 {
107 // Attachment objects
108 List<SceneObjectGroup> attachments = sp.GetAttachments();
109 if (attachments.Count > 0)
110 {
111 ad.AttachmentObjects = new List<ISceneObject>();
112 ad.AttachmentObjectStates = new List<string>();
113 // IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
114 sp.InTransitScriptStates.Clear();
115
116 foreach (SceneObjectGroup sog in attachments)
117 {
118 // We need to make a copy and pass that copy
119 // because of transfers withn the same sim
120 ISceneObject clone = sog.CloneForNewScene();
121 // Attachment module assumes that GroupPosition holds the offsets...!
122 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
123 ((SceneObjectGroup)clone).IsAttachment = false;
124 ad.AttachmentObjects.Add(clone);
125 string state = sog.GetStateSnapshot();
126 ad.AttachmentObjectStates.Add(state);
127 sp.InTransitScriptStates.Add(state);
128 // Let's remove the scripts of the original object here
129 sog.RemoveScriptInstances(true);
130 }
131 }
132 }
133 }
134
135 public void CopyAttachments(AgentData ad, IScenePresence sp)
136 {
137 if (ad.AttachmentObjects != null && ad.AttachmentObjects.Count > 0)
138 {
139 lock (sp.AttachmentsSyncLock)
140 sp.ClearAttachments();
141
142 int i = 0;
143 foreach (ISceneObject so in ad.AttachmentObjects)
144 {
145 ((SceneObjectGroup)so).LocalId = 0;
146 ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule();
147 so.SetState(ad.AttachmentObjectStates[i++], m_scene);
148 m_scene.IncomingCreateObject(Vector3.Zero, so);
149 }
150 }
151 }
152
103 /// <summary> 153 /// <summary>
104 /// RezAttachments. This should only be called upon login on the first region. 154 /// RezAttachments. This should only be called upon login on the first region.
105 /// Attachment rezzings on crossings and TPs are done in a different way. 155 /// Attachment rezzings on crossings and TPs are done in a different way.
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
index fde5de1..375d334 100644
--- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs
@@ -36,6 +36,20 @@ namespace OpenSim.Region.Framework.Interfaces
36 public interface IAttachmentsModule 36 public interface IAttachmentsModule
37 { 37 {
38 /// <summary> 38 /// <summary>
39 /// Copy attachment data from a ScenePresence into the AgentData structure for transmission to another simulator
40 /// </summary>
41 /// <param name='sp'></param>
42 /// <param name='ad'></param>
43 void CopyAttachments(IScenePresence sp, AgentData ad);
44
45 /// <summary>
46 /// Copy attachment data from an AgentData structure into a ScenePresence.
47 /// </summary>
48 /// <param name='ad'></param>
49 /// <param name='sp'></param>
50 void CopyAttachments(AgentData ad, IScenePresence sp);
51
52 /// <summary>
39 /// RezAttachments. This should only be called upon login on the first region. 53 /// RezAttachments. This should only be called upon login on the first region.
40 /// Attachment rezzings on crossings and TPs are done in a different way. 54 /// Attachment rezzings on crossings and TPs are done in a different way.
41 /// </summary> 55 /// </summary>
diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
index 5e43843..19a8236 100644
--- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
+++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs
@@ -41,6 +41,12 @@ namespace OpenSim.Region.Framework.Interfaces
41 public interface IScenePresence : ISceneAgent 41 public interface IScenePresence : ISceneAgent
42 { 42 {
43 /// <summary> 43 /// <summary>
44 /// Copy of the script states while the agent is in transit. This state may
45 /// need to be placed back in case of transfer fail.
46 /// </summary>
47 List<string> InTransitScriptStates { get; }
48
49 /// <summary>
44 /// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments. 50 /// The AttachmentsModule synchronizes on this to avoid race conditions between commands to add and remove attachments.
45 /// </summary> 51 /// </summary>
46 /// <remarks> 52 /// <remarks>
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 909c7c8..c7a670f 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -3084,31 +3084,8 @@ namespace OpenSim.Region.Framework.Scenes
3084 } 3084 }
3085 catch { } 3085 catch { }
3086 3086
3087 // Attachment objects 3087 if (Scene.AttachmentsModule != null)
3088 List<SceneObjectGroup> attachments = GetAttachments(); 3088 Scene.AttachmentsModule.CopyAttachments(this, cAgent);
3089 if (attachments.Count > 0)
3090 {
3091 cAgent.AttachmentObjects = new List<ISceneObject>();
3092 cAgent.AttachmentObjectStates = new List<string>();
3093// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
3094 InTransitScriptStates.Clear();
3095
3096 foreach (SceneObjectGroup sog in attachments)
3097 {
3098 // We need to make a copy and pass that copy
3099 // because of transfers withn the same sim
3100 ISceneObject clone = sog.CloneForNewScene();
3101 // Attachment module assumes that GroupPosition holds the offsets...!
3102 ((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
3103 ((SceneObjectGroup)clone).IsAttachment = false;
3104 cAgent.AttachmentObjects.Add(clone);
3105 string state = sog.GetStateSnapshot();
3106 cAgent.AttachmentObjectStates.Add(state);
3107 InTransitScriptStates.Add(state);
3108 // Let's remove the scripts of the original object here
3109 sog.RemoveScriptInstances(true);
3110 }
3111 }
3112 } 3089 }
3113 3090
3114 private void CopyFrom(AgentData cAgent) 3091 private void CopyFrom(AgentData cAgent)
@@ -3178,18 +3155,8 @@ namespace OpenSim.Region.Framework.Scenes
3178 if (cAgent.Anims != null) 3155 if (cAgent.Anims != null)
3179 Animator.Animations.FromArray(cAgent.Anims); 3156 Animator.Animations.FromArray(cAgent.Anims);
3180 3157
3181 if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0) 3158 if (Scene.AttachmentsModule != null)
3182 { 3159 Scene.AttachmentsModule.CopyAttachments(cAgent, this);
3183 m_attachments = new List<SceneObjectGroup>();
3184 int i = 0;
3185 foreach (ISceneObject so in cAgent.AttachmentObjects)
3186 {
3187 ((SceneObjectGroup)so).LocalId = 0;
3188 ((SceneObjectGroup)so).RootPart.ClearUpdateSchedule();
3189 so.SetState(cAgent.AttachmentObjectStates[i++], m_scene);
3190 m_scene.IncomingCreateObject(Vector3.Zero, so);
3191 }
3192 }
3193 } 3160 }
3194 3161
3195 public bool CopyAgent(out IAgentData agent) 3162 public bool CopyAgent(out IAgentData agent)