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:
44
src/cmd.c
44
src/cmd.c
@@ -7,6 +7,22 @@
|
||||
#include "lev.h"
|
||||
#include "func_tab.h"
|
||||
|
||||
/* 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
|
||||
*/
|
||||
#ifndef M
|
||||
#ifndef NHSTDC
|
||||
#define M(c) (0x80 | (c))
|
||||
#else
|
||||
#define M(c) ((c) - 128)
|
||||
#endif /* NHSTDC */
|
||||
#endif
|
||||
|
||||
#ifndef C
|
||||
#define C(c) (0x1f & (c))
|
||||
#endif
|
||||
|
||||
#ifdef ALTMETA
|
||||
STATIC_VAR boolean alt_esc = FALSE;
|
||||
#endif
|
||||
@@ -625,8 +641,18 @@ wiz_identify(VOID_ARGS)
|
||||
{
|
||||
if (wizard) {
|
||||
iflags.override_ID = (int) cmd_from_func(wiz_identify);
|
||||
if (display_inventory((char *) 0, TRUE) == -1)
|
||||
/* command remapping might leave #wizidentify as the only way
|
||||
to invoke us, in which case cmd_from_func() will yield NUL;
|
||||
it won't matter to display_inventory()/display_pickinv()
|
||||
if ^I invokes some other command--what matters is that it
|
||||
is never an inventory letter */
|
||||
if (!iflags.override_ID)
|
||||
iflags.override_ID = C('I');
|
||||
/* C('I') == ^I == default keystroke for wiz_identify;
|
||||
it doesn't matter whether the command has been remapped */
|
||||
if (display_inventory((char *) 0, TRUE) == C('I'))
|
||||
identify_pack(0, FALSE);
|
||||
/* [TODO? if player picks a specific inventory item, ID it] */
|
||||
iflags.override_ID = 0;
|
||||
} else
|
||||
pline("Unavailable command '%s'.",
|
||||
@@ -2859,22 +2885,6 @@ int final;
|
||||
en_win = WIN_ERR;
|
||||
}
|
||||
|
||||
/* 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
|
||||
*/
|
||||
#ifndef M
|
||||
#ifndef NHSTDC
|
||||
#define M(c) (0x80 | (c))
|
||||
#else
|
||||
#define M(c) ((c) - 128)
|
||||
#endif /* NHSTDC */
|
||||
#endif
|
||||
|
||||
#ifndef C
|
||||
#define C(c) (0x1f & (c))
|
||||
#endif
|
||||
|
||||
/* ordered by command name */
|
||||
struct ext_func_tab extcmdlist[] = {
|
||||
{ '#', "#", "perform an extended command",
|
||||
|
||||
Reference in New Issue
Block a user