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

Function obj_split_light_source

src/light.c:778–803  ·  view source on GitHub ↗

copy the light source(s) attached to src, and attach it/them to dest */

Source from the content-addressed store, hash-verified

776
777/* copy the light source(s) attached to src, and attach it/them to dest */
778void
779obj_split_light_source(struct obj *src, struct obj *dest)
780{
781 light_source *ls, *new_ls;
782
783 for (ls = gl.light_base; ls; ls = ls->next)
784 if (ls->type == LS_OBJECT && ls->id.a_obj == src) {
785 /*
786 * Insert the new source at beginning of list. This will
787 * never interfere us walking down the list - we are already
788 * past the insertion point.
789 */
790 new_ls = (light_source *) alloc(sizeof(light_source));
791 *new_ls = *ls;
792 if (Is_candle(src)) {
793 /* split candles may emit less light than original group */
794 ls->range = candle_light_range(src);
795 new_ls->range = candle_light_range(dest);
796 gv.vision_full_recalc = 1; /* in case range changed */
797 }
798 new_ls->id.a_obj = dest;
799 new_ls->next = gl.light_base;
800 gl.light_base = new_ls;
801 dest->lamplit = 1; /* now an active light source */
802 }
803}
804
805/* light source `src' has been folded into light source `dest';
806 used for merging lit candles and adding candle(s) to lit candelabrum */

Callers 1

splitobjFunction · 0.85

Calls 2

candle_light_rangeFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected