summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/items.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-08 11:56:10 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-08 11:56:10 +0000
commitd8a3aef168a6f025525282d57a4649c01439404d (patch)
tree19980a35173d7f2148d440b4b9bd5a51f5719b08 /crawl-ref/source/items.cc
parent4a90639598b8814c8c9036a8b8d2deccbc16d50f (diff)
downloadcrawl-ref-d8a3aef168a6f025525282d57a4649c01439404d.tar.gz
crawl-ref-d8a3aef168a6f025525282d57a4649c01439404d.zip
Fix 2008976: Unlinked items after area_shift()
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6454 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r--crawl-ref/source/items.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index e373e6f93b..ccce30d015 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1686,11 +1686,11 @@ bool move_item_to_grid( int *const obj, int x, int y )
// Need to actually move object, so first unlink from old position.
unlink_item( *obj );
- // move item to coord:
+ // Move item to coord.
mitm[*obj].x = x;
mitm[*obj].y = y;
- // link item to top of list.
+ // Link item to top of list.
mitm[*obj].link = igrd[x][y];
igrd[x][y] = *obj;
@@ -1710,11 +1710,21 @@ bool move_item_to_grid( int *const obj, int x, int y )
void move_item_stack_to_grid( int x, int y, int targ_x, int targ_y )
{
+ if (igrd[x][y] == NON_ITEM)
+ return;
+
// Tell all items in stack what the new coordinate is.
for (int o = igrd[x][y]; o != NON_ITEM; o = mitm[o].link)
{
mitm[o].x = targ_x;
mitm[o].y = targ_y;
+
+ // Link last of the stack to the top of the old stack.
+ if (mitm[o].link == NON_ITEM && igrd[targ_x][targ_y] != NON_ITEM)
+ {
+ mitm[o].link = igrd[targ_x][targ_y];
+ break;
+ }
}
igrd[targ_x][targ_y] = igrd[x][y];