Make R_RocketTrail take an entity_t * parameter (the one the trail is for) so that various things can be done, including using the entity as a key for R_AllocFire.

Also, rocket/lavaball trails now work beautifly. They have to be seen to be believed.
This commit is contained in:
Bill Currie 2000-04-25 09:35:07 +00:00
parent 2d4091ffa0
commit 6d9d7b6197
8 changed files with 25 additions and 81 deletions

View file

@ -561,24 +561,24 @@ void CL_LinkPacketEntities (void)
}
if (model->flags & EF_ROCKET)
{
R_RocketTrail (old_origin, ent->origin, 0);
R_RocketTrail (old_origin, ent->origin, 0, ent);
dl = CL_AllocDlight (s1->number);
VectorCopy (ent->origin, dl->origin);
dl->radius = 200;
dl->die = cl.time + 0.1;
}
else if (model->flags & EF_GRENADE)
R_RocketTrail (old_origin, ent->origin, 1);
R_RocketTrail (old_origin, ent->origin, 1, ent);
else if (model->flags & EF_GIB)
R_RocketTrail (old_origin, ent->origin, 2);
R_RocketTrail (old_origin, ent->origin, 2, ent);
else if (model->flags & EF_ZOMGIB)
R_RocketTrail (old_origin, ent->origin, 4);
R_RocketTrail (old_origin, ent->origin, 4, ent);
else if (model->flags & EF_TRACER)
R_RocketTrail (old_origin, ent->origin, 3);
R_RocketTrail (old_origin, ent->origin, 3, ent);
else if (model->flags & EF_TRACER2)
R_RocketTrail (old_origin, ent->origin, 5);
R_RocketTrail (old_origin, ent->origin, 5, ent);
else if (model->flags & EF_TRACER3)
R_RocketTrail (old_origin, ent->origin, 6);
R_RocketTrail (old_origin, ent->origin, 6, ent);
}
}

View file

@ -1321,25 +1321,25 @@ void CL_RelinkEntities (void)
#endif
if (ent->model->flags & EF_GIB)
R_RocketTrail (oldorg, ent->origin, 2);
R_RocketTrail (oldorg, ent->origin, 2, ent);
else if (ent->model->flags & EF_ZOMGIB)
R_RocketTrail (oldorg, ent->origin, 4);
R_RocketTrail (oldorg, ent->origin, 4, ent);
else if (ent->model->flags & EF_TRACER)
R_RocketTrail (oldorg, ent->origin, 3);
R_RocketTrail (oldorg, ent->origin, 3, ent);
else if (ent->model->flags & EF_TRACER2)
R_RocketTrail (oldorg, ent->origin, 5);
R_RocketTrail (oldorg, ent->origin, 5, ent);
else if (ent->model->flags & EF_ROCKET)
{
R_RocketTrail (oldorg, ent->origin, 0);
R_RocketTrail (oldorg, ent->origin, 0, ent);
dl = CL_AllocDlight (i);
VectorCopy (ent->origin, dl->origin);
dl->radius = 200;
dl->die = cl.time + 0.01;
}
else if (ent->model->flags & EF_GRENADE)
R_RocketTrail (oldorg, ent->origin, 1);
R_RocketTrail (oldorg, ent->origin, 1, ent);
else if (ent->model->flags & EF_TRACER3)
R_RocketTrail (oldorg, ent->origin, 6);
R_RocketTrail (oldorg, ent->origin, 6, ent);
ent->forcelink = false;

View file

@ -423,7 +423,6 @@ CL_NewTempEntity (void)
ent = &cl_visedicts[cl_numvisedicts];
cl_numvisedicts++;
ent->keynum = 0;
memset (ent, 0, sizeof(*ent));

View file

