Merge branch 'NetHack-3.6.0'

This commit is contained in:
nhmall
2015-12-12 17:15:16 -05:00
14 changed files with 414 additions and 284 deletions

View File

@@ -9,6 +9,12 @@ update MAXPLAYERS documentation in sysconf file and allow 0 for it
wizard mode: don't include feedback about named fruit for ^X and enlightenment
looking at distant objects while wearing the Eyes of the Overworld made their
up-close descriptions known when not intended
message when cursed wand zapped by a monster happens to explode was suppressed
if hero was deaf, even though that message has no audible component
support explicit 'symset:default' and 'symset:Default symbols' in options
crash during startup if player name set as 'player' in defaults
any existing vampire shape-shifted into critter (fog cloud, bat, wolf) became
an unkillable critter if vampires were genocided
Platform- and/or Interface-Specific Fixes
@@ -25,6 +31,7 @@ X11: core bug for '`' (backtick) command was only noticed by X11 interface,
General New Features
--------------------
naming Sting or Orcrist now breaks illiterate conduct
Platform- and/or Interface-Specific New Features
@@ -37,4 +44,3 @@ NetHack Community Patches (or Variation) Included
Code Cleanup and Reorganization
-------------------------------

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do_name.c $NHDT-Date: 1446808440 2015/11/06 11:14:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.77 $ */
/* NetHack 3.6 do_name.c $NHDT-Date: 1449914085 2015/12/12 09:54:45 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.78 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -504,6 +504,16 @@ register struct obj *obj;
/* strip leading and trailing spaces; unnames item if all spaces */
(void) mungspaces(buf);
/*
* We don't violate illiteracy conduct here, although it is
* arguable that we should for anything other than "X". Doing so
* would make attaching player's notes to hero's inventory have an
* in-game effect, which may or may not be the correct thing to do.
*
* We do violate illiteracy in oname() if player creates Sting or
* Orcrist, clearly being literate (no pun intended...).
*/
/* relax restrictions over proper capitalization for artifacts */
if ((aname = artifact_name(buf, &objtyp)) != 0 && objtyp == obj->otyp)
Strcpy(buf, aname);
@@ -573,6 +583,8 @@ const char *name;
/* if obj is owned by a shop, increase your bill */
if (obj->unpaid)
alter_cost(obj, 0L);
/* violate illiteracy conduct since successfully wrote arti-name */
u.uconduct.literate++;
}
if (carried(obj))
update_inventory();

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 files.c $NHDT-Date: 1449296293 2015/12/05 06:18:13 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.192 $ */
/* NetHack 3.6 files.c $NHDT-Date: 1449830204 2015/12/11 10:36:44 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.194 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2139,8 +2139,6 @@ int src;
++bufp; /* skip '='; parseoptions() handles spaces */
parseoptions(bufp, TRUE, TRUE);
if (plname[0]) /* If a name was given */
plnamesuffix(); /* set the character class */
} else if (match_varname(buf, "AUTOPICKUP_EXCEPTION", 5)) {
add_autopickup_exception(bufp);
} else if (match_varname(buf, "MSGTYPE", 7)) {
@@ -2215,7 +2213,6 @@ int src;
} else if (match_varname(buf, "NAME", 4)) {
(void) strncpy(plname, bufp, PL_NSIZ - 1);
plnamesuffix();
} else if (match_varname(buf, "ROLE", 4)
|| match_varname(buf, "CHARACTER", 4)) {
if ((len = str2role(bufp)) >= 0)
@@ -2783,8 +2780,17 @@ int which_set;
}
}
(void) fclose(fp);
if (!chosen_symset_end && !chosen_symset_start)
if (!chosen_symset_start && !chosen_symset_end) {
/* name caller put in symset[which_set].name was not found;
if it looks like "Default symbols", null it out and return
success to use the default; otherwise, return failure */
if (symset[which_set].name
&& (fuzzymatch(symset[which_set].name, "Default symbols",
" -_", TRUE)
|| !strcmpi(symset[which_set].name, "default")))
clear_symsetentry(which_set, TRUE);
return (symset[which_set].name == 0) ? 1 : 0;
}
if (!chosen_symset_end) {
raw_printf("Missing finish for symset \"%s\"",
symset[which_set].name ? symset[which_set].name

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mon.c $NHDT-Date: 1449269918 2015/12/04 22:58:38 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.199 $ */
/* NetHack 3.6 mon.c $NHDT-Date: 1449908726 2015/12/12 08:25:26 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.200 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1741,7 +1741,8 @@ register struct monst *mtmp;
int x = mtmp->mx, y = mtmp->my;
/* this only happens if shapeshifted */
if (mndx >= LOW_PM && mndx != monsndx(mtmp->data)) {
if (mndx >= LOW_PM && mndx != monsndx(mtmp->data)
&& !(mvitals[mndx].mvflags & G_GENOD)) {
char buf[BUFSZ];
boolean in_door = (amorphous(mtmp->data)
&& closed_door(mtmp->mx, mtmp->my)),

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 muse.c $NHDT-Date: 1447987786 2015/11/20 02:49:46 $ $NHDT-Branch: master $:$NHDT-Revision: 1.68 $ */
/* NetHack 3.6 muse.c $NHDT-Date: 1449799863 2015/12/11 02:11:03 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.69 $ */
/* Copyright (C) 1990 by Ken Arromdee */
/* NetHack may be freely redistributed. See license for details. */
@@ -138,12 +138,19 @@ struct obj *obj;
&& !rn2(WAND_BACKFIRE_CHANCE)) {
int dam = d(obj->spe + 2, 6);
if (!Deaf) {
if (vis)
pline("%s zaps %s, which suddenly explodes!", Monnam(mon),
an(xname(obj)));
else
You_hear("a zap and an explosion in the distance.");
/* 3.6.1: no Deaf filter; 'if' message doesn't warrant it, 'else'
message doesn't need it since Your_hear() has one of its own */
if (vis) {
pline("%s zaps %s, which suddenly explodes!", Monnam(mon),
an(xname(obj)));
} else {
/* same near/far threshold as mzapmsg() */
int range = couldsee(mon->mx, mon->my) /* 9 or 5 */
? (BOLT_LIM + 1) : (BOLT_LIM - 3);
You_hear("a zap and an explosion %s.",
(distu(mon->mx, mon->my) <= range * range)
? "nearby" : "in the distance");
}
m_useup(mon, obj);
if (mon->mhp <= dam) {
@@ -164,11 +171,11 @@ struct obj *otmp;
boolean self;
{
if (!canseemon(mtmp)) {
if (!Deaf)
You_hear("a %s zap.", (distu(mtmp->mx, mtmp->my)
<= (BOLT_LIM + 1) * (BOLT_LIM + 1))
? "nearby"
: "distant");
int range = couldsee(mtmp->mx, mtmp->my) /* 9 or 5 */
? (BOLT_LIM + 1) : (BOLT_LIM - 3);
You_hear("a %s zap.", (distu(mtmp->mx, mtmp->my) <= range * range)
? "nearby" : "distant");
} else if (self) {
pline("%s zaps %sself with %s!", Monnam(mtmp), mhim(mtmp),
doname(otmp));

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1448241657 2015/11/23 01:20:57 $ $NHDT-Branch: master $:$NHDT-Revision: 1.243 $ */
/* NetHack 3.6 options.c $NHDT-Date: 1449830206 2015/12/11 10:36:46 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.244 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -2010,7 +2010,7 @@ boolean tinitial, tfrom_file;
op, SYMBOLS);
wait_synch();
} else {
switch_symbols(TRUE);
switch_symbols(symset[PRIMARY].name != (char *) 0);
need_redraw = TRUE;
}
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pcmain.c $NHDT-Date: 1449116336 2015/12/03 04:18:56 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.66 $ */
/* NetHack 3.6 pcmain.c $NHDT-Date: 1449893255 2015/12/12 04:07:35 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.67 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -55,8 +55,12 @@ extern void FDECL(nethack_exit, (int));
#ifdef WIN32
extern boolean getreturn_enabled; /* from sys/share/pcsys.c */
extern int redirect_stdout; /* from sys/share/pcsys.c */
extern int GUILaunched;
HANDLE hStdOut;
char *NDECL(exename);
char default_window_sys[] = "mswin";
boolean NDECL(fakeconsole);
void NDECL(freefakeconsole);
#endif
#if defined(MSWIN_GRAPHICS)
@@ -279,16 +283,30 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
Strcpy(hackdir, dir);
}
if (argc > 1) {
#if defined(WIN32)
int sfd = 0;
boolean tmpconsole = FALSE;
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
#endif
/*
* Now we know the directory containing 'record' and
* may do a prscore().
*/
if (!strncmp(argv[1], "-s", 2)) {
#if defined(WIN32)
int sfd = (int) _fileno(stdout);
#if 0
if (!hStdOut) {
tmpconsole = fakeconsole();
}
#endif
/*
* Check to see if we're redirecting to a file.
*/
sfd = (int) _fileno(stdout);
redirect_stdout = (sfd >= 0) ? !isatty(sfd) : 0;
if (!redirect_stdout) {
if (!redirect_stdout && !hStdOut) {
raw_printf(
"-s is not supported for the Graphical Interface\n");
nethack_exit(EXIT_SUCCESS);
@@ -302,6 +320,13 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
initoptions();
#endif
prscore(argc, argv);
#ifdef WIN32
if (tmpconsole) {
getreturn("to exit");
freefakeconsole();
tmpconsole = FALSE;
}
#endif
nethack_exit(EXIT_SUCCESS);
}
@@ -313,7 +338,21 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/
#endif
/* Don't initialize the window system just to print usage */
if (!strncmp(argv[1], "-?", 2) || !strncmp(argv[1], "/?", 2)) {
#if 0
if (!hStdOut) {
GUILaunched = 0;
tmpconsole = fakeconsole();
}
#endif
nhusage();
#ifdef WIN32
if (tmpconsole) {
getreturn("to exit");
freefakeconsole();
tmpconsole = FALSE;
}
#endif
nethack_exit(EXIT_SUCCESS);
}
}
@@ -804,6 +843,9 @@ authorize_wizard_mode()
#ifdef WIN32
static char exenamebuf[PATHLEN];
extern HANDLE hConIn;
extern HANDLE hConOut;
boolean has_fakeconsole;
char *
exename()
@@ -826,6 +868,42 @@ exename()
tmp2++;
return tmp2;
}
boolean
fakeconsole(void)
{
if (!hStdOut) {
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
if (!hStdOut && !hStdIn) {
/* Bool rval; */
AllocConsole();
AttachConsole(GetCurrentProcessId());
/* rval = SetStdHandle(STD_OUTPUT_HANDLE, hWrite); */
freopen("CON", "w", stdout);
freopen("CON", "r", stdin);
}
has_fakeconsole = TRUE;
}
/* Obtain handles for the standard Console I/O devices */
hConIn = GetStdHandle(STD_INPUT_HANDLE);
hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
#if 0
if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE)) {
/* Unable to set control handler */
cmode = 0; /* just to have a statement to break on for debugger */
}
#endif
return has_fakeconsole;
}
void freefakeconsole()
{
if (has_fakeconsole) {
FreeConsole();
}
}
#endif
#define EXEPATHBUFSZ 256

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 vmsfiles.c $NHDT-Date: 1432512790 2015/05/25 00:13:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
/* NetHack 3.6 vmsfiles.c $NHDT-Date: 1449801740 2015/12/11 02:42:20 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.10 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -29,7 +29,7 @@ int FDECL(c__translate, (int));
extern unsigned long sys$parse(), sys$search(), sys$enter(), sys$remove();
extern int VDECL(lib$match_cond, (int, int, ...));
#define vms_success(sts) ((sts) &1) /* odd, */
#define vms_success(sts) ((sts) & 1) /* odd, */
#define vms_failure(sts) (!vms_success(sts)) /* even */
/* vms_link() -- create an additional directory for an existing file */
@@ -208,30 +208,30 @@ const char *d1, *d2;
f2.fab$b_fns = strlen(f2.fab$l_fna = (char *) d2);
f1.fab$l_nam = (genericptr_t) &n1; /* link nam to fab */
f2.fab$l_nam = (genericptr_t) &n2;
n1.nam$b_nop = n2.nam$b_nop =
NAM$M_NOCONCEAL; /* want true device name */
/* want true device name */
n1.nam$b_nop = n2.nam$b_nop = NAM$M_NOCONCEAL;
return (
vms_success(sys$parse(&f1)) && vms_success(sys$parse(&f2))
&& n1.nam$t_dvi[0] == n2.nam$t_dvi[0]
&& !strncmp(&n1.nam$t_dvi[1], &n2.nam$t_dvi[1], n1.nam$t_dvi[0])
&& !memcmp((genericptr_t) n1.nam$w_did,
(genericptr_t) n2.nam$w_did,
sizeof n1.nam$w_did)); /*{ short nam$w_did[3]; }*/
return (vms_success(sys$parse(&f1)) && vms_success(sys$parse(&f2))
&& n1.nam$t_dvi[0] == n2.nam$t_dvi[0]
&& !strncmp(&n1.nam$t_dvi[1], &n2.nam$t_dvi[1],
n1.nam$t_dvi[0])
&& !memcmp((genericptr_t) n1.nam$w_did,
(genericptr_t) n2.nam$w_did,
sizeof n1.nam$w_did)); /*{ short nam$w_did[3]; }*/
}
}
/*
* c__translate -- substitute for VAXCRTL routine C$$TRANSLATE.
*
* Try to convert a VMS status code into its Unix equivalent,
* then set `errno' to that value; use EVMSERR if there's no
* appropriate translation; set `vaxc$errno' to the original
* status code regardless.
* Try to convert a VMS status code into its Unix equivalent,
* then set `errno' to that value; use EVMSERR if there's no
* appropriate translation; set `vaxc$errno' to the original
* status code regardless.
*
* These translations match only a subset of VAXCRTL's lookup
* table, but work even if the severity has been adjusted or
* the inhibit-message bit has been set.
* These translations match only a subset of VAXCRTL's lookup
* table, but work even if the severity has been adjusted or
* the inhibit-message bit has been set.
*/
#include <errno.h>
#include <ssdef.h>
@@ -251,37 +251,46 @@ int code;
{
register int trans;
/* clang-format off */
/* *INDENT-OFF* */
switch ((code & 0x0FFFFFF8) >> 3) { /* strip upper 4 and bottom 3 bits */
CASE2(RMS$_PRV, SS$_NOPRIV) : VALUE(EPERM); /* not owner */
CASE2(RMS$_DNF, RMS$_DIR)
: CASE2(RMS$_FNF, RMS$_FND)
: CASE1(SS$_NOSUCHFILE)
: VALUE(ENOENT); /* no such file or directory */
CASE2(RMS$_IFI, RMS$_ISI) : VALUE(EIO); /* i/o error */
CASE1(RMS$_DEV)
: CASE2(SS$_NOSUCHDEV, SS$_DEVNOTMOUNT)
: VALUE(ENXIO); /* no such device or address codes */
CASE1(RMS$_DME)
: /* CASE1(LIB$INSVIRMEM): */
CASE2(SS$_VASFULL, SS$_INSFWSL)
: VALUE(ENOMEM); /* not enough core */
CASE1(SS$_ACCVIO) : VALUE(EFAULT); /* bad address */
CASE2(RMS$_DNR, SS$_DEVASSIGN)
: CASE2(SS$_DEVALLOC, SS$_DEVALRALLOC)
: CASE2(SS$_DEVMOUNT, SS$_DEVACTIVE)
: VALUE(EBUSY); /* mount device busy codes to name a few */
CASE2(RMS$_FEX, SS$_FILALRACC) : VALUE(EEXIST); /* file exists */
CASE2(RMS$_IDR, SS$_BADIRECTORY)
: VALUE(ENOTDIR); /* not a directory */
CASE1(SS$_NOIOCHAN) : VALUE(EMFILE); /* too many open files */
CASE1(RMS$_FUL)
: CASE2(SS$_DEVICEFULL, SS$_EXDISKQUOTA)
: VALUE(ENOSPC); /* no space left on disk codes */
CASE2(RMS$_WLK, SS$_WRITLCK)
: VALUE(EROFS); /* read-only file system */
CASE2(RMS$_PRV, SS$_NOPRIV):
VALUE(EPERM); /* not owner */
CASE2(RMS$_DNF, RMS$_DIR):
CASE2(RMS$_FNF, RMS$_FND):
CASE1(SS$_NOSUCHFILE):
VALUE(ENOENT); /* no such file or directory */
CASE2(RMS$_IFI, RMS$_ISI):
VALUE(EIO); /* i/o error */
CASE1(RMS$_DEV):
CASE2(SS$_NOSUCHDEV, SS$_DEVNOTMOUNT):
VALUE(ENXIO); /* no such device or address codes */
CASE1(RMS$_DME):
/* CASE1(LIB$INSVIRMEM): */
CASE2(SS$_VASFULL, SS$_INSFWSL):
VALUE(ENOMEM); /* not enough core */
CASE1(SS$_ACCVIO):
VALUE(EFAULT); /* bad address */
CASE2(RMS$_DNR, SS$_DEVASSIGN):
CASE2(SS$_DEVALLOC, SS$_DEVALRALLOC):
CASE2(SS$_DEVMOUNT, SS$_DEVACTIVE):
VALUE(EBUSY); /* mount device busy codes to name a few */
CASE2(RMS$_FEX, SS$_FILALRACC):
VALUE(EEXIST); /* file exists */
CASE2(RMS$_IDR, SS$_BADIRECTORY):
VALUE(ENOTDIR); /* not a directory */
CASE1(SS$_NOIOCHAN):
VALUE(EMFILE); /* too many open files */
CASE1(RMS$_FUL):
CASE2(SS$_DEVICEFULL, SS$_EXDISKQUOTA):
VALUE(ENOSPC); /* no space left on disk codes */
CASE2(RMS$_WLK, SS$_WRITLCK):
VALUE(EROFS); /* read-only file system */
default:
VALUE(EVMSERR);
};
/* clang-format on */
/* *INDENT-ON* */
errno = trans;
vaxc$errno = code;

View File

@@ -1,5 +1,5 @@
/* NetHack 3.6 vmsmail.c $NHDT-Date: 1432512789 2015/05/25 00:13:09 $ $NHDT-Branch: master $:$NHDT-Revision: 1.9 $ */
/* Copyright (c) Robert Patrick Rankin, 1991. */
/* NetHack 3.6 vmsmail.c $NHDT-Date: 1449801741 2015/12/11 02:42:21 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.10 $ */
/* Copyright (c) Robert Patrick Rankin, 1991. */
/* NetHack may be freely redistributed. See license for details. */
#include "config.h"
@@ -25,7 +25,7 @@ struct mail_info *NDECL(parse_next_broadcast);
#endif /*__GNUC__*/
#include <signal.h>
/* #include <string.h> */
#define vms_ok(sts) ((sts) &1)
#define vms_ok(sts) ((sts) & 1)
static struct mail_info *FDECL(parse_brdcst, (char *));
static void FDECL(filter_brdcst, (char *));
@@ -49,7 +49,7 @@ static long pasteboard_id = 0; /* SMG's magic cookie */
/*
* Mail (et al) overview:
*
* When a broadcast is asynchronously captured, a volatile counter
* When a broadcast is asynchronously captured, a volatile counter
* ('broadcasts') is incremented. Each player turn, ckmailstatus() polls
* the counter and calls parse_next_broadcast() if it's positive; this
* returns some display text, object name, and response command, which is
@@ -62,7 +62,7 @@ static long pasteboard_id = 0; /* SMG's magic cookie */
* If SHELL is undefined, then all broadcasts are treated as 'other'; since
* no subproceses are allowed, there'd be no way to respond to the scroll.
*
* When a scroll of mail is read by the character, readmail() extracts
* When a scroll of mail is read by the character, readmail() extracts
* the command string and uses it for the default when prompting the
* player for a system command to spawn. The player may enter any command
* he or she chooses, or just <return> to accept the default or <escape> to
@@ -73,36 +73,36 @@ static long pasteboard_id = 0; /* SMG's magic cookie */
*
* Broadcast parsing:
*
* The following broadcast messages are [attempted to be] recognized:
* text fragment name for scroll default command
* New mail VMSmail MAIL
* New ALL-IN-1 MAIL A1mail A1M
* Software Tools mail STmail MSG [+folder]
* MM mail MMmail MM
* WPmail: New mail WPmail OFFICE/MAIL
* **M400 mail M400mail M400
* " mail", ^"mail " unknown mail SPAWN
* " phoning" Phone call PHONE ANSWER
* talk-daemon...by...foo Talk request TALK[/OLD] foo@bar
* (node)user - Bitnet noise XYZZY user@node
* The following broadcast messages are [attempted to be] recognized:
* text fragment name for scroll default command
* New mail VMSmail MAIL
* New ALL-IN-1 MAIL A1mail A1M
* Software Tools mail STmail MSG [+folder]
* MM mail MMmail MM
* WPmail: New mail WPmail OFFICE/MAIL
* **M400 mail M400mail M400
* " mail", ^"mail " unknown mail SPAWN
* " phoning" Phone call PHONE ANSWER
* talk-daemon...by...foo Talk request TALK[/OLD] foo@bar
* (node)user - Bitnet noise XYZZY user@node
* Anything else results in just the message text being passed along, no
* scroll of mail so consequently no command to execute when scroll read.
* The user can set up ``$ XYZZY :== SEND'' prior to invoking NetHack if
* vanilla JNET responses to Bitnet messages are prefered.
*
* Static return buffers are used because only one broadcast gets
* Static return buffers are used because only one broadcast gets
* processed at a time, and the essential information in each one is
* either displayed and discarded or copied into a scroll-of-mail object.
*
* The test driver code below can be used to check out potential new
* The test driver code below can be used to check out potential new
* entries without rebuilding NetHack itself. CC/DEFINE="TEST_DRIVER"
* Link it with hacklib.obj or nethack.olb/incl=hacklib (not nethack/lib).
*/
static struct mail_info msg; /* parse_*()'s return buffer */
static char nam_buf[63], /* maximum onamelth, size of ONAME(object) */
cmd_buf[99], /* arbitrary */
txt_buf[255 + 1]; /* same size as used for message buf[] */
static struct mail_info msg; /* parse_*()'s return buffer */
static char nam_buf[63], /* maximum onamelth, size of ONAME(object) */
cmd_buf[99], /* arbitrary */
txt_buf[255 + 1]; /* same size as used for message buf[] */
/* try to decipher and categorize broadcast message text
*/
@@ -136,9 +136,9 @@ char *buf; /* input: filtered broadcast text */
if (!strncmpi(buf, "new mail", 8)) {
/*
New mail [on node FOO] from [SPAM::]BAR [\"personal_name\"]
[\(HH:MM:SS\)]
*/
* New mail [on node FOO] from [SPAM::]BAR
* [\"personal_name\"] [\(HH:MM:SS\)]
*/
nam = "VMSmail"; /* assume VMSmail */
cmd = "MAIL";
if (txt && (p = strrchr(txt, '(')) > txt && /* discard time */
@@ -147,9 +147,9 @@ char *buf; /* input: filtered broadcast text */
} else if (!strncmpi(buf, "new all-in-1", 12)) {
int i;
/*
New ALL-IN-1 MAIL message [on node FOO] from Personal Name
\(BAR@SPAM\) [\(DD-MMM-YYYY HH:MM:SS\)]
*/
* New ALL-IN-1 MAIL message [on node FOO] from Personal Name
* \(BAR@SPAM\) [\(DD-MMM-YYYY HH:MM:SS\)]
*/
nam = "A1mail";
cmd = "A1M";
if (txt && (p = strrchr(txt, '(')) > txt
@@ -159,29 +159,29 @@ char *buf; /* input: filtered broadcast text */
*--p = '\0';
} else if (!strncmpi(buf, "software tools", 14)) {
/*
Software Tools mail has arrived on FOO from \'BAR\' [in SPAM]
*/
* Software Tools mail has arrived on FOO from \'BAR\' [in SPAM]
*/
nam = "STmail";
cmd = "MSG";
if (txt && (p = strstri(p, " in ")) != 0) /* specific folder */
cmd = strcat(strcpy(cmd_buf, "MSG +"), p + 4);
} else if (q - 2 >= buf && !strncmpi(q - 2, "mm", 2)) {
/*
{MultiNet\ |PMDF\/}MM mail has arrived on FOO from BAR\n
[Subject: subject_text] (PMDF only)
*/
* {MultiNet\ |PMDF\/}MM mail has arrived on FOO from BAR\n
* [Subject: subject_text] (PMDF only)
*/
nam = "MMmail"; /* MultiNet's version of MM */
cmd = "MM"; /*{ perhaps "MM READ"? }*/
} else if (!strncmpi(buf, "wpmail:", 7)) {
/*
WPmail: New mail from BAR. subject_text
*/
* WPmail: New mail from BAR. subject_text
*/
nam = "WPmail"; /* WordPerfect [sic] Office */
cmd = "OFFICE/MAIL";
} else if (!strncmpi(buf, "**m400 mail", 7)) {
/*
**M400 mail waiting**
*/
* **M400 mail waiting**
*/
nam = "M400mail"; /* Messenger 400 [not seen] */
cmd = "M400";
} else {
@@ -193,14 +193,14 @@ char *buf; /* input: filtered broadcast text */
if (!txt)
txt = strcat(strcpy(txt_buf, "Mail for you: "), buf);
/*
: end of mail recognition; now check for call-type
interruptions...
*/
/*
* end of mail recognition; now check for call-type interruptions...
*/
} else if ((q = strstri(buf, " phoning")) != 0) {
/*
BAR is phoning you [on FOO] \(HH:MM:SS\)
*/
* BAR is phoning you [on FOO] \(HH:MM:SS\)
*/
typ = MSG_CALL;
nam = "Phone call";
cmd = "PHONE ANSWER";
@@ -210,10 +210,10 @@ char *buf; /* input: filtered broadcast text */
} else if ((q = strstri(buf, " talk-daemon")) != 0
|| (q = strstri(buf, " talk_daemon")) != 0) {
/*
Message from TALK-DAEMON@FOO at HH:MM:SS\n
Connection request by BAR@SPAM\n
\[Respond with: TALK[/OLD] BAR@SPAM\]
*/
* Message from TALK-DAEMON@FOO at HH:MM:SS\n
* Connection request by BAR@SPAM\n
* \[Respond with: TALK[/OLD] BAR@SPAM\]
*/
typ = MSG_CALL;
nam = "Talk request"; /* MultiNet's TALK and/or TALK/OLD */
cmd = "TALK";
@@ -239,25 +239,27 @@ char *buf; /* input: filtered broadcast text */
} else if (is_jnet_send) { /* sscanf(,"(%[^)])%s -%c",,,)==3 */
jnet_send:
/*
\(SPAM\)BAR - arbitrary_message_text (from BAR@SPAM)
*/
* \(SPAM\)BAR - arbitrary_message_text (from BAR@SPAM)
*/
typ = MSG_CALL;
nam = "Bitnet noise"; /* RSCS/NJE message received via JNET */
Sprintf(cmd_buf, "XYZZY %s@%s", user, node);
cmd = cmd_buf;
/*{ perhaps just vanilla SEND instead of XYZZY? }*/
Sprintf(txt_buf, "Message from %s@%s:%s", user, node,
&buf[1 + strlen(node) + 1 + strlen(user) + 2
- 1]); /* "(node)user -" */
/* "(node)user -" */
&buf[1 + strlen(node) + 1 + strlen(user) + 2 - 1]);
txt = txt_buf;
/*
: end of call recognition; anything else is none-of-the-above...
*/
/*
* end of call recognition; anything else is none-of-the-above...
*/
} else {
other:
#endif /* SHELL */
/* arbitrary broadcast: batch job completed, system shutdown imminent,
* &c */
/* arbitrary broadcast: batch job completed, system shutdown
* imminent, &c
*/
typ = MSG_OTHER;
nam = (char *) 0; /*"captured broadcast message"*/
cmd = (char *) 0;
@@ -300,21 +302,22 @@ register char *buf; /* in: original text; out: filtered text */
/* filter the text; restrict consecutive spaces or dots to just two */
for (p = buf_p = buf; *buf_p; buf_p++) {
c = *buf_p & '\177';
if (c == ' ' || c == '\t' || c == '\n')
if (c == ' ' || c == '\t' || c == '\n') {
if (p == buf || /* ignore leading whitespace */
(p >= buf + 2 && *(p - 1) == ' ' && *(p - 2) == ' '))
continue;
else
c = ' ';
else if (c == '.' || c < ' ' || c == '\177')
} else if (c == '.' || c < ' ' || c == '\177') {
if (p == buf || /* skip leading beeps & such */
(p >= buf + 2 && *(p - 1) == '.' && *(p - 2) == '.'))
continue;
else
c = '.';
else if (c == '%' && /* trim %%% OPCOM verbosity %%% */
p >= buf + 2 && *(p - 1) == '%' && *(p - 2) == '%')
} else if (c == '%' && /* trim %%% OPCOM verbosity %%% */
p >= buf + 2 && *(p - 1) == '%' && *(p - 2) == '%') {
continue;
}
*p++ = c;
}
*p = '\0'; /* terminate, then strip trailing junk */
@@ -326,7 +329,7 @@ register char *buf; /* in: original text; out: filtered text */
static char empty_string[] = "";
/* fetch the text of a captured broadcast, then mangle and decipher it
*/
*/
struct mail_info *parse_next_broadcast() /* called by ckmailstatus(mail.c) */
{
short length, msg_type;
@@ -349,7 +352,7 @@ struct mail_info *parse_next_broadcast() /* called by ckmailstatus(mail.c) */
}
/* spit out any pending broadcast messages whenever we leave
*/
*/
static void flush_broadcasts() /* called from disable_broadcast_trapping() */
{
if (broadcasts > 0) {
@@ -369,27 +372,26 @@ static void flush_broadcasts() /* called from disable_broadcast_trapping() */
}
}
/* AST routine called when the terminal's associated mailbox receives a
* message
*/
/* AST routine called when terminal's associated mailbox receives a message
*/
/*ARGSUSED*/
static void
broadcast_ast(dummy) /* called asynchronously by terminal driver */
int dummy; /* not used */
int dummy UNUSED;
{
broadcasts++;
}
/* initialize the broadcast manipulation code; SMG makes this easy
*/
unsigned long init_broadcast_trapping() /* called by setftty() [once only] */
unsigned long
init_broadcast_trapping() /* called by setftty() [once only] */
{
unsigned long sts, preserve_screen_flag = 1;
/* we need a pasteboard to pass to the broadcast setup/teardown routines
*/
sts =
smg$create_pasteboard(&pasteboard_id, 0, 0, 0, &preserve_screen_flag);
/* we need a pasteboard to pass to the broadcast setup/teardown routines */
sts = smg$create_pasteboard(&pasteboard_id, 0, 0, 0,
&preserve_screen_flag);
if (!vms_ok(sts)) {
errno = EVMSERR, vaxc$errno = sts;
raw_print("");
@@ -401,8 +403,9 @@ unsigned long init_broadcast_trapping() /* called by setftty() [once only] */
}
/* set up the terminal driver to deliver $brkthru data to a mailbox device
*/
unsigned long enable_broadcast_trapping() /* called by setftty() */
*/
unsigned long
enable_broadcast_trapping() /* called by setftty() */
{
unsigned long sts = 1;
@@ -422,8 +425,9 @@ unsigned long enable_broadcast_trapping() /* called by setftty() */
}
/* return to 'normal'; $brkthru data goes straight to the terminal
*/
unsigned long disable_broadcast_trapping() /* called by settty() */
*/
unsigned long
disable_broadcast_trapping() /* called by settty() */
{
unsigned long sts = 1;
@@ -436,7 +440,9 @@ unsigned long disable_broadcast_trapping() /* called by settty() */
}
return sts;
}
#else /* MAIL */
/* simple stubs for non-mail configuration */
unsigned long
init_broadcast_trapping()
@@ -458,6 +464,7 @@ parse_next_broadcast()
{
return 0;
}
#endif /* MAIL */
/*----------------------------------------------------------------------*/
@@ -538,6 +545,7 @@ void
wait_synch()
{
char dummy[BUFSIZ];
printf("\nPress <return> to continue: ");
fflush(stdout);
(void) gets(dummy);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 vmsmain.c $NHDT-Date: 1432512790 2015/05/25 00:13:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.31 $ */
/* NetHack 3.6 vmsmain.c $NHDT-Date: 1449801742 2015/12/11 02:42:22 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.32 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* main.c - VMS NetHack */
@@ -18,7 +18,7 @@ static void NDECL(byebye);
#define vms_handler_type unsigned int
#endif
extern void FDECL(VAXC$ESTABLISH,
(vms_handler_type (*) (genericptr_t, genericptr_t)));
(vms_handler_type (*) (genericptr_t, genericptr_t)));
static vms_handler_type FDECL(vms_handler, (genericptr_t, genericptr_t));
#include <ssdef.h> /* system service status codes */
#endif
@@ -54,13 +54,13 @@ char *argv[];
choose_windows(DEFAULT_WINDOW_SYS);
#ifdef CHDIR /* otherwise no chdir() */
/*
* See if we must change directory to the playground.
* (Perhaps hack is installed with privs and playground is
* inaccessible for the player.)
* The logical name HACKDIR is overridden by a
* -d command line option (must be the first option given)
*/
/*
* See if we must change directory to the playground.
* (Perhaps hack is installed with privs and playground is
* inaccessible for the player.)
* The logical name HACKDIR is overridden by a
* -d command line option (must be the first option given)
*/
dir = nh_getenv("NETHACKDIR");
if (!dir)
dir = nh_getenv("HACKDIR");
@@ -225,7 +225,7 @@ attempt_restore:
moveloop(resuming);
exit(EXIT_SUCCESS);
/*NOTREACHED*/
return (0);
return 0;
}
static void
@@ -357,8 +357,8 @@ static void
whoami()
{
/*
* Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS
* 2. Use lowercase of $USER (if 1. fails)
* Who am i? Algorithm: 1. Use name as specified in NETHACKOPTIONS;
* 2. Use lowercase of $USER (if 1. fails).
* The resulting name is overridden by command line options.
* If everything fails, or if the resulting name is some generic
* account like "games" then eventually we'll ask him.
@@ -404,8 +404,8 @@ byebye()
/* Condition handler to prevent byebye's hangup simulation
from saving the game after a fatal error has occurred. */
/*ARGSUSED*/
static vms_handler_type /* should be `unsigned long', but the -*/
vms_handler(sigargs, mechargs) /*+ prototype in <signal.h> is screwed */
static vms_handler_type /* should be `unsigned long', but the -*/
vms_handler(sigargs, mechargs) /*+ prototype in <signal.h> is screwed */
genericptr_t sigargs, mechargs; /* [0] is argc, [1..argc] are the real args */
{
unsigned long condition = ((unsigned long *) sigargs)[1];
@@ -416,7 +416,7 @@ genericptr_t sigargs, mechargs; /* [0] is argc, [1..argc] are the real args */
program_state.done_hup = TRUE; /* pretend hangup has been attempted */
#ifndef BETA
if (wizard)
#endif /* !BETA */
#endif
abort(); /* enter the debugger */
}
return SS$_RESIGNAL;
@@ -442,10 +442,6 @@ port_help()
}
#endif /* PORT_HELP */
/* for KR1ED config, WIZARD is 0 or 1 and WIZARD_NAME is a string;
for usual config, WIZARD is the string and vmsconf.h forces WIZARD_NAME
to match it, avoiding need to test which one to use in string ops */
/* validate wizard mode if player has requested access to it */
boolean
authorize_wizard_mode()

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 vmstty.c $NHDT-Date: 1432512790 2015/05/25 00:13:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.15 $ */
/* NetHack 3.6 vmstty.c $NHDT-Date: 1449801743 2015/12/11 02:42:23 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.17 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* tty.c - (VMS) version */
@@ -24,7 +24,7 @@
#define TT$M_NOBRDCST 0x00020000 /* disable broadcast messages, but */
#define TT2$M_BRDCSTMBX 0x00000010 /* catch them in associated mailbox */
#define TT2$M_APP_KEYPAD 0x00800000 /* application vs numeric keypad mode */
#endif /* __GNUC__ */
#endif /* __GNUC__ */
#ifdef USE_QIO_INPUT
#include <ssdef.h>
#endif
@@ -44,7 +44,7 @@ static void NDECL(resettty);
#define vms_ok(sts) ((sts) &1)
#define META(c) ((c) | 0x80) /* 8th bit */
#define CTRL(c) ((c) &0x1F)
#define CTRL(c) ((c) & 0x1F)
#define CMASK(c) (1 << CTRL(c))
#define LIB$M_CLI_CTRLT CMASK('T') /* 0x00100000 */
#define LIB$M_CLI_CTRLY CMASK('Y') /* 0x02000000 */
@@ -221,10 +221,10 @@ vms_getchar()
}
} else {
/* abnormal input--either SMG didn't initialize properly or
vms_getchar() has been called recursively (via SIGINT handler).
* vms_getchar() has been called recursively (via SIGINT handler).
*/
if (kb != 0) /* must have been a recursive call */
smg$cancel_input(&kb); /* from an interrupt handler */
smg$cancel_input(&kb); /* from an interrupt handler */
key = getchar();
}
--recurse;
@@ -247,7 +247,7 @@ vms_getchar()
* for two reasons:
* 1) retain support for arrow keys, and
* 2) treat other VTxxx function keys as <esc> for aborting
* various NetHack prompts.
* various NetHack prompts.
* The second reason is compelling; otherwise remaining chars of
* an escape sequence get treated as inappropriate user commands.
*
@@ -257,26 +257,25 @@ vms_getchar()
/*=
-- Summary of VTxxx-style keyboards and transmitted escape sequences. --
Keypad codes are prefixed by 7 bit (\033 O) or 8 bit SS3:
keypad: PF1 PF2 PF3 PF4 codes: P Q R S
7 8 9 - w x y m
4 5 6 . t u v n
1 2 3 :en-: q r s : :
...0... , :ter: ...p... l :M:
keypad: PF1 PF2 PF3 PF4 codes: P Q R S
7 8 9 - w x y m
4 5 6 . t u v n
1 2 3 :en-: q r s : :
...0... , :ter: ...p... l :M:
Arrows are prefixed by either SS3 or CSI (either 7 or 8 bit), depending on
whether the terminal is in application or numeric mode (ditto for PF keys):
arrows: <up> <dwn> <lft> <rgt> A B D C
Additional function keys (vk201/vk401) generate CSI nn ~ (nn is 1 or 2
digits):
arrows: <up> <dwn> <lft> <rgt> A B D C
Additional function keys (vk201/vk401) generate CSI nn ~ (nn is 1 or 2 digits):
vk201 keys: F6 F7 F8 F9 F10 F11 F12 F13 F14 Help Do F17 F18 F19 F20
'nn' digits: 17 18 19 20 21 23 24 25 26 28 29 31 32 33 34
alternate: ^C ^[ ^H ^J (when in VT100 mode)
edit keypad: <fnd> <ins> <rmv> digits: 1 2 3
<sel> <prv> <nxt> 4 5 6
alternate: ^C ^[ ^H ^J (when in VT100 mode)
edit keypad: <fnd> <ins> <rmv> digits: 1 2 3
<sel> <prv> <nxt> 4 5 6
VT52 mode: arrows and PF keys send ESCx where x is in A-D or P-S.
=*/
static const char *arrow_or_PF = "ABCDPQRS", /* suffix char */
*smg_keypad_codes = "PQRSpqrstuvwxyMmlnABDC";
*smg_keypad_codes = "PQRSpqrstuvwxyMmlnABDC";
/* PF1..PF4,KP0..KP9,enter,dash,comma,dot,up-arrow,down,left,right */
/* Ultimate return value is (index into smg_keypad_codes[] + 256). */
@@ -310,6 +309,7 @@ register int c;
if (vms_ok(sts) || sts == SS$_TIMEOUT) {
register int cnt = iosb.trm_offset + iosb.trm_siz + inc;
register char *p = seq_buf;
if (c == ESC) /* check for 7-bit vt100/ANSI, or vt52 */
if (*p == '[' || *p == 'O')
c = META(CTRL(*p++)), cnt--;
@@ -317,6 +317,7 @@ register int c;
c = SS3; /*CSI*/
if (cnt > 0 && (c == SS3 || (c == CSI && strchr(arrow_or_PF, *p)))) {
register char *q = strchr(smg_keypad_codes, *p);
if (q)
result = 256 + (q - smg_keypad_codes);
p++, --cnt; /* one more char consumed */
@@ -334,6 +335,7 @@ register int c;
}; /* note: there are several missing nn in CSI nn ~ values */
int nn;
char *q;
*(p + cnt) = '\0'; /* terminate string */
q = strchr(p, '~');
if (q && sscanf(p, "%d~", &nn) == 1) {
@@ -373,7 +375,9 @@ setctty()
}
}
static void resettty() /* atexit() routine */
/* atexit() routine */
static void
resettty()
{
if (settty_needed) {
bombing = TRUE; /* don't clear screen; preserve traceback info */
@@ -451,7 +455,8 @@ const char *s;
disable_broadcast_trapping();
#if 0 /* let SMG's exit handler do the cleanup (as per doc) */
/* #ifndef USE_QIO_INPUT */
if (kb) smg$delete_virtual_keyboard(&kb), kb = 0;
if (kb)
smg$delete_virtual_keyboard(&kb), kb = 0;
#endif /* 0 (!USE_QIO_INPUT) */
if (ctrl_mask)
(void) lib$enable_ctrl(&ctrl_mask, 0);
@@ -502,12 +507,16 @@ setftty()
settty_needed = TRUE;
}
void intron() /* enable kbd interupts if enabled when game started */
/* enable kbd interupts if enabled when game started */
void
intron()
{
intr_char = CTRL('C');
}
void introff() /* disable kbd interrupts if required*/
/* disable kbd interrupts if required*/
void
introff()
{
intr_char = 0;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 vmsunix.c $NHDT-Date: 1432512790 2015/05/25 00:13:10 $ $NHDT-Branch: master $:$NHDT-Revision: 1.14 $ */
/* NetHack 3.6 vmsunix.c $NHDT-Date: 1449801743 2015/12/11 02:42:23 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.15 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -28,7 +28,7 @@ extern void VDECL(lib$signal, (unsigned, ...));
extern unsigned long sys$setprv();
extern unsigned long lib$getdvi(), lib$getjpi(), lib$spawn(), lib$attach();
extern unsigned long smg$init_term_table_by_type(), smg$del_term_table();
#define vms_ok(sts) ((sts) &1) /* odd => success */
#define vms_ok(sts) ((sts) & 1) /* odd => success */
/* this could be static; it's only used within this file;
it won't be used at all if C_LIB$INTIALIZE gets commented out below,
@@ -51,10 +51,10 @@ int fd;
struct stat buf;
if (fstat(fd, &buf))
return (0); /* cannot get status */
return 0; /* cannot get status */
#ifndef INSURANCE
if (buf.st_size != sizeof(int))
return (0); /* not an xlock file */
return 0; /* not an xlock file */
#endif
(void) time(&date);
if (date - buf.st_mtime < 3L * 24L * 60L * 60L) { /* recent */
@@ -81,8 +81,8 @@ int fd;
}
set_levelfile_name(lock, 0);
if (delete (lock))
return (0); /* cannot remove it */
return (1); /* success! */
return 0; /* cannot remove it */
return 1; /* success! */
}
void
@@ -167,7 +167,7 @@ register char *s;
int
vms_getuid()
{
return (getgid() << 16) | getuid();
return ((getgid() << 16) | getuid());
}
#ifndef FAB$C_STMLF
@@ -189,7 +189,7 @@ int fd;
#else
rfm = buf.st_fab_rfm;
#endif
return rfm == FAB$C_STMLF;
return (boolean) (rfm == FAB$C_STMLF);
}
/*------*/
@@ -303,7 +303,7 @@ verify_term()
/* strip trailing blanks */
while (p > smgdevtyp && *--p == ' ')
*p = '\0';
/* (void)smg$del_term_table(); */
/* (void) smg$del_term_table(); */
term = smgdevtyp;
}
}
@@ -398,9 +398,9 @@ boolean screen_manip;
#ifdef SHELL
unsigned long dosh_pid = 0, /* this should cover any interactive escape */
mail_pid = 0; /* this only covers the last mail or phone; */
/*(mail & phone commands aren't expected to leave any process hanging
* around)*/
mail_pid = 0; /* this only covers the last mail or phone;
(mail & phone commands aren't expected to
leave any process hanging around) */
int
dosh()
@@ -408,20 +408,18 @@ dosh()
return vms_doshell("", TRUE); /* call for interactive child process */
}
/* vms_doshell -- called by dosh() and readmail() */
/* If execstring is not a null string, then it will be executed in a spawned
/* vms_doshell -- called by dosh() and readmail()
*
* If execstring is not a null string, then it will be executed in a spawned
* subprocess, which will then return. It is for handling mail or phone
* interactive commands, which are only available if both MAIL and SHELL are
* #defined, but we don't bother making the support code conditionalized on
* MAIL here, just on SHELL being enabled.
*
* Normally, all output from this interaction will be 'piped' to the user's
* screen (SYS$OUTPUT). However, if 'screenoutput' is set to FALSE, output
* will be piped into oblivion. Used for silent phone call rejection.
*/
/* subprocess, which will then return. It is for handling mail or phone */
/* interactive commands, which are only available if both MAIL and SHELL are
*/
/* #defined, but we don't bother making the support code conditionalized on */
/* MAIL here, just on SHELL being enabled. */
/* Normally, all output from this interaction will be 'piped' to the user's */
/* screen (SYS$OUTPUT). However, if 'screenoutput' is set to FALSE, output */
/* will be piped into oblivion. Used for silent phone call rejection. */
int
vms_doshell(execstring, screenoutput)
const char *execstring;
@@ -449,9 +447,8 @@ boolean screenoutput;
}
hack_escape(screenoutput,
command ? (const char *) 0 : " \"Escaping\" into a "
"subprocess; LOGOUT to "
"reconnect and resume play. ");
command ? (const char *) 0
: " \"Escaping\" into a subprocess; LOGOUT to reconnect and resume play. ");
if (command || !dosh_pid || !vms_ok(status = lib$attach(&dosh_pid))) {
#ifdef CHDIR
@@ -483,7 +480,7 @@ boolean screenoutput;
#ifdef SUSPEND
/* dosuspend() -- if we're a subprocess, attach to our parent;
* if not, there's nothing we can do.
* if not, there's nothing we can do.
*/
int
dosuspend()
@@ -494,15 +491,15 @@ dosuspend()
if (owner_pid == -1) /* need to check for parent */
owner_pid = getppid();
if (owner_pid == 0) {
pline(" No parent process. Use '!' to Spawn, 'S' to Save, or 'Q' "
"to Quit. ");
pline(
" No parent process. Use '!' to Spawn, 'S' to Save, or '#quit' to Quit. ");
mark_synch();
return 0;
}
/* restore normal tty environment & clear screen */
hack_escape(1, " Attaching to parent process; use the ATTACH command to "
"resume play. ");
hack_escape(1,
" Attaching to parent process; use the ATTACH command to resume play. ");
status = lib$attach(&owner_pid); /* connect to parent */
@@ -535,7 +532,7 @@ char ***array;
while (indx >= *asize - 1) {
oldsize = *asize;
*asize += 5;
newarray = (char **) alloc(*asize * sizeof(char *));
newarray = (char **) alloc(*asize * sizeof (char *));
/* poor man's realloc() */
for (i = 0; i < *asize; ++i)
newarray[i] = (i < oldsize) ? (*array)[i] : 0;
@@ -543,7 +540,7 @@ char ***array;
free((genericptr_t) *array);
*array = newarray;
}
(*array)[indx] = strcpy((char *) alloc(strlen(name) + 1), name);
(*array)[indx] = dupstr(name);
}
struct dsc {
@@ -551,8 +548,7 @@ struct dsc {
char *adr;
}; /* descriptor */
typedef unsigned long vmscond; /* vms condition value */
vmscond FDECL(lib$find_file,
(const struct dsc *, struct dsc *, genericptr *));
vmscond FDECL(lib$find_file, (const struct dsc *, struct dsc *, genericptr *));
vmscond FDECL(lib$find_file_end, (void **));
/* collect a list of character names from all save files for this player */
@@ -605,15 +601,11 @@ int how; /* 1: exit after traceback; 2: stay in debugger */
union dbgcmd {
struct ascic {
unsigned char len; /* 8-bit length prefix */
char
str[79]; /* could be up to 255, but we don't need that much */
char str[79]; /* could be up to 255, but we don't need so much */
} cmd_fields;
char cmd[1 + 79];
};
#define DBGCMD(arg) \
{ \
(unsigned char)(sizeof arg - sizeof ""), arg \
}
#define DBGCMD(arg) { (unsigned char) (sizeof arg - sizeof ""), arg }
static union dbgcmd dbg[3] = {
/* prologue for less verbose feedback (when combined with
$ define/User_mode dbg$output _NL: ) */
@@ -709,40 +701,40 @@ struct eiha { /* extended image header activation block, $EIHADEF */
};
/*
* We're going to use lib$initialize, not because we need or
* want to be called before main(), but because one of the
* arguments passed to a lib$initialize callback is a pointer
* to the image header (somewhat complex data structure which
* includes the memory location(s) of where to start executing)
* of the program being initialized. It comes in two flavors,
* one used by VAX and the other by Alpha and IA64.
* We're going to use lib$initialize, not because we need or
* want to be called before main(), but because one of the
* arguments passed to a lib$initialize callback is a pointer
* to the image header (somewhat complex data structure which
* includes the memory location(s) of where to start executing)
* of the program being initialized. It comes in two flavors,
* one used by VAX and the other by Alpha and IA64.
*
* An image can have up to three transfer addresses; one of them
* decides whether to run under debugger control (RUN/Debug, or
* LINK/Debug + plain RUN), another handles lib$initialize calls
* if that's used, and the last is to start the program itself
* (a jacket built around main() for code compiled with DEC C).
* They aren't always all present; some might be zero/null.
* A shareable image (pre-linked library) usually won't have any,
* but can have a separate initializer (not of interest here).
* An image can have up to three transfer addresses; one of them
* decides whether to run under debugger control (RUN/Debug, or
* LINK/Debug + plain RUN), another handles lib$initialize calls
* if that's used, and the last is to start the program itself
* (a jacket built around main() for code compiled with DEC C).
* They aren't always all present; some might be zero/null.
* A shareable image (pre-linked library) usually won't have any,
* but can have a separate initializer (not of interest here).
*
* The transfer targets don't have fixed slots but do occur in a
* particular order:
* link link lib$initialize lib$initialize
* sharable /noTrace /Trace + /noTrace + /Traceback
* 1: (none) main debugger init-handler debugger
* 2: main main init-handler
* 3: main
* The transfer targets don't have fixed slots but do occur in a
* particular order:
* link link lib$initialize lib$initialize
* sharable /noTrace /Trace + /noTrace + /Traceback
* 1: (none) main debugger init-handler debugger
* 2: main main init-handler
* 3: main
*
* We check whether the first transfer address is SYS$IMGSTA().
* If it is, the debugger should be available to catch SS$_DEBUG
* exception even when we don't start up under debugger control.
* One extra complication: if we *do* start up under debugger
* control, the first address in the in-memory copy of the image
* header will be changed from sys$imgsta() to a value in system
* space. [I don't know how to reference that one symbolically,
* so I'm going to treat any address in system space as meaning
* that the debugger is available. pr]
* We check whether the first transfer address is SYS$IMGSTA().
* If it is, the debugger should be available to catch SS$_DEBUG
* exception even when we don't start up under debugger control.
* One extra complication: if we *do* start up under debugger
* control, the first address in the in-memory copy of the image
* header will be changed from sys$imgsta() to a value in system
* space. [I don't know how to reference that one symbolically,
* so I'm going to treat any address in system space as meaning
* that the debugger is available. pr]
*/
/* called via lib$initialize during image activation: before main() and
@@ -760,14 +752,15 @@ const unsigned char *imghdr;
unsigned long trnadr1;
(void) lib$establish(lib$sig_to_ret); /* set up condition handler */
/*
* Check the first of three transfer addresses to see whether
* it is SYS$IMGSTA(). Note that they come from a file,
* where they reside as longword or quadword integers rather
* than function pointers. (Basically just a C type issue;
* casting back and forth between integer and pointer doesn't
* change any bits for the architectures VMS runs on.)
*/
/*
* Check the first of three transfer addresses to see whether
* it is SYS$IMGSTA(). Note that they come from a file,
* where they reside as longword or quadword integers rather
* than function pointers. (Basically just a C type issue;
* casting back and forth between integer and pointer doesn't
* change any bits for the architectures VMS runs on.)
*/
debuggable = 0;
/* start with a guess rather than bothering to figure out architecture */
vax_hdr = (struct ihd *) imghdr;
@@ -848,10 +841,11 @@ const unsigned long lib$initialize[] = { (unsigned long) (void *) vmsexeini };
#ifdef __DECC
#pragma extern_model restore /* pop previous mode */
#endif
/* We also need to link against a linker options file containing:
/* We also need to link against a linker options file containing:
sys$library:starlet.olb/Include=(lib$initialize)
psect_attr=lib$initialize, Con,Usr,noPic,Rel,Gbl,noShr,noExe,Rd,noWrt,Long
*/
#endif /* C_LIB$INITIALIZE */
/* End of debugger hackery. */
/*vmsunix.c*/

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 nttty.c $NHDT-Date: 1431737067 2015/05/16 00:44:27 $ $NHDT-Branch: master $:$NHDT-Revision: 1.63 $ */
/* NetHack 3.6 nttty.c $NHDT-Date: 1449893262 2015/12/12 04:07:42 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.64 $ */
/* Copyright (c) NetHack PC Development Team 1993 */
/* NetHack may be freely redistributed. See license for details. */
@@ -258,6 +258,8 @@ int mode;
DWORD cmode;
long mask;
GUILaunched = 0;
try :
/* The following lines of code were suggested by
* Bob Landau of Microsoft WIN32 Developer support,
@@ -265,14 +267,10 @@ int mode;
* we were launched from the command prompt, or from
* the NT program manager. M. Allison
*/
hStdOut
= GetStdHandle(STD_OUTPUT_HANDLE);
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdOut) {
GetConsoleScreenBufferInfo(hStdOut, &origcsbi);
GUILaunched = ((origcsbi.dwCursorPosition.X == 0)
&& (origcsbi.dwCursorPosition.Y == 0));
if ((origcsbi.dwSize.X <= 0) || (origcsbi.dwSize.Y <= 0))
GUILaunched = 0;
} else if (mode) {
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
HANDLE hStdIn = GetStdHandle(STD_INPUT_HANDLE);
@@ -286,10 +284,14 @@ int mode;
freopen("CON", "r", stdin);
}
mode = 0;
goto try
;
} else
goto try;
} else {
return;
}
/* Obtain handles for the standard Console I/O devices */
hConIn = GetStdHandle(STD_INPUT_HANDLE);
hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
load_keyboard_handler();
/* Initialize the function pointer that points to
@@ -297,9 +299,6 @@ int mode;
*/
nt_kbhit = nttty_kbhit;
/* Obtain handles for the standard Console I/O devices */
hConIn = GetStdHandle(STD_INPUT_HANDLE);
hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
#if 0
hConIn = CreateFile("CONIN$",
GENERIC_READ |GENERIC_WRITE,

View File

@@ -7,6 +7,7 @@
int GUILaunched;
struct window_procs mswin_procs = { "guistubs" };
void
mswin_destroy_reg()
{
@@ -36,6 +37,7 @@ char *argv[];
return 0;
}
#endif
#endif /* GUISTUB */
/* =============================================== */
@@ -43,7 +45,10 @@ char *argv[];
#ifdef TTYSTUB
#include "hack.h"
#include "win32api.h"
HANDLE hConIn;
HANDLE hConOut;
int GUILaunched;
struct window_procs tty_procs = { "ttystubs" };