From 3e6a77f46bac1b303645b7391f72e86c882986c9 Mon Sep 17 00:00:00 2001 From: Matthew Cline Date: Fri, 27 Nov 2009 00:28:13 -0800 Subject: ShoppingList: simplify. --- crawl-ref/source/shopping.cc | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index a956f52bd0..c9ecd853be 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -2389,21 +2389,17 @@ int ShoppingList::size() const return ( list->size() ); } -void ShoppingList::move_things(const coord_def &src, const coord_def &dst) +void ShoppingList::move_things(const coord_def &_src, const coord_def &_dst) { + const level_pos src(level_id::current(), _src); + const level_pos dst(level_id::current(), _dst); + for (unsigned int i = 0; i < list->size(); i++) { CrawlHashTable &thing = (*list)[i]; - level_pos lpos = ShoppingList::thing_pos(thing); - - if (lpos.id != level_id::current()) - continue; - if (lpos.pos == src) - { - lpos.pos = dst; - thing[SHOPPING_THING_POS_KEY] = lpos; - } + if (thing_pos(thing) == src) + thing[SHOPPING_THING_POS_KEY] = dst; } } @@ -2412,9 +2408,8 @@ void ShoppingList::forget_pos(const level_pos &pos) for (unsigned int i = (list->size() - 1); i>= 0; i--) { const CrawlHashTable &thing = (*list)[i]; - const level_pos lpos = ShoppingList::thing_pos(thing); - if (lpos == pos) + if (thing_pos(thing) == pos) list->erase(i); } } -- cgit v1.2.3-54-g00ecf