Merge remote-tracking branch 'origin/NetHack-3.6.0'

This commit is contained in:
keni
2017-03-31 14:00:11 -04:00
10 changed files with 172 additions and 72 deletions

View File

@@ -2737,24 +2737,18 @@ int final;
/* Macros for meta and ctrl modifiers:
* M and C return the meta/ctrl code for the given character;
* e.g., (C('c') is ctrl-c
* ISMETA and ISCTRL return TRUE iff the code is a meta/ctrl code
* UNMETA and UNCTRL are the opposite of M/C and return the key for a given
* meta/ctrl code. */
*/
#ifndef M
#ifndef NHSTDC
#define M(c) (0x80 | (c))
#else
#define M(c) ((c) -128)
#define M(c) ((c) - 128)
#endif /* NHSTDC */
#endif
#define ISMETA(c) (((c) & 0x80) != 0)
#define UNMETA(c) ((c) & 0x7f)
#ifndef C
#define C(c) (0x1f & (c))
#endif
#define ISCTRL(c) ((uchar)(c) < 0x20)
#define UNCTRL(c) (ISCTRL(c) ? (0x60 | (c)) : (c))
/* ordered by command name */
struct ext_func_tab extcmdlist[] = {
@@ -3727,27 +3721,25 @@ char *txt;
return '\0';
}
/* returns the text for a one-byte encoding
/* returns the text for a one-byte encoding;
* must be shorter than a tab for proper formatting */
char *
key2txt(c, txt)
uchar c;
char *txt; /* sufficiently long buffer */
{
/* should probably switch to "SPC", "ESC", "RET"
since nethack's documentation uses ESC for <escape> */
if (c == ' ')
Sprintf(txt, "<space>");
else if (c == '\033')
Sprintf(txt, "<esc>");
else if (c == '\n')
Sprintf(txt, "<enter>");
else if (ISCTRL(c))
Sprintf(txt, "^%c", highc(UNCTRL(c)));
else if (ISMETA(c))
Sprintf(txt, "M-%c", UNMETA(c));
else if (c >= 33 && c <= 126)
Sprintf(txt, "%c", c); /* regular keys: ! through ~ */
else if (c == '\177')
Sprintf(txt, "<del>"); /* "<delete>" won't fit */
else
Sprintf(txt, "A-%i", c); /* arbitrary ascii combinations */
Strcpy(txt, visctrl((char) c));
return txt;
}
@@ -4579,11 +4571,12 @@ int x, y, mod;
}
char
get_count(allowchars, inkey, maxcount, count)
get_count(allowchars, inkey, maxcount, count, historical)
char *allowchars;
char inkey;
long maxcount;
long *count;
boolean historical; /* whether to include in message history: True => yes */
{
char qbuf[QBUFSZ];
int key;
@@ -4624,10 +4617,19 @@ long *count;
Sprintf(qbuf, "Count: %ld", cnt);
backspaced = FALSE;
}
pline1(qbuf);
/* bypassing pline() keeps intermediate prompt out of
DUMPLOG message history */
putstr(WIN_MESSAGE, 0, qbuf);
mark_synch();
}
}
if (historical) {
Sprintf(qbuf, "Count: %ld ", *count);
(void) key2txt((uchar) key, eos(qbuf));
putmsghistory(qbuf, FALSE);
}
return key;
}
@@ -4653,7 +4655,7 @@ parse()
if (!Cmd.num_pad || (foo = readchar()) == Cmd.spkeys[NHKF_COUNT]) {
long tmpmulti = multi;
foo = get_count((char *) 0, '\0', LARGEST_INT, &tmpmulti);
foo = get_count((char *) 0, '\0', LARGEST_INT, &tmpmulti, FALSE);
last_multi = multi = tmpmulti;
}
#ifdef ALTMETA
@@ -4910,7 +4912,13 @@ yn_function(query, resp, def)
const char *query, *resp;
char def;
{
char qbuf[QBUFSZ];
char res, qbuf[QBUFSZ];
#ifdef DUMPLOG
extern unsigned saved_pline_index; /* pline.c */
unsigned idx = saved_pline_index;
/* buffer to hold query+space+formatted_single_char_response */
char dumplog_buf[QBUFSZ + 1 + 15]; /* [QBUFSZ+1+7] should suffice */
#endif
iflags.last_msg = PLNMSG_UNKNOWN; /* most recent pline is clobbered */
@@ -4922,7 +4930,18 @@ char def;
Strcpy(&qbuf[QBUFSZ - 1 - 3], "...");
query = qbuf;
}
return (*windowprocs.win_yn_function)(query, resp, def);
res = (*windowprocs.win_yn_function)(query, resp, def);
#ifdef DUMPLOG
if (idx == saved_pline_index) {
/* when idx is still the same as saved_pline_index, the interface
didn't put the prompt into saved_plines[]; we put a simplified
version in there now (without response choices or default) */
Sprintf(dumplog_buf, "%s ", query);
(void) key2txt((uchar) res, eos(dumplog_buf));
dumplogmsg(dumplog_buf);
}
#endif
return res;
}
/* for paranoid_confirm:quit,die,attack prompting */

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 do_name.c $NHDT-Date: 1452669022 2016/01/13 07:10:22 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.90 $ */
/* NetHack 3.6 do_name.c $NHDT-Date: 1489494376 2017/03/14 12:26:16 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.116 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1011,10 +1011,12 @@ do_mname()
(void) christen_monst(mtmp, buf);
}
STATIC_VAR int via_naming = 0;
/*
* This routine changes the address of obj. Be careful not to call it
* when there might be pointers around in unknown places. For now: only
* when obj is in the inventory.
* This routine used to change the address of 'obj' so be unsafe if not
* used with extreme care. Applying a name to an object no longer
* allocates a replacement object, so that old risk is gone.
*/
STATIC_OVL
void
@@ -1079,7 +1081,9 @@ register struct obj *obj;
display_nhwindow(WIN_MESSAGE, FALSE);
You("engrave: \"%s\".", buf);
}
++via_naming; /* This ought to be an argument rather than a static... */
obj = oname(obj, buf);
--via_naming; /* ...but oname() is used in a lot of places, so defer. */
}
struct obj *
@@ -1119,8 +1123,10 @@ 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 (via_naming) {
/* violate illiteracy conduct since successfully wrote arti-name */
u.uconduct.literate++;
}
}
if (carried(obj))
update_inventory();

