summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/invent.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-09 19:10:25 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-12-09 19:10:25 +0000
commit7dc7b1ec82bb235dcdc9172ef979c78e21744a2c (patch)
treeee9bb486381efda07e0f2697c1e9781c1b5d823b /crawl-ref/source/invent.cc
parent1a2b6ba98ba8ffd482ac94c4e7fa76910c446ffb (diff)
downloadcrawl-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/source/invent.cc')
-rw-r--r--crawl-ref/source/invent.cc40
1 files changed, 23 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 */