fix the casting to Boolean of lsl types vector,quaternion,list and rotation, so that if(variable) does compile and work. key still requires a explicit compare to NULL_KEY

avinationmerge
UbitUmarov 2015-10-08 06:27:37 +01:00
parent 40dc2541ff
commit 2b354902b5
1 changed files with 28 additions and 0 deletions

View File

@ -100,6 +100,17 @@ namespace OpenSim.Region.ScriptEngine.Shared
#region Overriders
public static implicit operator Boolean(Vector3 vec)
{
if (vec.x != 0)
return true;
if (vec.y != 0)
return true;
if (vec.z != 0)
return true;
return false;
}
public override string ToString()
{
string s = String.Format(Culture.FormatProvider, "<{0:0.000000}, {1:0.000000}, {2:0.000000}>", x, y, z);
@ -397,6 +408,18 @@ namespace OpenSim.Region.ScriptEngine.Shared
#endregion
#region Overriders
public static implicit operator Boolean(Quaternion q)
{
if (q.x != 0)
return true;
if (q.y != 0)
return true;
if (q.z != 0)
return true;
if (q.s != 1.0f)
return true;
return false;
}
public override int GetHashCode()
{
@ -721,6 +744,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
Data = tmp;
}
public static implicit operator Boolean(list l)
{
return l.Length != 0;
}
public static list operator +(list a, LSLString s)
{
a.ExtendAndAdd(s);