View File

@@ -166,16 +166,9 @@ const genericptr vptr2;
if ((namcmp = strcmpi(nam1, nam2)) != 0)
return namcmp;
/* Sort by BUCX. Map blessed to 4, uncursed to 2, cursed to 1, and
unknown to 0. */
val1 = obj1->bknown
? (obj1->blessed << 2)
+ ((!obj1->blessed && !obj1->cursed) << 1) + obj1->cursed
: 0;
val2 = obj2->bknown
? (obj2->blessed << 2)
+ ((!obj2->blessed && !obj2->cursed) << 1) + obj2->cursed
: 0;
/* Sort by BUCX. */
val1 = obj1->bknown ? (obj1->blessed ? 3 : !obj1->cursed ? 2 : 1) : 0;
val2 = obj2->bknown ? (obj2->blessed ? 3 : !obj2->cursed ? 2 : 1) : 0;
if (val1 != val2)
return val2 - val1; /* bigger is better */
@@ -216,7 +209,7 @@ tiebreak:
/* They're identical, as far as we're concerned. We want
to force a deterministic order, and do so by producing a
stable sort: maintain the original order of equal items. */
return (sli2->indx - sli1->indx);
return (sli1->indx - sli2->indx);
}
void
@@ -1313,7 +1306,7 @@ register const char *let, *word;
pline("No count allowed with this command.");
continue;
}
ilet = get_count(NULL, ilet, LARGEST_INT, &tmpcnt);
ilet = get_count(NULL, ilet, LARGEST_INT, &tmpcnt, TRUE);
if (tmpcnt) {
cnt = tmpcnt;
cntgiven = TRUE;

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 pline.c $NHDT-Date: 1489192905 2017/03/11 00:41:45 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.57 $ */
/* NetHack 3.6 pline.c $NHDT-Date: 1490908465 2017/03/30 21:14:25 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.58 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -6,7 +6,7 @@
*/
#include "hack.h"
static boolean no_repeat = FALSE;
static unsigned pline_flags = 0;
static char prevmsg[BUFSZ];
static char *FDECL(You_buf, (int));
@@ -98,7 +98,8 @@ VA_DECL(const char *, line)
{ /* start of vpline() or of nested block in USE_OLDARG's pline() */
char pbuf[3 * BUFSZ];
int ln;
xchar msgtyp;
int msgtyp;
boolean no_repeat;
/* Do NOT use VA_START and VA_END in here... see above */
if (!line || !*line)
@@ -134,18 +135,23 @@ VA_DECL(const char *, line)
return;
}
msgtyp = MSGTYP_NORMAL;
no_repeat = (pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE;
#ifdef DUMPLOG
/* We hook here early to have options-agnostic output.
* Unfortunately, that means Norep() isn't honored (general issue) and
* that short lines aren't combined into one longer one (tty behavior).
*/
dumplogmsg(line);
if ((pline_flags & SUPPRESS_HISTORY) == 0)
dumplogmsg(line);
#endif
if ((pline_flags & OVERRIDE_MSGTYPE) != 0) {
msgtyp = msgtype_type(line, no_repeat);
if (msgtyp == MSGTYP_NOSHOW
|| (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg)))
return;
}
msgtyp = msgtype_type(line, no_repeat);
if (msgtyp == MSGTYP_NOSHOW
|| (msgtyp == MSGTYP_NOREP && !strcmp(line, prevmsg)))
return;
if (vision_full_recalc)
vision_recalc(0);
if (u.ux)
@@ -170,15 +176,31 @@ VA_DECL(const char *, line)
#endif
}
/* pline() variant which can override MSGTYPE handling or suppress
message history (tty interface uses pline() to issue prompts and
they shouldn't be blockable via MSGTYPE=hide) */
/*VARARGS2*/
void custompline
VA_DECL2(unsigned, pflags, const char *, line)
{
VA_START(line);
VA_INIT(line, const char *);
pline_flags = pflags;
vpline(line, VA_ARGS);
pline_flags = 0;
VA_END();
return;
}
/*VARARGS1*/
void Norep
VA_DECL(const char *, line)
{
VA_START(line);
VA_INIT(line, const char *);
no_repeat = TRUE;
pline_flags = PLINE_NOREPEAT;
vpline(line, VA_ARGS);
no_repeat = FALSE;
pline_flags = 0;
VA_END();
return;
}

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 trap.c $NHDT-Date: 1473665044 2016/09/12 07:24:04 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.274 $ */
/* NetHack 3.6 trap.c $NHDT-Date: 1489745987 2017/03/17 10:19:47 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.277 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -4420,6 +4420,8 @@ boolean *noticed; /* set to true iff hero notices the effect; */
const char *trapdescr, *which;
boolean ishero = (mon == &youmonst);
if (!mon)
return FALSE;
if (mon == u.usteed)
ishero = TRUE;
t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my);
@@ -4478,6 +4480,8 @@ boolean *noticed; /* set to true iff hero notices the effect; */
unsigned dotrapflags;
boolean ishero = (mon == &youmonst), result;
if (!mon)
return FALSE;
if (mon == u.usteed)
ishero = TRUE;
t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my);
@@ -4521,6 +4525,8 @@ boolean *noticed; /* set to true iff hero notices the effect; */
struct trap *t;
boolean ishero = (mon == &youmonst), result;
if (!mon)
return FALSE;
if (mon == u.usteed)
ishero = TRUE;
t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my);