make a distinction between rock and unexplored area

This adds a pair of new glyphs: GLYPH_UNEXPLORED and GLYPH_NOTHING

GLYPH_UNEXPLORED is meant to be the glyph for areas of the map that
haven't been explored yet.

GLYPH_NOTHING is a glyph that represents that which cannot be seen,
for instance the dark part of a room when the dark_room option is
not set.  Since the symbol for stone can now be overridden to
a players choice, it no longer made sense using S_stone for the
dark areas of the room with dark_room off. This allows the same
intended result even if S_stone symbol is mapped to something visible.

GLYPH_UNEXPLORED is what areas of the map get initialized to now
instead of STONE.

This adds a pair of new symbols: S_unexplored and S_nothing.

S_nothing is meant to be left as an unseen character (space) in
order to achieve the intended effect on the display.

S_unexplored is the symbol that is mapped to GLYPH_UNEXPLORED, and
is a distinct symbol from S_stone, even if they are set to the same
character. They don't have to be set to the same character.

Hopefully there are minimal bugs, but it is a deviation from a
fairly long-standing approach so there could be some unintended
glitches that will need repair.
This commit is contained in:
nhmall
2020-02-08 00:48:03 -05:00
parent 84daf75981
commit d37fa196b2
19 changed files with 248 additions and 126 deletions

View File

@@ -482,9 +482,7 @@ struct obj *corpse;
/* Clear all memory from the level. */
for (x = 1; x < COLNO; x++)
for (y = 0; y < ROWNO; y++) {
levl[x][y].seenv = 0;
levl[x][y].waslit = 0;
levl[x][y].glyph = cmap_to_glyph(S_stone);
levl[x][y] = cg.zerorm;
g.lastseentyp[x][y] = 0;
}

View File

@@ -699,6 +699,7 @@ const struct const_globals cg = {
DUMMY, /* zeroobj */
DUMMY, /* zeromonst */
DUMMY, /* zeroany */
{ GLYPH_UNEXPLORED, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
};
#define ZERO(x) memset(&x, 0, sizeof(x))

View File

@@ -169,9 +169,9 @@ int show;
if (!cansee(x, y) && !lev->waslit) {
/* Floor spaces are dark if unlit. Corridors are dark if unlit. */
if (lev->typ == ROOM && glyph == cmap_to_glyph(S_room))
glyph = cmap_to_glyph((flags.dark_room && iflags.use_color)
? (DARKROOMSYM)
: S_stone);
glyph = (flags.dark_room && iflags.use_color)
? cmap_to_glyph(DARKROOMSYM)
: GLYPH_NOTHING;
else if (lev->typ == CORR && glyph == cmap_to_glyph(S_litcorr))
glyph = cmap_to_glyph(S_corr);
}
@@ -1137,7 +1137,7 @@ int first;
for (y = lasty - 1; y <= lasty + 1; y++)
for (x = lastx - 1; x <= lastx + 1; x++)
if (isok(x, y))
show_glyph(x, y, cmap_to_glyph(S_stone));
show_glyph(x, y, GLYPH_UNEXPLORED);
}
swallower = monsndx(u.ustuck->data);
@@ -1211,7 +1211,7 @@ int mode;
for (y = lasty - 1; y <= lasty + 1; y++)
for (x = lastx - 1; x <= lastx + 1; x++)
if (isok(x, y))
show_glyph(x, y, cmap_to_glyph(S_stone));
show_glyph(x, y, GLYPH_UNEXPLORED);
}
/*
@@ -1222,7 +1222,7 @@ int mode;
for (y = u.uy - 1; y <= u.uy + 1; y++)
if (isok(x, y) && (is_pool_or_lava(x, y) || is_ice(x, y))) {
if (Blind && !(x == u.ux && y == u.uy))
show_glyph(x, y, cmap_to_glyph(S_stone));
show_glyph(x, y, GLYPH_UNEXPLORED);
else
newsym(x, y);
}
@@ -1411,8 +1411,7 @@ docrt()
for (x = 1; x < COLNO; x++) {
lev = &levl[x][0];
for (y = 0; y < ROWNO; y++, lev++)
if (lev->glyph != cmap_to_glyph(S_stone))
show_glyph(x, y, lev->glyph);
show_glyph(x, y, lev->glyph);
}
/* see what is to be seen */
@@ -1565,19 +1564,19 @@ int x, y, glyph;
* Reset the changed glyph borders so that none of the 3rd screen has
* changed.
*/
#define reset_glyph_bbox() \
{ \
int i; \
\
for (i = 0; i < ROWNO; i++) { \
#define reset_glyph_bbox() \
{ \
int i; \
\
for (i = 0; i < ROWNO; i++) { \
g.gbuf_start[i] = COLNO - 1; \
g.gbuf_stop[i] = 0; \
} \
} \
}
static const gbuf_entry nul_gbuf = { 0, cmap_to_glyph(S_stone) };
static const gbuf_entry nul_gbuf = { 0, GLYPH_UNEXPLORED };
/*
* Turn the 3rd screen into stone.
* Turn the 3rd screen into UNEXPLORED.
*/
void
clear_glyph_buffer()
@@ -1595,7 +1594,7 @@ clear_glyph_buffer()
}
/*
* Assumes that the indicated positions are filled with S_stone glyphs.
* Assumes that the indicated positions are filled with GLYPH_UNEXPLORED glyphs.
*/
void
row_refresh(start, stop, y)
@@ -1604,13 +1603,14 @@ int start, stop, y;
register int x;
for (x = start; x <= stop; x++)
if (g.gbuf[y][x].glyph != cmap_to_glyph(S_stone))
if (g.gbuf[y][x].glyph != GLYPH_UNEXPLORED)
print_glyph(WIN_MAP, x, y, g.gbuf[y][x].glyph, get_bk_glyph(x, y));
}
void
cls()
{
int y;
static boolean in_cls = 0;
if (in_cls)
@@ -1621,6 +1621,10 @@ cls()
clear_nhwindow(WIN_MAP); /* clear physical screen */
clear_glyph_buffer(); /* this is sort of an extra effort, but OK */
for (y = 0; y < ROWNO; y++) {
g.gbuf_start[y] = 0;
g.gbuf_stop[y] = COLNO - 1;
}
in_cls = FALSE;
}
@@ -1890,11 +1894,11 @@ static int
get_bk_glyph(x, y)
xchar x, y;
{
int idx, bkglyph = NO_GLYPH;
int idx, bkglyph = GLYPH_UNEXPLORED;
struct rm *lev = &levl[x][y];
if (iflags.use_background_glyph && lev->seenv != 0
&& g.gbuf[y][x].glyph != cmap_to_glyph(S_stone)) {
&& (g.gbuf[y][x].glyph != GLYPH_UNEXPLORED)) {
switch (lev->typ) {
case SCORR:
case STONE:

View File

@@ -241,7 +241,7 @@ const void *b;
#define IS_UNEXPLORED_LOC(x,y) \
(isok((x), (y)) \
&& glyph_is_cmap(levl[(x)][(y)].glyph) \
&& glyph_to_cmap(levl[(x)][(y)].glyph) == S_stone \
&& levl[(x)][(y)].glyph == GLYPH_UNEXPLORED \
&& !levl[(x)][(y)].seenv)
#define GLOC_SAME_AREA(x,y) \

View File

@@ -130,7 +130,7 @@ const struct symdef def_warnsyms[WARNCOUNT] = {
* Default screen symbols with explanations and colors.
*/
const struct symdef defsyms[MAXPCHARS] = {
/* 0*/ { ' ', "dark part of a room", C(NO_COLOR) }, /* stone */
/* 0*/ { ' ', "stone", C(NO_COLOR) }, /* stone */
{ '|', "wall", C(CLR_GRAY) }, /* vwall */
{ '-', "wall", C(CLR_GRAY) }, /* hwall */
{ '-', "wall", C(CLR_GRAY) }, /* tlcorn */
@@ -405,12 +405,22 @@ int idx, which_set;
: g.primary_syms[oidx];
if (!sym) {
switch(idx) {
case SYM_NOTHING:
case SYM_UNEXPLORED:
sym = DEF_NOTHING;
break;
case SYM_BOULDER:
sym = def_oc_syms[ROCK_CLASS].sym;
break;
case SYM_INVISIBLE:
sym = DEF_INVISIBLE;
break;
#if 0
/* these intentionally have no defaults */
case SYM_PET_OVERRIDE:
case SYM_HERO_OVERRIDE:
break;
#endif
}
}
return sym;
@@ -805,6 +815,8 @@ const struct symparse loadsyms[] = {
{ SYM_MON, S_LIZARD + SYM_OFF_M, "S_lizard" },
{ SYM_MON, S_WORM_TAIL + SYM_OFF_M, "S_worm_tail" },
{ SYM_MON, S_MIMIC_DEF + SYM_OFF_M, "S_mimic_def" },
{ SYM_OTH, SYM_NOTHING + SYM_OFF_X, "S_nothing" },
{ SYM_OTH, SYM_UNEXPLORED + SYM_OFF_X, "S_unexplored" },
{ SYM_OTH, SYM_BOULDER + SYM_OFF_X, "S_boulder" },
{ SYM_OTH, SYM_INVISIBLE + SYM_OFF_X, "S_invisible" },
{ SYM_OTH, SYM_PET_OVERRIDE + SYM_OFF_X, "S_pet_override" },

View File

@@ -102,7 +102,15 @@ unsigned mgflags;
* Warning: For speed, this makes an assumption on the order of
* offsets. The order is set in display.h.
*/
if ((offset = (glyph - GLYPH_STATUE_OFF)) >= 0) { /* a statue */
if ((offset = (glyph - GLYPH_NOTHING_OFF)) >= 0) {
idx = SYM_NOTHING + SYM_OFF_X;
color = NO_COLOR;
special |= MG_NOTHING;
} else if ((offset = (glyph - GLYPH_UNEXPLORED_OFF)) >= 0) {
idx = SYM_UNEXPLORED + SYM_OFF_X;
color = NO_COLOR;
special |= MG_UNEXPL;
} else if ((offset = (glyph - GLYPH_STATUE_OFF)) >= 0) { /* a statue */
idx = mons[offset].mlet + SYM_OFF_M;
if (has_rogue_color)
color = CLR_RED;

View File

@@ -584,8 +584,6 @@ makevtele()
void
clear_level_structures()
{
static struct rm zerorm = { cmap_to_glyph(S_stone),
0, 0, 0, 0, 0, 0, 0, 0, 0 };
register int x, y;
register struct rm *lev;
@@ -596,7 +594,7 @@ clear_level_structures()
for (x = 0; x < COLNO; x++) {
lev = &levl[x][0];
for (y = 0; y < ROWNO; y++) {
*lev++ = zerorm;
*lev++ = cg.zerorm;
/*
* These used to be '#if MICROPORT_BUG',
* with use of memset(0) for '#if !MICROPORT_BUG' below,

View File

@@ -587,12 +587,12 @@ reglyph_darkroom()
|| Is_rogue_level(&u.uz)) {
if (lev->glyph == cmap_to_glyph(S_darkroom))
lev->glyph = lev->waslit ? cmap_to_glyph(S_room)
: cmap_to_glyph(S_stone);
: GLYPH_NOTHING;
} else {
if (lev->glyph == cmap_to_glyph(S_room) && lev->seenv
&& lev->waslit && !cansee(x, y))
lev->glyph = cmap_to_glyph(S_darkroom);
else if (lev->glyph == cmap_to_glyph(S_stone)
else if (lev->glyph == GLYPH_NOTHING
&& lev->typ == ROOM && lev->seenv && !cansee(x, y))
lev->glyph = cmap_to_glyph(S_darkroom);
}
@@ -600,7 +600,7 @@ reglyph_darkroom()
if (flags.dark_room && iflags.use_color)
g.showsyms[S_darkroom] = g.showsyms[S_room];
else
g.showsyms[S_darkroom] = g.showsyms[S_stone];
g.showsyms[S_darkroom] = g.showsyms[SYM_NOTHING + SYM_OFF_X];
}
/* check whether a user-supplied option string is a proper leading

View File

@@ -478,6 +478,16 @@ char *buf, *monbuf;
int warnindx = glyph_to_warning(glyph);
Strcpy(buf, def_warnsyms[warnindx].explanation);
} else if (glyph_is_nothing(glyph)) {
Strcpy(buf, "dark part of a room");
} else if (glyph_is_unexplored(glyph)) {
if (Underwater && !Is_waterlevel(&u.uz)) {
/* "unknown" == previously mapped but not visible when
submerged; better terminology appreciated... */
Strcpy(buf, (distu(x, y) <= 2) ? "land" : "unknown");
} else {
Strcpy(buf, "unexplored area");
}
} else if (!glyph_is_cmap(glyph)) {
Strcpy(buf, "unexplored area");
} else {
@@ -843,7 +853,7 @@ struct permonst **for_supplement;
unreconnoitered[] = "unreconnoitered";
static char look_buf[BUFSZ];
char prefix[BUFSZ], gobbledygook[33];
int i, alt_i, j, glyph = NO_GLYPH,
int i, j, glyph = NO_GLYPH,
skipped_venom = 0, found = 0; /* count of matching syms found */
boolean hit_trap, need_to_look = FALSE,
submerged = (Underwater && !Is_waterlevel(&u.uz)),
@@ -979,24 +989,33 @@ struct permonst **for_supplement;
found += append_str(out_str, an(unseen_explain));
}
}
/* Now check for graphics symbols */
alt_i = (sym == (looked ? g.showsyms[0] : defsyms[0].sym)) ? 0 : (2 + 1);
for (hit_trap = FALSE, i = 0; i < MAXPCHARS; i++) {
/* when sym is the default background character, we process
i == 0 three times: unexplored, stone, dark part of a room */
if (alt_i < 2) {
x_str = !alt_i++ ? "unexplored" : submerged ? "unknown" : "stone";
i = 0; /* for second iteration, undo loop increment */
/* alt_i is now 1 or 2 */
if ((glyph && glyph_is_nothing(glyph))
|| (looked && sym == g.showsyms[SYM_NOTHING + SYM_OFF_X])) {
x_str = "the dark part of a room";
if (!found) {
Sprintf(out_str, "%s%s", prefix, x_str);
*firstmatch = x_str;
found++;
} else {
if (alt_i++ == 2)
i = 0; /* undo loop increment */
x_str = defsyms[i].explanation;
if (submerged && !strcmp(x_str, defsyms[0].explanation))
x_str = "land"; /* replace "dark part of a room" */
/* alt_i is now 3 or more and no longer of interest */
found += append_str(out_str, x_str);
}
}
if ((glyph && glyph_is_unexplored(glyph))
|| (looked && sym == g.showsyms[SYM_UNEXPLORED + SYM_OFF_X])) {
x_str = "unexplored";
if (submerged)
x_str = "land"; /* replace "unexplored" */
if (!found) {
Sprintf(out_str, "%s%s", prefix, x_str);
*firstmatch = x_str;
found++;
} else {
found += append_str(out_str, x_str);
}
}
/* Now check for graphics symbols */
for (hit_trap = FALSE, i = 0; i < MAXPCHARS; i++) {
x_str = defsyms[i].explanation;
if (sym == (looked ? g.showsyms[i] : defsyms[i].sym) && *x_str) {
/* POOL, MOAT, and WATER are "water", LAVAPOOL is "molten lava" */
boolean water_or_lava = (!strcmp(x_str, "water")
@@ -1005,11 +1024,15 @@ struct permonst **for_supplement;
"a molten lava", "a floor of a room", "a dark part of a room";
article==2 => "the", 1 => "an", 0 => (none) */
int article = strstri(x_str, " of a room") ? 2
: !(alt_i <= 2
: !(i == S_stone
|| strcmp(x_str, "air") == 0
|| strcmp(x_str, "land") == 0
|| water_or_lava);
/* check if dark part of a room was already included above */
if (i == S_darkroom && glyph && glyph_is_nothing(glyph))
continue;
/* substitute for "water" and "molten lava" when hallucinating */
if (water_or_lava && hallucinate) {
if (*gobbledygook)

View File

@@ -804,9 +804,7 @@ int howmuch;
for (zy = 0; zy < ROWNO; zy++)
if (howmuch & ALL_MAP || rn2(7)) {
/* Zonk all memory of this location. */
levl[zx][zy].seenv = 0;
levl[zx][zy].waslit = 0;
levl[zx][zy].glyph = cmap_to_glyph(S_stone);
levl[zx][zy] = cg.zerorm;
g.lastseentyp[zx][zy] = STONE;
}
/* forget overview data for this level */

View File

@@ -579,8 +579,7 @@ xchar lev;
for (x = 0; x < COLNO; x++) {
g.level.monsters[x][y] = 0;
g.level.objects[x][y] = 0;
levl[x][y].seenv = 0;
levl[x][y].glyph = cmap_to_glyph(S_stone);
levl[x][y] = cg.zerorm;
}
fmon = 0;
g.ftrap = 0;