* Flush the buffer. Later we'll probably want to give the player options * as to when this happens (ex. always before command input, casting failed). */
| 927 | * as to when this happens (ex. always before command input, casting failed). |
| 928 | */ |
| 929 | void flush_input_buffer(int reason) |
| 930 | { |
| 931 | ASSERT(reason != FLUSH_KEY_REPLAY_CANCEL |
| 932 | || crawl_state.is_replaying_keys() || crawl_state.cmd_repeat_start); |
| 933 | |
| 934 | ASSERT(reason != FLUSH_ABORT_MACRO || is_processing_macro()); |
| 935 | |
| 936 | // Any attempt to flush means that the processing of the previously |
| 937 | // fetched keystroke is complete. |
| 938 | if (macro_keys_left == 0) |
| 939 | macro_keys_left = -1; |
| 940 | |
| 941 | if (crawl_state.is_replaying_keys() && reason != FLUSH_ABORT_MACRO |
| 942 | && reason != FLUSH_KEY_REPLAY_CANCEL |
| 943 | && reason != FLUSH_REPLAY_SETUP_FAILURE |
| 944 | && reason != FLUSH_ON_FAILURE |
| 945 | && reason != FLUSH_FORCE_MORE) |
| 946 | { |
| 947 | return; |
| 948 | } |
| 949 | |
| 950 | if (Options.flush_input[ reason ] || reason == FLUSH_ABORT_MACRO |
| 951 | || reason == FLUSH_FORCE_MORE |
| 952 | || reason == FLUSH_KEY_REPLAY_CANCEL |
| 953 | || reason == FLUSH_REPLAY_SETUP_FAILURE |
| 954 | || reason == FLUSH_REPEAT_SETUP_DONE) |
| 955 | { |
| 956 | if (crawl_state.nonempty_buffer_flush_errors && !Buffer.empty()) |
| 957 | { |
| 958 | if (you.wizard) // crash -- intended for tests |
| 959 | { |
| 960 | mprf(MSGCH_ERROR, |
| 961 | "Flushing non-empty key buffer (Buffer is '%s')", |
| 962 | _buffer_to_string().c_str()); |
| 963 | ASSERT(Buffer.empty()); |
| 964 | } |
| 965 | else |
| 966 | mprf(MSGCH_ERROR, "Flushing non-empty key buffer"); |
| 967 | } |
| 968 | while (!Buffer.empty()) |
| 969 | { |
| 970 | const int key = Buffer.front(); |
| 971 | Buffer.pop_front(); |
| 972 | if (key == KEY_MACRO_ENABLE_MORE) |
| 973 | crawl_state.show_more_prompt = true; |
| 974 | } |
| 975 | macro_keys_left = -1; |
| 976 | expanded_keys_left = 0; |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | static string _keyseq_desc(const keyseq &key) |
| 981 | { |
no test coverage detected