From 031aedb7a9cfa7ad7d86fef1a0ae3b382d31ebb9 Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 29 Dec 2006 13:22:12 +0000 Subject: Fix for bug 1622129, safe_autopickup check was happening before monster movement. Autopickup is no longer a delay but rather receives special handling (ouch, should be done better.) This necessitated removing a safety assert() in delay.cc. Also, you now get two messages when autopickup kicks in: You see 2 scrolls of identify here. C - 3 scrolls of identify I consider this...a feature. Right. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@729 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 3 +++ crawl-ref/source/delay.cc | 18 ++++-------------- crawl-ref/source/enum.h | 1 - crawl-ref/source/items.cc | 30 +++++++++++++++++------------- crawl-ref/source/items.h | 3 +++ 5 files changed, 27 insertions(+), 28 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 8b88aaf21a..5a3a678895 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -838,6 +838,9 @@ static void input() { middle_input(); + if ( need_to_autopickup() ) + autopickup(); + handle_delay(); gotoxy(18,9); diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index c7aab68460..659a1b76a5 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -202,7 +202,7 @@ void stop_delay( void ) // XXX: Large problems with object destruction here... food can // be from in the inventory or on the ground and these are // still handled quite differently. Eventually we would like - // this to be stoppable, with partial food items implimented. -- bwr + // this to be stoppable, with partial food items implemented. -- bwr break; case DELAY_ARMOUR_ON: @@ -218,7 +218,6 @@ void stop_delay( void ) // and would have to have a prompt... this works just fine. -- bwr break; - case DELAY_AUTOPICKUP: // one turn... too much trouble case DELAY_WEAPON_SWAP: // one turn... too much trouble case DELAY_DROP_ITEM: // one turn... only used for easy armour drops case DELAY_ASCENDING_STAIRS: // short... and probably what people want @@ -385,16 +384,6 @@ static void finish_delay(const delay_queue_item &delay) char str_pass[ ITEMNAME_SIZE ]; switch (delay.type) { - case DELAY_AUTOPICKUP: - { - const int estop = - you.running == RMODE_EXPLORE_GREEDY? - ES_GREEDY_PICKUP : ES_PICKUP; - if ((Options.explore_stop & estop) && prompt_stop_explore(estop)) - stop_delay(); - break; - } - case DELAY_WEAPON_SWAP: weapon_switch( delay.parm1 ); break; @@ -775,7 +764,8 @@ static void handle_run_delays(const delay_queue_item &delay) return; } - ASSERT( !you.turn_is_over ); + if ( you.turn_is_over ) + return; command_type cmd = CMD_NO_CMD; switch (delay.type) @@ -1014,7 +1004,7 @@ activity_interrupt_type get_activity_interrupt(const std::string &name) static const char *delay_names[] = { "not_delayed", "eat", "armour_on", "armour_off", "jewellery_on", - "memorise", "butcher", "autopickup", "weapon_swap", "passwall", + "memorise", "butcher", "weapon_swap", "passwall", "drop_item", "multidrop", "ascending_stairs", "descending_stairs", "run", "rest", "travel", "macro", "interruptible", "uninterruptible", }; diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index e5e8228d15..79dfd9e4c3 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -811,7 +811,6 @@ enum delay_type DELAY_JEWELLERY_ON, DELAY_MEMORISE, DELAY_BUTCHER, - DELAY_AUTOPICKUP, DELAY_WEAPON_SWAP, // for easy_butcher DELAY_PASSWALL, DELAY_DROP_ITEM, diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 9a5afc4fcf..180e5d17a2 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -60,12 +60,13 @@ #include "stuff.h" #include "stash.h" -static void autopickup(void); static bool invisible_to_player( const item_def& item ); static void item_list_on_square( std::vector& items, int obj, bool force_squelch = false ); static void autoinscribe_item( item_def& item ); -static void autoinscribe_items( void ); +static void autoinscribe_items(); + +static bool will_autopickup = false; // Used to be called "unlink_items", but all it really does is make // sure item coordinates are correct to the stack they're in. -- bwr @@ -733,6 +734,11 @@ static void item_list_on_square( std::vector& items, } } +bool need_to_autopickup() +{ + return will_autopickup; +} + /* * Takes keyin as an argument because it will only display a long list of items * if ; is pressed. @@ -754,7 +760,7 @@ void item_check(char keyin) } autoinscribe_items(); - autopickup(); + will_autopickup = true; origin_set(you.x_pos, you.y_pos); @@ -1522,7 +1528,6 @@ int move_item_to_player( int obj, int quant_got, bool quiet ) item.y = -1; item.link = freeslot; - /*** HP CHANGE: do autoinscribe ***/ autoinscribe_item( item ); @@ -2934,19 +2939,20 @@ bool can_autopickup() return (true); } -static void autopickup(void) +void autopickup() { //David Loewenstern 6/99 int result, o, next; bool did_pickup = false; bool tried_pickup = false; + will_autopickup = false; + if (!can_autopickup()) return; o = igrd[you.x_pos][you.y_pos]; - int unthrown = 0; while (o != NON_ITEM) { next = mitm[o].link; @@ -2971,9 +2977,6 @@ static void autopickup(void) num_to_take = num_can_take; } - if (!(mitm[o].flags & ISFLAG_THROWN)) - unthrown++; - mitm[o].flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED); result = move_item_to_player(o, num_to_take); @@ -2997,13 +3000,14 @@ static void autopickup(void) o = next; } - // move_item_to_player should leave things linked. -- bwr - // relink_cell(you.x_pos, you.y_pos); - if (did_pickup) { you.turn_is_over = true; - start_delay( DELAY_AUTOPICKUP, 1, unthrown ); + const int estop = + you.running == RMODE_EXPLORE_GREEDY? + ES_GREEDY_PICKUP : ES_PICKUP; + if ((Options.explore_stop & estop) && prompt_stop_explore(estop)) + stop_delay(); } // Greedy explore has no good way to deal with an item that we can't // pick up, so the only thing to do is to stop. diff --git a/crawl-ref/source/items.h b/crawl-ref/source/items.h index 459d52b862..d741cbf8fe 100644 --- a/crawl-ref/source/items.h +++ b/crawl-ref/source/items.h @@ -145,4 +145,7 @@ void origin_set_inventory( void (*oset)(item_def &item) ); bool item_needs_autopickup(const item_def &); bool can_autopickup(); +bool need_to_autopickup(); +void autopickup(); + #endif -- cgit v1.2.3-54-g00ecf