diff options
author | Neil Moore <neil@s-z.org> | 2013-09-02 10:59:29 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-09-02 11:07:12 -0400 |
commit | 7150391ffd0a0655e6840ee5e52e5300aae2233f (patch) | |
tree | f0b6c271d01a9566e97199843df13d9e216d724e /crawl-ref/source/player-stats.cc | |
parent | 931e27026d369bd8edeed33fd80be031395ec290 (diff) | |
download | crawl-ref-7150391ffd0a0655e6840ee5e52e5300aae2233f.tar.gz crawl-ref-7150391ffd0a0655e6840ee5e52e5300aae2233f.zip |
Cap stat_zero time, don't save it as a negative number.
Recovery is now limited to at most 200 turns. Previously it was
unlimited, but after a save and restore it would either take 127 or
fewer turns, or take forever as the time was restored as a negative
number. Besides the cap on recovery time, we marshall as an
unsigned byte, not signed.
The cap could be increased, but anything larger than 255 will
require a minor tag and a change to the marshalling format.
Diffstat (limited to 'crawl-ref/source/player-stats.cc')
-rw-r--r-- | crawl-ref/source/player-stats.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/crawl-ref/source/player-stats.cc b/crawl-ref/source/player-stats.cc index be75379735..443af7505f 100644 --- a/crawl-ref/source/player-stats.cc +++ b/crawl-ref/source/player-stats.cc @@ -27,6 +27,10 @@ #include "tilepick.h" #endif +// Don't make this larger than 255 without changing the type of you.stat_zero +// in player.h as well as the associated marshalling code in tags.cc +const int STATZERO_TURN_CAP = 200; + int player::stat(stat_type s, bool nonneg) const { const int val = max_stat(s) - stat_loss[s]; @@ -684,7 +688,10 @@ void update_stat_zero() { stat_type s = static_cast<stat_type>(i); if (you.stat(s) <= 0) - you.stat_zero[s]++; + { + if (you.stat_zero[s] < STATZERO_TURN_CAP) + you.stat_zero[s]++; + } else if (you.stat_zero[s] > 0) { you.stat_zero[s]--; |