fix #4071 - new timer sanity false positive

New timed sanity checking trying to validate a timer's map location
can't locate a timed object (in this case, an egg with a hatch timer)
inside a container carried by a migrating monster.

The case of the object being carried directly by a migrating monster
was handled, but one inside a container wasn't.
This commit is contained in:
PatR
2023-12-26 05:49:33 -08:00
parent 36e8e504c2
commit 0a10fcbb43

View File

@@ -2053,7 +2053,7 @@ timer_sanity_check(void)
case TIMER_OBJECT: {
/* TODO? verify that the timer type is attached to applicable
object (egg for hatch, glob for shrink, and so forth) */
struct obj *obj = curr->arg.a_obj;
struct obj *obj = curr->arg.a_obj, *top;
char *obj_adr = fmt_ptr((genericptr_t) obj);
int owhere = obj->where;
@@ -2062,19 +2062,26 @@ timer_sanity_check(void)
obj_adr, t_id);
}
x = y = 0;
/* if obj is in a container, possibly a nested one, figure out
where the outermost container is */
for (top = obj; top; top = top->ocontainer)
if ((owhere = top->where) != OBJ_CONTAINED)
break;
assert(top != NULL);
if (owhere == OBJ_MIGRATING
|| (owhere == OBJ_MINVENT && !mon_is_local(obj->ocarry))) {
|| (owhere == OBJ_MINVENT && !mon_is_local(top->ocarry))) {
/* migrating directly or carried by migrating monster */
; /* not able to validate location so skip checks */
} else if (!get_obj_location(obj, &x, &y,
CONTAINED_TOO | BURIED_TOO)) {
/* free? or on a shop's used-up bill? */
impossible(
"timer sanity: can't locate obj %s [where=%d], timer %lu",
obj_adr, owhere, t_id);
obj_adr, obj->where, t_id);
} else if (!isok(x, y)) {
impossible(
"timer sanity: obj %s [where=%d] located at <%d,%d>, timer %lu",
obj_adr, owhere, x, y, t_id);
obj_adr, obj->where, x, y, t_id);
}
break;
}