Ejemplo n.º 1
0
 public void default_event_touch_start(LSL_Types.LSLInteger num_detected)
 {
     LSL_Types.LSLInteger i = 0;
     LSL_Types.LSLInteger j = 14;
     LSL_Types.LSLFloat f = 0.0;
     LSL_Types.LSLFloat g = 14.0;
     LSL_Types.LSLString s = "";
     LSL_Types.LSLString t = "Hi there";
     LSL_Types.list l = new LSL_Types.list();
     LSL_Types.list m = new LSL_Types.list(1, 2, 3);
     LSL_Types.Vector3 v = new LSL_Types.Vector3(0.0, 0.0, 0.0);
     LSL_Types.Vector3 w = new LSL_Types.Vector3(1.0, 0.1, 0.5);
     LSL_Types.Quaternion r = new LSL_Types.Quaternion(0.0, 0.0, 0.0, 0.0);
     LSL_Types.Quaternion u = new LSL_Types.Quaternion(0.8, 0.7, 0.6, llSomeFunc());
     LSL_Types.LSLString k = "";
     LSL_Types.LSLString n = "ping";
 }
Ejemplo n.º 2
0
        // Set prim params for a torus, tube or ring and check results.
        public void CheckllSetPrimitiveParams(string primTest,
                                              LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut,
                                              float primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize,
                                              LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper,
                                              float primRev, float primRadius, float primSkew, float primHollowCheck)
        {
            // Set the prim params.
            m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize,
                                                             ScriptBaseClass.PRIM_TYPE, primType, primHoleType,
                                                             primCut, primHollow, primTwist, primHoleSize, primShear, primProfCut,
                                                             primTaper, primRev, primRadius, primSkew));

            // Get params for prim to validate settings.
            LSL_Types.list primParams =
                m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE));

            // Valdate settings.
            CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size");
            Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1),
                            "TestllSetPrimitiveParams " + primTest + " prim type check fail");
            Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2),
                            "TestllSetPrimitiveParams " + primTest + " prim hole default check fail");
            CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut");
            Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY,
                            "TestllSetPrimitiveParams " + primTest + " prim hollow check fail");
            CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist");
            CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size");
            CheckllSetPrimitiveParamsVector(primShear, m_lslApi.llList2Vector(primParams, 7), primTest + " prim shear");
            CheckllSetPrimitiveParamsVector(primProfCut, m_lslApi.llList2Vector(primParams, 8), primTest + " prim profile cut");
            CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 9), primTest + " prim taper");
            Assert.AreEqual(primRev, m_lslApi.llList2Float(primParams, 10), FLOAT_ACCURACY,
                            "TestllSetPrimitiveParams " + primTest + " prim revolutions fail");
            Assert.AreEqual(primRadius, m_lslApi.llList2Float(primParams, 11), FLOAT_ACCURACY,
                            "TestllSetPrimitiveParams " + primTest + " prim radius fail");
            Assert.AreEqual(primSkew, m_lslApi.llList2Float(primParams, 12), FLOAT_ACCURACY,
                            "TestllSetPrimitiveParams " + primTest + " prim skew fail");
        }
Ejemplo n.º 3
0
        public LSL_Types.list ParseValueToList(string inval, int start, out int end)
        {
            LSL_Types.list v = new LSL_Types.list();
            end = -1;
            char   c;
            string tr = ",}";

            char[] charany = tr.ToCharArray();
            string param   = "";
            int    totlen  = inval.Length;
            int    len;

            while (true)
            {
                try
                {
                    if (inval.Length == 0)
                    {
                        v.Add(new LSL_Types.LSLString(""));
                    }
                    else
                    {
                        c = inval[start++];
                        switch (c)
                        {
                        case 'i':
                            end = inval.IndexOfAny(charany, start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.LSLInteger(param));
                            break;

                        case 'f':
                            end = inval.IndexOfAny(charany, start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.LSLFloat(param));
                            break;

                        case 'v':
                            end = inval.IndexOf('>', start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.Vector3(param));
                            end++;
                            break;

                        case 'q':
                            end = inval.IndexOf('>', start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.Quaternion(param));
                            end++;
                            break;

                        case '"':
                            end = inval.IndexOf('"', start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.LSLString(param));
                            end++;
                            break;

                        case 'k':
                            start++;
                            end = inval.IndexOf('"', start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.key(param));
                            end++;
                            break;

                        case '{':
                            v.Add(ParseValueToList(inval, start, out end));
                            end++;
                            break;

                        default:
                            break;
                        }
                    }
                    start = end;
                    if (start == -1 || start >= totlen || (inval[start] == '}'))
                    {
                        break;
                    }
                    else
                    {
                        while (inval[start] == ',' || inval[start] == ' ')
                        {
                            start++;
                        }
                    }
                }
                catch
                {
                }
            }
            return(v);
        }
