From 63e312c909cf2d91461e1b17b6e4c4a71a8250a0 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Tue, 3 Jun 2008 02:51:49 +0000 Subject: Don't include items in drop filter if they're cursed and equipped, or if they're inscribed with "!d" or "!*". git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5446 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/invent.cc | 21 +++++++++++++++++++++ crawl-ref/source/invent.h | 1 + crawl-ref/source/menu.h | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index 9ed94b4425..adb60da6e6 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -389,6 +389,27 @@ void InvMenu::draw_stock_item(int index, const MenuEntry *me) const Menu::draw_stock_item(index, me); } +bool InvMenu::is_selectable(int index) const +{ + + if (type == MT_DROP) + { + InvEntry *item = dynamic_cast(items[index]); + if (item->is_item_cursed() && item->is_item_equipped()) + return false; + + std::string text = item->get_text(); + + if (text.find("!*") != std::string::npos + || text.find("!d") != std::string::npos) + { + return false; + } + } + + return Menu::is_selectable(index); +} + template int compare_item_str(const InvEntry *a, const InvEntry *b) { diff --git a/crawl-ref/source/invent.h b/crawl-ref/source/invent.h index ad2fa005b5..46a3ead180 100644 --- a/crawl-ref/source/invent.h +++ b/crawl-ref/source/invent.h @@ -158,6 +158,7 @@ protected: const menu_sort_condition *cond); const menu_sort_condition *find_menu_sort_condition() const; virtual void draw_stock_item(int index, const MenuEntry *me) const; + virtual bool is_selectable(int index) const; protected: menu_type type; diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h index fdb1ff2ba2..91561b0440 100644 --- a/crawl-ref/source/menu.h +++ b/crawl-ref/source/menu.h @@ -311,7 +311,7 @@ protected: void select_index( int index, int qty = -1 ); bool is_hotkey(int index, int key ); - bool is_selectable(int index) const; + virtual bool is_selectable(int index) const; virtual int item_colour(int index, const MenuEntry *me) const; -- cgit v1.2.3-54-g00ecf