fountain and sink bookkeeping

This replaces most of commit 0ca2af4d8b
from a couple of days ago with something more robust.  That change
actually introduced redundant code that caused fountain and/or sink
count to be off instead of preventing it.

Revise set_levltyp() to update level.flags.nfountains and
level.flags.nsinks if setting the type to or from fountain or sink.
A bunch of places that were setting levl[x][y].typ directly needed
to be revised to use set_levltyp() instead.  set_levltyp() itself
hadn't been updated to handle LAVAWALL (to force such to be lit).
This commit is contained in:
PatR
2023-06-12 15:07:34 -07:00
parent 299d49aebf
commit bf47cc878e
8 changed files with 100 additions and 85 deletions
+9 -8
View File
@@ -148,7 +148,8 @@ gush(coordxy x, coordxy y, genericptr_t poolcnt)
pline("Water gushes forth from the overflowing fountain!");
/* Put a pool at x, y */
levl[x][y].typ = POOL, levl[x][y].flags = 0;
set_levltyp(x, y, POOL);
levl[x][y].flags = 0;
/* No kelp! */
del_engr_at(x, y);
water_damage_chain(gl.level.objects[x][y], TRUE);
@@ -226,9 +227,9 @@ dryup(coordxy x, coordxy y, boolean isyou)
pline_The("fountain dries up!");
}
/* replace the fountain with ordinary floor */
levl[x][y].typ = ROOM, levl[x][y].flags = 0;
set_levltyp(x, y, ROOM); /* updates level.flags.nfountains */
levl[x][y].flags = 0;
levl[x][y].blessedftn = 0;
gl.level.flags.nfountains--;
/* The location is seen if the hero/monster is invisible
or felt if the hero is blind. */
newsym(x, y);
@@ -430,9 +431,9 @@ dipfountain(register struct obj *obj)
artiname(ART_EXCALIBUR), lady);
}
update_inventory();
levl[u.ux][u.uy].typ = ROOM, levl[u.ux][u.uy].flags = 0;
set_levltyp(u.ux, u.uy, ROOM); /* updates level.flags.nfountains */
levl[u.ux][u.uy].flags = 0;
newsym(u.ux, u.uy);
gl.level.flags.nfountains--;
if (in_town(u.ux, u.uy))
(void) angry_guards(FALSE);
return;
@@ -543,11 +544,11 @@ breaksink(coordxy x, coordxy y)
{
if (cansee(x, y) || u_at(x, y))
pline_The("pipes break! Water spurts out!");
gl.level.flags.nsinks--;
levl[x][y].typ = FOUNTAIN, levl[x][y].looted = 0;
/* updates level.flags.nsinks and level.flags.nfountains */
set_levltyp(x, y, FOUNTAIN);
levl[x][y].looted = 0;
levl[x][y].blessedftn = 0;
SET_FOUNTAIN_LOOTED(x, y);
gl.level.flags.nfountains++;
newsym(x, y);
}