MCPcopy Index your code
hub / github.com/NetHack/NetHack / snuff_light_source

Function snuff_light_source

src/light.c:728–759  ·  view source on GitHub ↗

* Snuff an object light source if at (x,y). This currently works * only for burning light sources. */

Source from the content-addressed store, hash-verified

726 * only for burning light sources.
727 */
728void
729snuff_light_source(coordxy x, coordxy y)
730{
731 light_source *ls;
732 struct obj *obj;
733
734 for (ls = gl.light_base; ls; ls = ls->next)
735 /*
736 * Is this position check valid??? Can I assume that the positions
737 * will always be correct because the objects would have been
738 * updated with the last vision update? [Is that recent enough???]
739 */
740 if (ls->type == LS_OBJECT && ls->x == x && ls->y == y) {
741 obj = ls->id.a_obj;
742 if (obj_is_burning(obj)) {
743 /* The only way to snuff Sunsword is to unwield it. Darkness
744 * scrolls won't affect it. (If we got here because it was
745 * dropped or thrown inside a monster, this won't matter
746 * anyway because it will go out when dropped.)
747 */
748 if (artifact_light(obj))
749 continue;
750 end_burn(obj, obj->otyp != MAGIC_LAMP);
751 /*
752 * The current ls element has just been removed (and
753 * ls->next is now invalid). Return assuming that there
754 * is only one light source attached to each object.
755 */
756 return;
757 }
758 }
759}
760
761/* Return TRUE if object sheds any light at all. */
762boolean

Callers 2

mpickobjFunction · 0.85
set_litFunction · 0.85

Calls 3

obj_is_burningFunction · 0.85
artifact_lightFunction · 0.85
end_burnFunction · 0.85

Tested by

no test coverage detected