From 7dc7b1ec82bb235dcdc9172ef979c78e21744a2c Mon Sep 17 00:00:00 2001 From: haranp Date: Sat, 9 Dec 2006 19:10:25 +0000 Subject: 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 --- crawl-ref/source/invent.cc | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) (limited to 'crawl-ref/source/invent.cc') 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 */ -- cgit v1.2.3-54-g00ecf