From fac344b62ebbf48e7b1d2a7b5f0bcdd3608bd4a7 Mon Sep 17 00:00:00 2001 From: haranp Date: Sat, 21 Apr 2007 16:18:19 +0000 Subject: Eliminated it_name(), in_name(), item_name(). The function to use is now item_def::name(). Cleaned up a lot of code in the process. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1341 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/invent.cc | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'crawl-ref/source/invent.cc') diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index 78d0aacf20..a00e69a77b 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -61,15 +61,19 @@ InvEntry::InvEntry( const item_def &i ) : MenuEntry( "", MEL_ITEM ), item( &i ) { data = const_cast( item ); - char buf[ITEMNAME_SIZE]; if (i.base_type == OBJ_GOLD) + { + // XXX XXX FIXME XXX XXX Why the special-casing? + char buf[ITEMNAME_SIZE]; snprintf(buf, sizeof buf, "%d gold piece%s", i.quantity, - (i.quantity > 1? "s" : "")); + (i.quantity > 1? "s" : "")); + text = buf; + } else - item_name(i, - in_inventory(i)? - DESC_INVENTORY_EQUIP : DESC_NOCAP_A, buf, false); - text = buf; + { + text = i.name(in_inventory(i)? DESC_INVENTORY_EQUIP : DESC_NOCAP_A, + false); + } if (i.base_type != OBJ_GOLD && in_inventory(i)) { @@ -738,26 +742,23 @@ static bool has_warning_inscription(const item_def& item, { char iletter = (char)(oper); unsigned int i; - char name[ITEMNAME_SIZE]; - item_name(item, DESC_INVENTORY, name, false); 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 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)); + item.name(DESC_INVENTORY).c_str()); return yesno(prompt, false, 'n'); } else -- cgit v1.2.3-54-g00ecf