engraving pristine text field not properly filled

level creation was not populating the pristine text field
of engraving appropriately
This commit is contained in:
nhmall
2025-05-26 12:56:44 -04:00
parent 86a7bfa7e9
commit b303f91f3a
7 changed files with 31 additions and 17 deletions

View File

@@ -1515,6 +1515,8 @@ Fire and Frost Brand can be invoked for expert level fireball or cone of cold
wielding Trollsbane grants hungerless regeneration
hitting with Ogresmasher gives a higher chance of knockback
Snickersnee can hit at a distance once per turn for free
the engraving pristine text field was not being appropriately populated during
level creation
Fixes to 3.7.0-x General Problems Exposed Via git Repository

View File

@@ -975,7 +975,7 @@ extern char *build_english_list(char *) NONNULLARG1;
/* ### engrave.c ### */
extern char *random_engraving(char *) NONNULLARG1;
extern char *random_engraving(char *, char *) NONNULLARG12;
extern void wipeout_text(char *, int, unsigned) NONNULLARG1;
extern boolean can_reach_floor(boolean);
extern void cant_reach_floor(coordxy, coordxy, boolean, boolean);
@@ -984,7 +984,7 @@ extern struct engr *sengr_at(const char *, coordxy, coordxy, boolean) NONNULLARG
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, int) NONNULLARG3;
extern void make_engr_at(coordxy, coordxy, const char *, const char *, long, int) NONNULLARG3;
extern void del_engr_at(coordxy, coordxy);
extern int freehand(void);
extern int doengrave(void);

View File

