BGE Py API
authorCampbell Barton <ideasman42@gmail.com>
Tue, 19 May 2009 07:16:40 +0000 (07:16 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 19 May 2009 07:16:40 +0000 (07:16 +0000)
use PY_SET_ATTR_FAIL and PY_SET_ATTR_SUCCESS return values so the fake subclassing can know if a value failed to be set or if it was missing from the type. (with PY_SET_ATTR_MISSING)

Also noticed some other mistakes.
- KX_LightObject, setting the type didnt check for an int.
- KX_SoundActuator, didnt return an error when assigning an invalid orientation value
- KX_GameObject, worldOrientation didnt return an error value.

16 files changed:
source/gameengine/Converter/BL_ActionActuator.cpp
source/gameengine/Converter/BL_ShapeActionActuator.cpp
source/gameengine/GameLogic/SCA_PythonController.cpp
source/gameengine/GameLogic/SCA_RandomActuator.cpp
source/gameengine/GameLogic/SCA_RandomSensor.cpp
source/gameengine/Ketsji/KX_CDActuator.cpp
source/gameengine/Ketsji/KX_Camera.cpp
source/gameengine/Ketsji/KX_CameraActuator.cpp
source/gameengine/Ketsji/KX_GameObject.cpp
source/gameengine/Ketsji/KX_Light.cpp
source/gameengine/Ketsji/KX_ParentActuator.cpp
source/gameengine/Ketsji/KX_PolygonMaterial.cpp
source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
source/gameengine/Ketsji/KX_SoundActuator.cpp
source/gameengine/Ketsji/KX_TrackToActuator.cpp

index d0a4a87af7268f92c1b172d5557a754df714c1e3..0812693ee0ad5e83aa26fe9c4222883c01832665 100644 (file)
@@ -1037,7 +1037,7 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF
        if (!PyString_Check(value))
        {
                PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, expected the string name of the action");
-               return -1;
+               return PY_SET_ATTR_FAIL;
        }
 
        bAction *action= NULL;
@@ -1049,11 +1049,11 @@ int BL_ActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE_DEF
                if (!action)
                {
                        PyErr_SetString(PyExc_ValueError, "actuator.action = val: Action Actuator, action not found!");
-                       return 1;
+                       return PY_SET_ATTR_FAIL;
                }
        }
        
        self->SetAction(action);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 
 }
index a24d83da90c7b03255c9ea80c3c961d689b67544..bf7edb5f641cb0a6e8625a8d6626d9b2e1e0fe68 100644 (file)
@@ -870,7 +870,7 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE
        if (!PyString_Check(value))
        {
                PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, expected the string name of the action");
-               return -1;
+               return PY_SET_ATTR_FAIL;
        }
 
        bAction *action= NULL;
@@ -882,11 +882,11 @@ int BL_ShapeActionActuator::pyattr_set_action(void *self_v, const KX_PYATTRIBUTE
                if (action==NULL)
                {
                        PyErr_SetString(PyExc_ValueError, "actuator.action = val: Shape Action Actuator, action not found!");
-                       return 1;
+                       return PY_SET_ATTR_FAIL;
                }
        }
        
        self->SetAction(action);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 
 }