Ejemplo n.º 4
0
        public Dictionary <string, object> GetStoreVars()
        {
            Dictionary <string, object> vars = new Dictionary <string, object>();


            if (m_Fields == null)
            {
                return(vars);
            }

            m_Fields.Clear();

            Type t = GetType();

            FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
                                             BindingFlags.Public |
                                             BindingFlags.Instance |
                                             BindingFlags.DeclaredOnly);

            foreach (FieldInfo field in fields)
            {
                m_Fields[field.Name] = field;

                if (field.FieldType == typeof(LSL_Types.list)) // ref type, copy
                {
                    string         tmp = "";
                    string         cur = "";
                    LSL_Types.list v   = (LSL_Types.list)field.GetValue(this);
                    foreach (object o in v.Data)
                    {
                        if (o.GetType() == typeof(LSL_Types.LSLInteger))
                        {
                            cur = "i" + o.ToString();
                        }
                        else if (o.GetType() == typeof(LSL_Types.LSLFloat))
                        {
                            cur = "f" + o.ToString();
                        }
                        else if (o.GetType() == typeof(LSL_Types.Vector3))
                        {
                            cur = "v" + o.ToString();
                        }
                        else if (o.GetType() == typeof(LSL_Types.Quaternion))
                        {
                            cur = "q" + o.ToString();
                        }
                        else if (o.GetType() == typeof(LSL_Types.LSLString))
                        {
                            cur = "\"" + o.ToString() + "\"";
                        }
                        else if (o.GetType() == typeof(LSL_Types.key))
                        {
                            cur = "k\"" + o.ToString() + "\"";
                        }
                        else if (o.GetType() == typeof(LSL_Types.list))
                        {
                            cur = "{" + ListToString(o) + "}";
                        }

                        if (tmp == "")
                        {
                            tmp = cur;
                        }
                        else
                        {
                            tmp += ", " + cur;
                        }
                    }
                    vars[field.Name] = (Object)tmp;
                }
                else if (field.FieldType == typeof(LSL_Types.LSLInteger) ||
                         field.FieldType == typeof(LSL_Types.LSLString) ||
                         field.FieldType == typeof(LSL_Types.LSLFloat) ||
                         field.FieldType == typeof(Int32) ||
                         field.FieldType == typeof(Double) ||
                         field.FieldType == typeof(Single) ||
                         field.FieldType == typeof(String) ||
                         field.FieldType == typeof(Byte) ||
                         field.FieldType == typeof(short) ||
                         field.FieldType == typeof(LSL_Types.Vector3) ||
                         field.FieldType == typeof(LSL_Types.Quaternion))
                {
                    vars[field.Name] = field.GetValue(this).ToString();
                }
            }

            return(vars);
        }
