summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/invent.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-15 15:26:57 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-15 15:26:57 +0000
commitcc137f4b229d1763c3ad71fe56605b8611a1067c (patch)
tree601f5b148db6c1d94d593d89a11208ae3fa925ad /crawl-ref/source/invent.cc
parent8b6107e382417e437cc541dfad85c20234ca3d7c (diff)
downloadcrawl-ref-cc137f4b229d1763c3ad71fe56605b8611a1067c.tar.gz
crawl-ref-cc137f4b229d1763c3ad71fe56605b8611a1067c.zip
Another code cleanup.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4244 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/invent.cc')
-rw-r--r--crawl-ref/source/invent.cc46
1 files changed, 25 insertions, 21 deletions
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<SelItem> 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<char>(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 ))
{