@ -579,7 +579,7 @@ void R_TeleportSplash (vec3_t org)
R_RocketTrail
*/
void
R_RocketTrail (vec3_t start, vec3_t end, int type)
R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent)
{
vec3_t vec;
float len;
@ -612,7 +612,7 @@ R_RocketTrail (vec3_t start, vec3_t end, int type)
switch (type) {
case 0: // rocket trail
R_AddFire (start, end);
R_AddFire (start, end, ent);
p->ramp = (rand()&3);
p->color = ramp3[(int)p->ramp];
p->type = pt_fire;
@ -871,7 +871,7 @@ void R_DrawParticles (void)
particle engine code.
*/
void
R_AddFire (vec3_t start, vec3_t end)
R_AddFire (vec3_t start, vec3_t end, entity_t *ent)
{
float len;
fire_t *f;
@ -882,7 +882,7 @@ R_AddFire (vec3_t start, vec3_t end)
if (len)
{
f = R_AllocFire (0);
f = R_AllocFire (ent-cl_entities+1);
VectorCopy (end, f->origin);
VectorCopy (start, f->owner);
f->size = 20;
@ -896,7 +896,7 @@ R_AddFire (vec3_t start, vec3_t end)
}
/*
R_AllocFireball
R_AllocFire
Clears out and returns a new fireball
*/
@ -905,7 +905,6 @@ R_AllocFire (int key)
{
int i;
fire_t *f;
if (key) // first try to find/reuse a keyed spot
{
f = r_fires;
@ -921,7 +920,7 @@ R_AllocFire (int key)
f = r_fires; // no match, look for a free spot
for (i = 0; i < MAX_FIRES; i++, f++)
{
if (f->die > cl.time)
if (f->die < cl.time)
{
memset (f, 0, sizeof(*f));
f->key = key;
@ -998,19 +997,17 @@ R_UpdateFires (void)
int i;
fire_t *f;
f = r_fires;
glDepthMask (0);
glDisable (GL_TEXTURE_2D);
glShadeModel (GL_SMOOTH);
glEnable (GL_BLEND);
glBlendFunc (GL_ONE, GL_ONE);
for (i = 0; i < MAX_FIRES; i++)
f = r_fires;
for (i = 0; i < MAX_FIRES; i++, f++)
{
if (f->die < cl.time || !f->size)
continue;
f->size += f->decay;
f->color[3] /= 2.0;
R_DrawFire (f);

View file

@ -961,56 +961,6 @@ dynamic:
}
}
#if 0
/*
================
R_DrawWaterSurfaces
================
*/
void R_DrawWaterSurfaces (void)
{
int i;
msurface_t *s;
texture_t *t;
if (r_wateralpha->value == 1.0)
return;
//
// go back to the world matrix
//
glLoadMatrixf (r_world_matrix);
glEnable (GL_BLEND);
glColor4f (1,1,1,r_wateralpha->value);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
for (i=0 ; i<cl.worldmodel->numtextures ; i++)
{
t = cl.worldmodel->textures[i];
if (!t)
continue;
s = t->texturechain;
if (!s)
continue;
if ( !(s->flags & SURF_DRAWTURB) )
continue;
// set modulate mode explicitly
GL_Bind (t->gl_texturenum);
for ( ; s ; s=s->texturechain)
R_RenderBrushPoly (s);
t->texturechain = NULL;
}
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glColor4f (1,1,1,1);
glDisable (GL_BLEND);
}
#else
/*
================
R_DrawWaterSurfaces
@ -1081,8 +1031,6 @@ void R_DrawWaterSurfaces (void)
}
#endif
/*
================
DrawTextureChains

View file

@ -252,7 +252,7 @@ typedef struct {
float color[4]; // RGBA
} fire_t;
void R_AddFire (vec3_t, vec3_t);
void R_AddFire (vec3_t, vec3_t, entity_t *ent);
fire_t *R_AllocFire (int);
void R_DrawFire (fire_t *);
void R_UpdateFires (void);

View file

@ -575,7 +575,7 @@ void R_TeleportSplash (vec3_t org)
R_RocketTrail
*/
void
R_RocketTrail (vec3_t start, vec3_t end, int type)
R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent)
{
vec3_t vec;
float len;

View file

@ -166,7 +166,7 @@ void R_NewMap (void);
void R_ParseParticleEffect (void);
void R_RunParticleEffect (vec3_t org, vec3_t dir, int color, int count);
void R_RocketTrail (vec3_t start, vec3_t end, int type);
void R_RocketTrail (vec3_t start, vec3_t end, int type, entity_t *ent);
#ifdef QUAKE2
void R_DarkFieldParticles (entity_t *ent);