Ejemplo n.º 5
0
        public void SetStoreVars(Dictionary <string, object> vars)
        {
            if (!m_useStateSaves)
            {
                return;
            }
            m_lastStateSaveValues = vars;
            m_stateSaveRequired   = false;
            //If something is setting the vars, we don't need to do a state save, as this came from a state save
            Type t = GetType();

            FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
                                             BindingFlags.Public |
                                             BindingFlags.Instance |
                                             BindingFlags.DeclaredOnly);

            foreach (FieldInfo field in fields)
            {
                if (vars.ContainsKey(field.Name))
                {
                    object var = vars[field.Name];
                    if (field.FieldType == typeof(LSL_Types.list))
                    {
                        string         val = var.ToString();
                        int            end;
                        LSL_Types.list v = ParseValueToList(val, 0, out end);
                        field.SetValue(this, v);
                    }
                    else if (field.FieldType == typeof(LSL_Types.LSLInteger))
                    {
                        int val = int.Parse(var.ToString());
                        field.SetValue(this, new LSL_Types.LSLInteger(val));
                    }
                    else if (field.FieldType == typeof(LSL_Types.LSLString))
                    {
                        string val = var.ToString();
                        field.SetValue(this, new LSL_Types.LSLString(val));
                    }
                    else if (field.FieldType == typeof(LSL_Types.LSLFloat))
                    {
                        float val = float.Parse(var.ToString());
                        field.SetValue(this, new LSL_Types.LSLFloat(val));
                    }
                    else if (field.FieldType == typeof(int))
                    {
                        int val = int.Parse(var.ToString());
                        field.SetValue(this, val);
                    }
                    else if (field.FieldType == typeof(double))
                    {
                        double val = double.Parse(var.ToString());
                        field.SetValue(this, val);
                    }
                    else if (field.FieldType == typeof(float))
                    {
                        float val = float.Parse(var.ToString());
                        field.SetValue(this, val);
                    }
                    else if (field.FieldType == typeof(string))
                    {
                        string val = var.ToString();
                        field.SetValue(this, val);
                    }
                    else if (field.FieldType == typeof(byte))
                    {
                        byte val = byte.Parse(var.ToString());
                        field.SetValue(this, val);
                    }
                    else if (field.FieldType == typeof(short))
                    {
                        short val = short.Parse(var.ToString());
                        field.SetValue(this, val);
                    }
                    else if (field.FieldType == typeof(LSL_Types.Quaternion))
                    {
                        LSL_Types.Quaternion val = new LSL_Types.Quaternion(var.ToString());
                        field.SetValue(this, val);
                    }
                    else if (field.FieldType == typeof(LSL_Types.Vector3))
                    {
                        LSL_Types.Vector3 val = new LSL_Types.Vector3(var.ToString());
                        field.SetValue(this, val);
                    }
                }
            }
            fields = null;
            t      = null;
        }
Ejemplo n.º 6
0
 public void default_event_state_entry()
 {
     LSL_Types.list l = new LSL_Types.list("hello");
     l = (l = new LSL_Types.list()) + l + "world";
 }
Ejemplo n.º 7
0
 public double osList2Double(LSL_Types.list src, int index)
 {
     return(m_OSSL_Functions.osList2Double(src, index));
 }
Ejemplo n.º 8
0
        public Dictionary<string, object> GetVars()
        {
            Dictionary<string, object> vars = new Dictionary<string, object>();

            Type t = GetType();

            FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
                                             BindingFlags.Public |
                                             BindingFlags.Instance |
                                             BindingFlags.DeclaredOnly);

            foreach (FieldInfo field in fields)
            {
                if (field.FieldType == typeof (LSL_Types.list)) // ref type, copy
                {
                    LSL_Types.list v = (LSL_Types.list) field.GetValue(this);
                    if (((object) v) == null)
                        continue; //Broken... :/
                    Object[] data = new Object[v.Data.Length];
                    Array.Copy(v.Data, 0, data, 0, v.Data.Length);
                    LSL_Types.list c = new LSL_Types.list {Data = data};
                    vars[field.Name] = c;
                }
                else if (field.FieldType == typeof (LSL_Types.LSLInteger) ||
                         field.FieldType == typeof (LSL_Types.LSLString) ||
                         field.FieldType == typeof (LSL_Types.LSLFloat) ||
                         field.FieldType == typeof (Int32) ||
                         field.FieldType == typeof (Double) ||
                         field.FieldType == typeof (Single) ||
                         field.FieldType == typeof (String) ||
                         field.FieldType == typeof (Byte) ||
                         field.FieldType == typeof (short) ||
                         field.FieldType == typeof (LSL_Types.Vector3) ||
                         field.FieldType == typeof (LSL_Types.Quaternion))
                {
                    vars[field.Name] = field.GetValue(this);
                }
            }
            fields = null;
            t = null;

            return vars;
        }
Ejemplo n.º 9
0
 public LSL_List AADeserializeXMLValues(LSL_String xmlFile)
 {
     ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "AADeserializeXMLValues", m_host, "AA");
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(xmlFile.m_string);
     XmlNodeList children = doc.ChildNodes;
     LSL_List values = new LSL_Types.list();
     foreach (XmlNode node in children)
     {
         values.Add(node.InnerText);
     }
     return values;
 }
