From 8786fef5e47392ca5c3daa8e932c10e7c1ef9715 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 6 Nov 2009 19:25:37 +0100 Subject: Implement actor::can_see. This just relies on actor::visible_to and actor::see_cell. An arena special case was removed. --- crawl-ref/source/actor.cc | 5 +++++ crawl-ref/source/actor.h | 2 +- crawl-ref/source/monster.cc | 5 ----- crawl-ref/source/monster.h | 1 - crawl-ref/source/player.cc | 8 -------- crawl-ref/source/player.h | 1 - 6 files changed, 6 insertions(+), 16 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/actor.cc b/crawl-ref/source/actor.cc index 83dcc799aa..b00125f5b7 100644 --- a/crawl-ref/source/actor.cc +++ b/crawl-ref/source/actor.cc @@ -17,6 +17,11 @@ bool actor::observable() const return (crawl_state.arena || this == &you || you.can_see(this)); } +bool actor::can_see(const actor *target) const +{ + return (target->visible_to(this) && see_cell(target->pos())); +} + bool actor::has_equipped(equipment_type eq, int sub_type) const { const item_def *item = slot_item(eq); diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h index b48945847d..69ae5ebf79 100644 --- a/crawl-ref/source/actor.h +++ b/crawl-ref/source/actor.h @@ -109,7 +109,7 @@ public: virtual bool see_cell(const coord_def &c) const = 0; // Can the actor actually see the target? - virtual bool can_see(const actor *target) const = 0; + virtual bool can_see(const actor *target) const; // Visibility as required by messaging. In usual play: // Does the player know what's happening to the actor? diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index 28f44c2c7b..affe0e3836 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -5159,11 +5159,6 @@ bool monsters::see_cell(const coord_def &c) const return (mon_see_cell(c)); } -bool monsters::can_see(const actor *targ) const -{ - return (targ->visible_to(this) && see_cell(targ->pos())); -} - bool monsters::near_foe() const { const actor *afoe = get_foe(); diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h index d19af87d5f..5138f6b6f7 100644 --- a/crawl-ref/source/monster.h +++ b/crawl-ref/source/monster.h @@ -317,7 +317,6 @@ public: bool visible_to(const actor *looker) const; bool mon_see_cell(const coord_def& pos, bool reach = false) const; bool see_cell(const coord_def& c) const; - bool can_see(const actor *target) const; bool near_foe() const; bool is_icy() const; diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index abd9b69748..b4b02a9c02 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6903,14 +6903,6 @@ bool player::see_cell(const coord_def &c) const return (::see_cell(c)); } -bool player::can_see(const actor *target) const -{ - if (crawl_state.arena) - return target->visible_to(this); - - return (target->visible_to(this) && see_cell(target->pos())); -} - bool player::backlit(bool check_haloed) const { return (get_contamination_level() > 0 || duration[DUR_BACKLIGHT] diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index 7e8fa551b8..0d113ff5b2 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -318,7 +318,6 @@ public: bool can_see_invisible(bool unid) const; bool visible_to(const actor *looker) const; bool see_cell(const coord_def &c) const; - bool can_see(const actor *target) const; bool is_icy() const; bool is_fiery() const; -- cgit v1.2.3-54-g00ecf