Revision: 16188
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16188
Author:   campbellbarton
Date:     2008-08-19 13:53:24 +0200 (Tue, 19 Aug 2008)

Log Message:
-----------
Added GameLogic.globalDict, this is a place where data can be stored even when 
new blend files are loaded. Using for apricot so frankie can go into levels in 
new blendfiles keeping his inventory, currently it dosnt work for the 
blenderplayer which stops python before loading new blend files.

Modified Paths:
--------------
    trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
    trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp

Modified: 
trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
===================================================================
--- trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp     
2008-08-19 11:26:18 UTC (rev 16187)
+++ trunk/blender/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp     
2008-08-19 11:53:24 UTC (rev 16188)
@@ -116,7 +116,9 @@
        // Acquire Python's GIL (global interpreter lock)
        // so we can safely run Python code and API calls
        PyGILState_STATE gilstate = PyGILState_Ensure();
-
+       
+       PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans 
blend file loading */
+       
        bgl::InitExtensions(true);
 
        do
@@ -310,6 +312,7 @@
                        initRasterizer(rasterizer, canvas);
                        PyObject *gameLogic = initGameLogic(startscene);
                        PyDict_SetItemString(dictionaryobject, "GameLogic", 
gameLogic); // Same as importing the module.
+                       PyDict_SetItemString(PyModule_GetDict(gameLogic), 
"globalDict", pyGlobalDict); // Same as importing the module.
                        initGameKeys();
                        initPythonConstraintBinding();
                        initMathutils();
@@ -384,6 +387,7 @@
                                // which allows the scene to safely delete them 
:)
                                // see: (space.c)->start_game
                                PyDict_Clear(PyModule_GetDict(gameLogic));
+                               
PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict);
                                
                                ketsjiengine->StopEngine();
                                exitGamePythonScripting();

Modified: trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp    2008-08-19 
11:26:18 UTC (rev 16187)
+++ trunk/blender/source/gameengine/Ketsji/KX_PythonInit.cpp    2008-08-19 
11:53:24 UTC (rev 16188)
@@ -733,6 +733,10 @@
 
        // Add some symbolic constants to the module
        d = PyModule_GetDict(m);
+       
+       // can be overwritten later for gameEngine instances that can load new 
blend files and re-initialize this module
+       // for now its safe to make sure it exists for other areas such as the 
web plugin
+       PyDict_SetItemString(d, "globalDict", PyDict_New());
 
        ErrorObject = PyString_FromString("GameLogic.error");
        PyDict_SetItemString(d, "error", ErrorObject);


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to