summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mon-util.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-24 18:44:55 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-24 18:44:55 +0000
commitcef2c17b4efb995e002c07062c04254055277d55 (patch)
tree7cb8d05cfc08c75e0594d649675340bb6451b937 /crawl-ref/source/mon-util.cc
parentde1e3653a03844e6c19246d9cc8f1bce3a4d98aa (diff)
downloadcrawl-ref-cef2c17b4efb995e002c07062c04254055277d55.tar.gz
crawl-ref-cef2c17b4efb995e002c07062c04254055277d55.zip
Partial fix for [2628480]: use you.can_see() instead of
player_monster_visible() in monsters::name() and do_mon_str_replacements(), so that noninvisible monsters which shout when out of sight are handled correctly. This isn't really the bug that's there, but it needed to be done sometime. Note that this is a change: if a monster is too far away to see and you want to get its name, you'll have to set force_vis. I hope this doesn't break anything. Also, make the mgrd-out-of-sync message trigger outside of DEBUG_DIAGNOSTICS. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9195 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mon-util.cc')
-rw-r--r--crawl-ref/source/mon-util.cc25
1 files changed, 10 insertions, 15 deletions
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 7c0ca403f9..439233d59a 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1964,8 +1964,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc,
&& mons_is_submerged(&mon);
// Handle non-visible case first.
- if (!force_seen && !player_monster_visible(&mon)
- && !arena_submerged)
+ if (!force_seen && !you.can_see(&mon) && !arena_submerged)
{
switch (desc)
{
@@ -8306,8 +8305,6 @@ std::string do_mon_str_replacements(const std::string &in_msg,
const actor* foe = (mons_wont_attack(monster)
&& invalid_monster_index(monster->foe)) ?
&you : monster->get_foe();
- const monsters* m_foe = (foe && foe->atype() == ACT_MONSTER) ?
- dynamic_cast<const monsters*>(foe) : NULL;
if (s_type < 0 || s_type >= NUM_LOUDNESS || s_type == NUM_SHOUTS)
s_type = mons_shouts(monster->type);
@@ -8341,16 +8338,17 @@ std::string do_mon_str_replacements(const std::string &in_msg,
else
{
std::string foe_name;
- if (you.can_see(m_foe) || crawl_state.arena)
+ const monsters* m_foe = dynamic_cast<const monsters*>(foe);
+ if (you.can_see(foe) || crawl_state.arena)
{
if (m_foe->attitude == ATT_FRIENDLY
&& !mons_is_unique(m_foe->type)
&& !crawl_state.arena)
{
- foe_name = m_foe->name(DESC_NOCAP_YOUR);
+ foe_name = foe->name(DESC_NOCAP_YOUR);
}
else
- foe_name = m_foe->name(DESC_NOCAP_THE);
+ foe_name = foe->name(DESC_NOCAP_THE);
}
else
foe_name = "something";
@@ -8368,16 +8366,14 @@ std::string do_mon_str_replacements(const std::string &in_msg,
msg = replace_all(msg, "@Foe@", upcase_first(foe_name));
if (m_foe->is_named())
- msg = replace_all(msg, "@foe_name@",
- m_foe->name(DESC_PLAIN, true));
+ msg = replace_all(msg, "@foe_name@", foe->name(DESC_PLAIN, true));
std::string species = mons_type_name(mons_species(m_foe->type),
DESC_PLAIN);
msg = replace_all(msg, "@foe_species@", species);
- std::string genus = mons_type_name(mons_genus(m_foe->type),
- DESC_PLAIN);
+ std::string genus = mons_type_name(mons_genus(m_foe->type), DESC_PLAIN);
msg = replace_all(msg, "@foe_genus@", genus);
msg = replace_all(msg, "@foe_genus_plural@", pluralise(genus));
@@ -8387,7 +8383,7 @@ std::string do_mon_str_replacements(const std::string &in_msg,
description_level_type nocap = DESC_NOCAP_THE, cap = DESC_CAP_THE;
- if (monster->is_named() && player_monster_visible(monster))
+ if (monster->is_named() && you.can_see(monster))
{
std::string name = monster->name(DESC_CAP_THE);
@@ -8399,7 +8395,7 @@ std::string do_mon_str_replacements(const std::string &in_msg,
else if (monster->attitude == ATT_FRIENDLY
&& !mons_is_unique(monster->type)
&& !crawl_state.arena
- && player_monster_visible(monster))
+ && you.can_see(monster))
{
nocap = DESC_PLAIN;
cap = DESC_PLAIN;
@@ -8432,8 +8428,7 @@ std::string do_mon_str_replacements(const std::string &in_msg,
msg = replace_all(msg, "@feature@", "buggy unseen feature");
}
-
- if (player_monster_visible(monster))
+ if (you.can_see(monster))
{
std::string something = monster->name(DESC_PLAIN);
msg = replace_all(msg, "@something@", something);