Ejemplo n.º 1
0
        public void Parse(string str, int[] pars)
        {
            str = ConvertStirng(str);

            string tmp = InsertParValues(str, pars, false);

            tmp = "(" + tmp + ")";
            QuestTCPVariant range = Calc(tmp);
            double          value = range.GetValue();

            value = (value < -2000000000) ? -2000000000 : value;
            value = (value > 2000000000) ? 2000000000 : value;

            try
            {
                answer = (int)Math.Round(value + +0.00000000001f);
            }
            catch
            {
                calc_error = true;
                error      = true;
                answer     = 0;
            }
            if ((answer < 0) && (value > 0))
            {
                calc_error = true;
                error      = true;
                answer     = 0;
            }
            if (calc_error)
            {
                error = true;
            }
        }
Ejemplo n.º 2
0
        private void OpDiv(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result)
        {
            result.Clear();
            double l = lf.GetValue();
            double r = rf.GetValue();

            if (r == 0)
            {
                result.vf = (l < 0) ? -2000000000 : 2000000000;
            }
            else
            {
                result.vf = l / r;
            }
        }
Ejemplo n.º 3
0
 private void OpIn(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result)
 {
     result.Clear();
     if ((lf.vtype == QuestTCPVType.vtExt) && (rf.vtype == QuestTCPVType.vtExt))
     {
         result.vf = lf.vf == rf.vf ? 1 : 0;
     }
     else if ((lf.vtype == QuestTCPVType.vtRange) && (rf.vtype == QuestTCPVType.vtExt))
     {
         result.vf = lf.vd.Have(rf.vf) ? 1 : 0;
     }
     else if ((lf.vtype == QuestTCPVType.vtExt) && (rf.vtype == QuestTCPVType.vtRange))
     {
         result.vf = rf.vd.Have(lf.vf) ? 1 : 0;
     }
     else if ((lf.vtype == QuestTCPVType.vtRange) && (rf.vtype == QuestTCPVType.vtRange))
     {
         result.vf = rf.vd.Have(lf.GetValue()) ? 1 : 0;
     }
 }
Ejemplo n.º 4
0
        private void OpMod(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result)
        {
            result.Clear();
            double l = lf.GetValue();
            double r = rf.GetValue();

            r = Math.Truncate(r);
            if (r == 0)
            {
                result.vf = (l < 0) ? -2000000000 : 2000000000;
            }
            else
            {
                r = (r < 0) ? -r: r;
                bool ldz = l < 0;
                l         = ldz ? -l : l;
                result.vf = Math.Truncate(l - r * Math.Truncate(l / r));
                result.vf = ldz ? -result.vf : result.vf;
            }
        }
Ejemplo n.º 5
0
 private void OpNotEq(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result)
 {
     result.Clear();
     result.vf = lf.GetValue() != rf.GetValue() ? 1 : 0;
 }
Ejemplo n.º 6
0
 private void OpMul(QuestTCPVariant lf, QuestTCPVariant rf, ref QuestTCPVariant result)
 {
     result.Clear();
     result.vf = lf.GetValue() * rf.GetValue();
 }