diff options
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r-- | OpenSim/Framework/AvatarAppearance.cs | 72 | ||||
-rw-r--r-- | OpenSim/Framework/ChildAgentDataUpdate.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Util.cs | 42 |
3 files changed, 96 insertions, 20 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index a68de57..21e2233 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -405,31 +405,40 @@ namespace OpenSim.Framework | |||
405 | /// </remarks> | 405 | /// </remarks> |
406 | public List<AvatarAttachment> GetAttachments() | 406 | public List<AvatarAttachment> GetAttachments() |
407 | { | 407 | { |
408 | |||
409 | |||
408 | lock (m_attachments) | 410 | lock (m_attachments) |
409 | { | 411 | { |
410 | List<AvatarAttachment> alist = new List<AvatarAttachment>(); | 412 | List<AvatarAttachment> alist = new List<AvatarAttachment>(); |
411 | foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) | 413 | foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) |
412 | { | 414 | { |
413 | foreach (AvatarAttachment attach in kvp.Value) | 415 | foreach (AvatarAttachment attach in kvp.Value) |
414 | alist.Add(new AvatarAttachment(attach)); | 416 | alist.Add(new AvatarAttachment(attach)); |
415 | } | 417 | } |
416 | 418 | return alist; | |
417 | return alist; | 419 | } } |
418 | } | ||
419 | } | ||
420 | 420 | ||
421 | internal void AppendAttachment(AvatarAttachment attach) | 421 | internal void AppendAttachment(AvatarAttachment attach) |
422 | { | 422 | { |
423 | // m_log.DebugFormat( | ||
424 | // "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}", | ||
425 | // attach.ItemID, attach.AssetID, attach.AttachPoint); | ||
426 | |||
423 | lock (m_attachments) | 427 | lock (m_attachments) |
424 | { | 428 | { |
425 | if (!m_attachments.ContainsKey(attach.AttachPoint)) | 429 | if (!m_attachments.ContainsKey(attach.AttachPoint)) |
426 | m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); | 430 | m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); |
431 | |||
427 | m_attachments[attach.AttachPoint].Add(attach); | 432 | m_attachments[attach.AttachPoint].Add(attach); |
428 | } | 433 | } |
429 | } | 434 | } |
430 | 435 | ||
431 | internal void ReplaceAttachment(AvatarAttachment attach) | 436 | internal void ReplaceAttachment(AvatarAttachment attach) |
432 | { | 437 | { |
438 | // m_log.DebugFormat( | ||
439 | // "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}", | ||
440 | // attach.ItemID, attach.AssetID, attach.AttachPoint); | ||
441 | |||
433 | lock (m_attachments) | 442 | lock (m_attachments) |
434 | { | 443 | { |
435 | m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); | 444 | m_attachments[attach.AttachPoint] = new List<AvatarAttachment>(); |
@@ -438,7 +447,7 @@ namespace OpenSim.Framework | |||
438 | } | 447 | } |
439 | 448 | ||
440 | /// <summary> | 449 | /// <summary> |
441 | /// Add an attachment | 450 | /// Set an attachment |
442 | /// </summary> | 451 | /// </summary> |
443 | /// <remarks> | 452 | /// <remarks> |
444 | /// If the attachpoint has the | 453 | /// If the attachpoint has the |
@@ -454,13 +463,13 @@ namespace OpenSim.Framework | |||
454 | /// </returns> | 463 | /// </returns> |
455 | public bool SetAttachment(int attachpoint, UUID item, UUID asset) | 464 | public bool SetAttachment(int attachpoint, UUID item, UUID asset) |
456 | { | 465 | { |
457 | if (attachpoint == 0) | ||
458 | return false; | ||
459 | |||
460 | // m_log.DebugFormat( | 466 | // m_log.DebugFormat( |
461 | // "[AVATAR APPEARANCE]: Setting attachment at {0} with item ID {1}, asset ID {2}", | 467 | // "[AVATAR APPEARANCE]: Setting attachment at {0} with item ID {1}, asset ID {2}", |
462 | // attachpoint, item, asset); | 468 | // attachpoint, item, asset); |
463 | 469 | ||
470 | if (attachpoint == 0) | ||
471 | return false; | ||
472 | |||
464 | if (item == UUID.Zero) | 473 | if (item == UUID.Zero) |
465 | { | 474 | { |
466 | lock (m_attachments) | 475 | lock (m_attachments) |
@@ -470,12 +479,21 @@ namespace OpenSim.Framework | |||
470 | m_attachments.Remove(attachpoint); | 479 | m_attachments.Remove(attachpoint); |
471 | return true; | 480 | return true; |
472 | } | 481 | } |
473 | return false; | ||
474 | } | 482 | } |
483 | |||
484 | return false; | ||
475 | } | 485 | } |
476 | 486 | ||
477 | // check if the item is already attached at this point | 487 | // When a user logs in, the attachment item ids are pulled from persistence in the Avatars table. However, |
478 | if (GetAttachpoint(item) == (attachpoint & 0x7F)) | 488 | // the asset ids are not saved. When the avatar enters a simulator the attachments are set again. If |
489 | // we simply perform an item check here then the asset ids (which are now present) are never set, and NPC attachments | ||
490 | // later fail unless the attachment is detached and reattached. | ||
491 | // | ||
492 | // Therefore, we will carry on with the set if the existing attachment has no asset id. | ||
493 | AvatarAttachment existingAttachment = GetAttachmentForItem(item); | ||
494 | if (existingAttachment != null | ||
495 | && existingAttachment.AssetID != UUID.Zero | ||
496 | && existingAttachment.AttachPoint == (attachpoint & 0x7F)) | ||
479 | { | 497 | { |
480 | // m_log.DebugFormat("[AVATAR APPEARANCE] attempt to attach an already attached item {0}",item); | 498 | // m_log.DebugFormat("[AVATAR APPEARANCE] attempt to attach an already attached item {0}",item); |
481 | return false; | 499 | return false; |
@@ -492,9 +510,30 @@ namespace OpenSim.Framework | |||
492 | { | 510 | { |
493 | ReplaceAttachment(new AvatarAttachment(attachpoint,item, asset)); | 511 | ReplaceAttachment(new AvatarAttachment(attachpoint,item, asset)); |
494 | } | 512 | } |
513 | |||
495 | return true; | 514 | return true; |
496 | } | 515 | } |
497 | 516 | ||
517 | /// <summary> | ||
518 | /// If the item is already attached, return it. | ||
519 | /// </summary> | ||
520 | /// <param name="itemID"></param> | ||
521 | /// <returns>Returns null if this item is not attached.</returns> | ||
522 | public AvatarAttachment GetAttachmentForItem(UUID itemID) | ||
523 | { | ||
524 | lock (m_attachments) | ||
525 | { | ||
526 | foreach (KeyValuePair<int, List<AvatarAttachment>> kvp in m_attachments) | ||
527 | { | ||
528 | int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return a.ItemID == itemID; }); | ||
529 | if (index >= 0) | ||
530 | return kvp.Value[index]; | ||
531 | } | ||
532 | } | ||
533 | |||
534 | return null; | ||
535 | } | ||
536 | |||
498 | public int GetAttachpoint(UUID itemID) | 537 | public int GetAttachpoint(UUID itemID) |
499 | { | 538 | { |
500 | lock (m_attachments) | 539 | lock (m_attachments) |
@@ -505,9 +544,8 @@ namespace OpenSim.Framework | |||
505 | if (index >= 0) | 544 | if (index >= 0) |
506 | return kvp.Key; | 545 | return kvp.Key; |
507 | } | 546 | } |
508 | |||
509 | return 0; | ||
510 | } | 547 | } |
548 | return 0; | ||
511 | } | 549 | } |
512 | 550 | ||
513 | public bool DetachAttachment(UUID itemID) | 551 | public bool DetachAttachment(UUID itemID) |
@@ -521,23 +559,23 @@ namespace OpenSim.Framework | |||
521 | { | 559 | { |
522 | // Remove it from the list of attachments at that attach point | 560 | // Remove it from the list of attachments at that attach point |
523 | m_attachments[kvp.Key].RemoveAt(index); | 561 | m_attachments[kvp.Key].RemoveAt(index); |
524 | 562 | ||
525 | // And remove the list if there are no more attachments here | 563 | // And remove the list if there are no more attachments here |
526 | if (m_attachments[kvp.Key].Count == 0) | 564 | if (m_attachments[kvp.Key].Count == 0) |
527 | m_attachments.Remove(kvp.Key); | 565 | m_attachments.Remove(kvp.Key); |
566 | |||
528 | return true; | 567 | return true; |
529 | } | 568 | } |
530 | } | 569 | } |
531 | } | 570 | } |
571 | |||
532 | return false; | 572 | return false; |
533 | } | 573 | } |
534 | 574 | ||
535 | public void ClearAttachments() | 575 | public void ClearAttachments() |
536 | { | 576 | { |
537 | lock (m_attachments) | 577 | lock (m_attachments) |
538 | { | ||
539 | m_attachments.Clear(); | 578 | m_attachments.Clear(); |
540 | } | ||
541 | } | 579 | } |
542 | 580 | ||
543 | #region Packing Functions | 581 | #region Packing Functions |
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 613db1c..5a4811e 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs | |||
@@ -441,7 +441,6 @@ namespace OpenSim.Framework | |||
441 | args["controllers"] = controls; | 441 | args["controllers"] = controls; |
442 | } | 442 | } |
443 | 443 | ||
444 | |||
445 | if ((CallbackURI != null) && (!CallbackURI.Equals(""))) | 444 | if ((CallbackURI != null) && (!CallbackURI.Equals(""))) |
446 | args["callback_uri"] = OSD.FromString(CallbackURI); | 445 | args["callback_uri"] = OSD.FromString(CallbackURI); |
447 | 446 | ||
@@ -628,6 +627,7 @@ namespace OpenSim.Framework | |||
628 | // We know all of these must end up as attachments so we | 627 | // We know all of these must end up as attachments so we |
629 | // append rather than replace to ensure multiple attachments | 628 | // append rather than replace to ensure multiple attachments |
630 | // per point continues to work | 629 | // per point continues to work |
630 | // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID); | ||
631 | Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); | 631 | Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o)); |
632 | } | 632 | } |
633 | } | 633 | } |
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 2d58807..1cbb53f 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -1384,11 +1384,30 @@ namespace OpenSim.Framework | |||
1384 | return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; | 1384 | return (ipaddr1 != null) ? "http://" + ipaddr1.ToString() + ":" + port1 : uri; |
1385 | } | 1385 | } |
1386 | 1386 | ||
1387 | /// <summary> | ||
1388 | /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 256 bytes if necessary. | ||
1389 | /// </summary> | ||
1390 | /// <param name="str"> | ||
1391 | /// If null or empty, then an bytes[0] is returned. | ||
1392 | /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0] | ||
1393 | /// </param> | ||
1394 | /// <param name="args"> | ||
1395 | /// Arguments to substitute into the string via the {} mechanism. | ||
1396 | /// </param> | ||
1397 | /// <returns></returns> | ||
1387 | public static byte[] StringToBytes256(string str, params object[] args) | 1398 | public static byte[] StringToBytes256(string str, params object[] args) |
1388 | { | 1399 | { |
1389 | return StringToBytes256(string.Format(str, args)); | 1400 | return StringToBytes256(string.Format(str, args)); |
1390 | } | 1401 | } |
1391 | 1402 | ||
1403 | /// <summary> | ||
1404 | /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 256 bytes if necessary. | ||
1405 | /// </summary> | ||
1406 | /// <param name="str"> | ||
1407 | /// If null or empty, then an bytes[0] is returned. | ||
1408 | /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0] | ||
1409 | /// </param> | ||
1410 | /// <returns></returns> | ||
1392 | public static byte[] StringToBytes256(string str) | 1411 | public static byte[] StringToBytes256(string str) |
1393 | { | 1412 | { |
1394 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } | 1413 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } |
@@ -1407,11 +1426,30 @@ namespace OpenSim.Framework | |||
1407 | return data; | 1426 | return data; |
1408 | } | 1427 | } |
1409 | 1428 | ||
1429 | /// <summary> | ||
1430 | /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 1024 bytes if necessary. | ||
1431 | /// </summary> | ||
1432 | /// <param name="str"> | ||
1433 | /// If null or empty, then an bytes[0] is returned. | ||
1434 | /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0] | ||
1435 | /// </param> | ||
1436 | /// <param name="args"> | ||
1437 | /// Arguments to substitute into the string via the {} mechanism. | ||
1438 | /// </param> | ||
1439 | /// <returns></returns> | ||
1410 | public static byte[] StringToBytes1024(string str, params object[] args) | 1440 | public static byte[] StringToBytes1024(string str, params object[] args) |
1411 | { | 1441 | { |
1412 | return StringToBytes1024(string.Format(str, args)); | 1442 | return StringToBytes1024(string.Format(str, args)); |
1413 | } | 1443 | } |
1414 | 1444 | ||
1445 | /// <summary> | ||
1446 | /// Convert a string to a byte format suitable for transport in an LLUDP packet. The output is truncated to 1024 bytes if necessary. | ||
1447 | /// </summary> | ||
1448 | /// <param name="str"> | ||
1449 | /// If null or empty, then an bytes[0] is returned. | ||
1450 | /// Using "\0" will return a conversion of the null character to a byte. This is not the same as bytes[0] | ||
1451 | /// </param> | ||
1452 | /// <returns></returns> | ||
1415 | public static byte[] StringToBytes1024(string str) | 1453 | public static byte[] StringToBytes1024(string str) |
1416 | { | 1454 | { |
1417 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } | 1455 | if (String.IsNullOrEmpty(str)) { return Utils.EmptyBytes; } |