BGE Blendfile path bug (use for loading and saving the GameLogic.globalDict)
authorCampbell Barton <ideasman42@gmail.com>
Mon, 1 Jun 2009 12:36:22 +0000 (12:36 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 1 Jun 2009 12:36:22 +0000 (12:36 +0000)
the original blendfile path wasn't reset when loading new blendfiles.
blenderplayer was ok, but running the BGE from blender would set the blendfile original path and never reset it on loading other blend files.

source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
source/gameengine/Ketsji/KX_PythonInit.cpp
source/gameengine/Ketsji/KX_PythonInit.h

index 0e0377a7cb986b13ec404870a447e1e36a5725a9..c3ff923b8fbfabfe45d86c779d60e05c55326170 100644 (file)
@@ -118,6 +118,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
 
        BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
        BLI_strncpy(oldsce, G.sce, sizeof(oldsce));
+       resetGamePythonPath(); // need this so running a second time wont use an old blendfiles path
        setGamePythonPath(G.sce);
 
        // Acquire Python's GIL (global interpreter lock)
index 3294789249df42f00bd23acecf921c8051f8b571..20009b7b8461894bdf123404ac1afbec6837ebe6 100644 (file)
@@ -2093,3 +2093,10 @@ void setGamePythonPath(char *path)
                BLI_strncpy(gp_GamePythonPathOrig, path, sizeof(gp_GamePythonPathOrig));
 }
 
+// we need this so while blender is open (not blenderplayer)
+// loading new blendfiles will reset this on starting the
+// engine but loading blend files within the BGE wont overwrite gp_GamePythonPathOrig
+void resetGamePythonPath()
+{
+       gp_GamePythonPathOrig[0] == '\0';
+}
index 3253ac8f711888960c3341fce8ec575fe05e30f5..8f102d13a18abea350d42cf702f01be665a196d9 100644 (file)
@@ -53,6 +53,7 @@ PyObject*     initGamePythonScripting(const STR_String& progname, TPythonSecurityLev
 void           exitGamePythonScripting();
 
 void           setGamePythonPath(char *path);
+void           resetGamePythonPath();
 void           pathGamePythonConfig( char *path );
 int                    saveGamePythonConfig( char **marshal_buffer);
 int                    loadGamePythonConfig(char *marshal_buffer, int marshal_length);