diff options
Diffstat (limited to 'OpenSim/Framework/AvatarAppearance.cs')
-rw-r--r-- | OpenSim/Framework/AvatarAppearance.cs | 50 |
1 files changed, 33 insertions, 17 deletions
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]); |