summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/delay.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-31 03:19:15 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-31 03:19:15 +0000
commit3e026503b17f1aa9367a88d0d6fdc9aab7e8aa51 (patch)
treef02349f8597977f706b87d3c001d73cac3279160 /crawl-ref/source/delay.cc
parent6de62154a08ad2e5da61694823aaff9ec033ed26 (diff)
downloadcrawl-ref-3e026503b17f1aa9367a88d0d6fdc9aab7e8aa51.tar.gz
crawl-ref-3e026503b17f1aa9367a88d0d6fdc9aab7e8aa51.zip
If butchering with a swapped weapon is interrupted, then switch back
to the non-butchering weapon as soon as the player is safe again. Enabled by setting option "swap_when_safe" to true. Also, fixed a bug where "not switching back" message wasn't always being given when butchering was interrupted. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5354 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/delay.cc')
-rw-r--r--crawl-ref/source/delay.cc33
1 files changed, 26 insertions, 7 deletions
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index e796164ac7..77c9d18412 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -268,12 +268,22 @@ static void pop_delay()
you.delay_queue.erase( you.delay_queue.begin() );
}
+static int delays_cleared[NUM_DELAYS];
+static int cleared_delays_parm1[NUM_DELAYS];
+
static void clear_pending_delays()
{
+ memset(delays_cleared, 0, sizeof(delays_cleared));
+ memset(cleared_delays_parm1, 0, sizeof(cleared_delays_parm1));
+
while (you.delay_queue.size() > 1)
{
const delay_queue_item delay =
you.delay_queue[you.delay_queue.size() - 1];
+
+ delays_cleared[delay.type]++;
+ cleared_delays_parm1[delay.type] = delay.parm1;
+
you.delay_queue.pop_back();
if (is_run_delay(delay.type) && you.running)
@@ -334,9 +344,10 @@ void stop_delay( bool stop_stair_travel )
case DELAY_BOTTLE_BLOOD:
case DELAY_OFFER_CORPSE:
{
- bool multiple_corpses = false;
- bool butcher_swap_warn = false;
- int wpn_delay = -1;
+ bool multiple_corpses = false;
+ bool butcher_swap_warn = false;
+ int butcher_swap_weapon = 0;
+
for (unsigned int i = 1; i < you.delay_queue.size(); i++)
{
if (you.delay_queue[i].type == DELAY_BUTCHER
@@ -347,14 +358,20 @@ void stop_delay( bool stop_stair_travel )
}
else if (you.delay_queue[i].type == DELAY_WEAPON_SWAP)
{
- wpn_delay = i;
- butcher_swap_warn = true;
+ butcher_swap_weapon = you.delay_queue[i].parm1;
+ butcher_swap_warn = true;
break;
}
else
break;
}
+ if (!butcher_swap_warn && delays_cleared[DELAY_WEAPON_SWAP] > 0)
+ {
+ butcher_swap_warn = true;
+ butcher_swap_weapon = cleared_delays_parm1[DELAY_WEAPON_SWAP];
+ }
+
const std::string butcher_verb =
(delay.type == DELAY_BUTCHER ? "butchering" :
delay.type == DELAY_BOTTLE_BLOOD ? "bottling blood from"
@@ -363,8 +380,6 @@ void stop_delay( bool stop_stair_travel )
// Corpse keeps track of work in plus2 field, see handle_delay() -- bwr
if (butcher_swap_warn)
{
- const int butcher_swap_weapon = you.delay_queue[wpn_delay].parm1;
-
std::string weapon;
if (butcher_swap_weapon == -1)
weapon = "unarmed combat";
@@ -376,6 +391,10 @@ void stop_delay( bool stop_stair_travel )
mprf(MSGCH_WARN, "You stop %s the corpse%s; not switching "
"back to %s.", butcher_verb.c_str(),
(multiple_corpses ? "s" : ""), weapon.c_str());
+
+ if (Options.swap_when_safe)
+ you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED]
+ = butcher_swap_weapon;
}
else
mprf("You stop %s the corpse%s.", butcher_verb.c_str(),