Ejemplo n.º 10
0
 public LSL_List aaGetTeamMembers(LSL_String team)
 {
     if(!ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "AAGetTeamMembers", m_host, "AA", m_itemID)) return new LSL_List();
     List<UUID> Members = new List<UUID>();
     ICombatModule module = World.RequestModuleInterface<ICombatModule>();
     if (module != null)
     {
         Members = module.GetTeammates(team);
     }
     LSL_List members = new LSL_Types.list();
     foreach(UUID member in Members)
         members.Add(new LSL_Key(member.ToString()));
     return members;
 }
Ejemplo n.º 11
0
 public void osMakeScript(string scriptName, LSL_Types.list contents)
 {
     m_OSSL_Functions.osMakeScript(scriptName, contents);
 }
Ejemplo n.º 12
0
        public void SetStoreVars(Dictionary <string, object> vars)
        {
            m_lastStateSaveValues = vars;
            m_stateSaveRequired   = false; //If something is setting the vars, we don't need to do a state save, as this came from a state save
            foreach (KeyValuePair <string, object> var in vars)
            {
                if (m_Fields.ContainsKey(var.Key))
                {
                    try
                    {
                        if (m_Fields[var.Key].FieldType == typeof(LSL_Types.list))
                        {
                            string         val = var.Value.ToString();
                            int            end;
                            LSL_Types.list v = ParseValueToList(val, 0, out end);
                            m_Fields[var.Key].SetValue(this, v);
                        }

                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLInteger))
                        {
                            int val = int.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, new LSL_Types.LSLInteger(val));
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLString))
                        {
                            string val = var.Value.ToString();
                            m_Fields[var.Key].SetValue(this, new LSL_Types.LSLString(val));
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLFloat))
                        {
                            float val = float.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, new LSL_Types.LSLFloat(val));
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(Int32))
                        {
                            Int32 val = Int32.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(Double))
                        {
                            Double val = Double.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(Single))
                        {
                            Single val = Single.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(String))
                        {
                            String val = var.Value.ToString();
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(Byte))
                        {
                            Byte val = Byte.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(short))
                        {
                            short val = short.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.Quaternion))
                        {
                            LSL_Types.Quaternion val = new LSL_Types.Quaternion(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.Vector3))
                        {
                            LSL_Types.Vector3 val = new LSL_Types.Vector3(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                    }
                    catch (Exception) { }
                }
            }
        }
Ejemplo n.º 13
0
        public LSL_Types.list ParseValueToList(string inval, int start, out int end)
        {
            LSL_Types.list v = new LSL_Types.list();
            end = -1;
            char c;
            string tr = ",}";
            char[] charany = tr.ToCharArray();
            string param = "";
            int totlen = inval.Length;
            int len;

            while (true)
            {
                try
                {
                    if (inval.Length == 0)
                        v.Add(new LSL_Types.LSLString(""));
                    else
                    {
                        c = inval[start++];
                        switch (c)
                        {
                            case 'i':
                                end = inval.IndexOfAny(charany, start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.LSLInteger(param));
                                break;
                            case 'f':
                                end = inval.IndexOfAny(charany, start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.LSLFloat(param));
                                break;
                            case 'v':
                                end = inval.IndexOf('>', start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.Vector3(param));
                                end++;
                                break;
                            case 'q':
                                end = inval.IndexOf('>', start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.Quaternion(param));
                                end++;
                                break;
                            case '"':
                                end = inval.IndexOf('"', start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.LSLString(param));
                                end++;
                                break;
                            case 'k':
                                start++;
                                end = inval.IndexOf('"', start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.key(param));
                                end++;
                                break;
                            case '{':
                                v.Add(ParseValueToList(inval, start, out end));
                                end++;
                                break;

                            default:
                                break;
                        }
                    }
                    start = end;
                    if (start == -1 || start >= totlen || (inval[start] == '}'))
                        break;
                    else
                        while (inval[start] == ',' || inval[start] == ' ')
                            start++;
                }
                catch
                {
                }
            }
            return v;
        }
