Merged 15170:15635 from trunk (no conflicts or even merges)
[blender.git] / source / gameengine / GamePlayer / ghost / GPG_ghost.cpp
index 23447d3640146daaea20d3c9d8800178e1fa6a6a..8222e5c8bac8da78f5c7a0b14960db8aff3f4b3f 100644 (file)
@@ -1,15 +1,12 @@
 /**
 * $Id$
 *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,7 +24,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
 * Start up of the Blender Player on GHOST.
 */
 
@@ -190,11 +187,10 @@ void usage(char* program)
        printf("       show_framerate     0         Show the frame rate\n");
        printf("       show_properties    0         Show debug properties\n");
        printf("       show_profile       0         Show profiling information\n");
-       printf("       vertexarrays       1         Enable vertex arrays\n");
        printf("       blender_material   0         Enable material settings\n");
        printf("\n");
        printf("example: %s -p 10 10 320 200 -g noaudio c:\\loadtest.blend\n", program);
-       printf("example: %s -g vertexarrays = 0 c:\\loadtest.blend\n", program);
+       printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program);
 }
 
 char *get_filename(int argc, char **argv) {
@@ -304,7 +300,6 @@ int main(int argc, char** argv)
 #endif /* __alpha__ */
 #endif /* __linux__ */
        BLI_where_am_i(bprogname, argv[0]);
-       
 #ifdef __APPLE__
     // Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh)
     /*
@@ -566,26 +561,37 @@ int main(int argc, char** argv)
                                STR_String exitstring = "";
                                GPG_Application app(system, NULL, exitstring);
                                bool firstTimeRunning = true;
+                               char *filename = get_filename(argc, argv);
+                               char *titlename;
+                               char pathname[160];
                                
                                do
                                {
                                        // Read the Blender file
-                                       char *filename = get_filename(argc, argv);
-                                       char *titlename;
-                                       char pathname[160];
                                        BlendFileData *bfd;
                                        
                                        // if we got an exitcode 3 (KX_EXIT_REQUEST_START_OTHER_GAME) load a different file
                                        if (exitcode == KX_EXIT_REQUEST_START_OTHER_GAME)
                                        {
-                                               char basedpath[160];
+                                               char basedpath[240];
                                                
                                                // base the actuator filename with respect
                                                // to the original file working directory
                                                strcpy(basedpath, exitstring.Ptr());
-                                               BLI_convertstringcode(basedpath, pathname, 0);
+                                               BLI_convertstringcode(basedpath, pathname);
                                                
                                                bfd = load_game_data(basedpath);
+
+                                               if (!bfd)
+                                               {
+                                                       // just add "//" in front of it
+                                                       char temppath[242];
+                                                       strcpy(temppath, "//");
+                                                       strcat(temppath, basedpath);
+                               
+                                                       BLI_convertstringcode(temppath, pathname);
+                                                       bfd = load_game_data(temppath);
+                                               }
                                        }
                                        else
                                        {
@@ -611,7 +617,6 @@ int main(int argc, char** argv)
 #endif // WIN32
                                                Main *maggie = bfd->main;
                                                Scene *scene = bfd->curscene;
-                                               strcpy (pathname, maggie->name);
                                                char *startscenename = scene->id.name + 2;
                                                G.fileflags  = bfd->fileflags;
 
@@ -655,7 +660,12 @@ int main(int argc, char** argv)
                                                if (firstTimeRunning)
                                                {
                                                        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