diff --git a/libs/video/renderer/gl/gl_rmain.c b/libs/video/renderer/gl/gl_rmain.c index 878741d73..6cc3f6862 100644 --- a/libs/video/renderer/gl/gl_rmain.c +++ b/libs/video/renderer/gl/gl_rmain.c @@ -146,13 +146,14 @@ R_ShowNearestLoc (void) if (nearloc) { dl = R_AllocDlight (4096); - VectorCopy (nearloc->loc, dl->origin); - dl->radius = 200; - dl->die = r_realtime + 0.1; - dl->color[0] = 0; - dl->color[1] = 1; - dl->color[2] = 0; - + if (dl) { + VectorCopy (nearloc->loc, dl->origin); + dl->radius = 200; + dl->die = r_realtime + 0.1; + dl->color[0] = 0; + dl->color[1] = 1; + dl->color[2] = 0; + } VectorCopy (nearloc->loc, trueloc); (*R_WizSpikeEffect) (trueloc); } diff --git a/libs/video/renderer/r_light.c b/libs/video/renderer/r_light.c index 819dfad33..59ecbd313 100644 --- a/libs/video/renderer/r_light.c +++ b/libs/video/renderer/r_light.c @@ -435,11 +435,9 @@ R_AllocDlight (int key) { int i; dlight_t *dl; - static dlight_t dummy; if (!r_maxdlights) { - memset (&dummy, 0, sizeof (dummy)); - return &dummy; + return NULL; } // first look for an exact key match diff --git a/libs/video/renderer/sw/sw_rmain.c b/libs/video/renderer/sw/sw_rmain.c index a3fe727b4..87e683b2a 100644 --- a/libs/video/renderer/sw/sw_rmain.c +++ b/libs/video/renderer/sw/sw_rmain.c @@ -465,11 +465,13 @@ R_ShowNearestLoc (void) nearloc = locs_find (r_origin); if (nearloc) { dl = R_AllocDlight (4096); - VectorCopy (nearloc->loc, dl->origin); - dl->radius = 200; - dl->die = r_realtime + 0.1; - dl->color[1] = 1; - + if (dl) { + VectorCopy (nearloc->loc, dl->origin); + dl->radius = 200; + dl->die = r_realtime + 0.1; + dl->color[1] = 1; + } + VectorCopy(nearloc->loc, trueloc); R_RunParticleEffect(trueloc, vec3_origin, 252, 10); } diff --git a/libs/video/renderer/sw32/sw32_rmain.c b/libs/video/renderer/sw32/sw32_rmain.c index fc709e799..dc8bd4498 100644 --- a/libs/video/renderer/sw32/sw32_rmain.c +++ b/libs/video/renderer/sw32/sw32_rmain.c @@ -493,11 +493,13 @@ R_ShowNearestLoc (void) nearloc = locs_find (r_origin); if (nearloc) { dl = R_AllocDlight (4096); - VectorCopy (nearloc->loc, dl->origin); - dl->radius = 200; - dl->die = r_realtime + 0.1; - dl->color[1] = 1; - + if (dl) { + VectorCopy (nearloc->loc, dl->origin); + dl->radius = 200; + dl->die = r_realtime + 0.1; + dl->color[1] = 1; + } + VectorCopy(nearloc->loc, trueloc); R_RunParticleEffect(trueloc, vec3_origin, 252, 10); } diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index cca3e3767..0ca47c98b 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -433,9 +433,11 @@ CL_NewDlight (int key, vec3_t org, int effects) if (!(effects & (EF_BLUE | EF_RED | EF_BRIGHTLIGHT | EF_DIMLIGHT))) return; - radius = 200 + (rand () & 31); dl = R_AllocDlight (key); + if (!dl) + return; VectorCopy (org, dl->origin); + switch (effects & (EF_BLUE | EF_RED)) { case EF_BLUE | EF_RED: VectorCopy (purple, dl->color); @@ -450,6 +452,7 @@ CL_NewDlight (int key, vec3_t org, int effects) VectorCopy (normal, dl->color); break; } + radius = 200 + (rand () & 31); if (effects & EF_BRIGHTLIGHT) { radius += 200; dl->origin[2] += 16; @@ -593,27 +596,31 @@ CL_RelinkEntities (void) vec3_t fv, rv, uv; dl = R_AllocDlight (i); - VectorCopy (ent->origin, dl->origin); - dl->origin[2] += 16; - AngleVectors (ent->angles, fv, rv, uv); + if (dl) { + VectorCopy (ent->origin, dl->origin); + dl->origin[2] += 16; + AngleVectors (ent->angles, fv, rv, uv); - VectorMA (dl->origin, 18, fv, dl->origin); - dl->radius = 200 + (rand () & 31); - dl->minlight = 32; - dl->die = cl.time + 0.1; - dl->color[0] = 0.2; - dl->color[1] = 0.1; - dl->color[2] = 0.05; + VectorMA (dl->origin, 18, fv, dl->origin); + dl->radius = 200 + (rand () & 31); + dl->minlight = 32; + dl->die = cl.time + 0.1; + dl->color[0] = 0.2; + dl->color[1] = 0.1; + dl->color[2] = 0.05; + } } CL_NewDlight (i, ent->origin, state->baseline.effects); if (VectorDistance_fast(state->msg_origins[1], ent->origin) > (256*256)) VectorCopy (ent ->origin, state->msg_origins[1]); if (ent->model->flags & EF_ROCKET) { dl = R_AllocDlight (i); - VectorCopy (ent->origin, dl->origin); - VectorCopy (r_firecolor->vec, dl->color); - dl->radius = 200; - dl->die = cl.time + 0.1; + if (dl) { + VectorCopy (ent->origin, dl->origin); + VectorCopy (r_firecolor->vec, dl->color); + dl->radius = 200; + dl->die = cl.time + 0.1; + } R_RocketTrail (ent); } else if (ent->model->flags & EF_GRENADE) R_GrenadeTrail (ent); diff --git a/nq/source/cl_tent.c b/nq/source/cl_tent.c index 3a2c50b85..e9ba7af8f 100644 --- a/nq/source/cl_tent.c +++ b/nq/source/cl_tent.c @@ -285,13 +285,15 @@ CL_ParseTEnt (void) // light dl = R_AllocDlight (0); - VectorCopy (pos, dl->origin); - dl->radius = 350; - dl->die = cl.time + 0.5; - dl->decay = 300; - dl->color[0] = 0.86; - dl->color[1] = 0.31; - dl->color[2] = 0.24; + if (dl) { + VectorCopy (pos, dl->origin); + dl->radius = 350; + dl->die = cl.time + 0.5; + dl->decay = 300; + dl->color[0] = 0.86; + dl->color[1] = 0.31; + dl->color[2] = 0.24; + } // sound S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); @@ -342,8 +344,11 @@ CL_ParseTEnt (void) MSG_ReadCoordV (net_message, pos); colorStart = MSG_ReadByte (net_message); colorLength = MSG_ReadByte (net_message); + S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); R_ParticleExplosion2 (pos, colorStart, colorLength); dl = R_AllocDlight (0); + if (!dl) + break; VectorCopy (pos, dl->origin); dl->radius = 350; dl->die = cl.time + 0.5; @@ -354,7 +359,6 @@ CL_ParseTEnt (void) 3 + 1] * (1.0 / 255.0); dl->color[2] = vid_basepal[(colorStart + (rand() % colorLength)) * 3 + 2] * (1.0 / 255.0); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); break; case TE_GUNSHOT: // bullet hitting wall @@ -373,13 +377,15 @@ CL_ParseTEnt (void) // light dl = R_AllocDlight (0); - VectorCopy (pos, dl->origin); - dl->radius = 150; - dl->die = cl.time + 0.1; - dl->decay = 200; - dl->color[0] = 0.25; - dl->color[1] = 0.40; - dl->color[2] = 0.65; + if (dl) { + VectorCopy (pos, dl->origin); + dl->radius = 150; + dl->die = cl.time + 0.1; + dl->decay = 200; + dl->color[0] = 0.25; + dl->color[1] = 0.40; + dl->color[2] = 0.65; + } R_LightningBloodEffect (pos); break; diff --git a/qw/source/cl_ents.c b/qw/source/cl_ents.c index f53d4d63e..b59a3812a 100644 --- a/qw/source/cl_ents.c +++ b/qw/source/cl_ents.c @@ -100,8 +100,9 @@ CL_NewDlight (int key, vec3_t org, int effects) if (!(effects & (EF_BLUE | EF_RED | EF_BRIGHTLIGHT | EF_DIMLIGHT))) return; - radius = 200 + (rand () & 31); dl = R_AllocDlight (key); + if (!dl) + return; VectorCopy (org, dl->origin); dl->die = cl.time + 0.1; switch (effects & (EF_BLUE | EF_RED)) { @@ -118,6 +119,7 @@ CL_NewDlight (int key, vec3_t org, int effects) VectorCopy (normal, dl->color); break; } + radius = 200 + (rand () & 31); if (effects & EF_BRIGHTLIGHT) { radius += 200; dl->origin[2] += 16; @@ -510,10 +512,12 @@ CL_LinkPacketEntities (void) if (model->flags & EF_ROCKET) { dl = R_AllocDlight (-s1->number); - VectorCopy ((*ent)->origin, dl->origin); - VectorCopy (r_firecolor->vec, dl->color); - dl->radius = 200; - dl->die = cl.time + 0.1; + if (dl) { + VectorCopy ((*ent)->origin, dl->origin); + VectorCopy (r_firecolor->vec, dl->color); + dl->radius = 200; + dl->die = cl.time + 0.1; + } } if (model->flags & EF_ROCKET) diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index bb86351b9..ffa5a96f6 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -1102,8 +1102,10 @@ CL_MuzzleFlash (void) pl = &cl.frames[parsecountmod].playerstate[i - 1]; - dl = R_AllocDlight (i); //FIXME - // this interfers with powerup glows, but we need more lights. + dl = R_AllocDlight (i); + if (!dl) + return; + VectorCopy (pl->origin, dl->origin); if (i - 1 == cl.playernum) AngleVectors (cl.viewangles, fv, rv, uv); diff --git a/qw/source/cl_tent.c b/qw/source/cl_tent.c index 274fe3e1b..dac227228 100644 --- a/qw/source/cl_tent.c +++ b/qw/source/cl_tent.c @@ -349,13 +349,15 @@ CL_ParseTEnt (void) // light dl = R_AllocDlight (0); - VectorCopy (pos, dl->origin); - dl->radius = 350; - dl->die = cl.time + 0.5; - dl->decay = 300; - dl->color[0] = 0.86; - dl->color[1] = 0.31; - dl->color[2] = 0.24; + if (dl) { + VectorCopy (pos, dl->origin); + dl->radius = 350; + dl->die = cl.time + 0.5; + dl->decay = 300; + dl->color[0] = 0.86; + dl->color[1] = 0.31; + dl->color[2] = 0.24; + } // sound S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); @@ -408,8 +410,11 @@ CL_ParseTEnt (void) MSG_ReadCoordV (net_message, pos); colorStart = MSG_ReadByte (net_message); colorLength = MSG_ReadByte (net_message); + S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); R_ParticleExplosion2 (pos, colorStart, colorLength); dl = R_AllocDlight (0); + if (!dl) + break; VectorCopy (pos, dl->origin); dl->radius = 350; dl->die = cl.time + 0.5; @@ -420,7 +425,6 @@ CL_ParseTEnt (void) 3 + 1] * (1.0 / 255.0); dl->color[2] = vid_basepal[(colorStart + (rand() % colorLength)) * 3 + 2] * (1.0 / 255.0); - S_StartSound (-1, 0, cl_sfx_r_exp3, pos, 1, 1); break; case TE_GUNSHOT: // bullet hitting wall @@ -440,13 +444,15 @@ CL_ParseTEnt (void) // light dl = R_AllocDlight (0); - VectorCopy (pos, dl->origin); - dl->radius = 150; - dl->die = cl.time + 0.1; - dl->decay = 200; - dl->color[0] = 0.25; - dl->color[1] = 0.40; - dl->color[2] = 0.65; + if (dl) { + VectorCopy (pos, dl->origin); + dl->radius = 150; + dl->die = cl.time + 0.1; + dl->decay = 200; + dl->color[0] = 0.25; + dl->color[1] = 0.40; + dl->color[2] = 0.65; + } R_LightningBloodEffect (pos); break;