diff options
author | Justin Clark-Casey (justincc) | 2011-08-22 23:59:48 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-22 23:59:48 +0100 |
commit | d328046efbcd7449e0421f72138f48272f514481 (patch) | |
tree | 57534b6ccf769e89a886f8b77d49c4d8e79e27d1 /OpenSim | |
parent | Add warning log message to say which attachment fails validation in order to ... (diff) | |
download | opensim-SC_OLD-d328046efbcd7449e0421f72138f48272f514481.zip opensim-SC_OLD-d328046efbcd7449e0421f72138f48272f514481.tar.gz opensim-SC_OLD-d328046efbcd7449e0421f72138f48272f514481.tar.bz2 opensim-SC_OLD-d328046efbcd7449e0421f72138f48272f514481.tar.xz |
If an attachment fails, then start logging the exception for now, in order to help with the inconsistent state bug.
This also refactors AttachmentsModules to stop pointlessly refetching the ScenePresence in various methods. However, more of this is required.
Diffstat (limited to 'OpenSim')
3 files changed, 84 insertions, 61 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 97a1be6..c96de3a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -105,6 +105,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
105 | 105 | ||
106 | try | 106 | try |
107 | { | 107 | { |
108 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
109 | |||
110 | if (sp == null) | ||
111 | { | ||
112 | m_log.ErrorFormat( | ||
113 | "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); | ||
114 | return; | ||
115 | } | ||
116 | |||
108 | // If we can't take it, we can't attach it! | 117 | // If we can't take it, we can't attach it! |
109 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); | 118 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); |
110 | if (part == null) | 119 | if (part == null) |
@@ -123,7 +132,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
123 | AttachmentPt &= 0x7f; | 132 | AttachmentPt &= 0x7f; |
124 | 133 | ||
125 | // Calls attach with a Zero position | 134 | // Calls attach with a Zero position |
126 | if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) | 135 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) |
127 | { | 136 | { |
128 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); | 137 | m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); |
129 | 138 | ||
@@ -136,12 +145,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
136 | } | 145 | } |
137 | catch (Exception e) | 146 | catch (Exception e) |
138 | { | 147 | { |
139 | m_log.DebugFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}", e); | 148 | m_log.ErrorFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}{1}", e.Message, e.StackTrace); |
140 | } | 149 | } |
141 | } | 150 | } |
142 | 151 | ||
143 | public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) | 152 | public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) |
144 | { | 153 | { |
154 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
155 | |||
156 | if (sp == null) | ||
157 | { | ||
158 | m_log.ErrorFormat( | ||
159 | "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); | ||
160 | return false; | ||
161 | } | ||
162 | |||
163 | return AttachObject(sp, group, AttachmentPt, silent); | ||
164 | } | ||
165 | |||
166 | public bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) | ||
167 | { | ||
145 | Vector3 attachPos = group.AbsolutePosition; | 168 | Vector3 attachPos = group.AbsolutePosition; |
146 | 169 | ||
147 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | 170 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should |
@@ -175,32 +198,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
175 | group.AbsolutePosition = attachPos; | 198 | group.AbsolutePosition = attachPos; |
176 | 199 | ||
177 | // Remove any previous attachments | 200 | // Remove any previous attachments |
178 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
179 | UUID itemID = UUID.Zero; | 201 | UUID itemID = UUID.Zero; |
180 | if (sp != null) | 202 | foreach (SceneObjectGroup grp in sp.Attachments) |
181 | { | 203 | { |
182 | foreach (SceneObjectGroup grp in sp.Attachments) | 204 | if (grp.GetAttachmentPoint() == (byte)AttachmentPt) |
183 | { | 205 | { |
184 | if (grp.GetAttachmentPoint() == (byte)AttachmentPt) | 206 | itemID = grp.GetFromItemID(); |
185 | { | 207 | break; |
186 | itemID = grp.GetFromItemID(); | ||
187 | break; | ||
188 | } | ||
189 | } | 208 | } |
190 | if (itemID != UUID.Zero) | ||
191 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
192 | } | 209 | } |
193 | 210 | ||
211 | if (itemID != UUID.Zero) | ||
212 | DetachSingleAttachmentToInv(itemID, sp); | ||
213 | |||
194 | if (group.GetFromItemID() == UUID.Zero) | 214 | if (group.GetFromItemID() == UUID.Zero) |
195 | { | 215 | { |
196 | m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID); | 216 | m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID); |
197 | } | 217 | } |
198 | else | 218 | else |
199 | { | 219 | { |
200 | itemID = group.GetFromItemID(); | 220 | itemID = group.GetFromItemID(); |
201 | } | 221 | } |
202 | 222 | ||
203 | ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group); | 223 | ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); |
204 | 224 | ||
205 | AttachToAgent(sp, group, AttachmentPt, attachPos, silent); | 225 | AttachToAgent(sp, group, AttachmentPt, attachPos, silent); |
206 | 226 | ||
@@ -229,19 +249,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
229 | // m_log.DebugFormat( | 249 | // m_log.DebugFormat( |
230 | // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", | 250 | // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", |
231 | // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); | 251 | // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); |
252 | |||
253 | ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); | ||
254 | |||
255 | if (sp == null) | ||
256 | { | ||
257 | m_log.ErrorFormat( | ||
258 | "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()", | ||
259 | remoteClient.Name, remoteClient.AgentId); | ||
260 | return UUID.Zero; | ||
261 | } | ||
232 | 262 | ||
233 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | 263 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should |
234 | // be removed when that functionality is implemented in opensim | 264 | // be removed when that functionality is implemented in opensim |
235 | AttachmentPt &= 0x7f; | 265 | AttachmentPt &= 0x7f; |
236 | 266 | ||
237 | SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); | 267 | SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, AttachmentPt); |
238 | 268 | ||
239 | if (updateInventoryStatus) | 269 | if (updateInventoryStatus) |
240 | { | 270 | { |
241 | if (att == null) | 271 | if (att == null) |
242 | ShowDetachInUserInventory(itemID, remoteClient); | 272 | ShowDetachInUserInventory(itemID, sp.ControllingClient); |
243 | else | 273 | else |
244 | ShowAttachInUserInventory(att, remoteClient, itemID, AttachmentPt); | 274 | ShowAttachInUserInventory(att, sp, itemID, AttachmentPt); |
245 | } | 275 | } |
246 | 276 | ||
247 | if (null == att) | 277 | if (null == att) |
@@ -250,15 +280,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
250 | return att.UUID; | 280 | return att.UUID; |
251 | } | 281 | } |
252 | 282 | ||
253 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( | 283 | private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( |
254 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 284 | ScenePresence sp, UUID itemID, uint AttachmentPt) |
255 | { | 285 | { |
256 | IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); | 286 | IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); |
257 | if (invAccess != null) | 287 | if (invAccess != null) |
258 | { | 288 | { |
259 | SceneObjectGroup objatt = invAccess.RezObject(remoteClient, | 289 | SceneObjectGroup objatt = invAccess.RezObject(sp.ControllingClient, |
260 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | 290 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, |
261 | false, false, remoteClient.AgentId, true); | 291 | false, false, sp.UUID, true); |
262 | 292 | ||
263 | // m_log.DebugFormat( | 293 | // m_log.DebugFormat( |
264 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", | 294 | // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", |
@@ -277,10 +307,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
277 | // This will throw if the attachment fails | 307 | // This will throw if the attachment fails |
278 | try | 308 | try |
279 | { | 309 | { |
280 | AttachObject(remoteClient, objatt, AttachmentPt, false); | 310 | AttachObject(sp, objatt, AttachmentPt, false); |
281 | } | 311 | } |
282 | catch | 312 | catch (Exception e) |
283 | { | 313 | { |
314 | m_log.ErrorFormat( | ||
315 | "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", | ||
316 | objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); | ||
317 | |||
284 | // Make sure the object doesn't stick around and bail | 318 | // Make sure the object doesn't stick around and bail |
285 | m_scene.DeleteSceneObject(objatt, false); | 319 | m_scene.DeleteSceneObject(objatt, false); |
286 | return null; | 320 | return null; |
@@ -295,13 +329,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
295 | objatt.ResumeScripts(); | 329 | objatt.ResumeScripts(); |
296 | 330 | ||
297 | // Do this last so that event listeners have access to all the effects of the attachment | 331 | // Do this last so that event listeners have access to all the effects of the attachment |
298 | m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); | 332 | m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); |
299 | } | 333 | } |
300 | else | 334 | else |
301 | { | 335 | { |
302 | m_log.WarnFormat( | 336 | m_log.WarnFormat( |
303 | "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", | 337 | "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", |
304 | itemID, remoteClient.Name, AttachmentPt); | 338 | itemID, sp.Name, AttachmentPt); |
305 | } | 339 | } |
306 | 340 | ||
307 | return objatt; | 341 | return objatt; |
@@ -314,12 +348,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
314 | /// Update the user inventory to the attachment of an item | 348 | /// Update the user inventory to the attachment of an item |
315 | /// </summary> | 349 | /// </summary> |
316 | /// <param name="att"></param> | 350 | /// <param name="att"></param> |
317 | /// <param name="remoteClient"></param> | 351 | /// <param name="sp"></param> |
318 | /// <param name="itemID"></param> | 352 | /// <param name="itemID"></param> |
319 | /// <param name="AttachmentPt"></param> | 353 | /// <param name="AttachmentPt"></param> |
320 | /// <returns></returns> | 354 | /// <returns></returns> |
321 | protected UUID ShowAttachInUserInventory( | 355 | private UUID ShowAttachInUserInventory( |
322 | SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | 356 | SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt) |
323 | { | 357 | { |
324 | // m_log.DebugFormat( | 358 | // m_log.DebugFormat( |
325 | // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})", | 359 | // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})", |
@@ -328,16 +362,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
328 | if (!att.IsDeleted) | 362 | if (!att.IsDeleted) |
329 | AttachmentPt = att.RootPart.AttachmentPoint; | 363 | AttachmentPt = att.RootPart.AttachmentPoint; |
330 | 364 | ||
331 | ScenePresence presence; | 365 | InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); |
332 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 366 | item = m_scene.InventoryService.GetItem(item); |
333 | { | ||
334 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
335 | item = m_scene.InventoryService.GetItem(item); | ||
336 | 367 | ||
337 | bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); | 368 | bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); |
338 | if (changed && m_scene.AvatarFactory != null) | 369 | if (changed && m_scene.AvatarFactory != null) |
339 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | 370 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); |
340 | } | ||
341 | 371 | ||
342 | return att.UUID; | 372 | return att.UUID; |
343 | } | 373 | } |
@@ -345,12 +375,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
345 | /// <summary> | 375 | /// <summary> |
346 | /// Update the user inventory to reflect an attachment | 376 | /// Update the user inventory to reflect an attachment |
347 | /// </summary> | 377 | /// </summary> |
348 | /// <param name="remoteClient"></param> | 378 | /// <param name="sp"></param> |
349 | /// <param name="AttachmentPt"></param> | 379 | /// <param name="AttachmentPt"></param> |
350 | /// <param name="itemID"></param> | 380 | /// <param name="itemID"></param> |
351 | /// <param name="att"></param> | 381 | /// <param name="att"></param> |
352 | protected void ShowAttachInUserInventory( | 382 | private void ShowAttachInUserInventory( |
353 | IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | 383 | ScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) |
354 | { | 384 | { |
355 | // m_log.DebugFormat( | 385 | // m_log.DebugFormat( |
356 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", | 386 | // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", |
@@ -374,16 +404,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
374 | return; | 404 | return; |
375 | } | 405 | } |
376 | 406 | ||
377 | ScenePresence presence; | 407 | InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); |
378 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) | 408 | item = m_scene.InventoryService.GetItem(item); |
379 | { | 409 | bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); |
380 | // XXYY!! | 410 | if (changed && m_scene.AvatarFactory != null) |
381 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | 411 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); |
382 | item = m_scene.InventoryService.GetItem(item); | ||
383 | bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); | ||
384 | if (changed && m_scene.AvatarFactory != null) | ||
385 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | ||
386 | } | ||
387 | } | 412 | } |
388 | 413 | ||
389 | public void DetachObject(uint objectLocalID, IClientAPI remoteClient) | 414 | public void DetachObject(uint objectLocalID, IClientAPI remoteClient) |
@@ -407,9 +432,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
407 | bool changed = presence.Appearance.DetachAttachment(itemID); | 432 | bool changed = presence.Appearance.DetachAttachment(itemID); |
408 | if (changed && m_scene.AvatarFactory != null) | 433 | if (changed && m_scene.AvatarFactory != null) |
409 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); | 434 | m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); |
410 | } | ||
411 | 435 | ||
412 | DetachSingleAttachmentToInv(itemID, remoteClient); | 436 | DetachSingleAttachmentToInv(itemID, presence); |
437 | } | ||
413 | } | 438 | } |
414 | 439 | ||
415 | public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) | 440 | public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) |
@@ -447,7 +472,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
447 | 472 | ||
448 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. | 473 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. |
449 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? | 474 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? |
450 | protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) | 475 | private void DetachSingleAttachmentToInv(UUID itemID, ScenePresence sp) |
451 | { | 476 | { |
452 | if (itemID == UUID.Zero) // If this happened, someone made a mistake.... | 477 | if (itemID == UUID.Zero) // If this happened, someone made a mistake.... |
453 | return; | 478 | return; |
@@ -474,7 +499,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
474 | if (p.Inventory.ContainsScripts()) | 499 | if (p.Inventory.ContainsScripts()) |
475 | group.HasGroupChanged = true; | 500 | group.HasGroupChanged = true; |
476 | 501 | ||
477 | UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID); | 502 | UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID); |
478 | m_scene.DeleteSceneObject(group, false); | 503 | m_scene.DeleteSceneObject(group, false); |
479 | return; | 504 | return; |
480 | } | 505 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 4cb3df2..e012885 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | |||
@@ -49,11 +49,9 @@ namespace OpenSim.Region.Framework.Interfaces | |||
49 | /// <summary> | 49 | /// <summary> |
50 | /// Attach an object to an avatar. | 50 | /// Attach an object to an avatar. |
51 | /// </summary> | 51 | /// </summary> |
52 | /// <param name="controllingClient"></param> | 52 | /// <param name="remoteClient"></param> |
53 | /// <param name="localID"></param> | 53 | /// <param name="grp"></param> |
54 | /// <param name="attachPoint"></param> | 54 | /// <param name="AttachmentPt"></param> |
55 | /// <param name="rot"></param> | ||
56 | /// <param name="attachPos"></param> | ||
57 | /// <param name="silent"></param> | 55 | /// <param name="silent"></param> |
58 | /// <returns>true if the object was successfully attached, false otherwise</returns> | 56 | /// <returns>true if the object was successfully attached, false otherwise</returns> |
59 | bool AttachObject( | 57 | bool AttachObject( |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 53c3b85..9f9af45 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3540,7 +3540,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3540 | } | 3540 | } |
3541 | } | 3541 | } |
3542 | } | 3542 | } |
3543 | 3543 | ||
3544 | return true; | 3544 | return true; |
3545 | } | 3545 | } |
3546 | 3546 | ||