mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
Check return value on R_AllocDlight. Small optimization, people cutting r_dlight_max heavily should like it.
This commit is contained in:
parent
f31705380f
commit
46949068a2
9 changed files with 100 additions and 72 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue