modified behaviour of PropertySensor and MessageSensor on popular request.
[blender.git] / source / gameengine / GameLogic / SCA_PropertySensor.cpp
index 52642c6757f35bdb9bd5bcec7783f76764a8d251..979ce51ab5e55eefcfc9368f2bae50c48dccfc78 100644 (file)
 #include "SCA_EventManager.h"
 #include "SCA_LogicManager.h"
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr,
                                                                         SCA_IObject* gameobj,
                                                                         const STR_String& propname,
@@ -49,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;
@@ -256,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;
 }
 
@@ -314,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! */
 }