| 3624 | } |
| 3625 | |
| 3626 | void |
| 3627 | rhack(int key) |
| 3628 | { |
| 3629 | boolean bad_command, firsttime = (key == 0); |
| 3630 | struct _cmd_queue cq, *cmdq = NULL; |
| 3631 | const struct ext_func_tab *cmdq_ec = 0, *prefix_seen = 0; |
| 3632 | boolean was_m_prefix = FALSE; |
| 3633 | int (*func)(void) = dummyfunction; |
| 3634 | |
| 3635 | iflags.menu_requested = FALSE; |
| 3636 | svc.context.nopick = 0; |
| 3637 | got_prefix_input: |
| 3638 | #ifdef SAFERHANGUP |
| 3639 | if (program_state.done_hup) |
| 3640 | end_of_input(); |
| 3641 | #endif |
| 3642 | if ((cmdq = cmdq_pop()) != 0) { |
| 3643 | /* doing queued commands */ |
| 3644 | cq = *cmdq; |
| 3645 | free(cmdq); |
| 3646 | if (cq.typ == CMDQ_EXTCMD && (cmdq_ec = cq.ec_entry) != 0) |
| 3647 | goto do_cmdq_extcmd; |
| 3648 | /* already handled a queued command (goto do_cmdq_extcmd); |
| 3649 | if something other than a key is queued, we'll drop down |
| 3650 | to the !*cmd handling which clears out the command-queue */ |
| 3651 | key = (cq.typ == CMDQ_KEY) ? cq.key : 0; |
| 3652 | } else if (firsttime) { |
| 3653 | key = parse(); |
| 3654 | /* parse() pushed a cmd but didn't return any key */ |
| 3655 | if (!key && cmdq_peek(CQ_CANNED)) |
| 3656 | goto got_prefix_input; |
| 3657 | } |
| 3658 | |
| 3659 | /* if there's no command, there's nothing to do except reset */ |
| 3660 | if (!key || key == (char) 0377 |
| 3661 | || key == gc.Cmd.spkeys[NHKF_ESC]) { |
| 3662 | if (key == gc.Cmd.spkeys[NHKF_ESC]) |
| 3663 | /* don't perform next sanity check if player typed ESC for |
| 3664 | the current command, similar to handling for CMD_INSANE |
| 3665 | flag below (^P and ^R) */ |
| 3666 | iflags.sanity_no_check = iflags.sanity_check; |
| 3667 | else |
| 3668 | nhbell(); |
| 3669 | reset_cmd_vars(TRUE); |
| 3670 | return; |
| 3671 | } |
| 3672 | |
| 3673 | /* handle most movement commands */ |
| 3674 | svc.context.travel = svc.context.travel1 = 0; |
| 3675 | { |
| 3676 | const struct ext_func_tab *tlist; |
| 3677 | int res; |
| 3678 | |
| 3679 | gc.cmd_bind = cmdbind_get(key & 0xFF); |
| 3680 | |
| 3681 | do_cmdq_extcmd: |
| 3682 | if (cmdq_ec) |
| 3683 | tlist = cmdq_ec; |
no test coverage detected