add command line option --showpaths
Add
--showpaths
early option to show where NetHack is expecting to find certain files
without starting up a game. It exits afterwards.
Windows sample (for illustration only, locations may differ for you):
Variable playground locations:
[hackdir ]="C:\Users\JohnDoe\NetHack\3.6\"
[leveldir ]="C:\Users\JohnDoe\AppData\Local\NetHack\3.6\"
[savedir ]="C:\Users\JohnDoe\AppData\Local\NetHack\3.6\"
[bonesdir ]="C:\ProgramData\NetHack\3.6\"
[datadir ]="C:\personal\nhdev\363\test\binary\"
[scoredir ]="C:\ProgramData\NetHack\3.6\"
[lockdir ]="C:\ProgramData\NetHack\3.6\"
[sysconfdir]="C:\ProgramData\NetHack\3.6\"
[configdir ]="C:\Users\JohnDoe\NetHack\3.6\"
[troubledir]="C:\Users\JohnDoe\NetHack\3.6\"
Your system configuration file (in sysconfdir):
"C:\Users\JohnDoe\NetHack\3.6\sysconf"
Your system symbols file (in sysconfdir):
"C:\Users\JohnDoe\NetHack\3.6\symbols"
Your personal configuration file (in configdir):
"C:\Users\JohnDoe\NetHack\3.6\.nethackrc"
Linux (for illustration only, locations may differ for you):
Your system configuration file:
"/home/johndoe/nh/install/games/lib/nethackdir/sysconf"
Your system symbols file:
"/home/johndoe/nh/install/games/lib/nethackdir/symbols"
Your personal configuration file:
"/home/johndoe/.nethackrc"
This commit is contained in:
@@ -47,6 +47,9 @@ nethack \- Exploring The Mazes of Menace
|
||||
.B \-ibm
|
||||
]
|
||||
[
|
||||
.BR \-\-showpaths
|
||||
]
|
||||
[
|
||||
.BR \-\-version [ :paste ]
|
||||
]
|
||||
.PP
|
||||
@@ -223,6 +226,10 @@ the list of top scorers, and a subdirectory
|
||||
.I save
|
||||
where games are saved.
|
||||
.PP
|
||||
.B \-\-showpaths
|
||||
can be used to cause NetHack to show where it is expecting
|
||||
to find various configuration files.
|
||||
.PP
|
||||
.B \-\-version
|
||||
can be used to cause NetHack to show the version information it
|
||||
was compiled with, then exit. That will include the
|
||||
|
||||
@@ -447,7 +447,7 @@ struct breadcrumbs {
|
||||
E const char *ARGV0;
|
||||
#endif
|
||||
|
||||
enum earlyarg {ARG_DEBUG, ARG_VERSION
|
||||
enum earlyarg {ARG_DEBUG, ARG_VERSION, ARG_SHOWPATHS
|
||||
#ifdef WIN32
|
||||
,ARG_WINDOWS
|
||||
#endif
|
||||
|
||||
@@ -846,6 +846,7 @@ E void NDECL(really_close);
|
||||
#ifdef DEBUG
|
||||
E boolean FDECL(debugcore, (const char *, BOOLEAN_P));
|
||||
#endif
|
||||
E void NDECL(reveal_paths);
|
||||
E boolean FDECL(read_tribute, (const char *, const char *, int,
|
||||
char *, int, unsigned));
|
||||
E boolean FDECL(Death_quote, (char *, int));
|
||||
|
||||
@@ -767,6 +767,7 @@ const char *msg;
|
||||
static struct early_opt earlyopts[] = {
|
||||
{ARG_DEBUG, "debug", 5, TRUE},
|
||||
{ARG_VERSION, "version", 4, TRUE},
|
||||
{ARG_SHOWPATHS, "showpaths", 9, FALSE},
|
||||
#ifdef WIN32
|
||||
{ARG_WINDOWS, "windows", 4, TRUE},
|
||||
#endif
|
||||
@@ -845,6 +846,9 @@ enum earlyarg e_arg;
|
||||
early_version_info(insert_into_pastebuf);
|
||||
return 2;
|
||||
}
|
||||
case ARG_SHOWPATHS: {
|
||||
return 2;
|
||||
}
|
||||
#ifdef WIN32
|
||||
case ARG_WINDOWS: {
|
||||
if (extended_opt) {
|
||||
|
||||
100
src/files.c
100
src/files.c
@@ -3197,7 +3197,13 @@ fopen_sym_file()
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
fp = fopen_datafile(SYMBOLS, "r", HACKPREFIX);
|
||||
fp = fopen_datafile(SYMBOLS, "r",
|
||||
#ifdef WIN32
|
||||
SYSCONFPREFIX
|
||||
#else
|
||||
HACKPREFIX
|
||||
#endif
|
||||
);
|
||||
|
||||
return fp;
|
||||
}
|
||||
@@ -3966,6 +3972,98 @@ boolean wildcards;
|
||||
|
||||
#endif /*DEBUG*/
|
||||
|
||||
void
|
||||
reveal_paths(VOID_ARGS)
|
||||
{
|
||||
int i;
|
||||
#define PATHBUFSZ 1024
|
||||
char buf[PATHBUFSZ];
|
||||
#ifdef UNIX
|
||||
char *envp, *slash, nhpath[PATHBUFSZ];
|
||||
#endif
|
||||
|
||||
/* write out path details */
|
||||
#ifdef PREFIXES_IN_USE
|
||||
raw_print("Variable playground locations:");
|
||||
for (i = 0; i < PREFIX_COUNT; i++)
|
||||
raw_printf(" [%-10s]=\"%s\"", fqn_prefix_names[i],
|
||||
fqn_prefix[i]
|
||||
? fqn_prefix[i]
|
||||
: "not set");
|
||||
#endif
|
||||
/* sysconf file */
|
||||
#ifdef PREFIXES_IN_USE
|
||||
Sprintf(buf, " (in %s)",
|
||||
fqn_prefix_names[SYSCONFPREFIX]);
|
||||
#else
|
||||
buf[0] = '\0';
|
||||
#endif
|
||||
raw_printf("Your system configuration file%s:", buf);
|
||||
set_configfile_name(fqname(SYSCF_FILE, SYSCONFPREFIX, 0));
|
||||
raw_printf(" \"%s\"", configfile);
|
||||
#ifdef UNIX
|
||||
Strcpy(nhpath, configfile);
|
||||
slash = rindex(nhpath, '/');
|
||||
if (slash)
|
||||
*slash = '\0';
|
||||
#endif
|
||||
|
||||
/* symbols file */
|
||||
#ifdef PREFIXES_IN_USE
|
||||
Sprintf(buf, " (in %s)",
|
||||
#ifdef WIN32
|
||||
fqn_prefix_names[SYSCONFPREFIX]);
|
||||
#else
|
||||
fqn_prefix_names[HACKPREFIX]);
|
||||
#endif /* WIN32 */
|
||||
#else /* PREFIXES_IN_USE */
|
||||
buf[0] = '\0';
|
||||
#endif
|
||||
|
||||
raw_printf("Your system symbols file%s:", buf);
|
||||
#ifdef UNIX
|
||||
Sprintf(buf, "%s/%s", nhpath, SYMBOLS);
|
||||
#else
|
||||
#ifdef PREFIXES_IN_USE
|
||||
Sprintf(buf, "%s",
|
||||
fqname(SYMBOLS,
|
||||
#ifdef WIN32
|
||||
SYSCONFPREFIX, 2));
|
||||
#else
|
||||
HACKPREFIX, 2));
|
||||
#endif
|
||||
#endif /* PREFIXES_IN_USE */
|
||||
#endif /* UNIX */
|
||||
raw_printf(" \"%s\"", buf);
|
||||
|
||||
/* configuration file */
|
||||
#ifdef PREFIXES_IN_USE
|
||||
Sprintf(buf, " (in %s)",
|
||||
fqn_prefix_names[CONFIGPREFIX]);
|
||||
#else /* PREFIXES_IN_USE */
|
||||
buf[0] = '\0';
|
||||
#endif
|
||||
raw_printf("Your personal configuration file%s:", buf);
|
||||
#ifdef UNIX
|
||||
envp = nh_getenv("HOME");
|
||||
if (!envp)
|
||||
Strcpy(nhpath, ".nethackrc");
|
||||
else
|
||||
Sprintf(nhpath, "%s/%s", envp, default_configfile);
|
||||
#endif
|
||||
raw_printf(" \"%s\"",
|
||||
#ifdef UNIX
|
||||
nhpath);
|
||||
#else
|
||||
#ifdef PREFIXES_IN_USE
|
||||
fqname(default_configfile, CONFIGPREFIX, 3));
|
||||
#else
|
||||
default_configfile);
|
||||
#endif /* PREFIXES_IN_USE */
|
||||
#endif /* UNIX */
|
||||
raw_print("");
|
||||
}
|
||||
|
||||
/* ---------- BEGIN TRIBUTE ----------- */
|
||||
|
||||
/* 3.6 tribute code
|
||||
|
||||
@@ -114,11 +114,15 @@ char *argv[];
|
||||
if (argcheck(argc, argv, ARG_VERSION) == 2)
|
||||
exit(EXIT_SUCCESS);
|
||||
|
||||
if (argcheck(argc, argv, ARG_SHOWPATHS) == 2) {
|
||||
initoptions();
|
||||
reveal_paths();
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
if (argcheck(argc, argv, ARG_DEBUG) == 1) {
|
||||
argc--;
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (argc > 1 && !strncmp(argv[1], "-d", 2) && argv[1][2] != 'e') {
|
||||
/* avoid matching "-dec" for DECgraphics; since the man page
|
||||
* says -d directory, hope nobody's using -desomething_else
|
||||
|
||||
@@ -580,6 +580,11 @@ char *argv[];
|
||||
if (argcheck(argc, argv, ARG_VERSION) == 2)
|
||||
nethack_exit(EXIT_SUCCESS);
|
||||
|
||||
if (argcheck(argc, argv, ARG_SHOWPATHS) == 2) {
|
||||
initoptions();
|
||||
reveal_paths();
|
||||
nethack_exit(EXIT_SUCCESS);
|
||||
}
|
||||
if (argcheck(argc, argv, ARG_DEBUG) == 1) {
|
||||
argc--;
|
||||
argv++;
|
||||
|
||||
Reference in New Issue
Block a user