diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-10-11 04:56:49 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-10-11 04:56:49 +0400 |
commit | 9b948cad08067a6bedd49ccfb059874aba7555b9 (patch) | |
tree | 5fc5236ab893aaaadec1a83081b923ededd24e32 /source/gameengine/Ketsji/KX_PythonInit.cpp | |
parent | c3aef29ab704ba7ca9ec401ad0028d21d8b431be (diff) |
Fix for a relative paths issue in the game engine. G.sce was being
kept as the original file, but that can't work correct for solving
relative paths once a .blend in another directory is loaded. The
reason it went OK with the apricot tech demo is that the images there
were lib linked into the level file, which still worked.
Now it sets G.sce to the current loaded .blend file. Note that the
python config file path still uses the first loaded .blend file so it
looks in the same location each time.
Also added some NULL pointer checks in the joystick code because it
was crashing there on Mac, there's similar checks in related functions
so I'm assuming this was just a missed case.
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonInit.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_PythonInit.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index cdf7ebd0943..a30d9f4022d 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -97,6 +97,7 @@ static RAS_ICanvas* gp_Canvas = NULL; static KX_Scene* gp_KetsjiScene = NULL; static KX_KetsjiEngine* gp_KetsjiEngine = NULL; static RAS_IRasterizer* gp_Rasterizer = NULL; +static char gp_GamePythonPath[FILE_MAXDIR + FILE_MAXFILE] = ""; void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color) { @@ -155,7 +156,7 @@ static PyObject* gPyExpandPath(PyObject*, PyObject* args) return NULL; BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE); - BLI_convertstringcode(expanded, G.sce); + BLI_convertstringcode(expanded, gp_GamePythonPath); return PyString_FromString(expanded); } @@ -281,7 +282,7 @@ static PyObject* gPyGetAverageFrameRate(PyObject*) static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) { - char cpath[sizeof(G.sce)]; + char cpath[sizeof(gp_GamePythonPath)]; char *searchpath = NULL; PyObject* list, *value; @@ -295,10 +296,10 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args) if (searchpath) { BLI_strncpy(cpath, searchpath, FILE_MAXDIR + FILE_MAXFILE); - BLI_convertstringcode(cpath, G.sce); + BLI_convertstringcode(cpath, gp_GamePythonPath); } else { /* Get the dir only */ - BLI_split_dirfile_basic(G.sce, cpath, NULL); + BLI_split_dirfile_basic(gp_GamePythonPath, cpath, NULL); } if((dp = opendir(cpath)) == NULL) { @@ -1541,9 +1542,10 @@ int loadGamePythonConfig(char *marshal_buffer, int marshal_length) void pathGamePythonConfig( char *path ) { - int len = strlen(G.sce); + int len = strlen(gp_GamePythonPath); - strncpy(path, G.sce, sizeof(G.sce)); + BLI_strncpy(path, gp_GamePythonPath, sizeof(gp_GamePythonPath)); + /* replace extension */ if (BLI_testextensie(path, ".blend")) { strcpy(path+(len-6), ".bgeconf"); @@ -1551,3 +1553,9 @@ void pathGamePythonConfig( char *path ) strcpy(path+len, ".bgeconf"); } } + +void setGamePythonPath(char *path) +{ + BLI_strncpy(gp_GamePythonPath, path, sizeof(gp_GamePythonPath)); +} + |