Fold invisible glyph unmapping into single function

This commit is contained in:
Pasi Kallinen
2017-10-07 16:24:49 +03:00
parent f8760093cc
commit 4b7aea0eac
8 changed files with 27 additions and 42 deletions

View File

@@ -321,6 +321,7 @@ E void FDECL(map_background, (XCHAR_P, XCHAR_P, int));
E void FDECL(map_trap, (struct trap *, int));
E void FDECL(map_object, (struct obj *, int));
E void FDECL(map_invisible, (XCHAR_P, XCHAR_P));
E boolean FDECL(unmap_invisible, (int, int));
E void FDECL(unmap_object, (int, int));
E void FDECL(map_location, (int, int, int));
E void FDECL(feel_newsym, (XCHAR_P, XCHAR_P));

View File

@@ -408,11 +408,8 @@ register struct obj *obj;
map_invisible(rx, ry);
return res;
}
if (glyph_is_invisible(levl[rx][ry].glyph)) {
unmap_object(rx, ry);
newsym(rx, ry);
if (unmap_invisible(rx,ry))
pline_The("invisible monster must have moved.");
}
lev = &levl[rx][ry];
switch (lev->typ) {
@@ -631,10 +628,7 @@ struct obj *obj;
if (!(mtmp = m_at(cc.x, cc.y))) {
There("is no creature there.");
if (glyph_is_invisible(levl[cc.x][cc.y].glyph)) {
unmap_object(cc.x, cc.y);
newsym(cc.x, cc.y);
}
(void) unmap_invisible(cc.x, cc.y);
return 1;
}
@@ -3030,11 +3024,7 @@ struct obj *obj;
}
} else {
/* no monster here and no statue seen or remembered here */
if (glyph_is_invisible(glyph)) {
/* now you know that nothing is there... */
unmap_object(bhitpos.x, bhitpos.y);
newsym(bhitpos.x, bhitpos.y);
}
(void) unmap_invisible(bhitpos.x, bhitpos.y);
You("miss; there is no one there to hit.");
}
u_wipe_engr(2); /* same as for melee or throwing */

View File

@@ -1394,9 +1394,7 @@ genericptr_t num;
}
if (!canspotmon(mtmp) && !glyph_is_invisible(levl[zx][zy].glyph))
map_invisible(zx, zy);
} else if (glyph_is_invisible(levl[zx][zy].glyph)) {
unmap_object(zx, zy);
newsym(zx, zy);
} else if (unmap_invisible(zx, zy)) {
(*(int *) num)++;
}
}
@@ -1646,11 +1644,8 @@ register int aflag; /* intrinsic autosearch vs explicit searching */
/* see if an invisible monster has moved--if Blind,
* feel_location() already did it
*/
if (!aflag && !mtmp && !Blind
&& glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y);
newsym(x, y);
}
if (!aflag && !mtmp && !Blind)
(void) unmap_invisible(x, y);
if ((trap = t_at(x, y)) && !trap->tseen && !rnl(8)) {
nomul(0);

View File

@@ -277,6 +277,19 @@ register xchar x, y;
}
}
boolean
unmap_invisible(x, y)
int x, y;
{
if (isok(x,y) && glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y);
newsym(x, y);
return TRUE;
}
return FALSE;
}
/*
* unmap_object()
*

View File

@@ -262,10 +262,7 @@ doit:
} else {
maybe_mnexto(mon);
if (mon->mx != x || mon->my != y) {
if (glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y);
newsym(x, y);
}
(void) unmap_invisible(x, y);
pline("%s %s, %s evading your %skick.", Monnam(mon),
(!level.flags.noteleport && can_teleport(mon->data))
? "teleports"
@@ -946,10 +943,7 @@ dokick()
}
return 1;
}
if (glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y);
newsym(x, y);
}
(void) unmap_invisible(x, y);
if (is_pool(x, y) ^ !!u.uinwater) {
/* objects normally can't be removed from water by kicking */
You("splash some %s around.", hliquid("water"));

View File

@@ -219,11 +219,8 @@ int expltype;
}
if (mtmp && cansee(i + x - 1, j + y - 1) && !canspotmon(mtmp))
map_invisible(i + x - 1, j + y - 1);
else if (!mtmp && glyph_is_invisible(
levl[i + x - 1][j + y - 1].glyph)) {
unmap_object(i + x - 1, j + y - 1);
newsym(i + x - 1, j + y - 1);
}
else if (!mtmp)
(void) unmap_invisible(i + x - 1, j + y - 1);
if (cansee(i + x - 1, j + y - 1))
visible = TRUE;
if (explmask[i][j] == 1)

View File

@@ -1635,10 +1635,7 @@ domove()
}
return;
}
if (glyph_is_invisible(levl[x][y].glyph)) {
unmap_object(x, y);
newsym(x, y);
}
(void) unmap_invisible(x, y);
/* not attacking an animal, so we try to move */
if ((u.dx || u.dy) && u.usteed && stucksteed(FALSE)) {
nomul(0);

View File

@@ -3958,10 +3958,8 @@ boolean say; /* Announce out of sight hit/miss events if true */
/* reveal/unreveal invisible monsters before tmp_at() */
if (mon && !canspotmon(mon))
map_invisible(sx, sy);
else if (!mon && glyph_is_invisible(levl[sx][sy].glyph)) {
unmap_object(sx, sy);
newsym(sx, sy);
}
else if (!mon)
(void) unmap_invisible(sx, sy);
if (ZAP_POS(levl[sx][sy].typ)
|| (isok(lsx, lsy) && cansee(lsx, lsy)))
tmp_at(sx, sy);