A minor removal of a few pieces of dead code. Nothing major. This is
[divverent/darkplaces.git] / cl_light.c
1
2 #include "quakedef.h"
3
4 dlight_t cl_dlights[MAX_DLIGHTS];
5
6 /*
7 ===============
8 CL_AllocDlight
9
10 ===============
11 */
12 void CL_AllocDlight (entity_render_t *ent, vec3_t org, float radius, float red, float green, float blue, float decay, float lifetime)
13 {
14         int             i;
15         dlight_t        *dl;
16
17 // first look for an exact key match
18         if (ent)
19         {
20                 dl = cl_dlights;
21                 for (i = 0;i < MAX_DLIGHTS;i++, dl++)
22                         if (dl->ent == ent)
23                                 goto dlightsetup;
24         }
25
26 // then look for anything else
27         dl = cl_dlights;
28         for (i = 0;i < MAX_DLIGHTS;i++, dl++)
29                 if (!dl->radius)
30                         goto dlightsetup;
31
32         // unable to find one
33         return;
34
35 dlightsetup:
36         memset (dl, 0, sizeof(*dl));
37         dl->ent = ent;
38         VectorCopy(org, dl->origin);
39         dl->radius = radius;
40         dl->color[0] = red;
41         dl->color[1] = green;
42         dl->color[2] = blue;
43         dl->decay = decay;
44         if (lifetime)
45                 dl->die = cl.time + lifetime;
46         else
47                 dl->die = 0;
48 }
49
50
51 /*
52 ===============
53 CL_DecayLights
54
55 ===============
56 */
57 void CL_DecayLights (void)
58 {
59         int                     i;
60         dlight_t        *dl;
61         float           time;
62
63         time = cl.time - cl.oldtime;
64
65         dl = cl_dlights;
66         for (i=0 ; i<MAX_DLIGHTS ; i++, dl++)
67         {
68                 if (!dl->radius)
69                         continue;
70                 if (dl->die < cl.time)
71                 {
72                         dl->radius = 0;
73                         continue;
74                 }
75
76                 dl->radius -= time*dl->decay;
77                 if (dl->radius < 0)
78                         dl->radius = 0;
79         }
80 }
81