summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/religion.cc
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2009-11-10 01:58:51 +0100
committerAdam Borowski <kilobyte@angband.pl>2009-11-10 01:59:33 +0100
commit871a3796a3e9a21278664d3188165eb6587a979f (patch)
treeae6c65535287a17b472d278829c2d7e1fde4bb45 /crawl-ref/source/religion.cc
parent1e6bb9e867330779428e2ff8e18f328ecdde7afe (diff)
downloadcrawl-ref-871a3796a3e9a21278664d3188165eb6587a979f.tar.gz
crawl-ref-871a3796a3e9a21278664d3188165eb6587a979f.zip
Allow calling did_god_conduct() with no monster ref without crashing.
Diffstat (limited to 'crawl-ref/source/religion.cc')
-rw-r--r--crawl-ref/source/religion.cc19
1 files changed, 11 insertions, 8 deletions
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 37a597371a..1179ea5115 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -2706,7 +2706,7 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known,
break;
}
- if (thing_done == DID_ATTACK_HOLY
+ if (thing_done == DID_ATTACK_HOLY && victim
&& !testbits(victim->flags, MF_CREATED_FRIENDLY)
&& !testbits(victim->flags, MF_WAS_NEUTRAL))
{
@@ -2744,7 +2744,7 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known,
{
if (thing_done == DID_UNCHIVALRIC_ATTACK)
{
- if (tso_unchivalric_attack_safe_monster(victim))
+ if (victim && tso_unchivalric_attack_safe_monster(victim))
break;
if (!known)
@@ -2806,7 +2806,7 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known,
break;
case GOD_JIYVA:
- if (mons_is_slime(victim))
+ if (victim && mons_is_slime(victim))
{
piety_change = -(level/2 + 3);
penance = level/2 + 3;
@@ -2841,7 +2841,7 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known,
{
case GOD_ELYVILON: // healer god cares more about this
// Converted allies (marked as TSOites) can be martyrs.
- if (victim->god == GOD_SHINING_ONE)
+ if (victim && victim->god == GOD_SHINING_ONE)
break;
if (player_under_penance())
@@ -2852,14 +2852,15 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known,
case GOD_ZIN:
// Converted allies (marked as TSOites) can be martyrs.
- if (victim->god == GOD_SHINING_ONE)
+ if (victim && victim->god == GOD_SHINING_ONE)
break;
// fall through
case GOD_FEDHAS:
// double-check god because of fall-throughs from other gods
// Toadstools are an exception for this conduct
- if (you.religion == GOD_FEDHAS && (!fedhas_protects(victim)
+ if (you.religion == GOD_FEDHAS && (!victim
+ || !fedhas_protects(victim)
|| victim->mons_species() == MONS_TOADSTOOL))
break;
// fall through
@@ -3045,7 +3046,8 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known,
case GOD_ZIN:
case GOD_SHINING_ONE:
case GOD_ELYVILON:
- if (!testbits(victim->flags, MF_CREATED_FRIENDLY)
+ if (victim
+ && !testbits(victim->flags, MF_CREATED_FRIENDLY)
&& !testbits(victim->flags, MF_WAS_NEUTRAL))
{
break;
@@ -3112,7 +3114,8 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known,
case GOD_ZIN:
case GOD_SHINING_ONE:
case GOD_ELYVILON:
- if (!testbits(victim->flags, MF_CREATED_FRIENDLY)
+ if (victim
+ && !testbits(victim->flags, MF_CREATED_FRIENDLY)
&& !testbits(victim->flags, MF_WAS_NEUTRAL))
{
break;