index abb3b36b91eb2a8b6f919bef3549629a206bf339..d58259457e6daf2234e855f512fc6306a2461687 100644 (file)
@@ -563,14 +563,14 @@ int SCA_PythonController::pyattr_set_script(void *self_v, const KX_PYATTRIBUTE_D
        
        if (scriptArg==NULL) {
                PyErr_SetString(PyExc_TypeError, "controller.script = string: Python Controller, expected a string script text");
-               return -1;
+               return PY_SET_ATTR_FAIL;
        }
 
        /* set scripttext sets m_bModified to true, 
                so next time the script is needed, a reparse into byte code is done */
        self->SetScriptText(scriptArg);
                
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 
index ff957d8350e079d5db73826f0e5bafefd3cd34d2..1bc4487b5bf9bc885687dea7250a4ce852972169 100644 (file)
@@ -387,10 +387,10 @@ int SCA_RandomActuator::pyattr_set_seed(void *self, const struct KX_PYATTRIBUTE_
        if (PyInt_Check(value)) {
                int ival = PyInt_AsLong(value);
                act->m_base->SetSeed(ival);
-               return 0;
+               return PY_SET_ATTR_SUCCESS;
        } else {
                PyErr_SetString(PyExc_TypeError, "actuator.seed = int: Random Actuator, expected an integer");
-               return 1;
+               return PY_SET_ATTR_FAIL;
        }
 }
 
index 1581a29480ec411922487a47a1f496c997ac7d11..3c04173d10eb124a532948fdbe2df9afd95e5007 100644 (file)
@@ -236,10 +236,10 @@ int SCA_RandomSensor::pyattr_set_seed(void *self_v, const KX_PYATTRIBUTE_DEF *at
        SCA_RandomSensor* self= static_cast<SCA_RandomSensor*>(self_v);
        if (!PyInt_Check(value)) {
                PyErr_SetString(PyExc_TypeError, "sensor.seed = int: Random Sensor, expected an integer");
-               return -1;
+               return PY_SET_ATTR_FAIL;
        }
        self->m_basegenerator->SetSeed(PyInt_AsLong(value));
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 /* eof */
index 7f8505afa3d904842578348f6581315267f3ee36..8511526fd5ff3b211b1b02ddfc94a3e3bf051bab 100644 (file)
@@ -214,7 +214,7 @@ int KX_CDActuator::pyattr_setGain(void *self, const struct KX_PYATTRIBUTE_DEF *a
 {
        KX_CDActuator* act = static_cast<KX_CDActuator*>(self);
        SND_CDObject::Instance()->SetGain(act->m_gain);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_CDActuator::py_getattro(PyObject *attr)
index 625710fa65de513a9adbacb36e28868facad1299..fe50b3714754d9da47b2c9e8e5b407f88d1849c2 100644 (file)
@@ -806,11 +806,11 @@ int KX_Camera::pyattr_set_perspective(void *self_v, const KX_PYATTRIBUTE_DEF *at
        int param = PyObject_IsTrue( value );
        if (param == -1) {
                PyErr_SetString(PyExc_AttributeError, "camera.perspective = bool: KX_Camera, expected True/False or 0/1");
-               return -1;
+               return PY_SET_ATTR_FAIL;
        }
        
        self->m_camdata.m_perspective= param;
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_Camera::pyattr_get_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -825,12 +825,12 @@ int KX_Camera::pyattr_set_lens(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef,
        float param = PyFloat_AsDouble(value);
        if (param == -1) {
                PyErr_SetString(PyExc_AttributeError, "camera.lens = float: KX_Camera, expected a float greater then zero");
-               return -1;
+               return PY_SET_ATTR_FAIL;
        }
        
        self->m_camdata.m_lens= param;
        self->m_set_projection_matrix = false;
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_Camera::pyattr_get_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -845,12 +845,12 @@ int KX_Camera::pyattr_set_near(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef,
        float param = PyFloat_AsDouble(value);
        if (param == -1) {
                PyErr_SetString(PyExc_AttributeError, "camera.near = float: KX_Camera, expected a float greater then zero");
-               return -1;
+               return PY_SET_ATTR_FAIL;
        }
        
        self->m_camdata.m_clipstart= param;
        self->m_set_projection_matrix = false;
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_Camera::pyattr_get_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -865,12 +865,12 @@ int KX_Camera::pyattr_set_far(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, P
        float param = PyFloat_AsDouble(value);
        if (param == -1) {
                PyErr_SetString(PyExc_AttributeError, "camera.far = float: KX_Camera, expected a float greater then zero");
-               return -1;
+               return PY_SET_ATTR_FAIL;
        }
        
        self->m_camdata.m_clipend= param;
        self->m_set_projection_matrix = false;
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 
@@ -886,10 +886,10 @@ int KX_Camera::pyattr_set_use_viewport(void *self_v, const KX_PYATTRIBUTE_DEF *a
        int param = PyObject_IsTrue( value );
        if (param == -1) {
                PyErr_SetString(PyExc_AttributeError, "camera.useViewport = bool: KX_Camera, expected True or False");
-               return 1;
+               return PY_SET_ATTR_FAIL;
        }
        self->EnableViewport((bool)param);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 
@@ -904,10 +904,10 @@ int KX_Camera::pyattr_set_projection_matrix(void *self_v, const KX_PYATTRIBUTE_D
        KX_Camera* self= static_cast<KX_Camera*>(self_v);
        MT_Matrix4x4 mat;
        if (!PyMatTo(value, mat)) 
-               return -1;
+               return PY_SET_ATTR_FAIL;
        
        self->SetProjectionMatrix(mat);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_Camera::pyattr_get_modelview_matrix(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
index b87d0ee4283ee2caa7d0437458cc8e46f2b06e34..3a6011db604749a21074b799715d5486da5d67e4 100644 (file)
@@ -597,7 +597,7 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF
        KX_GameObject *gameobj;
        
        if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_CameraActuator"))
-               return 1; // ConvertPythonToGameObject sets the error
+               return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
        
        if (self->m_ob)
                self->m_ob->UnregisterActuator(self);   
@@ -605,7 +605,7 @@ int KX_CameraActuator::pyattr_set_object(void *self_v, const KX_PYATTRIBUTE_DEF
        if ((self->m_ob = (SCA_IObject*)gameobj))
                self->m_ob->RegisterActuator(self);
        
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 /* eof */
index cbd17e66f62930cb6cc25d64ba4733d6f3e0b1ba..63d508e62505d25b09fc99d9ee90493d37e1f946 100644 (file)
@@ -1468,13 +1468,13 @@ int KX_GameObject::pyattr_set_mass(void *self_v, const KX_PYATTRIBUTE_DEF *attrd
        MT_Scalar val = PyFloat_AsDouble(value);
        if (val < 0.0f) { /* also accounts for non float */
                PyErr_SetString(PyExc_AttributeError, "gameOb.mass = float: KX_GameObject, expected a float zero or above");
-               return 1;
+               return PY_SET_ATTR_FAIL;
        }
 
        if (spc)
                spc->SetMass(val);
 
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1491,13 +1491,13 @@ int KX_GameObject::pyattr_set_lin_vel_min(void *self_v, const KX_PYATTRIBUTE_DEF
        MT_Scalar val = PyFloat_AsDouble(value);
        if (val < 0.0f) { /* also accounts for non float */
                PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above");
-               return 1;
+               return PY_SET_ATTR_FAIL;
        }
 
        if (spc)
                spc->SetLinVelocityMin(val);
 
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1514,13 +1514,13 @@ int KX_GameObject::pyattr_set_lin_vel_max(void *self_v, const KX_PYATTRIBUTE_DEF
        MT_Scalar val = PyFloat_AsDouble(value);
        if (val < 0.0f) { /* also accounts for non float */
                PyErr_SetString(PyExc_AttributeError, "gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above");
-               return 1;
+               return PY_SET_ATTR_FAIL;
        }
 
        if (spc)
                spc->SetLinVelocityMax(val);
 
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 
@@ -1536,12 +1536,12 @@ int KX_GameObject::pyattr_set_visible(void *self_v, const KX_PYATTRIBUTE_DEF *at
        int param = PyObject_IsTrue( value );
        if (param == -1) {
                PyErr_SetString(PyExc_AttributeError, "gameOb.visible = bool: KX_GameObject, expected True or False");
-               return 1;
+               return PY_SET_ATTR_FAIL;
        }
 
        self->SetVisible(param, false);
        self->UpdateBuckets(false);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_worldPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1555,11 +1555,11 @@ int KX_GameObject::pyattr_set_worldPosition(void *self_v, const KX_PYATTRIBUTE_D
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
        MT_Point3 pos;
        if (!PyVecTo(value, pos))
-               return 1;
+               return PY_SET_ATTR_FAIL;
        
        self->NodeSetWorldPosition(pos);
        self->NodeUpdateGS(0.f);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_localPosition(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1576,11 +1576,11 @@ int KX_GameObject::pyattr_set_localPosition(void *self_v, const KX_PYATTRIBUTE_D
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
        MT_Point3 pos;
        if (!PyVecTo(value, pos))
-               return 1;
+               return PY_SET_ATTR_FAIL;
        
        self->NodeSetLocalPosition(pos);
        self->NodeUpdateGS(0.f);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_localInertia(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1606,7 +1606,7 @@ int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUT
        /* if value is not a sequence PyOrientationTo makes an error */
        MT_Matrix3x3 rot;
        if (!PyOrientationTo(value, rot, "gameOb.worldOrientation = sequence: KX_GameObject, "))
-               return NULL;
+               return PY_SET_ATTR_FAIL;
 
        if (self->GetSGNode() && self->GetSGNode()->GetSGParent()) {
                self->NodeSetLocalOrientation(self->GetSGNode()->GetSGParent()->GetWorldOrientation().inverse()*rot);
@@ -1616,7 +1616,7 @@ int KX_GameObject::pyattr_set_worldOrientation(void *self_v, const KX_PYATTRIBUT
        }
        
        self->NodeUpdateGS(0.f);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_localOrientation(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1635,11 +1635,11 @@ int KX_GameObject::pyattr_set_localOrientation(void *self_v, const KX_PYATTRIBUT
        /* if value is not a sequence PyOrientationTo makes an error */
        MT_Matrix3x3 rot;
        if (!PyOrientationTo(value, rot, "gameOb.localOrientation = sequence: KX_GameObject, "))
-               return NULL;
+               return PY_SET_ATTR_FAIL;
 
        self->NodeSetLocalOrientation(rot);
        self->NodeUpdateGS(0.f);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_worldScaling(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1662,11 +1662,11 @@ int KX_GameObject::pyattr_set_localScaling(void *self_v, const KX_PYATTRIBUTE_DE
        KX_GameObject* self= static_cast<KX_GameObject*>(self_v);
        MT_Vector3 scale;
        if (!PyVecTo(value, scale))
-               return 1;
+               return PY_SET_ATTR_FAIL;
 
        self->NodeSetLocalScale(scale);
        self->NodeUpdateGS(0.f);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1688,12 +1688,12 @@ int KX_GameObject::pyattr_set_timeOffset(void *self_v, const KX_PYATTRIBUTE_DEF
                SG_Node* sg_parent= self->GetSGNode()->GetSGParent();
                if (val < 0.0f) { /* also accounts for non float */
                        PyErr_SetString(PyExc_AttributeError, "gameOb.timeOffset = float: KX_GameObject, expected a float zero or above");
-                       return 1;
+                       return PY_SET_ATTR_FAIL;
                }
                if (sg_parent && sg_parent->IsSlowParent())
                        static_cast<KX_SlowParentRelation *>(sg_parent->GetParentRelation())->SetTimeOffset(val);
        }
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_state(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -1712,16 +1712,16 @@ int KX_GameObject::pyattr_set_state(void *self_v, const KX_PYATTRIBUTE_DEF *attr
        
        if (state_i == -1 && PyErr_Occurred()) {
                PyErr_SetString(PyExc_TypeError, "gameOb.state = int: KX_GameObject, expected an int bit field");
-               return 1;
+               return PY_SET_ATTR_FAIL;
        }
        
        state |= state_i;
        if ((state & ((1<<30)-1)) == 0) {
                PyErr_SetString(PyExc_AttributeError, "gameOb.state = int: KX_GameObject, state bitfield was not between 0 and 30 (1<<0 and 1<<29)");
-               return 1;
+               return PY_SET_ATTR_FAIL;
        }
        self->SetState(state);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_GameObject::pyattr_get_meshes(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
index df7691d016b58b863df2e44b1775f57441fb4856..1496f34c5f257b31b15809a79eabe0ad6f7a0e93 100644 (file)
@@ -261,9 +261,9 @@ int KX_LightObject::pyattr_set_color(void *self_v, const KX_PYATTRIBUTE_DEF *att
                self->m_lightobj.m_red = color[0];
                self->m_lightobj.m_green = color[1];
                self->m_lightobj.m_blue = color[2];
-               return 0;
+               return PY_SET_ATTR_SUCCESS;
        }
-       return 1;
+       return PY_SET_ATTR_FAIL;
 }
 
 PyObject* KX_LightObject::pyattr_get_typeconst(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -293,6 +293,11 @@ int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attr
 {
        KX_LightObject* self = static_cast<KX_LightObject*>(self_v);
        int val = PyInt_AsLong(value);
+       if((val==-1 && PyErr_Occurred()) || val<0 || val>2) {
+               PyErr_SetString(PyExc_ValueError, "light.type= val: KX_LightObject, expected an int between 0 and 2");
+               return PY_SET_ATTR_FAIL;
+       }
+       
        switch(val) {
                case 0:
                        self->m_lightobj.m_type = self->m_lightobj.LIGHT_SPOT;
@@ -300,7 +305,7 @@ int KX_LightObject::pyattr_set_type(void* self_v, const KX_PYATTRIBUTE_DEF *attr
                case 1:
                        self->m_lightobj.m_type = self->m_lightobj.LIGHT_SUN;
                        break;
-               default:
+               case 2:
                        self->m_lightobj.m_type = self->m_lightobj.LIGHT_NORMAL;
                        break;
        }
index c5248785b12d73e28374f94950c3c5e030eda520..38ad9aec33bdaa5f867751e318903b857460456b 100644 (file)
@@ -197,7 +197,7 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE
        KX_GameObject *gameobj;
                
        if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_ParentActuator"))
-               return 1; // ConvertPythonToGameObject sets the error
+               return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
                
        if (actuator->m_ob != NULL)
                actuator->m_ob->UnregisterActuator(actuator);   
@@ -207,7 +207,7 @@ int KX_ParentActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUTE
        if (actuator->m_ob)
                actuator->m_ob->RegisterActuator(actuator);
                
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 
index 2aa0ef921e97b7c33170cbc4d95c4cdbb26b44aa..98aad3943fe5435d0cb1f2142f481c5d4247032f 100644 (file)
@@ -386,10 +386,10 @@ int KX_PolygonMaterial::pyattr_set_diffuse(void *self_v, const KX_PYATTRIBUTE_DE
        MT_Vector3 vec;
        
        if (!PyVecTo(value, vec))
-               return -1;
+               return PY_SET_ATTR_FAIL;
        
        self->m_diffuse= vec;
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_PolygonMaterial::pyattr_get_specular(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
@@ -404,8 +404,8 @@ int KX_PolygonMaterial::pyattr_set_specular(void *self_v, const KX_PYATTRIBUTE_D
        MT_Vector3 vec;
        
        if (!PyVecTo(value, vec))
-               return -1;
+               return PY_SET_ATTR_FAIL;
        
        self->m_specular= vec;
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
index 3c72eac3e62a42890bbba330896f1e5696e0060b..dec76a75e501a3207f20cd9f69d176b5d5c8a57d 100644 (file)
@@ -242,7 +242,7 @@ int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYAT
        KX_GameObject *gameobj;
                
        if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_SCA_AddObjectActuator"))
-               return 1; // ConvertPythonToGameObject sets the error
+               return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
                
        if (actuator->m_OriginalObject != NULL)
                actuator->m_OriginalObject->UnregisterActuator(actuator);       
@@ -252,7 +252,7 @@ int KX_SCA_AddObjectActuator::pyattr_set_object(void *self, const struct KX_PYAT
        if (actuator->m_OriginalObject)
                actuator->m_OriginalObject->RegisterActuator(actuator);
                
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 PyObject* KX_SCA_AddObjectActuator::pyattr_get_objectLastCreated(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
index 730d1ed49e64bce5abaf9c9c01a1bd81da38fa00..00842d7012aec77129632a9902ce0a92586ff1c3 100644 (file)
@@ -128,10 +128,10 @@ int KX_SCA_ReplaceMeshActuator::pyattr_set_mesh(void *self, const struct KX_PYAT
        RAS_MeshObject* new_mesh;
        
        if (!ConvertPythonToMesh(value, &new_mesh, true, "actuator.mesh = value: KX_SCA_ReplaceMeshActuator"))
-               return 1;
+               return PY_SET_ATTR_FAIL;
        
        actuator->m_mesh = new_mesh;
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 /* 1. setMesh */
index 3a341f007e473c0e92c6feb5d2f88b0338061320..5c02a2db6460bb845b7f05aac42208e9f73e6280 100644 (file)
@@ -450,13 +450,13 @@ int KX_SoundActuator::pyattr_set_filename(void *self, const struct KX_PYATTRIBUT
        // void *soundPointer = NULL; /*unused*/
        
        if (!PyArg_Parse(value, "s", &soundName))
-               return 1;
+               return PY_SET_ATTR_FAIL;
 
        if (actuator->m_soundObject) {
                actuator->m_soundObject->SetObjectName(soundName);
        }
        
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 
@@ -465,12 +465,12 @@ int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DE
        float gain = 1.0;
        KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
        if (!PyArg_Parse(value, "f", &gain))
-               return 1;
+               return PY_SET_ATTR_FAIL;
        
        if (actuator->m_soundObject)
                actuator->m_soundObject->SetGain(gain);
        
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }         
 
 int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -478,12 +478,12 @@ int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_D
        float pitch = 1.0;
        KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
        if (!PyArg_Parse(value, "f", &pitch))
-               return 1;
+               return PY_SET_ATTR_FAIL;
        
        if (actuator->m_soundObject)
                actuator->m_soundObject->SetPitch(pitch);
        
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }         
 
 int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -491,12 +491,12 @@ int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATT
        KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
        float rollofffactor = 1.0;
        if (!PyArg_Parse(value, "f", &rollofffactor))
-               return 1;
+               return PY_SET_ATTR_FAIL;
        
        if (actuator->m_soundObject)
                actuator->m_soundObject->SetRollOffFactor(rollofffactor);
 
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }         
 
 int KX_SoundActuator::pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -504,12 +504,12 @@ int KX_SoundActuator::pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE
        KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
        int looping = 1;
        if (!PyArg_Parse(value, "i", &looping))
-               return 1;
+               return PY_SET_ATTR_FAIL;
        
        if (actuator->m_soundObject)
                actuator->m_soundObject->SetLoopMode(looping);
        
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }         
 
 int KX_SoundActuator::pyattr_set_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -519,12 +519,12 @@ int KX_SoundActuator::pyattr_set_position(void *self, const struct KX_PYATTRIBUT
        KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
 
        if (!PyArg_ParseTuple(value, "fff", &pos[0], &pos[1], &pos[2]))
-               return 1;
+               return PY_SET_ATTR_FAIL;
        
        if (actuator->m_soundObject)
                actuator->m_soundObject->SetPosition(MT_Vector3(pos));
        
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }         
 
 int KX_SoundActuator::pyattr_set_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
@@ -534,12 +534,12 @@ int KX_SoundActuator::pyattr_set_velocity(void *self, const struct KX_PYATTRIBUT
 
 
        if (!PyArg_ParseTuple(value, "fff", &vel[0], &vel[1], &vel[2]))
-               return 1;
+               return PY_SET_ATTR_FAIL;
        
        if (actuator->m_soundObject)
                actuator->m_soundObject->SetVelocity(MT_Vector3(vel));
        
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 
 }         
 
@@ -551,14 +551,15 @@ int KX_SoundActuator::pyattr_set_orientation(void *self, const struct KX_PYATTRI
 
        /* if value is not a sequence PyOrientationTo makes an error */
        if (!PyOrientationTo(value, rot, "actuator.orientation = value: KX_SoundActuator"))
-               return NULL;
+               return PY_SET_ATTR_FAIL;
        
+       /* Since not having m_soundObject didn't do anything in the old version,
+        * it probably should be kept that way  */
        if (!actuator->m_soundObject)
-               return 0; /* Since not having m_soundObject didn't do anything in the old version,
-                                       * it probably should be kept that way  */
+               return PY_SET_ATTR_SUCCESS;
        
        actuator->m_soundObject->SetOrientation(rot);
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }
 
 // Deprecated ----->
index 800da83dc3d149c0b967912273930aceb22c4875..5a50d0fb94442da57b9d7f8cc408040f0547f599 100644 (file)
@@ -504,7 +504,7 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT
        KX_GameObject *gameobj;
                
        if (!ConvertPythonToGameObject(value, &gameobj, true, "actuator.object = value: KX_TrackToActuator"))
-               return 1; // ConvertPythonToGameObject sets the error
+               return PY_SET_ATTR_FAIL; // ConvertPythonToGameObject sets the error
                
        if (actuator->m_object != NULL)
                actuator->m_object->UnregisterActuator(actuator);       
@@ -514,7 +514,7 @@ int KX_TrackToActuator::pyattr_set_object(void *self, const struct KX_PYATTRIBUT
        if (actuator->m_object)
                actuator->m_object->RegisterActuator(actuator);
                
-       return 0;
+       return PY_SET_ATTR_SUCCESS;
 }