sym-changes - add engravings to the map

1. Add "engraved room floor" pchar sym (S_engroom). The symbol that
displays at the engraved part of a room (not a corridor though).
The default symbol is '`' which is currently never shown if people
have defined the boulder symbol to '0' and statues are displayed as
monster symbols. It is bright blue.

Add some stylized variations of the S_engroom symset to some of
the symsets.

2. Add "engraved corridor" pchar sym (S_engrcorr). The symbol that
displays at the engraved part of a corridor. The default symbol is
'#', and it matches the symbol for corridor from for whatever the
current symset uses. It is bright blue to match the color of the
S_engroom symbol. Using the normal corridor symbol for display
preserves the lines of the corridor so is not as visually-disruptive
as a smaller symbol would be. Explicit entries that match the S_corr
symbol have been added to the symset file.

Magic mapping and clairvoyance impacts yet to be determined.

The Guidebook updates will come later.
This commit is contained in:
nhmall
2023-03-05 17:35:49 -05:00
parent 0b5956ba34
commit 32ca917d2c
11 changed files with 540 additions and 337 deletions

View File

@@ -1216,12 +1216,14 @@ wiz_makemap(void)
return ECMD_OK;
}
/* the #wizmap command - reveal the level map and any traps on it */
/* the #wizmap command - reveal the level map
and any traps or engravings on it */
static int
wiz_map(void)
{
if (wizard) {
struct trap *t;
struct engr *ep;
long save_Hconf = HConfusion, save_Hhallu = HHallucination;
HConfusion = HHallucination = 0L;
@@ -1229,6 +1231,9 @@ wiz_map(void)
t->tseen = 1;
map_trap(t, TRUE);
}
for (ep = head_engr; ep != 0; ep = ep->nxt_engr) {
map_engraving(ep, TRUE);
}
do_mapping();
HConfusion = save_Hconf;
HHallucination = save_Hhallu;

View File

@@ -1328,6 +1328,7 @@ show_map_spot(coordxy x, coordxy y)
{
struct rm *lev;
struct trap *t;
struct engr *ep;
int oldglyph;
if (Confusion && rn2(7))
@@ -1359,6 +1360,8 @@ show_map_spot(coordxy x, coordxy y)
if (!IS_FURNITURE(lev->typ)) {
if ((t = t_at(x, y)) != 0 && t->tseen) {
map_trap(t, 1);
} else if ((ep = engr_at(x,y)) != 0) {
map_engraving(ep, 1);
} else if (glyph_is_trap(oldglyph) || glyph_is_object(oldglyph)) {
show_glyph(x, y, oldglyph);
if (gl.level.flags.hero_memory)

View File

@@ -60,7 +60,7 @@
*
* map_background
* map_object
* map_trap
* map_trap or map_engraving
* map_invisible
* unmap_object
*
@@ -304,6 +304,23 @@ map_trap(register struct trap *trap, register int show)
show_glyph(x, y, glyph);
}
/*
* map_engraving()
*
* Map the engraving and print it out if directed.
*/
void
map_engraving(struct engr *ep, register int show)
{
coordxy x = ep->engr_x, y = ep->engr_y;
int glyph = engraving_to_glyph(ep);
if (gl.level.flags.hero_memory)
levl[x][y].glyph = glyph;
if (show)
show_glyph(x, y, glyph);
}
/*
* map_object()
*
@@ -392,12 +409,15 @@ void
unmap_object(register coordxy x, register coordxy y)
{
register struct trap *trap;
struct engr *ep;
if (!gl.level.flags.hero_memory)
return;
if ((trap = t_at(x, y)) != 0 && trap->tseen && !covers_traps(x, y)) {
map_trap(trap, 0);
} else if ((ep = engr_at(x, y)) != 0 && !covers_traps(x, y)) {
map_engraving(ep, 0);
} else if (levl[x][y].seenv) {
struct rm *lev = &levl[x][y];
@@ -424,11 +444,14 @@ unmap_object(register coordxy x, register coordxy y)
{ \
register struct obj *obj; \
register struct trap *trap; \
struct engr *ep; \
\
if ((obj = vobj_at(x, y)) && !covers_objects(x, y)) \
map_object(obj, show); \
else if ((trap = t_at(x, y)) && trap->tseen && !covers_traps(x, y)) \
map_trap(trap, show); \
else if ((ep = engr_at(x, y)) && !covers_traps(x, y)) \
map_engraving(ep, show); \
else \
map_background(x, y, show); \
\

View File

@@ -254,7 +254,7 @@ ceiling(coordxy x, coordxy y)
struct engr *
engr_at(coordxy x, coordxy y)
{
register struct engr *ep = head_engr;
struct engr *ep = head_engr;
while (ep) {
if (x == ep->engr_x && y == ep->engr_y)
@@ -277,8 +277,8 @@ sengr_at(const char *s, coordxy x, coordxy y, boolean strict)
struct engr *ep = engr_at(x, y);
if (ep && ep->engr_type != HEADSTONE && ep->engr_time <= gm.moves) {
if (strict ? !strcmpi(ep->engr_txt, s)
: (strstri(ep->engr_txt, s) != 0))
if (strict ? !strcmpi(ep->engr_txt[actual_text], s)
: (strstri(ep->engr_txt[actual_text], s) != 0))
return ep;
}
return (struct engr *) NULL;
@@ -304,10 +304,10 @@ wipe_engr_at(coordxy x, coordxy y, xint16 cnt, boolean magical)
cnt = rn2(1 + 50 / (cnt + 1)) ? 0 : 1;
debugpline1("actually eroding %d characters", cnt);
}
wipeout_text(ep->engr_txt, (int) cnt, 0);
while (ep->engr_txt[0] == ' ')
ep->engr_txt++;
if (!ep->engr_txt[0])
wipeout_text(ep->engr_txt[actual_text], (int) cnt, 0);
while (ep->engr_txt[actual_text][0] == ' ')
ep->engr_txt[actual_text]++;
if (!ep->engr_txt[actual_text][0])
del_engr(ep);
}
}
@@ -322,7 +322,7 @@ read_engr_at(coordxy x, coordxy y)
/* Sensing an engraving does not require sight,
* nor does it necessarily imply comprehension (literacy).
*/
if (ep && ep->engr_txt[0]) {
if (ep && ep->engr_txt[actual_text][0]) {
switch (ep->engr_type) {
case DUST:
if (!Blind) {
@@ -373,14 +373,16 @@ read_engr_at(coordxy x, coordxy y)
/* sizeof "literal" counts terminating \0 */
- sizeof "You feel the words: \"\".");
if ((int) strlen(ep->engr_txt) > maxelen) {
(void) strncpy(buf, ep->engr_txt, maxelen);
if ((int) strlen(ep->engr_txt[actual_text]) > maxelen) {
(void) strncpy(buf, ep->engr_txt[actual_text], maxelen);
buf[maxelen] = '\0';
et = buf;
} else {
et = ep->engr_txt;
et = ep->engr_txt[actual_text];
}
You("%s: \"%s\".", (Blind) ? "feel the words" : "read", et);
Strcpy(ep->engr_txt[remembered_text], ep->engr_txt[actual_text]);
ep->eread = 1;
if (gc.context.run > 0)
nomul(0);
}
@@ -390,19 +392,24 @@ read_engr_at(coordxy x, coordxy y)
void
make_engr_at(coordxy x, coordxy y, const char *s, long e_time, xint16 e_type)
{
int i;
struct engr *ep;
unsigned smem = Strlen(s) + 1;
if ((ep = engr_at(x, y)) != 0)
del_engr(ep);
ep = newengr(smem);
(void) memset((genericptr_t) ep, 0, smem + sizeof (struct engr));
ep = newengr(smem * 3);
(void) memset((genericptr_t) ep, 0, (smem * 3) + sizeof (struct engr));
ep->nxt_engr = head_engr;
head_engr = ep;
ep->engr_x = x;
ep->engr_y = y;
ep->engr_txt = (char *) (ep + 1);
Strcpy(ep->engr_txt, s);
ep->engr_txt[actual_text] = (char *) (ep + 1);
ep->engr_txt[remembered_text] = ep->engr_txt[actual_text] + smem;
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 (!strcmp(s, "Elbereth")) {
/* engraving "Elbereth": if done when making a level, it creates
an old-style Elbereth that deters monsters when any objects are
@@ -414,7 +421,9 @@ make_engr_at(coordxy x, coordxy y, const char *s, long e_time, xint16 e_type)
}
ep->engr_time = e_time;
ep->engr_type = e_type > 0 ? e_type : rnd(N_ENGRAVE - 1);
ep->engr_lth = smem;
ep->engr_szeach = smem;
ep->engr_alloc = smem * 3;
/* we do not set ep->eread; the caller will need to if required */
}
/* delete any engraving at location <x,y> */
@@ -536,6 +545,8 @@ doengrave(void)
boolean ptext = TRUE; /* TRUE if we must prompt for engrave text */
boolean teleengr = FALSE; /* TRUE if we move the old engraving */
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 */
char buf[BUFSZ]; /* Buffer for final/poly engraving text */
@@ -937,17 +948,28 @@ doengrave(void)
}
if (teleengr) {
rloc_engr(oep);
oep->eread = 0;
disprefresh = TRUE;
oep = (struct engr *) 0;
}
if (dengr) {
del_engr(oep);
oep = (struct engr *) 0;
disprefresh = TRUE;
}
/* Something has changed the engraving here */
if (*buf) {
struct engr *tmp_ep;
make_engr_at(u.ux, u.uy, buf, gm.moves, type);
if (!Blind)
pline_The("engraving now reads: \"%s\".", buf);
tmp_ep = engr_at(u.ux, u.uy);
if (!Blind) {
if (tmp_ep != 0) {
pline_The("engraving now reads: \"%s\".", buf);
tmp_ep->eread = 1;
disprefresh = TRUE;
}
}
ptext = FALSE;
}
if (zapwand && (otmp->spe < 0)) {
@@ -965,6 +987,8 @@ doengrave(void)
if (!ptext) {
if (otmp && otmp->oclass == WAND_CLASS && !can_reach_floor(TRUE))
cant_reach_floor(u.ux, u.uy, FALSE, TRUE);
if (disprefresh)
newsym(u.ux, u.uy);
return ECMD_TIME;
}
/*
@@ -1004,6 +1028,7 @@ doengrave(void)
: "written");
del_engr(oep);
oep = (struct engr *) 0;
disprefresh = TRUE;
} else {
/* defer deletion until after we *know* we're engraving */
eow = TRUE;
@@ -1020,7 +1045,7 @@ doengrave(void)
You("will overwrite the current message.");
eow = TRUE;
}
} else if (oep && (int) strlen(oep->engr_txt) >= BUFSZ - 1) {
} else if (oep && (int) strlen(oep->engr_txt[actual_text]) >= BUFSZ - 1) {
There("is no room to add anything else here.");
return ECMD_TIME;
}
@@ -1107,6 +1132,7 @@ doengrave(void)
if (eow) {
del_engr(oep);
oep = (struct engr *) 0;
disprefresh = TRUE;
}
Strcpy(gc.context.engraving.text, ebuf);
@@ -1129,6 +1155,8 @@ doengrave(void)
/* Engraving will always take at least one action via being run as an
* occupation, so do not count this setup as taking time. */
if (disprefresh)
newsym(u.ux, u.uy);
return ECMD_OK;
}
@@ -1144,6 +1172,7 @@ engrave(void)
boolean firsttime = (gc.context.engraving.actionct == 0);
int rate = 10; /* # characters that can be engraved in this action */
boolean truncate = FALSE;
boolean neweng = (gc.context.engraving.actionct == 0);
boolean carving = (gc.context.engraving.type == ENGRAVE
|| gc.context.engraving.type == HEADSTONE);
@@ -1282,7 +1311,7 @@ engrave(void)
buf[0] = '\0';
oep = engr_at(u.ux, u.uy);
if (oep) /* add to existing engraving */
Strcpy(buf, oep->engr_txt);
Strcpy(buf, oep->engr_txt[actual_text]);
space_left = (int) (sizeof buf - strlen(buf) - 1U);
if (endc - gc.context.engraving.nextc > space_left) {
@@ -1305,9 +1334,15 @@ 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);
oep = engr_at(u.ux, u.uy);
if (oep)
oep->eread = 1;
if (*endc) {
gc.context.engraving.nextc = endc;
if (neweng) {
newsym(gc.context.engraving.pos.x, gc.context.engraving.pos.y);
}
return 1; /* not yet finished this turn */
} else { /* finished engraving */
/* actions that happen after the engraving is finished go here */
@@ -1324,6 +1359,8 @@ engrave(void)
gc.context.engraving.nextc = (char *) 0;
gc.context.engraving.stylus = (struct obj *) 0;
}
if (neweng)
newsym(gc.context.engraving.pos.x, gc.context.engraving.pos.y);
return 0;
}
@@ -1335,7 +1372,7 @@ sanitize_engravings(void)
struct engr *ep;
for (ep = head_engr; ep; ep = ep->nxt_engr) {
sanitize_name(ep->engr_txt);
sanitize_name(ep->engr_txt[actual_text]);
}
}
@@ -1347,12 +1384,13 @@ save_engravings(NHFILE *nhfp)
for (ep = head_engr; ep; ep = ep2) {
ep2 = ep->nxt_engr;
if (ep->engr_lth && ep->engr_txt[0] && perform_bwrite(nhfp)) {
if (ep->engr_alloc
&& ep->engr_txt[actual_text][0] && perform_bwrite(nhfp)) {
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t)&(ep->engr_lth),
sizeof ep->engr_lth);
bwrite(nhfp->fd, (genericptr_t)&(ep->engr_alloc),
sizeof ep->engr_alloc);
bwrite(nhfp->fd, (genericptr_t)ep,
sizeof (struct engr) + ep->engr_lth);
sizeof (struct engr) + ep->engr_alloc);
}
}
if (release_data(nhfp))
@@ -1385,7 +1423,13 @@ rest_engravings(NHFILE *nhfp)
}
ep->nxt_engr = head_engr;
head_engr = ep;
ep->engr_txt = (char *) (ep + 1); /* Andreas Bormann */
ep->engr_txt[actual_text] = (char *) (ep + 1); /* Andreas Bormann */
ep->engr_txt[remembered_text] = ep->engr_txt[actual_text] + ep->engr_szeach;
ep->engr_txt[pristine_text] = ep->engr_txt[remembered_text] + ep->engr_szeach;
while (ep->engr_txt[actual_text][0] == ' ')
ep->engr_txt[actual_text]++;
while (ep->engr_txt[remembered_text][0] == ' ')
ep->engr_txt[remembered_text]++;
/* mark as finished for bones levels -- no problem for
* normal levels as the player must have finished engraving
* to be able to move again */
@@ -1409,7 +1453,7 @@ engr_stats(
*count = *size = 0L;
for (ep = head_engr; ep; ep = ep->nxt_engr) {
++*count;
*size += (long) sizeof *ep + (long) ep->engr_lth;
*size += (long) sizeof *ep + (long) ep->engr_alloc;
}
}
@@ -1451,6 +1495,7 @@ rloc_engr(struct engr *ep)
ep->engr_x = tx;
ep->engr_y = ty;
newsym(tx, ty); /* caller took care of the old location */
}
/* Create a headstone at the given location.
@@ -1493,6 +1538,23 @@ disturb_grave(coordxy x, coordxy y)
}
}
void
see_engraving(struct engr *ep)
{
newsym(ep->engr_x, ep->engr_y);
}
/* like see_engravings() but overrides vision, but
only for some types of engravings that can be felt */
void
feel_engraving(struct engr *ep)
{
ep->eread = 1;
map_engraving(ep, 1);
/* in case it's beneath something, redisplay the something */
newsym(ep->engr_x, ep->engr_y);
}
static const char blind_writing[][21] = {
{0x44, 0x66, 0x6d, 0x69, 0x62, 0x65, 0x22, 0x45, 0x7b, 0x71,
0x65, 0x6d, 0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },

View File

@@ -43,6 +43,7 @@ static void domenucontrols(void);
extern void port_help(void);
#endif
static char *setopt_cmd(char *);
static boolean add_quoted_engraving(coordxy, coordxy, char *);
static const char invisexplain[] = "remembered, unseen, creature",
altinvisexplain[] = "unseen creature"; /* for clairvoyance */
@@ -653,6 +654,10 @@ lookat(coordxy x, coordxy y, char *buf, char *monbuf)
case S_ice: /* for hallucination; otherwise defsyms[] would be fine */
Strcpy(buf, waterbody_name(x, y));
break;
case S_engroom:
case S_engrcorr:
Strcpy(buf, "engraving");
break;
case S_stone:
if (!levl[x][y].seenv) {
Strcpy(buf, "unexplored");
@@ -1266,6 +1271,12 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str,
: !(alt_i == S_stone
|| strcmp(x_str, "air") == 0
|| strcmp(x_str, "land") == 0);
if (alt_i == S_engroom || alt_i == S_engrcorr) {
article = 1;
x_str = "engraving";
need_to_look = TRUE;
}
found = add_cmap_descr(found, alt_i, glyph, article,
cc, x_str, prefix,
&hit_trap, firstmatch, out_str);
@@ -1393,9 +1404,11 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str,
if (look_buf[0] != '\0')
*firstmatch = look_buf;
if (*(*firstmatch)) {
Snprintf(temp_buf, sizeof temp_buf, " (%s)", *firstmatch);
(void) strncat(out_str, temp_buf,
BUFSZ - strlen(out_str) - 1);
if (strncmp(look_buf, "engraving", 9) != 0) {
Snprintf(temp_buf, sizeof temp_buf, " (%s)", *firstmatch);
(void) strncat(out_str, temp_buf,
BUFSZ - strlen(out_str) - 1);
}
found = 1; /* we have something to look up */
}
if (monbuf[0]) {
@@ -1409,6 +1422,24 @@ do_screen_description(coord cc, boolean looked, int sym, char *out_str,
return found;
}
static boolean
add_quoted_engraving(coordxy x, coordxy y, char *buf)
{
char temp_buf[BUFSZ];
struct engr *ep = engr_at(x, y);
if (ep) {
if (ep->eread)
Snprintf(temp_buf, sizeof temp_buf, " with remembered text: \"%s\"",
ep->engr_txt[remembered_text]);
else
Snprintf(temp_buf, sizeof temp_buf, " that you've never read");
(void) strncat(buf, temp_buf, BUFSZ - strlen(buf) - 1);
return TRUE;
}
return FALSE;
}
/* also used by getpos hack in do_name.c */
const char what_is_an_unknown_object[] = "an unknown object";
@@ -1604,6 +1635,18 @@ do_look(int mode, coord *click_cc)
/* Finally, print out our explanation. */
if (found) {
if (ans != LOOK_QUICK && ans != LOOK_ONCE
&& (ans == LOOK_VERBOSE || (flags.help && !quick))
&& !clicklook
&& !strncmp(firstmatch, "engraving", 9)) {
char engbuf[BUFSZ];
engbuf[0] = '\0';
if (add_quoted_engraving(cc.x, cc.y, engbuf)) {
Snprintf(eos(out_str), BUFSZ - strlen(out_str) - 1,
engbuf);
}
}
/* use putmixed() because there may be an encoded glyph present */
putmixed(WIN_MESSAGE, 0, out_str);
#ifdef DUMPLOG