Create a new light source and return it. Only used within this file. */
| 66 | |
| 67 | /* Create a new light source and return it. Only used within this file. */ |
| 68 | staticfn light_source * |
| 69 | new_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. */ |
no test coverage detected