distinguish global variables that get written to savefile
The g? structs had a mix of variables that were written to
the savefile, and those that were not.
For better clarity and to distinguish those that end up in
the savefile, relocate some g? variables that get written
directly to the savefile into different structs.
This updates EDITLEVEL, although technically it probably
didn't need to, since savefile contents are not changing.
Details:
gb.bases -> svb.bases
gb.bbubbles -> svb.bbubbles
gb.branches -> svb.branches
gc.context -> svc.context
gd.disco -> svd.disco
gd.dndest -> svd.dndest
gd.doors -> svd.doors
gd.doors_alloc -> svd.doors_alloc
gd.dungeon_topology -> svd.dungeon_topology
gd.dungeons -> svd.dungeons
ge.exclusion_zones -> sve.exclusion_zones
gh.hackpid -> svh.hackpid
gi.inv_pos -> svi.inv_pos
gk.killer -> svk.killer
gl.lastseentyp -> svl.lastseentyp
gl.level -> svl.level
gl.level_info -> svl.level_info
gm.mapseenchn -> svm.mapseenchn
gm.moves -> svm.moves
gm.mvitals -> svm.mvitals
gn.n_dgns -> svn.n_dgns
gn.n_regions -> svn.n_regions
gn.nroom -> svn.nroom
go.oracle_cnt -> svo.oracle_cnt
gp.pl_character -> svp.pl_character
gp.pl_fruit -> svp.pl_fruit
gp.plname -> svp.plname
gp.program_state -> svp.program_state
gq.quest_status -> svq.quest_status
gr.rooms -> svr.rooms
gs.sp_levchn -> svs.sp_levchn
gs.spl_book -> svs.spl_book
gt.timer_id -> svt.timer_id
gt.tune -> svt.tune
gu.updest -> svu.updest
gx.xmax -> svx.xmax
gx.xmin -> svx.xmin
gy.ymax -> svy.ymax
gy.ymin -> svy.ymin
Related note:
There are some pointer variables that are heads of chains that were not
moved from 'g?' to 'sv?', because they are not actually written to the
savefile directly, but the objects/monst/trap/lightsource/timer in the
chains they point to are. That can be changed, if desired.
Examples: gi.invent, gm.migrating_objs, gb.billobjs, gm.migrating_mons,
gf.ftrap, gl.light_base, gt.timer_base
This commit is contained in:
86
src/mkroom.c
86
src/mkroom.c
@@ -150,14 +150,14 @@ mkshop(void)
|
||||
}
|
||||
|
||||
gottype:
|
||||
for (sroom = &gr.rooms[0];; sroom++) {
|
||||
for (sroom = &svr.rooms[0];; sroom++) {
|
||||
/* return from this loop: cannot find any eligible room to be a shop
|
||||
* continue: sroom is ineligible
|
||||
* break: sroom is eligible
|
||||
*/
|
||||
if (sroom->hx < 0)
|
||||
return;
|
||||
if (sroom - gr.rooms >= gn.nroom) {
|
||||
if (sroom - svr.rooms >= svn.nroom) {
|
||||
impossible("rooms[] not closed by -1?");
|
||||
return;
|
||||
}
|
||||
@@ -215,11 +215,11 @@ staticfn struct mkroom *
|
||||
pick_room(boolean strict)
|
||||
{
|
||||
struct mkroom *sroom;
|
||||
int i = gn.nroom;
|
||||
int i = svn.nroom;
|
||||
|
||||
for (sroom = &gr.rooms[rn2(gn.nroom)]; i--; sroom++) {
|
||||
if (sroom == &gr.rooms[gn.nroom])
|
||||
sroom = &gr.rooms[0];
|
||||
for (sroom = &svr.rooms[rn2(svn.nroom)]; i--; sroom++) {
|
||||
if (sroom == &svr.rooms[svn.nroom])
|
||||
sroom = &svr.rooms[0];
|
||||
if (sroom->hx < 0)
|
||||
return (struct mkroom *) 0;
|
||||
if (sroom->rtype != OROOM)
|
||||
@@ -274,7 +274,7 @@ fill_zoo(struct mkroom *sroom)
|
||||
int sx, sy, i;
|
||||
int sh, goldlim = 0, type = sroom->rtype;
|
||||
coordxy tx = 0, ty = 0;
|
||||
int rmno = (int) ((sroom - gr.rooms) + ROOMOFFSET);
|
||||
int rmno = (int) ((sroom - svr.rooms) + ROOMOFFSET);
|
||||
coord mm;
|
||||
|
||||
/* Note: This doesn't check needfill; it assumes the caller has already
|
||||
@@ -282,7 +282,7 @@ fill_zoo(struct mkroom *sroom)
|
||||
sh = sroom->fdoor;
|
||||
switch (type) {
|
||||
case COURT:
|
||||
if (gl.level.flags.is_maze_lev) {
|
||||
if (svl.level.flags.is_maze_lev) {
|
||||
for (tx = sroom->lx; tx <= sroom->hx; tx++)
|
||||
for (ty = sroom->ly; ty <= sroom->hy; ty++)
|
||||
if (IS_THRONE(levl[tx][ty].typ))
|
||||
@@ -320,15 +320,15 @@ fill_zoo(struct mkroom *sroom)
|
||||
if (sroom->irregular) {
|
||||
if ((int) levl[sx][sy].roomno != rmno || levl[sx][sy].edge
|
||||
|| (sroom->doorct
|
||||
&& distmin(sx, sy, gd.doors[sh].x, gd.doors[sh].y) <= 1))
|
||||
&& distmin(sx, sy, svd.doors[sh].x, svd.doors[sh].y) <= 1))
|
||||
continue;
|
||||
} else if (!SPACE_POS(levl[sx][sy].typ)
|
||||
|| (sroom->doorct
|
||||
&& ((sx == sroom->lx && gd.doors[sh].x == sx - 1)
|
||||
|| (sx == sroom->hx && gd.doors[sh].x == sx + 1)
|
||||
|| (sy == sroom->ly && gd.doors[sh].y == sy - 1)
|
||||
&& ((sx == sroom->lx && svd.doors[sh].x == sx - 1)
|
||||
|| (sx == sroom->hx && svd.doors[sh].x == sx + 1)
|
||||
|| (sy == sroom->ly && svd.doors[sh].y == sy - 1)
|
||||
|| (sy == sroom->hy
|
||||
&& gd.doors[sh].y == sy + 1))))
|
||||
&& svd.doors[sh].y == sy + 1))))
|
||||
continue;
|
||||
/* don't place monster on explicitly placed throne */
|
||||
if (type == COURT && IS_THRONE(levl[sx][sy].typ))
|
||||
@@ -362,7 +362,7 @@ fill_zoo(struct mkroom *sroom)
|
||||
case ZOO:
|
||||
case LEPREHALL:
|
||||
if (sroom->doorct) {
|
||||
int distval = dist2(sx, sy, gd.doors[sh].x, gd.doors[sh].y);
|
||||
int distval = dist2(sx, sy, svd.doors[sh].x, svd.doors[sh].y);
|
||||
i = sq(distval);
|
||||
} else
|
||||
i = goldlim;
|
||||
@@ -421,23 +421,23 @@ fill_zoo(struct mkroom *sroom)
|
||||
add_to_container(chest, gold);
|
||||
chest->owt = weight(chest);
|
||||
chest->spe = 2; /* so it can be found later */
|
||||
gl.level.flags.has_court = 1;
|
||||
svl.level.flags.has_court = 1;
|
||||
break;
|
||||
}
|
||||
case BARRACKS:
|
||||
gl.level.flags.has_barracks = 1;
|
||||
svl.level.flags.has_barracks = 1;
|
||||
break;
|
||||
case ZOO:
|
||||
gl.level.flags.has_zoo = 1;
|
||||
svl.level.flags.has_zoo = 1;
|
||||
break;
|
||||
case MORGUE:
|
||||
gl.level.flags.has_morgue = 1;
|
||||
svl.level.flags.has_morgue = 1;
|
||||
break;
|
||||
case SWAMP:
|
||||
gl.level.flags.has_swamp = 1;
|
||||
svl.level.flags.has_swamp = 1;
|
||||
break;
|
||||
case BEEHIVE:
|
||||
gl.level.flags.has_beehive = 1;
|
||||
svl.level.flags.has_beehive = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -462,7 +462,7 @@ mkundead(
|
||||
|| !revive(otmp, FALSE)))
|
||||
(void) makemon(mdat, cc.x, cc.y, mm_flags);
|
||||
}
|
||||
gl.level.flags.graveyard = TRUE; /* reduced chance for undead corpse */
|
||||
svl.level.flags.graveyard = TRUE; /* reduced chance for undead corpse */
|
||||
}
|
||||
|
||||
staticfn struct permonst *
|
||||
@@ -511,9 +511,9 @@ antholemon(void)
|
||||
break;
|
||||
}
|
||||
/* try again if chosen type has been genocided or used up */
|
||||
} while (++trycnt < 3 && (gm.mvitals[mtyp].mvflags & G_GONE));
|
||||
} while (++trycnt < 3 && (svm.mvitals[mtyp].mvflags & G_GONE));
|
||||
|
||||
return ((gm.mvitals[mtyp].mvflags & G_GONE) ? (struct permonst *) 0
|
||||
return ((svm.mvitals[mtyp].mvflags & G_GONE) ? (struct permonst *) 0
|
||||
: &mons[mtyp]);
|
||||
}
|
||||
|
||||
@@ -526,12 +526,12 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */
|
||||
int rmno;
|
||||
|
||||
for (i = 0; i < 5; i++) { /* turn up to 5 rooms swampy */
|
||||
sroom = &gr.rooms[rn2(gn.nroom)];
|
||||
sroom = &svr.rooms[rn2(svn.nroom)];
|
||||
if (sroom->hx < 0 || sroom->rtype != OROOM || has_upstairs(sroom)
|
||||
|| has_dnstairs(sroom))
|
||||
continue;
|
||||
|
||||
rmno = (int)(sroom - gr.rooms) + ROOMOFFSET;
|
||||
rmno = (int)(sroom - svr.rooms) + ROOMOFFSET;
|
||||
|
||||
/* satisfied; make a swamp */
|
||||
sroom->rtype = SWAMP;
|
||||
@@ -560,7 +560,7 @@ mkswamp(void) /* Michiel Huisjes & Fred de Wilde */
|
||||
NO_MM_FLAGS);
|
||||
}
|
||||
}
|
||||
gl.level.flags.has_swamp = 1;
|
||||
svl.level.flags.has_swamp = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ shrine_pos(int roomno)
|
||||
{
|
||||
static coord buf;
|
||||
int delta;
|
||||
struct mkroom *troom = &gr.rooms[roomno - ROOMOFFSET];
|
||||
struct mkroom *troom = &svr.rooms[roomno - ROOMOFFSET];
|
||||
|
||||
/* if width and height are odd, placement will be the exact center;
|
||||
if either or both are even, center point is a hypothetical spot
|
||||
@@ -601,13 +601,13 @@ mktemple(void)
|
||||
* In temples, shrines are blessed altars
|
||||
* located in the center of the room
|
||||
*/
|
||||
shrine_spot = shrine_pos((int) ((sroom - gr.rooms) + ROOMOFFSET));
|
||||
shrine_spot = shrine_pos((int) ((sroom - svr.rooms) + ROOMOFFSET));
|
||||
lev = &levl[shrine_spot->x][shrine_spot->y];
|
||||
lev->typ = ALTAR;
|
||||
lev->altarmask = induced_align(80);
|
||||
priestini(&u.uz, sroom, shrine_spot->x, shrine_spot->y, FALSE);
|
||||
lev->altarmask |= AM_SHRINE;
|
||||
gl.level.flags.has_temple = 1;
|
||||
svl.level.flags.has_temple = 1;
|
||||
}
|
||||
|
||||
boolean
|
||||
@@ -669,7 +669,7 @@ boolean
|
||||
inside_room(struct mkroom *croom, coordxy x, coordxy y)
|
||||
{
|
||||
if (croom->irregular) {
|
||||
int i = (int) ((croom - gr.rooms) + ROOMOFFSET);
|
||||
int i = (int) ((croom - svr.rooms) + ROOMOFFSET);
|
||||
return (!levl[x][y].edge && (int) levl[x][y].roomno == i);
|
||||
}
|
||||
|
||||
@@ -688,7 +688,7 @@ somexy(struct mkroom *croom, coord *c)
|
||||
int i;
|
||||
|
||||
if (croom->irregular) {
|
||||
i = (int) ((croom - gr.rooms) + ROOMOFFSET);
|
||||
i = (int) ((croom - svr.rooms) + ROOMOFFSET);
|
||||
|
||||
while (try_cnt++ < 100) {
|
||||
c->x = somex(croom);
|
||||
@@ -757,7 +757,7 @@ search_special(schar type)
|
||||
{
|
||||
struct mkroom *croom;
|
||||
|
||||
for (croom = &gr.rooms[0]; croom->hx >= 0; croom++)
|
||||
for (croom = &svr.rooms[0]; croom->hx >= 0; croom++)
|
||||
if ((type == ANY_TYPE && croom->rtype != OROOM)
|
||||
|| (type == ANY_SHOP && croom->rtype >= SHOPBASE)
|
||||
|| croom->rtype == type)
|
||||
@@ -821,7 +821,7 @@ squadmon(void)
|
||||
}
|
||||
mndx = ROLL_FROM(squadprob).pm;
|
||||
gotone:
|
||||
if (!(gm.mvitals[mndx].mvflags & G_GONE))
|
||||
if (!(svm.mvitals[mndx].mvflags & G_GONE))
|
||||
return &mons[mndx];
|
||||
else
|
||||
return (struct permonst *) 0;
|
||||
@@ -858,9 +858,9 @@ save_rooms(NHFILE *nhfp)
|
||||
|
||||
/* First, write the number of rooms */
|
||||
if (nhfp->structlevel)
|
||||
bwrite(nhfp->fd, (genericptr_t) &gn.nroom, sizeof(gn.nroom));
|
||||
for (i = 0; i < gn.nroom; i++)
|
||||
save_room(nhfp, &gr.rooms[i]);
|
||||
bwrite(nhfp->fd, (genericptr_t) &svn.nroom, sizeof(svn.nroom));
|
||||
for (i = 0; i < svn.nroom; i++)
|
||||
save_room(nhfp, &svr.rooms[i]);
|
||||
}
|
||||
|
||||
staticfn void
|
||||
@@ -888,14 +888,14 @@ rest_rooms(NHFILE *nhfp)
|
||||
short i;
|
||||
|
||||
if (nhfp->structlevel)
|
||||
mread(nhfp->fd, (genericptr_t) &gn.nroom, sizeof(gn.nroom));
|
||||
mread(nhfp->fd, (genericptr_t) &svn.nroom, sizeof(svn.nroom));
|
||||
|
||||
gn.nsubroom = 0;
|
||||
for (i = 0; i < gn.nroom; i++) {
|
||||
rest_room(nhfp, &gr.rooms[i]);
|
||||
gr.rooms[i].resident = (struct monst *) 0;
|
||||
for (i = 0; i < svn.nroom; i++) {
|
||||
rest_room(nhfp, &svr.rooms[i]);
|
||||
svr.rooms[i].resident = (struct monst *) 0;
|
||||
}
|
||||
gr.rooms[gn.nroom].hx = -1; /* restore ending flags */
|
||||
svr.rooms[svn.nroom].hx = -1; /* restore ending flags */
|
||||
gs.subrooms[gn.nsubroom].hx = -1;
|
||||
}
|
||||
|
||||
@@ -1043,8 +1043,8 @@ staticfn boolean
|
||||
invalid_shop_shape(struct mkroom *sroom)
|
||||
{
|
||||
coordxy x, y;
|
||||
coordxy doorx = gd.doors[sroom->fdoor].x;
|
||||
coordxy doory = gd.doors[sroom->fdoor].y;
|
||||
coordxy doorx = svd.doors[sroom->fdoor].x;
|
||||
coordxy doory = svd.doors[sroom->fdoor].y;
|
||||
coordxy insidex = 0, insidey = 0, insidect = 0;
|
||||
|
||||
/* First, identify squares inside the room and next to the door. */
|
||||
|
||||
Reference in New Issue
Block a user