| 2437 | } |
| 2438 | |
| 2439 | staticfn void |
| 2440 | obj_timer_checks( |
| 2441 | struct obj *otmp, |
| 2442 | coordxy x, coordxy y, |
| 2443 | int force) /* 0 = no force so do checks, <0 = force off, >0 force on */ |
| 2444 | { |
| 2445 | long tleft = 0L; |
| 2446 | short action = ROT_CORPSE; |
| 2447 | boolean restart_timer = FALSE; |
| 2448 | boolean on_floor = (otmp->where == OBJ_FLOOR); |
| 2449 | boolean buried = (otmp->where == OBJ_BURIED); |
| 2450 | |
| 2451 | /* Check for corpses just placed on or in ice */ |
| 2452 | if (otmp->otyp == CORPSE && (on_floor || buried) && is_ice(x, y)) { |
| 2453 | tleft = stop_timer(action, obj_to_any(otmp)); |
| 2454 | if (tleft == 0L) { |
| 2455 | action = REVIVE_MON; |
| 2456 | tleft = stop_timer(action, obj_to_any(otmp)); |
| 2457 | } |
| 2458 | if (tleft != 0L) { |
| 2459 | long age; |
| 2460 | |
| 2461 | /* mark the corpse as being on ice */ |
| 2462 | otmp->on_ice = 1; |
| 2463 | debugpline3("%s is now on ice at <%d,%d>.", |
| 2464 | The(xname(otmp)), x, y); |
| 2465 | /* Adjust the time remaining */ |
| 2466 | tleft *= ROT_ICE_ADJUSTMENT; |
| 2467 | restart_timer = TRUE; |
| 2468 | /* Adjust the age; time spent off ice needs to be multiplied |
| 2469 | by the ice adjustment and subtracted from the age so that |
| 2470 | later calculations behave as if it had been on ice during |
| 2471 | that time (longwinded way of saying this is the inverse |
| 2472 | of removing it from the ice and of peeking at its age). */ |
| 2473 | age = svm.moves - otmp->age; |
| 2474 | otmp->age = svm.moves - (age * ROT_ICE_ADJUSTMENT); |
| 2475 | } |
| 2476 | |
| 2477 | /* Check for corpses coming off ice */ |
| 2478 | } else if (force < 0 || (otmp->otyp == CORPSE && otmp->on_ice |
| 2479 | && !((on_floor || buried) && is_ice(x, y)))) { |
| 2480 | tleft = stop_timer(action, obj_to_any(otmp)); |
| 2481 | if (tleft == 0L) { |
| 2482 | action = REVIVE_MON; |
| 2483 | tleft = stop_timer(action, obj_to_any(otmp)); |
| 2484 | } |
| 2485 | if (tleft != 0L) { |
| 2486 | long age; |
| 2487 | |
| 2488 | otmp->on_ice = 0; |
| 2489 | debugpline3("%s is no longer on ice at <%d,%d>.", |
| 2490 | The(xname(otmp)), x, y); |
| 2491 | /* Adjust the remaining time */ |
| 2492 | tleft /= ROT_ICE_ADJUSTMENT; |
| 2493 | restart_timer = TRUE; |
| 2494 | /* Adjust the age */ |
| 2495 | age = svm.moves - otmp->age; |
| 2496 | otmp->age += age * (ROT_ICE_ADJUSTMENT - 1) / ROT_ICE_ADJUSTMENT; |
no test coverage detected