Merge branch 'NetHack-3.6.0'

This commit is contained in:
nhmall
2018-05-15 01:21:54 -04:00
20 changed files with 1592 additions and 702 deletions

View File

@@ -6,6 +6,7 @@
/* various code that was replicated in *main.c */
#include "hack.h"
#include <ctype.h>
#ifndef NO_SIGNAL
#include <signal.h>
@@ -16,6 +17,7 @@ STATIC_DCL void NDECL(do_positionbar);
#endif
STATIC_DCL void FDECL(regen_hp, (int));
STATIC_DCL void FDECL(interrupt_multi, (const char *));
STATIC_DCL void FDECL(debug_fields, (const char *));
void
moveloop(resuming)
@@ -760,11 +762,18 @@ const char *msg;
*/
static struct early_opt earlyopts[] = {
{ARG_DEBUG, "debug", 5, FALSE},
{ARG_DEBUG, "debug", 5, TRUE},
{ARG_VERSION, "version", 4, TRUE},
};
boolean
/*
* Returns:
* 0 = no match
* 1 = found and skip past this argument
* 2 = found and trigger immediate exit
*/
int
argcheck(argc, argv, e_arg)
int argc;
char *argv[];
@@ -782,7 +791,7 @@ enum earlyarg e_arg;
if ((idx >= SIZE(earlyopts)) || (argc <= 1))
return FALSE;
for (i = 1; i < argc; ++i) {
for (i = 0; i < argc; ++i) {
if (argv[i][0] != '-')
continue;
if (argv[i][1] == '-') {
@@ -797,15 +806,20 @@ enum earlyarg e_arg;
}
if (match) {
const char *extended_opt = index(userea,':');
if (!extended_opt)
extended_opt = index(userea, '=');
switch(e_arg) {
case ARG_DEBUG:
if (extended_opt) {
extended_opt++;
debug_fields(extended_opt);
}
return 1;
break;
case ARG_VERSION: {
boolean insert_into_pastebuf = FALSE;
const char *extended_opt = index(userea,':');
if (!extended_opt)
extended_opt = index(userea, '=');
if (extended_opt) {
extended_opt++;
@@ -820,7 +834,7 @@ enum earlyarg e_arg;
}
}
early_version_info(insert_into_pastebuf);
return TRUE;
return 2;
break;
}
default:
@@ -830,4 +844,62 @@ enum earlyarg e_arg;
return FALSE;
}
/*
* These are internal controls to aid developers with
* testing and debugging particular aspects of the code.
* They are not player options and the only place they
* are documented is right here. No gameplay is altered.
*
* test - test whether this parser is working
* ttystatus - TTY:
* immediateflips - WIN32: turn off display performance
* optimization so that display output
* can be debugged without buffering.
*/
void
debug_fields(opts)
const char *opts;
{
char *op;
boolean negated = FALSE;
while ((op = index(opts, ',')) != 0) {
*op++ = 0;
/* recurse */
debug_fields(op);
}
if (strlen(opts) > BUFSZ / 2)
return;
/* strip leading and trailing white space */
while (isspace((uchar) *opts))
opts++;
op = eos((char *) opts);
while (--op >= opts && isspace((uchar) *op))
*op = '\0';
if (!*opts) {
/* empty */
return;
}
while ((*opts == '!') || !strncmpi(opts, "no", 2)) {
if (*opts == '!')
opts++;
else
opts += 2;
negated = !negated;
}
if (match_optname(opts, "test", 4, FALSE))
iflags.debug.test = negated ? FALSE : TRUE;
#ifdef TTY_GRAPHICS
if (match_optname(opts, "ttystatus", 9, FALSE))
iflags.debug.ttystatus = negated ? FALSE : TRUE;
#endif
#ifdef WIN32
if (match_optname(opts, "immediateflips", 14, FALSE))
iflags.debug.immediateflips = negated ? FALSE : TRUE;
#endif
return;
}
/*allmain.c*/

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 botl.c $NHDT-Date: 1506903619 2017/10/02 00:20:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.81 $ */
/* NetHack 3.6 botl.c $NHDT-Date: 1525696908 2018/05/07 12:41:48 $ $NHDT-Branch: tty-status $:$NHDT-Revision: 1.91 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2006. */
/* NetHack may be freely redistributed. See license for details. */
@@ -483,14 +483,14 @@ STATIC_DCL struct istat_s initblstats[MAXBLSTATS] = {
INIT_BLSTAT("charisma", " Ch:%s", ANY_INT, 10, BL_CH),
INIT_BLSTAT("alignment", " %s", ANY_STR, 40, BL_ALIGN),
INIT_BLSTAT("score", " S:%s", ANY_LONG, 20, BL_SCORE),
INIT_BLSTAT("carrying-capacity", " %s", ANY_LONG, 20, BL_CAP),
INIT_BLSTAT("carrying-capacity", " %s", ANY_INT, 20, BL_CAP),
INIT_BLSTAT("gold", " %s", ANY_LONG, 30, BL_GOLD),
INIT_BLSTATP("power", " Pw:%s", ANY_INT, 10, BL_ENEMAX, BL_ENE),
INIT_BLSTAT("power-max", "(%s)", ANY_INT, 10, BL_ENEMAX),
INIT_BLSTAT("experience-level", " Xp:%s", ANY_LONG, 10, BL_XP),
INIT_BLSTAT("experience-level", " Xp:%s", ANY_INT, 10, BL_XP),
INIT_BLSTAT("armor-class", " AC:%s", ANY_INT, 10, BL_AC),
INIT_BLSTAT("HD", " HD:%s", ANY_INT, 10, BL_HD),
INIT_BLSTAT("time", " T:%s", ANY_INT, 20, BL_TIME),
INIT_BLSTAT("time", " T:%s", ANY_LONG, 20, BL_TIME),
INIT_BLSTAT("hunger", " %s", ANY_UINT, 40, BL_HUNGER),
INIT_BLSTATP("hitpoints", " HP:%s", ANY_INT, 10, BL_HPMAX, BL_HP),
INIT_BLSTAT("hitpoints-max", "(%s)", ANY_INT, 10, BL_HPMAX),
@@ -630,7 +630,7 @@ bot_via_windowport()
/* Experience */
blstats[idx][BL_XP].a.a_int = u.ulevel;
blstats[idx][BL_EXP].a.a_int = u.uexp;
blstats[idx][BL_EXP].a.a_long = u.uexp;
/* Time (moves) */
blstats[idx][BL_TIME].a.a_long = moves;
@@ -858,7 +858,10 @@ boolean
: TRUE;
fieldname = initblstats[i].fldname;
fieldfmt = initblstats[i].fldfmt;
if (fld == BL_TITLE && iflags.wc2_hitpointbar)
fieldfmt = "%-30s";
else
fieldfmt = initblstats[i].fldfmt;
status_enablefield(fld, fieldname, fieldfmt, fldenabled);
}
update_all = TRUE;

View File

@@ -3542,7 +3542,7 @@ const char *dir UNUSED_if_not_OS2_CODEVIEW;
/* ---------- END SCOREBOARD CREATION ----------- */
/* ---------- BEGIN PANIC/IMPOSSIBLE LOG ----------- */
/* ---------- BEGIN PANIC/IMPOSSIBLE/TESTING LOG ----------- */
/*ARGSUSED*/
void
@@ -3579,7 +3579,31 @@ const char *reason; /* explanation */
return;
}
/* ---------- END PANIC/IMPOSSIBLE LOG ----------- */
/*ARGSUSED*/
void
testinglog(filenm, type, reason)
const char *filenm; /* ad hoc file name */
const char *type;
const char *reason; /* explanation */
{
FILE *lfile;
char fnbuf[BUFSZ];
if (!filenm) return;
Strcpy(fnbuf, filenm);
if (index(fnbuf, '.') == 0)
Strcat(fnbuf, ".log");
lfile = fopen_datafile(fnbuf, "a", TROUBLEPREFIX);
if (lfile) {
time_t now = getnow();
int uid = getuid();
(void) fprintf(lfile, "%s\n%s\n", type, reason);
(void) fclose(lfile);
}
return;
}
/* ---------- END PANIC/IMPOSSIBLE/TESTING LOG ----------- */
#ifdef SELF_RECOVER

View File

@@ -247,6 +247,78 @@ int glyph;
return encbuf;
}
const char *
decode_mixed(buf, str)
char *buf;
const char *str;
{
static const char hex[] = "00112233445566778899aAbBcCdDeEfF";
char *put = buf;
if (!put || !str)
return "";
while (*str) {
if (*str == '\\') {
int rndchk, dcount, so, gv, ch = 0, oc = 0;
unsigned os = 0;
const char *dp, *save_str;
save_str = str++;
switch (*str) {
case 'G': /* glyph value \GXXXXNNNN*/
rndchk = dcount = 0;
for (++str; *str && ++dcount <= 4; ++str)
if ((dp = index(hex, *str)) != 0)
rndchk = (rndchk * 16) + ((int) (dp - hex) / 2);
else
break;
if (rndchk == context.rndencode) {
gv = dcount = 0;
for (; *str && ++dcount <= 4; ++str)
if ((dp = index(hex, *str)) != 0)
gv = (gv * 16) + ((int) (dp - hex) / 2);
else
break;
so = mapglyph(gv, &ch, &oc, &os, 0, 0);
*put++ = showsyms[so];
/* 'str' is ready for the next loop iteration and '*str'
should not be copied at the end of this iteration */
continue;
} else {
/* possible forgery - leave it the way it is */
str = save_str;
}
break;
#if 0
case 'S': /* symbol offset */
so = rndchk = dcount = 0;
for (++str; *str && ++dcount <= 4; ++str)
if ((dp = index(hex, *str)) != 0)
rndchk = (rndchk * 16) + ((int) (dp - hex) / 2);
else
break;
if (rndchk == context.rndencode) {
dcount = 0;
for (; *str && ++dcount <= 2; ++str)
if ((dp = index(hex, *str)) != 0)
so = (so * 16) + ((int) (dp - hex) / 2);
else
break;
}
*put++ = showsyms[so];
break;
#endif
case '\\':
break;
}
}
*put++ = *str++;
}
*put = '\0';
return buf;
}
/*
* This differs from putstr() because the str parameter can
* contain a sequence of characters representing:
@@ -265,71 +337,9 @@ winid window;
int attr;
const char *str;
{
static const char hex[] = "00112233445566778899aAbBcCdDeEfF";
char buf[BUFSZ];
const char *cp = str;
char *put = buf;
while (*cp) {
if (*cp == '\\') {
int rndchk, dcount, so, gv, ch = 0, oc = 0;
unsigned os = 0;
const char *dp, *save_cp;
save_cp = cp++;
switch (*cp) {
case 'G': /* glyph value \GXXXXNNNN*/
rndchk = dcount = 0;
for (++cp; *cp && ++dcount <= 4; ++cp)
if ((dp = index(hex, *cp)) != 0)
rndchk = (rndchk * 16) + ((int) (dp - hex) / 2);
else
break;
if (rndchk == context.rndencode) {
gv = dcount = 0;
for (; *cp && ++dcount <= 4; ++cp)
if ((dp = index(hex, *cp)) != 0)
gv = (gv * 16) + ((int) (dp - hex) / 2);
else
break;
so = mapglyph(gv, &ch, &oc, &os, 0, 0);
*put++ = showsyms[so];
/* 'cp' is ready for the next loop iteration and '*cp'
should not be copied at the end of this iteration */
continue;
} else {
/* possible forgery - leave it the way it is */
cp = save_cp;
}
break;
#if 0
case 'S': /* symbol offset */
so = rndchk = dcount = 0;
for (++cp; *cp && ++dcount <= 4; ++cp)
if ((dp = index(hex, *cp)) != 0)
rndchk = (rndchk * 16) + ((int) (dp - hex) / 2);
else
break;
if (rndchk == context.rndencode) {
dcount = 0;
for (; *cp && ++dcount <= 2; ++cp)
if ((dp = index(hex, *cp)) != 0)
so = (so * 16) + ((int) (dp - hex) / 2);
else
break;
}
*put++ = showsyms[so];
break;
#endif
case '\\':
break;
}
}
*put++ = *cp++;
}
*put = '\0';
/* now send it to the normal putstr */
putstr(window, attr, buf);
putstr(window, attr, decode_mixed(buf, str));
}
/*mapglyph.c*/

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 mon.c $NHDT-Date: 1522540516 2018/03/31 23:55:16 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.250 $ */
/* NetHack 3.6 mon.c $NHDT-Date: 1526132509 2018/05/12 13:41:49 $ $NHDT-Branch: master $:$NHDT-Revision: 1.252 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Derek S. Ray, 2015. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1876,9 +1876,13 @@ register struct monst *mtmp;
else
mtmp->cham = mndx;
if (canspotmon(mtmp)) {
const char *whom = mtmp->data->mname;
/* was using a_monnam(mtmp) but that's weird if mtmp is named:
"Dracula suddenly transforms and rises as Dracula" */
pline(upstart(buf), an(mtmp->data->mname));
if (!type_is_pname(mtmp->data))
whom = an(whom);
pline(upstart(buf), whom);
vamp_rise_msg = TRUE;
}
newsym(x, y);

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 options.c $NHDT-Date: 1510963525 2017/11/18 00:05:25 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.319 $ */
/* NetHack 3.6 options.c $NHDT-Date: 1526112322 2018/05/12 08:05:22 $ $NHDT-Branch: master $:$NHDT-Revision: 1.323 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */
@@ -263,7 +263,7 @@ static struct Comp_Opt {
DISP_IN_GAME },
{ "align_message", "message window alignment", 20, DISP_IN_GAME }, /*WC*/
{ "align_status", "status window alignment", 20, DISP_IN_GAME }, /*WC*/
{ "altkeyhandler", "alternate key handler", 20, DISP_IN_GAME },
{ "altkeyhandler", "alternate key handler", 20, SET_IN_GAME },
#ifdef BACKWARD_COMPAT
{ "boulder", "deprecated (use S_boulder in sym file instead)", 1,
SET_IN_GAME },
@@ -2651,9 +2651,8 @@ boolean tinitial, tfrom_file;
bad_negation(fullname, FALSE);
return FALSE;
} else if ((op = string_for_opt(opts, negated)) != 0) {
#ifdef WIN32
(void) strncpy(iflags.altkeyhandler, op, MAX_ALTKEYHANDLER - 5);
load_keyboard_handler();
#if defined(WIN32CON)
set_altkeyhandler(op);
#endif
} else
return FALSE;
@@ -4821,7 +4820,7 @@ boolean setinitial, setfromfile;
if (strlen(tmp->pattern) > ln)
Strcat(strncat(mtbuf, tmp->pattern, ln - 3), "...\"");
else
Strcat(mtbuf, "\"");
Strcat(strcat(mtbuf, tmp->pattern), "\"");
add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, mtbuf,
MENU_UNSELECTED);
tmp = tmp->next;