MCPcopy Create free account
hub / github.com/NetHack/NetHack / burn_object

Function burn_object

src/timeout.c:1382–1680  ·  view source on GitHub ↗

* Timeout callback for objects that are burning. E.g. lamps, candles. * See begin_burn() for meanings of obj->age and obj->spe. */

Source from the content-addressed store, hash-verified

1380 * See begin_burn() for meanings of obj->age and obj->spe.
1381 */
1382void
1383burn_object(anything *arg, long timeout)
1384{
1385 struct obj *obj = arg->a_obj;
1386 boolean canseeit, many, menorah, need_newsym, need_invupdate, bytouch;
1387 coordxy x, y;
1388 char whose[BUFSZ];
1389
1390 menorah = obj->otyp == CANDELABRUM_OF_INVOCATION;
1391 many = menorah ? obj->spe > 1 : obj->quan > 1L;
1392
1393 /* timeout while away */
1394 if (timeout != svm.moves) {
1395 long how_long = svm.moves - timeout;
1396
1397 if (how_long >= obj->age) {
1398 obj->age = 0;
1399 end_burn(obj, FALSE);
1400
1401 if (menorah) {
1402 obj->spe = 0; /* no more candles */
1403 obj->owt = weight(obj);
1404 } else if (Is_candle(obj) || obj->otyp == POT_OIL) {
1405 struct monst *mtmp = NULL;
1406
1407 if (obj->where == OBJ_FLOOR)
1408 mtmp = m_at(obj->ox, obj->oy);
1409 /* get rid of candles and burning oil potions;
1410 we know this object isn't carried by hero,
1411 nor is it migrating */
1412 obj_extract_self(obj);
1413 obfree(obj, (struct obj *) 0);
1414 obj = (struct obj *) 0;
1415 if (mtmp)
1416 maybe_unhide_at(mtmp->mx, mtmp->my);
1417 }
1418
1419 } else {
1420 obj->age -= how_long;
1421 begin_burn(obj, TRUE);
1422 }
1423 return;
1424 }
1425
1426 /* only interested in INVENT, FLOOR, and MINVENT */
1427 if (get_obj_location(obj, &x, &y, 0)) {
1428 canseeit = !Blind && cansee(x, y);
1429 /* set `whose[]' to be "Your " or "Fred's " or "The goblin's " */
1430 (void) Shk_Your(whose, obj);
1431 } else {
1432 canseeit = FALSE;
1433 }
1434 /* when carrying the light source, you can feel the heat from lit lamp
1435 or candle so you'll be notified when it burns out even if blind at
1436 the time; brass lantern doesn't radiate sufficient heat for that
1437 (however, inventory formatting drops "(lit)" so player can tell) */
1438 bytouch = (obj->where == OBJ_INVENT && obj->otyp != BRASS_LANTERN);
1439 need_newsym = need_invupdate = FALSE;

Callers

nothing calls this directly

Calls 15

end_burnFunction · 0.85
weightFunction · 0.85
obj_extract_selfFunction · 0.85
obfreeFunction · 0.85
maybe_unhide_atFunction · 0.85
begin_burnFunction · 0.85
get_obj_locationFunction · 0.85
Shk_YourFunction · 0.85
You_seeFunction · 0.85
useupallFunction · 0.85
lantern_messageFunction · 0.85
see_lamp_flickerFunction · 0.85

Tested by

no test coverage detected