summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/main.cc
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2010-01-04 03:43:02 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2010-01-04 03:44:34 +0530
commit0c8fe019ddaea7c80bd7a72bab958b729019991d (patch)
tree99653f542e25c337fdaa174844b090c6826182ce /crawl-ref/source/main.cc
parent4294ce7ebf7350f3d26dbe5350337aa9378d6797 (diff)
downloadcrawl-ref-0c8fe019ddaea7c80bd7a72bab958b729019991d.tar.gz
crawl-ref-0c8fe019ddaea7c80bd7a72bab958b729019991d.zip
Fix Crawl assert if user tries to repeat a command with Enter macroed to \{13} (Eifeltrampel).
Diffstat (limited to 'crawl-ref/source/main.cc')
-rw-r--r--crawl-ref/source/main.cc38
1 files changed, 19 insertions, 19 deletions
diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc
index fd4dd7b94e..1ccf335ed8 100644
--- a/crawl-ref/source/main.cc
+++ b/crawl-ref/source/main.cc
@@ -4259,6 +4259,13 @@ static int _get_num_and_char(const char* prompt, char* buf, int buf_len)
return reader.read_line(true);
}
+static void _cancel_cmd_repeat()
+{
+ crawl_state.cancel_cmd_again();
+ crawl_state.cancel_cmd_repeat();
+ flush_input_buffer(FLUSH_REPLAY_SETUP_FAILURE);
+}
+
static void _setup_cmd_repeat()
{
if (is_processing_macro())
@@ -4287,9 +4294,7 @@ static void _setup_cmd_repeat()
{
// Was just a single ESCAPE key, so not a macro trigger.
canned_msg( MSG_OK );
- crawl_state.cancel_cmd_again();
- crawl_state.cancel_cmd_repeat();
- flush_input_buffer(FLUSH_REPLAY_SETUP_FAILURE);
+ _cancel_cmd_repeat();
return;
}
ch = getchm();
@@ -4312,9 +4317,7 @@ static void _setup_cmd_repeat()
// Wasn't a macro trigger, just an ordinary escape.
canned_msg( MSG_OK );
- crawl_state.cancel_cmd_again();
- crawl_state.cancel_cmd_repeat();
- flush_input_buffer(FLUSH_REPLAY_SETUP_FAILURE);
+ _cancel_cmd_repeat();
return;
}
// *WAS* a macro trigger, keep going.
@@ -4323,11 +4326,7 @@ static void _setup_cmd_repeat()
if (strlen(buf) == 0)
{
mpr("You must enter the number of times for the command to repeat.");
-
- crawl_state.cancel_cmd_again();
- crawl_state.cancel_cmd_repeat();
- flush_input_buffer(FLUSH_REPLAY_SETUP_FAILURE);
-
+ _cancel_cmd_repeat();
return;
}
@@ -4339,9 +4338,7 @@ static void _setup_cmd_repeat()
if (count <= 0)
{
canned_msg( MSG_OK );
- crawl_state.cancel_cmd_again();
- crawl_state.cancel_cmd_repeat();
- flush_input_buffer(FLUSH_REPLAY_SETUP_FAILURE);
+ _cancel_cmd_repeat();
return;
}
@@ -4370,7 +4367,7 @@ static void _setup_cmd_repeat()
if (!crawl_state.doing_prev_cmd_again)
repeat_again_rec.keys.pop_back();
- mpr("Enter command to be repeated: ");
+ mpr("Enter command to be repeated: ", MSGCH_PROMPT);
// Enable the cursor to read input.
cursor_control con(true);
@@ -4388,9 +4385,7 @@ static void _setup_cmd_repeat()
if (!is_processing_macro() && !_cmd_is_repeatable(cmd))
{
- crawl_state.cancel_cmd_again();
- crawl_state.cancel_cmd_repeat();
- flush_input_buffer(FLUSH_REPLAY_SETUP_FAILURE);
+ _cancel_cmd_repeat();
return;
}
@@ -4413,7 +4408,12 @@ static void _setup_cmd_repeat()
while (isdigit(ch) || ch == ' ' || ch == CK_ENTER)
{
keys.pop_back();
- ASSERT(keys.size() > 0);
+ // Handle the case where the user has macroed enter to itself.
+ if (keys.empty())
+ {
+ _cancel_cmd_repeat();
+ return;
+ }
ch = keys[keys.size() - 1];
}
}