diff options
author | Neil Moore <neil@s-z.org> | 2014-05-29 13:08:59 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2014-05-29 13:19:12 -0400 |
commit | 8a4a71836c47770cf45212f7bf790c2a58937402 (patch) | |
tree | 49e02ca6b7fd76f57681aa1b1314c841187e21d3 /crawl-ref/source/itemprop.cc | |
parent | 1c38e164c05f2e4a26c45ea7df6749b15a19fd31 (diff) | |
download | crawl-ref-8a4a71836c47770cf45212f7bf790c2a58937402.tar.gz crawl-ref-8a4a71836c47770cf45212f7bf790c2a58937402.zip |
Refactor a bit.
Diffstat (limited to 'crawl-ref/source/itemprop.cc')
-rw-r--r-- | crawl-ref/source/itemprop.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index d2bb328837..d937f34c6d 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -37,6 +37,7 @@ #include "quiver.h" #include "random.h" #include "shopping.h" +#include "terrain.h" #include "xom.h" static iflags_t _full_ident_mask(const item_def& item); @@ -635,7 +636,7 @@ void do_uncurse_item(item_def &item, bool inscribe, bool no_ash, ash_check_bondage(); } -/* +/** * Make a net stationary (because it currently traps a victim). * * @param item The net item. @@ -646,8 +647,8 @@ void set_net_stationary(item_def &item) item.plus2 = 1; } -/* - * Is the item stationary (unmovable) +/** + * Is the item stationary (unmovable)? * * Currently only carrion and nets with a trapped victim are stationary. * @param item The item. @@ -658,8 +659,8 @@ bool item_is_stationary(const item_def &item) return item.base_type == OBJ_CORPSES || item_is_stationary_net(item); } -/* - * Is the item a stationary net +/** + * Is the item a stationary net? * * @param item The item. * @returns True iff the item is a stationary net. @@ -670,6 +671,22 @@ bool item_is_stationary_net(const item_def &item) && item.plus2; } +/** + * Get the actor held in a stationary net. + * + * @param net A stationary net item. + * @returns A pointer to the actor in the net, guaranteed to be non-null. + */ +actor *net_holdee(const item_def &net) +{ + ASSERT(item_is_stationary_net(net)); + // Stationary nets should not be in inventory etc. + ASSERT_IN_BOUNDS(net.pos); + actor * const a = actor_at(net.pos); + ASSERTM(a, "No actor in stationary net at (%d,%d)", net.pos.x, net.pos.y); + return a; +} + static bool _in_shop(const item_def &item) { // yay the shop hack... |