diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-09 06:04:09 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-09 06:04:09 +0000 |
commit | b24097a123b06b3a8f9808f0dc7fffaa3527f606 (patch) | |
tree | de3699782ccba2e9f4972df71105f8a3adcb9ffc /crawl-ref/source/monplace.cc | |
parent | eb910bc1e2c4f7222d565ccd4b0ca88faeb84047 (diff) | |
download | crawl-ref-b24097a123b06b3a8f9808f0dc7fffaa3527f606.tar.gz crawl-ref-b24097a123b06b3a8f9808f0dc7fffaa3527f606.zip |
Fix player_will_anger_monster() so that it works properly when the holy,
unholy, and antimagical parameters are NULL.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5643 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monplace.cc')
-rw-r--r-- | crawl-ref/source/monplace.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 0096b93231..eb1f5ceda1 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -2018,16 +2018,21 @@ bool player_will_anger_monster(monster_type type, bool *holy, bool player_will_anger_monster(monsters *mon, bool *holy, bool *unholy, bool *antimagical) { - if (holy) - *holy = (is_good_god(you.religion) && mons_is_evil_or_unholy(mon)); + const bool is_holy = + (is_good_god(you.religion) && mons_is_evil_or_unholy(mon)); + const bool is_unholy = + (is_evil_god(you.religion) && mons_is_holy(mon)); + const bool is_antimagical = + (you.religion == GOD_TROG && mons_is_magic_user(mon)); + if (holy) + *holy = is_holy; if (unholy) - *unholy = (is_evil_god(you.religion) && mons_is_holy(mon)); - + *unholy = is_unholy; if (antimagical) - *antimagical = (you.religion == GOD_TROG && mons_is_magic_user(mon)); + *antimagical = is_antimagical; - return (*holy || *unholy || *antimagical); + return (is_holy || is_unholy || is_antimagical); } bool player_angers_monster(monsters *mon) @@ -2039,8 +2044,6 @@ bool player_angers_monster(monsters *mon) // Get the drawbacks, not the benefits... (to prevent e.g. demon-scumming). if (player_will_anger_monster(mon, &holy, &unholy, &antimagical)) { - ASSERT (holy || unholy || antimagical); - if (mon->attitude != ATT_HOSTILE || mon->has_ench(ENCH_CHARM)) { mon->attitude = ATT_HOSTILE; |