diff options
author | Adam Borowski <kilobyte@angband.pl> | 2013-04-09 03:20:40 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2013-04-09 11:02:10 +0200 |
commit | 8bf01c43c17c1111a580daa0e3906cae1cccef6a (patch) | |
tree | 4dac3070de755a493361e782829304da26d26531 /crawl-ref/source/godconduct.cc | |
parent | 441f6435328c8c2e68de689e1a4c7dc687a0760c (diff) | |
download | crawl-ref-8bf01c43c17c1111a580daa0e3906cae1cccef6a.tar.gz crawl-ref-8bf01c43c17c1111a580daa0e3906cae1cccef6a.zip |
Use FixedBitArray instead of large arrays of bools.
The only cost is having assignments be a function, as you can't overload
operator[] to have separate bits be lvalues.
Diffstat (limited to 'crawl-ref/source/godconduct.cc')
-rw-r--r-- | crawl-ref/source/godconduct.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crawl-ref/source/godconduct.cc b/crawl-ref/source/godconduct.cc index 941f7feb9f..3204036693 100644 --- a/crawl-ref/source/godconduct.cc +++ b/crawl-ref/source/godconduct.cc @@ -1090,15 +1090,15 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known, // since a Beogh worshipper zapping an orc with lightning might cause it to // become a follower on the first hit, and the second hit would be // against a friendly orc. -static FixedVector<bool, MAX_MONSTERS> _first_attack_conduct; -static FixedVector<bool, MAX_MONSTERS> _first_attack_was_unchivalric; -static FixedVector<bool, MAX_MONSTERS> _first_attack_was_friendly; +static FixedBitVector<MAX_MONSTERS> _first_attack_conduct; +static FixedBitVector<MAX_MONSTERS> _first_attack_was_unchivalric; +static FixedBitVector<MAX_MONSTERS> _first_attack_was_friendly; void god_conduct_turn_start() { - _first_attack_conduct.init(true); - _first_attack_was_unchivalric.init(false); - _first_attack_was_friendly.init(false); + _first_attack_conduct.reset(); + _first_attack_was_unchivalric.reset(); + _first_attack_was_friendly.reset(); } void set_attack_conducts(god_conduct_trigger conduct[3], const monster* mon, @@ -1108,28 +1108,28 @@ void set_attack_conducts(god_conduct_trigger conduct[3], const monster* mon, if (mon->friendly()) { - if (_first_attack_conduct[midx] + if (!_first_attack_conduct[midx] || _first_attack_was_friendly[midx]) { conduct[0].set(DID_ATTACK_FRIEND, 5, known, mon); - _first_attack_was_friendly[midx] = true; + _first_attack_was_friendly.set(midx); } } else if (mon->neutral()) conduct[0].set(DID_ATTACK_NEUTRAL, 5, known, mon); if (is_unchivalric_attack(&you, mon) - && (_first_attack_conduct[midx] + && (!_first_attack_conduct[midx] || _first_attack_was_unchivalric[midx])) { conduct[1].set(DID_UNCHIVALRIC_ATTACK, 4, known, mon); - _first_attack_was_unchivalric[midx] = true; + _first_attack_was_unchivalric.set(midx); } if (mon->is_holy()) conduct[2].set(DID_ATTACK_HOLY, mon->hit_dice, known, mon); - _first_attack_conduct[midx] = false; + _first_attack_conduct.set(midx); } void enable_attack_conducts(god_conduct_trigger conduct[3]) |