diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
16 files changed, 1035 insertions, 534 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 1ca142e..d47ca4b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Region.Framework; | |||
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | using OpenSim.Region.Framework.Scenes.Serialization; | 43 | using OpenSim.Region.Framework.Scenes.Serialization; |
44 | using OpenSim.Services.Interfaces; | ||
44 | 45 | ||
45 | namespace OpenSim.Region.CoreModules.Avatar.Attachments | 46 | namespace OpenSim.Region.CoreModules.Avatar.Attachments |
46 | { | 47 | { |
@@ -295,6 +296,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
295 | if (DebugLevel > 0) | 296 | if (DebugLevel > 0) |
296 | m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name); | 297 | m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name); |
297 | 298 | ||
299 | XmlDocument doc = new XmlDocument(); | ||
300 | string stateData = String.Empty; | ||
301 | |||
302 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
303 | if (attServ != null) | ||
304 | { | ||
305 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
306 | stateData = attServ.Get(sp.UUID.ToString()); | ||
307 | if (stateData != String.Empty) | ||
308 | { | ||
309 | try | ||
310 | { | ||
311 | doc.LoadXml(stateData); | ||
312 | } | ||
313 | catch { } | ||
314 | } | ||
315 | } | ||
316 | |||
317 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
318 | |||
319 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
320 | if (nodes.Count > 0) | ||
321 | { | ||
322 | foreach (XmlNode n in nodes) | ||
323 | { | ||
324 | XmlElement elem = (XmlElement)n; | ||
325 | string itemID = elem.GetAttribute("ItemID"); | ||
326 | string xml = elem.InnerXml; | ||
327 | |||
328 | itemData[new UUID(itemID)] = xml; | ||
329 | } | ||
330 | } | ||
331 | |||
332 | |||
298 | List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); | 333 | List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); |
299 | foreach (AvatarAttachment attach in attachments) | 334 | foreach (AvatarAttachment attach in attachments) |
300 | { | 335 | { |
@@ -314,10 +349,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
314 | 349 | ||
315 | try | 350 | try |
316 | { | 351 | { |
352 | string xmlData; | ||
353 | XmlDocument d = null; | ||
354 | UUID asset; | ||
355 | if (itemData.TryGetValue(attach.ItemID, out xmlData)) | ||
356 | { | ||
357 | d = new XmlDocument(); | ||
358 | d.LoadXml(xmlData); | ||
359 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID); | ||
360 | } | ||
361 | |||
317 | // If we're an NPC then skip all the item checks and manipulations since we don't have an | 362 | // If we're an NPC then skip all the item checks and manipulations since we don't have an |
318 | // inventory right now. | 363 | // inventory right now. |
319 | RezSingleAttachmentFromInventoryInternal( | 364 | RezSingleAttachmentFromInventoryInternal( |
320 | sp, sp.PresenceType == PresenceType.Npc ? UUID.Zero : attach.ItemID, attach.AssetID, attachmentPt, true); | 365 | sp, sp.PresenceType == PresenceType.Npc ? UUID.Zero : attach.ItemID, attach.AssetID, attachmentPt, true, d); |
321 | } | 366 | } |
322 | catch (Exception e) | 367 | catch (Exception e) |
323 | { | 368 | { |
@@ -380,13 +425,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
380 | sp.ClearAttachments(); | 425 | sp.ClearAttachments(); |
381 | } | 426 | } |
382 | 427 | ||
383 | public bool AttachObject( | 428 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool addToInventory, bool append) |
384 | IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool append) | ||
385 | { | 429 | { |
386 | if (!Enabled) | 430 | if (!Enabled) |
387 | return false; | 431 | return false; |
388 | 432 | ||
389 | return AttachObjectInternal(sp, group, attachmentPt, silent, addToInventory, false, append); | 433 | return AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, addToInventory, false, append); |
390 | } | 434 | } |
391 | 435 | ||
392 | /// <summary> | 436 | /// <summary> |
@@ -399,10 +443,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
399 | /// <param name='silent'></param> | 443 | /// <param name='silent'></param> |
400 | /// <param name='addToInventory'>If true then add object to user inventory.</param> | 444 | /// <param name='addToInventory'>If true then add object to user inventory.</param> |
401 | /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> | 445 | /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> |
402 | /// <param name='append'>Append to attachment point rather than replace.</param> | 446 | private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool addToInventory, bool resumeScripts, bool append) |
403 | private bool AttachObjectInternal( | ||
404 | IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool resumeScripts, bool append) | ||
405 | { | 447 | { |
448 | // m_log.DebugFormat( | ||
449 | // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", | ||
450 | // group.Name, group.LocalId, sp.Name, attachmentPt, silent); | ||
451 | |||
452 | if (sp.GetAttachments().Contains(group)) | ||
453 | { | ||
454 | // m_log.WarnFormat( | ||
455 | // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", | ||
456 | // group.Name, group.LocalId, sp.Name, AttachmentPt); | ||
457 | |||
458 | return false; | ||
459 | } | ||
460 | |||
406 | if (group.GetSittingAvatarsCount() != 0) | 461 | if (group.GetSittingAvatarsCount() != 0) |
407 | { | 462 | { |
408 | if (DebugLevel > 0) | 463 | if (DebugLevel > 0) |
@@ -414,6 +469,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
414 | } | 469 | } |
415 | 470 | ||
416 | Vector3 attachPos = group.AbsolutePosition; | 471 | Vector3 attachPos = group.AbsolutePosition; |
472 | |||
473 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | ||
474 | // be removed when that functionality is implemented in opensim | ||
475 | attachmentPt &= 0x7f; | ||
476 | |||
417 | // If the attachment point isn't the same as the one previously used | 477 | // If the attachment point isn't the same as the one previously used |
418 | // set it's offset position = 0 so that it appears on the attachment point | 478 | // set it's offset position = 0 so that it appears on the attachment point |
419 | // and not in a weird location somewhere unknown. | 479 | // and not in a weird location somewhere unknown. |
@@ -452,9 +512,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
452 | attachPos = Vector3.Zero; | 512 | attachPos = Vector3.Zero; |
453 | } | 513 | } |
454 | 514 | ||
455 | group.AttachmentPoint = attachmentPt; | ||
456 | group.AbsolutePosition = attachPos; | ||
457 | |||
458 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); | 515 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); |
459 | 516 | ||
460 | if (attachments.Contains(group)) | 517 | if (attachments.Contains(group)) |
@@ -487,6 +544,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
487 | 544 | ||
488 | lock (sp.AttachmentsSyncLock) | 545 | lock (sp.AttachmentsSyncLock) |
489 | { | 546 | { |
547 | group.AttachmentPoint = attachmentPt; | ||
548 | group.AbsolutePosition = attachPos; | ||
549 | |||
490 | if (addToInventory && sp.PresenceType != PresenceType.Npc) | 550 | if (addToInventory && sp.PresenceType != PresenceType.Npc) |
491 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append); | 551 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append); |
492 | 552 | ||
@@ -517,7 +577,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
517 | ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append); | 577 | ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group, append); |
518 | } | 578 | } |
519 | 579 | ||
520 | public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) | 580 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) |
581 | { | ||
582 | return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, null); | ||
583 | } | ||
584 | |||
585 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, XmlDocument doc) | ||
521 | { | 586 | { |
522 | if (!Enabled) | 587 | if (!Enabled) |
523 | return null; | 588 | return null; |
@@ -555,7 +620,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
555 | bool append = (AttachmentPt & 0x80) != 0; | 620 | bool append = (AttachmentPt & 0x80) != 0; |
556 | AttachmentPt &= 0x7f; | 621 | AttachmentPt &= 0x7f; |
557 | 622 | ||
558 | return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, append); | 623 | return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, append, doc); |
559 | } | 624 | } |
560 | 625 | ||
561 | public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) | 626 | public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) |
@@ -620,6 +685,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
620 | if (changed && m_scene.AvatarFactory != null) | 685 | if (changed && m_scene.AvatarFactory != null) |
621 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); | 686 | m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); |
622 | 687 | ||
688 | so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint; | ||
689 | |||
623 | sp.RemoveAttachment(so); | 690 | sp.RemoveAttachment(so); |
624 | so.FromItemID = UUID.Zero; | 691 | so.FromItemID = UUID.Zero; |
625 | 692 | ||
@@ -632,9 +699,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
632 | so.AttachedAvatar = UUID.Zero; | 699 | so.AttachedAvatar = UUID.Zero; |
633 | rootPart.SetParentLocalId(0); | 700 | rootPart.SetParentLocalId(0); |
634 | so.ClearPartAttachmentData(); | 701 | so.ClearPartAttachmentData(); |
635 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); | 702 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive,false); |
636 | so.HasGroupChanged = true; | 703 | so.HasGroupChanged = true; |
637 | so.RootPart.Shape.LastAttachPoint = (byte)so.AttachmentPoint; | ||
638 | rootPart.Rezzed = DateTime.Now; | 704 | rootPart.Rezzed = DateTime.Now; |
639 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); | 705 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); |
640 | so.AttachToBackup(); | 706 | so.AttachToBackup(); |
@@ -966,7 +1032,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
966 | } | 1032 | } |
967 | 1033 | ||
968 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( | 1034 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( |
969 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, bool append) | 1035 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, bool append, XmlDocument doc) |
970 | { | 1036 | { |
971 | if (m_invAccessModule == null) | 1037 | if (m_invAccessModule == null) |
972 | return null; | 1038 | return null; |
@@ -1010,7 +1076,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
1010 | // This will throw if the attachment fails | 1076 | // This will throw if the attachment fails |
1011 | try | 1077 | try |
1012 | { | 1078 | { |
1013 | AttachObjectInternal(sp, objatt, attachmentPt, false, true, true, append); | 1079 | if (doc != null) |
1080 | { | ||
1081 | objatt.LoadScriptState(doc); | ||
1082 | objatt.ResetOwnerChangeFlag(); | ||
1083 | } | ||
1084 | |||
1085 | AttachObjectInternal(sp, objatt, attachmentPt, false, true, true, true, append); | ||
1014 | } | 1086 | } |
1015 | catch (Exception e) | 1087 | catch (Exception e) |
1016 | { | 1088 | { |
@@ -1164,7 +1236,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
1164 | AttachmentPt &= 0x7f; | 1236 | AttachmentPt &= 0x7f; |
1165 | 1237 | ||
1166 | // Calls attach with a Zero position | 1238 | // Calls attach with a Zero position |
1167 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, append)) | 1239 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false, true, append)) |
1168 | { | 1240 | { |
1169 | if (DebugLevel > 0) | 1241 | if (DebugLevel > 0) |
1170 | m_log.Debug( | 1242 | m_log.Debug( |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 4e58045..f023e77 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -201,7 +201,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
201 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); | 201 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); |
202 | 202 | ||
203 | m_numberOfAttachEventsFired = 0; | 203 | m_numberOfAttachEventsFired = 0; |
204 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false); | 204 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false, false); |
205 | 205 | ||
206 | // Check status on scene presence | 206 | // Check status on scene presence |
207 | Assert.That(sp.HasAttachments(), Is.True); | 207 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -248,7 +248,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
248 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); | 248 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); |
249 | 249 | ||
250 | m_numberOfAttachEventsFired = 0; | 250 | m_numberOfAttachEventsFired = 0; |
251 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false); | 251 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false, false); |
252 | 252 | ||
253 | // Check status on scene presence | 253 | // Check status on scene presence |
254 | Assert.That(sp.HasAttachments(), Is.True); | 254 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -281,7 +281,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
281 | 281 | ||
282 | // Test wearing a different attachment from the ground. | 282 | // Test wearing a different attachment from the ground. |
283 | { | 283 | { |
284 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); | 284 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false, false); |
285 | 285 | ||
286 | // Check status on scene presence | 286 | // Check status on scene presence |
287 | Assert.That(sp.HasAttachments(), Is.True); | 287 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -314,7 +314,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
314 | 314 | ||
315 | // Test rewearing an already worn attachment from ground. Nothing should happen. | 315 | // Test rewearing an already worn attachment from ground. Nothing should happen. |
316 | { | 316 | { |
317 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false); | 317 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false, false); |
318 | 318 | ||
319 | // Check status on scene presence | 319 | // Check status on scene presence |
320 | Assert.That(sp.HasAttachments(), Is.True); | 320 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -372,7 +372,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
372 | sp2.AbsolutePosition = new Vector3(0, 0, 0); | 372 | sp2.AbsolutePosition = new Vector3(0, 0, 0); |
373 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); | 373 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); |
374 | 374 | ||
375 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false); | 375 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false, false); |
376 | 376 | ||
377 | Assert.That(sp.HasAttachments(), Is.False); | 377 | Assert.That(sp.HasAttachments(), Is.False); |
378 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 378 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
@@ -667,7 +667,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
667 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 667 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; |
668 | 668 | ||
669 | SceneObjectGroup rezzedSo | 669 | SceneObjectGroup rezzedSo |
670 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 670 | = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); |
671 | 671 | ||
672 | // Wait for chat to signal rezzed script has been started. | 672 | // Wait for chat to signal rezzed script has been started. |
673 | m_chatEvent.WaitOne(60000); | 673 | m_chatEvent.WaitOne(60000); |
@@ -686,7 +686,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
686 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); | 686 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); |
687 | 687 | ||
688 | // Re-rez the attachment to check script running state | 688 | // Re-rez the attachment to check script running state |
689 | SceneObjectGroup reRezzedSo = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 689 | SceneObjectGroup reRezzedSo = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); |
690 | 690 | ||
691 | // Wait for chat to signal rezzed script has been started. | 691 | // Wait for chat to signal rezzed script has been started. |
692 | m_chatEvent.WaitOne(60000); | 692 | m_chatEvent.WaitOne(60000); |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index aea768e..09cc998 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -145,33 +145,37 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
145 | /// <param name="sp"></param> | 145 | /// <param name="sp"></param> |
146 | /// <param name="texture"></param> | 146 | /// <param name="texture"></param> |
147 | /// <param name="visualParam"></param> | 147 | /// <param name="visualParam"></param> |
148 | public void SetAppearance(IScenePresence sp, AvatarAppearance appearance) | 148 | public void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems) |
149 | { | 149 | { |
150 | DoSetAppearance(sp, appearance.Texture, appearance.VisualParams, new List<CachedTextureRequestArg>()); | 150 | SetAppearance(sp, appearance.Texture, appearance.VisualParams, cacheItems); |
151 | } | 151 | } |
152 | 152 | ||
153 | /// <summary> | 153 | |
154 | /// Set appearance data (texture asset IDs and slider settings) | 154 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) |
155 | /// </summary> | ||
156 | /// <param name="sp"></param> | ||
157 | /// <param name="texture"></param> | ||
158 | /// <param name="visualParam"></param> | ||
159 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams) | ||
160 | { | 155 | { |
161 | DoSetAppearance(sp, textureEntry, visualParams, new List<CachedTextureRequestArg>()); | 156 | float oldoff = sp.Appearance.AvatarFeetOffset; |
157 | Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
158 | |||
159 | SetAppearance(sp, textureEntry, visualParams, cacheItems); | ||
160 | sp.Appearance.SetSize(avSize); | ||
161 | |||
162 | float off = sp.Appearance.AvatarFeetOffset; | ||
163 | Vector3 box = sp.Appearance.AvatarBoxSize; | ||
164 | if (oldoff != off || oldbox != box) | ||
165 | ((ScenePresence)sp).SetSize(box, off); | ||
162 | } | 166 | } |
163 | 167 | ||
164 | /// <summary> | 168 | /// <summary> |
165 | /// Set appearance data (texture asset IDs and slider settings) | 169 | /// Set appearance data (texture asset IDs and slider settings) |
166 | /// </summary> | 170 | /// </summary> |
167 | /// <param name="sp"></param> | 171 | /// <param name="sp"></param> |
168 | /// <param name="texture"></param> | 172 | /// <param name="texture"></param> |
169 | /// <param name="visualParam"></param> | 173 | /// <param name="visualParam"></param> |
170 | protected void DoSetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, List<CachedTextureRequestArg> hashes) | 174 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems) |
171 | { | 175 | { |
172 | // m_log.DebugFormat( | 176 | // m_log.DebugFormat( |
173 | // "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}", | 177 | // "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}", |
174 | // sp.Name, textureEntry, visualParams); | 178 | // sp.Name, textureEntry, visualParams); |
175 | 179 | ||
176 | // TODO: This is probably not necessary any longer, just assume the | 180 | // TODO: This is probably not necessary any longer, just assume the |
177 | // textureEntry set implies that the appearance transaction is complete | 181 | // textureEntry set implies that the appearance transaction is complete |
@@ -190,36 +194,38 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
190 | // m_log.DebugFormat( | 194 | // m_log.DebugFormat( |
191 | // "[AVFACTORY]: Setting visual params for {0} to {1}", | 195 | // "[AVFACTORY]: Setting visual params for {0} to {1}", |
192 | // client.Name, string.Join(", ", visualParamsStrings)); | 196 | // client.Name, string.Join(", ", visualParamsStrings)); |
193 | 197 | /* | |
194 | float oldHeight = sp.Appearance.AvatarHeight; | 198 | float oldHeight = sp.Appearance.AvatarHeight; |
195 | changed = sp.Appearance.SetVisualParams(visualParams); | 199 | changed = sp.Appearance.SetVisualParams(visualParams); |
196 | 200 | ||
197 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) | 201 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) |
198 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); | 202 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); |
199 | } | 203 | */ |
204 | // float oldoff = sp.Appearance.AvatarFeetOffset; | ||
205 | // Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
206 | changed = sp.Appearance.SetVisualParams(visualParams); | ||
207 | // float off = sp.Appearance.AvatarFeetOffset; | ||
208 | // Vector3 box = sp.Appearance.AvatarBoxSize; | ||
209 | // if(oldoff != off || oldbox != box) | ||
210 | // ((ScenePresence)sp).SetSize(box,off); | ||
200 | 211 | ||
212 | } | ||
213 | |||
201 | // Process the baked texture array | 214 | // Process the baked texture array |
202 | if (textureEntry != null) | 215 | if (textureEntry != null) |
203 | { | 216 | { |
204 | // m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); | 217 | m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); |
205 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | 218 | |
219 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | ||
206 | 220 | ||
207 | changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; | 221 | changed = sp.Appearance.SetTextureEntries(textureEntry) || changed; |
208 | 222 | ||
209 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | 223 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); |
210 | 224 | ||
211 | // If bake textures are missing and this is not an NPC, request a rebake from client | 225 | // If bake textures are missing and this is not an NPC, request a rebake from client |
212 | if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc)) | 226 | if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc)) |
213 | RequestRebake(sp, true); | 227 | RequestRebake(sp, true); |
214 | 228 | ||
215 | // Save the wearble hashes in the appearance | ||
216 | sp.Appearance.ResetTextureHashes(); | ||
217 | if (m_reusetextures) | ||
218 | { | ||
219 | foreach (CachedTextureRequestArg arg in hashes) | ||
220 | sp.Appearance.SetTextureHash(arg.BakedTextureIndex,arg.WearableHashID); | ||
221 | } | ||
222 | |||
223 | // This appears to be set only in the final stage of the appearance | 229 | // This appears to be set only in the final stage of the appearance |
224 | // update transaction. In theory, we should be able to do an immediate | 230 | // update transaction. In theory, we should be able to do an immediate |
225 | // appearance send and save here. | 231 | // appearance send and save here. |
@@ -253,13 +259,13 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
253 | 259 | ||
254 | public bool SendAppearance(UUID agentId) | 260 | public bool SendAppearance(UUID agentId) |
255 | { | 261 | { |
256 | // m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId); | 262 | // m_log.DebugFormat("[AVFACTORY]: Sending appearance for {0}", agentId); |
257 | 263 | ||
258 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 264 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
259 | if (sp == null) | 265 | if (sp == null) |
260 | { | 266 | { |
261 | // This is expected if the user has gone away. | 267 | // This is expected if the user has gone away. |
262 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); | 268 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentId); |
263 | return false; | 269 | return false; |
264 | } | 270 | } |
265 | 271 | ||
@@ -277,6 +283,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
277 | return GetBakedTextureFaces(sp); | 283 | return GetBakedTextureFaces(sp); |
278 | } | 284 | } |
279 | 285 | ||
286 | public WearableCacheItem[] GetCachedItems(UUID agentId) | ||
287 | { | ||
288 | ScenePresence sp = m_scene.GetScenePresence(agentId); | ||
289 | WearableCacheItem[] items = sp.Appearance.WearableCacheItems; | ||
290 | //foreach (WearableCacheItem item in items) | ||
291 | //{ | ||
292 | |||
293 | //} | ||
294 | return items; | ||
295 | } | ||
296 | |||
280 | public bool SaveBakedTextures(UUID agentId) | 297 | public bool SaveBakedTextures(UUID agentId) |
281 | { | 298 | { |
282 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 299 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
@@ -336,7 +353,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
336 | /// <param name="agentId"></param> | 353 | /// <param name="agentId"></param> |
337 | public void QueueAppearanceSend(UUID agentid) | 354 | public void QueueAppearanceSend(UUID agentid) |
338 | { | 355 | { |
339 | // m_log.DebugFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); | 356 | // m_log.DebugFormat("[AVFACTORY]: Queue appearance send for {0}", agentid); |
340 | 357 | ||
341 | // 10000 ticks per millisecond, 1000 milliseconds per second | 358 | // 10000 ticks per millisecond, 1000 milliseconds per second |
342 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000); | 359 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_sendtime * 1000 * 10000); |
@@ -349,7 +366,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
349 | 366 | ||
350 | public void QueueAppearanceSave(UUID agentid) | 367 | public void QueueAppearanceSave(UUID agentid) |
351 | { | 368 | { |
352 | // m_log.DebugFormat("[AVFACTORY]: Queueing appearance save for {0}", agentid); | 369 | // m_log.DebugFormat("[AVFACTORY]: Queueing appearance save for {0}", agentid); |
353 | 370 | ||
354 | // 10000 ticks per millisecond, 1000 milliseconds per second | 371 | // 10000 ticks per millisecond, 1000 milliseconds per second |
355 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000); | 372 | long timestamp = DateTime.Now.Ticks + Convert.ToInt64(m_savetime * 1000 * 10000); |
@@ -363,6 +380,53 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
363 | public bool ValidateBakedTextureCache(IScenePresence sp) | 380 | public bool ValidateBakedTextureCache(IScenePresence sp) |
364 | { | 381 | { |
365 | bool defonly = true; // are we only using default textures | 382 | bool defonly = true; // are we only using default textures |
383 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
384 | IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
385 | WearableCacheItem[] wearableCache = null; | ||
386 | |||
387 | // Cache wearable data for teleport. | ||
388 | // Only makes sense if there's a bake module and a cache module | ||
389 | if (bakedModule != null && cache != null) | ||
390 | { | ||
391 | try | ||
392 | { | ||
393 | wearableCache = bakedModule.Get(sp.UUID); | ||
394 | } | ||
395 | catch (Exception) | ||
396 | { | ||
397 | |||
398 | } | ||
399 | if (wearableCache != null) | ||
400 | { | ||
401 | for (int i = 0; i < wearableCache.Length; i++) | ||
402 | { | ||
403 | cache.Cache(wearableCache[i].TextureAsset); | ||
404 | } | ||
405 | } | ||
406 | } | ||
407 | /* | ||
408 | IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
409 | if (invService.GetRootFolder(userID) != null) | ||
410 | { | ||
411 | WearableCacheItem[] wearableCache = null; | ||
412 | if (bakedModule != null) | ||
413 | { | ||
414 | try | ||
415 | { | ||
416 | wearableCache = bakedModule.Get(userID); | ||
417 | appearance.WearableCacheItems = wearableCache; | ||
418 | appearance.WearableCacheItemsDirty = false; | ||
419 | foreach (WearableCacheItem item in wearableCache) | ||
420 | { | ||
421 | appearance.Texture.FaceTextures[item.TextureIndex].TextureID = item.TextureID; | ||
422 | } | ||
423 | } | ||
424 | catch (Exception) | ||
425 | { | ||
426 | |||
427 | } | ||
428 | } | ||
429 | */ | ||
366 | 430 | ||
367 | // Process the texture entry | 431 | // Process the texture entry |
368 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 432 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
@@ -370,13 +434,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
370 | int idx = AvatarAppearance.BAKE_INDICES[i]; | 434 | int idx = AvatarAppearance.BAKE_INDICES[i]; |
371 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; | 435 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; |
372 | 436 | ||
373 | // if there is no texture entry, skip it | 437 | // No face, so lets check our baked service cache, teleport or login. |
374 | if (face == null) | 438 | if (face == null) |
375 | continue; | 439 | { |
440 | if (wearableCache != null) | ||
441 | { | ||
442 | // If we find the an appearance item, set it as the textureentry and the face | ||
443 | WearableCacheItem searchitem = WearableCacheItem.SearchTextureIndex((uint) idx, wearableCache); | ||
444 | if (searchitem != null) | ||
445 | { | ||
446 | sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx); | ||
447 | sp.Appearance.Texture.FaceTextures[idx].TextureID = searchitem.TextureID; | ||
448 | face = sp.Appearance.Texture.FaceTextures[idx]; | ||
449 | } | ||
450 | else | ||
451 | { | ||
452 | // if there is no texture entry and no baked cache, skip it | ||
453 | continue; | ||
454 | } | ||
455 | } | ||
456 | else | ||
457 | { | ||
458 | //No texture entry face and no cache. Skip this face. | ||
459 | continue; | ||
460 | } | ||
461 | } | ||
462 | |||
376 | 463 | ||
377 | // m_log.DebugFormat( | 464 | // m_log.DebugFormat( |
378 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", | 465 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", |
379 | // face.TextureID, idx, client.Name, client.AgentId); | 466 | // face.TextureID, idx, client.Name, client.AgentId); |
380 | 467 | ||
381 | // if the texture is one of the "defaults" then skip it | 468 | // if the texture is one of the "defaults" then skip it |
382 | // this should probably be more intelligent (skirt texture doesnt matter | 469 | // this should probably be more intelligent (skirt texture doesnt matter |
@@ -387,11 +474,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
387 | 474 | ||
388 | defonly = false; // found a non-default texture reference | 475 | defonly = false; // found a non-default texture reference |
389 | 476 | ||
390 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | 477 | if (cache != null) |
391 | return false; | 478 | { |
479 | if (!cache.Check(face.TextureID.ToString())) | ||
480 | return false; | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | ||
485 | return false; | ||
486 | } | ||
392 | } | 487 | } |
393 | 488 | ||
394 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); | 489 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); |
395 | 490 | ||
396 | // If we only found default textures, then the appearance is not cached | 491 | // If we only found default textures, then the appearance is not cached |
397 | return (defonly ? false : true); | 492 | return (defonly ? false : true); |
@@ -400,6 +495,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
400 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) | 495 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) |
401 | { | 496 | { |
402 | int texturesRebaked = 0; | 497 | int texturesRebaked = 0; |
498 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
403 | 499 | ||
404 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 500 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
405 | { | 501 | { |
@@ -410,9 +506,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
410 | if (face == null) | 506 | if (face == null) |
411 | continue; | 507 | continue; |
412 | 508 | ||
413 | // m_log.DebugFormat( | 509 | // m_log.DebugFormat( |
414 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", | 510 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", |
415 | // face.TextureID, idx, client.Name, client.AgentId); | 511 | // face.TextureID, idx, client.Name, client.AgentId); |
416 | 512 | ||
417 | // if the texture is one of the "defaults" then skip it | 513 | // if the texture is one of the "defaults" then skip it |
418 | // this should probably be more intelligent (skirt texture doesnt matter | 514 | // this should probably be more intelligent (skirt texture doesnt matter |
@@ -423,21 +519,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
423 | 519 | ||
424 | if (missingTexturesOnly) | 520 | if (missingTexturesOnly) |
425 | { | 521 | { |
426 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) | 522 | if (cache != null) |
427 | { | 523 | { |
428 | continue; | 524 | if (cache.Check(face.TextureID.ToString())) |
525 | continue; | ||
526 | else | ||
527 | { | ||
528 | m_log.DebugFormat( | ||
529 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
530 | face.TextureID, idx, sp.Name); | ||
531 | } | ||
429 | } | 532 | } |
430 | else | 533 | else |
431 | { | 534 | { |
432 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the | 535 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) |
433 | // grid asset service (which means that they are not available to the new region and so have | 536 | { |
434 | // to be re-requested from the client). | 537 | continue; |
435 | // | 538 | } |
436 | // The only available core OpenSimulator behaviour right now | 539 | |
437 | // is not to store these textures, temporarily or otherwise. | 540 | else |
438 | m_log.DebugFormat( | 541 | { |
439 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | 542 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the |
440 | face.TextureID, idx, sp.Name); | 543 | // grid asset service (which means that they are not available to the new region and so have |
544 | // to be re-requested from the client). | ||
545 | // | ||
546 | // The only available core OpenSimulator behaviour right now | ||
547 | // is not to store these textures, temporarily or otherwise. | ||
548 | m_log.DebugFormat( | ||
549 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
550 | face.TextureID, idx, sp.Name); | ||
551 | } | ||
441 | } | 552 | } |
442 | } | 553 | } |
443 | else | 554 | else |
@@ -476,9 +587,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
476 | if (bakeType == BakeType.Unknown) | 587 | if (bakeType == BakeType.Unknown) |
477 | continue; | 588 | continue; |
478 | 589 | ||
479 | // m_log.DebugFormat( | 590 | // m_log.DebugFormat( |
480 | // "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}", | 591 | // "[AVFACTORY]: NPC avatar {0} has texture id {1} : {2}", |
481 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | 592 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); |
482 | 593 | ||
483 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); | 594 | int ftIndex = (int)AppearanceManager.BakeTypeToAgentTextureIndex(bakeType); |
484 | Primitive.TextureEntryFace texture = faceTextures[ftIndex]; // this will be null if there's no such baked texture | 595 | Primitive.TextureEntryFace texture = faceTextures[ftIndex]; // this will be null if there's no such baked texture |
@@ -502,7 +613,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
502 | UUID avatarID = kvp.Key; | 613 | UUID avatarID = kvp.Key; |
503 | long sendTime = kvp.Value; | 614 | long sendTime = kvp.Value; |
504 | 615 | ||
505 | // m_log.DebugFormat("[AVFACTORY]: Handling queued appearance updates for {0}, update delta to now is {1}", avatarID, sendTime - now); | 616 | // m_log.DebugFormat("[AVFACTORY]: Handling queued appearance updates for {0}, update delta to now is {1}", avatarID, sendTime - now); |
506 | 617 | ||
507 | if (sendTime < now) | 618 | if (sendTime < now) |
508 | { | 619 | { |
@@ -548,11 +659,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
548 | if (sp == null) | 659 | if (sp == null) |
549 | { | 660 | { |
550 | // This is expected if the user has gone away. | 661 | // This is expected if the user has gone away. |
551 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); | 662 | // m_log.DebugFormat("[AVFACTORY]: Agent {0} no longer in the scene", agentid); |
552 | return; | 663 | return; |
553 | } | 664 | } |
554 | 665 | ||
555 | // m_log.DebugFormat("[AVFACTORY]: Saving appearance for avatar {0}", agentid); | 666 | // m_log.DebugFormat("[AVFACTORY]: Saving appearance for avatar {0}", agentid); |
556 | 667 | ||
557 | // This could take awhile since it needs to pull inventory | 668 | // This could take awhile since it needs to pull inventory |
558 | // We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape | 669 | // We need to do it at the point of save so that there is a sufficient delay for any upload of new body part/shape |
@@ -579,26 +690,70 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
579 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) | 690 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) |
580 | { | 691 | { |
581 | IInventoryService invService = m_scene.InventoryService; | 692 | IInventoryService invService = m_scene.InventoryService; |
582 | 693 | bool resetwearable = false; | |
583 | if (invService.GetRootFolder(userID) != null) | 694 | if (invService.GetRootFolder(userID) != null) |
584 | { | 695 | { |
585 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | 696 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) |
586 | { | 697 | { |
587 | for (int j = 0; j < appearance.Wearables[i].Count; j++) | 698 | for (int j = 0; j < appearance.Wearables[i].Count; j++) |
588 | { | 699 | { |
700 | // Check if the default wearables are not set | ||
589 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) | 701 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) |
702 | { | ||
703 | switch ((WearableType) i) | ||
704 | { | ||
705 | case WearableType.Eyes: | ||
706 | case WearableType.Hair: | ||
707 | case WearableType.Shape: | ||
708 | case WearableType.Skin: | ||
709 | //case WearableType.Underpants: | ||
710 | TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance); | ||
711 | resetwearable = true; | ||
712 | m_log.Warn("[AVFACTORY]: UUID.Zero Wearables, passing fake values."); | ||
713 | resetwearable = true; | ||
714 | break; | ||
715 | |||
716 | } | ||
590 | continue; | 717 | continue; |
718 | } | ||
591 | 719 | ||
592 | // Ignore ruth's assets | 720 | // Ignore ruth's assets except for the body parts! missing body parts fail avatar appearance on V1 |
593 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) | 721 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) |
722 | { | ||
723 | switch ((WearableType)i) | ||
724 | { | ||
725 | case WearableType.Eyes: | ||
726 | case WearableType.Hair: | ||
727 | case WearableType.Shape: | ||
728 | case WearableType.Skin: | ||
729 | //case WearableType.Underpants: | ||
730 | TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance); | ||
731 | |||
732 | m_log.WarnFormat("[AVFACTORY]: {0} Default Wearables, passing existing values.", (WearableType)i); | ||
733 | resetwearable = true; | ||
734 | break; | ||
735 | |||
736 | } | ||
594 | continue; | 737 | continue; |
595 | 738 | } | |
739 | |||
596 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); | 740 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); |
597 | baseItem = invService.GetItem(baseItem); | 741 | baseItem = invService.GetItem(baseItem); |
598 | 742 | ||
599 | if (baseItem != null) | 743 | if (baseItem != null) |
600 | { | 744 | { |
601 | appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID); | 745 | appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID); |
746 | int unmodifiedWearableIndexForClosure = i; | ||
747 | m_scene.AssetService.Get(baseItem.AssetID.ToString(), this, | ||
748 | delegate(string x, object y, AssetBase z) | ||
749 | { | ||
750 | if (z == null) | ||
751 | { | ||
752 | TryAndRepairBrokenWearable( | ||
753 | (WearableType)unmodifiedWearableIndexForClosure, invService, | ||
754 | userID, appearance); | ||
755 | } | ||
756 | }); | ||
602 | } | 757 | } |
603 | else | 758 | else |
604 | { | 759 | { |
@@ -606,17 +761,236 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
606 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", | 761 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", |
607 | appearance.Wearables[i][j].ItemID, (WearableType)i); | 762 | appearance.Wearables[i][j].ItemID, (WearableType)i); |
608 | 763 | ||
609 | appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID); | 764 | TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance); |
765 | resetwearable = true; | ||
766 | |||
610 | } | 767 | } |
611 | } | 768 | } |
612 | } | 769 | } |
770 | |||
771 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
772 | if (appearance.Wearables[(int) WearableType.Eyes] == null) | ||
773 | { | ||
774 | m_log.WarnFormat("[AVFACTORY]: {0} Eyes are Null, passing existing values.", (WearableType.Eyes)); | ||
775 | |||
776 | TryAndRepairBrokenWearable(WearableType.Eyes, invService, userID, appearance); | ||
777 | resetwearable = true; | ||
778 | } | ||
779 | else | ||
780 | { | ||
781 | if (appearance.Wearables[(int) WearableType.Eyes][0].ItemID == UUID.Zero) | ||
782 | { | ||
783 | m_log.WarnFormat("[AVFACTORY]: Eyes are UUID.Zero are broken, {0} {1}", | ||
784 | appearance.Wearables[(int) WearableType.Eyes][0].ItemID, | ||
785 | appearance.Wearables[(int) WearableType.Eyes][0].AssetID); | ||
786 | TryAndRepairBrokenWearable(WearableType.Eyes, invService, userID, appearance); | ||
787 | resetwearable = true; | ||
788 | |||
789 | } | ||
790 | |||
791 | } | ||
792 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
793 | if (appearance.Wearables[(int)WearableType.Shape] == null) | ||
794 | { | ||
795 | m_log.WarnFormat("[AVFACTORY]: {0} shape is Null, passing existing values.", (WearableType.Shape)); | ||
796 | |||
797 | TryAndRepairBrokenWearable(WearableType.Shape, invService, userID, appearance); | ||
798 | resetwearable = true; | ||
799 | } | ||
800 | else | ||
801 | { | ||
802 | if (appearance.Wearables[(int)WearableType.Shape][0].ItemID == UUID.Zero) | ||
803 | { | ||
804 | m_log.WarnFormat("[AVFACTORY]: Shape is UUID.Zero and broken, {0} {1}", | ||
805 | appearance.Wearables[(int)WearableType.Shape][0].ItemID, | ||
806 | appearance.Wearables[(int)WearableType.Shape][0].AssetID); | ||
807 | TryAndRepairBrokenWearable(WearableType.Shape, invService, userID, appearance); | ||
808 | resetwearable = true; | ||
809 | |||
810 | } | ||
811 | |||
812 | } | ||
813 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
814 | if (appearance.Wearables[(int)WearableType.Hair] == null) | ||
815 | { | ||
816 | m_log.WarnFormat("[AVFACTORY]: {0} Hair is Null, passing existing values.", (WearableType.Hair)); | ||
817 | |||
818 | TryAndRepairBrokenWearable(WearableType.Hair, invService, userID, appearance); | ||
819 | resetwearable = true; | ||
820 | } | ||
821 | else | ||
822 | { | ||
823 | if (appearance.Wearables[(int)WearableType.Hair][0].ItemID == UUID.Zero) | ||
824 | { | ||
825 | m_log.WarnFormat("[AVFACTORY]: Hair is UUID.Zero and broken, {0} {1}", | ||
826 | appearance.Wearables[(int)WearableType.Hair][0].ItemID, | ||
827 | appearance.Wearables[(int)WearableType.Hair][0].AssetID); | ||
828 | TryAndRepairBrokenWearable(WearableType.Hair, invService, userID, appearance); | ||
829 | resetwearable = true; | ||
830 | |||
831 | } | ||
832 | |||
833 | } | ||
834 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
835 | if (appearance.Wearables[(int)WearableType.Skin] == null) | ||
836 | { | ||
837 | m_log.WarnFormat("[AVFACTORY]: {0} Skin is Null, passing existing values.", (WearableType.Skin)); | ||
838 | |||
839 | TryAndRepairBrokenWearable(WearableType.Skin, invService, userID, appearance); | ||
840 | resetwearable = true; | ||
841 | } | ||
842 | else | ||
843 | { | ||
844 | if (appearance.Wearables[(int)WearableType.Skin][0].ItemID == UUID.Zero) | ||
845 | { | ||
846 | m_log.WarnFormat("[AVFACTORY]: Skin is UUID.Zero and broken, {0} {1}", | ||
847 | appearance.Wearables[(int)WearableType.Skin][0].ItemID, | ||
848 | appearance.Wearables[(int)WearableType.Skin][0].AssetID); | ||
849 | TryAndRepairBrokenWearable(WearableType.Skin, invService, userID, appearance); | ||
850 | resetwearable = true; | ||
851 | |||
852 | } | ||
853 | |||
854 | } | ||
855 | if (resetwearable) | ||
856 | { | ||
857 | ScenePresence presence = null; | ||
858 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
859 | { | ||
860 | presence.ControllingClient.SendWearables(presence.Appearance.Wearables, | ||
861 | presence.Appearance.Serial++); | ||
862 | } | ||
863 | } | ||
864 | |||
613 | } | 865 | } |
614 | else | 866 | else |
615 | { | 867 | { |
616 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); | 868 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); |
617 | } | 869 | } |
618 | } | 870 | } |
871 | private void TryAndRepairBrokenWearable(WearableType type, IInventoryService invService, UUID userID,AvatarAppearance appearance) | ||
872 | { | ||
873 | UUID defaultwearable = GetDefaultItem(type); | ||
874 | if (defaultwearable != UUID.Zero) | ||
875 | { | ||
876 | UUID newInvItem = UUID.Random(); | ||
877 | InventoryItemBase itembase = new InventoryItemBase(newInvItem, userID) | ||
878 | { | ||
879 | AssetID = | ||
880 | defaultwearable, | ||
881 | AssetType | ||
882 | = | ||
883 | (int) | ||
884 | AssetType | ||
885 | .Bodypart, | ||
886 | CreatorId | ||
887 | = | ||
888 | userID | ||
889 | .ToString | ||
890 | (), | ||
891 | //InvType = (int)InventoryType.Wearable, | ||
892 | |||
893 | Description | ||
894 | = | ||
895 | "Failed Wearable Replacement", | ||
896 | Folder = | ||
897 | invService | ||
898 | .GetFolderForType | ||
899 | (userID, | ||
900 | AssetType | ||
901 | .Bodypart) | ||
902 | .ID, | ||
903 | Flags = (uint) type, | ||
904 | Name = Enum.GetName(typeof (WearableType), type), | ||
905 | BasePermissions = (uint) PermissionMask.Copy, | ||
906 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
907 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
908 | GroupPermissions = (uint) PermissionMask.Copy, | ||
909 | NextPermissions = (uint) PermissionMask.Copy | ||
910 | }; | ||
911 | invService.AddItem(itembase); | ||
912 | UUID LinkInvItem = UUID.Random(); | ||
913 | itembase = new InventoryItemBase(LinkInvItem, userID) | ||
914 | { | ||
915 | AssetID = | ||
916 | newInvItem, | ||
917 | AssetType | ||
918 | = | ||
919 | (int) | ||
920 | AssetType | ||
921 | .Link, | ||
922 | CreatorId | ||
923 | = | ||
924 | userID | ||
925 | .ToString | ||
926 | (), | ||
927 | InvType = (int) InventoryType.Wearable, | ||
928 | |||
929 | Description | ||
930 | = | ||
931 | "Failed Wearable Replacement", | ||
932 | Folder = | ||
933 | invService | ||
934 | .GetFolderForType | ||
935 | (userID, | ||
936 | AssetType | ||
937 | .CurrentOutfitFolder) | ||
938 | .ID, | ||
939 | Flags = (uint) type, | ||
940 | Name = Enum.GetName(typeof (WearableType), type), | ||
941 | BasePermissions = (uint) PermissionMask.Copy, | ||
942 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
943 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
944 | GroupPermissions = (uint) PermissionMask.Copy, | ||
945 | NextPermissions = (uint) PermissionMask.Copy | ||
946 | }; | ||
947 | invService.AddItem(itembase); | ||
948 | appearance.Wearables[(int)type] = new AvatarWearable(newInvItem, GetDefaultItem(type)); | ||
949 | ScenePresence presence = null; | ||
950 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
951 | { | ||
952 | m_scene.SendInventoryUpdate(presence.ControllingClient, | ||
953 | invService.GetFolderForType(userID, | ||
954 | AssetType | ||
955 | .CurrentOutfitFolder), | ||
956 | false, true); | ||
957 | } | ||
958 | } | ||
959 | } | ||
960 | private UUID GetDefaultItem(WearableType wearable) | ||
961 | { | ||
962 | // These are ruth | ||
963 | UUID ret = UUID.Zero; | ||
964 | switch (wearable) | ||
965 | { | ||
966 | case WearableType.Eyes: | ||
967 | ret = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); | ||
968 | break; | ||
969 | case WearableType.Hair: | ||
970 | ret = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66"); | ||
971 | break; | ||
972 | case WearableType.Pants: | ||
973 | ret = new UUID("00000000-38f9-1111-024e-222222111120"); | ||
974 | break; | ||
975 | case WearableType.Shape: | ||
976 | ret = new UUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
977 | break; | ||
978 | case WearableType.Shirt: | ||
979 | ret = new UUID("00000000-38f9-1111-024e-222222111110"); | ||
980 | break; | ||
981 | case WearableType.Skin: | ||
982 | ret = new UUID("77c41e39-38f9-f75a-024e-585989bbabbb"); | ||
983 | break; | ||
984 | case WearableType.Undershirt: | ||
985 | ret = new UUID("16499ebb-3208-ec27-2def-481881728f47"); | ||
986 | break; | ||
987 | case WearableType.Underpants: | ||
988 | ret = new UUID("4ac2e9c7-3671-d229-316a-67717730841d"); | ||
989 | break; | ||
990 | } | ||
619 | 991 | ||
992 | return ret; | ||
993 | } | ||
620 | #endregion | 994 | #endregion |
621 | 995 | ||
622 | #region Client Event Handlers | 996 | #region Client Event Handlers |
@@ -626,12 +1000,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
626 | /// <param name="client"></param> | 1000 | /// <param name="client"></param> |
627 | private void Client_OnRequestWearables(IClientAPI client) | 1001 | private void Client_OnRequestWearables(IClientAPI client) |
628 | { | 1002 | { |
629 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); | 1003 | Util.FireAndForget(delegate(object x) |
630 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 1004 | { |
631 | if (sp != null) | 1005 | Thread.Sleep(4000); |
632 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | 1006 | |
633 | else | 1007 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); |
634 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | 1008 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
1009 | if (sp != null) | ||
1010 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | ||
1011 | else | ||
1012 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | ||
1013 | }); | ||
635 | } | 1014 | } |
636 | 1015 | ||
637 | /// <summary> | 1016 | /// <summary> |
@@ -640,12 +1019,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
640 | /// <param name="client"></param> | 1019 | /// <param name="client"></param> |
641 | /// <param name="texture"></param> | 1020 | /// <param name="texture"></param> |
642 | /// <param name="visualParam"></param> | 1021 | /// <param name="visualParam"></param> |
643 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, List<CachedTextureRequestArg> hashes) | 1022 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) |
644 | { | 1023 | { |
645 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); | 1024 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); |
646 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 1025 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
647 | if (sp != null) | 1026 | if (sp != null) |
648 | DoSetAppearance(sp, textureEntry, visualParams, hashes); | 1027 | SetAppearance(sp, textureEntry, visualParams,avSize, cacheItems); |
649 | else | 1028 | else |
650 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); | 1029 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); |
651 | } | 1030 | } |
@@ -702,7 +1081,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
702 | /// <param name="cachedTextureRequest"></param> | 1081 | /// <param name="cachedTextureRequest"></param> |
703 | private void Client_OnCachedTextureRequest(IClientAPI client, int serial, List<CachedTextureRequestArg> cachedTextureRequest) | 1082 | private void Client_OnCachedTextureRequest(IClientAPI client, int serial, List<CachedTextureRequestArg> cachedTextureRequest) |
704 | { | 1083 | { |
705 | // m_log.DebugFormat("[AVFACTORY]: Client_OnCachedTextureRequest called for {0} ({1})", client.Name, client.AgentId); | 1084 | // m_log.WarnFormat("[AVFACTORY]: Client_OnCachedTextureRequest called for {0} ({1})", client.Name, client.AgentId); |
706 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 1085 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
707 | 1086 | ||
708 | List<CachedTextureResponseArg> cachedTextureResponse = new List<CachedTextureResponseArg>(); | 1087 | List<CachedTextureResponseArg> cachedTextureResponse = new List<CachedTextureResponseArg>(); |
@@ -713,20 +1092,23 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
713 | 1092 | ||
714 | if (m_reusetextures) | 1093 | if (m_reusetextures) |
715 | { | 1094 | { |
716 | if (sp.Appearance.GetTextureHash(index) == request.WearableHashID) | 1095 | // this is the most insanely dumb way to do this... however it seems to |
717 | { | 1096 | // actually work. if the appearance has been reset because wearables have |
718 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[index]; | 1097 | // changed then the texture entries are zero'd out until the bakes are |
719 | if (face != null) | 1098 | // uploaded. on login, if the textures exist in the cache (eg if you logged |
720 | texture = face.TextureID; | 1099 | // into the simulator recently, then the appearance will pull those and send |
721 | } | 1100 | // them back in the packet and you won't have to rebake. if the textures aren't |
722 | else | 1101 | // in the cache then the intial makeroot() call in scenepresence will zero |
723 | { | 1102 | // them out. |
724 | // We know that that hash is wrong, null it out | 1103 | // |
725 | // and wait for the setappearance call | 1104 | // a better solution (though how much better is an open question) is to |
726 | sp.Appearance.SetTextureHash(index,UUID.Zero); | 1105 | // store the hashes in the appearance and compare them. Thats's coming. |
727 | } | 1106 | |
728 | 1107 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[index]; | |
729 | // m_log.WarnFormat("[AVFACTORY]: use texture {0} for index {1}; hash={2}",texture,index,request.WearableHashID); | 1108 | if (face != null) |
1109 | texture = face.TextureID; | ||
1110 | |||
1111 | // m_log.WarnFormat("[AVFACTORY]: reuse texture {0} for index {1}",texture,index); | ||
730 | } | 1112 | } |
731 | 1113 | ||
732 | CachedTextureResponseArg response = new CachedTextureResponseArg(); | 1114 | CachedTextureResponseArg response = new CachedTextureResponseArg(); |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 1830d41..f090e15 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | |||
@@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
61 | for (byte i = 0; i < visualParams.Length; i++) | 61 | for (byte i = 0; i < visualParams.Length; i++) |
62 | visualParams[i] = i; | 62 | visualParams[i] = i; |
63 | 63 | ||
64 | afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams); | 64 | afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams, new WearableCacheItem[0]); |
65 | 65 | ||
66 | // TODO: Check baked texture | 66 | // TODO: Check baked texture |
67 | Assert.AreEqual(visualParams, sp.Appearance.VisualParams); | 67 | Assert.AreEqual(visualParams, sp.Appearance.VisualParams); |
@@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
102 | Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); | 102 | Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex); |
103 | eyesFace.TextureID = eyesTextureId; | 103 | eyesFace.TextureID = eyesTextureId; |
104 | 104 | ||
105 | afm.SetAppearance(sp, bakedTextureEntry, visualParams); | 105 | afm.SetAppearance(sp, bakedTextureEntry, visualParams, new WearableCacheItem[0]); |
106 | afm.SaveBakedTextures(userId); | 106 | afm.SaveBakedTextures(userId); |
107 | // Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); | 107 | // Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId); |
108 | 108 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 27ace68..5cbfec6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -51,7 +51,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
51 | private int m_saydistance = 20; | 51 | private int m_saydistance = 20; |
52 | private int m_shoutdistance = 100; | 52 | private int m_shoutdistance = 100; |
53 | private int m_whisperdistance = 10; | 53 | private int m_whisperdistance = 10; |
54 | 54 | private List<Scene> m_scenes = new List<Scene>(); | |
55 | private List<string> FreezeCache = new List<string>(); | ||
56 | private string m_adminPrefix = ""; | ||
55 | internal object m_syncy = new object(); | 57 | internal object m_syncy = new object(); |
56 | 58 | ||
57 | internal IConfig m_config; | 59 | internal IConfig m_config; |
@@ -78,16 +80,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
78 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); | 80 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); |
79 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); | 81 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); |
80 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); | 82 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); |
83 | m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", ""); | ||
81 | } | 84 | } |
82 | 85 | ||
83 | public virtual void AddRegion(Scene scene) | 86 | public virtual void AddRegion(Scene scene) |
84 | { | 87 | { |
85 | if (!m_enabled) | 88 | if (!m_enabled) return; |
86 | return; | ||
87 | 89 | ||
88 | scene.EventManager.OnNewClient += OnNewClient; | 90 | lock (m_syncy) |
89 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 91 | { |
90 | scene.EventManager.OnChatBroadcast += OnChatBroadcast; | 92 | if (!m_scenes.Contains(scene)) |
93 | { | ||
94 | m_scenes.Add(scene); | ||
95 | scene.EventManager.OnNewClient += OnNewClient; | ||
96 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | ||
97 | scene.EventManager.OnChatBroadcast += OnChatBroadcast; | ||
98 | } | ||
99 | } | ||
91 | 100 | ||
92 | m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, | 101 | m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, |
93 | m_whisperdistance, m_saydistance, m_shoutdistance); | 102 | m_whisperdistance, m_saydistance, m_shoutdistance); |
@@ -107,12 +116,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
107 | 116 | ||
108 | public virtual void RemoveRegion(Scene scene) | 117 | public virtual void RemoveRegion(Scene scene) |
109 | { | 118 | { |
110 | if (!m_enabled) | 119 | if (!m_enabled) return; |
111 | return; | ||
112 | 120 | ||
113 | scene.EventManager.OnNewClient -= OnNewClient; | 121 | lock (m_syncy) |
114 | scene.EventManager.OnChatFromWorld -= OnChatFromWorld; | 122 | { |
115 | scene.EventManager.OnChatBroadcast -= OnChatBroadcast; | 123 | if (m_scenes.Contains(scene)) |
124 | { | ||
125 | scene.EventManager.OnNewClient -= OnNewClient; | ||
126 | scene.EventManager.OnChatFromWorld -= OnChatFromWorld; | ||
127 | scene.EventManager.OnChatBroadcast -= OnChatBroadcast; | ||
128 | m_scenes.Remove(scene); | ||
129 | } | ||
130 | } | ||
116 | } | 131 | } |
117 | 132 | ||
118 | public virtual void Close() | 133 | public virtual void Close() |
@@ -169,7 +184,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
169 | return; | 184 | return; |
170 | } | 185 | } |
171 | 186 | ||
172 | DeliverChatToAvatars(ChatSourceType.Agent, c); | 187 | if (FreezeCache.Contains(c.Sender.AgentId.ToString())) |
188 | { | ||
189 | if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping) | ||
190 | c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false); | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | DeliverChatToAvatars(ChatSourceType.Agent, c); | ||
195 | } | ||
173 | } | 196 | } |
174 | 197 | ||
175 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) | 198 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) |
@@ -183,11 +206,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
183 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) | 206 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) |
184 | { | 207 | { |
185 | string fromName = c.From; | 208 | string fromName = c.From; |
209 | string fromNamePrefix = ""; | ||
186 | UUID fromID = UUID.Zero; | 210 | UUID fromID = UUID.Zero; |
187 | UUID ownerID = UUID.Zero; | 211 | UUID ownerID = UUID.Zero; |
188 | UUID targetID = c.TargetUUID; | ||
189 | string message = c.Message; | 212 | string message = c.Message; |
190 | Scene scene = (Scene)c.Scene; | 213 | IScene scene = c.Scene; |
214 | UUID destination = c.Destination; | ||
191 | Vector3 fromPos = c.Position; | 215 | Vector3 fromPos = c.Position; |
192 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, | 216 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, |
193 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 217 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
@@ -197,10 +221,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
197 | switch (sourceType) | 221 | switch (sourceType) |
198 | { | 222 | { |
199 | case ChatSourceType.Agent: | 223 | case ChatSourceType.Agent: |
200 | ScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId); | 224 | if (!(scene is Scene)) |
225 | { | ||
226 | m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}", | ||
227 | scene.RegionInfo.RegionName, c.Sender.AgentId); | ||
228 | return; | ||
229 | } | ||
230 | ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId); | ||
201 | fromPos = avatar.AbsolutePosition; | 231 | fromPos = avatar.AbsolutePosition; |
202 | fromName = avatar.Name; | 232 | fromName = avatar.Name; |
203 | fromID = c.Sender.AgentId; | 233 | fromID = c.Sender.AgentId; |
234 | if (avatar.GodLevel >= 200) | ||
235 | { | ||
236 | fromNamePrefix = m_adminPrefix; | ||
237 | } | ||
238 | destination = UUID.Zero; // Avatars cant "SayTo" | ||
204 | ownerID = c.Sender.AgentId; | 239 | ownerID = c.Sender.AgentId; |
205 | 240 | ||
206 | break; | 241 | break; |
@@ -219,38 +254,48 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
219 | message = message.Substring(0, 1000); | 254 | message = message.Substring(0, 1000); |
220 | 255 | ||
221 | // m_log.DebugFormat( | 256 | // m_log.DebugFormat( |
222 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", | 257 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", |
223 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); | 258 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); |
224 | 259 | ||
225 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 260 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
226 | 261 | ||
227 | if (targetID == UUID.Zero) | 262 | foreach (Scene s in m_scenes) |
228 | { | 263 | { |
229 | // This should use ForEachClient, but clients don't have a position. | 264 | // This should use ForEachClient, but clients don't have a position. |
230 | // If camera is moved into client, then camera position can be used | 265 | // If camera is moved into client, then camera position can be used |
231 | scene.ForEachScenePresence( | 266 | // MT: No, it can't, as chat is heard from the avatar position, not |
267 | // the camera position. | ||
268 | s.ForEachScenePresence( | ||
232 | delegate(ScenePresence presence) | 269 | delegate(ScenePresence presence) |
233 | { | 270 | { |
234 | if (TrySendChatMessage( | 271 | if (destination != UUID.Zero && presence.UUID != destination) |
235 | presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) | 272 | return; |
236 | receiverIDs.Add(presence.UUID); | 273 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
274 | if (Presencecheck != null) | ||
275 | { | ||
276 | // This will pass all chat from objects. Not | ||
277 | // perfect, but it will do. For now. Better | ||
278 | // than the prior behavior of muting all | ||
279 | // objects on a parcel with access restrictions | ||
280 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | ||
281 | { | ||
282 | if (destination != UUID.Zero) | ||
283 | { | ||
284 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, true)) | ||
285 | receiverIDs.Add(presence.UUID); | ||
286 | } | ||
287 | else | ||
288 | { | ||
289 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, false)) | ||
290 | receiverIDs.Add(presence.UUID); | ||
291 | } | ||
292 | } | ||
293 | } | ||
237 | } | 294 | } |
238 | ); | 295 | ); |
239 | } | 296 | } |
240 | else | 297 | |
241 | { | 298 | (scene as Scene).EventManager.TriggerOnChatToClients( |
242 | // This is a send to a specific client eg from llRegionSayTo | ||
243 | // no need to check distance etc, jand send is as say | ||
244 | ScenePresence presence = scene.GetScenePresence(targetID); | ||
245 | if (presence != null && !presence.IsChildAgent) | ||
246 | { | ||
247 | if (TrySendChatMessage( | ||
248 | presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true)) | ||
249 | receiverIDs.Add(presence.UUID); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | scene.EventManager.TriggerOnChatToClients( | ||
254 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | 299 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); |
255 | } | 300 | } |
256 | 301 | ||
@@ -289,28 +334,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
289 | } | 334 | } |
290 | 335 | ||
291 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 336 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
292 | |||
293 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 337 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
294 | 338 | ||
295 | ((Scene)c.Scene).ForEachRootClient( | 339 | if (c.Scene != null) |
296 | delegate(IClientAPI client) | 340 | { |
297 | { | 341 | ((Scene)c.Scene).ForEachRootClient |
298 | // don't forward SayOwner chat from objects to | 342 | ( |
299 | // non-owner agents | 343 | delegate(IClientAPI client) |
300 | if ((c.Type == ChatTypeEnum.Owner) && | 344 | { |
301 | (null != c.SenderObject) && | 345 | // don't forward SayOwner chat from objects to |
302 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 346 | // non-owner agents |
303 | return; | 347 | if ((c.Type == ChatTypeEnum.Owner) && |
304 | 348 | (null != c.SenderObject) && | |
305 | client.SendChatMessage( | 349 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) |
306 | c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID, | 350 | return; |
307 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 351 | |
308 | 352 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID, | |
309 | receiverIDs.Add(client.AgentId); | 353 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); |
310 | }); | 354 | receiverIDs.Add(client.AgentId); |
311 | 355 | } | |
312 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | 356 | ); |
313 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | 357 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( |
358 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | ||
359 | } | ||
314 | } | 360 | } |
315 | 361 | ||
316 | /// <summary> | 362 | /// <summary> |
@@ -363,6 +409,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
363 | return true; | 409 | return true; |
364 | } | 410 | } |
365 | 411 | ||
412 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
413 | public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
414 | { | ||
415 | System.Threading.Timer Timer; | ||
416 | if (flags == 0) | ||
417 | { | ||
418 | FreezeCache.Add(target.ToString()); | ||
419 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
420 | Timer = new System.Threading.Timer(timeCB, target, 30000, 0); | ||
421 | Timers.Add(target, Timer); | ||
422 | } | ||
423 | else | ||
424 | { | ||
425 | FreezeCache.Remove(target.ToString()); | ||
426 | Timers.TryGetValue(target, out Timer); | ||
427 | Timers.Remove(target); | ||
428 | Timer.Dispose(); | ||
429 | } | ||
430 | } | ||
431 | |||
432 | private void OnEndParcelFrozen(object avatar) | ||
433 | { | ||
434 | UUID target = (UUID)avatar; | ||
435 | FreezeCache.Remove(target.ToString()); | ||
436 | System.Threading.Timer Timer; | ||
437 | Timers.TryGetValue(target, out Timer); | ||
438 | Timers.Remove(target); | ||
439 | Timer.Dispose(); | ||
440 | } | ||
366 | #region SimulatorFeaturesRequest | 441 | #region SimulatorFeaturesRequest |
367 | 442 | ||
368 | static OSDInteger m_SayRange, m_WhisperRange, m_ShoutRange; | 443 | static OSDInteger m_SayRange, m_WhisperRange, m_ShoutRange; |
@@ -391,4 +466,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
391 | 466 | ||
392 | #endregion | 467 | #endregion |
393 | } | 468 | } |
394 | } \ No newline at end of file | 469 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 343cdb5..c52d586 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs | |||
@@ -182,6 +182,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
182 | try | 182 | try |
183 | { | 183 | { |
184 | ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 184 | ILandObject obj = avatar.Scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); |
185 | if (obj == null) | ||
186 | return; | ||
185 | if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0 | 187 | if ((obj.LandData.Flags & (uint)ParcelFlags.AllowDamage) != 0 |
186 | || avatar.Scene.RegionInfo.RegionSettings.AllowDamage) | 188 | || avatar.Scene.RegionInfo.RegionSettings.AllowDamage) |
187 | { | 189 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index d26907b..0e7ab7e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | |||
@@ -260,4 +260,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
260 | return result; | 260 | return result; |
261 | } | 261 | } |
262 | } | 262 | } |
263 | } \ No newline at end of file | 263 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 3b6d970..adb838c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | |||
@@ -49,6 +49,8 @@ using Caps = OpenSim.Framework.Capabilities.Caps; | |||
49 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | 49 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; |
50 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | 50 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; |
51 | 51 | ||
52 | using Mono.Addins; | ||
53 | |||
52 | namespace OpenSim.Region.CoreModules.Avatar.Gods | 54 | namespace OpenSim.Region.CoreModules.Avatar.Gods |
53 | { | 55 | { |
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")] | 56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")] |
@@ -62,6 +64,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
62 | 64 | ||
63 | protected Scene m_scene; | 65 | protected Scene m_scene; |
64 | protected IDialogModule m_dialogModule; | 66 | protected IDialogModule m_dialogModule; |
67 | |||
65 | protected IDialogModule DialogModule | 68 | protected IDialogModule DialogModule |
66 | { | 69 | { |
67 | get | 70 | get |
@@ -146,6 +149,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
146 | UUID godSessionID = userData["GodSessionID"].AsUUID(); | 149 | UUID godSessionID = userData["GodSessionID"].AsUUID(); |
147 | uint kickFlags = userData["KickFlags"].AsUInteger(); | 150 | uint kickFlags = userData["KickFlags"].AsUInteger(); |
148 | string reason = userData["Reason"].AsString(); | 151 | string reason = userData["Reason"].AsString(); |
152 | |||
149 | ScenePresence god = m_scene.GetScenePresence(godID); | 153 | ScenePresence god = m_scene.GetScenePresence(godID); |
150 | if (god == null || god.ControllingClient.SessionId != godSessionID) | 154 | if (god == null || god.ControllingClient.SessionId != godSessionID) |
151 | return String.Empty; | 155 | return String.Empty; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs deleted file mode 100644 index b735c61..0000000 --- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs +++ /dev/null | |||
@@ -1,260 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using log4net; | ||
32 | using Nini.Config; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | |||
38 | using Mono.Addins; | ||
39 | |||
40 | namespace OpenSim.Region.CoreModules.Avatar.Groups | ||
41 | { | ||
42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")] | ||
43 | public class GroupsModule : ISharedRegionModule | ||
44 | { | ||
45 | private static readonly ILog m_log = | ||
46 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | private Dictionary<UUID, GroupMembershipData> m_GroupMap = | ||
49 | new Dictionary<UUID, GroupMembershipData>(); | ||
50 | |||
51 | private Dictionary<UUID, IClientAPI> m_ClientMap = | ||
52 | new Dictionary<UUID, IClientAPI>(); | ||
53 | |||
54 | private UUID opensimulatorGroupID = | ||
55 | new UUID("00000000-68f9-1111-024e-222222111123"); | ||
56 | |||
57 | private List<Scene> m_SceneList = new List<Scene>(); | ||
58 | |||
59 | private static GroupMembershipData osGroup = | ||
60 | new GroupMembershipData(); | ||
61 | |||
62 | private bool m_Enabled = false; | ||
63 | |||
64 | #region ISharedRegionModule Members | ||
65 | |||
66 | public void Initialise(IConfigSource config) | ||
67 | { | ||
68 | IConfig groupsConfig = config.Configs["Groups"]; | ||
69 | |||
70 | if (groupsConfig == null) | ||
71 | { | ||
72 | m_log.Info("[GROUPS]: No configuration found. Using defaults"); | ||
73 | } | ||
74 | else | ||
75 | { | ||
76 | m_Enabled = groupsConfig.GetBoolean("Enabled", false); | ||
77 | if (!m_Enabled) | ||
78 | { | ||
79 | m_log.Info("[GROUPS]: Groups disabled in configuration"); | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | if (groupsConfig.GetString("Module", "Default") != "Default") | ||
84 | { | ||
85 | m_Enabled = false; | ||
86 | return; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | } | ||
91 | |||
92 | public void AddRegion(Scene scene) | ||
93 | { | ||
94 | if (!m_Enabled) | ||
95 | return; | ||
96 | |||
97 | lock (m_SceneList) | ||
98 | { | ||
99 | if (!m_SceneList.Contains(scene)) | ||
100 | { | ||
101 | if (m_SceneList.Count == 0) | ||
102 | { | ||
103 | osGroup.GroupID = opensimulatorGroupID; | ||
104 | osGroup.GroupName = "OpenSimulator Testing"; | ||
105 | osGroup.GroupPowers = | ||
106 | (uint)(GroupPowers.AllowLandmark | | ||
107 | GroupPowers.AllowSetHome); | ||
108 | m_GroupMap[opensimulatorGroupID] = osGroup; | ||
109 | } | ||
110 | m_SceneList.Add(scene); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | scene.EventManager.OnNewClient += OnNewClient; | ||
115 | scene.EventManager.OnClientClosed += OnClientClosed; | ||
116 | // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | ||
117 | } | ||
118 | |||
119 | public void RemoveRegion(Scene scene) | ||
120 | { | ||
121 | if (!m_Enabled) | ||
122 | return; | ||
123 | |||
124 | lock (m_SceneList) | ||
125 | { | ||
126 | if (m_SceneList.Contains(scene)) | ||
127 | m_SceneList.Remove(scene); | ||
128 | } | ||
129 | |||
130 | scene.EventManager.OnNewClient -= OnNewClient; | ||
131 | scene.EventManager.OnClientClosed -= OnClientClosed; | ||
132 | } | ||
133 | |||
134 | public void RegionLoaded(Scene scene) | ||
135 | { | ||
136 | } | ||
137 | |||
138 | public void PostInitialise() | ||
139 | { | ||
140 | } | ||
141 | |||
142 | public void Close() | ||
143 | { | ||
144 | if (!m_Enabled) | ||
145 | return; | ||
146 | |||
147 | // m_log.Debug("[GROUPS]: Shutting down group module."); | ||
148 | |||
149 | lock (m_ClientMap) | ||
150 | { | ||
151 | m_ClientMap.Clear(); | ||
152 | } | ||
153 | |||
154 | lock (m_GroupMap) | ||
155 | { | ||
156 | m_GroupMap.Clear(); | ||
157 | } | ||
158 | } | ||
159 | |||
160 | public string Name | ||
161 | { | ||
162 | get { return "GroupsModule"; } | ||
163 | } | ||
164 | |||
165 | public Type ReplaceableInterface | ||
166 | { | ||
167 | get { return null; } | ||
168 | } | ||
169 | |||
170 | #endregion | ||
171 | |||
172 | private void OnNewClient(IClientAPI client) | ||
173 | { | ||
174 | // Subscribe to instant messages | ||
175 | // client.OnInstantMessage += OnInstantMessage; | ||
176 | client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; | ||
177 | client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest; | ||
178 | lock (m_ClientMap) | ||
179 | { | ||
180 | if (!m_ClientMap.ContainsKey(client.AgentId)) | ||
181 | { | ||
182 | m_ClientMap.Add(client.AgentId, client); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | GroupMembershipData[] updateGroups = new GroupMembershipData[1]; | ||
187 | updateGroups[0] = osGroup; | ||
188 | |||
189 | client.SendGroupMembership(updateGroups); | ||
190 | } | ||
191 | |||
192 | private void OnAgentDataUpdateRequest(IClientAPI remoteClient, | ||
193 | UUID AgentID, UUID SessionID) | ||
194 | { | ||
195 | UUID ActiveGroupID; | ||
196 | string ActiveGroupName; | ||
197 | ulong ActiveGroupPowers; | ||
198 | |||
199 | string firstname = remoteClient.FirstName; | ||
200 | string lastname = remoteClient.LastName; | ||
201 | |||
202 | string ActiveGroupTitle = "I IZ N0T"; | ||
203 | |||
204 | ActiveGroupID = osGroup.GroupID; | ||
205 | ActiveGroupName = osGroup.GroupName; | ||
206 | ActiveGroupPowers = osGroup.GroupPowers; | ||
207 | |||
208 | remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, | ||
209 | lastname, ActiveGroupPowers, ActiveGroupName, | ||
210 | ActiveGroupTitle); | ||
211 | } | ||
212 | |||
213 | // private void OnInstantMessage(IClientAPI client, GridInstantMessage im) | ||
214 | // { | ||
215 | // } | ||
216 | |||
217 | // private void OnGridInstantMessage(GridInstantMessage msg) | ||
218 | // { | ||
219 | // // Trigger the above event handler | ||
220 | // OnInstantMessage(null, msg); | ||
221 | // } | ||
222 | |||
223 | private void HandleUUIDGroupNameRequest(UUID id,IClientAPI remote_client) | ||
224 | { | ||
225 | string groupnamereply = "Unknown"; | ||
226 | UUID groupUUID = UUID.Zero; | ||
227 | |||
228 | lock (m_GroupMap) | ||
229 | { | ||
230 | if (m_GroupMap.ContainsKey(id)) | ||
231 | { | ||
232 | GroupMembershipData grp = m_GroupMap[id]; | ||
233 | groupnamereply = grp.GroupName; | ||
234 | groupUUID = grp.GroupID; | ||
235 | } | ||
236 | } | ||
237 | remote_client.SendGroupNameReply(groupUUID, groupnamereply); | ||
238 | } | ||
239 | |||
240 | private void OnClientClosed(UUID agentID, Scene scene) | ||
241 | { | ||
242 | lock (m_ClientMap) | ||
243 | { | ||
244 | if (m_ClientMap.ContainsKey(agentID)) | ||
245 | { | ||
246 | // IClientAPI cli = m_ClientMap[agentID]; | ||
247 | // if (cli != null) | ||
248 | // { | ||
249 | // //m_log.Info("[GROUPS]: Removing all reference to groups for " + cli.Name); | ||
250 | // } | ||
251 | // else | ||
252 | // { | ||
253 | // //m_log.Info("[GROUPS]: Removing all reference to groups for " + agentID.ToString()); | ||
254 | // } | ||
255 | m_ClientMap.Remove(agentID); | ||
256 | } | ||
257 | } | ||
258 | } | ||
259 | } | ||
260 | } | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index c33a296..55e30a0 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Timers; | ||
30 | using log4net; | 31 | using log4net; |
31 | using Mono.Addins; | 32 | using Mono.Addins; |
32 | using Nini.Config; | 33 | using Nini.Config; |
@@ -44,6 +45,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
44 | private static readonly ILog m_log = LogManager.GetLogger( | 45 | private static readonly ILog m_log = LogManager.GetLogger( |
45 | MethodBase.GetCurrentMethod().DeclaringType); | 46 | MethodBase.GetCurrentMethod().DeclaringType); |
46 | 47 | ||
48 | private Timer m_logTimer = new Timer(10000); | ||
49 | private List<GridInstantMessage> m_logData = new List<GridInstantMessage>(); | ||
50 | private string m_restUrl; | ||
51 | |||
47 | /// <value> | 52 | /// <value> |
48 | /// Is this module enabled? | 53 | /// Is this module enabled? |
49 | /// </value> | 54 | /// </value> |
@@ -63,9 +68,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
63 | "InstantMessageModule", "InstantMessageModule") != | 68 | "InstantMessageModule", "InstantMessageModule") != |
64 | "InstantMessageModule") | 69 | "InstantMessageModule") |
65 | return; | 70 | return; |
71 | m_restUrl = config.Configs["Messaging"].GetString("LogURL", String.Empty); | ||
66 | } | 72 | } |
67 | 73 | ||
68 | m_enabled = true; | 74 | m_enabled = true; |
75 | m_logTimer.AutoReset = false; | ||
76 | m_logTimer.Elapsed += LogTimerElapsed; | ||
69 | } | 77 | } |
70 | 78 | ||
71 | public void AddRegion(Scene scene) | 79 | public void AddRegion(Scene scene) |
@@ -150,6 +158,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
150 | { | 158 | { |
151 | byte dialog = im.dialog; | 159 | byte dialog = im.dialog; |
152 | 160 | ||
161 | if (client != null && dialog == (byte)InstantMessageDialog.MessageFromAgent) | ||
162 | LogInstantMesssage(im); | ||
163 | |||
153 | if (dialog != (byte)InstantMessageDialog.MessageFromAgent | 164 | if (dialog != (byte)InstantMessageDialog.MessageFromAgent |
154 | && dialog != (byte)InstantMessageDialog.StartTyping | 165 | && dialog != (byte)InstantMessageDialog.StartTyping |
155 | && dialog != (byte)InstantMessageDialog.StopTyping | 166 | && dialog != (byte)InstantMessageDialog.StopTyping |
@@ -159,6 +170,32 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
159 | return; | 170 | return; |
160 | } | 171 | } |
161 | 172 | ||
173 | //DateTime dt = DateTime.UtcNow; | ||
174 | |||
175 | // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
176 | //dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
177 | |||
178 | //try | ||
179 | //{ | ||
180 | // // Convert that to the PST timezone | ||
181 | // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
182 | // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
183 | //} | ||
184 | //catch | ||
185 | //{ | ||
186 | // //m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp."); | ||
187 | //} | ||
188 | |||
189 | //// And make it look local again to fool the unix time util | ||
190 | //dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
191 | |||
192 | // If client is null, this message comes from storage and IS offline | ||
193 | if (client != null) | ||
194 | im.offline = 0; | ||
195 | |||
196 | if (im.offline == 0) | ||
197 | im.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
198 | |||
162 | if (m_TransferModule != null) | 199 | if (m_TransferModule != null) |
163 | { | 200 | { |
164 | if (client != null) | 201 | if (client != null) |
@@ -202,5 +239,35 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
202 | // | 239 | // |
203 | OnInstantMessage(null, msg); | 240 | OnInstantMessage(null, msg); |
204 | } | 241 | } |
242 | |||
243 | private void LogInstantMesssage(GridInstantMessage im) | ||
244 | { | ||
245 | if (m_logData.Count < 20) | ||
246 | { | ||
247 | // Restart the log write timer | ||
248 | m_logTimer.Stop(); | ||
249 | } | ||
250 | if (!m_logTimer.Enabled) | ||
251 | m_logTimer.Start(); | ||
252 | |||
253 | lock (m_logData) | ||
254 | { | ||
255 | m_logData.Add(im); | ||
256 | } | ||
257 | } | ||
258 | |||
259 | private void LogTimerElapsed(object source, ElapsedEventArgs e) | ||
260 | { | ||
261 | lock (m_logData) | ||
262 | { | ||
263 | if (m_restUrl != String.Empty && m_logData.Count > 0) | ||
264 | { | ||
265 | bool success = SynchronousRestObjectRequester.MakeRequest<List<GridInstantMessage>, bool>("POST", m_restUrl + "/LogMessages/", m_logData); | ||
266 | if (!success) | ||
267 | m_log.ErrorFormat("[INSTANT MESSAGE]: Failed to save log data"); | ||
268 | } | ||
269 | m_logData.Clear(); | ||
270 | } | ||
271 | } | ||
205 | } | 272 | } |
206 | } | 273 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 40a400f..b321adb 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -50,6 +50,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 51 | ||
52 | private bool m_Enabled = false; | 52 | private bool m_Enabled = false; |
53 | protected string m_MessageKey = String.Empty; | ||
53 | protected List<Scene> m_Scenes = new List<Scene>(); | 54 | protected List<Scene> m_Scenes = new List<Scene>(); |
54 | protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); | 55 | protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); |
55 | 56 | ||
@@ -69,14 +70,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
69 | public virtual void Initialise(IConfigSource config) | 70 | public virtual void Initialise(IConfigSource config) |
70 | { | 71 | { |
71 | IConfig cnf = config.Configs["Messaging"]; | 72 | IConfig cnf = config.Configs["Messaging"]; |
72 | if (cnf != null && cnf.GetString( | 73 | if (cnf != null) |
73 | "MessageTransferModule", "MessageTransferModule") != | ||
74 | "MessageTransferModule") | ||
75 | { | 74 | { |
76 | m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration"); | 75 | if (cnf.GetString("MessageTransferModule", |
77 | return; | 76 | "MessageTransferModule") != "MessageTransferModule") |
78 | } | 77 | { |
78 | return; | ||
79 | } | ||
79 | 80 | ||
81 | m_MessageKey = cnf.GetString("MessageKey", String.Empty); | ||
82 | } | ||
83 | m_log.Debug("[MESSAGE TRANSFER]: Module enabled"); | ||
80 | m_Enabled = true; | 84 | m_Enabled = true; |
81 | } | 85 | } |
82 | 86 | ||
@@ -135,6 +139,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
135 | { | 139 | { |
136 | UUID toAgentID = new UUID(im.toAgentID); | 140 | UUID toAgentID = new UUID(im.toAgentID); |
137 | 141 | ||
142 | if (toAgentID == UUID.Zero) | ||
143 | return; | ||
144 | |||
138 | // Try root avatar only first | 145 | // Try root avatar only first |
139 | foreach (Scene scene in m_Scenes) | 146 | foreach (Scene scene in m_Scenes) |
140 | { | 147 | { |
@@ -249,6 +256,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
249 | && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") | 256 | && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") |
250 | && requestData.ContainsKey("binary_bucket")) | 257 | && requestData.ContainsKey("binary_bucket")) |
251 | { | 258 | { |
259 | if (m_MessageKey != String.Empty) | ||
260 | { | ||
261 | XmlRpcResponse error_resp = new XmlRpcResponse(); | ||
262 | Hashtable error_respdata = new Hashtable(); | ||
263 | error_respdata["success"] = "FALSE"; | ||
264 | error_resp.Value = error_respdata; | ||
265 | |||
266 | if (!requestData.Contains("message_key")) | ||
267 | return error_resp; | ||
268 | if (m_MessageKey != (string)requestData["message_key"]) | ||
269 | return error_resp; | ||
270 | } | ||
271 | |||
252 | // Do the easy way of validating the UUIDs | 272 | // Do the easy way of validating the UUIDs |
253 | UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); | 273 | UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); |
254 | UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); | 274 | UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); |
@@ -425,24 +445,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
425 | return resp; | 445 | return resp; |
426 | } | 446 | } |
427 | 447 | ||
428 | /// <summary> | 448 | private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); |
429 | /// delegate for sending a grid instant message asynchronously | ||
430 | /// </summary> | ||
431 | public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); | ||
432 | 449 | ||
433 | protected virtual void GridInstantMessageCompleted(IAsyncResult iar) | 450 | private class GIM { |
434 | { | 451 | public GridInstantMessage im; |
435 | GridInstantMessageDelegate icon = | 452 | public MessageResultNotification result; |
436 | (GridInstantMessageDelegate)iar.AsyncState; | 453 | }; |
437 | icon.EndInvoke(iar); | ||
438 | } | ||
439 | 454 | ||
455 | private Queue<GIM> pendingInstantMessages = new Queue<GIM>(); | ||
456 | private int numInstantMessageThreads = 0; | ||
440 | 457 | ||
441 | protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) | 458 | private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) |
442 | { | 459 | { |
443 | GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; | 460 | lock (pendingInstantMessages) { |
461 | if (numInstantMessageThreads >= 4) { | ||
462 | GIM gim = new GIM(); | ||
463 | gim.im = im; | ||
464 | gim.result = result; | ||
465 | pendingInstantMessages.Enqueue(gim); | ||
466 | } else { | ||
467 | ++ numInstantMessageThreads; | ||
468 | //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads); | ||
469 | GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain; | ||
470 | d.BeginInvoke(im, result, GridInstantMessageCompleted, d); | ||
471 | } | ||
472 | } | ||
473 | } | ||
444 | 474 | ||
445 | d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); | 475 | private void GridInstantMessageCompleted(IAsyncResult iar) |
476 | { | ||
477 | GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState; | ||
478 | d.EndInvoke(iar); | ||
446 | } | 479 | } |
447 | 480 | ||
448 | /// <summary> | 481 | /// <summary> |
@@ -457,8 +490,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
457 | /// Pass in 0 the first time this method is called. It will be called recursively with the last | 490 | /// Pass in 0 the first time this method is called. It will be called recursively with the last |
458 | /// regionhandle tried | 491 | /// regionhandle tried |
459 | /// </param> | 492 | /// </param> |
460 | protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) | 493 | private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result) |
461 | { | 494 | { |
495 | GIM gim; | ||
496 | do { | ||
497 | try { | ||
498 | SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero); | ||
499 | } catch (Exception e) { | ||
500 | m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message); | ||
501 | } | ||
502 | lock (pendingInstantMessages) { | ||
503 | if (pendingInstantMessages.Count > 0) { | ||
504 | gim = pendingInstantMessages.Dequeue(); | ||
505 | im = gim.im; | ||
506 | result = gim.result; | ||
507 | } else { | ||
508 | gim = null; | ||
509 | -- numInstantMessageThreads; | ||
510 | //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads); | ||
511 | } | ||
512 | } | ||
513 | } while (gim != null); | ||
514 | } | ||
515 | private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) | ||
516 | { | ||
517 | |||
462 | UUID toAgentID = new UUID(im.toAgentID); | 518 | UUID toAgentID = new UUID(im.toAgentID); |
463 | 519 | ||
464 | PresenceInfo upd = null; | 520 | PresenceInfo upd = null; |
@@ -525,7 +581,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
525 | 581 | ||
526 | if (upd != null) | 582 | if (upd != null) |
527 | { | 583 | { |
528 | GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, | 584 | GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero, |
529 | upd.RegionID); | 585 | upd.RegionID); |
530 | if (reginfo != null) | 586 | if (reginfo != null) |
531 | { | 587 | { |
@@ -674,6 +730,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
674 | gim["position_z"] = msg.Position.Z.ToString(); | 730 | gim["position_z"] = msg.Position.Z.ToString(); |
675 | gim["region_id"] = new UUID(msg.RegionID).ToString(); | 731 | gim["region_id"] = new UUID(msg.RegionID).ToString(); |
676 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); | 732 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); |
733 | if (m_MessageKey != String.Empty) | ||
734 | gim["message_key"] = m_MessageKey; | ||
677 | return gim; | 735 | return gim; |
678 | } | 736 | } |
679 | 737 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index 7f3d0a2..2d46276 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -173,7 +173,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
173 | 173 | ||
174 | private void RetrieveInstantMessages(IClientAPI client) | 174 | private void RetrieveInstantMessages(IClientAPI client) |
175 | { | 175 | { |
176 | if (m_RestURL != "") | 176 | if (m_RestURL == String.Empty) |
177 | { | ||
178 | return; | ||
179 | } | ||
180 | else | ||
177 | { | 181 | { |
178 | m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); | 182 | m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); |
179 | 183 | ||
@@ -181,28 +185,28 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
181 | = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( | 185 | = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( |
182 | "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); | 186 | "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); |
183 | 187 | ||
184 | if (msglist == null) | 188 | if (msglist != null) |
185 | { | 189 | { |
186 | m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list."); | 190 | foreach (GridInstantMessage im in msglist) |
187 | return; | ||
188 | } | ||
189 | |||
190 | foreach (GridInstantMessage im in msglist) | ||
191 | { | ||
192 | if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) | ||
193 | // send it directly or else the item will be given twice | ||
194 | client.SendInstantMessage(im); | ||
195 | else | ||
196 | { | 191 | { |
197 | // Send through scene event manager so all modules get a chance | 192 | if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) |
198 | // to look at this message before it gets delivered. | 193 | // send it directly or else the item will be given twice |
199 | // | 194 | client.SendInstantMessage(im); |
200 | // Needed for proper state management for stored group | 195 | else |
201 | // invitations | 196 | { |
202 | // | 197 | // Send through scene event manager so all modules get a chance |
203 | Scene s = FindScene(client.AgentId); | 198 | // to look at this message before it gets delivered. |
204 | if (s != null) | 199 | // |
205 | s.EventManager.TriggerIncomingInstantMessage(im); | 200 | // Needed for proper state management for stored group |
201 | // invitations | ||
202 | // | ||
203 | |||
204 | im.offline = 1; | ||
205 | |||
206 | Scene s = FindScene(client.AgentId); | ||
207 | if (s != null) | ||
208 | s.EventManager.TriggerIncomingInstantMessage(im); | ||
209 | } | ||
206 | } | 210 | } |
207 | } | 211 | } |
208 | } | 212 | } |
@@ -214,24 +218,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
214 | im.dialog != (byte)InstantMessageDialog.MessageFromAgent && | 218 | im.dialog != (byte)InstantMessageDialog.MessageFromAgent && |
215 | im.dialog != (byte)InstantMessageDialog.GroupNotice && | 219 | im.dialog != (byte)InstantMessageDialog.GroupNotice && |
216 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && | 220 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && |
217 | im.dialog != (byte)InstantMessageDialog.InventoryOffered) | 221 | im.dialog != (byte)InstantMessageDialog.InventoryOffered && |
222 | im.dialog != (byte)InstantMessageDialog.TaskInventoryOffered) | ||
218 | { | 223 | { |
219 | return; | 224 | return; |
220 | } | 225 | } |
221 | 226 | ||
222 | if (!m_ForwardOfflineGroupMessages) | ||
223 | { | ||
224 | if (im.dialog == (byte)InstantMessageDialog.GroupNotice || | ||
225 | im.dialog == (byte)InstantMessageDialog.GroupInvitation) | ||
226 | return; | ||
227 | } | ||
228 | |||
229 | Scene scene = FindScene(new UUID(im.fromAgentID)); | 227 | Scene scene = FindScene(new UUID(im.fromAgentID)); |
230 | if (scene == null) | 228 | if (scene == null) |
231 | scene = m_SceneList[0]; | 229 | scene = m_SceneList[0]; |
232 | 230 | ||
233 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( | 231 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( |
234 | "POST", m_RestURL+"/SaveMessage/", im); | 232 | "POST", m_RestURL+"/SaveMessage/?scope=" + |
233 | scene.RegionInfo.ScopeID.ToString(), im); | ||
235 | 234 | ||
236 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) | 235 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) |
237 | { | 236 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index f7057fe..5a8544e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -656,4 +656,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
656 | m_assetsLoaded = true; | 656 | m_assetsLoaded = true; |
657 | } | 657 | } |
658 | } | 658 | } |
659 | } \ No newline at end of file | 659 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 5854428..ea660bd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -519,6 +519,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
519 | return null; | 519 | return null; |
520 | } | 520 | } |
521 | 521 | ||
522 | return account; | ||
523 | /* | ||
522 | try | 524 | try |
523 | { | 525 | { |
524 | string encpass = Util.Md5Hash(pass); | 526 | string encpass = Util.Md5Hash(pass); |
@@ -539,6 +541,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
539 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e); | 541 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e); |
540 | return null; | 542 | return null; |
541 | } | 543 | } |
544 | */ | ||
542 | } | 545 | } |
543 | 546 | ||
544 | /// <summary> | 547 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 0b10dd8..03aaaac 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -165,8 +165,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
165 | if (im.binaryBucket.Length < 17) // Invalid | 165 | if (im.binaryBucket.Length < 17) // Invalid |
166 | return; | 166 | return; |
167 | 167 | ||
168 | UUID receipientID = new UUID(im.toAgentID); | 168 | UUID recipientID = new UUID(im.toAgentID); |
169 | ScenePresence user = scene.GetScenePresence(receipientID); | 169 | ScenePresence user = scene.GetScenePresence(recipientID); |
170 | UUID copyID; | 170 | UUID copyID; |
171 | 171 | ||
172 | // First byte is the asset type | 172 | // First byte is the asset type |
@@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
181 | folderID, new UUID(im.toAgentID)); | 181 | folderID, new UUID(im.toAgentID)); |
182 | 182 | ||
183 | InventoryFolderBase folderCopy | 183 | InventoryFolderBase folderCopy |
184 | = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); | 184 | = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero); |
185 | 185 | ||
186 | if (folderCopy == null) | 186 | if (folderCopy == null) |
187 | { | 187 | { |
@@ -240,6 +240,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
240 | im.imSessionID = copyID.Guid; | 240 | im.imSessionID = copyID.Guid; |
241 | } | 241 | } |
242 | 242 | ||
243 | im.offline = 0; | ||
244 | |||
243 | // Send the IM to the recipient. The item is already | 245 | // Send the IM to the recipient. The item is already |
244 | // in their inventory, so it will not be lost if | 246 | // in their inventory, so it will not be lost if |
245 | // they are offline. | 247 | // they are offline. |
@@ -259,8 +261,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
259 | }); | 261 | }); |
260 | } | 262 | } |
261 | } | 263 | } |
262 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) | 264 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || |
265 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
263 | { | 266 | { |
267 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip | ||
268 | IInventoryService invService = scene.InventoryService; | ||
269 | |||
270 | // Special case: folder redirect. | ||
271 | // RLV uses this | ||
272 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
273 | { | ||
274 | InventoryFolderBase folder = new InventoryFolderBase(inventoryID, client.AgentId); | ||
275 | folder = invService.GetFolder(folder); | ||
276 | |||
277 | if (folder != null) | ||
278 | { | ||
279 | if (im.binaryBucket.Length >= 16) | ||
280 | { | ||
281 | UUID destFolderID = new UUID(im.binaryBucket, 0); | ||
282 | if (destFolderID != UUID.Zero) | ||
283 | { | ||
284 | InventoryFolderBase destFolder = new InventoryFolderBase(destFolderID, client.AgentId); | ||
285 | destFolder = invService.GetFolder(destFolder); | ||
286 | if (destFolder != null) | ||
287 | { | ||
288 | if (folder.ParentID != destFolder.ID) | ||
289 | { | ||
290 | folder.ParentID = destFolder.ID; | ||
291 | invService.MoveFolder(folder); | ||
292 | client.SendBulkUpdateInventory(folder); | ||
293 | } | ||
294 | } | ||
295 | } | ||
296 | } | ||
297 | } | ||
298 | } | ||
299 | |||
264 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); | 300 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
265 | 301 | ||
266 | if (user != null) // Local | 302 | if (user != null) // Local |
@@ -270,27 +306,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
270 | else | 306 | else |
271 | { | 307 | { |
272 | if (m_TransferModule != null) | 308 | if (m_TransferModule != null) |
273 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { | 309 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); |
274 | |||
275 | // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011 | ||
276 | // and is apparently supposed to fix bulk inventory updates after accepting items. But | ||
277 | // instead it appears to cause two copies of an accepted folder for the receiving user in | ||
278 | // at least some cases. Folder/item update is already done when the offer is made (see code above) | ||
279 | |||
280 | // // Send BulkUpdateInventory | ||
281 | // IInventoryService invService = scene.InventoryService; | ||
282 | // UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip | ||
283 | // | ||
284 | // InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); | ||
285 | // folder = invService.GetFolder(folder); | ||
286 | // | ||
287 | // ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); | ||
288 | // | ||
289 | // // If the user has left the scene by the time the message comes back then we can't send | ||
290 | // // them the update. | ||
291 | // if (fromUser != null) | ||
292 | // fromUser.ControllingClient.SendBulkUpdateInventory(folder); | ||
293 | }); | ||
294 | } | 310 | } |
295 | } | 311 | } |
296 | 312 | ||
@@ -403,6 +419,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
403 | previousParentFolderID = folder.ParentID; | 419 | previousParentFolderID = folder.ParentID; |
404 | folder.ParentID = trashFolder.ID; | 420 | folder.ParentID = trashFolder.ID; |
405 | invService.MoveFolder(folder); | 421 | invService.MoveFolder(folder); |
422 | client.SendBulkUpdateInventory(folder); | ||
406 | } | 423 | } |
407 | } | 424 | } |
408 | 425 | ||
@@ -475,32 +492,100 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
475 | // Find agent to deliver to | 492 | // Find agent to deliver to |
476 | // | 493 | // |
477 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); | 494 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
495 | if (user == null) | ||
496 | return; | ||
478 | 497 | ||
479 | if (user != null) | 498 | // This requires a little bit of processing because we have to make the |
499 | // new item visible in the recipient's inventory here | ||
500 | // | ||
501 | if (im.dialog == (byte) InstantMessageDialog.InventoryOffered) | ||
480 | { | 502 | { |
481 | user.ControllingClient.SendInstantMessage(im); | 503 | if (im.binaryBucket.Length < 17) // Invalid |
504 | return; | ||
505 | |||
506 | UUID recipientID = new UUID(im.toAgentID); | ||
482 | 507 | ||
483 | if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) | 508 | // First byte is the asset type |
484 | { | 509 | AssetType assetType = (AssetType)im.binaryBucket[0]; |
485 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
486 | UUID inventoryID = new UUID(im.binaryBucket, 1); | ||
487 | 510 | ||
488 | IInventoryService invService = scene.InventoryService; | 511 | if (AssetType.Folder == assetType) |
489 | InventoryNodeBase node = null; | 512 | { |
490 | if (AssetType.Folder == assetType) | 513 | UUID folderID = new UUID(im.binaryBucket, 1); |
514 | |||
515 | InventoryFolderBase given = | ||
516 | new InventoryFolderBase(folderID, recipientID); | ||
517 | InventoryFolderBase folder = | ||
518 | scene.InventoryService.GetFolder(given); | ||
519 | |||
520 | if (folder != null) | ||
521 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
522 | } | ||
523 | else | ||
524 | { | ||
525 | UUID itemID = new UUID(im.binaryBucket, 1); | ||
526 | |||
527 | InventoryItemBase given = | ||
528 | new InventoryItemBase(itemID, recipientID); | ||
529 | InventoryItemBase item = | ||
530 | scene.InventoryService.GetItem(given); | ||
531 | |||
532 | if (item != null) | ||
491 | { | 533 | { |
492 | InventoryFolderBase folder = new InventoryFolderBase(inventoryID, new UUID(im.toAgentID)); | 534 | user.ControllingClient.SendBulkUpdateInventory(item); |
493 | node = invService.GetFolder(folder); | ||
494 | } | 535 | } |
495 | else | 536 | } |
537 | user.ControllingClient.SendInstantMessage(im); | ||
538 | } | ||
539 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered) | ||
540 | { | ||
541 | if (im.binaryBucket.Length < 1) // Invalid | ||
542 | return; | ||
543 | |||
544 | UUID recipientID = new UUID(im.toAgentID); | ||
545 | |||
546 | // Bucket is the asset type | ||
547 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
548 | |||
549 | if (AssetType.Folder == assetType) | ||
550 | { | ||
551 | UUID folderID = new UUID(im.imSessionID); | ||
552 | |||
553 | InventoryFolderBase given = | ||
554 | new InventoryFolderBase(folderID, recipientID); | ||
555 | InventoryFolderBase folder = | ||
556 | scene.InventoryService.GetFolder(given); | ||
557 | |||
558 | if (folder != null) | ||
559 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
560 | } | ||
561 | else | ||
562 | { | ||
563 | UUID itemID = new UUID(im.imSessionID); | ||
564 | |||
565 | InventoryItemBase given = | ||
566 | new InventoryItemBase(itemID, recipientID); | ||
567 | InventoryItemBase item = | ||
568 | scene.InventoryService.GetItem(given); | ||
569 | |||
570 | if (item != null) | ||
496 | { | 571 | { |
497 | InventoryItemBase item = new InventoryItemBase(inventoryID, new UUID(im.toAgentID)); | 572 | user.ControllingClient.SendBulkUpdateInventory(item); |
498 | node = invService.GetItem(item); | ||
499 | } | 573 | } |
500 | |||
501 | if (node != null) | ||
502 | user.ControllingClient.SendBulkUpdateInventory(node); | ||
503 | } | 574 | } |
575 | |||
576 | // Fix up binary bucket since this may be 17 chars long here | ||
577 | Byte[] bucket = new Byte[1]; | ||
578 | bucket[0] = im.binaryBucket[0]; | ||
579 | im.binaryBucket = bucket; | ||
580 | |||
581 | user.ControllingClient.SendInstantMessage(im); | ||
582 | } | ||
583 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || | ||
584 | im.dialog == (byte) InstantMessageDialog.InventoryDeclined || | ||
585 | im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined || | ||
586 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
587 | { | ||
588 | user.ControllingClient.SendInstantMessage(im); | ||
504 | } | 589 | } |
505 | } | 590 | } |
506 | } | 591 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index 465ffbc..c517a30 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | |||
@@ -163,16 +163,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
163 | scene.RegionInfo.RegionHandle, | 163 | scene.RegionInfo.RegionHandle, |
164 | (uint)presence.AbsolutePosition.X, | 164 | (uint)presence.AbsolutePosition.X, |
165 | (uint)presence.AbsolutePosition.Y, | 165 | (uint)presence.AbsolutePosition.Y, |
166 | (uint)Math.Ceiling(presence.AbsolutePosition.Z)); | 166 | (uint)presence.AbsolutePosition.Z + 2); |
167 | 167 | ||
168 | m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1}", message, lureType); | 168 | m_log.DebugFormat("[LURE MODULE]: TP invite with message {0}, type {1}", message, lureType); |
169 | 169 | ||
170 | GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, | 170 | GridInstantMessage m; |
171 | client.FirstName+" "+client.LastName, targetid, | 171 | |
172 | (byte)InstantMessageDialog.RequestTeleport, false, | 172 | if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid))) |
173 | message, dest, false, presence.AbsolutePosition, | 173 | { |
174 | new Byte[0], true); | 174 | m = new GridInstantMessage(scene, client.AgentId, |
175 | 175 | client.FirstName+" "+client.LastName, targetid, | |
176 | (byte)InstantMessageDialog.GodLikeRequestTeleport, false, | ||
177 | message, dest, false, presence.AbsolutePosition, | ||
178 | new Byte[0], true); | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | m = new GridInstantMessage(scene, client.AgentId, | ||
183 | client.FirstName+" "+client.LastName, targetid, | ||
184 | (byte)InstantMessageDialog.RequestTeleport, false, | ||
185 | message, dest, false, presence.AbsolutePosition, | ||
186 | new Byte[0], true); | ||
187 | } | ||
188 | |||
176 | if (m_TransferModule != null) | 189 | if (m_TransferModule != null) |
177 | { | 190 | { |
178 | m_TransferModule.SendInstantMessage(m, | 191 | m_TransferModule.SendInstantMessage(m, |
@@ -207,7 +220,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
207 | { | 220 | { |
208 | // Forward remote teleport requests | 221 | // Forward remote teleport requests |
209 | // | 222 | // |
210 | if (msg.dialog != 22) | 223 | if (msg.dialog != (byte)InstantMessageDialog.RequestTeleport && |
224 | msg.dialog != (byte)InstantMessageDialog.GodLikeRequestTeleport) | ||
211 | return; | 225 | return; |
212 | 226 | ||
213 | if (m_TransferModule != null) | 227 | if (m_TransferModule != null) |