summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-03 23:26:10 +0200
committerRobert Vollmert <rvollmert@gmx.net>2009-10-06 17:19:42 +0200
commitf2ab142032b8b522ef3b54abb975957a59e48452 (patch)
tree72b9aac523553069cd7582b70fa3c89789677618
parentdd1de5f827370e16f4f19e7abb5870b2f3d05da3 (diff)
downloadcrawl-ref-f2ab142032b8b522ef3b54abb975957a59e48452.tar.gz
crawl-ref-f2ab142032b8b522ef3b54abb975957a59e48452.zip
Fix _decrement_a_duration going from 2 to 0.
-rw-r--r--crawl-ref/source/acr.cc28
1 files changed, 10 insertions, 18 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 58acce1cdd..f09d17a559 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -2021,6 +2021,7 @@ static void _prep_input()
}
// Decrement a single duration. Print the message if the duration runs out.
+// Returns true if the duration ended.
// At midpoint (defined by get_expiration_threshold() in player.cc)
// print midmsg and decrease duration by midloss (a randomized amount so as
// to make it impossible to know the exact remaining duration for sure).
@@ -2034,34 +2035,25 @@ static bool _decrement_a_duration(duration_type dur, const char* endmsg = NULL,
if (you.duration[dur] < 1)
return (false);
- bool rc = false;
const int midpoint = get_expiration_threshold(dur);
- if (you.duration[dur] > 1)
+ you.duration[dur]--;
+ if (you.duration[dur] == midpoint)
{
- you.duration[dur]--;
- if (you.duration[dur] == midpoint)
- {
- if (midmsg)
- mpr(midmsg, chan);
-
- you.duration[dur] -= midloss;
- }
+ if (midmsg)
+ mpr(midmsg, chan);
+ you.duration[dur] -= midloss;
}
- // No "else", in case midloss caused the duration to end prematurely.
- // (This really shouldn't happen, else the whole point of the
- // "begins to time out" message is lost!)
- if (you.duration[dur] <= 1)
+ // allow fall-through in case midloss ended the duration (it shouldn't)
+ if (you.duration[dur] == 0)
{
if (endmsg)
mpr(endmsg, chan);
-
- rc = true;
- you.duration[dur] = 0;
+ return true;
}
- return rc;
+ return false;
}
// Perhaps we should write functions like: update_liquid_flames(), etc.