[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15562] trunk/blender/source/gameengine: last commit didn' t work because GameLogic was a imported as a dict rather then a module.
Campbell Barton
ideasman42 at gmail.com
Mon Jul 14 03:44:07 CEST 2008
Revision: 15562
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15562
Author: campbellbarton
Date: 2008-07-14 03:44:05 +0200 (Mon, 14 Jul 2008)
Log Message:
-----------
last commit didn't work because GameLogic was a imported as a dict rather then a module. (was only printing it when testing).
Removed dictionaryClearByHand which was only called PyDict_Clear()
Modified Paths:
--------------
trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
trunk/blender/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp
trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
trunk/blender/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp
trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
trunk/blender/source/gameengine/Ketsji/KX_PythonInit.h
trunk/blender/source/gameengine/Ketsji/KX_SoundActuator.cpp
Modified: trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
===================================================================
--- trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp 2008-07-14 00:47:07 UTC (rev 15561)
+++ trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp 2008-07-14 01:44:05 UTC (rev 15562)
@@ -400,7 +400,14 @@
exitstring = ketsjiengine->GetExitString();
// when exiting the mainloop
- dictionaryClearByHand(gameLogic);
+
+ // Clears the dictionary by hand:
+ // This prevents, extra references to global variables
+ // inside the GameLogic dictionary when the python interpreter is finalized.
+ // which allows the scene to safely delete them :)
+ // see: (space.c)->start_game
+ PyDict_Clear(PyModule_GetDict(gameLogic));
+
ketsjiengine->StopEngine();
exitGamePythonScripting();
networkdevice->Disconnect();
Modified: trunk/blender/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp
===================================================================
--- trunk/blender/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp 2008-07-14 00:47:07 UTC (rev 15561)
+++ trunk/blender/source/gameengine/GamePlayer/ActiveX/BlenderPlayerCtl.cpp 2008-07-14 01:44:05 UTC (rev 15562)
@@ -668,7 +668,7 @@
m_ketsjiengine->SetPythonDictionary(m_dictionaryobject);
initRasterizer(m_rasterizer, m_canvas);
- initGameLogic(startscene);
+ PyDict_SetItemString(m_dictionaryobject, "GameLogic", initGameLogic(startscene)); // Same as importing the module
initGameKeys();
initPythonConstraintBinding();
Modified: trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
===================================================================
--- trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Application.cpp 2008-07-14 00:47:07 UTC (rev 15561)
+++ trunk/blender/source/gameengine/GamePlayer/ghost/GPG_Application.cpp 2008-07-14 01:44:05 UTC (rev 15562)
@@ -644,7 +644,7 @@
PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest);
m_ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(m_rasterizer, m_canvas);
- PyObject *gameLogic = initGameLogic(startscene);
+ PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(startscene)); // Same as importing the module
initGameKeys();
initPythonConstraintBinding();
Modified: trunk/blender/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp
===================================================================
--- trunk/blender/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp 2008-07-14 00:47:07 UTC (rev 15561)
+++ trunk/blender/source/gameengine/GamePlayer/netscape/src/ketsji/KXH_ketsji_hooks.cpp 2008-07-14 01:44:05 UTC (rev 15562)
@@ -566,8 +566,8 @@
k->audiodevice,
startSceneName->Ptr());
- initRasterizer(k->rasterizer, k->canvas_device);
- initGameLogic(startscene);
+ initRasterizer(k->rasterizer, k->canvas_device);;
+ PyDict_SetItemString(dictionaryobject, "GameLogic", initGameLogic(startscene)); // Same as importing the module
initGameKeys();
initPythonConstraintBinding();
Modified: trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp 2008-07-14 00:47:07 UTC (rev 15561)
+++ trunk/blender/source/gameengine/Ketsji/KX_KetsjiEngine.cpp 2008-07-14 01:44:05 UTC (rev 15562)
@@ -231,7 +231,10 @@
}
-
+/*
+ * At the moment the GameLogic module is imported into 'pythondictionary' after this function is called.
+ * if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand.
+ */
void KX_KetsjiEngine::SetPythonDictionary(PyObject* pythondictionary)
{
MT_assert(pythondictionary);
Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2008-07-14 00:47:07 UTC (rev 15561)
+++ trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp 2008-07-14 01:44:05 UTC (rev 15562)
@@ -828,20 +828,9 @@
Py_FatalError("can't initialize module GameLogic");
}
- return d;
+ return m;
}
-void dictionaryClearByHand(PyObject *dict)
-{
- // Clears the dictionary by hand:
- // This prevents, extra references to global variables
- // inside the GameLogic dictionary when the python interpreter is finalized.
- // which allows the scene to safely delete them :)
- // see: (space.c)->start_game
- if(dict) PyDict_Clear(dict);
-}
-
-
// Python Sandbox code
// override builtin functions import() and open()
Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.h
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PythonInit.h 2008-07-14 00:47:07 UTC (rev 15561)
+++ trunk/blender/source/gameengine/Ketsji/KX_PythonInit.h 2008-07-14 01:44:05 UTC (rev 15562)
@@ -47,7 +47,6 @@
void exitGamePlayerPythonScripting();
PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level);
void exitGamePythonScripting();
-void dictionaryClearByHand(PyObject *dict);
void PHY_SetActiveScene(class KX_Scene* scene);
class KX_Scene* PHY_GetActiveScene();
Modified: trunk/blender/source/gameengine/Ketsji/KX_SoundActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_SoundActuator.cpp 2008-07-14 00:47:07 UTC (rev 15561)
+++ trunk/blender/source/gameengine/Ketsji/KX_SoundActuator.cpp 2008-07-14 01:44:05 UTC (rev 15562)
@@ -291,7 +291,8 @@
char* name = objectname.Ptr();
if (!name) {
- Py_Return; /* internal error */
+ PyErr_SetString(PyExc_RuntimeError, "Unable to get sound filename");
+ return NULL;
} else
return PyString_FromString(name);
}
More information about the Bf-blender-cvs
mailing list