From 6d9d7b6197ab4bfea716cf996af26e448dc0a627 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 25 Apr 2000 09:35:07 +0000 Subject: [PATCH] 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. --- common/cl_ents.c | 14 ++++++------- common/cl_main.c | 14 ++++++------- common/cl_tent.c | 1 - common/gl_rpart.c | 19 ++++++++--------- common/gl_rsurf.c | 52 ----------------------------------------------- common/glquake.h | 2 +- common/r_part.c | 2 +- common/render.h | 2 +- 8 files changed, 25 insertions(+), 81 deletions(-) diff --git a/common/cl_ents.c b/common/cl_ents.c index 21e0692..0f86547 100644 --- a/common/cl_ents.c +++ b/common/cl_ents.c @@ -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); } } diff --git a/common/cl_main.c b/common/cl_main.c index d7f3654..822a51f 100644 --- a/common/cl_main.c +++ b/common/cl_main.c @@ -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; diff --git a/common/cl_tent.c b/common/cl_tent.c index 29f546a..8296c66 100644 --- a/common/cl_tent.c +++ b/common/cl_tent.c @@ -423,7 +423,6 @@ CL_NewTempEntity (void) ent = &cl_visedicts[cl_numvisedicts]; cl_numvisedicts++; - ent->keynum = 0; memset (ent, 0, sizeof(*ent)); diff --git a/common/gl_rpart.c b/common/gl_rpart.c index 04555a4..3d9b2da 100644 --- a/common/gl_rpart.c +++ b/common/gl_rpart.c @@ -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); diff --git a/common/gl_rsurf.c b/common/gl_rsurf.c index 17d1fdd..45878ec 100644 --- a/common/gl_rsurf.c +++ b/common/gl_rsurf.c @@ -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 ; inumtextures ; 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 diff --git a/common/glquake.h b/common/glquake.h index fbd2f31..cb37ad9 100644 --- a/common/glquake.h +++ b/common/glquake.h @@ -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); diff --git a/common/r_part.c b/common/r_part.c index 969c389..f80a10b 100644 --- a/common/r_part.c +++ b/common/r_part.c @@ -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; diff --git a/common/render.h b/common/render.h index 3c49cfe..fca1b73 100644 --- a/common/render.h +++ b/common/render.h @@ -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);