Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/gameengine/Ketsji/KX_GameObject.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 5ca780bb319..85d09d9f5d5 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -157,7 +157,8 @@ KX_GameObject::~KX_GameObject()
#ifdef WITH_PYTHON
if (m_attr_dict) {
PyDict_Clear(m_attr_dict); /* incase of circular refs or other weired cases */
- Py_DECREF(m_attr_dict);
+ /* Py_CLEAR: Py_DECREF's and NULL's */
+ Py_CLEAR(m_attr_dict);
}
#endif // WITH_PYTHON
}
@@ -1262,16 +1263,16 @@ static int mathutils_kxgameob_generic_check(BaseMathObject *bmo)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
- return 1;
+ return 0;
}
static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
#define PHYS_ERR(attr) PyErr_SetString(PyExc_AttributeError, "KX_GameObject." attr ", is missing a physics controller")
@@ -1289,26 +1290,26 @@ static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype)
self->NodeGetWorldScaling().getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_INERTIA_LOCAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("localInertia"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("localInertia"), -1;
self->GetPhysicsController()->GetLocalInertia().getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_OBJECT_COLOR:
self->GetObjectColor().getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_LINVEL_LOCAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), -1;
self->GetLinearVelocity(true).getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_LINVEL_GLOBAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), -1;
self->GetLinearVelocity(false).getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_ANGVEL_LOCAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("localLinearVelocity"), -1;
self->GetAngularVelocity(true).getValue(bmo->data);
break;
case MATHUTILS_VEC_CB_ANGVEL_GLOBAL:
- if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), 0;
+ if(!self->GetPhysicsController()) return PHYS_ERR("worldLinearVelocity"), -1;
self->GetAngularVelocity(false).getValue(bmo->data);
break;
@@ -1316,14 +1317,14 @@ static int mathutils_kxgameob_vector_get(BaseMathObject *bmo, int subtype)
#undef PHYS_ERR
- return 1;
+ return 0;
}
static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
switch(subtype) {
case MATHUTILS_VEC_CB_POS_LOCAL:
@@ -1340,7 +1341,7 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
break;
case MATHUTILS_VEC_CB_SCALE_GLOBAL:
PyErr_SetString(PyExc_AttributeError, "KX_GameObject.worldScale is read-only");
- return 0;
+ return -1;
case MATHUTILS_VEC_CB_INERTIA_LOCAL:
/* read only */
break;
@@ -1361,15 +1362,15 @@ static int mathutils_kxgameob_vector_set(BaseMathObject *bmo, int subtype)
break;
}
- return 1;
+ return 0;
}
static int mathutils_kxgameob_vector_get_index(BaseMathObject *bmo, int subtype, int index)
{
/* lazy, avoid repeteing the case statement */
- if(!mathutils_kxgameob_vector_get(bmo, subtype))
- return 0;
- return 1;
+ if(mathutils_kxgameob_vector_get(bmo, subtype) == -1)
+ return -1;
+ return 0;
}
static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype, int index)
@@ -1377,8 +1378,8 @@ static int mathutils_kxgameob_vector_set_index(BaseMathObject *bmo, int subtype,
float f= bmo->data[index];
/* lazy, avoid repeteing the case statement */
- if(!mathutils_kxgameob_vector_get(bmo, subtype))
- return 0;
+ if(mathutils_kxgameob_vector_get(bmo, subtype) == -1)
+ return -1;
bmo->data[index]= f;
return mathutils_kxgameob_vector_set(bmo, subtype);
@@ -1402,7 +1403,7 @@ static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
switch(subtype) {
case MATHUTILS_MAT_CB_ORI_LOCAL:
@@ -1413,7 +1414,7 @@ static int mathutils_kxgameob_matrix_get(BaseMathObject *bmo, int subtype)
break;
}
- return 1;
+ return 0;
}
@@ -1421,7 +1422,7 @@ static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype)
{
KX_GameObject* self= static_cast<KX_GameObject*>BGE_PROXY_REF(bmo->cb_user);
if(self==NULL)
- return 0;
+ return -1;
MT_Matrix3x3 mat3x3;
switch(subtype) {
@@ -1437,7 +1438,7 @@ static int mathutils_kxgameob_matrix_set(BaseMathObject *bmo, int subtype)
break;
}
- return 1;
+ return 0;
}
Mathutils_Callback mathutils_kxgameob_matrix_cb = {