From 0ef58589f1a7db17167f64a609131c017b03bf45 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 10 May 2019 15:21:59 -0700 Subject: [PATCH] place_object vs multiple boulders When place_object() puts a non-boulder underneath a boulder, make it put the non-boulder under all the boulders there rather than just under the topmost one. Otherwise the map display will show the non-boulder rather than the 2nd boulder if the top boulder gets moved away by some means other than pushing. (Pushing explicitly brings lower boulder to top of pile in order to try to push it next.) Reproduce by: wish for boulder--it will drop. Drop something else-- the something-else will end up under the boulder. Repeat. The second boulder will be on top but the second something-else will be next in the pile, above the first boulder. Now polymorph into a giant and pick up the first boulder, then move away from that spot. Map will show second something-else instead of the remaining boulder. This fairly simple fix should work reliably on new games since boulders will end up being consecutive on the top of piles. For old games, boulders after the topmost could be anywhere and still yield a display glitch, but since that's all the problem is (I hope...), we ought to be able to live with that until old games eventually go away. [A map display glitch doesn't explain a corrupted 'uball' so this fix doesn't solve that.] --- doc/fixes36.3 | 8 +++++++- src/mkobj.c | 25 +++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/doc/fixes36.3 b/doc/fixes36.3 index 11a285fad..115ed8f60 100644 --- a/doc/fixes36.3 +++ b/doc/fixes36.3 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.0 $ $NHDT-Date: 1557358216 2019/05/08 23:30:16 $ +$NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.0 $ $NHDT-Date: 1557526914 2019/05/10 22:21:54 $ This fixes36.3 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.2 in May 2019. Please note, however, @@ -7,6 +7,10 @@ focus will shift to the next major release. General Fixes and Modified Features ----------------------------------- +when place_object() puts a non-boulder on the map at a spot which contains + other objects, put it under all boulders in the pile rather than just + under the top one; previously, map wasn't showing a boulder there if + the top one got moved by means other than pushing Fixes to Post-3.6.2 Problems that Were Exposed Via git Repository @@ -19,6 +23,8 @@ Platform- and/or Interface-Specific Fixes or Features General New Features -------------------- +classify sources as released, beta, or work-in-progress via NH_DEVEL_STATUS + rather than just released vs beta via BETA NetHack Community Patches (or Variation) Included diff --git a/src/mkobj.c b/src/mkobj.c index f87beb554..2da16391a 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkobj.c $NHDT-Date: 1548978605 2019/01/31 23:50:05 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.142 $ */ +/* NetHack 3.6 mkobj.c $NHDT-Date: 1557526914 2019/05/10 22:21:54 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.144 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1726,15 +1726,25 @@ int x, y; panic("place_object: obj not free"); obj_no_longer_held(otmp); - /* (could bypass this vision update if there is already a boulder here) */ - if (otmp->otyp == BOULDER) - block_point(x, y); /* vision */ - - /* obj goes under boulders */ - if (otmp2 && (otmp2->otyp == BOULDER)) { + if (otmp->otyp == BOULDER) { + if (!otmp2 || otmp2->otyp != BOULDER) + block_point(x, y); /* vision */ + } + + /* non-boulder object goes under boulders so that map will show boulder + here without display code needing to traverse pile chain to find one */ + if (otmp2 && otmp2->otyp == BOULDER && otmp->otyp != BOULDER) { + /* 3.6.3: put otmp under last consecutive boulder rather than under + just the first one; multiple boulders at same spot in new games + will be consecutive due to this, ones in old games saved before + this change might not be; can affect the map display if the top + boulder is moved/removed by some means other than pushing */ + while (otmp2->nexthere && otmp2->nexthere->otyp == BOULDER) + otmp2 = otmp2->nexthere; otmp->nexthere = otmp2->nexthere; otmp2->nexthere = otmp; } else { + /* put on top of current pile */ otmp->nexthere = otmp2; level.objects[x][y] = otmp; } @@ -1742,7 +1752,6 @@ int x, y; /* set the new object's location */ otmp->ox = x; otmp->oy = y; - otmp->where = OBJ_FLOOR; /* add to floor chain */ -- 2.40.0