From cc137f4b229d1763c3ad71fe56605b8611a1067c Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 15 Apr 2008 15:26:57 +0000 Subject: Another code cleanup. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4244 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/invent.cc | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'crawl-ref/source/invent.cc') diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index be27796667..31c979aa22 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -661,16 +661,17 @@ unsigned char get_invent( int invent_type ) { unsigned char select; - while (true) { - select = invent_select(NULL, MT_INVLIST, invent_type, + while (true) + { + select = invent_select(NULL, MT_INVLIST, invent_type, MF_SINGLESELECT); - if ( isalpha(select) ) - { - const int invidx = letter_to_index(select); - if ( is_valid_item(you.inv[invidx]) ) + if ( isalpha(select) ) + { + const int invidx = letter_to_index(select); + if ( is_valid_item(you.inv[invidx]) ) describe_item( you.inv[invidx], true ); - } - else break; + } + else break; } redraw_screen(); return select; @@ -1023,18 +1024,23 @@ std::vector prompt_invent_items( return items; } -static int _digit_to_index( char digit, operation_types oper ) { +static int _digit_to_index( char digit, operation_types oper ) +{ const char iletter = static_cast(oper); - for ( int i = 0; i < ENDOFPACK; ++i ) { - if (is_valid_item(you.inv[i])) { + for ( int i = 0; i < ENDOFPACK; ++i ) + { + if (is_valid_item(you.inv[i])) + { const std::string& r(you.inv[i].inscription); /* note that r.size() is unsigned */ - for ( unsigned int j = 0; j + 2 < r.size(); ++j ) { - if ( r[j] == '@' && - (r[j+1] == iletter || r[j+1] == '*') && - r[j+2] == digit ) { + for ( unsigned int j = 0; j + 2 < r.size(); ++j ) + { + if ( r[j] == '@' + && (r[j+1] == iletter || r[j+1] == '*') + && r[j+2] == digit ) + { return i; } } @@ -1296,7 +1302,8 @@ int prompt_invent_item( const char *prompt, { /* scan for our item */ int res = _digit_to_index( keyin, oper ); - if ( res != -1 ) { + if ( res != -1 ) + { ret = res; if ( check_warning_inscriptions( you.inv[ret], oper ) ) break; @@ -1316,11 +1323,8 @@ int prompt_invent_item( const char *prompt, if (must_exist && !is_valid_item( you.inv[ret] )) mpr( "You do not have any such object." ); - else { - if ( check_warning_inscriptions( you.inv[ret], oper ) ) { - break; - } - } + else if ( check_warning_inscriptions( you.inv[ret], oper ) ) + break; } else if (!isspace( keyin )) { -- cgit v1.2.3-54-g00ecf