diff options
author | Shmuale Mark <shm.mark@gmail.com> | 2014-06-19 16:05:04 -0400 |
---|---|---|
committer | Shmuale Mark <shm.mark@gmail.com> | 2014-06-22 10:03:45 -0400 |
commit | 465957cba490a2a9d5444a64523572a90cfb837f (patch) | |
tree | 536c94ce0702e60217120aa2bb27325aff1b8f2d /crawl-ref/source/directn.cc | |
parent | 393eda0d444702a7eda580e6c363bbdcaba8d54e (diff) | |
download | crawl-ref-465957cba490a2a9d5444a64523572a90cfb837f.tar.gz crawl-ref-465957cba490a2a9d5444a64523572a90cfb837f.zip |
The great mon-stuff migration.
A good deal of functions move to the two new files, mon-poly and
mon-message. Of the others, some go to where they are used, some to
mon-util, and a few are made member methods of monster.
This probably breaks Xcode compilation, and I'm not able to test
the changes I made to MSVC that will (hopefully) keep it working.
Diffstat (limited to 'crawl-ref/source/directn.cc')
-rw-r--r-- | crawl-ref/source/directn.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 79d2577aaf..05b3ec05a4 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -18,6 +18,7 @@ #include "externs.h" #include "options.h" +#include "attitude-change.h" #include "cio.h" #include "cloud.h" #include "colour.h" @@ -42,7 +43,6 @@ #include "message.h" #include "misc.h" #include "mon-death.h" -#include "mon-stuff.h" #include "mon-info.h" #include "output.h" #include "shopping.h" @@ -330,6 +330,19 @@ monster* direction_chooser::targeted_monster() const return NULL; } +// Return your target, if it still exists and is visible to you. +static monster* _get_current_target() +{ + if (invalid_monster_index(you.prev_targ)) + return NULL; + + monster* mon = &menv[you.prev_targ]; + if (mon->alive() && you.can_see(mon)) + return mon; + else + return NULL; +} + string direction_chooser::build_targeting_hint_string() const { string hint_string; @@ -337,7 +350,7 @@ string direction_chooser::build_targeting_hint_string() const // Hint for 'p' - previous target, and for 'f' - current cell, if // applicable. const actor* f_target = targeted_actor(); - const monster* p_target = get_current_target(); + const monster* p_target = _get_current_target(); if (f_target && f_target == p_target) hint_string = ", f/p - " + f_target->name(DESC_PLAIN); @@ -1033,7 +1046,7 @@ bool direction_chooser::find_default_monster_target(coord_def& result) const bool (*find_targ)(const coord_def&, int, bool, int, targetter*); // First try to pick our previous target. - const monster* mons_target = get_current_target(); + const monster* mons_target = _get_current_target(); if (mons_target != NULL && (mode != TARG_EVOLVABLE_PLANTS && mons_attitude(mons_target) == ATT_HOSTILE @@ -1633,7 +1646,7 @@ void direction_chooser::toggle_beam() bool direction_chooser::select_previous_target() { - if (const monster* mon_target = get_current_target()) + if (const monster* mon_target = _get_current_target()) { // We have all the information we need. moves.isValid = true; |