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

Function new_light_core

src/light.c:68–94  ·  view source on GitHub ↗

Create a new light source and return it. Only used within this file. */

Source from the content-addressed store, hash-verified

66
67/* Create a new light source and return it. Only used within this file. */
68staticfn light_source *
69new_light_core(coordxy x, coordxy y, int range, int type, anything *id)
70{
71 light_source *ls;
72
73 if (range > MAX_RADIUS || range < 0
74 /* camera flash uses radius 0 and passes Null object */
75 || (range == 0 && (type != LS_OBJECT || id->a_obj != 0))) {
76 impossible("new_light_source: illegal range %d", range);
77 return (light_source *) 0;
78 }
79
80 ls = (light_source *) alloc(sizeof *ls);
81
82 (void) memset((genericptr_t) ls, 0, sizeof (light_source));
83 ls->next = gl.light_base;
84 ls->x = x;
85 ls->y = y;
86 ls->range = range;
87 ls->type = type;
88 ls->id = *id;
89 ls->flags = 0;
90 gl.light_base = ls;
91
92 gv.vision_full_recalc = 1; /* make the source show up */
93 return ls;
94}
95
96/* Find and delete a light source.
97 Assumes at most one light source is attached to an object at a time. */

Callers 2

new_light_sourceFunction · 0.85
show_transient_lightFunction · 0.85

Calls 2

impossibleFunction · 0.70
allocFunction · 0.70

Tested by

no test coverage detected