From 5c65cedddfd6f3d893c7eaec03f3c8519e266d45 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Fri, 1 Dec 2006 15:20:32 +0000 Subject: [1597293] Preliminary greedy-explore, parked on Ctrl-I. We can (re)move it if necessary. Stash-tracking is no longer #ifdef conditionalised. I'm not aware of anybody who compiles without it. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@538 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/items.cc | 68 +++++++++++++++++++++++++++++------------------ 1 file changed, 42 insertions(+), 26 deletions(-) (limited to 'crawl-ref/source/items.cc') diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index e0313a6ff6..c040288570 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2882,47 +2882,63 @@ static void autoinscribe_items() autoinscribe_item( mitm[o] ); o = next; } -} +} -static void autopickup(void) +bool item_needs_autopickup(const item_def &item) { - //David Loewenstern 6/99 - int result, o, next; - bool did_pickup = false; - - if (!Options.autopickup_on || Options.autopickups == 0L) - return; + return (strstr(item.inscription.c_str(), "=g") != 0 + || ((item.flags & ISFLAG_THROWN) && Options.pickup_thrown) + || (((Options.autopickups & (1L << item.base_type)) +#ifdef CLUA_BINDINGS + || clua.callbooleanfn(false, "ch_autopickup", "u", &item) +#endif + ) + && (Options.pickup_dropped || !(item.flags & ISFLAG_DROPPED)) + && !is_banned(item))); +} + +bool can_autopickup() +{ + // [ds] Checking for autopickups == 0 is a bad idea because + // autopickup is still possible with inscriptions and + // pickup_thrown. + if (!Options.autopickup_on) + return (false); if (you.attribute[ATTR_TRANSFORMATION] == TRAN_AIR - && you.duration[DUR_TRANSFORMATION] > 0) - { - return; - } + && you.duration[DUR_TRANSFORMATION] > 0) + return (false); if (player_is_levitating() && !wearing_amulet(AMU_CONTROLLED_FLIGHT)) - return; + return (false); if ( Options.safe_autopickup && !i_feel_safe() ) - return; + return (false); + return (true); +} + +static void autopickup(void) +{ + //David Loewenstern 6/99 + int result, o, next; + bool did_pickup = false; + + if (!can_autopickup()) + return; + o = igrd[you.x_pos][you.y_pos]; + int unthrown = 0; while (o != NON_ITEM) { next = mitm[o].link; - if ( - (strstr(mitm[o].inscription.c_str(), "=g") != 0) || ( - - ((mitm[o].flags & ISFLAG_THROWN) && Options.pickup_thrown) || - ( (Options.autopickups & (1L << mitm[o].base_type) -#ifdef CLUA_BINDINGS - || clua.callbooleanfn(false, "ch_autopickup", "u", &mitm[o]) -#endif - ) - && (Options.pickup_dropped || !(mitm[o].flags & ISFLAG_DROPPED)) - && !is_banned(mitm[o])))) + if (item_needs_autopickup(mitm[o])) { + if (!(mitm[o].flags & ISFLAG_THROWN)) + unthrown++; + mitm[o].flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED); result = move_item_to_player( o, mitm[o].quantity); @@ -2950,7 +2966,7 @@ static void autopickup(void) if (did_pickup) { you.turn_is_over = true; - start_delay( DELAY_AUTOPICKUP, 1 ); + start_delay( DELAY_AUTOPICKUP, 1, unthrown ); } } -- cgit v1.2.3-54-g00ecf