From 2b354902b5581156fcbfecb37c5bc2abeae89c3b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 8 Oct 2015 06:27:37 +0100 Subject: 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 --- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'OpenSim/Region/ScriptEngine/Shared') diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index c34aecc..d501979 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -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); -- cgit v1.1