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
+8 -1
View File
@@ -368,6 +368,8 @@ add option status_updates to prevent bottom of screen status line updates
fix achievement recording bug with mines and sokoban prizes fix achievement recording bug with mines and sokoban prizes
g.cubes would eat globs of green slime without harm; engulf those instead g.cubes would eat globs of green slime without harm; engulf those instead
fix up true rumor about rock moles vs boots fix up true rumor about rock moles vs boots
Bell of Opening could trigger segfault attempting to open some types of traps
if hero was mounted
Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository Fixes to Post-3.6.0 Problems that Were Exposed Via git Repository
@@ -398,6 +400,9 @@ DUMPLOG: genocided and extinct species was always a blank line;
vanquished creatures was just a blank line if nothing had been killed vanquished creatures was just a blank line if nothing had been killed
DUMPLOG: RIP tombstone was printed for characters who survived (ascended, DUMPLOG: RIP tombstone was printed for characters who survived (ascended,
escaped dungeon, quit, trickery or panic) escaped dungeon, quit, trickery or panic)
artifact creation violated illiterate conduct when artifact name was assigned,
behavior intended only for creating Sting or Orcrist via naming
tty: revert to pline() for issuing prompts (override MSGTYPE=hide differently)
Platform- and/or Interface-Specific Fixes Platform- and/or Interface-Specific Fixes
@@ -422,6 +427,7 @@ tty: if "--More--" was written to leftmost column (beginning of second line)
of status line instead back on map) after message line was cleared of status line instead back on map) after message line was cleared
tty: long message lines which wrap when shown on the top line might be tty: long message lines which wrap when shown on the top line might be
re-displayed incorrectly by ^P for msg_window={full,combo,reverse} re-displayed incorrectly by ^P for msg_window={full,combo,reverse}
tty: MSGTYPE=hide could interfere with display of prompts
unix/X11: in top level Makefile, some commented out definitions of VARDATND unix/X11: in top level Makefile, some commented out definitions of VARDATND
misspelled pilemark.xbm (as pilemark.xpm) misspelled pilemark.xbm (as pilemark.xpm)
unix: options file with CR+LF line ends and an invalid option line resulted in unix: options file with CR+LF line ends and an invalid option line resulted in
@@ -566,7 +572,8 @@ Ray Chason's MS-DOS port restored to functionality with credit to Reddit user
Ray Chason's MSDOS port support for some VESA modes Ray Chason's MSDOS port support for some VESA modes
Darshan Shaligram's pet ranged attack Darshan Shaligram's pet ranged attack
Jason Dorje Short's key rebinding Jason Dorje Short's key rebinding
Maxime Bacoux's new dumplog Maxime Bacoux's new DUMPLOG: compile-time option to enable logging of
end-of-game information into a text file
Code Cleanup and Reorganization Code Cleanup and Reorganization
+3 -2
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 extern.h $NHDT-Date: 1489192904 2017/03/11 00:41:44 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.583 $ */ /* NetHack 3.6 extern.h $NHDT-Date: 1490908458 2017/03/30 21:14:18 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.585 $ */
/* Copyright (c) Steve Creps, 1988. */ /* Copyright (c) Steve Creps, 1988. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -211,7 +211,7 @@ E int FDECL(isok, (int, int));
E int FDECL(get_adjacent_loc, E int FDECL(get_adjacent_loc,
(const char *, const char *, XCHAR_P, XCHAR_P, coord *)); (const char *, const char *, XCHAR_P, XCHAR_P, coord *));
E const char *FDECL(click_to_cmd, (int, int, int)); E const char *FDECL(click_to_cmd, (int, int, int));
E char FDECL(get_count, (char *, CHAR_P, long, long *)); E char FDECL(get_count, (char *, CHAR_P, long, long *, BOOLEAN_P));
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
E void FDECL(hangup, (int)); E void FDECL(hangup, (int));
E void NDECL(end_of_input); E void NDECL(end_of_input);
@@ -1809,6 +1809,7 @@ E void FDECL(dumplogmsg, (const char *));
E void NDECL(dumplogfreemessages); E void NDECL(dumplogfreemessages);
#endif #endif
E void VDECL(pline, (const char *, ...)) PRINTF_F(1, 2); E void VDECL(pline, (const char *, ...)) PRINTF_F(1, 2);
E void VDECL(custompline, (unsigned, const char *, ...)) PRINTF_F(2, 3);
E void VDECL(Norep, (const char *, ...)) PRINTF_F(1, 2); E void VDECL(Norep, (const char *, ...)) PRINTF_F(1, 2);
E void NDECL(free_youbuf); E void NDECL(free_youbuf);
E void VDECL(You, (const char *, ...)) PRINTF_F(1, 2); E void VDECL(You, (const char *, ...)) PRINTF_F(1, 2);
+7 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 hack.h $NHDT-Date: 1451683048 2016/01/01 21:17:28 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.68 $ */ /* NetHack 3.6 hack.h $NHDT-Date: 1490908464 2017/03/30 21:14:24 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.76 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -359,6 +359,12 @@ enum explosion_types {
#define XKILL_NOCORPSE 2 #define XKILL_NOCORPSE 2
#define XKILL_NOCONDUCT 4 #define XKILL_NOCONDUCT 4
/* pline_flags; mask values for custompline()'s first argument */
/* #define PLINE_ORDINARY 0 */
#define PLINE_NOREPEAT 1
#define OVERRIDE_MSGTYPE 2
#define SUPPRESS_HISTORY 4
/* Macros for messages referring to hands, eyes, feet, etc... */ /* Macros for messages referring to hands, eyes, feet, etc... */
enum bodypart_types { enum bodypart_types {
ARM = 0, ARM = 0,
+40 -21
View File
@@ -2737,24 +2737,18 @@ int final;
/* Macros for meta and ctrl modifiers: /* Macros for meta and ctrl modifiers:
* M and C return the meta/ctrl code for the given character; * M and C return the meta/ctrl code for the given character;
* e.g., (C('c') is ctrl-c * 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 M
#ifndef NHSTDC #ifndef NHSTDC
#define M(c) (0x80 | (c)) #define M(c) (0x80 | (c))
#else #else
#define M(c) ((c) -128) #define M(c) ((c) - 128)
#endif /* NHSTDC */ #endif /* NHSTDC */
#endif #endif
#define ISMETA(c) (((c) & 0x80) != 0)
#define UNMETA(c) ((c) & 0x7f)
#ifndef C #ifndef C
#define C(c) (0x1f & (c)) #define C(c) (0x1f & (c))
#endif #endif
#define ISCTRL(c) ((uchar)(c) < 0x20)
#define UNCTRL(c) (ISCTRL(c) ? (0x60 | (c)) : (c))
/* ordered by command name */ /* ordered by command name */
struct ext_func_tab extcmdlist[] = { struct ext_func_tab extcmdlist[] = {
@@ -3727,27 +3721,25 @@ char *txt;
return '\0'; 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 */ * must be shorter than a tab for proper formatting */
char * char *
key2txt(c, txt) key2txt(c, txt)
uchar c; uchar c;
char *txt; /* sufficiently long buffer */ char *txt; /* sufficiently long buffer */
{ {
/* should probably switch to "SPC", "ESC", "RET"
since nethack's documentation uses ESC for <escape> */
if (c == ' ') if (c == ' ')
Sprintf(txt, "<space>"); Sprintf(txt, "<space>");
else if (c == '\033') else if (c == '\033')
Sprintf(txt, "<esc>"); Sprintf(txt, "<esc>");
else if (c == '\n') else if (c == '\n')
Sprintf(txt, "<enter>"); Sprintf(txt, "<enter>");
else if (ISCTRL(c)) else if (c == '\177')
Sprintf(txt, "^%c", highc(UNCTRL(c))); Sprintf(txt, "<del>"); /* "<delete>" won't fit */
else if (ISMETA(c))
Sprintf(txt, "M-%c", UNMETA(c));
else if (c >= 33 && c <= 126)
Sprintf(txt, "%c", c); /* regular keys: ! through ~ */
else else
Sprintf(txt, "A-%i", c); /* arbitrary ascii combinations */ Strcpy(txt, visctrl((char) c));
return txt; return txt;
} }
@@ -4579,11 +4571,12 @@ int x, y, mod;
} }
char char
get_count(allowchars, inkey, maxcount, count) get_count(allowchars, inkey, maxcount, count, historical)
char *allowchars; char *allowchars;
char inkey; char inkey;
long maxcount; long maxcount;
long *count; long *count;
boolean historical; /* whether to include in message history: True => yes */
{ {
char qbuf[QBUFSZ]; char qbuf[QBUFSZ];
int key; int key;
@@ -4624,10 +4617,19 @@ long *count;
Sprintf(qbuf, "Count: %ld", cnt); Sprintf(qbuf, "Count: %ld", cnt);
backspaced = FALSE; backspaced = FALSE;
} }
pline1(qbuf); /* bypassing pline() keeps intermediate prompt out of
DUMPLOG message history */
putstr(WIN_MESSAGE, 0, qbuf);
mark_synch(); mark_synch();
} }
} }
if (historical) {
Sprintf(qbuf, "Count: %ld ", *count);
(void) key2txt((uchar) key, eos(qbuf));
putmsghistory(qbuf, FALSE);
}
return key; return key;
} }
@@ -4653,7 +4655,7 @@ parse()
if (!Cmd.num_pad || (foo = readchar()) == Cmd.spkeys[NHKF_COUNT]) { if (!Cmd.num_pad || (foo = readchar()) == Cmd.spkeys[NHKF_COUNT]) {
long tmpmulti = multi; 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; last_multi = multi = tmpmulti;
} }
#ifdef ALTMETA #ifdef ALTMETA
@@ -4910,7 +4912,13 @@ yn_function(query, resp, def)
const char *query, *resp; const char *query, *resp;
char def; 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 */ iflags.last_msg = PLNMSG_UNKNOWN; /* most recent pline is clobbered */
@@ -4922,7 +4930,18 @@ char def;
Strcpy(&qbuf[QBUFSZ - 1 - 3], "..."); Strcpy(&qbuf[QBUFSZ - 1 - 3], "...");
query = qbuf; 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 */ /* for paranoid_confirm:quit,die,attack prompting */
+12 -6
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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -1011,10 +1011,12 @@ do_mname()
(void) christen_monst(mtmp, buf); (void) christen_monst(mtmp, buf);
} }
STATIC_VAR int via_naming = 0;
/* /*
* This routine changes the address of obj. Be careful not to call it * This routine used to change the address of 'obj' so be unsafe if not
* when there might be pointers around in unknown places. For now: only * used with extreme care. Applying a name to an object no longer
* when obj is in the inventory. * allocates a replacement object, so that old risk is gone.
*/ */
STATIC_OVL STATIC_OVL
void void
@@ -1079,7 +1081,9 @@ register struct obj *obj;
display_nhwindow(WIN_MESSAGE, FALSE); display_nhwindow(WIN_MESSAGE, FALSE);
You("engrave: \"%s\".", buf); You("engrave: \"%s\".", buf);
} }
++via_naming; /* This ought to be an argument rather than a static... */
obj = oname(obj, buf); obj = oname(obj, buf);
--via_naming; /* ...but oname() is used in a lot of places, so defer. */
} }
struct obj * struct obj *
@@ -1119,8 +1123,10 @@ const char *name;
/* if obj is owned by a shop, increase your bill */ /* if obj is owned by a shop, increase your bill */
if (obj->unpaid) if (obj->unpaid)
alter_cost(obj, 0L); alter_cost(obj, 0L);
/* violate illiteracy conduct since successfully wrote arti-name */ if (via_naming) {
u.uconduct.literate++; /* violate illiteracy conduct since successfully wrote arti-name */
u.uconduct.literate++;
}
} }
if (carried(obj)) if (carried(obj))
update_inventory(); update_inventory();
+5 -12
View File
@@ -166,16 +166,9 @@ const genericptr vptr2;
if ((namcmp = strcmpi(nam1, nam2)) != 0) if ((namcmp = strcmpi(nam1, nam2)) != 0)
return namcmp; return namcmp;
/* Sort by BUCX. Map blessed to 4, uncursed to 2, cursed to 1, and /* Sort by BUCX. */
unknown to 0. */ val1 = obj1->bknown ? (obj1->blessed ? 3 : !obj1->cursed ? 2 : 1) : 0;
val1 = obj1->bknown val2 = obj2->bknown ? (obj2->blessed ? 3 : !obj2->cursed ? 2 : 1) : 0;
? (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;
if (val1 != val2) if (val1 != val2)
return val2 - val1; /* bigger is better */ return val2 - val1; /* bigger is better */
@@ -216,7 +209,7 @@ tiebreak:
/* They're identical, as far as we're concerned. We want /* They're identical, as far as we're concerned. We want
to force a deterministic order, and do so by producing a to force a deterministic order, and do so by producing a
stable sort: maintain the original order of equal items. */ stable sort: maintain the original order of equal items. */
return (sli2->indx - sli1->indx); return (sli1->indx - sli2->indx);
} }
void void
@@ -1313,7 +1306,7 @@ register const char *let, *word;
pline("No count allowed with this command."); pline("No count allowed with this command.");
continue; continue;
} }
ilet = get_count(NULL, ilet, LARGEST_INT, &tmpcnt); ilet = get_count(NULL, ilet, LARGEST_INT, &tmpcnt, TRUE);
if (tmpcnt) { if (tmpcnt) {
cnt = tmpcnt; cnt = tmpcnt;
cntgiven = TRUE; cntgiven = TRUE;
+32 -10
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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -6,7 +6,7 @@
*/ */
#include "hack.h" #include "hack.h"
static boolean no_repeat = FALSE; static unsigned pline_flags = 0;
static char prevmsg[BUFSZ]; static char prevmsg[BUFSZ];
static char *FDECL(You_buf, (int)); 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() */ { /* start of vpline() or of nested block in USE_OLDARG's pline() */
char pbuf[3 * BUFSZ]; char pbuf[3 * BUFSZ];
int ln; int ln;
xchar msgtyp; int msgtyp;
boolean no_repeat;
/* Do NOT use VA_START and VA_END in here... see above */ /* Do NOT use VA_START and VA_END in here... see above */
if (!line || !*line) if (!line || !*line)
@@ -134,18 +135,23 @@ VA_DECL(const char *, line)
return; return;
} }
msgtyp = MSGTYP_NORMAL;
no_repeat = (pline_flags & PLINE_NOREPEAT) ? TRUE : FALSE;
#ifdef DUMPLOG #ifdef DUMPLOG
/* We hook here early to have options-agnostic output. /* We hook here early to have options-agnostic output.
* Unfortunately, that means Norep() isn't honored (general issue) and * Unfortunately, that means Norep() isn't honored (general issue) and
* that short lines aren't combined into one longer one (tty behavior). * that short lines aren't combined into one longer one (tty behavior).
*/ */
dumplogmsg(line); if ((pline_flags & SUPPRESS_HISTORY) == 0)
dumplogmsg(line);
#endif #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) if (vision_full_recalc)
vision_recalc(0); vision_recalc(0);
if (u.ux) if (u.ux)
@@ -170,15 +176,31 @@ VA_DECL(const char *, line)
#endif #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*/ /*VARARGS1*/
void Norep void Norep
VA_DECL(const char *, line) VA_DECL(const char *, line)
{ {
VA_START(line); VA_START(line);
VA_INIT(line, const char *); VA_INIT(line, const char *);
no_repeat = TRUE; pline_flags = PLINE_NOREPEAT;
vpline(line, VA_ARGS); vpline(line, VA_ARGS);
no_repeat = FALSE; pline_flags = 0;
VA_END(); VA_END();
return; return;
} }
+7 -1
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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* 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; const char *trapdescr, *which;
boolean ishero = (mon == &youmonst); boolean ishero = (mon == &youmonst);
if (!mon)
return FALSE;
if (mon == u.usteed) if (mon == u.usteed)
ishero = TRUE; ishero = TRUE;
t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my); 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; unsigned dotrapflags;
boolean ishero = (mon == &youmonst), result; boolean ishero = (mon == &youmonst), result;
if (!mon)
return FALSE;
if (mon == u.usteed) if (mon == u.usteed)
ishero = TRUE; ishero = TRUE;
t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my); 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; struct trap *t;
boolean ishero = (mon == &youmonst), result; boolean ishero = (mon == &youmonst), result;
if (!mon)
return FALSE;
if (mon == u.usteed) if (mon == u.usteed)
ishero = TRUE; ishero = TRUE;
t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my); t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my);
+27 -8
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 getline.c $NHDT-Date: 1432512813 2015/05/25 00:13:33 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */ /* NetHack 3.6 getline.c $NHDT-Date: 1490908467 2017/03/30 21:14:27 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.31 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -14,6 +14,7 @@
#include "func_tab.h" #include "func_tab.h"
char morc = 0; /* tell the outside world what char you chose */ char morc = 0; /* tell the outside world what char you chose */
STATIC_VAR boolean suppress_history;
STATIC_DCL boolean FDECL(ext_cmd_getlin_hook, (char *)); STATIC_DCL boolean FDECL(ext_cmd_getlin_hook, (char *));
typedef boolean FDECL((*getlin_hook_proc), (char *)); typedef boolean FDECL((*getlin_hook_proc), (char *));
@@ -35,6 +36,7 @@ tty_getlin(query, bufp)
const char *query; const char *query;
register char *bufp; register char *bufp;
{ {
suppress_history = FALSE;
hooked_tty_getlin(query, bufp, (getlin_hook_proc) 0); hooked_tty_getlin(query, bufp, (getlin_hook_proc) 0);
} }
@@ -54,7 +56,7 @@ getlin_hook_proc hook;
cw->flags &= ~WIN_STOP; cw->flags &= ~WIN_STOP;
ttyDisplay->toplin = 3; /* special prompt state */ ttyDisplay->toplin = 3; /* special prompt state */
ttyDisplay->inread++; ttyDisplay->inread++;
pline("%s ", query); custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s ", query);
*obufp = 0; *obufp = 0;
for (;;) { for (;;) {
(void) fflush(stdout); (void) fflush(stdout);
@@ -82,6 +84,7 @@ getlin_hook_proc hook;
if (c == '\020') { /* ctrl-P */ if (c == '\020') { /* ctrl-P */
if (iflags.prevmsg_window != 's') { if (iflags.prevmsg_window != 's') {
int sav = ttyDisplay->inread; int sav = ttyDisplay->inread;
ttyDisplay->inread = 0; ttyDisplay->inread = 0;
(void) tty_doprev_message(); (void) tty_doprev_message();
ttyDisplay->inread = sav; ttyDisplay->inread = sav;
@@ -136,9 +139,9 @@ getlin_hook_proc hook;
#endif /* not NEWAUTOCOMP */ #endif /* not NEWAUTOCOMP */
break; break;
} else if (' ' <= (unsigned char) c && c != '\177' } else if (' ' <= (unsigned char) c && c != '\177'
/* avoid isprint() - some people don't have it
' ' is not always a printing char */
&& (bufp - obufp < BUFSZ - 1 && bufp - obufp < COLNO)) { && (bufp - obufp < BUFSZ - 1 && bufp - obufp < COLNO)) {
/* avoid isprint() - some people don't have it
' ' is not always a printing char */
#ifdef NEWAUTOCOMP #ifdef NEWAUTOCOMP
char *i = eos(bufp); char *i = eos(bufp);
@@ -166,7 +169,7 @@ getlin_hook_proc hook;
#endif /* NEWAUTOCOMP */ #endif /* NEWAUTOCOMP */
} }
} else if (c == kill_char || c == '\177') { /* Robert Viduya */ } else if (c == kill_char || c == '\177') { /* Robert Viduya */
/* this test last - @ might be the kill_char */ /* this test last - @ might be the kill_char */
#ifndef NEWAUTOCOMP #ifndef NEWAUTOCOMP
while (bufp != obufp) { while (bufp != obufp) {
bufp--; bufp--;
@@ -185,6 +188,17 @@ getlin_hook_proc hook;
ttyDisplay->toplin = 2; /* nonempty, no --More-- required */ ttyDisplay->toplin = 2; /* nonempty, no --More-- required */
ttyDisplay->inread--; ttyDisplay->inread--;
clear_nhwindow(WIN_MESSAGE); /* clean up after ourselves */ clear_nhwindow(WIN_MESSAGE); /* clean up after ourselves */
if (suppress_history) {
/* prevent next message from pushing current query+answer into
tty message history */
*toplines = '\0';
#ifdef DUMPLOG
} else {
/* needed because we've bypassed pline() */
dumplogmsg(toplines);
#endif
}
} }
void void
@@ -267,9 +281,14 @@ tty_get_ext_cmd()
if (iflags.extmenu) if (iflags.extmenu)
return extcmd_via_menu(); return extcmd_via_menu();
/* maybe a runtime option? */
/* hooked_tty_getlin("#", buf, flags.cmd_comp ? ext_cmd_getlin_hook : suppress_history = TRUE;
* (getlin_hook_proc) 0); */ /* maybe a runtime option?
* hooked_tty_getlin("#", buf,
* (flags.cmd_comp && !in_doagain)
* ? ext_cmd_getlin_hook
* : (getlin_hook_proc) 0);
*/
hooked_tty_getlin("#", buf, in_doagain ? (getlin_hook_proc) 0 hooked_tty_getlin("#", buf, in_doagain ? (getlin_hook_proc) 0
: ext_cmd_getlin_hook); : ext_cmd_getlin_hook);
(void) mungspaces(buf); (void) mungspaces(buf);
+31 -10
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 topl.c $NHDT-Date: 1463787697 2016/05/20 23:41:37 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.33 $ */ /* NetHack 3.6 topl.c $NHDT-Date: 1490908468 2017/03/30 21:14:28 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.36 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -331,6 +331,7 @@ register int n;
extern char erase_char; /* from xxxtty.c; don't need kill_char */ extern char erase_char; /* from xxxtty.c; don't need kill_char */
/* returns a single keystroke; also sets 'yn_number' */
char char
tty_yn_function(query, resp, def) tty_yn_function(query, resp, def)
const char *query, *resp; const char *query, *resp;
@@ -354,6 +355,7 @@ char def;
boolean doprev = 0; boolean doprev = 0;
char prompt[BUFSZ]; char prompt[BUFSZ];
yn_number = 0L;
if (ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP)) if (ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP))
more(); more();
cw->flags &= ~WIN_STOP; cw->flags &= ~WIN_STOP;
@@ -383,11 +385,12 @@ char def;
/* not pline("%s ", prompt); /* not pline("%s ", prompt);
trailing space is wanted here in case of reprompt */ trailing space is wanted here in case of reprompt */
Strcat(prompt, " "); Strcat(prompt, " ");
pline("%s", prompt); custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s", prompt);
} else { } else {
/* no restriction on allowed response, so always preserve case */ /* no restriction on allowed response, so always preserve case */
/* preserve_case = TRUE; -- moot since we're jumping to the end */ /* preserve_case = TRUE; -- moot since we're jumping to the end */
pline("%s ", query); Sprintf(prompt, "%s ", query);
custompline(OVERRIDE_MSGTYPE | SUPPRESS_HISTORY, "%s", prompt);
q = readchar(); q = readchar();
goto clean_up; goto clean_up;
} }
@@ -444,6 +447,7 @@ char def;
char z, digit_string[2]; char z, digit_string[2];
int n_len = 0; int n_len = 0;
long value = 0; long value = 0;
addtopl("#"), n_len++; addtopl("#"), n_len++;
digit_string[1] = '\0'; digit_string[1] = '\0';
if (q != '#') { if (q != '#') {
@@ -491,11 +495,16 @@ char def;
} }
} while (!q); } while (!q);
if (q != '#') { clean_up:
Sprintf(rtmp, "%c", q); if (yn_number)
addtopl(rtmp); Sprintf(rtmp, "#%ld", yn_number);
} else
clean_up: (void) key2txt(q, rtmp);
/* addtopl(rtmp); -- rewrite toplines instead */
Sprintf(toplines, "%s%s", prompt, rtmp);
#ifdef DUMPLOG
dumplogmsg(toplines);
#endif
ttyDisplay->inread--; ttyDisplay->inread--;
ttyDisplay->toplin = 2; ttyDisplay->toplin = 2;
if (ttyDisplay->intr) if (ttyDisplay->intr)
@@ -636,6 +645,9 @@ boolean restoring_msghist;
{ {
static boolean initd = FALSE; static boolean initd = FALSE;
int idx; int idx;
#ifdef DUMPLOG
extern unsigned saved_pline_index; /* pline.c */
#endif
if (restoring_msghist && !initd) { if (restoring_msghist && !initd) {
/* we're restoring history from the previous session, but new /* we're restoring history from the previous session, but new
@@ -645,18 +657,27 @@ boolean restoring_msghist;
restored ones are being put into place */ restored ones are being put into place */
msghistory_snapshot(TRUE); msghistory_snapshot(TRUE);
initd = TRUE; initd = TRUE;
#ifdef DUMPLOG
/* this suffices; there's no need to scrub saved_pline[] pointers */
saved_pline_index = 0;
#endif
} }
if (msg) { if (msg) {
/* move most recent message to history, make this become most recent /* move most recent message to history, make this become most recent */
*/
remember_topl(); remember_topl();
Strcpy(toplines, msg); Strcpy(toplines, msg);
#ifdef DUMPLOG
dumplogmsg(toplines);
#endif
} else if (snapshot_mesgs) { } else if (snapshot_mesgs) {
/* done putting arbitrary messages in; put the snapshot ones back */ /* done putting arbitrary messages in; put the snapshot ones back */
for (idx = 0; snapshot_mesgs[idx]; ++idx) { for (idx = 0; snapshot_mesgs[idx]; ++idx) {
remember_topl(); remember_topl();
Strcpy(toplines, snapshot_mesgs[idx]); Strcpy(toplines, snapshot_mesgs[idx]);
#ifdef DUMPLOG
dumplogmsg(toplines);
#endif
} }
/* now release the snapshot */ /* now release the snapshot */
free_msghistory_snapshot(TRUE); free_msghistory_snapshot(TRUE);