static void obj_timer_checks(struct obj *otmp, xchar x, xchar y, int force) /* 0 = no force so do checks, <0 = force off, >0 force on */ { long tleft = 0L; short action = ROT_CORPSE; boolean restart_timer = FALSE; boolean on_floor = (otmp->where == OBJ_FLOOR); boolean buried = (otmp->where == OBJ_BURIED); /* Check for corpses just placed on or in ice */ if (otmp->otyp == CORPSE && (on_floor || buried) && is_ice(otmp->olev,x,y)) { tleft = stop_timer(otmp->olev, action, otmp); if (tleft == 0L) { action = REVIVE_MON; tleft = stop_timer(otmp->olev, action, otmp); } if (tleft != 0L) { long age; tleft = tleft - moves; /* mark the corpse as being on ice */ ON_ICE(otmp) = 1; /* Adjust the time remaining */ tleft *= ROT_ICE_ADJUSTMENT; restart_timer = TRUE; /* Adjust the age; must be same as in obj_ice_age() */ age = moves - otmp->age; otmp->age = moves - (age * ROT_ICE_ADJUSTMENT); } } /* Check for corpses coming off ice */ else if ((force < 0) || (otmp->otyp == CORPSE && ON_ICE(otmp) && ((on_floor && !is_ice(otmp->olev, x, y)) || !on_floor))) { tleft = stop_timer(otmp->olev, action, otmp); if (tleft == 0L) { action = REVIVE_MON; tleft = stop_timer(otmp->olev, action, otmp); } if (tleft != 0L) { long age; tleft = tleft - moves; ON_ICE(otmp) = 0; /* Adjust the remaining time */ tleft /= ROT_ICE_ADJUSTMENT; restart_timer = TRUE; /* Adjust the age */ age = moves - otmp->age; otmp->age = otmp->age + (age / ROT_ICE_ADJUSTMENT); } } /* now re-start the timer with the appropriate modifications */ if (restart_timer) start_timer(otmp->olev, tleft, TIMER_OBJECT, action, otmp); }
/* * Returns an obj->age for a corpse object on ice, that would be the * actual obj->age if the corpse had just been lifted from the ice. * This is useful when just using obj->age in a check or calculation because * rot timers pertaining to the object don't have to be stopped and * restarted etc. */ long peek_at_iced_corpse_age(struct obj *otmp) { long age, retval = otmp->age; if (otmp->otyp == CORPSE && ON_ICE(otmp)) { /* Adjust the age; must be same as obj_timer_checks() for off ice*/ age = moves - otmp->age; retval = otmp->age + (age / ROT_ICE_ADJUSTMENT); } return retval; }
/* * Returns an obj->age for a corpse object on ice, that would be the * actual obj->age if the corpse had just been lifted from the ice. * This is useful when just using obj->age in a check or calculation because * rot timers pertaining to the object don't have to be stopped and * restarted etc. */ long peek_at_iced_corpse_age(struct obj *otmp) { long age, retval = otmp->age; if (otmp->otyp == CORPSE && ON_ICE(otmp)) { /* Adjust the age; must be same as obj_timer_checks() for off ice*/ age = monstermoves - otmp->age; retval = otmp->age + (age / ROT_ICE_ADJUSTMENT); #ifdef DEBUG_EFFECTS pline_The("%s age has ice modifications:otmp->age = %ld, returning %ld.", s_suffix(doname(otmp)),otmp->age, retval); pline("Effective age of corpse: %ld.", monstermoves - retval); #endif } return retval; }