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 | |
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.
-rw-r--r-- | crawl-ref/source/dactions.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/dungeon.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 35 |
3 files changed, 23 insertions, 16 deletions
diff --git a/crawl-ref/source/dactions.cc b/crawl-ref/source/dactions.cc index da2273049e..703aa9f4e1 100644 --- a/crawl-ref/source/dactions.cc +++ b/crawl-ref/source/dactions.cc @@ -326,7 +326,7 @@ static void _apply_daction(daction_type act) if (j->base_type == OBJ_GOLD) { bool detected = false; - int dummy = j->link; + int dummy = j->index(); j->special = 0; unlink_item(dummy); move_item_to_grid(&dummy, *ri, true); diff --git a/crawl-ref/source/dungeon.cc b/crawl-ref/source/dungeon.cc index c6271ee301..eb0510bd4d 100644 --- a/crawl-ref/source/dungeon.cc +++ b/crawl-ref/source/dungeon.cc @@ -293,7 +293,7 @@ static void _count_gold() for (unsigned int i = 0; i < gold_places.size(); i++) { bool detected = false; - int dummy = gold_piles[i]->link; + int dummy = gold_piles[i]->index(); coord_def &pos = gold_places[i]; unlink_item(dummy); move_item_to_grid(&dummy, pos, true); 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; } |