more SYSCF and related bits - cleanup and features
infrastructure for "system options" - things currently specified at build time that should be changeable at install time or run time but not really under user control generalize contact info so it can be localized and it doesn't have to be an email address move recently introduced WIZARDS into sysopt drop bogus OPTIONS=wizards possibility new function build_english_list() to comma-ize and add 'or' from a whitespace separated list: A. A or B. A, B, or C. syscf file now handles: WIZARDS SUPPORT RECOVER SUPPORT specifies local support information RECOVER will eventually supply port-specific and/or localized info on how to run recover (or get it run for you). Note: in sys/msdos I changed sys.o (generated from pcsys.c) to pcsys.o Note: sys/msdos/Makefile.GCC has 2 rules for sys.o (now pcsys.o)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)decl.c 3.5 2006/07/10 */
|
||||
/* SCCS Id: @(#)decl.c 3.5 2008/01/30 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -70,9 +70,6 @@ const char ynNaqchars[] = "yn#aq";
|
||||
NEARDATA long yn_number = 0L;
|
||||
|
||||
const char disclosure_options[] = "iavgc";
|
||||
#ifdef SYSCF
|
||||
char wizards[PL_PSIZ] = DUMMY;
|
||||
#endif
|
||||
|
||||
#if defined(MICRO) || defined(WIN32)
|
||||
char hackdir[PATHLEN]; /* where rumors, help, record are */
|
||||
|
||||
87
src/end.c
87
src/end.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)end.c 3.5 2008/01/19 */
|
||||
/* SCCS Id: @(#)end.c 3.5 2008/01/30 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#ifndef NO_SIGNAL
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include "dlb.h"
|
||||
|
||||
@@ -255,7 +256,7 @@ int how;
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
#if defined(WIN32) && !defined(SYSCF)
|
||||
#define NOTIFY_NETHACK_BUGS
|
||||
#endif
|
||||
|
||||
@@ -283,13 +284,24 @@ panic VA_DECL(const char *, str)
|
||||
#if defined(WIZARD) && !defined(MICRO)
|
||||
# if defined(NOTIFY_NETHACK_BUGS)
|
||||
if (!wizard)
|
||||
raw_printf("Report the following error to \"%s\".",
|
||||
"nethack-bugs@nethack.org");
|
||||
raw_printf("Report the following error to \"%s\" or at \"%s\".",
|
||||
DEVTEAM_EMAIL, DEVTEAM_URL);
|
||||
else if (program_state.something_worth_saving)
|
||||
raw_print("\nError save file being written.\n");
|
||||
# else
|
||||
if (!wizard)
|
||||
raw_printf("Report error to \"%s\"%s.",
|
||||
if (!wizard){
|
||||
if(sysopt.support)
|
||||
raw_printf("To report this error, %s%s.", sysopt.support,
|
||||
!program_state.something_worth_saving ? "" :
|
||||
" and it may be possible to rebuild.");
|
||||
else if(sysopt.wizards){
|
||||
char *tmp = build_english_list(sysopt.wizards);
|
||||
raw_printf("To report this error, contact %s%s", tmp,
|
||||
!program_state.something_worth_saving ? "" :
|
||||
" and it may be possible to rebuild.");
|
||||
free(tmp);
|
||||
} else
|
||||
raw_printf("Report error to \"%s\"%s.",
|
||||
# ifdef WIZARD_NAME /*(KR1ED)*/
|
||||
WIZARD_NAME,
|
||||
# else
|
||||
@@ -297,10 +309,17 @@ panic VA_DECL(const char *, str)
|
||||
# endif
|
||||
!program_state.something_worth_saving ? "" :
|
||||
" and it may be possible to rebuild.");
|
||||
}
|
||||
# endif
|
||||
/* XXX can we move this above the prints? Then we'd be able to
|
||||
* suppress "it may be possible to rebuild" based on dosave0()
|
||||
* or say it's NOT possible to rebuild. */
|
||||
if (program_state.something_worth_saving) {
|
||||
set_error_savefile();
|
||||
(void) dosave0();
|
||||
if(dosave0()){
|
||||
/* os/win port specific recover instructions */
|
||||
if(sysopt.recover) raw_printf("%s", sysopt.recover);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
{
|
||||
@@ -1293,4 +1312,58 @@ restore_killers(fd)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
wordcount(p)
|
||||
char *p;
|
||||
{
|
||||
int words = 0;
|
||||
while(*p){
|
||||
while(*p && isspace(*p))p++;
|
||||
if(*p) words++;
|
||||
while(*p && !isspace(*p))p++;
|
||||
}
|
||||
return words;
|
||||
}
|
||||
|
||||
static void
|
||||
bel_copy1(inp, out)
|
||||
char **inp, *out;
|
||||
{
|
||||
char *in = *inp;
|
||||
while(*in && isspace(*in)) in++;
|
||||
while(*in && !isspace(*in)){
|
||||
*out = *in; out++; in++;
|
||||
}
|
||||
*inp = in;
|
||||
}
|
||||
|
||||
char *
|
||||
build_english_list(in)
|
||||
char *in;
|
||||
{
|
||||
char *out;
|
||||
int len = strlen(in);
|
||||
char *p = in;
|
||||
int words = wordcount(in);
|
||||
switch(words){
|
||||
case 0:
|
||||
impossible("no words in list");
|
||||
break;
|
||||
case 1:
|
||||
out = (char *)alloc(len+1);
|
||||
strcpy(out, in);
|
||||
break;
|
||||
default:
|
||||
len += 3 + (words-1);
|
||||
bel_copy1(&p, out); words--;
|
||||
while(words>1){
|
||||
strcat(out, ", ");
|
||||
bel_copy1(&p, out); words--;
|
||||
}
|
||||
strcat(out, " or ");
|
||||
bel_copy1(&p, out);
|
||||
break;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
/*end.c*/
|
||||
|
||||
15
src/files.c
15
src/files.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)files.c 3.5 2007/10/27 */
|
||||
/* SCCS Id: @(#)files.c 3.5 2008/01/30 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -2067,9 +2067,18 @@ int src;
|
||||
(void) strncpy(catname, bufp, PL_PSIZ-1);
|
||||
#ifdef SYSCF
|
||||
} else if ( (src==SET_IN_SYS) && match_varname(buf, "WIZARDS", 6)) {
|
||||
(void) strncpy(wizards, bufp, PL_PSIZ-1);
|
||||
if(sysopt.wizards) free(sysopt.wizards);
|
||||
sysopt.wizards = alloc(strlen(bufp));
|
||||
(void) strcpy(sysopt.wizards, bufp);
|
||||
} else if ( (src==SET_IN_SYS) && match_varname(buf, "SUPPORT", 7)) {
|
||||
if(sysopt.support) free(sysopt.support);
|
||||
sysopt.support = alloc(strlen(bufp));
|
||||
(void) strcpy(sysopt.support, bufp);
|
||||
} else if ( (src==SET_IN_SYS) && match_varname(buf, "RECOVER", 7)) {
|
||||
if(sysopt.recover) free(sysopt.recover);
|
||||
sysopt.recover = alloc(strlen(bufp));
|
||||
(void) strcpy(sysopt.recover, bufp);
|
||||
#endif
|
||||
|
||||
} else if (match_varname(buf, "BOULDER", 3)) {
|
||||
(void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE,
|
||||
1, "BOULDER");
|
||||
|
||||
13
src/mail.c
13
src/mail.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)mail.c 3.5 2006/12/13 */
|
||||
/* SCCS Id: @(#)mail.c 3.5 2008/01/30 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -428,21 +428,28 @@ readmail(otmp)
|
||||
struct obj *otmp;
|
||||
{
|
||||
static char *junk[] = {
|
||||
NULL, /* placeholder for "Report bugs to <devteam@nethack.org>.", */
|
||||
"Please disregard previous letter.",
|
||||
"Welcome to NetHack.",
|
||||
#ifdef AMIGA
|
||||
"Only Amiga makes it possible.",
|
||||
"CATS have all the answers.",
|
||||
#endif
|
||||
"Report bugs to <devteam@nethack.org>.",
|
||||
"Invitation: Visit the NetHack web site at http://www.nethack.org!"
|
||||
};
|
||||
|
||||
/* XXX replace with more general substitution code and add local
|
||||
* contact message. Also use DEVTEAM_URL */
|
||||
if(junk[0]) == NULL){
|
||||
#define BUGS_FORMAT "Report bugs to %s."
|
||||
junk[0] = (char *)alloc(strlen(BUGS_FORMAT) + strlen(DEVTEAM_EMAIL));
|
||||
sprintf(junk[0], DEVTEAM_EMAIL);
|
||||
#undef BUGS_FORMAT
|
||||
}
|
||||
if (Blind) {
|
||||
pline("Unfortunately you cannot see what it says.");
|
||||
} else
|
||||
pline("It reads: \"%s\"", junk[rn2(SIZE(junk))]);
|
||||
|
||||
}
|
||||
|
||||
# endif /* !UNIX && !VMS */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)options.c 3.5 2007/04/26 */
|
||||
/* SCCS Id: @(#)options.c 3.5 2008/01/30 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -386,9 +386,6 @@ static struct Comp_Opt
|
||||
{ "windowcolors", "the foreground/background colors of windows", /*WC*/
|
||||
80, DISP_IN_GAME },
|
||||
{ "windowtype", "windowing system to use", WINTYPELEN, DISP_IN_GAME },
|
||||
#ifdef SYSCF
|
||||
{ "wizards", "users with access to wizard mode (etc)", PL_PSIZ, SET_IN_SYS},
|
||||
#endif
|
||||
#ifdef BACKWARD_COMPAT
|
||||
{"DECgraphics", "load DECGraphics display symbols", 70, SET_IN_FILE},
|
||||
{"IBMgraphics", "load IBMGraphics display symbols", 70, SET_IN_FILE},
|
||||
@@ -2263,23 +2260,6 @@ goodfruit:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SYSCF
|
||||
fullname = "wizards";
|
||||
if (wizard && match_optname(opts, fullname, 6, TRUE)) {
|
||||
if (duplicate) {
|
||||
complain_about_duplicate(opts,1);
|
||||
return;
|
||||
}
|
||||
if (negated) {
|
||||
bad_negation(fullname, FALSE);
|
||||
return;
|
||||
} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
|
||||
nmcpy(wizards, op, PL_PSIZ);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* menustyle:traditional or combo or full or partial */
|
||||
if (match_optname(opts, "menustyle", 4, TRUE)) {
|
||||
int tmp;
|
||||
@@ -3489,14 +3469,6 @@ char *buf;
|
||||
#endif
|
||||
else if (!strcmp(optname, "catname"))
|
||||
Sprintf(buf, "%s", catname[0] ? catname : none );
|
||||
#ifdef SYSCF
|
||||
else if (!strcmp(optname, "wizards"))
|
||||
# ifdef KR1ED
|
||||
Sprintf(buf, "%s", wizards[0] ? wizards : WIZARD_NAME);
|
||||
# else
|
||||
Sprintf(buf, "%s", wizards[0] ? wizards : WIZARD);
|
||||
# endif
|
||||
#endif
|
||||
else if (!strcmp(optname, "disclose")) {
|
||||
for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) {
|
||||
char topt[2];
|
||||
|
||||
48
src/pager.c
48
src/pager.c
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)pager.c 3.5 2007/05/11 */
|
||||
/* SCCS Id: @(#)pager.c 3.5 2008/01/30 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -873,6 +873,36 @@ dowhatdoes()
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
docontact()
|
||||
{
|
||||
winid cwin = create_nhwindow(NHW_TEXT);
|
||||
char buf[BUFSZ];
|
||||
if(sysopt.support){
|
||||
/*XXX overflow possibilities*/
|
||||
Sprintf(buf, "To contact local support, %s", sysopt.support);
|
||||
putstr(cwin, 0, buf);
|
||||
putstr(cwin, 0, "");
|
||||
} else if(sysopt.wizards){
|
||||
char *tmp = build_english_list(sysopt.wizards);
|
||||
Sprintf(buf, "To contact local support, %s", tmp);
|
||||
free(tmp);
|
||||
putstr(cwin, 0, buf);
|
||||
putstr(cwin, 0, "");
|
||||
}
|
||||
putstr(cwin, 0, "To contact the NetHack development team directly,");
|
||||
/*XXX overflow possibilities*/
|
||||
Sprintf(buf, " see the Contact form on our website or email %s",
|
||||
DEVTEAM_EMAIL);
|
||||
putstr(cwin, 0, buf);
|
||||
putstr(cwin, 0, "");
|
||||
putstr(cwin, 0, "For more information on NetHack, or to report a bug,");
|
||||
Sprintf(buf, "visit our website %s", DEVTEAM_URL);
|
||||
putstr(cwin, 0, buf);
|
||||
display_nhwindow(cwin, FALSE);
|
||||
destroy_nhwindow(cwin);
|
||||
}
|
||||
|
||||
/* data for help_menu() */
|
||||
static const char *help_menu_items[] = {
|
||||
/* 0*/ "Long description of the game and commands.",
|
||||
@@ -884,12 +914,13 @@ static const char *help_menu_items[] = {
|
||||
/* 6*/ "Longer explanation of game options.",
|
||||
/* 7*/ "List of extended commands.",
|
||||
/* 8*/ "The NetHack license.",
|
||||
/* 9*/ "Support information.",
|
||||
#ifdef PORT_HELP
|
||||
"%s-specific help and commands.",
|
||||
#define PORT_HELP_ID 100
|
||||
#define WIZHLP_SLOT 10
|
||||
#define WIZHLP_SLOT 11
|
||||
#else
|
||||
#define WIZHLP_SLOT 9
|
||||
#define WIZHLP_SLOT 10
|
||||
#endif
|
||||
#ifdef WIZARD
|
||||
"List of wizard-mode commands.",
|
||||
@@ -958,13 +989,16 @@ dohelp()
|
||||
case 6: display_file(OPTIONFILE, TRUE); break;
|
||||
case 7: (void) doextlist(); break;
|
||||
case 8: display_file(LICENSE, TRUE); break;
|
||||
#ifdef WIZARD
|
||||
/* handle slot 9 or 10 */
|
||||
default: display_file(DEBUGHELP, TRUE); break;
|
||||
#endif
|
||||
case 9: (void) docontact(); break;
|
||||
#ifdef PORT_HELP
|
||||
case PORT_HELP_ID: port_help(); break;
|
||||
#endif
|
||||
default:
|
||||
#ifdef WIZARD
|
||||
/* handle slot 10 or 11 */
|
||||
display_file(DEBUGHELP, TRUE);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
18
src/sys.c
Normal file
18
src/sys.c
Normal file
@@ -0,0 +1,18 @@
|
||||
/* SCCS Id: @(#)sys.c 3.5 2008/01/30 */
|
||||
/* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
#include "hack.h"
|
||||
|
||||
struct sysopt sysopt;
|
||||
|
||||
void
|
||||
sys_early_init(){
|
||||
sysopt.support = NULL;
|
||||
sysopt.recover = NULL;
|
||||
#ifdef notyet
|
||||
/* replace use of WIZARD vs WIZARD_NAME vs KR1ED, by filling this in */
|
||||
#endif
|
||||
sysopt.wizards = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user