extern void cmdq_add_dir(schar, schar, schar);
extern void cmdq_add_userinput(void);
extern struct _cmd_queue *cmdq_pop(void);
+extern struct _cmd_queue *cmdq_peek(void);
extern void cmdq_clear(void);
extern char pgetchar(void);
extern void pushch(char);
void
cmdq_add_dir(schar dx, schar dy, schar dz)
{
- struct _cmd_queue *tmp = (struct _cmd_queue *)alloc(sizeof(struct _cmd_queue));
+ struct _cmd_queue *tmp = (struct _cmd_queue *) alloc(sizeof *tmp);
struct _cmd_queue *cq = g.command_queue;
tmp->typ = CMDQ_DIR;
void
cmdq_add_userinput(void)
{
- struct _cmd_queue *tmp = (struct _cmd_queue *)alloc(sizeof(struct _cmd_queue));
+ struct _cmd_queue *tmp = (struct _cmd_queue *) alloc(sizeof *tmp);
struct _cmd_queue *cq = g.command_queue;
tmp->typ = CMDQ_USER_INPUT;
return tmp;
}
+/* get the top entry without popping it */
+struct _cmd_queue *
+cmdq_peek(void)
+{
+ return g.command_queue;
+}
+
/* clear all commands from the command queue */
void
cmdq_clear(void)
pline("Not wearing any armor or accessories.");
return ECMD_OK;
}
- if (Narmorpieces != 1 || ParanoidRemove || g.command_queue)
+ if (Narmorpieces != 1 || ParanoidRemove || cmdq_peek())
otmp = getobj("take off", takeoff_ok, GETOBJ_NOFLAGS);
if (!otmp)
return ECMD_CANCEL;
pline("Not wearing any accessories or armor.");
return ECMD_OK;
}
- if (Naccessories != 1 || ParanoidRemove || g.command_queue)
+ if (Naccessories != 1 || ParanoidRemove || cmdq_peek())
otmp = getobj("remove", remove_ok, GETOBJ_NOFLAGS);
if (!otmp)
return ECMD_CANCEL;
* Object may be either on floor or in inventory.
*/
struct obj *
-floorfood(const char *verb,
- int corpsecheck) /* 0, no check, 1, corpses, 2, tinnable corpses */
+floorfood(
+ const char *verb,
+ int corpsecheck) /* 0, no check, 1, corpses, 2, tinnable corpses */
{
register struct obj *otmp;
char qbuf[QBUFSZ];
boolean feeding = !strcmp(verb, "eat"), /* corpsecheck==0 */
offering = !strcmp(verb, "sacrifice"); /* corpsecheck==1 */
- /* if we can't touch floor objects then use invent food only */
- if (iflags.menu_requested /* command was preceded by 'm' prefix */
+ /* if we can't touch floor objects then use invent food only;
+ same if 'm' prefix was used or we're executing an item action
+ for context-sensitive inventory */
+ if (iflags.menu_requested || cmdq_peek()
|| !can_reach_floor(TRUE) || (feeding && u.usteed)
|| (is_pool_or_lava(u.ux, u.uy)
&& (Wwalking || is_clinger(uptr) || (Flying && !Breathless))))