aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/ChildAgentDataUpdate.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/ChildAgentDataUpdate.cs')
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs222
1 files changed, 180 insertions, 42 deletions
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index 2a8e67d..72c2c34 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -61,8 +61,8 @@ namespace OpenSim.Framework
61 { 61 {
62 UUID AgentID { get; set; } 62 UUID AgentID { get; set; }
63 63
64 OSDMap Pack(); 64 OSDMap Pack(EntityTransferContext ctx);
65 void Unpack(OSDMap map, IScene scene); 65 void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx);
66 } 66 }
67 67
68 /// <summary> 68 /// <summary>
@@ -94,8 +94,9 @@ namespace OpenSim.Framework
94 // This probably shouldn't be here 94 // This probably shouldn't be here
95 public byte[] Throttles; 95 public byte[] Throttles;
96 96
97 public Dictionary<ulong, string> ChildrenCapSeeds = null;
97 98
98 public OSDMap Pack() 99 public OSDMap Pack(EntityTransferContext ctx)
99 { 100 {
100 OSDMap args = new OSDMap(); 101 OSDMap args = new OSDMap();
101 args["message_type"] = OSD.FromString("AgentPosition"); 102 args["message_type"] = OSD.FromString("AgentPosition");
@@ -119,10 +120,23 @@ namespace OpenSim.Framework
119 if ((Throttles != null) && (Throttles.Length > 0)) 120 if ((Throttles != null) && (Throttles.Length > 0))
120 args["throttles"] = OSD.FromBinary(Throttles); 121 args["throttles"] = OSD.FromBinary(Throttles);
121 122
123 if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
124 {
125 OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
126 foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
127 {
128 OSDMap pair = new OSDMap();
129 pair["handle"] = OSD.FromString(kvp.Key.ToString());
130 pair["seed"] = OSD.FromString(kvp.Value);
131 childrenSeeds.Add(pair);
132 }
133 args["children_seeds"] = childrenSeeds;
134 }
135
122 return args; 136 return args;
123 } 137 }
124 138
125 public void Unpack(OSDMap args, IScene scene) 139 public void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
126 { 140 {
127 if (args.ContainsKey("region_handle")) 141 if (args.ContainsKey("region_handle"))
128 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); 142 UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
@@ -165,6 +179,30 @@ namespace OpenSim.Framework
165 179
166 if (args["throttles"] != null) 180 if (args["throttles"] != null)
167 Throttles = args["throttles"].AsBinary(); 181 Throttles = args["throttles"].AsBinary();
182
183 if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) &&
184 (args["children_seeds"].Type == OSDType.Array))
185 {
186 OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
187 ChildrenCapSeeds = new Dictionary<ulong, string>();
188 foreach (OSD o in childrenSeeds)
189 {
190 if (o.Type == OSDType.Map)
191 {
192 ulong handle = 0;
193 string seed = "";
194 OSDMap pair = (OSDMap)o;
195 if (pair["handle"] != null)
196 if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
197 continue;
198 if (pair["seed"] != null)
199 seed = pair["seed"].AsString();
200 if (!ChildrenCapSeeds.ContainsKey(handle))
201 ChildrenCapSeeds.Add(handle, seed);
202 }
203 }
204 }
205
168 } 206 }
169 207
170 /// <summary> 208 /// <summary>
@@ -317,9 +355,11 @@ namespace OpenSim.Framework
317 public UUID ActiveGroupID; 355 public UUID ActiveGroupID;
318 356
319 public AgentGroupData[] Groups; 357 public AgentGroupData[] Groups;
358 public Dictionary<ulong, string> ChildrenCapSeeds = null;
320 public Animation[] Anims; 359 public Animation[] Anims;
321 public Animation DefaultAnim = null; 360 public Animation DefaultAnim = null;
322 public Animation AnimState = null; 361 public Animation AnimState = null;
362 public Byte MotionState = 0;
323 363
324 public UUID GranterID; 364 public UUID GranterID;
325 public UUID ParentPart; 365 public UUID ParentPart;
@@ -349,8 +389,12 @@ namespace OpenSim.Framework
349 public List<ISceneObject> AttachmentObjects; 389 public List<ISceneObject> AttachmentObjects;
350 public List<string> AttachmentObjectStates; 390 public List<string> AttachmentObjectStates;
351 391
352 public virtual OSDMap Pack() 392 public Dictionary<string, UUID> MovementAnimationOverRides = new Dictionary<string, UUID>();
393
394 public virtual OSDMap Pack(EntityTransferContext ctx)
353 { 395 {
396 int wearablesCount = -1;
397
354// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); 398// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");
355 399
356 OSDMap args = new OSDMap(); 400 OSDMap args = new OSDMap();
@@ -399,6 +443,19 @@ namespace OpenSim.Framework
399 args["groups"] = groups; 443 args["groups"] = groups;
400 } 444 }
401 445
446 if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
447 {
448 OSDArray childrenSeeds = new OSDArray(ChildrenCapSeeds.Count);
449 foreach (KeyValuePair<ulong, string> kvp in ChildrenCapSeeds)
450 {
451 OSDMap pair = new OSDMap();
452 pair["handle"] = OSD.FromString(kvp.Key.ToString());
453 pair["seed"] = OSD.FromString(kvp.Value);
454 childrenSeeds.Add(pair);
455 }
456 args["children_seeds"] = childrenSeeds;
457 }
458
402 if ((Anims != null) && (Anims.Length > 0)) 459 if ((Anims != null) && (Anims.Length > 0))
403 { 460 {
404 OSDArray anims = new OSDArray(Anims.Length); 461 OSDArray anims = new OSDArray(Anims.Length);
@@ -417,8 +474,28 @@ namespace OpenSim.Framework
417 args["animation_state"] = AnimState.PackUpdateMessage(); 474 args["animation_state"] = AnimState.PackUpdateMessage();
418 } 475 }
419 476
477 if (MovementAnimationOverRides.Count > 0)
478 {
479 OSDArray AOs = new OSDArray(MovementAnimationOverRides.Count);
480 {
481 foreach (KeyValuePair<string, UUID> kvp in MovementAnimationOverRides)
482 {
483 OSDMap ao = new OSDMap(2);
484 ao["state"] = OSD.FromString(kvp.Key);
485 ao["uuid"] = OSD.FromUUID(kvp.Value);
486 AOs.Add(ao);
487 }
488 }
489 args["movementAO"] = AOs;
490 }
491
492 if (MotionState != 0)
493 {
494 args["motion_state"] = OSD.FromInteger(MotionState);
495 }
496
420 if (Appearance != null) 497 if (Appearance != null)
421 args["packed_appearance"] = Appearance.Pack(); 498 args["packed_appearance"] = Appearance.Pack(ctx);
422 499
423 //if ((AgentTextures != null) && (AgentTextures.Length > 0)) 500 //if ((AgentTextures != null) && (AgentTextures.Length > 0))
424 //{ 501 //{
@@ -431,6 +508,8 @@ namespace OpenSim.Framework
431 // The code to pack textures, visuals, wearables and attachments 508 // The code to pack textures, visuals, wearables and attachments
432 // should be removed; packed appearance contains the full appearance 509 // should be removed; packed appearance contains the full appearance
433 // This is retained for backward compatibility only 510 // This is retained for backward compatibility only
511
512/* then lets remove
434 if (Appearance.Texture != null) 513 if (Appearance.Texture != null)
435 { 514 {
436 byte[] rawtextures = Appearance.Texture.GetBytes(); 515 byte[] rawtextures = Appearance.Texture.GetBytes();
@@ -459,7 +538,7 @@ namespace OpenSim.Framework
459 args["attachments"] = attachs; 538 args["attachments"] = attachs;
460 } 539 }
461 // End of code to remove 540 // End of code to remove
462 541*/
463 if ((Controllers != null) && (Controllers.Length > 0)) 542 if ((Controllers != null) && (Controllers.Length > 0))
464 { 543 {
465 OSDArray controls = new OSDArray(Controllers.Length); 544 OSDArray controls = new OSDArray(Controllers.Length);
@@ -507,7 +586,7 @@ namespace OpenSim.Framework
507 /// Avoiding reflection makes it painful to write, but that's the price! 586 /// Avoiding reflection makes it painful to write, but that's the price!
508 /// </summary> 587 /// </summary>
509 /// <param name="hash"></param> 588 /// <param name="hash"></param>
510 public virtual void Unpack(OSDMap args, IScene scene) 589 public virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
511 { 590 {
512 //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data"); 591 //m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data");
513 592
@@ -600,6 +679,29 @@ namespace OpenSim.Framework
600 } 679 }
601 } 680 }
602 681
682 if (args.ContainsKey("children_seeds") && (args["children_seeds"] != null) &&
683 (args["children_seeds"].Type == OSDType.Array))
684 {
685 OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
686 ChildrenCapSeeds = new Dictionary<ulong, string>();
687 foreach (OSD o in childrenSeeds)
688 {
689 if (o.Type == OSDType.Map)
690 {
691 ulong handle = 0;
692 string seed = "";
693 OSDMap pair = (OSDMap)o;
694 if (pair["handle"] != null)
695 if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
696 continue;
697 if (pair["seed"] != null)
698 seed = pair["seed"].AsString();
699 if (!ChildrenCapSeeds.ContainsKey(handle))
700 ChildrenCapSeeds.Add(handle, seed);
701 }
702 }
703 }
704
603 if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array) 705 if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array)
604 { 706 {
605 OSDArray anims = (OSDArray)(args["animations"]); 707 OSDArray anims = (OSDArray)(args["animations"]);
@@ -638,6 +740,28 @@ namespace OpenSim.Framework
638 } 740 }
639 } 741 }
640 742
743 MovementAnimationOverRides.Clear();
744
745 if (args["movementAO"] != null && args["movementAO"].Type == OSDType.Array)
746 {
747 OSDArray AOs = (OSDArray)(args["movementAO"]);
748 int count = AOs.Count;
749
750 for (int i = 0; i < count; i++)
751 {
752 OSDMap ao = (OSDMap)AOs[i];
753 if (ao["state"] != null && ao["uuid"] != null)
754 {
755 string state = ao["state"].AsString();
756 UUID id = ao["uuid"].AsUUID();
757 MovementAnimationOverRides[state] = id;
758 }
759 }
760 }
761
762 if (args.ContainsKey("motion_state"))
763 MotionState = (byte)args["motion_state"].AsInteger();
764
641 //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array) 765 //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
642 //{ 766 //{
643 // OSDArray textures = (OSDArray)(args["agent_textures"]); 767 // OSDArray textures = (OSDArray)(args["agent_textures"]);
@@ -647,53 +771,67 @@ namespace OpenSim.Framework
647 // AgentTextures[i++] = o.AsUUID(); 771 // AgentTextures[i++] = o.AsUUID();
648 //} 772 //}
649 773
650 Appearance = new AvatarAppearance();
651 774
652 // The code to unpack textures, visuals, wearables and attachments 775 // packed_appearence should contain all appearance information
653 // should be removed; packed appearance contains the full appearance 776 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
654 // This is retained for backward compatibility only
655 if (args["texture_entry"] != null)
656 { 777 {
657 byte[] rawtextures = args["texture_entry"].AsBinary(); 778 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] got packed appearance");
658 Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures,0,rawtextures.Length); 779 Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]);
659 Appearance.SetTextureEntries(textures);
660 } 780 }
781 else
782 {
783 // if missing try the old pack method
784 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance, checking old method");
661 785
662 if (args["visual_params"] != null) 786 Appearance = new AvatarAppearance();
663 Appearance.SetVisualParams(args["visual_params"].AsBinary());
664 787
665 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array) 788 // The code to unpack textures, visuals, wearables and attachments
666 { 789 // should be removed; packed appearance contains the full appearance
667 OSDArray wears = (OSDArray)(args["wearables"]); 790 // This is retained for backward compatibility only
668 for (int i = 0; i < wears.Count / 2; i++) 791 if (args["texture_entry"] != null)
669 { 792 {
670 AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); 793 byte[] rawtextures = args["texture_entry"].AsBinary();
671 Appearance.SetWearable(i,awear); 794 Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length);
795 Appearance.SetTextureEntries(textures);
672 } 796 }
673 }
674 797
675 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array) 798 if (args["visual_params"] != null)
676 { 799 Appearance.SetVisualParams(args["visual_params"].AsBinary());
677 OSDArray attachs = (OSDArray)(args["attachments"]); 800
678 foreach (OSD o in attachs) 801 if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
679 { 802 {
680 if (o.Type == OSDType.Map) 803 OSDArray wears = (OSDArray)(args["wearables"]);
804
805 for (int i = 0; i < wears.Count / 2; i++)
681 { 806 {
682 // We know all of these must end up as attachments so we 807 AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]);
683 // append rather than replace to ensure multiple attachments 808 Appearance.SetWearable(i, awear);
684 // per point continues to work
685// m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID);
686 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
687 } 809 }
688 } 810 }
689 }
690 // end of code to remove
691 811
812 if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
813 {
814 OSDArray attachs = (OSDArray)(args["attachments"]);
815 foreach (OSD o in attachs)
816 {
817 if (o.Type == OSDType.Map)
818 {
819 // We know all of these must end up as attachments so we
820 // append rather than replace to ensure multiple attachments
821 // per point continues to work
822 // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID);
823 Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
824 }
825 }
826 }
827 // end of code to remove
828 }
829/* moved above
692 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map) 830 if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
693 Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]); 831 Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]);
694 else 832 else
695 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance"); 833 m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance");
696 834*/
697 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array) 835 if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
698 { 836 {
699 OSDArray controls = (OSDArray)(args["controllers"]); 837 OSDArray controls = (OSDArray)(args["controllers"]);
@@ -757,14 +895,14 @@ namespace OpenSim.Framework
757 895
758 public class CompleteAgentData : AgentData 896 public class CompleteAgentData : AgentData
759 { 897 {
760 public override OSDMap Pack() 898 public override OSDMap Pack(EntityTransferContext ctx)
761 { 899 {
762 return base.Pack(); 900 return base.Pack(ctx);
763 } 901 }
764 902
765 public override void Unpack(OSDMap map, IScene scene) 903 public override void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx)
766 { 904 {
767 base.Unpack(map, scene); 905 base.Unpack(map, scene, ctx);
768 } 906 }
769 } 907 }
770} 908}