BGE: Fix for [#34398] "Ā«illegal operatorĀ» in Expression Controller" reported by Andre...
authorMitchell Stokes <mogurijin@gmail.com>
Mon, 22 Jul 2013 22:46:17 +0000 (22:46 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Mon, 22 Jul 2013 22:46:17 +0000 (22:46 +0000)
The expressions system now supports the not operator on ints and floats.

source/gameengine/Expressions/FloatValue.cpp
source/gameengine/Expressions/IntValue.cpp

index b7d7f52815516dc9cadc856b19790faa61939734..0f468e328edc4d5a191465943b16e71993444fa1 100644 (file)
@@ -97,7 +97,7 @@ ret: a new object containing the result of applying operator op to this
                return new CFloatValue (-m_float);
                break;
        case VALUE_NOT_OPERATOR:
-               return new CErrorValue (op2str(op) + "only allowed on booleans");
+               return new CBoolValue (m_float == 0.f);
                break;
        case VALUE_AND_OPERATOR:
        case VALUE_OR_OPERATOR:
@@ -160,6 +160,9 @@ ret: a new object containing the result of applying operator op to val and
                                case VALUE_LEQ_OPERATOR:
                                        ret = new CBoolValue(((CIntValue *) val)->GetInt() <= m_float);
                                        break;
+                               case VALUE_NOT_OPERATOR:
+                                       ret = new CBoolValue(m_float == 0);
+                                       break;
                                default:
                                        ret = new CErrorValue("illegal operator. please send a bug report.");
                                        break;
@@ -212,7 +215,9 @@ ret: a new object containing the result of applying operator op to val and
                                case VALUE_POS_OPERATOR:
                                        ret = new CFloatValue (m_float);
                                        break;
-
+                               case VALUE_NOT_OPERATOR:
+                                       ret = new CBoolValue(m_float == 0);
+                                       break;
                                default:
                                        ret = new CErrorValue("illegal operator. please send a bug report.");
                                        break;
index 2cacea984674b68a4b4ac088bab38a1ede751508..fa4c9ad8ac991e759639ab616707052ef9db1b88 100644 (file)
@@ -96,7 +96,7 @@ object and val
                return new CIntValue (-m_int);
                break;
        case VALUE_NOT_OPERATOR:
-               return new CErrorValue (op2str(op) + "only allowed on booleans");
+               return new CBoolValue (m_int == 0);
                break;
        case VALUE_AND_OPERATOR:
        case VALUE_OR_OPERATOR:
@@ -170,7 +170,11 @@ CValue* CIntValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *v
                                case VALUE_POS_OPERATOR:
                                        ret = new CIntValue (m_int);
                                        break;
+                               case VALUE_NOT_OPERATOR:
+                                       ret = new CBoolValue(m_int == 0);
+                                       break;
                                default:
+                                       printf("Found op: %d\n", op);
                                        ret = new CErrorValue("illegal operator. please send a bug report.");
                                        break;
                        }
@@ -215,6 +219,9 @@ CValue* CIntValue::CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *v
                                case VALUE_LEQ_OPERATOR:
                                        ret = new CBoolValue(((CFloatValue *) val)->GetFloat() <= m_int);
                                        break;
+                               case VALUE_NOT_OPERATOR:
+                                       ret = new CBoolValue(m_int == 0);
+                                       break;
                                default:
                                        ret = new CErrorValue("illegal operator. please send a bug report.");
                                        break;