aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AgentCircuitData.cs4
-rw-r--r--OpenSim/Framework/AvatarAppearance.cs50
-rw-r--r--OpenSim/Framework/AvatarWearable.cs7
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs28
-rw-r--r--OpenSim/Framework/Tests/AgentCircuitDataTest.cs2
5 files changed, 57 insertions, 34 deletions
diff --git a/OpenSim/Framework/AgentCircuitData.cs b/OpenSim/Framework/AgentCircuitData.cs
index 0d053e4..f4b35a6 100644
--- a/OpenSim/Framework/AgentCircuitData.cs
+++ b/OpenSim/Framework/AgentCircuitData.cs
@@ -184,7 +184,7 @@ namespace OpenSim.Framework
184 /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json 184 /// Pack AgentCircuitData into an OSDMap for transmission over LLSD XML or LLSD json
185 /// </summary> 185 /// </summary>
186 /// <returns>map of the agent circuit data</returns> 186 /// <returns>map of the agent circuit data</returns>
187 public OSDMap PackAgentCircuitData() 187 public OSDMap PackAgentCircuitData(int wearablesCount)
188 { 188 {
189 OSDMap args = new OSDMap(); 189 OSDMap args = new OSDMap();
190 args["agent_id"] = OSD.FromUUID(AgentID); 190 args["agent_id"] = OSD.FromUUID(AgentID);
@@ -224,7 +224,7 @@ namespace OpenSim.Framework
224 { 224 {
225 args["appearance_serial"] = OSD.FromInteger(Appearance.Serial); 225 args["appearance_serial"] = OSD.FromInteger(Appearance.Serial);
226 226
227 OSDMap appmap = Appearance.Pack(); 227 OSDMap appmap = Appearance.Pack(wearablesCount);
228 args["packed_appearance"] = appmap; 228 args["packed_appearance"] = appmap;
229 } 229 }
230 230
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 72c6bfc..50746a0 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -211,13 +211,12 @@ namespace OpenSim.Framework
211 211
212 m_serial = appearance.Serial; 212 m_serial = appearance.Serial;
213 213
214 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; 214 ClearWearables();
215 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
216 m_wearables[i] = new AvatarWearable();
217 215
218 if (copyWearables && (appearance.Wearables != null)) 216 if (copyWearables && (appearance.Wearables != null))
219 { 217 {
220 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 218 m_wearables = new AvatarWearable[appearance.Wearables.Length];
219 for (int i = 0; i < appearance.Wearables.Length; i++)
221 SetWearable(i,appearance.Wearables[i]); 220 SetWearable(i,appearance.Wearables[i]);
222 } 221 }
223 222
@@ -247,7 +246,7 @@ namespace OpenSim.Framework
247 246
248 public void GetAssetsFrom(AvatarAppearance app) 247 public void GetAssetsFrom(AvatarAppearance app)
249 { 248 {
250 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 249 for (int i = 0; i < m_wearables.Length; i++)
251 { 250 {
252 for (int j = 0; j < m_wearables[i].Count; j++) 251 for (int j = 0; j < m_wearables[i].Count; j++)
253 { 252 {
@@ -262,8 +261,8 @@ namespace OpenSim.Framework
262 261
263 public void ClearWearables() 262 public void ClearWearables()
264 { 263 {
265 m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES]; 264 m_wearables = new AvatarWearable[AvatarWearable.LEGACY_VERSION_MAX_WEARABLES];
266 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 265 for (int i = 0; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES; i++)
267 m_wearables[i] = new AvatarWearable(); 266 m_wearables[i] = new AvatarWearable();
268 } 267 }
269 268
@@ -470,11 +469,15 @@ namespace OpenSim.Framework
470// DEBUG ON 469// DEBUG ON
471// m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID); 470// m_log.WarnFormat("[AVATARAPPEARANCE] set wearable {0} --> {1}:{2}",wearableId,wearable.ItemID,wearable.AssetID);
472// DEBUG OFF 471// DEBUG OFF
472 if (wearableId >= m_wearables.Length)
473 {
474 int currentLength = m_wearables.Length;
475 Array.Resize(ref m_wearables, wearableId + 1);
476 for (int i = currentLength ; i < m_wearables.Length ; i++)
477 m_wearables[i] = new AvatarWearable();
478 }
473 m_wearables[wearableId].Clear(); 479 m_wearables[wearableId].Clear();
474 int count = wearable.Count; 480 for (int i = 0; i < wearable.Count; i++)
475 if (count > AvatarWearable.MAX_WEARABLES)
476 count = AvatarWearable.MAX_WEARABLES;
477 for (int i = 0; i < count; i++)
478 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID); 481 m_wearables[wearableId].Add(wearable[i].ItemID, wearable[i].AssetID);
479 } 482 }
480 483
@@ -714,7 +717,7 @@ namespace OpenSim.Framework
714 /// <summary> 717 /// <summary>
715 /// Create an OSDMap from the appearance data 718 /// Create an OSDMap from the appearance data
716 /// </summary> 719 /// </summary>
717 public OSDMap Pack() 720 public OSDMap Pack(int wearablesCount)
718 { 721 {
719 OSDMap data = new OSDMap(); 722 OSDMap data = new OSDMap();
720 723
@@ -722,9 +725,22 @@ namespace OpenSim.Framework
722 data["height"] = OSD.FromReal(m_avatarHeight); 725 data["height"] = OSD.FromReal(m_avatarHeight);
723 726
724 // Wearables 727 // Wearables
725 OSDArray wears = new OSDArray(AvatarWearable.MAX_WEARABLES); 728 //
726 for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) 729 // This will send as many or as few wearables as we have, unless a count
727 wears.Add(m_wearables[i].Pack()); 730 // is given. Used for legacy (pre 0.4) versions.
731 int count = wearablesCount;
732 if (wearablesCount == -1)
733 count = m_wearables.Length;
734 OSDArray wears = new OSDArray(count);
735 for (int i = 0; i < count; i++)
736 {
737 AvatarWearable dummyWearable = new AvatarWearable();
738
739 if (i < m_wearables.Length)
740 wears.Add(m_wearables[i].Pack());
741 else
742 wears.Add(dummyWearable.Pack());
743 }
728 data["wearables"] = wears; 744 data["wearables"] = wears;
729 745
730 // Avatar Textures 746 // Avatar Textures
@@ -782,8 +798,8 @@ namespace OpenSim.Framework
782 OSDArray wears = (OSDArray)(data["wearables"]); 798 OSDArray wears = (OSDArray)(data["wearables"]);
783 799
784 int count = wears.Count; 800 int count = wears.Count;
785 if (count > AvatarWearable.MAX_WEARABLES) 801
786 count = AvatarWearable.MAX_WEARABLES; 802 m_wearables = new AvatarWearable[count];
787 803
788 for (int i = 0; i < count; i++) 804 for (int i = 0; i < count; i++)
789 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]); 805 m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs
index e662d5f..80ed77f 100644
--- a/OpenSim/Framework/AvatarWearable.cs
+++ b/OpenSim/Framework/AvatarWearable.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Framework
68 public static readonly int ALPHA = 13; 68 public static readonly int ALPHA = 13;
69 public static readonly int TATTOO = 14; 69 public static readonly int TATTOO = 14;
70 70
71 public static readonly int MAX_WEARABLES = 15; 71 public static readonly int LEGACY_VERSION_MAX_WEARABLES = 15;
72// public static readonly int PHYSICS = 15; 72// public static readonly int PHYSICS = 15;
73// public static int MAX_WEARABLES = 16; 73// public static int MAX_WEARABLES = 16;
74 74
@@ -225,8 +225,9 @@ namespace OpenSim.Framework
225 { 225 {
226 get 226 get
227 { 227 {
228 AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; 228 // We use the legacy count here because this is just a fallback anyway
229 for (int i = 0; i < MAX_WEARABLES; i++) 229 AvatarWearable[] defaultWearables = new AvatarWearable[LEGACY_VERSION_MAX_WEARABLES];
230 for (int i = 0; i < LEGACY_VERSION_MAX_WEARABLES; i++)
230 { 231 {
231 defaultWearables[i] = new AvatarWearable(); 232 defaultWearables[i] = new AvatarWearable();
232 } 233 }
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index a714d86..2fce155 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Framework
61 { 61 {
62 UUID AgentID { get; set; } 62 UUID AgentID { get; set; }
63 63
64 OSDMap Pack(); 64 OSDMap Pack(Object parms = null);
65 void Unpack(OSDMap map, IScene scene); 65 void Unpack(OSDMap map, IScene scene);
66 } 66 }
67 67
@@ -96,7 +96,7 @@ namespace OpenSim.Framework
96 96
97 public Dictionary<ulong, string> ChildrenCapSeeds = null; 97 public Dictionary<ulong, string> ChildrenCapSeeds = null;
98 98
99 public OSDMap Pack() 99 public OSDMap Pack(Object parms = null)
100 { 100 {
101 OSDMap args = new OSDMap(); 101 OSDMap args = new OSDMap();
102 args["message_type"] = OSD.FromString("AgentPosition"); 102 args["message_type"] = OSD.FromString("AgentPosition");
@@ -391,8 +391,18 @@ namespace OpenSim.Framework
391 391
392 public Dictionary<string, UUID> MovementAnimationOverRides = new Dictionary<string, UUID>(); 392 public Dictionary<string, UUID> MovementAnimationOverRides = new Dictionary<string, UUID>();
393 393
394 public virtual OSDMap Pack() 394 public virtual OSDMap Pack(Object parms = null)
395 { 395 {
396 int wearablesCount = -1;
397
398 if (parms != null)
399 {
400 Hashtable p = (Hashtable)parms;
401
402 if (p.ContainsKey("wearablesCount"))
403 wearablesCount = (int)p["wearablesCount"];
404 }
405
396// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data"); 406// m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");
397 407
398 OSDMap args = new OSDMap(); 408 OSDMap args = new OSDMap();
@@ -493,7 +503,7 @@ namespace OpenSim.Framework
493 } 503 }
494 504
495 if (Appearance != null) 505 if (Appearance != null)
496 args["packed_appearance"] = Appearance.Pack(); 506 args["packed_appearance"] = Appearance.Pack(wearablesCount);
497 507
498 //if ((AgentTextures != null) && (AgentTextures.Length > 0)) 508 //if ((AgentTextures != null) && (AgentTextures.Length > 0))
499 //{ 509 //{
@@ -800,11 +810,7 @@ namespace OpenSim.Framework
800 { 810 {
801 OSDArray wears = (OSDArray)(args["wearables"]); 811 OSDArray wears = (OSDArray)(args["wearables"]);
802 812
803 int count = wears.Count; 813 for (int i = 0; i < wears.Count / 2; i++)
804 if (count > AvatarWearable.MAX_WEARABLES)
805 count = AvatarWearable.MAX_WEARABLES;
806
807 for (int i = 0; i < count / 2; i++)
808 { 814 {
809 AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]); 815 AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]);
810 Appearance.SetWearable(i, awear); 816 Appearance.SetWearable(i, awear);
@@ -897,9 +903,9 @@ namespace OpenSim.Framework
897 903
898 public class CompleteAgentData : AgentData 904 public class CompleteAgentData : AgentData
899 { 905 {
900 public override OSDMap Pack() 906 public override OSDMap Pack(object parms = null)
901 { 907 {
902 return base.Pack(); 908 return base.Pack(parms);
903 } 909 }
904 910
905 public override void Unpack(OSDMap map, IScene scene) 911 public override void Unpack(OSDMap map, IScene scene)
diff --git a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
index 95e9439..a2a2eea 100644
--- a/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
+++ b/OpenSim/Framework/Tests/AgentCircuitDataTest.cs
@@ -312,7 +312,7 @@ namespace OpenSim.Framework.Tests
312 Agent1Data.startpos = StartPos; 312 Agent1Data.startpos = StartPos;
313 313
314 OSDMap map2; 314 OSDMap map2;
315 OSDMap map = Agent1Data.PackAgentCircuitData(); 315 OSDMap map = Agent1Data.PackAgentCircuitData(-1);
316 try 316 try
317 { 317 {
318 string str = OSDParser.SerializeJsonString(map); 318 string str = OSDParser.SerializeJsonString(map);