From 31940f5b3abb5a8ad9fe4ba4a420f943bf84eb03 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Tue, 20 Jan 2009 14:33:54 +0000 Subject: Fix bug #2517821: if a trap killed a monster and then tried to drop ammo it would get a position of (0, 0) from the dead monster and place it there, leading to a debug_item_scan() warning. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8626 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/traps.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/traps.cc') diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 0e0bd2ec4f..764f3b429b 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -1129,6 +1129,10 @@ void trap_def::shoot_ammo(actor& act, bool was_known) } else { + // Record position now, in case it's a monster and dies (thus + // resetting its position) before the ammo can be droped. + const coord_def apos = act.pos(); + item_def shot = this->generate_trap_item(); bool poison = (this->type == TRAP_NEEDLE); int damage_taken = @@ -1233,7 +1237,7 @@ void trap_def::shoot_ammo(actor& act, bool was_known) // Drop the item (sometimes.) if (coinflip()) - copy_item_to_grid(shot, act.pos()); + copy_item_to_grid(shot, apos); this->ammo_qty--; } -- cgit v1.2.3-54-g00ecf