diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-09 19:10:25 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-09 19:10:25 +0000 |
commit | 7dc7b1ec82bb235dcdc9172ef979c78e21744a2c (patch) | |
tree | ee9bb486381efda07e0f2697c1e9781c1b5d823b /crawl-ref | |
parent | 1a2b6ba98ba8ffd482ac94c4e7fa76910c446ffb (diff) | |
download | crawl-ref-7dc7b1ec82bb235dcdc9172ef979c78e21744a2c.tar.gz crawl-ref-7dc7b1ec82bb235dcdc9172ef979c78e21744a2c.zip |
Fixed 1612023: !d was not respected. Now dropping items with !d will
ask for confirmation for each item and abort multidrop if it receives
a negative answer to anything.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@602 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/invent.cc | 40 | ||||
-rw-r--r-- | crawl-ref/source/invent.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 11 |
3 files changed, 36 insertions, 17 deletions
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index 2be4e335c9..e9d4cf07e9 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -727,33 +727,40 @@ static int digit_to_index( char digit, operation_types oper ) { return -1; } -/* return true if user OK'd it (or no warning), false otherwise */ -static bool check_warning_inscriptions( const item_def& item, - operation_types oper ) +static bool has_warning_inscription(const item_def& item, + operation_types oper) { - unsigned int i; char iletter = (char)(oper); + unsigned int i; char name[ITEMNAME_SIZE]; - char prompt[ITEMNAME_SIZE + 100]; item_name(item, DESC_INVENTORY, name, false); - strcpy( prompt, "Really choose "); - strncat( prompt, name, ITEMNAME_SIZE ); - strcat( prompt, "?"); const std::string& r(item.inscription); - for ( i = 0; i + 1 < r.size(); ++i ) { - if ( r[i] == '!' && - (r[i+1] == iletter || r[i+1] == '*') ) { - - return yesno(prompt, false, 'n'); - } + for ( i = 0; i + 1 < r.size(); ++i ) + if (r[i] == '!' && (r[i+1] == iletter || r[i+1] == '*')) + return true; + return false; +} + +/* return true if user OK'd it (or no warning), false otherwise */ +bool check_warning_inscriptions( const item_def& item, + operation_types oper ) +{ + char prompt[ITEMNAME_SIZE + 100]; + char name[ITEMNAME_SIZE]; + if ( has_warning_inscription(item, oper) ) + { + snprintf(prompt, sizeof prompt, "Really choose %s?", + item_name(item, DESC_INVENTORY, name, false)); + return yesno(prompt, false, 'n'); } - return true; + else + return true; } // This function prompts the user for an item, handles the '?' and '*' // listings, and returns the inventory slot to the caller (which if -// must_exist is true (the default) will be an assigned item, with +// must_exist is true (the default) will be an assigned item), with // a positive quantity. // // It returns PROMPT_ABORT if the player hits escape. @@ -843,7 +850,6 @@ int prompt_invent_item( const char *prompt, need_prompt = false; need_getch = false; } - /*** HP CHANGE ***/ else if ( count == NULL && isdigit( keyin ) ) { /* scan for our item */ diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h index 566bf42b44..d99150b9dc 100644 --- a/crawl-ref/source/invent.h +++ b/crawl-ref/source/invent.h @@ -190,4 +190,6 @@ void list_commands(bool wizard); std::string item_class_name(int type, bool terse = false); +bool check_warning_inscriptions(const item_def& item, operation_types oper); + #endif diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 42d6506131..9b03065bcd 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1920,6 +1920,17 @@ void drop(void) std::sort( items_for_multidrop.begin(), items_for_multidrop.end(), drop_item_order ); + for ( unsigned int i = 0; i < items_for_multidrop.size(); ++i ) + { + if ( !check_warning_inscriptions( *(items_for_multidrop[i].item), + OPER_DROP)) + { + canned_msg( MSG_OK ); + items_for_multidrop.clear(); + return; + } + } + if ( items_for_multidrop.size() == 1 ) // only one item { drop_item( items_for_multidrop[0].slot, |