Ejemplo n.º 14
0
 public void default_event_touch_start(LSL_Types.LSLInteger num_detected)
 {
     LSL_Types.list l = new LSL_Types.list();
     LSL_Types.list m = new LSL_Types.list(1, two, "three", new LSL_Types.Vector3(4.0, 4.0, 4.0), 5 + 5);
     llCallSomeFunc(1, llAnotherFunc(), new LSL_Types.list(1, 2, 3));
 }
Ejemplo n.º 15
0
        public void SetStoreVars(Dictionary <string, object> vars)
        {
            foreach (KeyValuePair <string, object> var in vars)
            {
                if (m_Fields.ContainsKey(var.Key))
                {
                    try
                    {
                        if (m_Fields[var.Key].FieldType == typeof(LSL_Types.list))
                        {
                            string         val = var.Value.ToString();
                            int            end;
                            LSL_Types.list v = ParseValueToList(val, 0, out end);
                            m_Fields[var.Key].SetValue(this, v);
                        }

                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLInteger))
                        {
                            int val = int.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, new LSL_Types.LSLInteger(val));
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLString))
                        {
                            string val = var.Value.ToString();
                            m_Fields[var.Key].SetValue(this, new LSL_Types.LSLString(val));
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLFloat))
                        {
                            float val = float.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, new LSL_Types.LSLFloat(val));
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(Int32))
                        {
                            Int32 val = Int32.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(Double))
                        {
                            Double val = Double.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(Single))
                        {
                            Single val = Single.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(String))
                        {
                            String val = var.Value.ToString();
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(Byte))
                        {
                            Byte val = Byte.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(short))
                        {
                            short val = short.Parse(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.Quaternion))
                        {
                            LSL_Types.Quaternion val = new LSL_Types.Quaternion(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                        else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.Vector3))
                        {
                            LSL_Types.Vector3 val = new LSL_Types.Vector3(var.Value.ToString());
                            m_Fields[var.Key].SetValue(this, val);
                        }
                    }
                    catch (Exception) { }
                }
            }
        }
Ejemplo n.º 16
0
 public LSL_List aaDeserializeXMLKeys(LSL_String xmlFile)
 {
     ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "AADeserializeXMLKeys", m_host, "AA");
     XmlDocument doc = new XmlDocument();
     doc.LoadXml(xmlFile.m_string);
     XmlNodeList children = doc.ChildNodes;
     LSL_List keys = new LSL_Types.list();
     foreach (XmlNode node in children)
     {
         keys.Add(node.Name);
     }
     return keys;
 }
Ejemplo n.º 17
0
        public LSL_List AAQueryDatabase(LSL_String key, LSL_String token)
        {
            ScriptProtection.CheckThreatLevel(ThreatLevel.Moderate, "AAQueryDatabase", m_host, "AA");

            List<string> query = AssetConnector.FindLSLData(token.m_string, key.m_string);
            LSL_List list = new LSL_Types.list(query.ToArray());
            return list;
        }
Ejemplo n.º 18
0
 public LSL_List aaGetTeamMembers(LSL_String team)
 {
     ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "AAGetTeamMembers", m_host, "AA");
     List<UUID> Members = new List<UUID>();
     ICombatModule module = World.RequestModuleInterface<ICombatModule>();
     if (module != null)
     {
         Members = module.GetTeammates(team);
     }
     LSL_List members = new LSL_Types.list(Members.ToArray());
     return members;
 }
Ejemplo n.º 19
0
 public LSL_List AAGetTeamMembers()
 {
     ScriptProtection.CheckThreatLevel(ThreatLevel.Low, "AAGetTeamMembers", m_host, "AA");
     ScenePresence SP = World.GetScenePresence(m_host.OwnerID);
     List<UUID> Members = new List<UUID>();
     if (SP != null)
     {
         ICombatPresence CP = SP.RequestModuleInterface<ICombatPresence>();
         if (CP != null)
         {
             Members = CP.GetTeammates();
         }
     }
     LSL_List members = new LSL_Types.list(Members.ToArray());
     return members;
 }
