diff options
author | Benoit Bolsee <benoit.bolsee@online.be> | 2008-03-01 22:05:41 +0300 |
---|---|---|
committer | Benoit Bolsee <benoit.bolsee@online.be> | 2008-03-01 22:05:41 +0300 |
commit | 407b2d334d2facab83f847045aca45cc9ab49cde (patch) | |
tree | 6eb787af4645ba4f6ac1a36a7489cfe90efdd748 /source/gameengine/GameLogic/SCA_PropertySensor.cpp | |
parent | 8d81e154f60744b49c89ef79ec2f4b0325b1effe (diff) |
unknown property fixed in sensor/actuators
Diffstat (limited to 'source/gameengine/GameLogic/SCA_PropertySensor.cpp')
-rw-r--r-- | source/gameengine/GameLogic/SCA_PropertySensor.cpp | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index 09332b870c9..cdd0666947e 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -66,11 +66,11 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, //CValue* resultval = m_rightexpr->Calculate(); CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); - if (orgprop) + if (!orgprop->IsError()) { m_previoustext = orgprop->GetText(); - orgprop->Release(); } + orgprop->Release(); if (m_checktype==KX_PROPSENSOR_INTERVAL) { @@ -82,16 +82,28 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr, void SCA_PropertySensor::PrecalculateRangeExpression() { CParser pars; + //The context is needed to retrieve the property at runtime but it creates + //loop of references pars.SetContext(this->AddRef()); STR_String checkstr = "(" + m_checkpropval + " <= " + m_checkpropname + ") && ( " + m_checkpropname + " <= " - + m_checkpropmaxval; + + m_checkpropmaxval + ")"; m_range_expr = pars.ProcessText(checkstr); } - +// Forced deletion of precalculated range expression to break reference loop +// Use this function when you know that you won't use the sensor anymore +void SCA_PropertySensor::Delete() +{ + if (m_range_expr) + { + m_range_expr->Release(); + m_range_expr = NULL; + } + Release(); +} CValue* SCA_PropertySensor::GetReplica() { @@ -164,7 +176,7 @@ bool SCA_PropertySensor::CheckPropertyCondition() case KX_PROPSENSOR_EQUAL: { CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); - if (orgprop) + if (!orgprop->IsError()) { STR_String testprop = orgprop->GetText(); // Force strings to upper case, to avoid confusion in @@ -177,9 +189,8 @@ bool SCA_PropertySensor::CheckPropertyCondition() } else { result = (orgprop->GetText() == m_checkpropval); } - orgprop->Release(); - } + orgprop->Release(); if (reverse) result = !result; @@ -244,15 +255,15 @@ bool SCA_PropertySensor::CheckPropertyCondition() { CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname); - if (orgprop) + if (!orgprop->IsError()) { if (m_previoustext != orgprop->GetText()) { m_previoustext = orgprop->GetText(); result = true; } - orgprop->Release(); } + orgprop->Release(); //cout << " \nSens:Prop:changed!"; /* need implementation here!!! */ break; @@ -388,12 +399,13 @@ PyObject* SCA_PropertySensor::PySetProperty(PyObject* self, PyObject* args, PyOb return NULL; } - if (FindIdentifier(STR_String(propNameArg))) { + CValue *prop = FindIdentifier(STR_String(propNameArg)); + if (!prop->IsError()) { m_checkpropname = propNameArg; } else { ; /* error: bad property name */ } - + prop->Release(); Py_Return; } |