fix wiz identify bugs

Fixes #124

Fix github pull request #124 which was also reported directly (but not
through the contact form so #Hxxx number).  Using ^I or #wizidentify
displays inventory with everything ID'd for that command only and adds
a menu entry "_ - use '^I' to identify" that can be chosen to make
those ID's persistent.  Picking underscore would work but picking the
alternate '^I' wouldn't work if the platform had unsigned characters
for plain 'char'.  Switch the return value from magic number -1 to
magic number ^I which isn't a valid inventory letter and isn't subject
to sign conversion.  Casting -1 to '(char) -1' would have worked too
despite some confusion expressed in discussion of the pull request.

If ^I has been bound to some other command and #wizidentify hasn't
been bound to any keystroke, temporary ID didn't disclose any extra
information (ie, acted like ordinary inventory display) and the extra
menu entry to make temporary ID become persistent wasn't available.
This fixes that too.
This commit is contained in:
PatR
2018-08-29 19:19:49 -07:00
parent 9457fde9fc
commit f1d0636ba0
4 changed files with 44 additions and 20 deletions

View File

@@ -5,6 +5,10 @@
#include "hack.h"
#ifndef C /* same as cmd.c */
#define C(c) (0x1f & (c))
#endif
#define NOINVSYM '#'
#define CONTAINED_SYM '>' /* designator for inside a container */
#define HANDS_SYM '-'
@@ -2580,9 +2584,15 @@ long *out_cnt;
if (wizard && iflags.override_ID) {
char prompt[QBUFSZ];
any.a_char = -1;
/* C('I') == ^I == default keystroke for wiz_identify;
it is guaranteed not to be in use as an inventory letter
(wiz_identify might be remapped to an ordinary letter,
making iflags.override_ID ambiguous as a return value) */
any.a_char = C('I');
/* wiz_identify stuffed the wiz_identify command character (^I)
into iflags.override_ID for our use as an accelerator */
into iflags.override_ID for our use as an accelerator;
it could be ambiguous as a selector but the only time it
is wanted is in case where no item is being selected */
Sprintf(prompt, "Debug Identify (%s to permanently identify)",
visctrl(iflags.override_ID));
add_menu(win, NO_GLYPH, &any, '_', iflags.override_ID, ATR_NONE,