preserve dknown field between fakeobj instances

Preserve temporary fake object's previous dknown value by storing it
as a flag value within the m_ap_type field of the posing monster, and
recalling it when it is needed.

This is intended to help eliminate observable differences in price display
between real objects and mimics posing as objects.

98% of this is just switching the code to utilize macro M_AP_TYPE(mon)
everywhere to ensure that the flag bits are stripped off when needed.
This commit is contained in:
nhmall
2019-04-22 14:17:18 -04:00
parent cd6b5ef933
commit dcf4da2150
30 changed files with 127 additions and 115 deletions

View File

@@ -1533,8 +1533,8 @@ domove_core()
/* It's fine to displace pets, though */
/* We should never get here if forcefight */
if (context.run && ((!Blind && mon_visible(mtmp)
&& ((mtmp->m_ap_type != M_AP_FURNITURE
&& mtmp->m_ap_type != M_AP_OBJECT)
&& ((M_AP_TYPE(mtmp) != M_AP_FURNITURE
&& M_AP_TYPE(mtmp) != M_AP_OBJECT)
|| Protection_from_shape_changers))
|| sensemon(mtmp))) {
nomul(0);
@@ -1574,7 +1574,7 @@ domove_core()
*/
if (context.nopick && !context.travel
&& (canspotmon(mtmp) || glyph_is_invisible(levl[x][y].glyph))) {
if (mtmp->m_ap_type && !Protection_from_shape_changers
if (M_AP_TYPE(mtmp) && !Protection_from_shape_changers
&& !sensemon(mtmp))
stumble_onto_mimic(mtmp);
else if (mtmp->mpeaceful && !Hallucination)
@@ -1762,7 +1762,7 @@ domove_core()
cancel the swap below (we can ignore steed mx,my here) */
u.ux = u.ux0, u.uy = u.uy0;
mtmp->mundetected = 0;
if (mtmp->m_ap_type)
if (M_AP_TYPE(mtmp))
seemimic(mtmp);
else if (!mtmp->mtame)
newsym(mtmp->mx, mtmp->my);
@@ -1866,8 +1866,8 @@ domove_core()
* imitating something that doesn't move. We could extend this
* to non-moving monsters...
*/
if ((u.dx || u.dy) && (youmonst.m_ap_type == M_AP_OBJECT
|| youmonst.m_ap_type == M_AP_FURNITURE))
if ((u.dx || u.dy) && (U_AP_TYPE == M_AP_OBJECT
|| U_AP_TYPE == M_AP_FURNITURE))
youmonst.m_ap_type = M_AP_NOTHING;
check_leash(u.ux0, u.uy0);
@@ -2655,8 +2655,8 @@ lookaround()
continue;
if ((mtmp = m_at(x, y)) != 0
&& mtmp->m_ap_type != M_AP_FURNITURE
&& mtmp->m_ap_type != M_AP_OBJECT
&& M_AP_TYPE(mtmp) != M_AP_FURNITURE
&& M_AP_TYPE(mtmp) != M_AP_OBJECT
&& (!mtmp->minvis || See_invisible) && !mtmp->mundetected) {
if ((context.run != 1 && !mtmp->mtame)
|| (x == u.ux + u.dx && y == u.uy + u.dy
@@ -2838,8 +2838,8 @@ monster_nearby()
for (y = u.uy - 1; y <= u.uy + 1; y++) {
if (!isok(x, y) || (x == u.ux && y == u.uy))
continue;
if ((mtmp = m_at(x, y)) && mtmp->m_ap_type != M_AP_FURNITURE
&& mtmp->m_ap_type != M_AP_OBJECT
if ((mtmp = m_at(x, y)) && M_AP_TYPE(mtmp) != M_AP_FURNITURE
&& M_AP_TYPE(mtmp) != M_AP_OBJECT
&& (!mtmp->mpeaceful || Hallucination)
&& (!is_hider(mtmp->data) || !mtmp->mundetected)
&& !noattacks(mtmp->data) && mtmp->mcanmove