diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs index 48523e4fa5..612dae1f61 100644 --- a/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Common/LSL_Types.cs @@ -31,7 +31,7 @@ using System; namespace OpenSim.Region.ScriptEngine.Common { [Serializable] - public class LSL_Types + public partial class LSL_Types { // Types are kept is separate .dll to avoid having to add whatever .dll it is in it to script AppDomain @@ -47,9 +47,9 @@ namespace OpenSim.Region.ScriptEngine.Common public Vector3(Vector3 vector) { - x = (float) vector.x; - y = (float) vector.y; - z = (float) vector.z; + x = (float)vector.x; + y = (float)vector.y; + z = (float)vector.z; } public Vector3(double X, double Y, double Z) @@ -98,7 +98,7 @@ namespace OpenSim.Region.ScriptEngine.Common { if (!(o is Vector3)) return false; - Vector3 vector = (Vector3) o; + Vector3 vector = (Vector3)o; return (x == vector.x && x == vector.x && z == vector.z); } @@ -120,16 +120,16 @@ namespace OpenSim.Region.ScriptEngine.Common public static Vector3 operator *(Vector3 lhs, Vector3 rhs) { - return new Vector3(lhs.x*rhs.x, lhs.y*rhs.y, lhs.z*rhs.z); + return new Vector3(lhs.x * rhs.x, lhs.y * rhs.y, lhs.z * rhs.z); } public static Vector3 operator %(Vector3 v1, Vector3 v2) { //Cross product Vector3 tv; - tv.x = (v1.y*v2.z) - (v1.z*v2.y); - tv.y = (v1.z*v2.x) - (v1.x*v2.z); - tv.z = (v1.x*v2.y) - (v1.y*v2.x); + tv.x = (v1.y * v2.z) - (v1.z * v2.y); + tv.y = (v1.z * v2.x) - (v1.x * v2.z); + tv.z = (v1.x * v2.y) - (v1.y * v2.x); return tv; } @@ -140,19 +140,19 @@ namespace OpenSim.Region.ScriptEngine.Common // Vector-Float and Float-Vector Math public static Vector3 operator *(Vector3 vec, float val) { - return new Vector3(vec.x*val, vec.y*val, vec.z*val); + return new Vector3(vec.x * val, vec.y * val, vec.z * val); } public static Vector3 operator *(float val, Vector3 vec) { - return new Vector3(vec.x*val, vec.y*val, vec.z*val); + return new Vector3(vec.x * val, vec.y * val, vec.z * val); } public static Vector3 operator /(Vector3 v, float f) { - v.x = v.x/f; - v.y = v.y/f; - v.z = v.z/f; + v.x = v.x / f; + v.y = v.y / f; + v.z = v.z / f; return v; } @@ -188,7 +188,7 @@ namespace OpenSim.Region.ScriptEngine.Common Quaternion vq = new Quaternion(v.x, v.y, v.z, 0); Quaternion nq = new Quaternion(-r.x, -r.y, -r.z, r.s); - Quaternion result = (r*vq)*nq; + Quaternion result = (r * vq) * nq; return new Vector3(result.x, result.y, result.z); } @@ -200,7 +200,7 @@ namespace OpenSim.Region.ScriptEngine.Common Quaternion vq = new Quaternion(vec.x, vec.y, vec.z, 0); Quaternion nq = new Quaternion(-quat.x, -quat.y, -quat.z, quat.s); - Quaternion result = (quat*vq)*nq; + Quaternion result = (quat * vq) * nq; return new Vector3(result.x, result.y, result.z); } @@ -211,28 +211,28 @@ namespace OpenSim.Region.ScriptEngine.Common public static double Dot(Vector3 v1, Vector3 v2) { - return (v1.x*v2.x) + (v1.y*v2.y) + (v1.z*v2.z); + return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z); } public static Vector3 Cross(Vector3 v1, Vector3 v2) { return new Vector3 ( - v1.y*v2.z - v1.z*v2.y, - v1.z*v2.x - v1.x*v2.z, - v1.x*v2.y - v1.y*v2.x + v1.y * v2.z - v1.z * v2.y, + v1.z * v2.x - v1.x * v2.z, + v1.x * v2.y - v1.y * v2.x ); } public static float Mag(Vector3 v) { - return (float) Math.Sqrt(v.x*v.y + v.y*v.y + v.z*v.z); + return (float)Math.Sqrt(v.x * v.y + v.y * v.y + v.z * v.z); } public static Vector3 Norm(Vector3 vector) { float mag = Mag(vector); - return new Vector3(vector.x/mag, vector.y/mag, vector.z/mag); + return new Vector3(vector.x / mag, vector.y / mag, vector.z / mag); } #endregion @@ -250,10 +250,10 @@ namespace OpenSim.Region.ScriptEngine.Common public Quaternion(Quaternion Quat) { - x = (float) Quat.x; - y = (float) Quat.y; - z = (float) Quat.z; - s = (float) Quat.s; + x = (float)Quat.x; + y = (float)Quat.y; + z = (float)Quat.z; + s = (float)Quat.s; } public Quaternion(double X, double Y, double Z, double S) @@ -276,7 +276,7 @@ namespace OpenSim.Region.ScriptEngine.Common res = res & Double.TryParse(tmps[3], out s); } - #endregion + #endregion #region Overriders @@ -289,7 +289,7 @@ namespace OpenSim.Region.ScriptEngine.Common { if (!(o is Quaternion)) return false; - Quaternion quaternion = (Quaternion) o; + Quaternion quaternion = (Quaternion)o; return x == quaternion.x && y == quaternion.y && z == quaternion.z && s == quaternion.s; } @@ -315,10 +315,10 @@ namespace OpenSim.Region.ScriptEngine.Common public static Quaternion operator *(Quaternion a, Quaternion b) { Quaternion c; - c.x = a.s*b.x + a.x*b.s + a.y*b.z - a.z*b.y; - c.y = a.s*b.y + a.y*b.s + a.z*b.x - a.x*b.z; - c.z = a.s*b.z + a.z*b.s + a.x*b.y - a.y*b.x; - c.s = a.s*b.s - a.x*b.x - a.y*b.y - a.z*b.z; + c.x = a.s * b.x + a.x * b.s + a.y * b.z - a.z * b.y; + c.y = a.s * b.y + a.y * b.s + a.z * b.x - a.x * b.z; + c.z = a.s * b.z + a.z * b.s + a.x * b.y - a.y * b.x; + c.s = a.s * b.s - a.x * b.x - a.y * b.y - a.z * b.z; return c; } } @@ -411,7 +411,7 @@ namespace OpenSim.Region.ScriptEngine.Common output = "["; foreach (object o in m_data) { - if (o.GetType().ToString() == "System.String") + if (o is System.String) { output = output + "\"" + o + "\", "; } @@ -438,12 +438,26 @@ namespace OpenSim.Region.ScriptEngine.Common output = output + o.ToString(); } return output; + } - public class String + public struct String { + // Our own little string + internal string actualString; + public static implicit operator bool(String mString) + { + if (mString.actualString.Length == 0) + return true; + return false; + } + public override string ToString() + { + return actualString; + } } + } } } diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 109b8e2e43..dfdf8f470d 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -47,7 +47,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL dataTypes.Add("void", "void"); dataTypes.Add("integer", "int"); dataTypes.Add("float", "double"); - dataTypes.Add("string", "LSL_Types.String"); + dataTypes.Add("string", "string"); dataTypes.Add("key", "string"); dataTypes.Add("vector", "LSL_Types.Vector3"); dataTypes.Add("rotation", "LSL_Types.Quaternion");