Ejemplo n.º 20
0
        public Dictionary <string, object> GetStoreVars()
        {
            Dictionary <string, object> vars = new Dictionary <string, object>();

            if (!m_useStateSaves)
            {
                return(vars);
            }

            Type t = GetType();

            FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
                                             BindingFlags.Public |
                                             BindingFlags.Instance |
                                             BindingFlags.DeclaredOnly);

            foreach (FieldInfo field in fields)
            {
                if (field.FieldType == typeof(LSL_Types.list))  // ref type, copy
                {
                    string         tmp = "";
                    string         cur = "";
                    LSL_Types.list v   = (LSL_Types.list)field.GetValue(this);
                    foreach (object o in v.Data)
                    {
                        if (o is LSL_Types.LSLInteger)
                        {
                            cur = "i" + o;
                        }
                        else if (o is LSL_Types.LSLFloat)
                        {
                            cur = "f" + o;
                        }
                        else if (o is LSL_Types.Vector3)
                        {
                            cur = "v" + o;
                        }
                        else if (o is LSL_Types.Quaternion)
                        {
                            cur = "q" + o;
                        }
                        else if (o is LSL_Types.LSLString)
                        {
                            cur = "\"" + EscapeString(o.ToString()) + "\"";
                        }
                        else if (o.GetType() == typeof(LSL_Types.list))
                        {
                            cur = "{" + ListToString(o) + "}";
                        }

                        if (tmp == "")
                        {
                            tmp = cur;
                        }
                        else
                        {
                            tmp += ", " + cur;
                        }
                    }
                    vars[field.Name] = tmp;
                }
                else if (field.FieldType == typeof(LSL_Types.LSLInteger) ||
                         field.FieldType == typeof(LSL_Types.LSLString) ||
                         field.FieldType == typeof(LSL_Types.LSLFloat) ||
                         field.FieldType == typeof(int) ||
                         field.FieldType == typeof(double) ||
                         field.FieldType == typeof(float) ||
                         field.FieldType == typeof(string) ||
                         field.FieldType == typeof(byte) ||
                         field.FieldType == typeof(short) ||
                         field.FieldType == typeof(LSL_Types.Vector3) ||
                         field.FieldType == typeof(LSL_Types.Quaternion))
                {
                    vars[field.Name] = field.GetValue(this).ToString();
                }
            }
            fields = null;
            t      = null;

            return(vars);
        }
Ejemplo n.º 21
0
        public LSL_Types.list ParseValueToList(string inval, int start, out int end)
        {
            LSL_Types.list v = new LSL_Types.list();
            end = -1;
            char c;
            string tr = ",}";
            char[] charany = tr.ToCharArray();
            string param = "";
            int totlen = inval.Length;
            int len;
            DateTime time_limit = DateTime.Now.AddSeconds(5.0);

            while (true)
            {
                try
                {
                    if (inval.Length == 0)
                        v.Add(new LSL_Types.LSLString(""));
                    else
                    {
                        c = inval[start++];
                        switch (c)
                        {
                            case 'i':
                                end = inval.IndexOfAny(charany, start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.LSLInteger(param));
                                break;
                            case 'f':
                                end = inval.IndexOfAny(charany, start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.LSLFloat(param));
                                break;
                            case 'v':
                                end = inval.IndexOf('>', start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.Vector3(param));
                                end++;
                                break;
                            case 'q':
                                end = inval.IndexOf('>', start);
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = inval.Substring(start, len);
                                v.Add(new LSL_Types.Quaternion(param));
                                end++;
                                break;
                            case '"':
                                end = inval.IndexOf('"', start);
                                while (inval[end - 1] == '\\')
                                {
                                    int slashes = 2;
                                    while (end - slashes > 0 && inval[end - slashes] == '\\')
                                        slashes++;
                                    if ((slashes - 1)%2 == 0)
                                        end = inval.IndexOf('"', end + 1);
                                    else
                                        break;
                                }
                                if (end > 0)
                                    len = end - start;
                                else
                                    len = totlen - start;
                                param = UnEscapeString(inval.Substring(start, len));
                                v.Add(new LSL_Types.LSLString(param));
                                end++;
                                break;
                            case '{':
                                v.Add(ParseValueToList(inval, start, out end));
                                end++;
                                break;

                            default:
                                break;
                        }
                    }
                    start = end;
                    if (start == -1 || start >= totlen || (inval[start] == '}'))
                        break;
                    else
                        while ((inval[start] == ',' || inval[start] == ' ') && DateTime.Now.CompareTo(time_limit) < 0)
                            start++;
                    if (DateTime.Now.CompareTo(time_limit) > 0)
                        break;
                }
                catch
                {
                }
            }
            return v;
        }
