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/GamePlayer | |
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/GamePlayer')
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_ghost.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index fbb8d6530ba..0bf0317d8f2 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -44,6 +44,7 @@ #endif // __APPLE__ #include "GEN_messaging.h" #include "KX_KetsjiEngine.h" +#include "KX_PythonInit.h" /********************************** * Begin Blender include block @@ -599,8 +600,8 @@ int main(int argc, char** argv) GPG_Application app(system); bool firstTimeRunning = true; char filename[FILE_MAXDIR + FILE_MAXFILE]; + char pathname[FILE_MAXDIR + FILE_MAXFILE]; char *titlename; - char pathname[160]; get_filename(argc, argv, filename); if(filename[0]) @@ -616,8 +617,7 @@ int main(int argc, char** argv) { char basedpath[240]; - // base the actuator filename with respect - // to the original file working directory + // base the actuator filename relative to the last file strcpy(basedpath, exitstring.Ptr()); BLI_convertstringcode(basedpath, pathname); @@ -700,15 +700,14 @@ int main(int argc, char** argv) // GPG_Application app (system, maggie, startscenename); app.SetGameEngineData(maggie, scene); + BLI_strncpy(pathname, maggie->name, sizeof(pathname)); + BLI_strncpy(G.sce, maggie->name, sizeof(G.sce)); + if (firstTimeRunning) { + setGamePythonPath(G.sce); firstTimeRunning = false; - // set the filename only the first time as in KetsjiEmbedded - strcpy (pathname, maggie->name); - // also copy here (used by GameLogic.getBaseDirectory) - strcpy (G.sce, maggie->name); - if (fullScreen) { #ifdef WIN32 |