@@ -48,15 +48,16 @@ staticfn int engrave(void);
staticfn const char *blengr(void);
char *
random_engraving(char *outbuf)
random_engraving(char *outbuf, char *pristine_copy)
{
const char *rumor;
/* a random engraving may come from the "rumors" file,
or from the "engrave" file (formerly in an array here) */
if (!rn2(4) || !(rumor = getrumor(0, outbuf, TRUE)) || !*rumor)
(void) get_rnd_text(ENGRAVEFILE, outbuf, rn2, MD_PAD_RUMORS);
if (!rn2(4) || !(rumor = getrumor(0, pristine_copy, TRUE)) || !*rumor)
(void) get_rnd_text(ENGRAVEFILE, pristine_copy, rn2, MD_PAD_RUMORS);
Strcpy(outbuf, pristine_copy);
wipeout_text(outbuf, (int) (strlen(outbuf) / 4), 0);
return outbuf;
}
@@ -391,13 +392,21 @@ void
make_engr_at(
coordxy x, coordxy y,
const char *s,
const char *pristine_s,
long e_time,
int e_type)
{
int i;
struct engr *ep;
unsigned smem = Strlen(s) + 1;
boolean havepristine = FALSE;
if (pristine_s != NULL) {
unsigned prmem = Strlen(pristine_s) + 1;
if (prmem > smem)
smem = prmem;
havepristine = TRUE;
}
if ((ep = engr_at(x, y)) != 0)
del_engr(ep);
@@ -412,6 +421,8 @@ make_engr_at(
ep->engr_txt[pristine_text] = ep->engr_txt[remembered_text] + smem;
for(i = 0; i < text_states; ++i)
Strcpy(ep->engr_txt[i], s);
if (havepristine)
Strcpy(ep->engr_txt[pristine_text], pristine_s);
if (!strcmp(s, "Elbereth")) {
/* engraving "Elbereth": if done when making a level, it creates
an old-style Elbereth that deters monsters when any objects are
@@ -591,7 +602,7 @@ doengrave_sfx_item_WAN(struct _doengrave_ctx *de)
if (de->oep) {
if (!Blind) {
de->type = (xint16) 0; /* random */
(void) random_engraving(de->buf);
(void) random_engraving(de->buf, de->ebuf);
} else {
/* keep the same type so that feels don't
change and only the text is altered,
@@ -1036,7 +1047,7 @@ doengrave(void)
if (*de->buf) {
struct engr *tmp_ep;
make_engr_at(u.ux, u.uy, de->buf, svm.moves, de->type);
make_engr_at(u.ux, u.uy, de->buf, de->ebuf, svm.moves, de->type);
tmp_ep = engr_at(u.ux, u.uy);
if (!Blind) {
if (tmp_ep != 0) {
@@ -1422,7 +1433,7 @@ engrave(void)
(void) strncat(buf, svc.context.engraving.nextc,
min(space_left, endc - svc.context.engraving.nextc));
make_engr_at(u.ux, u.uy, buf, svm.moves - gm.multi,
make_engr_at(u.ux, u.uy, buf, NULL, svm.moves - gm.multi,
svc.context.engraving.type);
oep = engr_at(u.ux, u.uy);
if (oep) {
@@ -1662,7 +1673,7 @@ make_grave(coordxy x, coordxy y, const char *str)
del_engr_at(x, y);
if (!str)
str = get_rnd_text(EPITAPHFILE, buf, rn2, MD_PAD_RUMORS);
make_engr_at(x, y, str, 0L, HEADSTONE);
make_engr_at(x, y, str, NULL, 0L, HEADSTONE);
return;
}

View File

@@ -763,7 +763,7 @@ makeniche(int trap_type)
ttmp->once = 1;
if (trap_engravings[trap_type]) {
make_engr_at(xx, yy - dy,
trap_engravings[trap_type], 0L,
trap_engravings[trap_type], NULL, 0L,
DUST);
wipe_engr_at(xx, yy - dy, 5,
FALSE); /* age it a little */
@@ -1136,8 +1136,8 @@ fill_ordinary_room(
/* maybe make some graffiti */
if (!rn2(27 + 3 * abs(depth(&u.uz)))) {
char buf[BUFSZ];
const char *mesg = random_engraving(buf);
char buf[BUFSZ], pristinebuf[BUFSZ];
const char *mesg = random_engraving(buf, pristinebuf);
if (mesg) {
do {
@@ -1146,7 +1146,7 @@ fill_ordinary_room(
y = pos.y;
} while (levl[x][y].typ != ROOM && !rn2(40));
if (levl[x][y].typ == ROOM)
make_engr_at(x, y, mesg, 0L, MARK);
make_engr_at(x, y, mesg, pristinebuf, 0L, MARK);
}
}

View File

@@ -755,7 +755,7 @@ stock_room(int shp_indx, struct mkroom *sroom)
else if (inside_shop(sx, sy - 1))
n++;
Sprintf(buf, "Closed for inventory");
make_engr_at(m, n, buf, 0L, DUST);
make_engr_at(m, n, buf, NULL, 0L, DUST);
if (levl[m][n].typ != CORR && levl[m][n].typ != ROOM)
levl[m][n].typ = (Is_special(&u.uz)
|| *in_rooms(m, n, 0)) ? ROOM : CORR;

View File

@@ -3912,7 +3912,7 @@ lspo_engraving(lua_State *L)
ecoord = SP_COORD_PACK(x, y);
get_location_coord(&x, &y, DRY, gc.coder->croom, ecoord);
make_engr_at(x, y, txt, 0L, etyp);
make_engr_at(x, y, txt, NULL, 0L, etyp);
Free(txt);
ep = engr_at(x, y);
if (ep) {

View File

@@ -3628,7 +3628,7 @@ zap_map(
ttmp = t_at(x, y); /* refresh in case trap was altered or is gone */
if (u.dz > 0) { /* zapping down */
char ebuf[BUFSZ];
char ebuf[BUFSZ], pristinebuf[BUFSZ], *etxt;
struct engr *e = engr_at(x, y);
/* subset of engraving effects; none sets `disclose' */
@@ -3637,7 +3637,8 @@ zap_map(
case WAN_POLYMORPH:
case SPE_POLYMORPH:
del_engr(e);
make_engr_at(x, y, random_engraving(ebuf), svm.moves, 0);
etxt = random_engraving(ebuf, pristinebuf);
make_engr_at(x, y, etxt, pristinebuf, svm.moves, 0);
break;
case WAN_CANCELLATION:
case SPE_CANCELLATION: