summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2009-11-05 15:01:52 +0100
committerAdam Borowski <kilobyte@angband.pl>2009-11-05 15:01:52 +0100
commit329209bca2c5cf2b32fe7cffc12ced1151200043 (patch)
tree9db8bc365ef272027099218cb87436af1741f4a8
parent24c5e57c05fcc819155415be59ba2d23a28284d1 (diff)
downloadcrawl-ref-329209bca2c5cf2b32fe7cffc12ced1151200043.tar.gz
crawl-ref-329209bca2c5cf2b32fe7cffc12ced1151200043.zip
Put lots of actor:: methods where they belong (Zaba)
-rw-r--r--crawl-ref/source/actor.cc64
-rw-r--r--crawl-ref/source/player.cc70
2 files changed, 64 insertions, 70 deletions
diff --git a/crawl-ref/source/actor.cc b/crawl-ref/source/actor.cc
index 009da3ba7f..657542d0f5 100644
--- a/crawl-ref/source/actor.cc
+++ b/crawl-ref/source/actor.cc
@@ -1,11 +1,75 @@
#include "AppHdr.h"
#include "actor.h"
+#include "env.h"
#include "player.h"
#include "state.h"
+#include "traps.h"
+
+actor::~actor()
+{
+}
bool actor::observable() const
{
return (crawl_state.arena || this == &you || you.can_see(this));
}
+bool actor::has_equipped(equipment_type eq, int sub_type) const
+{
+ const item_def *item = slot_item(eq);
+ return (item && item->sub_type == sub_type);
+}
+
+bool actor::will_trigger_shaft() const
+{
+ return (!airborne() && total_weight() > 0 && is_valid_shaft_level());
+}
+
+level_id actor::shaft_dest() const
+{
+ return generic_shaft_dest(pos());
+}
+
+bool actor::airborne() const
+{
+ return (is_levitating() || (flight_mode() == FL_FLY && !cannot_move()));
+}
+
+bool actor::can_wield(const item_def* item, bool ignore_curse,
+ bool ignore_brand, bool ignore_shield,
+ bool ignore_transform) const
+{
+ if (item == NULL)
+ {
+ // Unarmed combat.
+ item_def fake;
+ fake.base_type = OBJ_UNASSIGNED;
+ return can_wield(fake, ignore_curse, ignore_brand, ignore_transform);
+ }
+ else
+ return can_wield(*item, ignore_curse, ignore_brand, ignore_transform);
+}
+
+bool actor::can_pass_through(int x, int y) const
+{
+ return can_pass_through_feat(grd[x][y]);
+}
+
+bool actor::can_pass_through(const coord_def &c) const
+{
+ return can_pass_through_feat(grd(c));
+}
+
+bool actor::is_habitable(const coord_def &_pos) const
+{
+ return is_habitable_feat(grd(_pos));
+}
+
+bool actor::handle_trap()
+{
+ trap_def* trap = find_trap(pos());
+ if (trap)
+ trap->trigger(*this);
+ return (trap != NULL);
+}
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 6bf43dd736..1d84ae7496 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -5602,50 +5602,6 @@ int stat_modifier(stat_type stat)
}
}
-
-//////////////////////////////////////////////////////////////////////////////
-// actor
-
-actor::~actor()
-{
-}
-
-bool actor::has_equipped(equipment_type eq, int sub_type) const
-{
- const item_def *item = slot_item(eq);
- return (item && item->sub_type == sub_type);
-}
-
-bool actor::will_trigger_shaft() const
-{
- return (!airborne() && total_weight() > 0 && is_valid_shaft_level());
-}
-
-level_id actor::shaft_dest() const
-{
- return generic_shaft_dest(pos());
-}
-
-bool actor::airborne() const
-{
- return (is_levitating() || (flight_mode() == FL_FLY && !cannot_move()));
-}
-
-bool actor::can_pass_through(int x, int y) const
-{
- return can_pass_through_feat(grd[x][y]);
-}
-
-bool actor::can_pass_through(const coord_def &c) const
-{
- return can_pass_through_feat(grd(c));
-}
-
-bool actor::is_habitable(const coord_def &_pos) const
-{
- return is_habitable_feat(grd(_pos));
-}
-
bool player::is_habitable_feat(dungeon_feature_type actual_grid) const
{
if (!can_pass_through_feat(actual_grid))
@@ -5663,17 +5619,6 @@ bool player::is_habitable_feat(dungeon_feature_type actual_grid) const
return (true);
}
-bool actor::handle_trap()
-{
- trap_def* trap = find_trap(pos());
- if (trap)
- trap->trigger(*this);
- return (trap != NULL);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// player
-
player::player()
: m_quiver(0)
{
@@ -6155,21 +6100,6 @@ item_def *player::weapon(int /* which_attack */)
return (slot_item(EQ_WEAPON));
}
-bool actor::can_wield(const item_def* item, bool ignore_curse,
- bool ignore_brand, bool ignore_shield,
- bool ignore_transform) const
-{
- if (item == NULL)
- {
- // Unarmed combat.
- item_def fake;
- fake.base_type = OBJ_UNASSIGNED;
- return can_wield(fake, ignore_curse, ignore_brand, ignore_transform);
- }
- else
- return can_wield(*item, ignore_curse, ignore_brand, ignore_transform);
-}
-
bool player::can_wield(const item_def& item, bool ignore_curse,
bool ignore_brand, bool ignore_shield,
bool ignore_transform) const