avoid potencial out of range issues
parent
fbb77274da
commit
570440256b
|
@ -28,6 +28,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
|
||||||
|
@ -150,7 +151,6 @@ namespace OpenSim.Services.Interfaces
|
||||||
// Wearables
|
// Wearables
|
||||||
Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
|
Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
|
||||||
|
|
||||||
// TODO: With COF, is this even needed?
|
|
||||||
for (int i = 0 ; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES ; i++)
|
for (int i = 0 ; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES ; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0 ; j < appearance.Wearables[i].Count ; j++)
|
for (int j = 0 ; j < appearance.Wearables[i].Count ; j++)
|
||||||
|
@ -162,21 +162,18 @@ namespace OpenSim.Services.Interfaces
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visual Params
|
|
||||||
//string[] vps = new string[AvatarAppearance.VISUALPARAM_COUNT];
|
|
||||||
//byte[] binary = appearance.VisualParams;
|
|
||||||
|
|
||||||
// for (int i = 0 ; i < AvatarAppearance.VISUALPARAM_COUNT ; i++)
|
|
||||||
|
|
||||||
byte[] binary = appearance.VisualParams;
|
byte[] binary = appearance.VisualParams;
|
||||||
string[] vps = new string[binary.Length];
|
int len = binary.Length;
|
||||||
|
int last = len - 1;
|
||||||
|
|
||||||
for (int i = 0; i < binary.Length; i++)
|
StringBuilder sb = new StringBuilder(5 * len);
|
||||||
|
for (int i = 0; i < len; i++)
|
||||||
{
|
{
|
||||||
vps[i] = binary[i].ToString();
|
sb.Append(binary[i].ToString());
|
||||||
|
if (i < last)
|
||||||
|
sb.Append(",");
|
||||||
}
|
}
|
||||||
|
Data["VisualParams"] = sb.ToString();
|
||||||
Data["VisualParams"] = String.Join(",", vps);
|
|
||||||
|
|
||||||
// Attachments
|
// Attachments
|
||||||
List<AvatarAttachment> attachments = appearance.GetAttachments();
|
List<AvatarAttachment> attachments = appearance.GetAttachments();
|
||||||
|
@ -213,7 +210,6 @@ namespace OpenSim.Services.Interfaces
|
||||||
if( h == 0f)
|
if( h == 0f)
|
||||||
h = 1.9f;
|
h = 1.9f;
|
||||||
appearance.SetSize(new Vector3(0.45f, 0.6f, h ));
|
appearance.SetSize(new Vector3(0.45f, 0.6f, h ));
|
||||||
// appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Legacy Wearables
|
// Legacy Wearables
|
||||||
|
@ -285,9 +281,6 @@ namespace OpenSim.Services.Interfaces
|
||||||
if (Data.ContainsKey("VisualParams"))
|
if (Data.ContainsKey("VisualParams"))
|
||||||
{
|
{
|
||||||
string[] vps = Data["VisualParams"].Split(new char[] {','});
|
string[] vps = Data["VisualParams"].Split(new char[] {','});
|
||||||
//byte[] binary = new byte[AvatarAppearance.VISUALPARAM_COUNT];
|
|
||||||
|
|
||||||
//for (int i = 0 ; i < vps.Length && i < binary.Length ; i++)
|
|
||||||
byte[] binary = new byte[vps.Length];
|
byte[] binary = new byte[vps.Length];
|
||||||
|
|
||||||
for (int i = 0; i < vps.Length; i++)
|
for (int i = 0; i < vps.Length; i++)
|
||||||
|
@ -296,10 +289,12 @@ namespace OpenSim.Services.Interfaces
|
||||||
appearance.VisualParams = binary;
|
appearance.VisualParams = binary;
|
||||||
}
|
}
|
||||||
|
|
||||||
// New style wearables
|
AvatarWearable[] wearables = appearance.Wearables;
|
||||||
|
int currentLength = wearables.Length;
|
||||||
foreach (KeyValuePair<string, string> _kvp in Data)
|
foreach (KeyValuePair<string, string> _kvp in Data)
|
||||||
{
|
{
|
||||||
if (_kvp.Key.StartsWith("Wearable "))
|
// New style wearables
|
||||||
|
if (_kvp.Key.StartsWith("Wearable ") && _kvp.Key.Length > 9)
|
||||||
{
|
{
|
||||||
string wearIndex = _kvp.Key.Substring(9);
|
string wearIndex = _kvp.Key.Substring(9);
|
||||||
string[] wearIndices = wearIndex.Split(new char[] {':'});
|
string[] wearIndices = wearIndex.Split(new char[] {':'});
|
||||||
|
@ -308,35 +303,35 @@ namespace OpenSim.Services.Interfaces
|
||||||
string[] ids = _kvp.Value.Split(new char[] {':'});
|
string[] ids = _kvp.Value.Split(new char[] {':'});
|
||||||
UUID itemID = new UUID(ids[0]);
|
UUID itemID = new UUID(ids[0]);
|
||||||
UUID assetID = new UUID(ids[1]);
|
UUID assetID = new UUID(ids[1]);
|
||||||
|
if (index >= currentLength)
|
||||||
appearance.Wearables[index].Add(itemID, assetID);
|
{
|
||||||
|
Array.Resize(ref wearables, index + 1);
|
||||||
|
for (int i = currentLength ; i < wearables.Length ; i++)
|
||||||
|
wearables[i] = new AvatarWearable();
|
||||||
|
currentLength = wearables.Length;
|
||||||
}
|
}
|
||||||
|
wearables[index].Add(itemID, assetID);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attachments
|
// Attachments
|
||||||
Dictionary<string, string> attchs = new Dictionary<string, string>();
|
if (_kvp.Key.StartsWith("_ap_") && _kvp.Key.Length > 4)
|
||||||
foreach (KeyValuePair<string, string> _kvp in Data)
|
|
||||||
if (_kvp.Key.StartsWith("_ap_"))
|
|
||||||
attchs[_kvp.Key] = _kvp.Value;
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string, string> _kvp in attchs)
|
|
||||||
{
|
{
|
||||||
string pointStr = _kvp.Key.Substring(4);
|
string pointStr = _kvp.Key.Substring(4);
|
||||||
int point = 0;
|
int point = 0;
|
||||||
if (!Int32.TryParse(pointStr, out point))
|
if (Int32.TryParse(pointStr, out point))
|
||||||
continue;
|
{
|
||||||
|
|
||||||
List<string> idList = new List<string>(_kvp.Value.Split(new char[] {','}));
|
List<string> idList = new List<string>(_kvp.Value.Split(new char[] {','}));
|
||||||
|
|
||||||
appearance.SetAttachment(point, UUID.Zero, UUID.Zero);
|
appearance.SetAttachment(point, UUID.Zero, UUID.Zero);
|
||||||
foreach (string id in idList)
|
foreach (string id in idList)
|
||||||
{
|
{
|
||||||
UUID uuid = UUID.Zero;
|
UUID uuid = UUID.Zero;
|
||||||
UUID.TryParse(id, out uuid);
|
if(UUID.TryParse(id, out uuid))
|
||||||
|
|
||||||
appearance.SetAttachment(point | 0x80, uuid, UUID.Zero);
|
appearance.SetAttachment(point | 0x80, uuid, UUID.Zero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (appearance.Wearables[AvatarWearable.BODY].Count == 0)
|
if (appearance.Wearables[AvatarWearable.BODY].Count == 0)
|
||||||
appearance.Wearables[AvatarWearable.BODY].Wear(
|
appearance.Wearables[AvatarWearable.BODY].Wear(
|
||||||
|
|
Loading…
Reference in New Issue