summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/player-stats.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2013-09-02 11:07:40 -0400
committerNeil Moore <neil@s-z.org>2013-09-02 11:07:40 -0400
commit9203b688c69c08d631bd4f741de9eb50086e6e58 (patch)
tree4ef918e32195fbce9ec634b912b3cc2baf900ddd /crawl-ref/source/player-stats.cc
parent7150391ffd0a0655e6840ee5e52e5300aae2233f (diff)
downloadcrawl-ref-9203b688c69c08d631bd4f741de9eb50086e6e58.tar.gz
crawl-ref-9203b688c69c08d631bd4f741de9eb50086e6e58.zip
Simplify.
Now that you.stat_zero[] is unsigned, test for nonzero rather than greater than zero in a number of places. Also replace a += (conditioned on the initial value being zero) with plain assignment. This helps to clarify that we don't have to worry about overflowing the cap there.
Diffstat (limited to 'crawl-ref/source/player-stats.cc')
-rw-r--r--crawl-ref/source/player-stats.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/crawl-ref/source/player-stats.cc b/crawl-ref/source/player-stats.cc
index 443af7505f..625879ceaf 100644
--- a/crawl-ref/source/player-stats.cc
+++ b/crawl-ref/source/player-stats.cc
@@ -541,7 +541,7 @@ bool lose_stat(stat_type which_stat, int stat_loss, bool force,
{
you.stat_loss[which_stat] = min<int>(100,
you.stat_loss[which_stat] + stat_loss);
- if (you.stat_zero[which_stat] > 0)
+ if (you.stat_zero[which_stat])
{
mprf(MSGCH_DANGER, "You convulse from lack of %s!", stat_desc(which_stat, SD_NAME));
ouch(5 + random2(you.hp_max / 10), NON_MONSTER, _statloss_killtype(which_stat), cause);
@@ -644,7 +644,7 @@ static void _handle_stat_change(stat_type stat, const char* cause, bool see_sour
if (you.stat(stat) <= 0 && you.stat_zero[stat] == 0)
{
// Turns required for recovery once the stat is restored, randomised slightly.
- you.stat_zero[stat] += 10 + random2(10);
+ you.stat_zero[stat] = 10 + random2(10);
mprf(MSGCH_WARN, "You have lost your %s.", stat_desc(stat, SD_NAME));
take_note(Note(NOTE_MESSAGE, 0, 0, make_stringf("Lost %s.",
stat_desc(stat, SD_NAME)).c_str()), true);
@@ -692,7 +692,7 @@ void update_stat_zero()
if (you.stat_zero[s] < STATZERO_TURN_CAP)
you.stat_zero[s]++;
}
- else if (you.stat_zero[s] > 0)
+ else if (you.stat_zero[s])
{
you.stat_zero[s]--;
if (you.stat_zero[s] == 0)