diff options
author | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2011-03-17 01:18:57 +0530 |
---|---|---|
committer | Darshan Shaligram <dshaligram@users.sourceforge.net> | 2011-03-17 01:26:47 +0530 |
commit | 253c36b556fba611650053e2f9848a40f026f5a4 (patch) | |
tree | 687b45cb33d1e31bed4f9a7184dd78f4f6aa09e8 /crawl-ref/source/stash.h | |
parent | 8e833524887264c67f2992d333cc551102b0f282 (diff) | |
download | crawl-ref-253c36b556fba611650053e2f9848a40f026f5a4.tar.gz crawl-ref-253c36b556fba611650053e2f9848a40f026f5a4.zip |
[2930] Fix stash search results not being coloured correctly when matching item heaps.
This alters menu colouring to prefer a menu item's preset colour value over
using menu_colour on the item string.
This is really a bit of a hack: we should probably switch the stash tracker to
use real InvEntrys at some point and remove this shim.
Diffstat (limited to 'crawl-ref/source/stash.h')
-rw-r--r-- | crawl-ref/source/stash.h | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/crawl-ref/source/stash.h b/crawl-ref/source/stash.h index 1138305b31..cca68c037b 100644 --- a/crawl-ref/source/stash.h +++ b/crawl-ref/source/stash.h @@ -197,9 +197,43 @@ struct stash_search_result const Stash *stash; const ShopInfo *shop; + // The item that matched the search, if any. + std::auto_ptr<item_def> matching_item; + stash_search_result() : pos(), player_distance(0), matches(0), - count(0), match(), stash(NULL), shop(NULL) + count(0), match(), stash(NULL), shop(NULL), + matching_item() + { + } + + stash_search_result(const stash_search_result &o) + : pos(o.pos), player_distance(o.player_distance), matches(o.matches), + count(o.count), match(o.match), stash(o.stash), shop(o.shop), + matching_item() + { + if (o.matching_item.get()) + matching_item.reset(new item_def(*o.matching_item)); + } + + stash_search_result &operator = (const stash_search_result &o) + { + pos = o.pos; + player_distance = o.player_distance; + matches = o.matches; + count = o.count; + match = o.match; + stash = o.stash; + shop = o.shop; + matching_item.reset(NULL); + if (o.matching_item.get()) + matching_item.reset(new item_def(*o.matching_item)); + return (*this); + } + + void set_matching_item(const item_def &item) { + if (!matching_item.get()) + matching_item.reset(new item_def(item)); } bool operator < (const stash_search_result &ssr) const |