summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/traps.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-20 14:33:54 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-20 14:33:54 +0000
commit31940f5b3abb5a8ad9fe4ba4a420f943bf84eb03 (patch)
treec1d8f56c53101d15a3f28eab089d71837d2d591c /crawl-ref/source/traps.cc
parentdc59d2025591002a2ebaedcdb59540afbed1ce44 (diff)
downloadcrawl-ref-31940f5b3abb5a8ad9fe4ba4a420f943bf84eb03.tar.gz
crawl-ref-31940f5b3abb5a8ad9fe4ba4a420f943bf84eb03.zip
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
Diffstat (limited to 'crawl-ref/source/traps.cc')
-rw-r--r--crawl-ref/source/traps.cc6
1 files changed, 5 insertions, 1 deletions
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--;
}