u.uswallow
Make sure u.uswallow is cleared when u.ustuck gets set to Null so that they won't be out of sync with each other. Having u.uswallow be non-zero does imply that u.ustuck is non-Null. Running #panic while swallowed didn't produce any anomalies for me, either before or after this change.
This commit is contained in:
3
src/do.c
3
src/do.c
@@ -1442,8 +1442,7 @@ goto_level(
|
|||||||
unplacebc();
|
unplacebc();
|
||||||
reset_utrap(FALSE); /* needed in level_tele */
|
reset_utrap(FALSE); /* needed in level_tele */
|
||||||
fill_pit(u.ux, u.uy);
|
fill_pit(u.ux, u.uy);
|
||||||
set_ustuck((struct monst *) 0); /* idem */
|
set_ustuck((struct monst *) 0); /* clear u.ustuck and u.uswallow */
|
||||||
u.uswallow = u.uswldtim = 0;
|
|
||||||
set_uinwater(0); /* u.uinwater = 0 */
|
set_uinwater(0); /* u.uinwater = 0 */
|
||||||
u.uundetected = 0; /* not hidden, even if means are available */
|
u.uundetected = 0; /* not hidden, even if means are available */
|
||||||
keepdogs(FALSE);
|
keepdogs(FALSE);
|
||||||
|
|||||||
15
src/mon.c
15
src/mon.c
@@ -2952,7 +2952,7 @@ monkilled(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
set_ustuck(struct monst* mtmp)
|
set_ustuck(struct monst *mtmp)
|
||||||
{
|
{
|
||||||
if (iflags.sanity_check || iflags.debug_fuzzer) {
|
if (iflags.sanity_check || iflags.debug_fuzzer) {
|
||||||
if (mtmp && !next2u(mtmp->mx, mtmp->my))
|
if (mtmp && !next2u(mtmp->mx, mtmp->my))
|
||||||
@@ -2962,23 +2962,26 @@ set_ustuck(struct monst* mtmp)
|
|||||||
|
|
||||||
g.context.botl = 1;
|
g.context.botl = 1;
|
||||||
u.ustuck = mtmp;
|
u.ustuck = mtmp;
|
||||||
|
if (!u.ustuck) {
|
||||||
|
u.uswallow = 0;
|
||||||
|
u.uswldtim = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
unstuck(struct monst* mtmp)
|
unstuck(struct monst *mtmp)
|
||||||
{
|
{
|
||||||
if (u.ustuck == mtmp) {
|
if (u.ustuck == mtmp) {
|
||||||
struct permonst *ptr = mtmp->data;
|
struct permonst *ptr = mtmp->data;
|
||||||
|
unsigned swallowed = u.uswallow;
|
||||||
|
|
||||||
/* do this first so that docrt()'s botl update is accurate;
|
/* do this first so that docrt()'s botl update is accurate;
|
||||||
safe to do as long as u.uswallow is also cleared before docrt() */
|
clears u.uswallow as well as setting u.ustuck to Null */
|
||||||
set_ustuck((struct monst *) 0);
|
set_ustuck((struct monst *) 0);
|
||||||
|
|
||||||
if (u.uswallow) {
|
if (swallowed) {
|
||||||
u.ux = mtmp->mx;
|
u.ux = mtmp->mx;
|
||||||
u.uy = mtmp->my;
|
u.uy = mtmp->my;
|
||||||
u.uswallow = 0;
|
|
||||||
u.uswldtim = 0;
|
|
||||||
if (Punished && uchain->where != OBJ_FLOOR)
|
if (Punished && uchain->where != OBJ_FLOOR)
|
||||||
placebc();
|
placebc();
|
||||||
g.vision_full_recalc = 1;
|
g.vision_full_recalc = 1;
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ dosave0(void)
|
|||||||
/* these pointers are no longer valid, and at least u.usteed
|
/* these pointers are no longer valid, and at least u.usteed
|
||||||
* may mislead place_monster() on other levels
|
* may mislead place_monster() on other levels
|
||||||
*/
|
*/
|
||||||
set_ustuck((struct monst *) 0);
|
set_ustuck((struct monst *) 0); /* also clears u.uswallow */
|
||||||
u.usteed = (struct monst *) 0;
|
u.usteed = (struct monst *) 0;
|
||||||
|
|
||||||
for (ltmp = (xint8) 1; ltmp <= maxledgerno(); ltmp++) {
|
for (ltmp = (xint8) 1; ltmp <= maxledgerno(); ltmp++) {
|
||||||
|
|||||||
@@ -354,6 +354,7 @@ teleok(coordxy x, coordxy y, boolean trapok)
|
|||||||
void
|
void
|
||||||
teleds(coordxy nux, coordxy nuy, int teleds_flags)
|
teleds(coordxy nux, coordxy nuy, int teleds_flags)
|
||||||
{
|
{
|
||||||
|
unsigned was_swallowed;
|
||||||
boolean ball_active, ball_still_in_range = FALSE,
|
boolean ball_active, ball_still_in_range = FALSE,
|
||||||
allow_drag = (teleds_flags & TELEDS_ALLOW_DRAG) != 0,
|
allow_drag = (teleds_flags & TELEDS_ALLOW_DRAG) != 0,
|
||||||
is_teleport = (teleds_flags & TELEDS_TELEPORT) != 0;
|
is_teleport = (teleds_flags & TELEDS_TELEPORT) != 0;
|
||||||
@@ -391,6 +392,7 @@ teleds(coordxy nux, coordxy nuy, int teleds_flags)
|
|||||||
unplacebc(); /* have to move the ball */
|
unplacebc(); /* have to move the ball */
|
||||||
}
|
}
|
||||||
reset_utrap(FALSE);
|
reset_utrap(FALSE);
|
||||||
|
was_swallowed = u.uswallow; /* set_ustuck(Null) clears uswallow */
|
||||||
set_ustuck((struct monst *) 0);
|
set_ustuck((struct monst *) 0);
|
||||||
u.ux0 = u.ux;
|
u.ux0 = u.ux;
|
||||||
u.uy0 = u.uy;
|
u.uy0 = u.uy;
|
||||||
@@ -400,9 +402,7 @@ teleds(coordxy nux, coordxy nuy, int teleds_flags)
|
|||||||
g.youmonst.m_ap_type = M_AP_NOTHING;
|
g.youmonst.m_ap_type = M_AP_NOTHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (u.uswallow) {
|
if (was_swallowed) {
|
||||||
/* subset of unstuck() */
|
|
||||||
u.uswldtim = u.uswallow = 0;
|
|
||||||
if (Punished) { /* ball&chain are off map while swallowed */
|
if (Punished) { /* ball&chain are off map while swallowed */
|
||||||
ball_active = TRUE; /* to put chain and non-carried ball on map */
|
ball_active = TRUE; /* to put chain and non-carried ball on map */
|
||||||
ball_still_in_range = allow_drag = FALSE; /* (redundant) */
|
ball_still_in_range = allow_drag = FALSE; /* (redundant) */
|
||||||
|
|||||||
Reference in New Issue
Block a user