Skip to content
Permalink
Browse files

noz's fix for #1212

* pete/staging:
  Minor correction to inscriptions - make \!k and \!v work.
  Better fix for #1212, along the lines of what takkaria had planned.
  Fix inscriptions on objects related to commands (fixes #1212)
  • Loading branch information...
magnate committed Nov 27, 2010
2 parents 94fed50 + 74a3557 commit 7911f2248a133dad6bb031787f02c782a4a978f3
Showing with 48 additions and 28 deletions.
  1. +1 −0 src/angband.h
  2. +1 −1 src/attack.c
  3. +2 −2 src/cmd-obj.c
  4. +23 −6 src/cmd0.c
  5. +1 −1 src/cmd1.c
  6. +1 −1 src/cmd3.c
  7. +1 −0 src/cmds.h
  8. +1 −2 src/game-cmd.c
  9. +2 −1 src/game-cmd.h
  10. +10 −9 src/object/obj-ui.c
  11. +1 −1 src/object/object.h
  12. +1 −1 src/store.c
  13. +3 −3 src/ui-spell.c
@@ -36,6 +36,7 @@
#include "defines.h"
#include "option.h"
#include "types.h"
#include "game-cmd.h"
#include "object/constants.h"
#include "object/types.h"
#include "object/object.h"
@@ -1168,7 +1168,7 @@ void textui_cmd_throw(void)
/* Get an item */
q = "Throw which item? ";
s = "You have nothing to throw.";
if (!get_item(&item, q, s, 't', (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
if (!get_item(&item, q, s, CMD_THROW, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;

if (item >= INVEN_WIELD && item < QUIVER_START)
{
@@ -378,7 +378,7 @@ void textui_obj_wield(object_type *o_ptr, int item)
cptr q = "Replace which ring? ";
cptr s = "Error in obj_wield, please report";
item_tester_hook = obj_is_ring;
if (!get_item(&slot, q, s, 'w', USE_EQUIP)) return;
if (!get_item(&slot, q, s, CMD_WIELD, USE_EQUIP)) return;
}

if (obj_is_ammo(o_ptr) && !object_similar(&p_ptr->inventory[slot],
@@ -387,7 +387,7 @@ void textui_obj_wield(object_type *o_ptr, int item)
cptr q = "Replace which ammunition? ";
cptr s = "Error in obj_wield, please report";
item_tester_hook = obj_is_ammo;
if (!get_item(&slot, q, s, 'w', USE_EQUIP)) return;
if (!get_item(&slot, q, s, CMD_WIELD, USE_EQUIP)) return;
}
}

@@ -134,7 +134,7 @@ static struct generic_command cmd_action[] =
{ "Jam a door shut", 'j', CMD_JAM, NULL },
{ "Bash a door open", 'B', CMD_BASH, NULL },
{ "Fire at nearest target", 'h', CMD_NULL, textui_cmd_fire_at_nearest },
{ "Throw an item", 'v', CMD_NULL, textui_cmd_throw }
{ "Throw an item", 'v', CMD_THROW, textui_cmd_throw }
};

/* Item management commands */
@@ -143,15 +143,15 @@ static struct generic_command cmd_item_manage[] =
{ "Display equipment listing", 'e', CMD_NULL, do_cmd_equip },
{ "Display inventory listing", 'i', CMD_NULL, do_cmd_inven },
{ "Pick up objects", 'g', CMD_PICKUP, NULL },
{ "Destroy an item", 'k', CMD_NULL, textui_cmd_destroy },
{ "Destroy an item", 'k', CMD_DESTROY, textui_cmd_destroy },

};

/* Information access commands */
static struct generic_command cmd_info[] =
{
{ "Browse a book", 'b', CMD_NULL, textui_spell_browse, NULL },
{ "Gain new spells", 'G', CMD_NULL, textui_obj_study, player_can_study },
{ "Browse a book", 'b', CMD_BROWSE_SPELL, textui_spell_browse, NULL },
{ "Gain new spells", 'G', CMD_STUDY_BOOK, textui_obj_study, player_can_study },
{ "Cast a spell", 'm', CMD_CAST, textui_obj_cast, player_can_cast },
{ "Cast a spell", 'p', CMD_CAST, textui_obj_cast, player_can_cast },
{ "Full dungeon map", 'M', CMD_NULL, do_cmd_view_map },
@@ -406,8 +406,21 @@ void cmd_init(void)
}
}

unsigned char cmd_lookup_key(cmd_code cmd)
{
unsigned int i;
struct generic_command *command;


for (i = 0; i < N_ELEMENTS(converted_list); i++)
{
command = converted_list[i].command;
if (command && command->cmd == cmd)
{
return command->key;
}
}
return 0;
}


/*** Input processing ***/
@@ -687,7 +700,7 @@ static bool textui_process_key(unsigned char c)
item_tester_hook = act->selector.filter;

if (!get_item(&item, act->selector.prompt,
act->selector.noop, c, act->selector.mode))
act->selector.noop, command->cmd, act->selector.mode))
return TRUE;

/* Execute the item command */
@@ -696,9 +709,13 @@ static bool textui_process_key(unsigned char c)
else
{
if (command->hook)
{
command->hook();
}
else
{
cmd_insert_repeated(command->cmd, p_ptr->command_arg);
}
}
}

@@ -567,7 +567,7 @@ byte py_pickup(int pickup)
/* Get an object or exit. */
q = "Get which item?";
s = "You see nothing there.";
if (!get_item(&item, q, s, 'g', USE_FLOOR))
if (!get_item(&item, q, s, CMD_PICKUP, USE_FLOOR))
return (objs_picked_up);

this_o_idx = 0 - item;
@@ -325,7 +325,7 @@ void textui_cmd_destroy(void)
/* Get an item */
q = "Destroy which item? ";
s = "You have nothing to destroy.";
if (!get_item(&item, q, s, 'k', (USE_INVEN | USE_EQUIP | USE_FLOOR | CAN_SQUELCH))) return;
if (!get_item(&item, q, s, CMD_DESTROY, (USE_INVEN | USE_EQUIP | USE_FLOOR | CAN_SQUELCH))) return;

/* Deal with squelched items */
if (item == ALL_SQUELCHED)
@@ -11,6 +11,7 @@ typedef void (*cmd_handler_fn)(cmd_code code, cmd_arg args[]);

/* cmd.c */
extern void cmd_init(void);
unsigned char cmd_lookup_key(cmd_code cmd);

/* cmd0.c */
void do_cmd_quit(cmd_code code, cmd_arg args[]);
@@ -348,7 +348,6 @@ void cmd_set_arg_number(game_command *cmd, int n, int num)
cmd->arg_present[n] = TRUE;
}


/*
* Inserts a command in the queue to be carried out, with the given
* number of repeats.
@@ -406,7 +405,7 @@ void process_command(cmd_context ctx, bool no_request)
int item;

item_tester_hook = is->filter;
if (!get_item(&item, is->prompt, is->noop, 0, is->mode))
if (!get_item(&item, is->prompt, is->noop, cmd->command, is->mode))
return;

cmd_set_arg_item(cmd, 0, item);
@@ -46,6 +46,7 @@ typedef enum cmd_code
CMD_TAKEOFF,
CMD_WIELD,
CMD_DROP,
CMD_BROWSE_SPELL,
CMD_STUDY_SPELL,
CMD_STUDY_BOOK,
CMD_CAST, /* Casting a spell /or/ praying. */
@@ -150,7 +151,7 @@ typedef struct game_command
cmd_code command;

/* Number of times to attempt to repeat command. */
int nrepeats;
int nrepeats;

/* Arguments to the command */
cmd_arg arg[CMD_MAX_ARGS];
@@ -19,7 +19,7 @@
#include "angband.h"
#include "button.h"
#include "tvalsval.h"

#include "cmds.h"

