diff options
author | Justin Clark-Casey (justincc) | 2010-03-06 00:07:47 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-03-06 00:07:47 +0000 |
commit | 395f343498bc429c0360201991147c6e089b0730 (patch) | |
tree | 70dedf88258e3496a5cbd267bc5db7e067b88e57 /OpenSim/Region/CoreModules/Avatar | |
parent | Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-395f343498bc429c0360201991147c6e089b0730.zip opensim-SC_OLD-395f343498bc429c0360201991147c6e089b0730.tar.gz opensim-SC_OLD-395f343498bc429c0360201991147c6e089b0730.tar.bz2 opensim-SC_OLD-395f343498bc429c0360201991147c6e089b0730.tar.xz |
refactor: Move DetachSingleAttachmentToInv to region module
need to rationalize method names later
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 71 |
1 files changed, 56 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 530a21c..d458364 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -25,6 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | ||
28 | using System.Reflection; | 29 | using System.Reflection; |
29 | using log4net; | 30 | using log4net; |
30 | using Nini.Config; | 31 | using Nini.Config; |
@@ -131,26 +132,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
131 | } | 132 | } |
132 | else | 133 | else |
133 | { | 134 | { |
134 | m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID); | 135 | m_log.DebugFormat("[ATTACHMENTS MODULE]: AttachObject found no such scene object {0}", objectLocalID); |
135 | return false; | 136 | return false; |
136 | } | 137 | } |
137 | 138 | ||
138 | return true; | 139 | return true; |
139 | } | 140 | } |
140 | 141 | ||
141 | /// <summary> | ||
142 | /// Update the user inventory to reflect an attachment | ||
143 | /// </summary> | ||
144 | /// <param name="att"></param> | ||
145 | /// <param name="remoteClient"></param> | ||
146 | /// <param name="itemID"></param> | ||
147 | /// <param name="AttachmentPt"></param> | ||
148 | /// <returns></returns> | ||
149 | public UUID SetAttachmentInventoryStatus( | 142 | public UUID SetAttachmentInventoryStatus( |
150 | SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 143 | SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) |
151 | { | 144 | { |
152 | m_log.DebugFormat( | 145 | m_log.DebugFormat( |
153 | "[USER INVENTORY]: Updating inventory of {0} to show attachment of {1} (item ID {2})", | 146 | "[ATTACHMENTS MODULEY]: Updating inventory of {0} to show attachment of {1} (item ID {2})", |
154 | remoteClient.Name, att.Name, itemID); | 147 | remoteClient.Name, att.Name, itemID); |
155 | 148 | ||
156 | if (!att.IsDeleted) | 149 | if (!att.IsDeleted) |
@@ -184,19 +177,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
184 | 177 | ||
185 | if (UUID.Zero == itemID) | 178 | if (UUID.Zero == itemID) |
186 | { | 179 | { |
187 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID."); | 180 | m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment. Error inventory item ID."); |
188 | return; | 181 | return; |
189 | } | 182 | } |
190 | 183 | ||
191 | if (0 == AttachmentPt) | 184 | if (0 == AttachmentPt) |
192 | { | 185 | { |
193 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point."); | 186 | m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment. Error attachment point."); |
194 | return; | 187 | return; |
195 | } | 188 | } |
196 | 189 | ||
197 | if (null == att.RootPart) | 190 | if (null == att.RootPart) |
198 | { | 191 | { |
199 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!"); | 192 | m_log.Error("[ATTACHMENTS MODULE]: Unable to save attachment for a prim without the rootpart!"); |
200 | return; | 193 | return; |
201 | } | 194 | } |
202 | 195 | ||
@@ -212,5 +205,53 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
212 | m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | 205 | m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); |
213 | } | 206 | } |
214 | } | 207 | } |
208 | |||
209 | public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) | ||
210 | { | ||
211 | ScenePresence presence; | ||
212 | if (m_scene.TryGetAvatar(remoteClient.AgentId, out presence)) | ||
213 | { | ||
214 | presence.Appearance.DetachAttachment(itemID); | ||
215 | |||
216 | // Save avatar attachment information | ||
217 | if (m_scene.AvatarFactory != null) | ||
218 | { | ||
219 | m_log.Debug("[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID); | ||
220 | m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
221 | } | ||
222 | } | ||
223 | |||
224 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
225 | } | ||
226 | |||
227 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. | ||
228 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? | ||
229 | protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) | ||
230 | { | ||
231 | if (itemID == UUID.Zero) // If this happened, someone made a mistake.... | ||
232 | return; | ||
233 | |||
234 | // We can NOT use the dictionries here, as we are looking | ||
235 | // for an entity by the fromAssetID, which is NOT the prim UUID | ||
236 | List<EntityBase> detachEntities = m_scene.GetEntities(); | ||
237 | SceneObjectGroup group; | ||
238 | |||
239 | foreach (EntityBase entity in detachEntities) | ||
240 | { | ||
241 | if (entity is SceneObjectGroup) | ||
242 | { | ||
243 | group = (SceneObjectGroup)entity; | ||
244 | if (group.GetFromItemID() == itemID) | ||
245 | { | ||
246 | m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); | ||
247 | group.DetachToInventoryPrep(); | ||
248 | m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); | ||
249 | m_scene.UpdateKnownItem(remoteClient, group,group.GetFromItemID(), group.OwnerID); | ||
250 | m_scene.DeleteSceneObject(group, false); | ||
251 | return; | ||
252 | } | ||
253 | } | ||
254 | } | ||
255 | } | ||
215 | } | 256 | } |
216 | } \ No newline at end of file | 257 | } \ No newline at end of file |