more engraving sanity feedback

Delete engravings made in a breach of a shop's wall or of a vault's
wall or in the guard's temporary corridor when the wall is repaired
or the corridor removed.  If 'sanity_check' was On, those would
trigger impossible warning "engraving sanity: illegal surface (x)"
where x was the terrain type code for solid rock or relevant walls.

Adding del_engr_at() calls to the shop code was straightforward.
The vault code is very complicated and I'm not sure that all the
calls I added were actually necessary.
This commit is contained in:
PatR
2023-05-04 06:02:23 -07:00
parent c0441126b8
commit 180042434e
7 changed files with 39 additions and 18 deletions

View File

@@ -1167,6 +1167,8 @@ it was possible to produce a web at a water or lava location; it would not be
engraving in an open doorway was allowed, engraving in closed one (presumably
via Passes_walls) was not, but closing the door on an engraving was;
change to allow engraving at closed door location
engraving in a breach in a shop's or vault's wall or vault guard's temporary
corridor would leave the engraving intact after repair/cleanup
Fixes to 3.7.0-x General Problems Exposed Via git Repository

View File

@@ -6,7 +6,12 @@
#ifndef ENGRAVE_H
#define ENGRAVE_H
enum engraving_texts { actual_text, remembered_text, pristine_text, text_states };
enum engraving_texts {
actual_text,
remembered_text,
pristine_text,
text_states
};
struct engr {
struct engr *nxt_engr;
@@ -37,9 +42,9 @@ struct engr {
#define dealloc_engr(engr) free((genericptr_t) (engr))
#define engraving_to_defsym(ep) \
(levl[(ep)->engr_x][(ep)->engr_y].typ == CORR ? S_engrcorr : S_engroom)
((levl[(ep)->engr_x][(ep)->engr_y].typ == CORR) ? S_engrcorr : S_engroom)
#define spot_shows_engravings(x,y) \
#define spot_shows_engravings(x,y) \
(levl[(x)][(y)].typ == CORR \
|| levl[(x)][(y)].typ == SCORR \
|| levl[(x)][(y)].typ == ICE \

View File

@@ -823,7 +823,7 @@ extern struct engr *sengr_at(const char *, coordxy, coordxy, boolean);
extern void u_wipe_engr(int);
extern void wipe_engr_at(coordxy, coordxy, xint16, boolean);
extern void read_engr_at(coordxy, coordxy);
extern void make_engr_at(coordxy, coordxy, const char *, long, xint16);
extern void make_engr_at(coordxy, coordxy, const char *, long, int);
extern void del_engr_at(coordxy, coordxy);
extern int freehand(void);
extern int doengrave(void);

View File

@@ -325,7 +325,11 @@ read_engr_at(coordxy x, coordxy y)
}
void
make_engr_at(coordxy x, coordxy y, const char *s, long e_time, xint16 e_type)
make_engr_at(
coordxy x, coordxy y,
const char *s,
long e_time,
int e_type)
{
int i;
struct engr *ep;
@@ -355,7 +359,7 @@ make_engr_at(coordxy x, coordxy y, const char *s, long e_time, xint16 e_type)
exercise(A_WIS, TRUE);
}
ep->engr_time = e_time;
ep->engr_type = e_type > 0 ? e_type : rnd(N_ENGRAVE - 1);
ep->engr_type = (xint8) ((e_type > 0) ? e_type : rnd(N_ENGRAVE - 1));
ep->engr_szeach = smem;
ep->engr_alloc = smem * 3;
/* we do not set ep->eread; the caller will need to if required */
@@ -486,8 +490,8 @@ doengrave(void)
boolean zapwand = FALSE; /* TRUE if we remove a wand charge */
boolean disprefresh = FALSE; /* TRUE if the display needs a refresh */
xint16 type = DUST; /* Type of engraving made */
xint16 oetype = 0; /* will be set to type of current engraving */
int type = DUST; /* Type of engraving made */
int oetype = 0; /* will be set to type of current engraving */
char buf[BUFSZ]; /* Buffer for final/poly engraving text */
char ebuf[BUFSZ]; /* Buffer for initial engraving text */
char fbuf[BUFSZ]; /* Buffer for "your fingers" */
@@ -984,7 +988,7 @@ doengrave(void)
You("will overwrite the current message.");
eow = TRUE;
}
} else if (oep && (int) strlen(oep->engr_txt[actual_text]) >= BUFSZ - 1) {
} else if (oep && Strlen(oep->engr_txt[actual_text]) >= BUFSZ - 1) {
There("is no room to add anything else here.");
return ECMD_TIME;
}
@@ -1131,9 +1135,8 @@ engrave(void)
stylus = (struct obj *) 0;
} else {
for (stylus = gi.invent; stylus; stylus = stylus->nobj) {
if (stylus == gc.context.engraving.stylus) {
if (stylus == gc.context.engraving.stylus)
break;
}
}
if (!stylus) {
You("are unable to continue engraving.");
@@ -1187,7 +1190,7 @@ engrave(void)
if (firsttime) {
pline("%s dull.", Yobjnam2(stylus, "get"));
}
if (gc.context.engraving.actionct % 2 == 1) { /* 1st, 3rd, ... action */
if (gc.context.engraving.actionct % 2 == 1) { /* 1st,3rd,... action */
/* deduct a point on 1st, 3rd, 5th, ... turns, unless this is the
* last character being engraved (a rather convoluted way to round
* down), but always deduct a point on the 1st turn to prevent
@@ -1272,7 +1275,8 @@ engrave(void)
(void) strncat(buf, gc.context.engraving.nextc,
min(space_left, endc - gc.context.engraving.nextc));
make_engr_at(u.ux, u.uy, buf, gm.moves - gm.multi, gc.context.engraving.type);
make_engr_at(u.ux, u.uy, buf, gm.moves - gm.multi,
gc.context.engraving.type);
oep = engr_at(u.ux, u.uy);
if (oep)
oep->eread = 1;

View File

@@ -4074,6 +4074,7 @@ repair_damage(
break;
}
deltrap(ttmp);
del_engr_at(x, y);
if (seeit)
newsym(x, y);
if (!catchup)
@@ -4100,6 +4101,7 @@ repair_damage(
if (litter_getpos(litter, x, y, shkp))
litter_scatter(litter, x, y, shkp);
del_engr_at(x, y);
/* needed if hero has line-of-sight to the former gap from outside
the shop but is farther than one step away; once the light inside

View File

@@ -96,6 +96,7 @@ clear_fcorr(struct monst *grd, boolean forceshow)
if (lev->typ == STONE)
blackout(fcx, fcy);
}
del_engr_at(fcx, fcy);
map_location(fcx, fcy, 1); /* bypass vision */
if (!ACCESSIBLE(lev->typ))
block_point(fcx, fcy);
@@ -689,6 +690,7 @@ wallify_vault(struct monst *grd)
levl[x][y].typ = typ;
levl[x][y].wall_info = 0;
xy_set_wall_state(x, y); /* set WA_MASK bits in .wall_info */
del_engr_at(x, y);
/*
* hack: player knows walls are restored because of the
* message, below, so show this on the screen.
@@ -870,12 +872,12 @@ gd_letknow(struct monst *grd)
int
gd_move(struct monst *grd)
{
coordxy x, y, nx, ny, m, n;
coordxy x, y, nx, ny, m, n, ex, ey;
coordxy dx, dy, ggx = 0, ggy = 0, fci;
uchar typ;
struct rm *crm;
struct fakecorridor *fcp;
register struct egd *egrd = EGD(grd);
struct egd *egrd = EGD(grd);
long umoney = 0L;
boolean goldincorridor = FALSE, u_in_vault = FALSE, grd_in_vault = FALSE,
semi_dead = DEADMONSTER(grd),
@@ -954,6 +956,7 @@ gd_move(struct monst *grd)
mnexto(grd, RLOC_NOMSG);
levl[m][n].typ = egrd->fakecorr[0].ftyp;
levl[m][n].flags = egrd->fakecorr[0].flags;
del_engr_at(m, n);
newsym(m, n);
return -1;
}
@@ -970,6 +973,7 @@ gd_move(struct monst *grd)
(void) rloc(grd, RLOC_MSG);
levl[m][n].typ = egrd->fakecorr[0].ftyp;
levl[m][n].flags = egrd->fakecorr[0].flags;
del_engr_at(m, n);
newsym(m, n);
grd->mpeaceful = 0;
gd_letknow(grd);
@@ -1079,6 +1083,7 @@ gd_move(struct monst *grd)
crm->doormask = D_NODOOR;
else
crm->flags = 0;
del_engr_at(nx, ny);
goto proceed;
}
}
@@ -1098,12 +1103,14 @@ gd_move(struct monst *grd)
ny += dy;
while ((typ = (crm = &levl[nx][ny])->typ) != STONE) {
ex = nx + nx - x;
ey = ny + ny - y;
/* in view of the above we must have IS_WALL(typ) or typ == POOL */
/* must be a wall here */
if (isok(nx + nx - x, ny + ny - y) && !IS_POOL(typ)
&& IS_ROOM(levl[nx + nx - x][ny + ny - y].typ)) {
if (isok(ex, ey) && IS_ROOM(levl[ex][ey].typ)) {
crm->typ = DOOR;
crm->doormask = D_NODOOR;
del_engr_at(ex, ey);
goto proceed;
}
if (dy && nx != x) {
@@ -1121,6 +1128,7 @@ gd_move(struct monst *grd)
if (IS_ROOM(typ)) {
crm->typ = DOOR;
crm->doormask = D_NODOOR;
del_engr_at(ex, ey);
goto proceed;
}
break;

View File

@@ -3217,7 +3217,7 @@ zap_updown(struct obj *obj) /* wand or spell */
case WAN_POLYMORPH:
case SPE_POLYMORPH:
del_engr(e);
make_engr_at(x, y, random_engraving(buf), gm.moves, (coordxy) 0);
make_engr_at(x, y, random_engraving(buf), gm.moves, 0);
break;
case WAN_CANCELLATION:
case SPE_CANCELLATION: