mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-19 16:00:56 +00:00
Hack a simple way to specify the CFGDIR at command line.
Until now CFGDIR was hardcoded to YamagiQ2 on Windows and .yq2 on everything else. Sometimes it's desireable to have a separate dir for some tasks, for example whentesting things that introduce new cvars. Add -cfgdir to override CFGDIR.
This commit is contained in:
parent
fd1874ff0f
commit
b2f0430c9f
5 changed files with 46 additions and 2 deletions
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <libgen.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -88,6 +89,22 @@ main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Inject a custom config dir.
|
||||
if (strcmp(argv[i], "-cfgdir") == 0)
|
||||
{
|
||||
// We need an argument.
|
||||
if (i != (argc - 1))
|
||||
{
|
||||
Q_strlcpy(cfgdir, argv[i + 1], sizeof(cfgdir));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("-cfgdir needs an argument\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Prevent running Quake II as root. Only very mad
|
||||
|
|
|
@ -50,6 +50,9 @@ static void *game_library;
|
|||
// Evil hack to determine if stdin is available
|
||||
qboolean stdin_active = true;
|
||||
|
||||
// Config dir
|
||||
char cfgdir[MAX_OSPATH] = CFGDIR;
|
||||
|
||||
// Console logfile
|
||||
extern FILE *logfile;
|
||||
|
||||
|
@ -476,7 +479,7 @@ Sys_GetHomeDir(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
snprintf(gdir, sizeof(gdir), "%s/%s/", home, CFGDIR);
|
||||
snprintf(gdir, sizeof(gdir), "%s/%s/", home, cfgdir);
|
||||
|
||||
return gdir;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,25 @@ main(int argc, char **argv)
|
|||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Inject a custom config dir.
|
||||
if (strcmp(argv[i], "-cfgdir") == 0)
|
||||
{
|
||||
// We need an argument.
|
||||
if (i != (argc - 1))
|
||||
{
|
||||
WCHAR wpath[MAX_OSPATH];
|
||||
|
||||
MultiByteToWideChar(CP_UTF8, 0, argv[i + 1], -1, wpath, MAX_OSPATH);
|
||||
Q_strlcpy(cfgdir, wpath, sizeof(cfgdir));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("-cfgdir needs an argument\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Need to redirect stdout before anything happens.
|
||||
|
|
|
@ -195,6 +195,8 @@ static qboolean checkForHelp(int argc, char **argv)
|
|||
printf("Yamagi Quake II v%s\n", YQ2VERSION);
|
||||
printf("Most interesting commandline arguments:\n");
|
||||
printf("-h or --help: Show this help\n");
|
||||
printf("-cfgdir <path>\n");
|
||||
printf(" set the name of your config directory\n");
|
||||
printf("-datadir <path>\n");
|
||||
printf(" set path to your Quake2 game data (the directory baseq2/ is in)\n");
|
||||
printf("-portable\n");
|
||||
|
|
|
@ -746,9 +746,12 @@ extern cvar_t *sv_entfile;
|
|||
/* Hack for portable client */
|
||||
extern qboolean is_portable;
|
||||
|
||||
/* Hack fo external datadir */
|
||||
/* Hack for external datadir */
|
||||
extern char datadir[MAX_OSPATH];
|
||||
|
||||
/* Hack for external datadir */
|
||||
extern char cfgdir[MAX_OSPATH];
|
||||
|
||||
/* Hack for working 'game' cmd */
|
||||
extern char userGivenGame[MAX_QPATH];
|
||||
|
||||
|
|
Loading…
Reference in a new issue