diff options
author | Steve Melenchuk <smelenchuk@gmail.com> | 2014-05-23 13:43:07 -0600 |
---|---|---|
committer | Steve Melenchuk <smelenchuk@gmail.com> | 2014-05-23 13:58:16 -0600 |
commit | df56bc9af60c6a091d13ee8c51212638c114d116 (patch) | |
tree | 9e188ec8bf894fefd0b2268d06dd940e95223d94 /crawl-ref/source/items.cc | |
parent | cc16dbc6859834ec60dfe42dbe877fe2a6d8b920 (diff) | |
download | crawl-ref-df56bc9af60c6a091d13ee8c51212638c114d116.tar.gz crawl-ref-df56bc9af60c6a091d13ee8c51212638c114d116.zip |
Really fix Gozag gold detection (#8584).
It was moving the wrong item to the top of the cell - I wanted
item_def::index(), not item_def::link.
Also, if the gold was the second item on the cell, it would get missed, and
if more than one identical item was being generated on the same tile before
and after the gold, it could also get missed.
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r-- | crawl-ref/source/items.cc | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index c4c7f64233..e706879b8f 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1911,6 +1911,24 @@ void clear_item_pickup_flags(item_def &item) item.flags &= ~(ISFLAG_THROWN | ISFLAG_DROPPED | ISFLAG_NO_PICKUP); } +// Move gold to the the top of a pile if following Gozag. +static void _gozag_move_gold_to_top(const coord_def p) +{ + if (you_worship(GOD_GOZAG)) + { + for (int gold = igrd(p); gold != NON_ITEM; + gold = mitm[gold].link) + { + if (mitm[gold].base_type == OBJ_GOLD) + { + unlink_item(gold); + move_item_to_grid(&gold, p, true); + break; + } + } + } +} + // Moves mitm[obj] to p... will modify the value of obj to // be the index of the final object (possibly different). // @@ -1963,6 +1981,7 @@ bool move_item_to_grid(int *const obj, const coord_def& p, bool silent) merge_item_stacks(item, *si); destroy_item(ob); ob = si->index(); + _gozag_move_gold_to_top(p); return true; } } @@ -1998,20 +2017,8 @@ bool move_item_to_grid(int *const obj, const coord_def& p, bool silent) if (item_is_orb(item)) env.orb_pos = p; - // Gozag: make sure gold stays on top of piles. - if (you_worship(GOD_GOZAG) && item.base_type != OBJ_GOLD) - { - for (int gold = mitm[igrd(p)].link; gold != NON_ITEM; - gold = mitm[gold].link) - { - if (mitm[gold].base_type == OBJ_GOLD) - { - unlink_item(gold); - move_item_to_grid(&gold, p, true); - break; - } - } - } + if (item.base_type != OBJ_GOLD) + _gozag_move_gold_to_top(p); return true; } |