modified behaviour of PropertySensor and MessageSensor on popular request.
[blender.git] / source / gameengine / GameLogic / SCA_PropertySensor.cpp
index 6fceddcb5f889a0a79eeb9d4d15e3480d3095928..979ce51ab5e55eefcfc9368f2bae50c48dccfc78 100644 (file)
@@ -53,12 +53,12 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr,
                                                                         KX_PROPSENSOR_TYPE checktype,
                                                                         PyTypeObject* T )
        : SCA_ISensor(gameobj,eventmgr,T),
-         m_checkpropname(propname),
+         m_checktype(checktype),
          m_checkpropval(propval),
          m_checkpropmaxval(propmaxval),
-         m_checktype(checktype),
-         m_range_expr(NULL),
-         m_lastresult(false)
+         m_checkpropname(propname),
+         m_lastresult(false),
+         m_range_expr(NULL)
 {
        m_recentresult=false;
        //CParser pars;
@@ -260,7 +260,16 @@ bool       SCA_PropertySensor::CheckPropertyCondition()
        default:
                ; /* error */
        }
-       m_recentresult=result;
+
+       //the concept of Edge and Level triggering has unwanted effect for KX_PROPSENSOR_CHANGED
+       //see Game Engine bugtracker [ #3809 ]
+       if (m_checktype != KX_PROPSENSOR_CHANGED)
+       {
+               m_recentresult=result;
+       } else
+       {
+               m_recentresult=true;
+       }
        return result;
 }
 
@@ -318,7 +327,7 @@ PyMethodDef SCA_PropertySensor::Methods[] = {
        {NULL,NULL} //Sentinel
 };
 
-PyObject* SCA_PropertySensor::_getattr(char* attr) {
+PyObject* SCA_PropertySensor::_getattr(const STR_String& attr) {
        _getattr_up(SCA_ISensor); /* implicit return! */
 }