diff options
Diffstat (limited to 'source/gameengine/GameLogic')
22 files changed, 56 insertions, 67 deletions
diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt index 64f198f72a0..e511704c7f4 100644 --- a/source/gameengine/GameLogic/CMakeLists.txt +++ b/source/gameengine/GameLogic/CMakeLists.txt @@ -32,6 +32,7 @@ set(INC ../../../intern/container ../../../intern/moto/include ../../../intern/string + ../../../intern/ghost ) set(INC_SYS diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h index b91e6f872a2..dee9ea4e8ba 100644 --- a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h +++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h @@ -49,9 +49,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_ActuatorEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_ActuatorEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h index 21ac55d36a4..cf4063fba1f 100644 --- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h +++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h @@ -43,9 +43,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_AlwaysEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_AlwaysEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_BasicEventManager.h b/source/gameengine/GameLogic/SCA_BasicEventManager.h index 9d08a7785e2..24206e46a61 100644 --- a/source/gameengine/GameLogic/SCA_BasicEventManager.h +++ b/source/gameengine/GameLogic/SCA_BasicEventManager.h @@ -50,9 +50,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_BasicEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_BasicEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h index 933fdc5190a..83322fe8243 100644 --- a/source/gameengine/GameLogic/SCA_EventManager.h +++ b/source/gameengine/GameLogic/SCA_EventManager.h @@ -84,9 +84,7 @@ protected: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_EventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_EventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_ExpressionController.h b/source/gameengine/GameLogic/SCA_ExpressionController.h index 47401ea5807..06edc83ab96 100644 --- a/source/gameengine/GameLogic/SCA_ExpressionController.h +++ b/source/gameengine/GameLogic/SCA_ExpressionController.h @@ -59,9 +59,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_ExpressionController"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_ExpressionController") #endif }; diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h index 211a25b84c8..801483bb882 100644 --- a/source/gameengine/GameLogic/SCA_IActuator.h +++ b/source/gameengine/GameLogic/SCA_IActuator.h @@ -160,9 +160,7 @@ public: bool IsType(KX_ACTUATOR_TYPE type) { return m_type == type; } #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_IActuator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_IActuator") #endif }; diff --git a/source/gameengine/GameLogic/SCA_IInputDevice.h b/source/gameengine/GameLogic/SCA_IInputDevice.h index 443faef6338..0382a2efd21 100644 --- a/source/gameengine/GameLogic/SCA_IInputDevice.h +++ b/source/gameengine/GameLogic/SCA_IInputDevice.h @@ -274,14 +274,14 @@ public: protected: /** - m_eventStatusTables are two tables that contain current and previous - status of all events - */ + * m_eventStatusTables are two tables that contain current and previous + * status of all events + */ SCA_InputEvent m_eventStatusTables[2][SCA_IInputDevice::KX_MAX_KEYS]; /** - m_currentTable is index for m_keyStatusTable that toggle between 0 or 1 - */ + * m_currentTable is index for m_keyStatusTable that toggle between 0 or 1 + */ int m_currentTable; void ClearStatusTable(int tableid); @@ -316,9 +316,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_InputEvent"); } - void operator delete(void *mem) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_InputEvent") #endif }; diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h index e7806ea0746..a399e313082 100644 --- a/source/gameengine/GameLogic/SCA_IScene.h +++ b/source/gameengine/GameLogic/SCA_IScene.h @@ -74,9 +74,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_IScene"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_IScene") #endif }; diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h index dcdd667cb1a..60dcaea4ef2 100644 --- a/source/gameengine/GameLogic/SCA_JoystickManager.h +++ b/source/gameengine/GameLogic/SCA_JoystickManager.h @@ -51,9 +51,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_JoystickManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_JoystickManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h index 5706d16ae19..2d9ad45833f 100644 --- a/source/gameengine/GameLogic/SCA_KeyboardManager.h +++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h @@ -59,9 +59,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_KeyboardManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_KeyboardManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp index 6543d16d469..1263514d475 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.cpp +++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp @@ -56,7 +56,7 @@ SCA_LogicManager::~SCA_LogicManager() assert(m_activeActuators.Empty()); } -/* +#if 0 // this kind of fixes bug 398 but breakes games, so better leave it out for now. // a removed object's gameobject (and logicbricks and stuff) didn't get released // because it was still in the m_mapStringToGameObjects map. @@ -77,7 +77,7 @@ void SCA_LogicManager::RemoveGameObject(const STR_String& gameobjname) m_mapStringToGameObjects.remove(gameobjname); } -*/ +#endif void SCA_LogicManager::RegisterEventManager(SCA_EventManager* eventmgr) diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h index 751c03bc712..817f3a1c22a 100644 --- a/source/gameengine/GameLogic/SCA_LogicManager.h +++ b/source/gameengine/GameLogic/SCA_LogicManager.h @@ -147,9 +147,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_LogicManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_LogicManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h index 4b40ab8a197..60edb2816cb 100644 --- a/source/gameengine/GameLogic/SCA_MouseManager.h +++ b/source/gameengine/GameLogic/SCA_MouseManager.h @@ -68,9 +68,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_MouseManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_MouseManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h index 7d5e13f0ae1..7a4ec750484 100644 --- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h +++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.h @@ -48,9 +48,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_PropertyEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_PropertyEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp index ce183b37498..a92ffac4129 100644 --- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp +++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp @@ -318,9 +318,9 @@ CValue* SCA_PropertySensor::FindIdentifier(const STR_String& identifiername) int SCA_PropertySensor::validValueForProperty(void *self, const PyAttributeDef*) { - /* If someone actually do type checking please make sure the 'max' and 'min' - are checked as well (currently they are calling the PrecalculateRangeExpression - function directly */ + /* If someone actually do type checking please make sure the 'max' and 'min' + * are checked as well (currently they are calling the PrecalculateRangeExpression + * function directly */ /* There is no type checking at this moment, unfortunately... */ return 0; diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp index 94a8628ca79..ab7f57a5454 100644 --- a/source/gameengine/GameLogic/SCA_PythonController.cpp +++ b/source/gameengine/GameLogic/SCA_PythonController.cpp @@ -71,21 +71,19 @@ SCA_PythonController::SCA_PythonController(SCA_IObject* gameobj, int mode) } -/* +#if 0 //debugging -CValue* SCA_PythonController::AddRef() +CValue *SCA_PythonController::AddRef() { //printf("AddRef refcount = %i\n",GetRefCount()); return CValue::AddRef(); } -int SCA_PythonController::Release() +int SCA_PythonController::Release() { //printf("Release refcount = %i\n",GetRefCount()); return CValue::Release(); } -*/ - - +#endif SCA_PythonController::~SCA_PythonController() { @@ -122,13 +120,14 @@ CValue* SCA_PythonController::GetReplica() if (m_pythondictionary) replica->m_pythondictionary = PyDict_Copy(m_pythondictionary); - /* +#if 0 // The other option is to incref the replica->m_pythondictionary - // the replica objects can then share data. if (m_pythondictionary) Py_INCREF(replica->m_pythondictionary); - */ #endif + +#endif /* WITH_PYTHON */ // this will copy properties and so on... replica->ProcessReplica(); diff --git a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp index 46c43b5e339..f83b23f510c 100644 --- a/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp +++ b/source/gameengine/GameLogic/SCA_PythonKeyboard.cpp @@ -28,6 +28,8 @@ #include "SCA_PythonKeyboard.h" #include "SCA_IInputDevice.h" +#include "GHOST_C-api.h" + /* ------------------------------------------------------------------------- */ /* Native functions */ /* ------------------------------------------------------------------------- */ @@ -55,6 +57,23 @@ SCA_PythonKeyboard::~SCA_PythonKeyboard() /* Python functions */ /* ------------------------------------------------------------------------- */ +/* clipboard */ +static PyObject* gPyGetClipboard(PyObject* args, PyObject* kwds) +{ + char *buf = (char *)GHOST_getClipboard(0); + return PyUnicode_FromString(buf?buf:""); +} + +static PyObject* gPySetClipboard(PyObject* args, PyObject* value) +{ + char* buf; + if (!PyArg_ParseTuple(value,"s:setClipboard",&buf)) + Py_RETURN_NONE; + + GHOST_putClipboard((GHOST_TInt8 *)buf, 0); + Py_RETURN_NONE; +} + /* Integration hooks ------------------------------------------------------- */ PyTypeObject SCA_PythonKeyboard::Type = { PyVarObject_HEAD_INIT(NULL, 0) @@ -79,6 +98,8 @@ PyTypeObject SCA_PythonKeyboard::Type = { }; PyMethodDef SCA_PythonKeyboard::Methods[] = { + {"getClipboard", (PyCFunction) gPyGetClipboard, METH_VARARGS, "getCliboard doc"}, + {"setClipboard", (PyCFunction) gPySetClipboard, METH_VARARGS, "setCliboard doc"}, {NULL,NULL} //Sentinel }; diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.h b/source/gameengine/GameLogic/SCA_RandomEventManager.h index 7205363a3ee..b46899b1355 100644 --- a/source/gameengine/GameLogic/SCA_RandomEventManager.h +++ b/source/gameengine/GameLogic/SCA_RandomEventManager.h @@ -47,9 +47,7 @@ public: #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_RandomEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_RandomEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h index 8f546b37ec8..10818cb4e8f 100644 --- a/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h +++ b/source/gameengine/GameLogic/SCA_RandomNumberGenerator.h @@ -77,9 +77,7 @@ class SCA_RandomNumberGenerator { #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_RandomNumberGenerator"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_RandomNumberGenerator") #endif }; diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.h b/source/gameengine/GameLogic/SCA_TimeEventManager.h index 7c813785b9c..092cf016370 100644 --- a/source/gameengine/GameLogic/SCA_TimeEventManager.h +++ b/source/gameengine/GameLogic/SCA_TimeEventManager.h @@ -55,9 +55,7 @@ public: vector<CValue*> GetTimeValues(); #ifdef WITH_CXX_GUARDEDALLOC -public: - void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_TimeEventManager"); } - void operator delete( void *mem ) { MEM_freeN(mem); } + MEM_CXX_CLASS_ALLOC_FUNCS("GE:SCA_TimeEventManager") #endif }; diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript index e33169bada7..da3c0fadb51 100644 --- a/source/gameengine/GameLogic/SConscript +++ b/source/gameengine/GameLogic/SConscript @@ -3,7 +3,7 @@ Import ('env') sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp') -incs = '. #/intern/string #intern/container' +incs = '. #/intern/string #intern/container #intern/ghost' incs += ' #/source/gameengine/Expressions #/intern/moto/include' incs += ' #/source/gameengine/Rasterizer #/source/gameengine/SceneGraph' incs += ' #/source/blender/blenlib' |