From 939265a77de93fd6e9b5136ad948fc16ce077918 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 1 Jun 2012 20:34:17 +0100 Subject: [PATCH] Deferred loading of save files --- includes/defines.h | 2 ++ src/SDLMain.m | 26 +++++++++++++++++--- src/interface.c | 2 +- src/main.c | 61 ++++++++++++++++++++++++++++++---------------- 4 files changed, 65 insertions(+), 26 deletions(-) diff --git a/includes/defines.h b/includes/defines.h index 9ccc83ad6..bfe8654f8 100644 --- a/includes/defines.h +++ b/includes/defines.h @@ -162,6 +162,8 @@ typedef unsigned int pixel; typedef unsigned char uint8; extern int saveURIOpen; +extern char * saveDataOpen; +extern int saveDataOpenSize; extern int amd; diff --git a/src/SDLMain.m b/src/SDLMain.m index 3298fc2ba..bca225357 100644 --- a/src/SDLMain.m +++ b/src/SDLMain.m @@ -233,6 +233,7 @@ static void CustomApplicationMain (int argc, char **argv) #endif +void *file_load(char *fn, int *size); /* * Catch document open requests...this lets us notice files when the app @@ -251,15 +252,15 @@ static void CustomApplicationMain (int argc, char **argv) */ - (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename { - const char *temparg; + /*const char *temparg; size_t arglen; char *arg; char **newargv; - if (!gFinderLaunch) /* MacOS is passing command line args. */ + if (!gFinderLaunch) return FALSE; - if (gCalledAppMainline) /* app has started, ignore this document. */ + if (gCalledAppMainline) return FALSE; temparg = [filename UTF8String]; @@ -280,7 +281,24 @@ static void CustomApplicationMain (int argc, char **argv) gArgv[gArgc++] = "open"; gArgv[gArgc++] = arg; gArgv[gArgc] = NULL; - return TRUE; + return TRUE;*/ + const char * tempArg; + char * arg; + size_t argLen; + tempArg = [filename UTF8String]; + argLen = SDL_strlen(tempArg)+1; + arg = (char *) SDL_malloc(argLen); + if (arg == NULL) + return FALSE; + SDL_strlcpy(arg, tempArg, argLen); + + saveDataOpen = file_load(arg, &saveDataOpenSize); + if(saveDataOpen) + return TRUE; + + saveDataOpen = NULL; + saveDataOpenSize = 0; + return FALSE; } - (void)handleGetURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent diff --git a/src/interface.c b/src/interface.c index 6ee597467..689ef13eb 100644 --- a/src/interface.c +++ b/src/interface.c @@ -820,7 +820,7 @@ void draw_svf_ui(pixel *vid_buf, int alternate)// all the buttons at the bottom } // the reload button - c = (svf_open || svf_fileopen) ? 255 : 128; + c = (svf_last) ? 255 : 128; drawtext(vid_buf, 23, YRES+(MENUSIZE-14), "\x91", c, c, c, 255); drawrect(vid_buf, 19, YRES+(MENUSIZE-16), 16, 14, c, c, c, 255); diff --git a/src/main.c b/src/main.c index a21f11a1a..a7da674b6 100644 --- a/src/main.c +++ b/src/main.c @@ -203,6 +203,8 @@ char new_message_msg[255]; float mheat = 0.0f; int saveURIOpen = 0; +char * saveDataOpen = NULL; +int saveDataOpenSize = 0; int do_open = 0; int sys_pause = 0; @@ -830,6 +832,11 @@ int main(int argc, char *argv[]) argc = i+2; break; } + else if (!strncmp(argv[i], "open", 5) && i+1=19 && x<=35 && svf_last && (svf_open || svf_fileopen) && !bq) { + if (x>=19 && x<=35 && svf_last && !bq) { //int tpval = sys_pause; parse_save(svf_last, svf_lsize, 1, 0, 0, bmap, vx, vy, pv, fvx, fvy, signs, parts, pmap); //sys_pause = tpval;