/*
* Display a list of objects. Each object may be prefixed with a label.
@@ -422,7 +422,7 @@ bool verify_item(cptr prompt, int item)
*
* The item can be negative to mean "item on floor".
*/
static bool get_item_allow(int item, char ch, bool is_harmless)
static bool get_item_allow(int item, unsigned char ch, bool is_harmless)
{
object_type *o_ptr;
char verify_inscrip[] = "!*";
@@ -578,10 +578,11 @@ static int get_tag(int *cp, char tag, char cmdkey, bool quiver_tags)
* Note that only "acceptable" floor objects get indexes, so between two
* commands, the indexes of floor objects may change. XXX XXX XXX
*/
bool get_item(int *cp, cptr pmt, cptr str, char c, int mode)
bool get_item(int *cp, cptr pmt, cptr str, cmd_code cmd, int mode)
{
int py = p_ptr->py;
int px = p_ptr->px;
unsigned char cmdkey = cmd_lookup_key(cmd);

ui_event_data which;

@@ -1011,7 +1012,7 @@ bool get_item(int *cp, cptr pmt, cptr str, char c, int mode)
k = 0 - floor_list[0];

/* Allow player to "refuse" certain actions */
if (!get_item_allow(k, c, is_harmless))
if (!get_item_allow(k, cmdkey, is_harmless))
{
done = TRUE;
break;
@@ -1049,7 +1050,7 @@ bool get_item(int *cp, cptr pmt, cptr str, char c, int mode)
if (!get_item_okay(k)) continue;

/* Allow player to "refuse" certain actions */
if (!get_item_allow(k, c, is_harmless)) continue;
if (!get_item_allow(k, cmdkey, is_harmless)) continue;

/* Accept that choice */
(*cp) = k;
@@ -1068,7 +1069,7 @@ bool get_item(int *cp, cptr pmt, cptr str, char c, int mode)
case '7': case '8': case '9':
{
/* Look up the tag */
if (!get_tag(&k, which.key, c, quiver_tags))
if (!get_tag(&k, which.key, cmdkey, quiver_tags))
{
bell("Illegal object choice (tag)!");
break;
@@ -1089,7 +1090,7 @@ bool get_item(int *cp, cptr pmt, cptr str, char c, int mode)
}

/* Allow player to "refuse" certain actions */
if (!get_item_allow(k, c, is_harmless))
if (!get_item_allow(k, cmdkey, is_harmless))
{
done = TRUE;
break;
@@ -1153,7 +1154,7 @@ bool get_item(int *cp, cptr pmt, cptr str, char c, int mode)
}

/* Allow player to "refuse" certain actions */
if (!get_item_allow(k, c, is_harmless))
if (!get_item_allow(k, cmdkey, is_harmless))
{
done = TRUE;
break;
@@ -1244,7 +1245,7 @@ bool get_item(int *cp, cptr pmt, cptr str, char c, int mode)
}

/* Allow player to "refuse" certain actions */
if (!get_item_allow(k, c, is_harmless))
if (!get_item_allow(k, cmdkey, is_harmless))
{
done = TRUE;
break;
@@ -173,7 +173,7 @@ void show_inven(olist_detail_t mode);
void show_equip(olist_detail_t mode);
void show_floor(const int *floor_list, int floor_num, olist_detail_t mode);
bool verify_item(cptr prompt, int item);
bool get_item(int *cp, cptr pmt, cptr str, char c, int mode);
bool get_item(int *cp, cptr pmt, cptr str, cmd_code cmd, int mode);

/* obj-util.c */
object_kind *objkind_get(int tval, int sval);
@@ -2718,7 +2718,7 @@ static bool store_sell(void)
/* Get an item */
p_ptr->command_wrk = USE_INVEN;

if (!get_item(&item, prompt, reject, 'd', get_mode))
if (!get_item(&item, prompt, reject, CMD_DROP, get_mode))
return FALSE;

/* Get the item */
@@ -287,7 +287,7 @@ void textui_spell_browse(void)
item_tester_hook = obj_can_browse;
if (!get_item(&item, "Browse which book? ",
"You have no books that you can read.",
'b', (USE_INVEN | USE_FLOOR | IS_HARMLESS)))
CMD_BROWSE_SPELL, (USE_INVEN | USE_FLOOR | IS_HARMLESS)))
return;

/* Track the object kind */
@@ -307,7 +307,7 @@ void textui_obj_study(void)
item_tester_hook = obj_can_study;
if (!get_item(&item, "Study which book? ",
"You have no books that you can read.",
'G', (USE_INVEN | USE_FLOOR)))
CMD_STUDY_BOOK, (USE_INVEN | USE_FLOOR)))
return;

track_object(item);
@@ -339,7 +339,7 @@ void textui_obj_cast(void)
item_tester_hook = obj_can_cast_from;
if (!get_item(&item, "Cast from which book? ",
"You have no books that you can read.",
'm', (USE_INVEN | USE_FLOOR)))
CMD_CAST, (USE_INVEN | USE_FLOOR)))
return;

/* Track the object kind */

0 comments on commit 7911f22

Please sign in to comment.
You can’t perform that action at this time.