Implement builds_up correctly, resolving its FIXME
The FIXME comment noted that builds_up would return an incorrect false
value for a dungeon branch that builds upwards but is only 1 level, but
that this is a latent problem because no such branch exists in NetHack.
Such a branch does exist in xNetHack, and it causes the debug fuzzer to
crash ("mon_arrive: no corresponding portal" because it can't find the
correct-direction stairs), so I figured I might as well fix it upstream.
This commit is contained in:
+13
-6
@@ -1413,12 +1413,19 @@ boolean
|
|||||||
builds_up(d_level *lev)
|
builds_up(d_level *lev)
|
||||||
{
|
{
|
||||||
dungeon *dptr = &gd.dungeons[lev->dnum];
|
dungeon *dptr = &gd.dungeons[lev->dnum];
|
||||||
/*
|
branch *br;
|
||||||
* FIXME: this misclassifies a single level branch reached via stairs
|
if (dptr->num_dunlevs > 1)
|
||||||
* from below. Saving grace is that no such branches currently exist.
|
return (boolean) (dptr->entry_lev == dptr->num_dunlevs);
|
||||||
*/
|
/* else, single-level branch; find the branch connection that connects this
|
||||||
return (boolean) (dptr->num_dunlevs > 1
|
* dungeon from a parent dungeon and determine whether it builds up from
|
||||||
&& dptr->entry_lev == dptr->num_dunlevs);
|
* that */
|
||||||
|
for (br = gb.branches; br; br = br->next) {
|
||||||
|
if (on_level(lev, &br->end2)) {
|
||||||
|
return br->end1_up;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impossible("builds_up: can't find branch for dungeon %d", lev->dnum);
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* goto the next level (or appropriate dungeon) */
|
/* goto the next level (or appropriate dungeon) */
|
||||||
|
|||||||
Reference in New Issue
Block a user