From f2ab142032b8b522ef3b54abb975957a59e48452 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sat, 3 Oct 2009 23:26:10 +0200 Subject: Fix _decrement_a_duration going from 2 to 0. --- crawl-ref/source/acr.cc | 28 ++++++++++------------------ 1 file 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. -- cgit v1.2.3-54-g00ecf