Rework stairs structure

Use a linked list to store stair and ladder information, instead
of having fixed up/down stairs/ladders and a single "special" (branch)
stair.

Breaks saves and bones.

Adds information to migrating objects and monsters for the dungeon
and level where they are migrating from.
This commit is contained in:
Pasi Kallinen
2020-11-09 18:50:02 +02:00
parent e23f764d11
commit 6ec55a3624
34 changed files with 552 additions and 361 deletions

View File

@@ -905,6 +905,33 @@ NHFILE *nhfp;
return 1;
}
void
rest_stairs(nhfp)
NHFILE *nhfp;
{
int buflen = 0;
stairway stway;
int len = 0;
stairway_free_all();
while (1) {
if (nhfp->structlevel) {
len += sizeof(buflen);
mread(nhfp->fd, (genericptr_t) &buflen, sizeof buflen);
}
if (buflen == -1)
break;
if (nhfp->structlevel) {
len += sizeof(stairway);
mread(nhfp->fd, (genericptr_t) &stway, sizeof(stairway));
}
stairway_add(stway.sx, stway.sy, stway.up, stway.isladder, &(stway.tolev));
}
}
void
restcemetery(nhfp, cemeteryaddr)
NHFILE *nhfp;
@@ -1050,11 +1077,7 @@ xchar lev;
elapsed = g.monstermoves - g.omoves;
if (nhfp->structlevel) {
mread(nhfp->fd, (genericptr_t)&g.upstair, sizeof(stairway));
mread(nhfp->fd, (genericptr_t)&g.dnstair, sizeof(stairway));
mread(nhfp->fd, (genericptr_t)&g.upladder, sizeof(stairway));
mread(nhfp->fd, (genericptr_t)&g.dnladder, sizeof(stairway));
mread(nhfp->fd, (genericptr_t)&g.sstairs, sizeof(stairway));
rest_stairs(nhfp);
mread(nhfp->fd, (genericptr_t)&g.updest, sizeof(dest_area));
mread(nhfp->fd, (genericptr_t)&g.dndest, sizeof(dest_area));
mread(nhfp->fd, (genericptr_t)&g.level.flags, sizeof(g.level.flags));
@@ -1132,22 +1155,33 @@ xchar lev;
rest_regions(nhfp);
if (ghostly) {
stairway *stway = g.stairs;
while (stway) {
if (!stway->isladder && !stway->up && stway->tolev.dnum == u.uz.dnum)
break;
stway = stway->next;
}
/* Now get rid of all the temp fruits... */
freefruitchn(g.oldfruit), g.oldfruit = 0;
if (lev > ledger_no(&medusa_level)
&& lev < ledger_no(&stronghold_level) && xdnstair == 0) {
&& lev < ledger_no(&stronghold_level) && !stway) {
coord cc;
d_level dest;
dest.dnum = u.uz.dnum;
dest.dlevel = u.uz.dlevel + 1;
mazexy(&cc);
xdnstair = cc.x;
ydnstair = cc.y;
stairway_add(cc.x, cc.y, FALSE, FALSE, &dest);
levl[cc.x][cc.y].typ = STAIRS;
}
br = Is_branchlev(&u.uz);
if (br && u.uz.dlevel == 1) {
d_level ltmp;
stairway *stway;
if (on_level(&u.uz, &br->end1))
assign_level(&ltmp, &br->end2);
@@ -1157,8 +1191,15 @@ xchar lev;
switch (br->type) {
case BR_STAIR:
case BR_NO_END1:
case BR_NO_END2: /* OK to assign to g.sstairs if it's not used */
assign_level(&g.sstairs.tolev, &ltmp);
case BR_NO_END2:
stway = g.stairs;
while (stway) {
if (stway->tolev.dnum != u.uz.dnum)
break;
stway = stway->next;
}
if (stway)
assign_level(&(stway->tolev), &ltmp);
break;
case BR_PORTAL: /* max of 1 portal per level */
for (trap = g.ftrap; trap; trap = trap->ntrap)