diff --git a/engine/qclib/gui.h b/engine/qclib/gui.h index c3ea15a17..8c7b329b9 100644 --- a/engine/qclib/gui.h +++ b/engine/qclib/gui.h @@ -13,7 +13,7 @@ void GUI_DialogPrint(char *title, char *text); void *GUIReadFile(const char *fname, unsigned char *(*buf_get)(void *ctx, size_t len), void *buf_ctx, size_t *out_size); int GUIFileSize(const char *fname); -int GUI_ParseCommandLine(char *args); //0=gui, 1=commandline +int GUI_ParseCommandLine(char *args, pbool keepsrcanddir); //0=gui, 1=commandline void GUI_SaveConfig(void); void GUI_RevealOptions(void); int GUIprintf(const char *msg, ...); diff --git a/engine/qclib/qccgui.c b/engine/qclib/qccgui.c index 6c300f976..3538245fa 100644 --- a/engine/qclib/qccgui.c +++ b/engine/qclib/qccgui.c @@ -6994,7 +6994,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin strcpy(enginecommandline, ""); GUI_SetDefaultOpts(); - mode = GUI_ParseCommandLine(lpCmdLine); + mode = GUI_ParseCommandLine(lpCmdLine, false); if(mode == 1) { @@ -7140,15 +7140,14 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin { *s = '\0'; strcpy(progssrcname, s+1); + SetCurrentDirectory(progssrcdir); } - - SetCurrentDirectory(progssrcdir); *progssrcdir = '\0'; } //reset project/directory options GUI_SetDefaultOpts(); - GUI_ParseCommandLine(lpCmdLine); + GUI_ParseCommandLine(lpCmdLine, true); GUI_RevealOptions(); //if the project is a .dat or .zip then decompile it now (so we can access the 'source') diff --git a/engine/qclib/qccguistuff.c b/engine/qclib/qccguistuff.c index 048e1ffd5..c18341374 100644 --- a/engine/qclib/qccguistuff.c +++ b/engine/qclib/qccguistuff.c @@ -443,7 +443,7 @@ void GUI_LoadConfig(void) //this function takes the windows specified commandline and strips out all the options menu items. -int GUI_ParseCommandLine(char *args) +int GUI_ParseCommandLine(char *args, pbool keepsrcanddir) { int paramlen=0; int l, p; @@ -494,24 +494,30 @@ int GUI_ParseCommandLine(char *args) args++; break; } - progssrcname[l++] = *args++; + if (!keepsrcanddir) + progssrcname[l++] = *args; + args++; } - progssrcname[l] = 0; + if (!keepsrcanddir) + progssrcname[l] = 0; next = args; - args = strrchr(progssrcname, '\\'); - while(args && strchr(args, '/')) - args = strchr(args, '/'); - if (args) + if (!keepsrcanddir) { - memcpy(progssrcdir, progssrcname, args-progssrcname); - progssrcdir[args-progssrcname] = 0; - args++; - memmove(progssrcname, args, strlen(args)+1); + args = strrchr(progssrcname, '\\'); + while(args && strchr(args, '/')) + args = strchr(args, '/'); + if (args) + { + memcpy(progssrcdir, progssrcname, args-progssrcname); + progssrcdir[args-progssrcname] = 0; + args++; + memmove(progssrcname, args, strlen(args)+1); - SetCurrentDirectoryA(progssrcdir); - *progssrcdir = 0; + SetCurrentDirectoryA(progssrcdir); + *progssrcdir = 0; + } } args = next; } @@ -687,20 +693,36 @@ int GUI_ParseCommandLine(char *args) while (*next == ' ') next++; - l = 0; - while (*next != ' ' && *next) - progssrcname[l++] = *next++; - progssrcname[l] = 0; + if (keepsrcanddir) + { //ignore it + while (*next != ' ' && *next) + next++; + } + else + { + l = 0; + while (*next != ' ' && *next) + progssrcname[l++] = *next++; + progssrcname[l] = 0; + } } else if (!strnicmp(parameters+paramlen, "-src ", 5) || !strnicmp(parameters+paramlen, "/src ", 5)) { while (*next == ' ') next++; - - l = 0; - while (*next != ' ' && *next) - progssrcdir[l++] = *next++; - progssrcdir[l] = 0; + + if (keepsrcanddir) + { //ignore it + while (*next != ' ' && *next) + next++; + } + else + { + l = 0; + while (*next != ' ' && *next) + progssrcdir[l++] = *next++; + progssrcdir[l] = 0; + } } else if (!strnicmp(parameters+paramlen, "-T", 2) || !strnicmp(parameters+paramlen, "/T", 2)) //the target {