summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-09-17 21:04:04 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-09-17 21:04:04 +0000
commitd636d3368b6441379025477373212cd203fe16bf (patch)
treee21710f2ca920d456247f29ecfe7a49bbe10e160
parent04a7ba1ee47556dcdf4d7ce56ebb7596f66cebfb (diff)
downloadcrawl-ref-d636d3368b6441379025477373212cd203fe16bf.tar.gz
crawl-ref-d636d3368b6441379025477373212cd203fe16bf.zip
Simplify further.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10700 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/command.cc9
-rw-r--r--crawl-ref/source/debug.cc5
-rw-r--r--crawl-ref/source/describe.cc12
-rw-r--r--crawl-ref/source/mon-util.cc18
-rw-r--r--crawl-ref/source/mon-util.h1
-rw-r--r--crawl-ref/source/tags.cc4
6 files changed, 27 insertions, 22 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index df0d87914d..f3f52191ad 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -1340,11 +1340,10 @@ static bool _do_description(std::string key, std::string type,
else
{
monster_type mon_num = get_monster_by_name(key, true);
- // Don't attempt to get more information on ghosts or
- // pandemonium demons, as the ghost struct has not been
- // initialised, which will cause a crash.
- if (mon_num != MONS_PROGRAM_BUG && mon_num != MONS_PLAYER_GHOST
- && mon_num != MONS_PANDEMONIUM_DEMON)
+ // Don't attempt to get more information on ghost demon
+ // monsters, as the ghost struct has not been initialised, which
+ // will cause a crash.
+ if (mon_num != MONS_PROGRAM_BUG && !mons_is_ghost_demon(mon_num))
{
monsters mon;
mon.type = mon_num;
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index a8d6a3cf5e..2cf9b2130c 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -2715,13 +2715,12 @@ void debug_stethoscope(int mon)
if (found_spell)
mprf(MSGCH_DIAGNOSTICS, "spells: %s", spl.str().c_str());
- if (mons.type == MONS_PLAYER_GHOST
- || mons.type == MONS_PANDEMONIUM_DEMON)
+ if (mons_is_ghost_demon(mons.type))
{
ASSERT(mons.ghost.get());
const ghost_demon &ghost = *mons.ghost;
mprf(MSGCH_DIAGNOSTICS, "Ghost damage: %d; brand: %d",
- ghost.damage, ghost.brand );
+ ghost.damage, ghost.brand);
}
}
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 9fc5de9beb..c738b23d72 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -2586,11 +2586,11 @@ static std::string _monster_stat_description(const monsters& mon)
{
std::ostringstream result;
- // Don't leak or duplicate resistance information for demons/ghosts.
+ // Don't leak or duplicate resistance information for ghost demon
+ // monsters.
const mon_resist_def resist =
- (mon.type == MONS_PANDEMONIUM_DEMON
- || mon.type == MONS_PLAYER_GHOST ? get_mons_class_resists(mon.type)
- : get_mons_resists(&mon));
+ mons_is_ghost_demon(mon.type) ? get_mons_class_resists(mon.type)
+ : get_mons_resists(&mon);
const mon_resist_flags resists[] = {
MR_RES_ELEC, MR_RES_POISON, MR_RES_FIRE,
@@ -2676,8 +2676,8 @@ static std::string _monster_stat_description(const monsters& mon)
if (mons_immune_magic(&mon))
result << pronoun << " is immune to magical enchantments.$";
- // These differ from ghost to ghost, so would be spoily.
- if (mon.type != MONS_PANDEMONIUM_DEMON && mon.type != MONS_PLAYER_GHOST)
+ // These differ between ghost demon monsters, so would be spoily.
+ if (!mons_is_ghost_demon(mon.type))
{
// Seeing/sensing invisible.
if (mons_class_flag(mon.type, M_SEE_INVIS))
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 80fa813597..8e85a80a1a 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -285,7 +285,7 @@ const mon_resist_def &get_mons_class_resists(int mc)
mon_resist_def get_mons_resists(const monsters *mon)
{
mon_resist_def resists;
- if (mon->type == MONS_PLAYER_GHOST || mon->type == MONS_PANDEMONIUM_DEMON)
+ if (mons_is_ghost_demon(mon->type))
resists = (mon->ghost->resists);
else
resists = mon_resist_def();
@@ -867,6 +867,12 @@ shout_type mons_shouts(int mc, bool demon_shout)
return (u);
}
+bool mons_is_ghost_demon(int mc)
+{
+ return (mc == MONS_PLAYER_GHOST
+ || mc == MONS_PANDEMONIUM_DEMON);
+}
+
bool mons_is_unique(int mc)
{
return (mons_class_flag(mc, M_UNIQUE));
@@ -879,7 +885,7 @@ bool mons_sense_invis(const monsters *mon)
bool mons_see_invis(const monsters *mon)
{
- if (mon->type == MONS_PLAYER_GHOST || mon->type == MONS_PANDEMONIUM_DEMON)
+ if (mons_is_ghost_demon(mon->type))
return (mon->ghost->see_invis);
else if (mons_class_flag(mon->type, M_SEE_INVIS))
return (true);
@@ -1142,7 +1148,7 @@ mon_attack_def mons_attack_spec(const monsters *mon, int attk_number)
if (attk_number < 0 || attk_number > 3 || mon->has_hydra_multi_attack())
attk_number = 0;
- if (mc == MONS_PLAYER_GHOST || mc == MONS_PANDEMONIUM_DEMON)
+ if (mons_is_ghost_demon(mc))
{
if (attk_number == 0)
return (mon_attack_def::attk(mon->ghost->damage));
@@ -1553,7 +1559,7 @@ flight_type mons_flies(const monsters *mon, bool randarts)
if (mons_enslaved_twisted_soul(mon))
return (FL_LEVITATE);
- if (mon->type == MONS_PLAYER_GHOST || mon->type == MONS_PANDEMONIUM_DEMON)
+ if (mons_is_ghost_demon(mon->type))
return (mon->ghost->fly);
const int montype = mons_is_zombified(mon) ? mons_zombie_base(mon)
@@ -2576,7 +2582,7 @@ int mons_offhand_weapon_index(const monsters *m)
int mons_base_damage_brand(const monsters *m)
{
- if (m->type == MONS_PLAYER_GHOST || m->type == MONS_PANDEMONIUM_DEMON)
+ if (mons_is_ghost_demon(m->type))
return (m->ghost->brand);
return (SPWPN_NORMAL);
@@ -3905,7 +3911,7 @@ int monsters::damage_brand(int which_attack)
if (!mweap)
{
- if (type == MONS_PLAYER_GHOST || type == MONS_PANDEMONIUM_DEMON)
+ if (mons_is_ghost_demon(type))
return (ghost->brand);
return (SPWPN_NORMAL);
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index 6a69b2c90d..62146ac041 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -520,6 +520,7 @@ bool mons_player_visible(const monsters *mon);
int get_shout_noise_level(const shout_type shout);
shout_type mons_shouts(int mclass, bool demon_shout = false);
+bool mons_is_ghost_demon(int mc);
bool mons_is_unique(int mc);
// last updated 12may2000 {dlb}
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index 3b6c0ef4af..5db90d707d 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -1879,7 +1879,7 @@ static void marshall_monster(writer &th, const monsters &m)
marshallSpells(th, m.spells);
marshallByte(th, m.god);
- if (m.type == MONS_PLAYER_GHOST || m.type == MONS_PANDEMONIUM_DEMON)
+ if (mons_is_ghost_demon(m.type))
{
// *Must* have ghost field set.
ASSERT(m.ghost.get());
@@ -2191,7 +2191,7 @@ static void unmarshall_monster(reader &th, monsters &m)
m.god = static_cast<god_type>( unmarshallByte(th) );
- if (m.type == MONS_PLAYER_GHOST || m.type == MONS_PANDEMONIUM_DEMON)
+ if (mons_is_ghost_demon(m.type))
m.set_ghost(unmarshallGhost(th, _tag_minor_version));
m.check_speed();