summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-19 22:56:46 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-19 22:56:46 +0000
commit7b52c20fd2613f4597a5b429c604369d393367ec (patch)
treeb955c5b143a0210879141bb8ad3258cf819b35fb /crawl-ref/source
parent5e4ca0912ae656b9e2a55b95027ebc6f483a01a6 (diff)
downloadcrawl-ref-7b52c20fd2613f4597a5b429c604369d393367ec.tar.gz
crawl-ref-7b52c20fd2613f4597a5b429c604369d393367ec.zip
Input buffer needs to be flushed if the first iteration of command
repetition is canceled. Repetitions of searching and go-nowhere weren't being interrupted. Wasn't generating activity interrupts for AI_FULL_MP and AI_FULL_HP. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2150 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/macro.cc2
-rw-r--r--crawl-ref/source/player.cc10
-rw-r--r--crawl-ref/source/state.cc24
3 files changed, 26 insertions, 10 deletions
diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc
index 803252ad7e..a87e86172d 100644
--- a/crawl-ref/source/macro.cc
+++ b/crawl-ref/source/macro.cc
@@ -705,7 +705,7 @@ int getch_with_command_macros( void )
void flush_input_buffer( int reason )
{
ASSERT(reason != FLUSH_KEY_REPLAY_CANCEL ||
- crawl_state.is_replaying_keys());
+ crawl_state.is_replaying_keys() || crawl_state.cmd_repeat_start);
ASSERT(reason != FLUSH_ABORT_MACRO || is_processing_macro());
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index f7bf812bda..77b4fbe3e1 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -4200,6 +4200,8 @@ void inc_mp(int mp_gain, bool max_too)
if (mp_gain < 1)
return;
+ bool wasnt_max = (you.magic_points < you.max_magic_points);
+
you.magic_points += mp_gain;
if (max_too)
@@ -4208,6 +4210,9 @@ void inc_mp(int mp_gain, bool max_too)
if (you.magic_points > you.max_magic_points)
you.magic_points = you.max_magic_points;
+ if (wasnt_max && you.magic_points == you.max_magic_points)
+ interrupt_activity(AI_FULL_MP);
+
take_note(Note(NOTE_MP_CHANGE, you.magic_points, you.max_magic_points));
you.redraw_magic_points = 1;
@@ -4221,6 +4226,8 @@ void inc_hp(int hp_gain, bool max_too)
if (hp_gain < 1)
return;
+ bool wasnt_max = (you.hp < you.hp_max);
+
you.hp += hp_gain;
if (max_too)
@@ -4229,6 +4236,9 @@ void inc_hp(int hp_gain, bool max_too)
if (you.hp > you.hp_max)
you.hp = you.hp_max;
+ if (wasnt_max && you.hp == you.hp_max)
+ interrupt_activity(AI_FULL_HP);
+
// to avoid message spam, no information when HP increases
// take_note(Note(NOTE_HP_CHANGE, you.hp, you.hp_max));
diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc
index a664a3464b..41c4837dff 100644
--- a/crawl-ref/source/state.cc
+++ b/crawl-ref/source/state.cc
@@ -63,7 +63,7 @@ void game_state::cancel_cmd_repeat(std::string reason)
if (!is_repeating_cmd())
return;
- if (is_replaying_keys())
+ if (is_replaying_keys() || cmd_repeat_start)
flush_input_buffer(FLUSH_KEY_REPLAY_CANCEL);
if (is_processing_macro())
@@ -124,14 +124,6 @@ bool interrupt_cmd_repeat( activity_interrupt_type ai,
if (crawl_state.cmd_repeat_start)
return false;
- // If command repitition is being used to immitate the rest command,
- // then everything interrupts it.
- if (crawl_state.repeat_cmd == CMD_MOVE_NOWHERE
- || crawl_state.repeat_cmd == CMD_SEARCH)
- {
- return true;
- }
-
if (crawl_state.repeat_cmd == CMD_WIZARD)
return false;
@@ -192,6 +184,20 @@ bool interrupt_cmd_repeat( activity_interrupt_type ai,
return true;
}
+ // If command repitition is being used to immitate the rest command,
+ // then everything interrupts it.
+ if (crawl_state.repeat_cmd == CMD_MOVE_NOWHERE
+ || crawl_state.repeat_cmd == CMD_SEARCH)
+ {
+ if (ai == AI_FULL_MP)
+ crawl_state.cancel_cmd_repeat("Magic restored.");
+ else if (ai = AI_FULL_HP)
+ crawl_state.cancel_cmd_repeat("HP restored.");
+ else
+ crawl_state.cancel_cmd_repeat("Command repetition interrupted.");
+ return true;
+ }
+
if (crawl_state.cmd_repeat_started_unsafe)
return false;