MCPcopy Create free account
hub / github.com/crawl/crawl / flush_input_buffer

Function flush_input_buffer

crawl-ref/source/macro.cc:929–978  ·  view source on GitHub ↗

* 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). */

Source from the content-addressed store, hash-verified

927 * as to when this happens (ex. always before command input, casting failed).
928 */
929void 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
980static string _keyseq_desc(const keyseq &key)
981{

Callers 15

process_commandFunction · 0.85
_get_next_keycodeFunction · 0.85
_cancel_cmd_repeatFunction · 0.85
_find_commandFunction · 0.85
_do_cmd_repeatFunction · 0.85
_do_prev_cmd_againFunction · 0.85
handle_mouseMethod · 0.85
do_cast_spell_cmdFunction · 0.85
your_spellsFunction · 0.85
moreMethod · 0.85
l-crawl.ccFile · 0.85
crawl_process_keysFunction · 0.85

Calls 5

is_processing_macroFunction · 0.85
mprfFunction · 0.85
_buffer_to_stringFunction · 0.85
is_replaying_keysMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected