Index: source/blender/windowmanager/intern/wm_init_exit.c =================================================================== --- source/blender/windowmanager/intern/wm_init_exit.c (revision 27366) +++ source/blender/windowmanager/intern/wm_init_exit.c (working copy) @@ -185,16 +185,55 @@ void WM_init_game(bContext *C) { - //XXX copied from WM_init_splash we may not even need those "window" related code - //XXX not working yet, it fails at the game_start_operator pool (it needs an area) wmWindowManager *wm= CTX_wm_manager(C); - wmWindow *prevwin= CTX_wm_window(C); - - if(wm->windows.first) { + + /* + bScreen *sc= CTX_wm_screen(C); + ScrArea *sa= CTX_wm_area(C); + */ + + bScreen *sc; + ScrArea *sa; + ARegion *ar; + + //first to get a valid window + if(wm->windows.first) CTX_wm_window_set(C, wm->windows.first); + + // now to get the current screen + sc= CTX_wm_screen(C); + + // loop over the areas and try to find a space_view3d + // use the first one that's found + // it could use the biggest one (not implemented though) + + if(sc){ + for(sa= sc->areabase.first; sa; sa= sa->next) { + + if(sa->spacetype != SPACE_VIEW3D) + for(sa=sc->areabase.first; sa; sa= sa->next) + if(sa->spacetype==SPACE_VIEW3D) + break; + + if (!sa) continue; + + for(ar=sa->regionbase.first; ar; ar=ar->next) + if(ar->regiontype == RGN_TYPE_WINDOW) + break; + + if(!ar) continue; + + CTX_wm_area_set(C, sa); + CTX_wm_region_set(C, ar); + + break; + } + } + // if we have a valid 3D view + if (sa && ar) WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL); - CTX_wm_window_set(C, prevwin); - } + else + printf("No valid 3D View found. Game auto start is not possible"); } /* free strings of open recent files */ Index: source/creator/creator.c =================================================================== --- source/creator/creator.c (revision 27366) +++ source/creator/creator.c (working copy) @@ -1041,7 +1041,7 @@ } else { - if((G.fileflags & G_FILE_AUTOPLAY) && (G.fileflags & G_SCRIPT_AUTOEXEC)) + if((G.fileflags & G_FILE_AUTOPLAY))// && (G.fileflags & G_SCRIPT_AUTOEXEC)) WM_init_game(C); else if(!G.file_loaded)