Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2008-05-11 22:45:30 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2008-05-11 22:45:30 +0400
commit96486b356f7d035a7abc835adbef850c3f314264 (patch)
tree29a66d4ec0ef0b8188be7deed6ba818114ff7d39 /source/gameengine/Ketsji
parent6da415d406c5d46852aac65a4920fbf4a89d4fa7 (diff)
fix BGE bug #8668: Behavior of os.getcwd() is not consistent between operating systems
Add a function GameLogic.expandPath() that works like Blender.sys.expandpath() and is also available in the BlenderPlayer. Fix the game actuator in the BlenderPlayer to work like in Blender: - try first to load the .blend from the current working directory - if not found, try to load from the startup .blend or runtime base directory
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index a2aff54d385..a80a7f04e8f 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -88,6 +88,10 @@
//#include "BPY_extern.h"
#endif
+#include "BKE_utildefines.h"
+#include "BKE_global.h"
+#include "BLI_blenlib.h"
+
static void setSandbox(TPythonSecurityLevel level);
@@ -140,6 +144,32 @@ static PyObject* gPySetGravity(PyObject*,
return NULL;
}
+static char gPyExpandPath_doc[] =
+"(path) - Converts a blender internal path into a proper file system path.\n\
+path - the string path to convert.\n\n\
+Use / as directory separator in path\n\
+You can use '//' at the start of the string to define a relative path;\n\
+Blender replaces that string by the directory of the startup .blend or runtime\n\
+file to make a full path name (doesn't change during the game, even if you load\n\
+other .blend).\n\
+The function also converts the directory separator to the local file system format.";
+
+static PyObject* gPyExpandPath(PyObject*,
+ PyObject* args,
+ PyObject*)
+{
+ char expanded[FILE_MAXDIR + FILE_MAXFILE];
+ char* filename;
+
+ if (PyArg_ParseTuple(args,"s",&filename))
+ {
+ BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE);
+ BLI_convertstringcode(expanded, G.sce);
+ return PyString_FromString(expanded);
+ }
+ return NULL;
+}
+
static bool usedsp = false;
@@ -361,6 +391,7 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
static struct PyMethodDef game_methods[] = {
+ {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, gPyExpandPath_doc},
{"getCurrentController",
(PyCFunction) SCA_PythonController::sPyGetCurrentController,
METH_VARARGS, SCA_PythonController::sPyGetCurrentController__doc__},