diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
15 files changed, 1159 insertions, 579 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index ad17aa9..f62512e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Region.Framework; | |||
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Scenes.Serialization; | 42 | using OpenSim.Region.Framework.Scenes.Serialization; |
43 | using OpenSim.Services.Interfaces; | ||
43 | 44 | ||
44 | namespace OpenSim.Region.CoreModules.Avatar.Attachments | 45 | namespace OpenSim.Region.CoreModules.Avatar.Attachments |
45 | { | 46 | { |
@@ -75,40 +76,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
75 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); | 76 | m_scene.RegisterModuleInterface<IAttachmentsModule>(this); |
76 | 77 | ||
77 | if (Enabled) | 78 | if (Enabled) |
78 | { | ||
79 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 79 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
80 | m_scene.EventManager.OnStartScript += (localID, itemID) => HandleScriptStateChange(localID, true); | ||
81 | m_scene.EventManager.OnStopScript += (localID, itemID) => HandleScriptStateChange(localID, false); | ||
82 | } | ||
83 | 80 | ||
84 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI | 81 | // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI |
85 | } | 82 | } |
86 | |||
87 | /// <summary> | ||
88 | /// Listen for client triggered running state changes so that we can persist the script's object if necessary. | ||
89 | /// </summary> | ||
90 | /// <param name='localID'></param> | ||
91 | /// <param name='itemID'></param> | ||
92 | private void HandleScriptStateChange(uint localID, bool started) | ||
93 | { | ||
94 | SceneObjectGroup sog = m_scene.GetGroupByPrim(localID); | ||
95 | if (sog != null && sog.IsAttachment) | ||
96 | { | ||
97 | if (!started) | ||
98 | { | ||
99 | // FIXME: This is a convoluted way for working out whether the script state has changed to stop | ||
100 | // because it has been manually stopped or because the stop was called in UpdateDetachedObject() below | ||
101 | // This needs to be handled in a less tangled way. | ||
102 | ScenePresence sp = m_scene.GetScenePresence(sog.AttachedAvatar); | ||
103 | if (sp.ControllingClient.IsActive) | ||
104 | sog.HasGroupChanged = true; | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | sog.HasGroupChanged = true; | ||
109 | } | ||
110 | } | ||
111 | } | ||
112 | 83 | ||
113 | public void RemoveRegion(Scene scene) | 84 | public void RemoveRegion(Scene scene) |
114 | { | 85 | { |
@@ -199,6 +170,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
199 | 170 | ||
200 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0}", sp.Name); | 171 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0}", sp.Name); |
201 | 172 | ||
173 | XmlDocument doc = new XmlDocument(); | ||
174 | string stateData = String.Empty; | ||
175 | |||
176 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
177 | if (attServ != null) | ||
178 | { | ||
179 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
180 | stateData = attServ.Get(sp.UUID.ToString()); | ||
181 | if (stateData != String.Empty) | ||
182 | { | ||
183 | try | ||
184 | { | ||
185 | doc.LoadXml(stateData); | ||
186 | } | ||
187 | catch { } | ||
188 | } | ||
189 | } | ||
190 | |||
191 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
192 | |||
193 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
194 | if (nodes.Count > 0) | ||
195 | { | ||
196 | foreach (XmlNode n in nodes) | ||
197 | { | ||
198 | XmlElement elem = (XmlElement)n; | ||
199 | string itemID = elem.GetAttribute("ItemID"); | ||
200 | string xml = elem.InnerXml; | ||
201 | |||
202 | itemData[new UUID(itemID)] = xml; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | |||
202 | List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); | 207 | List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); |
203 | foreach (AvatarAttachment attach in attachments) | 208 | foreach (AvatarAttachment attach in attachments) |
204 | { | 209 | { |
@@ -218,12 +223,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
218 | 223 | ||
219 | try | 224 | try |
220 | { | 225 | { |
226 | string xmlData; | ||
227 | XmlDocument d = null; | ||
228 | UUID asset; | ||
229 | if (itemData.TryGetValue(attach.ItemID, out xmlData)) | ||
230 | { | ||
231 | d = new XmlDocument(); | ||
232 | d.LoadXml(xmlData); | ||
233 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID); | ||
234 | } | ||
235 | |||
221 | // If we're an NPC then skip all the item checks and manipulations since we don't have an | 236 | // If we're an NPC then skip all the item checks and manipulations since we don't have an |
222 | // inventory right now. | 237 | // inventory right now. |
223 | if (sp.PresenceType == PresenceType.Npc) | 238 | if (sp.PresenceType == PresenceType.Npc) |
224 | RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, true); | 239 | RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null, true); |
225 | else | 240 | else |
226 | RezSingleAttachmentFromInventory(sp, attach.ItemID, p | (uint)0x80); | 241 | RezSingleAttachmentFromInventory(sp, attach.ItemID, p | (uint)0x80, d); |
227 | } | 242 | } |
228 | catch (Exception e) | 243 | catch (Exception e) |
229 | { | 244 | { |
@@ -284,12 +299,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
284 | sp.ClearAttachments(); | 299 | sp.ClearAttachments(); |
285 | } | 300 | } |
286 | 301 | ||
287 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool append) | 302 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp, bool append) |
288 | { | 303 | { |
289 | if (!Enabled) | 304 | if (!Enabled) |
290 | return false; | 305 | return false; |
291 | 306 | ||
292 | return AttachObjectInternal(sp, group, attachmentPt, silent, temp, true, append); | 307 | return AttachObjectInternal(sp, group, attachmentPt, silent, useAttachData, temp, false, append); |
293 | } | 308 | } |
294 | 309 | ||
295 | /// <summary> | 310 | /// <summary> |
@@ -302,9 +317,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
302 | /// <param name='silent'></param> | 317 | /// <param name='silent'></param> |
303 | /// <param name='temp'></param> | 318 | /// <param name='temp'></param> |
304 | /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> | 319 | /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param> |
305 | private bool AttachObjectInternal( | 320 | private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp, bool resumeScripts, bool append) |
306 | IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp, bool resumeScripts, bool append) | ||
307 | { | 321 | { |
322 | // m_log.DebugFormat( | ||
323 | // "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", | ||
324 | // group.Name, group.LocalId, sp.Name, attachmentPt, silent); | ||
325 | |||
326 | if (sp.GetAttachments().Contains(group)) | ||
327 | { | ||
328 | // m_log.WarnFormat( | ||
329 | // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", | ||
330 | // group.Name, group.LocalId, sp.Name, AttachmentPt); | ||
331 | |||
332 | return false; | ||
333 | } | ||
334 | |||
308 | if (group.GetSittingAvatarsCount() != 0) | 335 | if (group.GetSittingAvatarsCount() != 0) |
309 | { | 336 | { |
310 | // m_log.WarnFormat( | 337 | // m_log.WarnFormat( |
@@ -315,6 +342,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
315 | } | 342 | } |
316 | 343 | ||
317 | Vector3 attachPos = group.AbsolutePosition; | 344 | Vector3 attachPos = group.AbsolutePosition; |
345 | |||
346 | // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should | ||
347 | // be removed when that functionality is implemented in opensim | ||
348 | attachmentPt &= 0x7f; | ||
349 | |||
318 | // If the attachment point isn't the same as the one previously used | 350 | // If the attachment point isn't the same as the one previously used |
319 | // set it's offset position = 0 so that it appears on the attachment point | 351 | // set it's offset position = 0 so that it appears on the attachment point |
320 | // and not in a weird location somewhere unknown. | 352 | // and not in a weird location somewhere unknown. |
@@ -323,7 +355,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
323 | attachPos = Vector3.Zero; | 355 | attachPos = Vector3.Zero; |
324 | } | 356 | } |
325 | 357 | ||
326 | // AttachmentPt 0 means the client chose to 'wear' the attachment. | 358 | // AttachmentPt 0 (default) means the client chose to 'wear' the attachment. |
327 | if (attachmentPt == (uint)AttachmentPoint.Default) | 359 | if (attachmentPt == (uint)AttachmentPoint.Default) |
328 | { | 360 | { |
329 | // Check object for stored attachment point | 361 | // Check object for stored attachment point |
@@ -338,20 +370,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
338 | attachPos = Vector3.Zero; | 370 | attachPos = Vector3.Zero; |
339 | } | 371 | } |
340 | 372 | ||
341 | group.AttachmentPoint = attachmentPt; | ||
342 | group.AbsolutePosition = attachPos; | ||
343 | |||
344 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); | 373 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); |
345 | 374 | ||
346 | if (attachments.Contains(group)) | ||
347 | { | ||
348 | // m_log.WarnFormat( | ||
349 | // "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", | ||
350 | // group.Name, group.LocalId, sp.Name, AttachmentPt); | ||
351 | |||
352 | return false; | ||
353 | } | ||
354 | |||
355 | // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones | 375 | // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones |
356 | while (attachments.Count >= 5) | 376 | while (attachments.Count >= 5) |
357 | { | 377 | { |
@@ -372,6 +392,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
372 | 392 | ||
373 | lock (sp.AttachmentsSyncLock) | 393 | lock (sp.AttachmentsSyncLock) |
374 | { | 394 | { |
395 | group.AttachmentPoint = attachmentPt; | ||
396 | group.AbsolutePosition = attachPos; | ||
397 | |||
375 | if (sp.PresenceType != PresenceType.Npc) | 398 | if (sp.PresenceType != PresenceType.Npc) |
376 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append); | 399 | UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp, append); |
377 | 400 | ||
@@ -394,8 +417,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
394 | 417 | ||
395 | private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp, bool append) | 418 | private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp, bool append) |
396 | { | 419 | { |
397 | List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt); | ||
398 | |||
399 | // Add the new attachment to inventory if we don't already have it. | 420 | // Add the new attachment to inventory if we don't already have it. |
400 | if (!temp) | 421 | if (!temp) |
401 | { | 422 | { |
@@ -407,7 +428,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
407 | } | 428 | } |
408 | } | 429 | } |
409 | 430 | ||
410 | public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) | 431 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) |
432 | { | ||
433 | return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, null); | ||
434 | } | ||
435 | |||
436 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, XmlDocument doc) | ||
411 | { | 437 | { |
412 | if (!Enabled) | 438 | if (!Enabled) |
413 | return null; | 439 | return null; |
@@ -445,7 +471,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
445 | return null; | 471 | return null; |
446 | } | 472 | } |
447 | 473 | ||
448 | return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, append); | 474 | return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc, append); |
449 | } | 475 | } |
450 | 476 | ||
451 | public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) | 477 | public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) |
@@ -517,7 +543,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
517 | so.AttachedAvatar = UUID.Zero; | 543 | so.AttachedAvatar = UUID.Zero; |
518 | rootPart.SetParentLocalId(0); | 544 | rootPart.SetParentLocalId(0); |
519 | so.ClearPartAttachmentData(); | 545 | so.ClearPartAttachmentData(); |
520 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); | 546 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive,false); |
521 | so.HasGroupChanged = true; | 547 | so.HasGroupChanged = true; |
522 | rootPart.Rezzed = DateTime.Now; | 548 | rootPart.Rezzed = DateTime.Now; |
523 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); | 549 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); |
@@ -846,7 +872,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
846 | } | 872 | } |
847 | 873 | ||
848 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( | 874 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( |
849 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, bool append) | 875 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc, bool append) |
850 | { | 876 | { |
851 | if (m_invAccessModule == null) | 877 | if (m_invAccessModule == null) |
852 | return null; | 878 | return null; |
@@ -871,10 +897,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
871 | return null; | 897 | return null; |
872 | } | 898 | } |
873 | 899 | ||
874 | // m_log.DebugFormat( | ||
875 | // "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}", | ||
876 | // objatt.Name, sp.Name, attachmentPt, m_scene.Name); | ||
877 | |||
878 | // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. | 900 | // HasGroupChanged is being set from within RezObject. Ideally it would be set by the caller. |
879 | objatt.HasGroupChanged = false; | 901 | objatt.HasGroupChanged = false; |
880 | bool tainted = false; | 902 | bool tainted = false; |
@@ -889,7 +911,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
889 | // This will throw if the attachment fails | 911 | // This will throw if the attachment fails |
890 | try | 912 | try |
891 | { | 913 | { |
892 | AttachObjectInternal(sp, objatt, attachmentPt, false, false, true, append); | 914 | if (doc != null) |
915 | { | ||
916 | objatt.LoadScriptState(doc); | ||
917 | objatt.ResetOwnerChangeFlag(); | ||
918 | } | ||
919 | |||
920 | AttachObjectInternal(sp, objatt, attachmentPt, false, true, false, true, append); | ||
893 | } | 921 | } |
894 | catch (Exception e) | 922 | catch (Exception e) |
895 | { | 923 | { |
@@ -1028,7 +1056,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
1028 | AttachmentPt &= 0x7f; | 1056 | AttachmentPt &= 0x7f; |
1029 | 1057 | ||
1030 | // Calls attach with a Zero position | 1058 | // Calls attach with a Zero position |
1031 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false, append)) | 1059 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false, append)) |
1032 | { | 1060 | { |
1033 | // m_log.Debug( | 1061 | // m_log.Debug( |
1034 | // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | 1062 | // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index c8c594d..a8fe045 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -197,7 +197,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
197 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); | 197 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); |
198 | 198 | ||
199 | m_numberOfAttachEventsFired = 0; | 199 | m_numberOfAttachEventsFired = 0; |
200 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); | 200 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false, false); |
201 | 201 | ||
202 | // Check status on scene presence | 202 | // Check status on scene presence |
203 | Assert.That(sp.HasAttachments(), Is.True); | 203 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -244,7 +244,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
244 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); | 244 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID); |
245 | 245 | ||
246 | m_numberOfAttachEventsFired = 0; | 246 | m_numberOfAttachEventsFired = 0; |
247 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, false, false); | 247 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, false, false, false); |
248 | 248 | ||
249 | // Check status on scene presence | 249 | // Check status on scene presence |
250 | Assert.That(sp.HasAttachments(), Is.True); | 250 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -277,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
277 | 277 | ||
278 | // Test wearing a different attachment from the ground. | 278 | // Test wearing a different attachment from the ground. |
279 | { | 279 | { |
280 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false); | 280 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false, false); |
281 | 281 | ||
282 | // Check status on scene presence | 282 | // Check status on scene presence |
283 | Assert.That(sp.HasAttachments(), Is.True); | 283 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -310,7 +310,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
310 | 310 | ||
311 | // Test rewearing an already worn attachment from ground. Nothing should happen. | 311 | // Test rewearing an already worn attachment from ground. Nothing should happen. |
312 | { | 312 | { |
313 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false); | 313 | scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, false, false, false); |
314 | 314 | ||
315 | // Check status on scene presence | 315 | // Check status on scene presence |
316 | Assert.That(sp.HasAttachments(), Is.True); | 316 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -368,7 +368,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
368 | sp2.AbsolutePosition = new Vector3(0, 0, 0); | 368 | sp2.AbsolutePosition = new Vector3(0, 0, 0); |
369 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); | 369 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); |
370 | 370 | ||
371 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); | 371 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false, false); |
372 | 372 | ||
373 | Assert.That(sp.HasAttachments(), Is.False); | 373 | Assert.That(sp.HasAttachments(), Is.False); |
374 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 374 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
@@ -663,7 +663,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
663 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 663 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; |
664 | 664 | ||
665 | SceneObjectGroup rezzedSo | 665 | SceneObjectGroup rezzedSo |
666 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 666 | = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); |
667 | 667 | ||
668 | // Wait for chat to signal rezzed script has been started. | 668 | // Wait for chat to signal rezzed script has been started. |
669 | m_chatEvent.WaitOne(60000); | 669 | m_chatEvent.WaitOne(60000); |
@@ -682,7 +682,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
682 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); | 682 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); |
683 | 683 | ||
684 | // Re-rez the attachment to check script running state | 684 | // Re-rez the attachment to check script running state |
685 | SceneObjectGroup reRezzedSo = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 685 | SceneObjectGroup reRezzedSo = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); |
686 | 686 | ||
687 | // Wait for chat to signal rezzed script has been started. | 687 | // Wait for chat to signal rezzed script has been started. |
688 | m_chatEvent.WaitOne(60000); | 688 | m_chatEvent.WaitOne(60000); |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index c7ac7c4..bc79944 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -141,9 +141,24 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
141 | /// <param name="sp"></param> | 141 | /// <param name="sp"></param> |
142 | /// <param name="texture"></param> | 142 | /// <param name="texture"></param> |
143 | /// <param name="visualParam"></param> | 143 | /// <param name="visualParam"></param> |
144 | public void SetAppearance(IScenePresence sp, AvatarAppearance appearance) | 144 | public void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems) |
145 | { | 145 | { |
146 | SetAppearance(sp, appearance.Texture, appearance.VisualParams); | 146 | SetAppearance(sp, appearance.Texture, appearance.VisualParams, cacheItems); |
147 | } | ||
148 | |||
149 | |||
150 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) | ||
151 | { | ||
152 | float oldoff = sp.Appearance.AvatarFeetOffset; | ||
153 | Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
154 | |||
155 | SetAppearance(sp, textureEntry, visualParams, cacheItems); | ||
156 | sp.Appearance.SetSize(avSize); | ||
157 | |||
158 | float off = sp.Appearance.AvatarFeetOffset; | ||
159 | Vector3 box = sp.Appearance.AvatarBoxSize; | ||
160 | if (oldoff != off || oldbox != box) | ||
161 | ((ScenePresence)sp).SetSize(box, off); | ||
147 | } | 162 | } |
148 | 163 | ||
149 | /// <summary> | 164 | /// <summary> |
@@ -152,7 +167,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
152 | /// <param name="sp"></param> | 167 | /// <param name="sp"></param> |
153 | /// <param name="texture"></param> | 168 | /// <param name="texture"></param> |
154 | /// <param name="visualParam"></param> | 169 | /// <param name="visualParam"></param> |
155 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams) | 170 | public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems) |
156 | { | 171 | { |
157 | // m_log.DebugFormat( | 172 | // m_log.DebugFormat( |
158 | // "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}", | 173 | // "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}", |
@@ -175,18 +190,27 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
175 | // m_log.DebugFormat( | 190 | // m_log.DebugFormat( |
176 | // "[AVFACTORY]: Setting visual params for {0} to {1}", | 191 | // "[AVFACTORY]: Setting visual params for {0} to {1}", |
177 | // client.Name, string.Join(", ", visualParamsStrings)); | 192 | // client.Name, string.Join(", ", visualParamsStrings)); |
178 | 193 | /* | |
179 | float oldHeight = sp.Appearance.AvatarHeight; | 194 | float oldHeight = sp.Appearance.AvatarHeight; |
180 | changed = sp.Appearance.SetVisualParams(visualParams); | 195 | changed = sp.Appearance.SetVisualParams(visualParams); |
181 | 196 | ||
182 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) | 197 | if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) |
183 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); | 198 | ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); |
184 | } | 199 | */ |
200 | // float oldoff = sp.Appearance.AvatarFeetOffset; | ||
201 | // Vector3 oldbox = sp.Appearance.AvatarBoxSize; | ||
202 | changed = sp.Appearance.SetVisualParams(visualParams); | ||
203 | // float off = sp.Appearance.AvatarFeetOffset; | ||
204 | // Vector3 box = sp.Appearance.AvatarBoxSize; | ||
205 | // if(oldoff != off || oldbox != box) | ||
206 | // ((ScenePresence)sp).SetSize(box,off); | ||
185 | 207 | ||
208 | } | ||
209 | |||
186 | // Process the baked texture array | 210 | // Process the baked texture array |
187 | if (textureEntry != null) | 211 | if (textureEntry != null) |
188 | { | 212 | { |
189 | // m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); | 213 | m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID); |
190 | 214 | ||
191 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); | 215 | // WriteBakedTexturesReport(sp, m_log.DebugFormat); |
192 | 216 | ||
@@ -255,6 +279,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
255 | return GetBakedTextureFaces(sp); | 279 | return GetBakedTextureFaces(sp); |
256 | } | 280 | } |
257 | 281 | ||
282 | public WearableCacheItem[] GetCachedItems(UUID agentId) | ||
283 | { | ||
284 | ScenePresence sp = m_scene.GetScenePresence(agentId); | ||
285 | WearableCacheItem[] items = sp.Appearance.WearableCacheItems; | ||
286 | //foreach (WearableCacheItem item in items) | ||
287 | //{ | ||
288 | |||
289 | //} | ||
290 | return items; | ||
291 | } | ||
292 | |||
258 | public bool SaveBakedTextures(UUID agentId) | 293 | public bool SaveBakedTextures(UUID agentId) |
259 | { | 294 | { |
260 | ScenePresence sp = m_scene.GetScenePresence(agentId); | 295 | ScenePresence sp = m_scene.GetScenePresence(agentId); |
@@ -341,6 +376,53 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
341 | public bool ValidateBakedTextureCache(IScenePresence sp) | 376 | public bool ValidateBakedTextureCache(IScenePresence sp) |
342 | { | 377 | { |
343 | bool defonly = true; // are we only using default textures | 378 | bool defonly = true; // are we only using default textures |
379 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
380 | IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
381 | WearableCacheItem[] wearableCache = null; | ||
382 | |||
383 | // Cache wearable data for teleport. | ||
384 | // Only makes sense if there's a bake module and a cache module | ||
385 | if (bakedModule != null && cache != null) | ||
386 | { | ||
387 | try | ||
388 | { | ||
389 | wearableCache = bakedModule.Get(sp.UUID); | ||
390 | } | ||
391 | catch (Exception) | ||
392 | { | ||
393 | |||
394 | } | ||
395 | if (wearableCache != null) | ||
396 | { | ||
397 | for (int i = 0; i < wearableCache.Length; i++) | ||
398 | { | ||
399 | cache.Cache(wearableCache[i].TextureAsset); | ||
400 | } | ||
401 | } | ||
402 | } | ||
403 | /* | ||
404 | IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
405 | if (invService.GetRootFolder(userID) != null) | ||
406 | { | ||
407 | WearableCacheItem[] wearableCache = null; | ||
408 | if (bakedModule != null) | ||
409 | { | ||
410 | try | ||
411 | { | ||
412 | wearableCache = bakedModule.Get(userID); | ||
413 | appearance.WearableCacheItems = wearableCache; | ||
414 | appearance.WearableCacheItemsDirty = false; | ||
415 | foreach (WearableCacheItem item in wearableCache) | ||
416 | { | ||
417 | appearance.Texture.FaceTextures[item.TextureIndex].TextureID = item.TextureID; | ||
418 | } | ||
419 | } | ||
420 | catch (Exception) | ||
421 | { | ||
422 | |||
423 | } | ||
424 | } | ||
425 | */ | ||
344 | 426 | ||
345 | // Process the texture entry | 427 | // Process the texture entry |
346 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 428 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
@@ -348,9 +430,32 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
348 | int idx = AvatarAppearance.BAKE_INDICES[i]; | 430 | int idx = AvatarAppearance.BAKE_INDICES[i]; |
349 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; | 431 | Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; |
350 | 432 | ||
351 | // if there is no texture entry, skip it | 433 | // No face, so lets check our baked service cache, teleport or login. |
352 | if (face == null) | 434 | if (face == null) |
353 | continue; | 435 | { |
436 | if (wearableCache != null) | ||
437 | { | ||
438 | // If we find the an appearance item, set it as the textureentry and the face | ||
439 | WearableCacheItem searchitem = WearableCacheItem.SearchTextureIndex((uint) idx, wearableCache); | ||
440 | if (searchitem != null) | ||
441 | { | ||
442 | sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx); | ||
443 | sp.Appearance.Texture.FaceTextures[idx].TextureID = searchitem.TextureID; | ||
444 | face = sp.Appearance.Texture.FaceTextures[idx]; | ||
445 | } | ||
446 | else | ||
447 | { | ||
448 | // if there is no texture entry and no baked cache, skip it | ||
449 | continue; | ||
450 | } | ||
451 | } | ||
452 | else | ||
453 | { | ||
454 | //No texture entry face and no cache. Skip this face. | ||
455 | continue; | ||
456 | } | ||
457 | } | ||
458 | |||
354 | 459 | ||
355 | // m_log.DebugFormat( | 460 | // m_log.DebugFormat( |
356 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", | 461 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", |
@@ -365,8 +470,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
365 | 470 | ||
366 | defonly = false; // found a non-default texture reference | 471 | defonly = false; // found a non-default texture reference |
367 | 472 | ||
368 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | 473 | if (cache != null) |
369 | return false; | 474 | { |
475 | if (!cache.Check(face.TextureID.ToString())) | ||
476 | return false; | ||
477 | } | ||
478 | else | ||
479 | { | ||
480 | if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) | ||
481 | return false; | ||
482 | } | ||
370 | } | 483 | } |
371 | 484 | ||
372 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); | 485 | // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); |
@@ -378,6 +491,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
378 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) | 491 | public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) |
379 | { | 492 | { |
380 | int texturesRebaked = 0; | 493 | int texturesRebaked = 0; |
494 | IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
381 | 495 | ||
382 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) | 496 | for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) |
383 | { | 497 | { |
@@ -401,21 +515,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
401 | 515 | ||
402 | if (missingTexturesOnly) | 516 | if (missingTexturesOnly) |
403 | { | 517 | { |
404 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) | 518 | if (cache != null) |
405 | { | 519 | { |
406 | continue; | 520 | if (cache.Check(face.TextureID.ToString())) |
521 | continue; | ||
522 | else | ||
523 | { | ||
524 | m_log.DebugFormat( | ||
525 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
526 | face.TextureID, idx, sp.Name); | ||
527 | } | ||
407 | } | 528 | } |
408 | else | 529 | else |
409 | { | 530 | { |
410 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the | 531 | if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) |
411 | // grid asset service (which means that they are not available to the new region and so have | 532 | { |
412 | // to be re-requested from the client). | 533 | continue; |
413 | // | 534 | } |
414 | // The only available core OpenSimulator behaviour right now | 535 | |
415 | // is not to store these textures, temporarily or otherwise. | 536 | else |
416 | m_log.DebugFormat( | 537 | { |
417 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | 538 | // On inter-simulator teleports, this occurs if baked textures are not being stored by the |
418 | face.TextureID, idx, sp.Name); | 539 | // grid asset service (which means that they are not available to the new region and so have |
540 | // to be re-requested from the client). | ||
541 | // | ||
542 | // The only available core OpenSimulator behaviour right now | ||
543 | // is not to store these textures, temporarily or otherwise. | ||
544 | m_log.DebugFormat( | ||
545 | "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", | ||
546 | face.TextureID, idx, sp.Name); | ||
547 | } | ||
419 | } | 548 | } |
420 | } | 549 | } |
421 | else | 550 | else |
@@ -557,26 +686,70 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
557 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) | 686 | private void SetAppearanceAssets(UUID userID, AvatarAppearance appearance) |
558 | { | 687 | { |
559 | IInventoryService invService = m_scene.InventoryService; | 688 | IInventoryService invService = m_scene.InventoryService; |
560 | 689 | bool resetwearable = false; | |
561 | if (invService.GetRootFolder(userID) != null) | 690 | if (invService.GetRootFolder(userID) != null) |
562 | { | 691 | { |
563 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | 692 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) |
564 | { | 693 | { |
565 | for (int j = 0; j < appearance.Wearables[i].Count; j++) | 694 | for (int j = 0; j < appearance.Wearables[i].Count; j++) |
566 | { | 695 | { |
696 | // Check if the default wearables are not set | ||
567 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) | 697 | if (appearance.Wearables[i][j].ItemID == UUID.Zero) |
698 | { | ||
699 | switch ((WearableType) i) | ||
700 | { | ||
701 | case WearableType.Eyes: | ||
702 | case WearableType.Hair: | ||
703 | case WearableType.Shape: | ||
704 | case WearableType.Skin: | ||
705 | //case WearableType.Underpants: | ||
706 | TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance); | ||
707 | resetwearable = true; | ||
708 | m_log.Warn("[AVFACTORY]: UUID.Zero Wearables, passing fake values."); | ||
709 | resetwearable = true; | ||
710 | break; | ||
711 | |||
712 | } | ||
568 | continue; | 713 | continue; |
714 | } | ||
569 | 715 | ||
570 | // Ignore ruth's assets | 716 | // Ignore ruth's assets except for the body parts! missing body parts fail avatar appearance on V1 |
571 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) | 717 | if (appearance.Wearables[i][j].ItemID == AvatarWearable.DefaultWearables[i][0].ItemID) |
718 | { | ||
719 | switch ((WearableType)i) | ||
720 | { | ||
721 | case WearableType.Eyes: | ||
722 | case WearableType.Hair: | ||
723 | case WearableType.Shape: | ||
724 | case WearableType.Skin: | ||
725 | //case WearableType.Underpants: | ||
726 | TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance); | ||
727 | |||
728 | m_log.WarnFormat("[AVFACTORY]: {0} Default Wearables, passing existing values.", (WearableType)i); | ||
729 | resetwearable = true; | ||
730 | break; | ||
731 | |||
732 | } | ||
572 | continue; | 733 | continue; |
573 | 734 | } | |
735 | |||
574 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); | 736 | InventoryItemBase baseItem = new InventoryItemBase(appearance.Wearables[i][j].ItemID, userID); |
575 | baseItem = invService.GetItem(baseItem); | 737 | baseItem = invService.GetItem(baseItem); |
576 | 738 | ||
577 | if (baseItem != null) | 739 | if (baseItem != null) |
578 | { | 740 | { |
579 | appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID); | 741 | appearance.Wearables[i].Add(appearance.Wearables[i][j].ItemID, baseItem.AssetID); |
742 | int unmodifiedWearableIndexForClosure = i; | ||
743 | m_scene.AssetService.Get(baseItem.AssetID.ToString(), this, | ||
744 | delegate(string x, object y, AssetBase z) | ||
745 | { | ||
746 | if (z == null) | ||
747 | { | ||
748 | TryAndRepairBrokenWearable( | ||
749 | (WearableType)unmodifiedWearableIndexForClosure, invService, | ||
750 | userID, appearance); | ||
751 | } | ||
752 | }); | ||
580 | } | 753 | } |
581 | else | 754 | else |
582 | { | 755 | { |
@@ -584,17 +757,236 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
584 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", | 757 | "[AVFACTORY]: Can't find inventory item {0} for {1}, setting to default", |
585 | appearance.Wearables[i][j].ItemID, (WearableType)i); | 758 | appearance.Wearables[i][j].ItemID, (WearableType)i); |
586 | 759 | ||
587 | appearance.Wearables[i].RemoveItem(appearance.Wearables[i][j].ItemID); | 760 | TryAndRepairBrokenWearable((WearableType)i, invService, userID, appearance); |
761 | resetwearable = true; | ||
762 | |||
588 | } | 763 | } |
589 | } | 764 | } |
590 | } | 765 | } |
766 | |||
767 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
768 | if (appearance.Wearables[(int) WearableType.Eyes] == null) | ||
769 | { | ||
770 | m_log.WarnFormat("[AVFACTORY]: {0} Eyes are Null, passing existing values.", (WearableType.Eyes)); | ||
771 | |||
772 | TryAndRepairBrokenWearable(WearableType.Eyes, invService, userID, appearance); | ||
773 | resetwearable = true; | ||
774 | } | ||
775 | else | ||
776 | { | ||
777 | if (appearance.Wearables[(int) WearableType.Eyes][0].ItemID == UUID.Zero) | ||
778 | { | ||
779 | m_log.WarnFormat("[AVFACTORY]: Eyes are UUID.Zero are broken, {0} {1}", | ||
780 | appearance.Wearables[(int) WearableType.Eyes][0].ItemID, | ||
781 | appearance.Wearables[(int) WearableType.Eyes][0].AssetID); | ||
782 | TryAndRepairBrokenWearable(WearableType.Eyes, invService, userID, appearance); | ||
783 | resetwearable = true; | ||
784 | |||
785 | } | ||
786 | |||
787 | } | ||
788 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
789 | if (appearance.Wearables[(int)WearableType.Shape] == null) | ||
790 | { | ||
791 | m_log.WarnFormat("[AVFACTORY]: {0} shape is Null, passing existing values.", (WearableType.Shape)); | ||
792 | |||
793 | TryAndRepairBrokenWearable(WearableType.Shape, invService, userID, appearance); | ||
794 | resetwearable = true; | ||
795 | } | ||
796 | else | ||
797 | { | ||
798 | if (appearance.Wearables[(int)WearableType.Shape][0].ItemID == UUID.Zero) | ||
799 | { | ||
800 | m_log.WarnFormat("[AVFACTORY]: Shape is UUID.Zero and broken, {0} {1}", | ||
801 | appearance.Wearables[(int)WearableType.Shape][0].ItemID, | ||
802 | appearance.Wearables[(int)WearableType.Shape][0].AssetID); | ||
803 | TryAndRepairBrokenWearable(WearableType.Shape, invService, userID, appearance); | ||
804 | resetwearable = true; | ||
805 | |||
806 | } | ||
807 | |||
808 | } | ||
809 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
810 | if (appearance.Wearables[(int)WearableType.Hair] == null) | ||
811 | { | ||
812 | m_log.WarnFormat("[AVFACTORY]: {0} Hair is Null, passing existing values.", (WearableType.Hair)); | ||
813 | |||
814 | TryAndRepairBrokenWearable(WearableType.Hair, invService, userID, appearance); | ||
815 | resetwearable = true; | ||
816 | } | ||
817 | else | ||
818 | { | ||
819 | if (appearance.Wearables[(int)WearableType.Hair][0].ItemID == UUID.Zero) | ||
820 | { | ||
821 | m_log.WarnFormat("[AVFACTORY]: Hair is UUID.Zero and broken, {0} {1}", | ||
822 | appearance.Wearables[(int)WearableType.Hair][0].ItemID, | ||
823 | appearance.Wearables[(int)WearableType.Hair][0].AssetID); | ||
824 | TryAndRepairBrokenWearable(WearableType.Hair, invService, userID, appearance); | ||
825 | resetwearable = true; | ||
826 | |||
827 | } | ||
828 | |||
829 | } | ||
830 | // I don't know why we have to test for this again... but the above switches do not capture these scenarios for some reason.... | ||
831 | if (appearance.Wearables[(int)WearableType.Skin] == null) | ||
832 | { | ||
833 | m_log.WarnFormat("[AVFACTORY]: {0} Skin is Null, passing existing values.", (WearableType.Skin)); | ||
834 | |||
835 | TryAndRepairBrokenWearable(WearableType.Skin, invService, userID, appearance); | ||
836 | resetwearable = true; | ||
837 | } | ||
838 | else | ||
839 | { | ||
840 | if (appearance.Wearables[(int)WearableType.Skin][0].ItemID == UUID.Zero) | ||
841 | { | ||
842 | m_log.WarnFormat("[AVFACTORY]: Skin is UUID.Zero and broken, {0} {1}", | ||
843 | appearance.Wearables[(int)WearableType.Skin][0].ItemID, | ||
844 | appearance.Wearables[(int)WearableType.Skin][0].AssetID); | ||
845 | TryAndRepairBrokenWearable(WearableType.Skin, invService, userID, appearance); | ||
846 | resetwearable = true; | ||
847 | |||
848 | } | ||
849 | |||
850 | } | ||
851 | if (resetwearable) | ||
852 | { | ||
853 | ScenePresence presence = null; | ||
854 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
855 | { | ||
856 | presence.ControllingClient.SendWearables(presence.Appearance.Wearables, | ||
857 | presence.Appearance.Serial++); | ||
858 | } | ||
859 | } | ||
860 | |||
591 | } | 861 | } |
592 | else | 862 | else |
593 | { | 863 | { |
594 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); | 864 | m_log.WarnFormat("[AVFACTORY]: user {0} has no inventory, appearance isn't going to work", userID); |
595 | } | 865 | } |
596 | } | 866 | } |
867 | private void TryAndRepairBrokenWearable(WearableType type, IInventoryService invService, UUID userID,AvatarAppearance appearance) | ||
868 | { | ||
869 | UUID defaultwearable = GetDefaultItem(type); | ||
870 | if (defaultwearable != UUID.Zero) | ||
871 | { | ||
872 | UUID newInvItem = UUID.Random(); | ||
873 | InventoryItemBase itembase = new InventoryItemBase(newInvItem, userID) | ||
874 | { | ||
875 | AssetID = | ||
876 | defaultwearable, | ||
877 | AssetType | ||
878 | = | ||
879 | (int) | ||
880 | AssetType | ||
881 | .Bodypart, | ||
882 | CreatorId | ||
883 | = | ||
884 | userID | ||
885 | .ToString | ||
886 | (), | ||
887 | //InvType = (int)InventoryType.Wearable, | ||
888 | |||
889 | Description | ||
890 | = | ||
891 | "Failed Wearable Replacement", | ||
892 | Folder = | ||
893 | invService | ||
894 | .GetFolderForType | ||
895 | (userID, | ||
896 | AssetType | ||
897 | .Bodypart) | ||
898 | .ID, | ||
899 | Flags = (uint) type, | ||
900 | Name = Enum.GetName(typeof (WearableType), type), | ||
901 | BasePermissions = (uint) PermissionMask.Copy, | ||
902 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
903 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
904 | GroupPermissions = (uint) PermissionMask.Copy, | ||
905 | NextPermissions = (uint) PermissionMask.Copy | ||
906 | }; | ||
907 | invService.AddItem(itembase); | ||
908 | UUID LinkInvItem = UUID.Random(); | ||
909 | itembase = new InventoryItemBase(LinkInvItem, userID) | ||
910 | { | ||
911 | AssetID = | ||
912 | newInvItem, | ||
913 | AssetType | ||
914 | = | ||
915 | (int) | ||
916 | AssetType | ||
917 | .Link, | ||
918 | CreatorId | ||
919 | = | ||
920 | userID | ||
921 | .ToString | ||
922 | (), | ||
923 | InvType = (int) InventoryType.Wearable, | ||
924 | |||
925 | Description | ||
926 | = | ||
927 | "Failed Wearable Replacement", | ||
928 | Folder = | ||
929 | invService | ||
930 | .GetFolderForType | ||
931 | (userID, | ||
932 | AssetType | ||
933 | .CurrentOutfitFolder) | ||
934 | .ID, | ||
935 | Flags = (uint) type, | ||
936 | Name = Enum.GetName(typeof (WearableType), type), | ||
937 | BasePermissions = (uint) PermissionMask.Copy, | ||
938 | CurrentPermissions = (uint) PermissionMask.Copy, | ||
939 | EveryOnePermissions = (uint) PermissionMask.Copy, | ||
940 | GroupPermissions = (uint) PermissionMask.Copy, | ||
941 | NextPermissions = (uint) PermissionMask.Copy | ||
942 | }; | ||
943 | invService.AddItem(itembase); | ||
944 | appearance.Wearables[(int)type] = new AvatarWearable(newInvItem, GetDefaultItem(type)); | ||
945 | ScenePresence presence = null; | ||
946 | if (m_scene.TryGetScenePresence(userID, out presence)) | ||
947 | { | ||
948 | m_scene.SendInventoryUpdate(presence.ControllingClient, | ||
949 | invService.GetFolderForType(userID, | ||
950 | AssetType | ||
951 | .CurrentOutfitFolder), | ||
952 | false, true); | ||
953 | } | ||
954 | } | ||
955 | } | ||
956 | private UUID GetDefaultItem(WearableType wearable) | ||
957 | { | ||
958 | // These are ruth | ||
959 | UUID ret = UUID.Zero; | ||
960 | switch (wearable) | ||
961 | { | ||
962 | case WearableType.Eyes: | ||
963 | ret = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); | ||
964 | break; | ||
965 | case WearableType.Hair: | ||
966 | ret = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66"); | ||
967 | break; | ||
968 | case WearableType.Pants: | ||
969 | ret = new UUID("00000000-38f9-1111-024e-222222111120"); | ||
970 | break; | ||
971 | case WearableType.Shape: | ||
972 | ret = new UUID("66c41e39-38f9-f75a-024e-585989bfab73"); | ||
973 | break; | ||
974 | case WearableType.Shirt: | ||
975 | ret = new UUID("00000000-38f9-1111-024e-222222111110"); | ||
976 | break; | ||
977 | case WearableType.Skin: | ||
978 | ret = new UUID("77c41e39-38f9-f75a-024e-585989bbabbb"); | ||
979 | break; | ||
980 | case WearableType.Undershirt: | ||
981 | ret = new UUID("16499ebb-3208-ec27-2def-481881728f47"); | ||
982 | break; | ||
983 | case WearableType.Underpants: | ||
984 | ret = new UUID("4ac2e9c7-3671-d229-316a-67717730841d"); | ||
985 | break; | ||
986 | } | ||
597 | 987 | ||
988 | return ret; | ||
989 | } | ||
598 | #endregion | 990 | #endregion |
599 | 991 | ||
600 | #region Client Event Handlers | 992 | #region Client Event Handlers |
@@ -604,12 +996,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
604 | /// <param name="client"></param> | 996 | /// <param name="client"></param> |
605 | private void Client_OnRequestWearables(IClientAPI client) | 997 | private void Client_OnRequestWearables(IClientAPI client) |
606 | { | 998 | { |
607 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); | 999 | Util.FireAndForget(delegate(object x) |
608 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 1000 | { |
609 | if (sp != null) | 1001 | Thread.Sleep(4000); |
610 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | 1002 | |
611 | else | 1003 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); |
612 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | 1004 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
1005 | if (sp != null) | ||
1006 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | ||
1007 | else | ||
1008 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | ||
1009 | }); | ||
613 | } | 1010 | } |
614 | 1011 | ||
615 | /// <summary> | 1012 | /// <summary> |
@@ -618,12 +1015,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
618 | /// <param name="client"></param> | 1015 | /// <param name="client"></param> |
619 | /// <param name="texture"></param> | 1016 | /// <param name="texture"></param> |
620 | /// <param name="visualParam"></param> | 1017 | /// <param name="visualParam"></param> |
621 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) | 1018 | private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) |
622 | { | 1019 | { |
623 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); | 1020 | // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); |
624 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 1021 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
625 | if (sp != null) | 1022 | if (sp != null) |
626 | SetAppearance(sp, textureEntry, visualParams); | 1023 | SetAppearance(sp, textureEntry, visualParams,avSize, cacheItems); |
627 | else | 1024 | else |
628 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); | 1025 | m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); |
629 | } | 1026 | } |
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 58f747b..174642d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -50,7 +50,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
50 | private int m_saydistance = 20; | 50 | private int m_saydistance = 20; |
51 | private int m_shoutdistance = 100; | 51 | private int m_shoutdistance = 100; |
52 | private int m_whisperdistance = 10; | 52 | private int m_whisperdistance = 10; |
53 | 53 | private List<Scene> m_scenes = new List<Scene>(); | |
54 | private List<string> FreezeCache = new List<string>(); | ||
55 | private string m_adminPrefix = ""; | ||
54 | internal object m_syncy = new object(); | 56 | internal object m_syncy = new object(); |
55 | 57 | ||
56 | internal IConfig m_config; | 58 | internal IConfig m_config; |
@@ -77,16 +79,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
77 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); | 79 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); |
78 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); | 80 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); |
79 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); | 81 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); |
82 | m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", ""); | ||
80 | } | 83 | } |
81 | 84 | ||
82 | public virtual void AddRegion(Scene scene) | 85 | public virtual void AddRegion(Scene scene) |
83 | { | 86 | { |
84 | if (!m_enabled) | 87 | if (!m_enabled) return; |
85 | return; | ||
86 | 88 | ||
87 | scene.EventManager.OnNewClient += OnNewClient; | 89 | lock (m_syncy) |
88 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 90 | { |
89 | scene.EventManager.OnChatBroadcast += OnChatBroadcast; | 91 | if (!m_scenes.Contains(scene)) |
92 | { | ||
93 | m_scenes.Add(scene); | ||
94 | scene.EventManager.OnNewClient += OnNewClient; | ||
95 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | ||
96 | scene.EventManager.OnChatBroadcast += OnChatBroadcast; | ||
97 | } | ||
98 | } | ||
90 | 99 | ||
91 | m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, | 100 | m_log.InfoFormat("[CHAT]: Initialized for {0} w:{1} s:{2} S:{3}", scene.RegionInfo.RegionName, |
92 | m_whisperdistance, m_saydistance, m_shoutdistance); | 101 | m_whisperdistance, m_saydistance, m_shoutdistance); |
@@ -98,12 +107,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
98 | 107 | ||
99 | public virtual void RemoveRegion(Scene scene) | 108 | public virtual void RemoveRegion(Scene scene) |
100 | { | 109 | { |
101 | if (!m_enabled) | 110 | if (!m_enabled) return; |
102 | return; | ||
103 | 111 | ||
104 | scene.EventManager.OnNewClient -= OnNewClient; | 112 | lock (m_syncy) |
105 | scene.EventManager.OnChatFromWorld -= OnChatFromWorld; | 113 | { |
106 | scene.EventManager.OnChatBroadcast -= OnChatBroadcast; | 114 | if (m_scenes.Contains(scene)) |
115 | { | ||
116 | scene.EventManager.OnNewClient -= OnNewClient; | ||
117 | scene.EventManager.OnChatFromWorld -= OnChatFromWorld; | ||
118 | scene.EventManager.OnChatBroadcast -= OnChatBroadcast; | ||
119 | m_scenes.Remove(scene); | ||
120 | } | ||
121 | } | ||
107 | } | 122 | } |
108 | 123 | ||
109 | public virtual void Close() | 124 | public virtual void Close() |
@@ -160,7 +175,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
160 | return; | 175 | return; |
161 | } | 176 | } |
162 | 177 | ||
163 | DeliverChatToAvatars(ChatSourceType.Agent, c); | 178 | if (FreezeCache.Contains(c.Sender.AgentId.ToString())) |
179 | { | ||
180 | if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping) | ||
181 | c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false); | ||
182 | } | ||
183 | else | ||
184 | { | ||
185 | DeliverChatToAvatars(ChatSourceType.Agent, c); | ||
186 | } | ||
164 | } | 187 | } |
165 | 188 | ||
166 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) | 189 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) |
@@ -174,11 +197,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
174 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) | 197 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) |
175 | { | 198 | { |
176 | string fromName = c.From; | 199 | string fromName = c.From; |
200 | string fromNamePrefix = ""; | ||
177 | UUID fromID = UUID.Zero; | 201 | UUID fromID = UUID.Zero; |
178 | UUID ownerID = UUID.Zero; | 202 | UUID ownerID = UUID.Zero; |
179 | UUID targetID = c.TargetUUID; | ||
180 | string message = c.Message; | 203 | string message = c.Message; |
181 | Scene scene = (Scene)c.Scene; | 204 | IScene scene = c.Scene; |
205 | UUID destination = c.Destination; | ||
182 | Vector3 fromPos = c.Position; | 206 | Vector3 fromPos = c.Position; |
183 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, | 207 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, |
184 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 208 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
@@ -188,10 +212,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
188 | switch (sourceType) | 212 | switch (sourceType) |
189 | { | 213 | { |
190 | case ChatSourceType.Agent: | 214 | case ChatSourceType.Agent: |
191 | ScenePresence avatar = scene.GetScenePresence(c.Sender.AgentId); | 215 | if (!(scene is Scene)) |
216 | { | ||
217 | m_log.WarnFormat("[CHAT]: scene {0} is not a Scene object, cannot obtain scene presence for {1}", | ||
218 | scene.RegionInfo.RegionName, c.Sender.AgentId); | ||
219 | return; | ||
220 | } | ||
221 | ScenePresence avatar = (scene as Scene).GetScenePresence(c.Sender.AgentId); | ||
192 | fromPos = avatar.AbsolutePosition; | 222 | fromPos = avatar.AbsolutePosition; |
193 | fromName = avatar.Name; | 223 | fromName = avatar.Name; |
194 | fromID = c.Sender.AgentId; | 224 | fromID = c.Sender.AgentId; |
225 | if (avatar.GodLevel >= 200) | ||
226 | { | ||
227 | fromNamePrefix = m_adminPrefix; | ||
228 | } | ||
229 | destination = UUID.Zero; // Avatars cant "SayTo" | ||
195 | ownerID = c.Sender.AgentId; | 230 | ownerID = c.Sender.AgentId; |
196 | 231 | ||
197 | break; | 232 | break; |
@@ -210,38 +245,48 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
210 | message = message.Substring(0, 1000); | 245 | message = message.Substring(0, 1000); |
211 | 246 | ||
212 | // m_log.DebugFormat( | 247 | // m_log.DebugFormat( |
213 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", | 248 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", |
214 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); | 249 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); |
215 | 250 | ||
216 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 251 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
217 | 252 | ||
218 | if (targetID == UUID.Zero) | 253 | foreach (Scene s in m_scenes) |
219 | { | 254 | { |
220 | // This should use ForEachClient, but clients don't have a position. | 255 | // This should use ForEachClient, but clients don't have a position. |
221 | // If camera is moved into client, then camera position can be used | 256 | // If camera is moved into client, then camera position can be used |
222 | scene.ForEachScenePresence( | 257 | // MT: No, it can't, as chat is heard from the avatar position, not |
258 | // the camera position. | ||
259 | s.ForEachScenePresence( | ||
223 | delegate(ScenePresence presence) | 260 | delegate(ScenePresence presence) |
224 | { | 261 | { |
225 | if (TrySendChatMessage( | 262 | if (destination != UUID.Zero && presence.UUID != destination) |
226 | presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) | 263 | return; |
227 | receiverIDs.Add(presence.UUID); | 264 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); |
265 | if (Presencecheck != null) | ||
266 | { | ||
267 | // This will pass all chat from objects. Not | ||
268 | // perfect, but it will do. For now. Better | ||
269 | // than the prior behavior of muting all | ||
270 | // objects on a parcel with access restrictions | ||
271 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | ||
272 | { | ||
273 | if (destination != UUID.Zero) | ||
274 | { | ||
275 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, true)) | ||
276 | receiverIDs.Add(presence.UUID); | ||
277 | } | ||
278 | else | ||
279 | { | ||
280 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, ownerID, fromNamePrefix + fromName, c.Type, message, sourceType, false)) | ||
281 | receiverIDs.Add(presence.UUID); | ||
282 | } | ||
283 | } | ||
284 | } | ||
228 | } | 285 | } |
229 | ); | 286 | ); |
230 | } | 287 | } |
231 | else | 288 | |
232 | { | 289 | (scene as Scene).EventManager.TriggerOnChatToClients( |
233 | // This is a send to a specific client eg from llRegionSayTo | ||
234 | // no need to check distance etc, jand send is as say | ||
235 | ScenePresence presence = scene.GetScenePresence(targetID); | ||
236 | if (presence != null && !presence.IsChildAgent) | ||
237 | { | ||
238 | if (TrySendChatMessage( | ||
239 | presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true)) | ||
240 | receiverIDs.Add(presence.UUID); | ||
241 | } | ||
242 | } | ||
243 | |||
244 | scene.EventManager.TriggerOnChatToClients( | ||
245 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | 290 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); |
246 | } | 291 | } |
247 | 292 | ||
@@ -280,28 +325,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
280 | } | 325 | } |
281 | 326 | ||
282 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 327 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
283 | |||
284 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 328 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
285 | 329 | ||
286 | ((Scene)c.Scene).ForEachRootClient( | 330 | if (c.Scene != null) |
287 | delegate(IClientAPI client) | 331 | { |
288 | { | 332 | ((Scene)c.Scene).ForEachRootClient |
289 | // don't forward SayOwner chat from objects to | 333 | ( |
290 | // non-owner agents | 334 | delegate(IClientAPI client) |
291 | if ((c.Type == ChatTypeEnum.Owner) && | 335 | { |
292 | (null != c.SenderObject) && | 336 | // don't forward SayOwner chat from objects to |
293 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 337 | // non-owner agents |
294 | return; | 338 | if ((c.Type == ChatTypeEnum.Owner) && |
295 | 339 | (null != c.SenderObject) && | |
296 | client.SendChatMessage( | 340 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) |
297 | c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID, | 341 | return; |
298 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 342 | |
299 | 343 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID, | |
300 | receiverIDs.Add(client.AgentId); | 344 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); |
301 | }); | 345 | receiverIDs.Add(client.AgentId); |
302 | 346 | } | |
303 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | 347 | ); |
304 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | 348 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( |
349 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | ||
350 | } | ||
305 | } | 351 | } |
306 | 352 | ||
307 | /// <summary> | 353 | /// <summary> |
@@ -326,21 +372,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
326 | UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type, | 372 | UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type, |
327 | string message, ChatSourceType src, bool ignoreDistance) | 373 | string message, ChatSourceType src, bool ignoreDistance) |
328 | { | 374 | { |
375 | // don't send chat to child agents | ||
376 | if (presence.IsChildAgent) return false; | ||
377 | |||
329 | Vector3 fromRegionPos = fromPos + regionPos; | 378 | Vector3 fromRegionPos = fromPos + regionPos; |
330 | Vector3 toRegionPos = presence.AbsolutePosition + | 379 | Vector3 toRegionPos = presence.AbsolutePosition + |
331 | new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, | 380 | new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, |
332 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 381 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
333 | 382 | ||
334 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); | 383 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); |
335 | 384 | ||
336 | if (!ignoreDistance) | 385 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || |
386 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
387 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
337 | { | 388 | { |
338 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || | 389 | return false; |
339 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
340 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
341 | { | ||
342 | return false; | ||
343 | } | ||
344 | } | 390 | } |
345 | 391 | ||
346 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView | 392 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView |
@@ -350,5 +396,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
350 | 396 | ||
351 | return true; | 397 | return true; |
352 | } | 398 | } |
399 | |||
400 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
401 | public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
402 | { | ||
403 | System.Threading.Timer Timer; | ||
404 | if (flags == 0) | ||
405 | { | ||
406 | FreezeCache.Add(target.ToString()); | ||
407 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
408 | Timer = new System.Threading.Timer(timeCB, target, 30000, 0); | ||
409 | Timers.Add(target, Timer); | ||
410 | } | ||
411 | else | ||
412 | { | ||
413 | FreezeCache.Remove(target.ToString()); | ||
414 | Timers.TryGetValue(target, out Timer); | ||
415 | Timers.Remove(target); | ||
416 | Timer.Dispose(); | ||
417 | } | ||
418 | } | ||
419 | |||
420 | private void OnEndParcelFrozen(object avatar) | ||
421 | { | ||
422 | UUID target = (UUID)avatar; | ||
423 | FreezeCache.Remove(target.ToString()); | ||
424 | System.Threading.Timer Timer; | ||
425 | Timers.TryGetValue(target, out Timer); | ||
426 | Timers.Remove(target); | ||
427 | Timer.Dispose(); | ||
428 | } | ||
353 | } | 429 | } |
354 | } \ No newline at end of file | 430 | } |
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 5a7446f..9fa9be1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | |||
@@ -32,6 +32,24 @@ using OpenMetaverse; | |||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | using System; | ||
36 | using System.Reflection; | ||
37 | using System.Collections; | ||
38 | using System.Collections.Specialized; | ||
39 | using System.Reflection; | ||
40 | using System.IO; | ||
41 | using System.Web; | ||
42 | using System.Xml; | ||
43 | using log4net; | ||
44 | using Mono.Addins; | ||
45 | using OpenMetaverse.Messages.Linden; | ||
46 | using OpenMetaverse.StructuredData; | ||
47 | using OpenSim.Framework.Capabilities; | ||
48 | using OpenSim.Framework.Servers; | ||
49 | using OpenSim.Framework.Servers.HttpServer; | ||
50 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
51 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
52 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
35 | 53 | ||
36 | using Mono.Addins; | 54 | using Mono.Addins; |
37 | 55 | ||
@@ -40,11 +58,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")] | 58 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")] |
41 | public class GodsModule : INonSharedRegionModule, IGodsModule | 59 | public class GodsModule : INonSharedRegionModule, IGodsModule |
42 | { | 60 | { |
61 | private static readonly ILog m_log = | ||
62 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
63 | |||
43 | /// <summary>Special UUID for actions that apply to all agents</summary> | 64 | /// <summary>Special UUID for actions that apply to all agents</summary> |
44 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); | 65 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); |
45 | 66 | ||
46 | protected Scene m_scene; | 67 | protected Scene m_scene; |
47 | protected IDialogModule m_dialogModule; | 68 | protected IDialogModule m_dialogModule; |
69 | |||
70 | protected Dictionary<UUID, string> m_capsDict = | ||
71 | new Dictionary<UUID, string>(); | ||
72 | |||
48 | protected IDialogModule DialogModule | 73 | protected IDialogModule DialogModule |
49 | { | 74 | { |
50 | get | 75 | get |
@@ -65,6 +90,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
65 | m_scene = scene; | 90 | m_scene = scene; |
66 | m_scene.RegisterModuleInterface<IGodsModule>(this); | 91 | m_scene.RegisterModuleInterface<IGodsModule>(this); |
67 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 92 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
93 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
94 | m_scene.EventManager.OnClientClosed += OnClientClosed; | ||
95 | scene.EventManager.OnIncomingInstantMessage += | ||
96 | OnIncomingInstantMessage; | ||
68 | } | 97 | } |
69 | 98 | ||
70 | public void RemoveRegion(Scene scene) | 99 | public void RemoveRegion(Scene scene) |
@@ -98,6 +127,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
98 | client.OnRequestGodlikePowers -= RequestGodlikePowers; | 127 | client.OnRequestGodlikePowers -= RequestGodlikePowers; |
99 | } | 128 | } |
100 | 129 | ||
130 | private void OnClientClosed(UUID agentID, Scene scene) | ||
131 | { | ||
132 | m_capsDict.Remove(agentID); | ||
133 | } | ||
134 | |||
135 | private void OnRegisterCaps(UUID agentID, Caps caps) | ||
136 | { | ||
137 | string uri = "/CAPS/" + UUID.Random(); | ||
138 | m_capsDict[agentID] = uri; | ||
139 | |||
140 | caps.RegisterHandler("UntrustedSimulatorMessage", | ||
141 | new RestStreamHandler("POST", uri, | ||
142 | HandleUntrustedSimulatorMessage)); | ||
143 | } | ||
144 | |||
145 | private string HandleUntrustedSimulatorMessage(string request, | ||
146 | string path, string param, IOSHttpRequest httpRequest, | ||
147 | IOSHttpResponse httpResponse) | ||
148 | { | ||
149 | OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
150 | |||
151 | string message = osd["message"].AsString(); | ||
152 | |||
153 | if (message == "GodKickUser") | ||
154 | { | ||
155 | OSDMap body = (OSDMap)osd["body"]; | ||
156 | OSDArray userInfo = (OSDArray)body["UserInfo"]; | ||
157 | OSDMap userData = (OSDMap)userInfo[0]; | ||
158 | |||
159 | UUID agentID = userData["AgentID"].AsUUID(); | ||
160 | UUID godID = userData["GodID"].AsUUID(); | ||
161 | UUID godSessionID = userData["GodSessionID"].AsUUID(); | ||
162 | uint kickFlags = userData["KickFlags"].AsUInteger(); | ||
163 | string reason = userData["Reason"].AsString(); | ||
164 | |||
165 | ScenePresence god = m_scene.GetScenePresence(godID); | ||
166 | if (god == null || god.ControllingClient.SessionId != godSessionID) | ||
167 | return String.Empty; | ||
168 | |||
169 | KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason)); | ||
170 | } | ||
171 | else | ||
172 | { | ||
173 | m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message); | ||
174 | } | ||
175 | return String.Empty; | ||
176 | } | ||
177 | |||
101 | public void RequestGodlikePowers( | 178 | public void RequestGodlikePowers( |
102 | UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) | 179 | UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) |
103 | { | 180 | { |
@@ -146,76 +223,86 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
146 | /// <param name="reason">The message to send to the user after it's been turned into a field</param> | 223 | /// <param name="reason">The message to send to the user after it's been turned into a field</param> |
147 | public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) | 224 | public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) |
148 | { | 225 | { |
149 | UUID kickUserID = ALL_AGENTS; | 226 | if (!m_scene.Permissions.IsGod(godID)) |
150 | 227 | return; | |
228 | |||
151 | ScenePresence sp = m_scene.GetScenePresence(agentID); | 229 | ScenePresence sp = m_scene.GetScenePresence(agentID); |
152 | 230 | ||
153 | if (sp != null || agentID == kickUserID) | 231 | if (sp == null && agentID != ALL_AGENTS) |
154 | { | 232 | { |
155 | if (m_scene.Permissions.IsGod(godID)) | 233 | IMessageTransferModule transferModule = |
234 | m_scene.RequestModuleInterface<IMessageTransferModule>(); | ||
235 | if (transferModule != null) | ||
156 | { | 236 | { |
157 | if (kickflags == 0) | 237 | m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID); |
158 | { | 238 | transferModule.SendInstantMessage(new GridInstantMessage( |
159 | if (agentID == kickUserID) | 239 | m_scene, godID, "God", agentID, (byte)250, false, |
160 | { | 240 | Utils.BytesToString(reason), UUID.Zero, true, |
161 | string reasonStr = Utils.BytesToString(reason); | 241 | new Vector3(), new byte[] {(byte)kickflags}, true), |
162 | 242 | delegate(bool success) {} ); | |
163 | m_scene.ForEachClient( | 243 | } |
164 | delegate(IClientAPI controller) | 244 | return; |
165 | { | 245 | } |
166 | if (controller.AgentId != godID) | ||
167 | controller.Kick(reasonStr); | ||
168 | } | ||
169 | ); | ||
170 | |||
171 | // This is a bit crude. It seems the client will be null before it actually stops the thread | ||
172 | // The thread will kill itself eventually :/ | ||
173 | // Is there another way to make sure *all* clients get this 'inter region' message? | ||
174 | m_scene.ForEachRootClient( | ||
175 | delegate(IClientAPI client) | ||
176 | { | ||
177 | if (client.AgentId != godID) | ||
178 | { | ||
179 | client.Close(); | ||
180 | } | ||
181 | } | ||
182 | ); | ||
183 | } | ||
184 | else | ||
185 | { | ||
186 | m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent); | ||
187 | 246 | ||
188 | sp.ControllingClient.Kick(Utils.BytesToString(reason)); | 247 | switch (kickflags) |
189 | sp.ControllingClient.Close(); | 248 | { |
190 | } | 249 | case 0: |
191 | } | 250 | if (sp != null) |
192 | 251 | { | |
193 | if (kickflags == 1) | 252 | KickPresence(sp, Utils.BytesToString(reason)); |
194 | { | ||
195 | sp.AllowMovement = false; | ||
196 | if (DialogModule != null) | ||
197 | { | ||
198 | DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
199 | DialogModule.SendAlertToUser(godID, "User Frozen"); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | if (kickflags == 2) | ||
204 | { | ||
205 | sp.AllowMovement = true; | ||
206 | if (DialogModule != null) | ||
207 | { | ||
208 | DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
209 | DialogModule.SendAlertToUser(godID, "User Unfrozen"); | ||
210 | } | ||
211 | } | ||
212 | } | 253 | } |
213 | else | 254 | else if (agentID == ALL_AGENTS) |
214 | { | 255 | { |
215 | if (DialogModule != null) | 256 | m_scene.ForEachRootScenePresence( |
216 | DialogModule.SendAlertToUser(godID, "Kick request denied"); | 257 | delegate(ScenePresence p) |
258 | { | ||
259 | if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID))) | ||
260 | KickPresence(p, Utils.BytesToString(reason)); | ||
261 | } | ||
262 | ); | ||
263 | } | ||
264 | break; | ||
265 | case 1: | ||
266 | if (sp != null) | ||
267 | { | ||
268 | sp.AllowMovement = false; | ||
269 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
270 | m_dialogModule.SendAlertToUser(godID, "User Frozen"); | ||
217 | } | 271 | } |
272 | break; | ||
273 | case 2: | ||
274 | if (sp != null) | ||
275 | { | ||
276 | sp.AllowMovement = true; | ||
277 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
278 | m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); | ||
279 | } | ||
280 | break; | ||
281 | default: | ||
282 | break; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | private void KickPresence(ScenePresence sp, string reason) | ||
287 | { | ||
288 | if (sp.IsChildAgent) | ||
289 | return; | ||
290 | sp.ControllingClient.Kick(reason); | ||
291 | sp.MakeChildAgent(); | ||
292 | sp.ControllingClient.Close(); | ||
293 | } | ||
294 | |||
295 | private void OnIncomingInstantMessage(GridInstantMessage msg) | ||
296 | { | ||
297 | if (msg.dialog == (uint)250) // Nonlocal kick | ||
298 | { | ||
299 | UUID agentID = new UUID(msg.toAgentID); | ||
300 | string reason = msg.message; | ||
301 | UUID godID = new UUID(msg.fromAgentID); | ||
302 | uint kickMode = (uint)msg.binaryBucket[0]; | ||
303 | |||
304 | KickUser(godID, UUID.Zero, agentID, kickMode, Util.StringToBytes1024(reason)); | ||
218 | } | 305 | } |
219 | } | 306 | } |
220 | } | 307 | } |
221 | } \ No newline at end of file | 308 | } |
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 fa935cd..1627f6c 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"] = msg.RegionID.ToString(); | 731 | gim["region_id"] = 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 7d763fa..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,25 +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 | m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list."); | ||
186 | |||
187 | foreach (GridInstantMessage im in msglist) | ||
188 | { | 189 | { |
189 | if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) | 190 | foreach (GridInstantMessage im in msglist) |
190 | // send it directly or else the item will be given twice | ||
191 | client.SendInstantMessage(im); | ||
192 | else | ||
193 | { | 191 | { |
194 | // Send through scene event manager so all modules get a chance | 192 | if (im.dialog == (byte)InstantMessageDialog.InventoryOffered) |
195 | // to look at this message before it gets delivered. | 193 | // send it directly or else the item will be given twice |
196 | // | 194 | client.SendInstantMessage(im); |
197 | // Needed for proper state management for stored group | 195 | else |
198 | // invitations | 196 | { |
199 | // | 197 | // Send through scene event manager so all modules get a chance |
200 | Scene s = FindScene(client.AgentId); | 198 | // to look at this message before it gets delivered. |
201 | if (s != null) | 199 | // |
202 | 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 | } | ||
203 | } | 210 | } |
204 | } | 211 | } |
205 | } | 212 | } |
@@ -211,24 +218,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
211 | im.dialog != (byte)InstantMessageDialog.MessageFromAgent && | 218 | im.dialog != (byte)InstantMessageDialog.MessageFromAgent && |
212 | im.dialog != (byte)InstantMessageDialog.GroupNotice && | 219 | im.dialog != (byte)InstantMessageDialog.GroupNotice && |
213 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && | 220 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && |
214 | im.dialog != (byte)InstantMessageDialog.InventoryOffered) | 221 | im.dialog != (byte)InstantMessageDialog.InventoryOffered && |
222 | im.dialog != (byte)InstantMessageDialog.TaskInventoryOffered) | ||
215 | { | 223 | { |
216 | return; | 224 | return; |
217 | } | 225 | } |
218 | 226 | ||
219 | if (!m_ForwardOfflineGroupMessages) | ||
220 | { | ||
221 | if (im.dialog == (byte)InstantMessageDialog.GroupNotice || | ||
222 | im.dialog == (byte)InstantMessageDialog.GroupInvitation) | ||
223 | return; | ||
224 | } | ||
225 | |||
226 | Scene scene = FindScene(new UUID(im.fromAgentID)); | 227 | Scene scene = FindScene(new UUID(im.fromAgentID)); |
227 | if (scene == null) | 228 | if (scene == null) |
228 | scene = m_SceneList[0]; | 229 | scene = m_SceneList[0]; |
229 | 230 | ||
230 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( | 231 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( |
231 | "POST", m_RestURL+"/SaveMessage/", im); | 232 | "POST", m_RestURL+"/SaveMessage/?scope=" + |
233 | scene.RegionInfo.ScopeID.ToString(), im); | ||
232 | 234 | ||
233 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) | 235 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) |
234 | { | 236 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index 98285e9..659b178 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -652,4 +652,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
652 | m_assetsLoaded = true; | 652 | m_assetsLoaded = true; |
653 | } | 653 | } |
654 | } | 654 | } |
655 | } \ No newline at end of file | 655 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 849449b..f4f9e2d 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.Message); | 541 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message); |
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 bcb7f42..ae58dfd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -177,8 +177,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
177 | if (im.binaryBucket.Length < 17) // Invalid | 177 | if (im.binaryBucket.Length < 17) // Invalid |
178 | return; | 178 | return; |
179 | 179 | ||
180 | UUID receipientID = new UUID(im.toAgentID); | 180 | UUID recipientID = new UUID(im.toAgentID); |
181 | ScenePresence user = scene.GetScenePresence(receipientID); | 181 | ScenePresence user = scene.GetScenePresence(recipientID); |
182 | UUID copyID; | 182 | UUID copyID; |
183 | 183 | ||
184 | // First byte is the asset type | 184 | // First byte is the asset type |
@@ -193,7 +193,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
193 | folderID, new UUID(im.toAgentID)); | 193 | folderID, new UUID(im.toAgentID)); |
194 | 194 | ||
195 | InventoryFolderBase folderCopy | 195 | InventoryFolderBase folderCopy |
196 | = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); | 196 | = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero); |
197 | 197 | ||
198 | if (folderCopy == null) | 198 | if (folderCopy == null) |
199 | { | 199 | { |
@@ -246,6 +246,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
246 | im.imSessionID = itemID.Guid; | 246 | im.imSessionID = itemID.Guid; |
247 | } | 247 | } |
248 | 248 | ||
249 | im.offline = 0; | ||
250 | |||
249 | // Send the IM to the recipient. The item is already | 251 | // Send the IM to the recipient. The item is already |
250 | // in their inventory, so it will not be lost if | 252 | // in their inventory, so it will not be lost if |
251 | // they are offline. | 253 | // they are offline. |
@@ -265,8 +267,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
265 | }); | 267 | }); |
266 | } | 268 | } |
267 | } | 269 | } |
268 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) | 270 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || |
271 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
269 | { | 272 | { |
273 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip | ||
274 | IInventoryService invService = scene.InventoryService; | ||
275 | |||
276 | // Special case: folder redirect. | ||
277 | // RLV uses this | ||
278 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
279 | { | ||
280 | InventoryFolderBase folder = new InventoryFolderBase(inventoryID, client.AgentId); | ||
281 | folder = invService.GetFolder(folder); | ||
282 | |||
283 | if (folder != null) | ||
284 | { | ||
285 | if (im.binaryBucket.Length >= 16) | ||
286 | { | ||
287 | UUID destFolderID = new UUID(im.binaryBucket, 0); | ||
288 | if (destFolderID != UUID.Zero) | ||
289 | { | ||
290 | InventoryFolderBase destFolder = new InventoryFolderBase(destFolderID, client.AgentId); | ||
291 | destFolder = invService.GetFolder(destFolder); | ||
292 | if (destFolder != null) | ||
293 | { | ||
294 | if (folder.ParentID != destFolder.ID) | ||
295 | { | ||
296 | folder.ParentID = destFolder.ID; | ||
297 | invService.MoveFolder(folder); | ||
298 | client.SendBulkUpdateInventory(folder); | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | } | ||
303 | } | ||
304 | } | ||
305 | |||
270 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); | 306 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
271 | 307 | ||
272 | if (user != null) // Local | 308 | if (user != null) // Local |
@@ -276,27 +312,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
276 | else | 312 | else |
277 | { | 313 | { |
278 | if (m_TransferModule != null) | 314 | if (m_TransferModule != null) |
279 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { | 315 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); |
280 | |||
281 | // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011 | ||
282 | // and is apparently supposed to fix bulk inventory updates after accepting items. But | ||
283 | // instead it appears to cause two copies of an accepted folder for the receiving user in | ||
284 | // at least some cases. Folder/item update is already done when the offer is made (see code above) | ||
285 | |||
286 | // // Send BulkUpdateInventory | ||
287 | // IInventoryService invService = scene.InventoryService; | ||
288 | // UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip | ||
289 | // | ||
290 | // InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); | ||
291 | // folder = invService.GetFolder(folder); | ||
292 | // | ||
293 | // ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); | ||
294 | // | ||
295 | // // If the user has left the scene by the time the message comes back then we can't send | ||
296 | // // them the update. | ||
297 | // if (fromUser != null) | ||
298 | // fromUser.ControllingClient.SendBulkUpdateInventory(folder); | ||
299 | }); | ||
300 | } | 316 | } |
301 | } | 317 | } |
302 | 318 | ||
@@ -409,6 +425,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
409 | previousParentFolderID = folder.ParentID; | 425 | previousParentFolderID = folder.ParentID; |
410 | folder.ParentID = trashFolder.ID; | 426 | folder.ParentID = trashFolder.ID; |
411 | invService.MoveFolder(folder); | 427 | invService.MoveFolder(folder); |
428 | client.SendBulkUpdateInventory(folder); | ||
412 | } | 429 | } |
413 | } | 430 | } |
414 | 431 | ||
@@ -522,22 +539,113 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
522 | /// | 539 | /// |
523 | /// </summary> | 540 | /// </summary> |
524 | /// <param name="msg"></param> | 541 | /// <param name="msg"></param> |
525 | private void OnGridInstantMessage(GridInstantMessage msg) | 542 | private void OnGridInstantMessage(GridInstantMessage im) |
526 | { | 543 | { |
527 | // Check if this is ours to handle | 544 | // Check if this is ours to handle |
528 | // | 545 | // |
529 | Scene scene = FindClientScene(new UUID(msg.toAgentID)); | 546 | Scene scene = FindClientScene(new UUID(im.toAgentID)); |
530 | 547 | ||
531 | if (scene == null) | 548 | if (scene == null) |
532 | return; | 549 | return; |
533 | 550 | ||
534 | // Find agent to deliver to | 551 | // Find agent to deliver to |
535 | // | 552 | // |
536 | ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); | 553 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
554 | if (user == null) | ||
555 | return; | ||
556 | |||
557 | // This requires a little bit of processing because we have to make the | ||
558 | // new item visible in the recipient's inventory here | ||
559 | // | ||
560 | if (im.dialog == (byte) InstantMessageDialog.InventoryOffered) | ||
561 | { | ||
562 | if (im.binaryBucket.Length < 17) // Invalid | ||
563 | return; | ||
564 | |||
565 | UUID recipientID = new UUID(im.toAgentID); | ||
566 | |||
567 | // First byte is the asset type | ||
568 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
569 | |||
570 | if (AssetType.Folder == assetType) | ||
571 | { | ||
572 | UUID folderID = new UUID(im.binaryBucket, 1); | ||
537 | 573 | ||
538 | // Just forward to local handling | 574 | InventoryFolderBase given = |
539 | OnInstantMessage(user.ControllingClient, msg); | 575 | new InventoryFolderBase(folderID, recipientID); |
576 | InventoryFolderBase folder = | ||
577 | scene.InventoryService.GetFolder(given); | ||
540 | 578 | ||
579 | if (folder != null) | ||
580 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
581 | } | ||
582 | else | ||
583 | { | ||
584 | UUID itemID = new UUID(im.binaryBucket, 1); | ||
585 | |||
586 | InventoryItemBase given = | ||
587 | new InventoryItemBase(itemID, recipientID); | ||
588 | InventoryItemBase item = | ||
589 | scene.InventoryService.GetItem(given); | ||
590 | |||
591 | if (item != null) | ||
592 | { | ||
593 | user.ControllingClient.SendBulkUpdateInventory(item); | ||
594 | } | ||
595 | } | ||
596 | user.ControllingClient.SendInstantMessage(im); | ||
597 | } | ||
598 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered) | ||
599 | { | ||
600 | if (im.binaryBucket.Length < 1) // Invalid | ||
601 | return; | ||
602 | |||
603 | UUID recipientID = new UUID(im.toAgentID); | ||
604 | |||
605 | // Bucket is the asset type | ||
606 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
607 | |||
608 | if (AssetType.Folder == assetType) | ||
609 | { | ||
610 | UUID folderID = new UUID(im.imSessionID); | ||
611 | |||
612 | InventoryFolderBase given = | ||
613 | new InventoryFolderBase(folderID, recipientID); | ||
614 | InventoryFolderBase folder = | ||
615 | scene.InventoryService.GetFolder(given); | ||
616 | |||
617 | if (folder != null) | ||
618 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
619 | } | ||
620 | else | ||
621 | { | ||
622 | UUID itemID = new UUID(im.imSessionID); | ||
623 | |||
624 | InventoryItemBase given = | ||
625 | new InventoryItemBase(itemID, recipientID); | ||
626 | InventoryItemBase item = | ||
627 | scene.InventoryService.GetItem(given); | ||
628 | |||
629 | if (item != null) | ||
630 | { | ||
631 | user.ControllingClient.SendBulkUpdateInventory(item); | ||
632 | } | ||
633 | } | ||
634 | |||
635 | // Fix up binary bucket since this may be 17 chars long here | ||
636 | Byte[] bucket = new Byte[1]; | ||
637 | bucket[0] = im.binaryBucket[0]; | ||
638 | im.binaryBucket = bucket; | ||
639 | |||
640 | user.ControllingClient.SendInstantMessage(im); | ||
641 | } | ||
642 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || | ||
643 | im.dialog == (byte) InstantMessageDialog.InventoryDeclined || | ||
644 | im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined || | ||
645 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
646 | { | ||
647 | user.ControllingClient.SendInstantMessage(im); | ||
648 | } | ||
541 | } | 649 | } |
542 | } | 650 | } |
543 | } | 651 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index 7f4606b..0c64f19 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("TP invite with message {0}, type {1}", message, lureType); | 168 | m_log.DebugFormat("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) |