diff options
author | Neil Moore <neil@s-z.org> | 2014-07-07 15:59:10 -0400 |
---|---|---|
committer | Neil Moore <neil@s-z.org> | 2014-07-07 16:04:04 -0400 |
commit | b5428166a3e1ab7b4bc5f0c26511e6479d98fc29 (patch) | |
tree | d094609f6a7e58a3e851a76199c4fd0868740fa7 /crawl-ref/source/items.cc | |
parent | 48b8069c387ee6b63f4d9f9270326ad917cbd9ed (diff) | |
download | crawl-ref-b5428166a3e1ab7b4bc5f0c26511e6479d98fc29.tar.gz crawl-ref-b5428166a3e1ab7b4bc5f0c26511e6479d98fc29.zip |
Fix item_pickup triggers and rune/orb milestones.
The former were broken by 0.15-a0-1884-gb98b893 and the latter by
0.15-a0-1887-gff848d3.
Unfortunately, moving the floor quantity decrement later as this
commit does means there is more opportunity for the player to send
a HUP and duplicate items. That was already a problem before
0.15-a0-1884-gb98b893, though, and I'd rather have the potential
exploit than have non-functional item_pickup triggers.
Milestones could be fixed without reintroducing the exploit, by using a
temporary on-stack copy of the object. That doesn't work for the pickup
trigger, though, because the latter needs the object's index and
therefore requires a (still-extant) floor item.
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 2554b9ac76..46364798c8 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1675,14 +1675,12 @@ bool move_item_to_inv(int obj, int quant_got, bool quiet) if (is_blood_potion(it) && quant_got != it.quantity) for (int i = 0; i < quant_got; i++) remove_oldest_blood_potion(it); - dec_mitm_item_quantity(obj, quant_got); // cleanup items that ended up in an inventory slot (not gold, etc) if (inv_slot != -1) - { _got_item(you.inv[inv_slot]); - _check_note_item(you.inv[inv_slot]); - } + + _check_note_item(it); if (item_is_rune(it) || item_is_orb(it) || in_bounds(old_item_pos)) { @@ -1692,6 +1690,12 @@ bool move_item_to_inv(int obj, int quant_got, bool quiet) you.pos()); } + // XXX: Waiting until now to decrement the quantity gives plenty of + // opportunity for the player to send a HUP and duplicate the item. + // However, we can't decrement the quantity before firing the position + // event, because the latter needs the object's index. + dec_mitm_item_quantity(obj, quant_got); + you.turn_is_over = true; return true; } |