Provide a better implementation of llList2Float

avinationmerge
Melanie Thielker 2010-08-22 16:23:36 +02:00
parent 98b2d3a7f2
commit 0ca771c185
1 changed files with 14 additions and 1 deletions

View File

@ -5123,7 +5123,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
else if (src.Data[index] is LSL_Float)
return Convert.ToDouble(((LSL_Float) src.Data[index]).value);
else if (src.Data[index] is LSL_String)
return Convert.ToDouble(((LSL_String) src.Data[index]).m_string);
{
string str = ((LSL_String) src.Data[index]).m_string;
Match m = Regex.Match(str, "^\\s*(-?+?[0-9,]+\\.?[0-9]*)");
if (m != Match.Empty)
{
str = m.Value;
double d = 0.0;
if (!Double.TryParse(str, out d))
return 0.0;
return d;
}
return 0.0;
}
return Convert.ToDouble(src.Data[index]);
}
catch (FormatException)