Mantis #2112
Thannk you, ralphos, for a patch to clean up list item type handling and add a missing explicit cast in Shared/0.6.0-stable
parent
cf7f3df4c2
commit
ef27c8817f
|
@ -5721,13 +5721,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
if (remain < 7)
|
if (remain < 7)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LSL_Types.LSLInteger flexi = new LSL_Types.LSLInteger(rules.Data[idx++].ToString());
|
bool flexi = (LSL_Types.LSLInteger)rules.Data[idx++];
|
||||||
int softness = Convert.ToInt32(rules.Data[idx++]);
|
int softness = (LSL_Types.LSLInteger)rules.Data[idx++];
|
||||||
float gravity = (float)Convert.ToDouble(rules.Data[idx++]);
|
float gravity = (float)(LSL_Types.LSLFloat)rules.Data[idx++];
|
||||||
float friction = (float)Convert.ToDouble(rules.Data[idx++]);
|
float friction = (float)(LSL_Types.LSLFloat)rules.Data[idx++];
|
||||||
float wind = (float)Convert.ToDouble(rules.Data[idx++]);
|
float wind = (float)(LSL_Types.LSLFloat)rules.Data[idx++];
|
||||||
float tension = (float)Convert.ToDouble(rules.Data[idx++]);
|
float tension = (float)(LSL_Types.LSLFloat)rules.Data[idx++];
|
||||||
LSL_Types.Vector3 force =new LSL_Types.Vector3(rules.Data[idx++].ToString());
|
LSL_Types.Vector3 force = (LSL_Types.Vector3)rules.Data[idx++];
|
||||||
|
|
||||||
SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force);
|
SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force);
|
||||||
|
|
||||||
|
|
|
@ -1569,6 +1569,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
|
||||||
|
|
||||||
#region Operators
|
#region Operators
|
||||||
|
|
||||||
|
static public explicit operator float(LSLFloat f)
|
||||||
|
{
|
||||||
|
return (float)f.value;
|
||||||
|
}
|
||||||
|
|
||||||
static public explicit operator int(LSLFloat f)
|
static public explicit operator int(LSLFloat f)
|
||||||
{
|
{
|
||||||
return (int)f.value;
|
return (int)f.value;
|
||||||
|
|
|
@ -395,6 +395,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests LSLFloat is correctly cast explicitly to float
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestExplicitCastLSLFloatToFloat()
|
||||||
|
{
|
||||||
|
float testFloat;
|
||||||
|
float numberAsFloat;
|
||||||
|
LSL_Types.LSLFloat testLSLFloat;
|
||||||
|
foreach (double number in m_doubleList)
|
||||||
|
{
|
||||||
|
testLSLFloat = new LSL_Types.LSLFloat(number);
|
||||||
|
numberAsFloat = (float)number;
|
||||||
|
testFloat = (float)testLSLFloat;
|
||||||
|
|
||||||
|
Assert.That((double)testFloat, new DoubleToleranceConstraint((double)numberAsFloat, _lowPrecisionTolerance));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tests the equality (==) operator.
|
/// Tests the equality (==) operator.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -97,5 +97,66 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
|
||||||
Assert.AreEqual(0.04, secondTestList.Data[4]);
|
Assert.AreEqual(0.04, secondTestList.Data[4]);
|
||||||
Assert.AreEqual(typeof(double), secondTestList.Data[4].GetType());
|
Assert.AreEqual(typeof(double), secondTestList.Data[4].GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests casting LSLInteger item to LSLInteger.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestCastLSLIntegerItemToLSLInteger()
|
||||||
|
{
|
||||||
|
LSL_Types.LSLInteger testValue = new LSL_Types.LSLInteger(123);
|
||||||
|
LSL_Types.list testList = new LSL_Types.list(testValue);
|
||||||
|
|
||||||
|
Assert.AreEqual(testValue, (LSL_Types.LSLInteger)testList.Data[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests casting LSLFloat item to LSLFloat.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestCastLSLFloatItemToLSLFloat()
|
||||||
|
{
|
||||||
|
LSL_Types.LSLFloat testValue = new LSL_Types.LSLFloat(123.45678987);
|
||||||
|
LSL_Types.list testList = new LSL_Types.list(testValue);
|
||||||
|
|
||||||
|
Assert.AreEqual(testValue, (LSL_Types.LSLFloat)testList.Data[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests casting LSLString item to LSLString.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestCastLSLStringItemToLSLString()
|
||||||
|
{
|
||||||
|
LSL_Types.LSLString testValue = new LSL_Types.LSLString("hello there");
|
||||||
|
LSL_Types.list testList = new LSL_Types.list(testValue);
|
||||||
|
|
||||||
|
Assert.AreEqual(testValue, (LSL_Types.LSLString)testList.Data[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests casting Vector3 item to Vector3.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestCastVector3ItemToVector3()
|
||||||
|
{
|
||||||
|
LSL_Types.Vector3 testValue = new LSL_Types.Vector3(12.34, 56.987654, 0.00987);
|
||||||
|
LSL_Types.list testList = new LSL_Types.list(testValue);
|
||||||
|
|
||||||
|
Assert.AreEqual(testValue, (LSL_Types.Vector3)testList.Data[0]);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Tests casting Quaternion item to Quaternion.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void TestCastQuaternionItemToQuaternion()
|
||||||
|
{
|
||||||
|
LSL_Types.Quaternion testValue = new LSL_Types.Quaternion(12.34, 56.44323, 765.983421, 0.00987);
|
||||||
|
LSL_Types.list testList = new LSL_Types.list(testValue);
|
||||||
|
|
||||||
|
Assert.AreEqual(testValue, (LSL_Types.Quaternion)testList.Data[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue