diff options
author | Neil Moore <neil@s-z.org> | 2014-05-31 22:44:11 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2014-05-31 22:44:58 -0400 |
commit | 7ec533578637a75973e718e236289985149858bc (patch) | |
tree | 9c1d133e453d8291d8978e09adbedfe18cbc0dbd /crawl-ref/source/items.cc | |
parent | 41138fff585b6ea0222b2a766ec0f9416734eefc (diff) | |
download | crawl-ref-7ec533578637a75973e718e236289985149858bc.tar.gz crawl-ref-7ec533578637a75973e718e236289985149858bc.zip |
More carefully chase item links in the pickup menu (#8603)
Moving the item to the player destroyed it; normally that would have set
the non-item's link to NON_ITEM, exiting the loop, but level excursions as
part of pickup could overwrite the link.
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index dc92552887..c4e07f2756 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -873,12 +873,17 @@ void pickup_menu(int item_link) string pickup_warning; for (int i = 0, count = selected.size(); i < count; ++i) - for (int j = item_link; j != NON_ITEM; j = mitm[j].link) + { + // Moving the item might destroy it, in which case we can't + // rely on the link. + short next; + for (int j = item_link; j != NON_ITEM; j = next) { + next = mitm[j].link; if (&mitm[j] == selected[i].item) { if (j == item_link) - item_link = mitm[j].link; + item_link = next; int num_to_take = selected[i].quantity; const bool take_all = (num_to_take == mitm[j].quantity); @@ -907,6 +912,7 @@ void pickup_menu(int item_link) } } } + } if (!pickup_warning.empty()) { |