BGE Dynamic Loading: When given a relative path (starts with "//") for LibLoad()...
authorMitchell Stokes <mogurijin@gmail.com>
Mon, 21 Mar 2011 09:29:28 +0000 (09:29 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Mon, 21 Mar 2011 09:29:28 +0000 (09:29 +0000)
source/gameengine/Ketsji/KX_PythonInit.cpp

index 60ee86c52c432cb73e971abb965f5486593089b2..5d5367653b79bafc4d9062326d37ae6f2437aebf 100644 (file)
@@ -642,6 +642,7 @@ static PyObject *gLibLoad(PyObject*, PyObject* args)
 {
        KX_Scene *kx_scene= gp_KetsjiScene;
        char *path;
+       char abs_path[FILE_MAX] = {0};
        char *group;
        Py_buffer py_buffer;
        py_buffer.buf = NULL;
@@ -652,7 +653,11 @@ static PyObject *gLibLoad(PyObject*, PyObject* args)
 
        if (!py_buffer.buf)
        {
-               if(kx_scene->GetSceneConverter()->LinkBlendFilePath(path, group, kx_scene, &err_str)) {
+               // Make the path absolute
+               BLI_strncpy(abs_path, path, sizeof(abs_path));
+               BLI_path_abs(abs_path, gp_GamePythonPath);
+
+               if(kx_scene->GetSceneConverter()->LinkBlendFilePath(abs_path, group, kx_scene, &err_str)) {
                        Py_RETURN_TRUE;
                }
        }