diff options
author | Neil Moore <neil@s-z.org> | 2013-06-26 02:36:11 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2013-06-26 02:36:11 -0400 |
commit | bfd7fd8dd3d879e079e8c9a7656348346cc59084 (patch) | |
tree | b0838d06b7467aa4db0ad58ed62b35796bb964a3 /crawl-ref/source/mon-util.h | |
parent | cae46e358690cf86f43a5743b5b048be0652072e (diff) | |
download | crawl-ref-bfd7fd8dd3d879e079e8c9a7656348346cc59084.tar.gz crawl-ref-bfd7fd8dd3d879e079e8c9a7656348346cc59084.zip |
Fix overflow in curse skull monster energy pickup_percent.
Curse skulls got an action energy of 15, meaning their pickup_percent
was 150, outside the range of the int8_t that stores it. Since none
of the energy usage numbers should be negative, make that a uint8_t
instead. Also change the other members to uint8_t so we don't need
duplicate overloaded versions of combine().
This wasn't actually relevant to curse skulls, since they had
MONUSE_NOTHING, but it was producing a compiler warning and more
importantly could turn up with some future monster.
Diffstat (limited to 'crawl-ref/source/mon-util.h')
-rw-r--r-- | crawl-ref/source/mon-util.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index cef1cca03e..826772b8dc 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -34,17 +34,17 @@ struct mon_attack_def #define DEFAULT_ENERGY {10, 10, 10, 10, 10, 10, 10, 100} struct mon_energy_usage { - int8_t move; - int8_t swim; - int8_t attack; - int8_t missile; // Arrows/crossbows/etc - int8_t spell; - int8_t special; - int8_t item; // Using an item (i.e., drinking a potion) + uint8_t move; + uint8_t swim; + uint8_t attack; + uint8_t missile; // Arrows/crossbows/etc + uint8_t spell; + uint8_t special; + uint8_t item; // Using an item (i.e., drinking a potion) // Percent of mons->speed used when picking up an item; defaults // to 100% - int8_t pickup_percent; + uint8_t pickup_percent; static mon_energy_usage attack_cost(int cost, int sw = 10) { @@ -90,7 +90,7 @@ struct mon_energy_usage return me; } private: - static int8_t combine(int8_t a, int8_t b, int8_t def = 10) + static uint8_t combine(uint8_t a, uint8_t b, uint8_t def = 10) { return (b != def? b : a); } |