diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-08 11:56:10 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-07-08 11:56:10 +0000 |
commit | d8a3aef168a6f025525282d57a4649c01439404d (patch) | |
tree | 19980a35173d7f2148d440b4b9bd5a51f5719b08 /crawl-ref | |
parent | 4a90639598b8814c8c9036a8b8d2deccbc16d50f (diff) | |
download | crawl-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')
-rw-r--r-- | crawl-ref/source/abyss.cc | 25 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 14 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 4 |
3 files changed, 34 insertions, 9 deletions
diff --git a/crawl-ref/source/abyss.cc b/crawl-ref/source/abyss.cc index e3e850af08..2ded18e8a7 100644 --- a/crawl-ref/source/abyss.cc +++ b/crawl-ref/source/abyss.cc @@ -74,13 +74,15 @@ static bool _place_feature_near( const coord_def ¢re, return (false); } +//#define DEBUG_ABYSS + // Public for abyss generation. void generate_abyss() { int i, j; // loop variables int temp_rand; // probability determination {dlb} -#if DEBUG_ABYSS +#ifdef DEBUG_ABYSS mprf(MSGCH_DIAGNOSTICS, "generate_abyss(); turn_on_level: %d", env.turns_on_level); #endif @@ -157,7 +159,7 @@ static void _generate_area(int gx1, int gy1, int gx2, int gy2, bool placed_abyssal_rune = find_floor_item(OBJ_MISCELLANY, MISC_RUNE_OF_ZOT); -#if DEBUG_ABYSS +#ifdef DEBUG_ABYSS mprf(MSGCH_DIAGNOSTICS, "_generate_area(). turns_on_level: %d, rune_on_floor: %s", env.turns_on_level, placed_abyssal_rune? "yes" : "no"); @@ -403,7 +405,8 @@ static void _abyss_lose_monster(monsters &mons) void area_shift(void) { #ifdef DEBUG_ABYSS - mpr("area_shift().", MSGCH_DIAGNOSTICS); + mprf(MSGCH_DIAGNOSTICS, "area_shift() - player at pos (%d, %d)", + you.x_pos, you.y_pos); #endif // Preserve floor props around the player, primarily so that @@ -469,6 +472,10 @@ void area_shift(void) grd[i][j] = DNGN_UNSEEN; // Nuke items. +#ifdef DEBUG_ABYSS + if (igrd[i][j] != NON_ITEM) + mprf(MSGCH_DIAGNOSTICS, "Nuke item stack at (%d, %d)", i, j); +#endif lose_item_stack( i, j ); if (mgrd[i][j] != NON_MONSTER) @@ -476,12 +483,12 @@ void area_shift(void) } // Shift all monsters & items to new area. - for (int i = you.x_pos - 10; i < you.x_pos + 11; i++) + for (int i = you.x_pos - 10; i <= you.x_pos + 10; i++) { if (i < 0 || i >= GXM) continue; - for (int j = you.y_pos - 10; j < you.y_pos + 11; j++) + for (int j = you.y_pos - 10; j <= you.y_pos + 10; j++) { if (j < 0 || j >= GYM) continue; @@ -493,6 +500,14 @@ void area_shift(void) grd[ipos][jpos] = grd[i][j]; // Move item. +#ifdef DEBUG_ABYSS + if (igrd[i][j] != NON_ITEM) + { + mprf(MSGCH_DIAGNOSTICS, + "Move item stack from (%d, %d) to (%d, %d)", + i, j, ipos, jpos); + } +#endif move_item_stack_to_grid( i, j, ipos, jpos ); // Move monster. 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]; diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 2ebe2153f9..7e23bd12e7 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -2730,8 +2730,8 @@ bool stop_attack_prompt(const monsters *mon, bool beam_attack, else if (inSanctuary || wontAttack || (isNeutral || isHoly) && is_good_god(you.religion) || isUnchivalric - && you.religion == GOD_SHINING_ONE - && !tso_unchivalric_attack_safe_monster(mon)) + && you.religion == GOD_SHINING_ONE + && !tso_unchivalric_attack_safe_monster(mon)) { // "Really fire through the helpless neutral holy Daeva?" // was: "Really fire through this helpless neutral holy creature?" |