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/GameLogic')
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.h2
-rw-r--r--source/gameengine/GameLogic/SCA_ANDController.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_ANDController.h2
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.h2
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.cpp16
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.cpp35
-rw-r--r--source/gameengine/GameLogic/SCA_ExpressionController.h8
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.h2
-rw-r--r--source/gameengine/GameLogic/SCA_IController.cpp4
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.h5
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.cpp11
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.h2
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.cpp20
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.h9
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp18
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp16
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.cpp14
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.h2
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.h2
-rw-r--r--source/gameengine/GameLogic/SCA_ORController.cpp7
-rw-r--r--source/gameengine/GameLogic/SCA_ORController.h2
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp8
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.h4
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp10
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.h8
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp198
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.h9
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp32
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.h4
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp10
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.h4
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.h2
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.cpp6
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.h2
-rw-r--r--source/gameengine/GameLogic/SConscript7
49 files changed, 356 insertions, 206 deletions
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
index e8e29fb2769..c21e5db1410 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
@@ -42,14 +42,14 @@ SCA_Joystick::SCA_Joystick(short int index)
m_axis21(0),
m_prec(3200),
m_buttonnum(-2),
+ m_axismax(-1),
m_hatdir(-2),
+ m_buttonmax(-1),
+ m_hatmax(-1),
m_isinit(0),
m_istrig_axis(0),
m_istrig_button(0),
- m_istrig_hat(0),
- m_axismax(-1),
- m_buttonmax(-1),
- m_hatmax(-1)
+ m_istrig_hat(0)
{
#ifndef DISABLE_SDL
m_private = new PrivateData();
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
index a70830193db..7bf051f2b5c 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
@@ -113,7 +113,10 @@ PyMethodDef SCA_2DFilterActuator::Methods[] = {
{NULL,NULL}
};
+PyAttributeDef SCA_2DFilterActuator::Attributes[] = {
+ { NULL } //Sentinel
+};
-PyObject* SCA_2DFilterActuator::_getattr(const STR_String& attr) {
+PyObject* SCA_2DFilterActuator::_getattr(const char *attr) {
_getattr_up(SCA_IActuator);
}
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
index 7ec07cf5b19..9da0500afff 100644
--- a/source/gameengine/GameLogic/SCA_2DFilterActuator.h
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
@@ -38,7 +38,7 @@ public:
virtual bool Update();
virtual CValue* GetReplica();
- virtual PyObject* _getattr(const STR_String& attr);
+ virtual PyObject* _getattr(const char *attr);
};
#endif
diff --git a/source/gameengine/GameLogic/SCA_ANDController.cpp b/source/gameengine/GameLogic/SCA_ANDController.cpp
index cfc2d25e0ae..b67ef7dabaf 100644
--- a/source/gameengine/GameLogic/SCA_ANDController.cpp
+++ b/source/gameengine/GameLogic/SCA_ANDController.cpp
@@ -137,7 +137,11 @@ PyMethodDef SCA_ANDController::Methods[] = {
{NULL,NULL} //Sentinel
};
-PyObject* SCA_ANDController::_getattr(const STR_String& attr) {
+PyAttributeDef SCA_ANDController::Attributes[] = {
+ { NULL } //Sentinel
+};
+
+PyObject* SCA_ANDController::_getattr(const char *attr) {
_getattr_up(SCA_IController);
}
diff --git a/source/gameengine/GameLogic/SCA_ANDController.h b/source/gameengine/GameLogic/SCA_ANDController.h
index 376f4a9a876..eba7e1b545a 100644
--- a/source/gameengine/GameLogic/SCA_ANDController.h
+++ b/source/gameengine/GameLogic/SCA_ANDController.h
@@ -48,7 +48,7 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
+ virtual PyObject* _getattr(const char *attr);
};
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
index fae8d2ba5a7..7f8dbef7758 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
@@ -161,7 +161,7 @@ PyAttributeDef SCA_ActuatorSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_ActuatorSensor::_getattr(const STR_String& attr) {
+PyObject* SCA_ActuatorSensor::_getattr(const char *attr) {
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
return object;
@@ -180,7 +180,7 @@ int SCA_ActuatorSensor::CheckActuator(void *self, const PyAttributeDef*)
return 1;
}
-int SCA_ActuatorSensor::_setattr(const STR_String& attr, PyObject *value) {
+int SCA_ActuatorSensor::_setattr(const char *attr, PyObject *value) {
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
return ret;
@@ -221,7 +221,7 @@ PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* self, PyObject* args, PyOb
} else {
; /* error: bad actuator name */
}
- Py_Return;
+ Py_RETURN_NONE;
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
index 3d64247461c..75ee08f42d6 100644
--- a/source/gameengine/GameLogic/SCA_ActuatorSensor.h
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
@@ -61,8 +61,8 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
/* 3. setProperty */
KX_PYMETHOD_DOC(SCA_ActuatorSensor,SetActuator);
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
index f9fbf2387c4..154f0ad8cef 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
@@ -135,7 +135,11 @@ PyMethodDef SCA_AlwaysSensor::Methods[] = {
{NULL,NULL} //Sentinel
};
-PyObject* SCA_AlwaysSensor::_getattr(const STR_String& attr) {
+PyAttributeDef SCA_AlwaysSensor::Attributes[] = {
+ { NULL } //Sentinel
+};
+
+PyObject* SCA_AlwaysSensor::_getattr(const char *attr) {
_getattr_up(SCA_ISensor);
}
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.h b/source/gameengine/GameLogic/SCA_AlwaysSensor.h
index 8bf2a8aa98e..ebe6ba80208 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.h
+++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.h
@@ -52,7 +52,7 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
+ virtual PyObject* _getattr(const char *attr);
};
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
index 4c97ca98d72..31a620b939d 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
@@ -53,10 +53,10 @@ SCA_DelaySensor::SCA_DelaySensor(class SCA_EventManager* eventmgr,
int duration,
bool repeat,
PyTypeObject* T)
- : SCA_ISensor(gameobj,eventmgr, T),
+ : SCA_ISensor(gameobj,eventmgr, T),
+ m_repeat(repeat),
m_delay(delay),
- m_duration(duration),
- m_repeat(repeat)
+ m_duration(duration)
{
Init();
}
@@ -178,14 +178,14 @@ PyAttributeDef SCA_DelaySensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_DelaySensor::_getattr(const STR_String& attr) {
+PyObject* SCA_DelaySensor::_getattr(const char *attr) {
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
return object;
_getattr_up(SCA_ISensor);
}
-int SCA_DelaySensor::_setattr(const STR_String& attr, PyObject *value) {
+int SCA_DelaySensor::_setattr(const char *attr, PyObject *value) {
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
return ret;
@@ -211,7 +211,7 @@ PyObject* SCA_DelaySensor::PySetDelay(PyObject* self, PyObject* args, PyObject*
return NULL;
}
m_delay = delay;
- Py_Return;
+ Py_RETURN_NONE;
}
const char SCA_DelaySensor::SetDuration_doc[] =
@@ -233,7 +233,7 @@ PyObject* SCA_DelaySensor::PySetDuration(PyObject* self, PyObject* args, PyObjec
return NULL;
}
m_duration = duration;
- Py_Return;
+ Py_RETURN_NONE;
}
const char SCA_DelaySensor::SetRepeat_doc[] =
@@ -250,7 +250,7 @@ PyObject* SCA_DelaySensor::PySetRepeat(PyObject* self, PyObject* args, PyObject*
return NULL;
}
m_repeat = (repeat != 0);
- Py_Return;
+ Py_RETURN_NONE;
}
const char SCA_DelaySensor::GetDelay_doc[] =
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h
index ff3afe16542..491eee61da8 100644
--- a/source/gameengine/GameLogic/SCA_DelaySensor.h
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.h
@@ -60,8 +60,8 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
/* setProperty */
KX_PYMETHOD_DOC(SCA_DelaySensor,SetDelay);
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.cpp b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
index e9a543c9f31..8ed46beb7f3 100644
--- a/source/gameengine/GameLogic/SCA_ExpressionController.cpp
+++ b/source/gameengine/GameLogic/SCA_ExpressionController.cpp
@@ -49,7 +49,8 @@ SCA_ExpressionController::SCA_ExpressionController(SCA_IObject* gameobj,
const STR_String& exprtext,
PyTypeObject* T)
:SCA_IController(gameobj,T),
- m_exprText(exprtext)
+ m_exprText(exprtext),
+ m_exprCache(NULL)
{
}
@@ -57,6 +58,8 @@ SCA_ExpressionController::SCA_ExpressionController(SCA_IObject* gameobj,
SCA_ExpressionController::~SCA_ExpressionController()
{
+ if (m_exprCache)
+ m_exprCache->Release();
}
@@ -65,6 +68,7 @@ CValue* SCA_ExpressionController::GetReplica()
{
SCA_ExpressionController* replica = new SCA_ExpressionController(*this);
replica->m_exprText = m_exprText;
+ replica->m_exprCache = NULL;
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
@@ -72,18 +76,32 @@ CValue* SCA_ExpressionController::GetReplica()
}
+// Forced deletion of precalculated expression to break reference loop
+// Use this function when you know that you won't use the sensor anymore
+void SCA_ExpressionController::Delete()
+{
+ if (m_exprCache)
+ {
+ m_exprCache->Release();
+ m_exprCache = NULL;
+ }
+ Release();
+}
+
void SCA_ExpressionController::Trigger(SCA_LogicManager* logicmgr)
{
bool expressionresult = false;
-
- CParser parser;
- parser.SetContext(this->AddRef());
- CExpression* expr = parser.ProcessText(m_exprText);
- if (expr)
+ if (!m_exprCache)
+ {
+ CParser parser;
+ parser.SetContext(this->AddRef());
+ m_exprCache = parser.ProcessText(m_exprText);
+ }
+ if (m_exprCache)
{
- CValue* value = expr->Calculate();
+ CValue* value = m_exprCache->Calculate();
if (value)
{
if (value->IsError())
@@ -97,7 +115,8 @@ void SCA_ExpressionController::Trigger(SCA_LogicManager* logicmgr)
value->Release();
}
- expr->Release();
+ //m_exprCache->Release();
+ //m_exprCache = NULL;
}
/*
diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h
index f1db45a19e0..79c26eea1e7 100644
--- a/source/gameengine/GameLogic/SCA_ExpressionController.h
+++ b/source/gameengine/GameLogic/SCA_ExpressionController.h
@@ -38,6 +38,7 @@ class SCA_ExpressionController : public SCA_IController
{
// Py_Header;
STR_String m_exprText;
+ CExpression* m_exprCache;
public:
SCA_ExpressionController(SCA_IObject* gameobj,
@@ -48,12 +49,17 @@ public:
virtual CValue* GetReplica();
virtual void Trigger(SCA_LogicManager* logicmgr);
virtual CValue* FindIdentifier(const STR_String& identifiername);
+ /**
+ * used to release the expression cache
+ * so that self references are removed before the controller itself is released
+ */
+ virtual void Delete();
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
-// virtual PyObject* _getattr(const STR_String& attr);
+// virtual PyObject* _getattr(const char *attr);
};
diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp
index eeca2d7b44c..309f3108418 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_IActuator.cpp
@@ -36,8 +36,8 @@ using namespace std;
SCA_IActuator::SCA_IActuator(SCA_IObject* gameobj,
PyTypeObject* T) :
- m_links(0),
- SCA_ILogicBrick(gameobj,T)
+ SCA_ILogicBrick(gameobj,T),
+ m_links(0)
{
// nothing to do
}
diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h
index 7ffb21b5490..51bd6454d92 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.h
+++ b/source/gameengine/GameLogic/SCA_IActuator.h
@@ -36,9 +36,9 @@ class SCA_IActuator : public SCA_ILogicBrick
{
friend class SCA_LogicManager;
protected:
- std::vector<CValue*> m_events;
int m_links; // number of active links to controllers
// when 0, the actuator is automatically stopped
+ std::vector<CValue*> m_events;
void RemoveAllEvents();
public:
diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp
index 0bd20117f31..f9c192cae5c 100644
--- a/source/gameengine/GameLogic/SCA_IController.cpp
+++ b/source/gameengine/GameLogic/SCA_IController.cpp
@@ -38,8 +38,8 @@
SCA_IController::SCA_IController(SCA_IObject* gameobj,
PyTypeObject* T)
:
- m_statemask(0),
- SCA_ILogicBrick(gameobj,T)
+ SCA_ILogicBrick(gameobj,T),
+ m_statemask(0)
{
}
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
index 8286c0829a7..49d39f75814 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
@@ -278,7 +278,7 @@ int SCA_ILogicBrick::CheckProperty(void *self, const PyAttributeDef *attrdef)
}
PyObject*
-SCA_ILogicBrick::_getattr(const STR_String& attr)
+SCA_ILogicBrick::_getattr(const char *attr)
{
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
@@ -286,7 +286,7 @@ SCA_ILogicBrick::_getattr(const STR_String& attr)
_getattr_up(CValue);
}
-int SCA_ILogicBrick::_setattr(const STR_String& attr, PyObject *value)
+int SCA_ILogicBrick::_setattr(const char *attr, PyObject *value)
{
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
@@ -324,7 +324,7 @@ PyObject* SCA_ILogicBrick::PySetExecutePriority(PyObject* self,
m_Execute_Ueber_Priority = priority;
- Py_Return;
+ Py_RETURN_NONE;
}
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h
index 772bd65d577..70d49941613 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.h
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h
@@ -62,6 +62,7 @@ public:
SCA_IObject* GetParent();
virtual void ReParent(SCA_IObject* parent);
virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
+ virtual void Delete() { Release(); }
// act as a BoolValue (with value IsPositiveTrigger)
virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
@@ -78,8 +79,8 @@ public:
virtual bool LessComparedTo(SCA_ILogicBrick* other);
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
static class SCA_LogicManager* m_sCurrentLogicManager;
diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp
index b0f8decee26..debd62d44e6 100644
--- a/source/gameengine/GameLogic/SCA_IObject.cpp
+++ b/source/gameengine/GameLogic/SCA_IObject.cpp
@@ -40,7 +40,7 @@
MT_Point3 SCA_IObject::m_sDummy=MT_Point3(0,0,0);
-SCA_IObject::SCA_IObject(PyTypeObject* T): m_initState(0), m_state(0), CValue(T)
+SCA_IObject::SCA_IObject(PyTypeObject* T): CValue(T), m_initState(0), m_state(0)
{
m_suspended = false;
}
@@ -59,7 +59,9 @@ SCA_IObject::~SCA_IObject()
SCA_ControllerList::iterator itc;
for (itc = m_controllers.begin(); !(itc == m_controllers.end()); ++itc)
{
- ((CValue*)(*itc))->Release();
+ //Use Delete for controller to ensure proper cleaning (expression controller)
+ (*itc)->Delete();
+ //((CValue*)(*itc))->Release();
}
SCA_ActuatorList::iterator ita;
for (ita = m_registeredActuators.begin(); !(ita==m_registeredActuators.end()); ++ita)
@@ -407,9 +409,12 @@ PyMethodDef SCA_IObject::Methods[] = {
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_IObject::Attributes[] = {
+ { NULL } //Sentinel
+};
-PyObject* SCA_IObject::_getattr(const STR_String& attr) {
+PyObject* SCA_IObject::_getattr(const char *attr) {
_getattr_up(CValue);
}
diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h
index 38a7ed29dca..d47353b1ac0 100644
--- a/source/gameengine/GameLogic/SCA_IObject.h
+++ b/source/gameengine/GameLogic/SCA_IObject.h
@@ -145,7 +145,7 @@ public:
// const class MT_Point3& ConvertPythonPylist(PyObject* pylist);
// here come the python forwarded methods
- virtual PyObject* _getattr(const STR_String& attr);
+ virtual PyObject* _getattr(const char *attr);
virtual int GetGameObjectType() {return -1;}
diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp
index 68a3a93eab0..e8a072f4c46 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ISensor.cpp
@@ -264,7 +264,7 @@ PyObject* SCA_ISensor::PySetUsePosPulseMode(PyObject* self, PyObject* args, PyOb
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_pos_pulsemode = PyArgToBool(pyarg);
- Py_Return;
+ Py_RETURN_NONE;
}
/**
@@ -303,7 +303,7 @@ PyObject* SCA_ISensor::PySetFrequency(PyObject* self, PyObject* args, PyObject*
};
m_pulse_frequency = pulse_frequencyArg;
- Py_Return;
+ Py_RETURN_NONE;
}
@@ -326,7 +326,7 @@ PyObject* SCA_ISensor::PySetInvert(PyObject* self, PyObject* args, PyObject* kwd
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_invert = PyArgToBool(pyarg);
- Py_Return;
+ Py_RETURN_NONE;
}
const char SCA_ISensor::GetLevel_doc[] =
@@ -352,7 +352,7 @@ PyObject* SCA_ISensor::PySetLevel(PyObject* self, PyObject* args, PyObject* kwds
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_level = PyArgToBool(pyarg);
- Py_Return;
+ Py_RETURN_NONE;
}
const char SCA_ISensor::GetUseNegPulseMode_doc[] =
@@ -375,7 +375,7 @@ PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyOb
int pyarg = 0;
if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
m_neg_pulsemode = PyArgToBool(pyarg);
- Py_Return;
+ Py_RETURN_NONE;
}
//<------Deprecated
@@ -385,7 +385,7 @@ KX_PYMETHODDEF_DOC_NOARGS(SCA_ISensor, reset,
"\tThe sensor is put in its initial state as if it was just activated.\n")
{
Init();
- Py_Return;
+ Py_RETURN_NONE;
}
/* ----------------------------------------------- */
@@ -461,19 +461,19 @@ PyAttributeDef SCA_ISensor::Attributes[] = {
};
PyObject*
-SCA_ISensor::_getattr(const STR_String& attr)
+SCA_ISensor::_getattr(const char *attr)
{
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
return object;
- if (attr == "triggered")
+ if (!strcmp(attr, "triggered"))
{
int retval = 0;
if (SCA_PythonController::m_sCurrentController)
retval = SCA_PythonController::m_sCurrentController->IsTriggered(this);
return PyInt_FromLong(retval);
}
- if (attr == "positive")
+ if (!strcmp(attr, "positive"))
{
int retval = IsPositiveTrigger();
return PyInt_FromLong(retval);
@@ -481,7 +481,7 @@ SCA_ISensor::_getattr(const STR_String& attr)
_getattr_up(SCA_ILogicBrick);
}
-int SCA_ISensor::_setattr(const STR_String& attr, PyObject *value)
+int SCA_ISensor::_setattr(const char *attr, PyObject *value)
{
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h
index 1b57c4621e4..23f2c76c19f 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.h
+++ b/source/gameengine/GameLogic/SCA_ISensor.h
@@ -105,11 +105,6 @@ public:
bool negmode,
int freq);
- /** Release sensor
- * For property sensor, it is used to release the pre-calculated expression
- * so that self references are removed before the sensor itself is released
- */
- virtual void Delete() { Release(); }
/** Set inversion of pulses on or off. */
void SetInvert(bool inv);
/** set the level detection on or off */
@@ -141,8 +136,8 @@ public:
/* Python functions: */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
//Deprecated functions ----->
KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsPositive);
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index 694bca9bac5..c2d90c830cf 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -331,8 +331,8 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
KX_PYATTRIBUTE_SHORT_RW("index",0,JOYINDEX_MAX-1,true,SCA_JoystickSensor,m_joyindex),
KX_PYATTRIBUTE_INT_RW("threshold",0,32768,true,SCA_JoystickSensor,m_precision),
KX_PYATTRIBUTE_INT_RW("button",0,100,false,SCA_JoystickSensor,m_button),
- KX_PYATTRIBUTE_INT_ARRAY_RW_CHECK("axis",0,3,true,SCA_JoystickSensor,m_axis,2,CheckAxis),
- KX_PYATTRIBUTE_INT_ARRAY_RW_CHECK("hat",0,12,true,SCA_JoystickSensor,m_hat,2,CheckHat),
+ KX_PYATTRIBUTE_INT_LIST_RW_CHECK("axis",0,3,true,SCA_JoystickSensor,m_axis,2,CheckAxis),
+ KX_PYATTRIBUTE_INT_LIST_RW_CHECK("hat",0,12,true,SCA_JoystickSensor,m_hat,2,CheckHat),
// dummy attributes will just be read-only in _setattr
// you still need to defined them in _getattr
KX_PYATTRIBUTE_DUMMY("axisPosition"),
@@ -343,24 +343,24 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_JoystickSensor::_getattr(const STR_String& attr) {
+PyObject* SCA_JoystickSensor::_getattr(const char *attr) {
SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
- if (attr == "axisPosition") {
+ if (!strcmp(attr, "axisPosition")) {
if(joy)
return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
else
return Py_BuildValue("[iiii]", 0, 0, 0, 0);
}
- if (attr == "numAxis") {
+ if (!strcmp(attr, "numAxis")) {
return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
}
- if (attr == "numButtons") {
+ if (!strcmp(attr, "numButtons")) {
return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
}
- if (attr == "numHats") {
+ if (!strcmp(attr, "numHats")) {
return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
}
- if (attr == "connected") {
+ if (!strcmp(attr, "connected")) {
return PyBool_FromLong( joy ? joy->Connected() : 0 );
}
PyObject* object = _getattr_self(Attributes, this, attr);
@@ -369,7 +369,7 @@ PyObject* SCA_JoystickSensor::_getattr(const STR_String& attr) {
_getattr_up(SCA_ISensor);
}
-int SCA_JoystickSensor::_setattr(const STR_String& attr, PyObject *value)
+int SCA_JoystickSensor::_setattr(const char *attr, PyObject *value)
{
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
index fa11f1cc3d0..49d220c056d 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h
@@ -121,8 +121,8 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
/* Joystick Index */
KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex);
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index 981d165287b..324e5eae98a 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -577,7 +577,7 @@ PyObject* SCA_KeyboardSensor::PySetKey(PyObject* self, PyObject* args, PyObject*
/* anything. It's up to the user to provide a sensible number. */
m_hotkey = keyCode;
- Py_Return;
+ Py_RETURN_NONE;
}
/** 3. GetHold1 : set the first bucky bit */
@@ -609,7 +609,7 @@ PyObject* SCA_KeyboardSensor::PySetHold1(PyObject* self, PyObject* args, PyObjec
/* anything. It's up to the user to provide a sensible number. */
m_qual = keyCode;
- Py_Return;
+ Py_RETURN_NONE;
}
/** 5. GetHold2 : get the second bucky bit */
@@ -641,7 +641,7 @@ PyObject* SCA_KeyboardSensor::PySetHold2(PyObject* self, PyObject* args, PyObjec
/* anything. It's up to the user to provide a sensible number. */
m_qual2 = keyCode;
- Py_Return;
+ Py_RETURN_NONE;
}
@@ -682,7 +682,7 @@ PyObject* SCA_KeyboardSensor::PyGetPressedKeys(PyObject* self, PyObject* args, P
if (index>0) return resultlist;
}
- Py_Return;
+ Py_RETURN_NONE;
}
@@ -725,7 +725,7 @@ SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
if (index > 0) return resultlist;
}
- Py_Return;
+ Py_RETURN_NONE;
}
//<---- Deprecated
@@ -770,7 +770,7 @@ KX_PYMETHODDEF_DOC_O(SCA_KeyboardSensor, getKeyStatus,
return PyInt_FromLong(inevent.m_status);
}
- Py_Return;
+ Py_RETURN_NONE;
}
/* ------------------------------------------------------------------------- */
@@ -831,7 +831,7 @@ PyAttributeDef SCA_KeyboardSensor::Attributes[] = {
};
PyObject*
-SCA_KeyboardSensor::_getattr(const STR_String& attr)
+SCA_KeyboardSensor::_getattr(const char *attr)
{
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
@@ -839,7 +839,7 @@ SCA_KeyboardSensor::_getattr(const STR_String& attr)
_getattr_up(SCA_ISensor);
}
-int SCA_KeyboardSensor::_setattr(const STR_String& attr, PyObject *value)
+int SCA_KeyboardSensor::_setattr(const char *attr, PyObject *value)
{
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
index 4efbe9366cc..bc2f86327a5 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
@@ -126,8 +126,8 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
//Deprecated functions ----->
/** 1. GetKey : check which key this sensor looks at */
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
index 09b46e6443e..57535b29f32 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
@@ -158,8 +158,8 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
case KX_MOUSESENSORMODE_WHEELUP:
case KX_MOUSESENSORMODE_WHEELDOWN:
{
- const SCA_InputEvent& event = mousedev->GetEventValue(m_hotkey);
- switch (event.m_status){
+ const SCA_InputEvent& mevent = mousedev->GetEventValue(m_hotkey);
+ switch (mevent.m_status){
case SCA_InputEvent::KX_JUSTACTIVATED:
m_val = 1;
result = true;
@@ -282,7 +282,7 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
int button = PyInt_AsLong(value);
if ((button < SCA_IInputDevice::KX_LEFTMOUSE)
- || (button > SCA_IInputDevice::KX_MIDDLEMOUSE)){
+ || (button > SCA_IInputDevice::KX_RIGHTMOUSE)){
PyErr_SetString(PyExc_ValueError, "invalid button specified!");
return NULL;
}
@@ -292,7 +292,7 @@ KX_PYMETHODDEF_DOC_O(SCA_MouseSensor, getButtonStatus,
return PyInt_FromLong(event.m_status);
}
- Py_Return;
+ Py_RETURN_NONE;
}
/* ------------------------------------------------------------------------- */
@@ -337,11 +337,11 @@ PyMethodDef SCA_MouseSensor::Methods[] = {
PyAttributeDef SCA_MouseSensor::Attributes[] = {
KX_PYATTRIBUTE_SHORT_RW_CHECK("mode",KX_MOUSESENSORMODE_NODEF,KX_MOUSESENSORMODE_MAX-1,true,SCA_MouseSensor,m_mousemode,UpdateHotkey),
- KX_PYATTRIBUTE_SHORT_ARRAY_RO("position",SCA_MouseSensor,m_x,2),
+ KX_PYATTRIBUTE_SHORT_LIST_RO("position",SCA_MouseSensor,m_x,2),
{ NULL } //Sentinel
};
-PyObject* SCA_MouseSensor::_getattr(const STR_String& attr)
+PyObject* SCA_MouseSensor::_getattr(const char *attr)
{
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
@@ -349,7 +349,7 @@ PyObject* SCA_MouseSensor::_getattr(const STR_String& attr)
_getattr_up(SCA_ISensor);
}
-int SCA_MouseSensor::_setattr(const STR_String& attr, PyObject *value)
+int SCA_MouseSensor::_setattr(const char *attr, PyObject *value)
{
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h
index 82af2ce9c04..30b43fe53cc 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.h
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.h
@@ -109,8 +109,8 @@ class SCA_MouseSensor : public SCA_ISensor
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
//Deprecated functions ----->
/* read x-coordinate */
diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp
index 5b869ee8298..18426d75582 100644
--- a/source/gameengine/GameLogic/SCA_NANDController.cpp
+++ b/source/gameengine/GameLogic/SCA_NANDController.cpp
@@ -137,7 +137,11 @@ PyMethodDef SCA_NANDController::Methods[] = {
{NULL,NULL} //Sentinel
};
-PyObject* SCA_NANDController::_getattr(const STR_String& attr) {
+PyAttributeDef SCA_NANDController::Attributes[] = {
+ { NULL } //Sentinel
+};
+
+PyObject* SCA_NANDController::_getattr(const char *attr) {
_getattr_up(SCA_IController);
}
diff --git a/source/gameengine/GameLogic/SCA_NANDController.h b/source/gameengine/GameLogic/SCA_NANDController.h
index 1193ff64f07..d88504cfc0d 100644
--- a/source/gameengine/GameLogic/SCA_NANDController.h
+++ b/source/gameengine/GameLogic/SCA_NANDController.h
@@ -48,7 +48,7 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
+ virtual PyObject* _getattr(const char *attr);
};
diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp
index 2866dec0b74..1de6a641c3d 100644
--- a/source/gameengine/GameLogic/SCA_NORController.cpp
+++ b/source/gameengine/GameLogic/SCA_NORController.cpp
@@ -137,7 +137,11 @@ PyMethodDef SCA_NORController::Methods[] = {
{NULL,NULL} //Sentinel
};
-PyObject* SCA_NORController::_getattr(const STR_String& attr) {
+PyAttributeDef SCA_NORController::Attributes[] = {
+ { NULL } //Sentinel
+};
+
+PyObject* SCA_NORController::_getattr(const char *attr) {
_getattr_up(SCA_IController);
}
diff --git a/source/gameengine/GameLogic/SCA_NORController.h b/source/gameengine/GameLogic/SCA_NORController.h
index aab59e3d46c..45b639f3f3f 100644
--- a/source/gameengine/GameLogic/SCA_NORController.h
+++ b/source/gameengine/GameLogic/SCA_NORController.h
@@ -48,7 +48,7 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
+ virtual PyObject* _getattr(const char *attr);
};
diff --git a/source/gameengine/GameLogic/SCA_ORController.cpp b/source/gameengine/GameLogic/SCA_ORController.cpp
index 2d4eb31f241..61fbc889d90 100644
--- a/source/gameengine/GameLogic/SCA_ORController.cpp
+++ b/source/gameengine/GameLogic/SCA_ORController.cpp
@@ -129,7 +129,12 @@ PyMethodDef SCA_ORController::Methods[] = {
{NULL,NULL} //Sentinel
};
-PyObject* SCA_ORController::_getattr(const STR_String& attr) {
+PyAttributeDef SCA_ORController::Attributes[] = {
+ { NULL } //Sentinel
+};
+
+
+PyObject* SCA_ORController::_getattr(const char *attr) {
_getattr_up(SCA_IController);
}
diff --git a/source/gameengine/GameLogic/SCA_ORController.h b/source/gameengine/GameLogic/SCA_ORController.h
index beb69aa2af9..9a6e9e75022 100644
--- a/source/gameengine/GameLogic/SCA_ORController.h
+++ b/source/gameengine/GameLogic/SCA_ORController.h
@@ -49,7 +49,7 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
+ virtual PyObject* _getattr(const char *attr);
};
#endif //__KX_ORCONTROLLER
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index 566d3b63487..c9ace081bae 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -260,14 +260,14 @@ PyAttributeDef SCA_PropertyActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_PropertyActuator::_getattr(const STR_String& attr) {
+PyObject* SCA_PropertyActuator::_getattr(const char *attr) {
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
return object;
_getattr_up(SCA_IActuator);
}
-int SCA_PropertyActuator::_setattr(const STR_String& attr, PyObject *value) {
+int SCA_PropertyActuator::_setattr(const char *attr, PyObject *value) {
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
return ret;
@@ -298,7 +298,7 @@ PyObject* SCA_PropertyActuator::PySetProperty(PyObject* self, PyObject* args, Py
}
prop->Release();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 2. getProperty */
@@ -328,7 +328,7 @@ PyObject* SCA_PropertyActuator::PySetValue(PyObject* self, PyObject* args, PyObj
if (valArg) m_exprtxt = valArg;
- Py_Return;
+ Py_RETURN_NONE;
}
/* 4. getValue */
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
index cdfeee4c67d..444d9285796 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h
@@ -85,8 +85,8 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
// python wrapped methods
KX_PYMETHOD_DOC(SCA_PropertyActuator,SetProperty);
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
index a6f7a9cd82b..d683c8bb3e7 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
@@ -352,14 +352,14 @@ PyAttributeDef SCA_PropertySensor::Attributes[] = {
};
-PyObject* SCA_PropertySensor::_getattr(const STR_String& attr) {
+PyObject* SCA_PropertySensor::_getattr(const char *attr) {
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
return object;
_getattr_up(SCA_ISensor); /* implicit return! */
}
-int SCA_PropertySensor::_setattr(const STR_String& attr, PyObject *value) {
+int SCA_PropertySensor::_setattr(const char *attr, PyObject *value) {
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
return ret;
@@ -397,7 +397,7 @@ PyObject* SCA_PropertySensor::PySetType(PyObject* self, PyObject* args, PyObject
m_checktype = typeArg;
}
- Py_Return;
+ Py_RETURN_NONE;
}
/* 3. getProperty */
@@ -434,7 +434,7 @@ PyObject* SCA_PropertySensor::PySetProperty(PyObject* self, PyObject* args, PyOb
; /* error: bad property name */
}
prop->Release();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 5. getValue */
@@ -470,7 +470,7 @@ PyObject* SCA_PropertySensor::PySetValue(PyObject* self, PyObject* args, PyObjec
m_checkpropval = oldval;
return NULL;
}
- Py_Return;
+ Py_RETURN_NONE;
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h
index e625e84a36f..2594e3fca9d 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.h
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.h
@@ -70,6 +70,10 @@ public:
KX_PROPSENSOR_TYPE checktype,
PyTypeObject* T=&Type );
+ /**
+ * For property sensor, it is used to release the pre-calculated expression
+ * so that self references are removed before the sensor itself is released
+ */
virtual void Delete();
virtual ~SCA_PropertySensor();
virtual CValue* GetReplica();
@@ -85,8 +89,8 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
/* 1. getType */
KX_PYMETHOD_DOC(SCA_PropertySensor,GetType);
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index e879481a444..c75e36acab2 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -157,8 +157,40 @@ static const char* sPyGetCurrentController__doc__;
PyObject* SCA_PythonController::sPyGetCurrentController(PyObject* self)
{
- m_sCurrentController->AddRef();
- return m_sCurrentController;
+ return m_sCurrentController->AddRef();
+}
+
+SCA_IActuator* SCA_PythonController::LinkedActuatorFromPy(PyObject *value)
+{
+ // for safety, todo: only allow for registered actuators (pointertable)
+ // we don't want to crash gameengine/blender by python scripts
+ std::vector<SCA_IActuator*> lacts = m_sCurrentController->GetLinkedActuators();
+ std::vector<SCA_IActuator*>::iterator it;
+
+ if (PyString_Check(value)) {
+ /* get the actuator from the name */
+ char *name= PyString_AsString(value);
+ for(it = lacts.begin(); it!= lacts.end(); it++) {
+ if( name == (*it)->GetName() ) {
+ return *it;
+ }
+ }
+ }
+ else {
+ /* Expecting an actuator type */
+ for(it = lacts.begin(); it!= lacts.end(); it++) {
+ if( static_cast<SCA_IActuator*>(value) == (*it) ) {
+ return *it;
+ }
+ }
+ }
+
+ /* set the exception */
+ PyObject *value_str = PyObject_Repr(value); /* new ref */
+ PyErr_Format(PyExc_ValueError, "'%s' not in this controllers actuator list", PyString_AsString(value_str));
+ Py_DECREF(value_str);
+
+ return false;
}
#if 0
@@ -175,26 +207,14 @@ PyObject* SCA_PythonController::sPyAddActiveActuator(
int activate;
if (!PyArg_ParseTuple(args, "Oi", &ob1,&activate))
return NULL;
-
- // for safety, todo: only allow for registered actuators (pointertable)
- // we don't want to crash gameengine/blender by python scripts
- std::vector<SCA_IActuator*> lacts = m_sCurrentController->GetLinkedActuators();
- std::vector<SCA_IActuator*>::iterator it;
- bool found = false;
- CValue* act = (CValue*)ob1;
-
- for(it = lacts.begin(); it!= lacts.end(); it++) {
- if( static_cast<SCA_IActuator*>(act) == (*it) ) {
- found=true;
- break;
- }
- }
- if(found){
- CValue* boolval = new CBoolValue(activate!=0);
- m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)act,boolval);
- boolval->Release();
- }
+ SCA_IActuator* actu = LinkedActuatorFromPy(ob1);
+ if(actu==NULL)
+ return NULL;
+
+ CValue* boolval = new CBoolValue(activate!=0);
+ m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu,boolval);
+ boolval->Release();
Py_RETURN_NONE;
}
@@ -229,18 +249,61 @@ PyParentObject SCA_PythonController::Parents[] = {
NULL
};
PyMethodDef SCA_PythonController::Methods[] = {
+ {"activate", (PyCFunction) SCA_PythonController::sPyActivate, METH_O},
+ {"deactivate", (PyCFunction) SCA_PythonController::sPyDeActivate, METH_O},
+
{"getActuators", (PyCFunction) SCA_PythonController::sPyGetActuators, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetActuators_doc},
{"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, METH_O, (PY_METHODCHAR)SCA_PythonController::GetActuator_doc},
{"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetSensors_doc},
{"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, METH_O, (PY_METHODCHAR)SCA_PythonController::GetSensor_doc},
- {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_O},
//Deprecated functions ------>
+ {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_O},
{"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS},
{"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_NOARGS},
//<----- Deprecated
{NULL,NULL} //Sentinel
};
+PyAttributeDef SCA_PythonController::Attributes[] = {
+ { NULL } //Sentinel
+};
+
+bool SCA_PythonController::Compile()
+{
+ //printf("py script modified '%s'\n", m_scriptName.Ptr());
+
+ // if a script already exists, decref it before replace the pointer to a new script
+ if (m_bytecode)
+ {
+ Py_DECREF(m_bytecode);
+ m_bytecode=NULL;
+ }
+ // recompile the scripttext into bytecode
+ m_bytecode = Py_CompileString(m_scriptText.Ptr(), m_scriptName.Ptr(), Py_file_input);
+ m_bModified=false;
+
+ if (m_bytecode)
+ {
+
+ return true;
+ }
+ else {
+ // didn't compile, so instead of compile, complain
+ // something is wrong, tell the user what went wrong
+ printf("Python compile error from controller \"%s\": \n", GetName().Ptr());
+ //PyRun_SimpleString(m_scriptText.Ptr());
+ PyErr_Print();
+
+ /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+ * their user count. Not to mention holding references to wrapped data.
+ * This is especially bad when the PyObject for the wrapped data is free'd, after blender
+ * has alredy dealocated the pointer */
+ PySys_SetObject( (char *)"last_traceback", Py_None);
+ PyErr_Clear(); /* just to be sure */
+
+ return false;
+ }
+}
void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
{
@@ -249,33 +312,13 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
if (m_bModified)
{
- // if a script already exists, decref it before replace the pointer to a new script
- if (m_bytecode)
- {
- Py_DECREF(m_bytecode);
- m_bytecode=NULL;
- }
- // recompile the scripttext into bytecode
- m_bytecode = Py_CompileString(m_scriptText.Ptr(), m_scriptName.Ptr(), Py_file_input);
- if (!m_bytecode)
- {
- // didn't compile, so instead of compile, complain
- // something is wrong, tell the user what went wrong
- printf("Python compile error from controller \"%s\": \n", GetName().Ptr());
- //PyRun_SimpleString(m_scriptText.Ptr());
- PyErr_Print();
-
- /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
- * their user count. Not to mention holding references to wrapped data.
- * This is especially bad when the PyObject for the wrapped data is free'd, after blender
- * has alredy dealocated the pointer */
- PySys_SetObject( "last_traceback", Py_None);
- PyErr_Clear(); /* just to be sure */
-
+ if (Compile()==false) // sets m_bModified to false
return;
- }
- m_bModified=false;
}
+ if (!m_bytecode) {
+ return;
+ }
+
/*
* This part here with excdict is a temporary patch
@@ -313,7 +356,7 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
* their user count. Not to mention holding references to wrapped data.
* This is especially bad when the PyObject for the wrapped data is free'd, after blender
* has alredy dealocated the pointer */
- PySys_SetObject( "last_traceback", Py_None);
+ PySys_SetObject( (char *)"last_traceback", Py_None);
PyErr_Clear(); /* just to be sure */
//PyRun_SimpleString(m_scriptText.Ptr());
@@ -329,30 +372,63 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
-PyObject* SCA_PythonController::_getattr(const STR_String& attr)
+PyObject* SCA_PythonController::_getattr(const char *attr)
{
- if (attr == "script") {
- return PyString_FromString(m_scriptText);
- }
- if (attr == "state") {
+ if (!strcmp(attr,"state")) {
return PyInt_FromLong(m_statemask);
}
+ if (!strcmp(attr,"script")) {
+ return PyString_FromString(m_scriptText);
+ }
_getattr_up(SCA_IController);
}
-int SCA_PythonController::_setattr(const STR_String& attr, PyObject *value)
+int SCA_PythonController::_setattr(const char *attr, PyObject *value)
{
- if (attr == "script") {
- PyErr_SetString(PyExc_AttributeError, "script is read only, use setScript() to update the script");
+ if (!strcmp(attr,"state")) {
+ PyErr_SetString(PyExc_AttributeError, "state is read only");
return 1;
}
- if (attr == "state") {
- PyErr_SetString(PyExc_AttributeError, "state is read only");
+ if (!strcmp(attr,"script")) {
+ char *scriptArg = PyString_AsString(value);
+
+ if (scriptArg==NULL) {
+ PyErr_SetString(PyExc_TypeError, "expected a string (script name)");
+ return -1;
+ }
+
+ /* set scripttext sets m_bModified to true,
+ so next time the script is needed, a reparse into byte code is done */
+ this->SetScriptText(scriptArg);
+
return 1;
}
return SCA_IController::_setattr(attr, value);
}
+PyObject* SCA_PythonController::PyActivate(PyObject* self, PyObject *value)
+{
+ SCA_IActuator* actu = LinkedActuatorFromPy(value);
+ if(actu==NULL)
+ return NULL;
+
+ CValue* boolval = new CBoolValue(true);
+ m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, boolval);
+ boolval->Release();
+ Py_RETURN_NONE;
+}
+
+PyObject* SCA_PythonController::PyDeActivate(PyObject* self, PyObject *value)
+{
+ SCA_IActuator* actu = LinkedActuatorFromPy(value);
+ if(actu==NULL)
+ return NULL;
+
+ CValue* boolval = new CBoolValue(false);
+ m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)actu, boolval);
+ boolval->Release();
+ Py_RETURN_NONE;
+}
PyObject* SCA_PythonController::PyGetActuators(PyObject* self)
{
@@ -410,8 +486,7 @@ SCA_PythonController::PyGetActuator(PyObject* self, PyObject* value)
for (unsigned int index=0;index<m_linkedactuators.size();index++)
{
SCA_IActuator* actua = m_linkedactuators[index];
- STR_String realname = actua->GetName();
- if (realname == scriptArg)
+ if (actua->GetName() == scriptArg)
{
return actua->AddRef();
}
@@ -448,6 +523,9 @@ PyObject* SCA_PythonController::PyGetScript(PyObject* self)
PyObject* SCA_PythonController::PySetScript(PyObject* self, PyObject* value)
{
char *scriptArg = PyString_AsString(value);
+
+ ShowDeprecationWarning("setScript()", "the script property");
+
if (scriptArg==NULL) {
PyErr_SetString(PyExc_TypeError, "expected a string (script name)");
return NULL;
diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h
index 1918cc488d8..4ec18f32c23 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.h
+++ b/source/gameengine/GameLogic/SCA_PythonController.h
@@ -70,15 +70,20 @@ class SCA_PythonController : public SCA_IController
void AddTriggeredSensor(class SCA_ISensor* sensor)
{ m_triggeredSensors.push_back(sensor); }
int IsTriggered(class SCA_ISensor* sensor);
+ bool Compile();
static const char* sPyGetCurrentController__doc__;
static PyObject* sPyGetCurrentController(PyObject* self);
static const char* sPyAddActiveActuator__doc__;
static PyObject* sPyAddActiveActuator(PyObject* self,
PyObject* args);
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ static SCA_IActuator* LinkedActuatorFromPy(PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
+
+ KX_PYMETHOD_O(SCA_PythonController,Activate);
+ KX_PYMETHOD_O(SCA_PythonController,DeActivate);
KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetSensors);
KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetActuators);
KX_PYMETHOD_DOC_O(SCA_PythonController,GetSensor);
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index 840b95d559a..d6c73f21f37 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
@@ -369,22 +369,22 @@ PyAttributeDef SCA_RandomActuator::Attributes[] = {
{ NULL } //Sentinel
};
-PyObject* SCA_RandomActuator::_getattr(const STR_String& attr) {
+PyObject* SCA_RandomActuator::_getattr(const char *attr) {
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
return object;
- if (attr == "seed") {
+ if (!strcmp(attr, "seed")) {
return PyInt_FromLong(m_base->GetSeed());
}
_getattr_up(SCA_IActuator);
}
-int SCA_RandomActuator::_setattr(const STR_String& attr, PyObject *value)
+int SCA_RandomActuator::_setattr(const char *attr, PyObject *value)
{
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
return ret;
- if (attr == "seed") {
+ if (!strcmp(attr, "seed")) {
if (PyInt_Check(value)) {
int ival = PyInt_AsLong(value);
m_base->SetSeed(ival);
@@ -413,7 +413,7 @@ PyObject* SCA_RandomActuator::PySetSeed(PyObject* self, PyObject* args, PyObject
m_base->SetSeed(seedArg);
- Py_Return;
+ Py_RETURN_NONE;
}
/* 2. getSeed */
const char SCA_RandomActuator::GetSeed_doc[] =
@@ -478,7 +478,7 @@ PyObject* SCA_RandomActuator::PySetProperty(PyObject* self, PyObject* args, PyOb
}
prop->Release();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 10. getProperty */
const char SCA_RandomActuator::GetProperty_doc[] =
@@ -506,7 +506,7 @@ PyObject* SCA_RandomActuator::PySetBoolConst(PyObject* self,
m_distribution = KX_RANDOMACT_BOOL_CONST;
m_parameter1 = (paraArg) ? 1.0 : 0.0;
- Py_Return;
+ Py_RETURN_NONE;
}
/* 12. setBoolUniform, */
const char SCA_RandomActuator::SetBoolUniform_doc[] =
@@ -518,7 +518,7 @@ PyObject* SCA_RandomActuator::PySetBoolUniform(PyObject* self,
/* no args */
m_distribution = KX_RANDOMACT_BOOL_UNIFORM;
enforceConstraints();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 13. setBoolBernouilli, */
const char SCA_RandomActuator::SetBoolBernouilli_doc[] =
@@ -536,7 +536,7 @@ PyObject* SCA_RandomActuator::PySetBoolBernouilli(PyObject* self,
m_distribution = KX_RANDOMACT_BOOL_BERNOUILLI;
m_parameter1 = paraArg;
enforceConstraints();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 14. setIntConst,*/
const char SCA_RandomActuator::SetIntConst_doc[] =
@@ -554,7 +554,7 @@ PyObject* SCA_RandomActuator::PySetIntConst(PyObject* self,
m_distribution = KX_RANDOMACT_INT_CONST;
m_parameter1 = paraArg;
enforceConstraints();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 15. setIntUniform,*/
const char SCA_RandomActuator::SetIntUniform_doc[] =
@@ -575,7 +575,7 @@ PyObject* SCA_RandomActuator::PySetIntUniform(PyObject* self,
m_parameter1 = paraArg1;
m_parameter2 = paraArg2;
enforceConstraints();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 16. setIntPoisson, */
const char SCA_RandomActuator::SetIntPoisson_doc[] =
@@ -595,7 +595,7 @@ PyObject* SCA_RandomActuator::PySetIntPoisson(PyObject* self,
m_distribution = KX_RANDOMACT_INT_POISSON;
m_parameter1 = paraArg;
enforceConstraints();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 17. setFloatConst,*/
const char SCA_RandomActuator::SetFloatConst_doc[] =
@@ -613,7 +613,7 @@ PyObject* SCA_RandomActuator::PySetFloatConst(PyObject* self,
m_distribution = KX_RANDOMACT_FLOAT_CONST;
m_parameter1 = paraArg;
enforceConstraints();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 18. setFloatUniform, */
const char SCA_RandomActuator::SetFloatUniform_doc[] =
@@ -634,7 +634,7 @@ PyObject* SCA_RandomActuator::PySetFloatUniform(PyObject* self,
m_parameter1 = paraArg1;
m_parameter2 = paraArg2;
enforceConstraints();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 19. setFloatNormal, */
const char SCA_RandomActuator::SetFloatNormal_doc[] =
@@ -655,7 +655,7 @@ PyObject* SCA_RandomActuator::PySetFloatNormal(PyObject* self,
m_parameter1 = paraArg1;
m_parameter2 = paraArg2;
enforceConstraints();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 20. setFloatNegativeExponential, */
const char SCA_RandomActuator::SetFloatNegativeExponential_doc[] =
@@ -674,7 +674,7 @@ PyObject* SCA_RandomActuator::PySetFloatNegativeExponential(PyObject* self,
m_distribution = KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL;
m_parameter1 = paraArg;
enforceConstraints();
- Py_Return;
+ Py_RETURN_NONE;
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.h b/source/gameengine/GameLogic/SCA_RandomActuator.h
index de8faaf9c72..0d404fa8a9f 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.h
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.h
@@ -96,8 +96,8 @@ class SCA_RandomActuator : public SCA_IActuator
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
/* 1. setSeed */
KX_PYMETHOD_DOC(SCA_RandomActuator,SetSeed);
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
index 8fae0bbeaba..5354c120f52 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
@@ -165,22 +165,22 @@ PyAttributeDef SCA_RandomSensor::Attributes[] = {
{NULL} //Sentinel
};
-PyObject* SCA_RandomSensor::_getattr(const STR_String& attr) {
+PyObject* SCA_RandomSensor::_getattr(const char *attr) {
PyObject* object = _getattr_self(Attributes, this, attr);
if (object != NULL)
return object;
- if (attr == "seed") {
+ if (!strcmp(attr,"seed")) {
return PyInt_FromLong(m_basegenerator->GetSeed());
}
_getattr_up(SCA_ISensor);
}
-int SCA_RandomSensor::_setattr(const STR_String& attr, PyObject *value)
+int SCA_RandomSensor::_setattr(const char *attr, PyObject *value)
{
int ret = _setattr_self(Attributes, this, attr, value);
if (ret >= 0)
return ret;
- if (attr == "seed") {
+ if (!strcmp(attr,"seed")) {
if (PyInt_Check(value)) {
int ival = PyInt_AsLong(value);
m_basegenerator->SetSeed(ival);
@@ -209,7 +209,7 @@ PyObject* SCA_RandomSensor::PySetSeed(PyObject* self, PyObject* args, PyObject*
m_basegenerator->SetSeed(seedArg);
- Py_Return;
+ Py_RETURN_NONE;
}
/* 2. getSeed */
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h
index 009efc32aac..d808db07536 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.h
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.h
@@ -60,8 +60,8 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
- virtual int _setattr(const STR_String& attr, PyObject *value);
+ virtual PyObject* _getattr(const char *attr);
+ virtual int _setattr(const char *attr, PyObject *value);
/* 1. setSeed */
KX_PYMETHOD_DOC(SCA_RandomSensor,SetSeed);
diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp
index 3ef7c07fe0a..b2734dd1b33 100644
--- a/source/gameengine/GameLogic/SCA_XNORController.cpp
+++ b/source/gameengine/GameLogic/SCA_XNORController.cpp
@@ -141,7 +141,11 @@ PyMethodDef SCA_XNORController::Methods[] = {
{NULL,NULL} //Sentinel
};
-PyObject* SCA_XNORController::_getattr(const STR_String& attr) {
+PyAttributeDef SCA_XNORController::Attributes[] = {
+ { NULL } //Sentinel
+};
+
+PyObject* SCA_XNORController::_getattr(const char *attr) {
_getattr_up(SCA_IController);
}
diff --git a/source/gameengine/GameLogic/SCA_XNORController.h b/source/gameengine/GameLogic/SCA_XNORController.h
index 4b1eaee95d8..a431a72c177 100644
--- a/source/gameengine/GameLogic/SCA_XNORController.h
+++ b/source/gameengine/GameLogic/SCA_XNORController.h
@@ -48,7 +48,7 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
+ virtual PyObject* _getattr(const char *attr);
};
diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp
index 6499c62f5f2..662ef523d56 100644
--- a/source/gameengine/GameLogic/SCA_XORController.cpp
+++ b/source/gameengine/GameLogic/SCA_XORController.cpp
@@ -141,7 +141,11 @@ PyMethodDef SCA_XORController::Methods[] = {
{NULL,NULL} //Sentinel
};
-PyObject* SCA_XORController::_getattr(const STR_String& attr) {
+PyAttributeDef SCA_XORController::Attributes[] = {
+ { NULL } //Sentinel
+};
+
+PyObject* SCA_XORController::_getattr(const char *attr) {
_getattr_up(SCA_IController);
}
diff --git a/source/gameengine/GameLogic/SCA_XORController.h b/source/gameengine/GameLogic/SCA_XORController.h
index f50cd33c125..2fbc7866ecf 100644
--- a/source/gameengine/GameLogic/SCA_XORController.h
+++ b/source/gameengine/GameLogic/SCA_XORController.h
@@ -48,7 +48,7 @@ public:
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
- virtual PyObject* _getattr(const STR_String& attr);
+ virtual PyObject* _getattr(const char *attr);
};
diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript
index 25cf73cd079..88e5f7e87cc 100644
--- a/source/gameengine/GameLogic/SConscript
+++ b/source/gameengine/GameLogic/SConscript
@@ -17,4 +17,9 @@ if env['WITH_BF_SDL']:
else:
defs += ' DISABLE_SDL'
-env.BlenderLib ( 'bf_logic', sources, Split(incs), Split(defs), libtype=['core','player'], priority=[315, 100] )
+cxxflags = []
+if env['OURPLATFORM']=='win32-vc':
+ cxxflags.append ('/GR')
+ cxxflags.append ('/O2')
+
+env.BlenderLib ( 'bf_logic', sources, Split(incs), Split(defs), libtype=['core','player'], priority=[330, 100], cxx_compileflags=cxxflags )