a fix for the fteqccgui issue that was annoying shpuld

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5244 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2018-04-16 21:46:10 +00:00
parent 08ca60d1bf
commit 8df89fc186
3 changed files with 48 additions and 27 deletions

View File

@ -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, ...);

View File

@ -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')

View File

@ -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
{