Ejemplo n.º 22
0
        public LSL_Types.list ParseValueToList(string inval, int start, out int end)
        {
            LSL_Types.list v = new LSL_Types.list();
            end = -1;
            char   c;
            string tr = ",}";

            char[]   charany = tr.ToCharArray();
            string   param   = "";
            int      totlen  = inval.Length;
            int      len;
            DateTime time_limit = DateTime.Now.AddSeconds(5.0);

            while (true)
            {
                try
                {
                    if (inval.Length == 0)
                    {
                        v.Add(new LSL_Types.LSLString(""));
                    }
                    else
                    {
                        c = inval[start++];
                        switch (c)
                        {
                        case 'i':
                            end = inval.IndexOfAny(charany, start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.LSLInteger(param));
                            break;

                        case 'f':
                            end = inval.IndexOfAny(charany, start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.LSLFloat(param));
                            break;

                        case 'v':
                            end = inval.IndexOf('>', start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.Vector3(param));
                            end++;
                            break;

                        case 'q':
                            end = inval.IndexOf('>', start);
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = inval.Substring(start, len);
                            v.Add(new LSL_Types.Quaternion(param));
                            end++;
                            break;

                        case '"':
                            end = inval.IndexOf('"', start);
                            while (inval[end - 1] == '\\')
                            {
                                int slashes = 2;
                                while (end - slashes > 0 && inval[end - slashes] == '\\')
                                {
                                    slashes++;
                                }
                                if ((slashes - 1) % 2 == 0)
                                {
                                    end = inval.IndexOf('"', end + 1);
                                }
                                else
                                {
                                    break;
                                }
                            }
                            if (end > 0)
                            {
                                len = end - start;
                            }
                            else
                            {
                                len = totlen - start;
                            }
                            param = UnEscapeString(inval.Substring(start, len));
                            v.Add(new LSL_Types.LSLString(param));
                            end++;
                            break;

                        case '{':
                            v.Add(ParseValueToList(inval, start, out end));
                            end++;
                            break;

                        default:
                            break;
                        }
                    }
                    start = end;
                    if (start == -1 || start >= totlen || (inval[start] == '}'))
                    {
                        break;
                    }
                    else
                    {
                        while ((inval[start] == ',' || inval[start] == ' ') && DateTime.Now.CompareTo(time_limit) < 0)
                        {
                            start++;
                        }
                    }
                    if (DateTime.Now.CompareTo(time_limit) > 0)
                    {
                        break;
                    }
                }
                catch
                {
                }
            }
            return(v);
        }
Ejemplo n.º 23
0
 public void osMakeNotecard(string notecardName, LSL_Types.list contents)
 {
     m_OSSL_Functions.osMakeNotecard(notecardName, contents);
 }
Ejemplo n.º 24
0
 public GLOBALS()
 {
     this.V_modeDebug = new LSL_Types.LSLInteger(1);
     this.V_data_pos  = (new LSL_Types.list((new LSL_Types.Vector3(0.0, 0.0, 0.0)), (new LSL_Types.Vector3(0.0, 0.0, 0.0)), (new LSL_Types.Vector3(0.0, 0.0, 0.0)), (new LSL_Types.Vector3(0.0, 0.0, 0.0)), (new LSL_Types.Vector3(0.0, 0.0, 0.0)), (new LSL_Types.Vector3(0.0, 0.0, 0.0))));
     this.V_data_rot  = (new LSL_Types.list((new LSL_Types.Quaternion(0.0, 0.0, 0.0, 0.0)), (new LSL_Types.Quaternion(0.0, 0.0, 0.0, 0.0)), (new LSL_Types.Quaternion(0.0, 0.0, 0.0, 0.0)), (new LSL_Types.Quaternion(0.0, 0.0, 0.0, 0.0)), (new LSL_Types.Quaternion(0.0, 0.0, 0.0, 0.0)), (new LSL_Types.Quaternion(0.0, 0.0, 0.0, 0.0))));
 }