diff --git a/common/particledef.h b/common/particledef.h deleted file mode 100644 index 4b235c42..00000000 --- a/common/particledef.h +++ /dev/null @@ -1,55 +0,0 @@ -/*** -* -* Copyright (c) 1996-2002, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef PARTICLEDEF_H -#define PARTICLEDEF_H - -#include "xash3d_types.h" - -typedef enum -{ - pt_static, - pt_grav, - pt_slowgrav, - pt_fire, - pt_explode, - pt_explode2, - pt_blob, - pt_blob2, - pt_vox_slowgrav, - pt_vox_grav, - pt_clientcustom // Must have callback function specified -} ptype_t; - -typedef struct particle_s -{ - vec3_t org; - short color; - short packedColor; - struct particle_s *next; - vec3_t vel; - float ramp; - float die; - ptype_t type; - void (*deathfunc)( struct particle_s *particle ); - - // for pt_clientcusttom, we'll call this function each frame - void (*callback)( struct particle_s *particle, float frametime ); - - // For deathfunc, etc. - unsigned char context; -} particle_t; - -#endif//PARTICLEDEF_H diff --git a/common/q_client.h b/common/q_client.h index 678b09af..1528ce6e 100644 --- a/common/q_client.h +++ b/common/q_client.h @@ -79,4 +79,37 @@ typedef struct STATIC_CHECK_SIZEOF( kbutton_t, 12, 12 ); +typedef enum { + // Quake defined types + pt_static, pt_grav, pt_slowgrav, pt_fire, pt_explode, pt_explode2, pt_blob, pt_blob2, + + // added in HL + pr_4x_slowgrav, // 4 times faster than pt_slowgrav + pt_8x_slowgrav, // 8 times faster than pt_slowgrav + pt_custom, // will call think function from particle +} ptype_t; + +// !!! if this is changed, it must be changed in d_ifacea.h too !!! +typedef struct particle_s +{ + // driver-usable fields + vec3_t org; + short color; // in HL color is defnied by palette + short unused; // not used in hw + + // drivers never touch the following fields + struct particle_s *next; + vec3_t vel; + float ramp; + float die; + ptype_t type; + + // HL added fields + void (*on_die)( struct particle_s *p ); + void (*think)( struct particle_s *p, float frametime ); + unsigned char userdata; +} particle_t; + +STATIC_CHECK_SIZEOF( particle_t, 56, 72 ); + #endif // QUAKE_CLIENT_H diff --git a/common/r_efx.h b/common/r_efx.h index 798bccc2..4ce5e630 100644 --- a/common/r_efx.h +++ b/common/r_efx.h @@ -16,11 +16,6 @@ #ifndef R_EFX_H #define R_EFX_H -// particle_t -#if !defined( PARTICLEDEF_H ) -#include "particledef.h" -#endif - // BEAM #if !defined( BEAMDEF_H ) #include "beamdef.h" @@ -109,6 +104,7 @@ typedef struct tempent_s // baseline.angles - angle velocity } TEMPENTITY; +typedef struct particle_s particle_t; typedef struct efx_api_s efx_api_t; struct dlight_s; diff --git a/engine/client/cl_debug.c b/engine/client/cl_debug.c index b2307445..5c2efee6 100644 --- a/engine/client/cl_debug.c +++ b/engine/client/cl_debug.c @@ -16,7 +16,6 @@ GNU General Public License for more details. #include "common.h" #include "client.h" #include "net_encode.h" -#include "particledef.h" #include "cl_tent.h" #include "shake.h" #include "input.h" diff --git a/engine/client/cl_efx.c b/engine/client/cl_efx.c index 51ffde8c..7a248674 100644 --- a/engine/client/cl_efx.c +++ b/engine/client/cl_efx.c @@ -200,15 +200,15 @@ particle_t * GAME_EXPORT R_AllocParticle( void (*callback)( particle_t*, float ) p->type = pt_static; VectorClear( p->vel ); VectorClear( p->org ); - p->packedColor = 0; + p->unused = 0; p->die = cl.time; p->color = 0; p->ramp = 0; if( callback ) { - p->type = pt_clientcustom; - p->callback = callback; + p->type = pt_custom; + p->think = callback; } return p; @@ -254,7 +254,7 @@ static particle_t *R_AllocTracer( const vec3_t org, const vec3_t vel, float life p->die = cl.time + life; p->ramp = tracerlength.value; p->color = TRACER_COLORINDEX_DEFAULT; // select custom color - p->packedColor = 255; // alpha + p->unused = 255; // alpha return p; } @@ -1118,7 +1118,7 @@ void GAME_EXPORT R_ParticleExplosion2( const vec3_t org, int colorStart, int col p->die = cl.time + 0.3f; p->color = colorStart + ( colorMod % colorLength ); - p->packedColor = packedColor; + p->unused = packedColor; colorMod++; p->type = pt_blob; @@ -1150,7 +1150,7 @@ void GAME_EXPORT R_BlobExplosion( const vec3_t org ) if( !p ) return; p->die = cl.time + COM_RandomFloat( 1.0f, 1.4f ); - p->packedColor = packedColor; + p->unused = packedColor; if( i & 1 ) { @@ -1232,7 +1232,7 @@ void GAME_EXPORT R_Blood( const vec3_t org, const vec3_t ndir, int pcolor, int s p->die = cl.time + 1.5f; p->color = pcolor + COM_RandomLong( 0, 9 ); - p->type = pt_vox_grav; + p->type = pr_4x_slowgrav; VectorAddScalar( pos, COM_RandomFloat( -1.0f, 1.0f ), p->org ); VectorScale( vec, pspeed, p->vel ); @@ -1263,7 +1263,7 @@ void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t ndir, int pcolor, if( !p ) return; p->die = cl.time + 2.0f; - p->type = pt_vox_grav; + p->type = pt_8x_slowgrav; p->color = pcolor + COM_RandomLong( 0, 9 ); VectorCopy( org, p->org ); @@ -1284,7 +1284,7 @@ void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t ndir, int pcolor, p->die = cl.time + 3.0f; p->color = pcolor + COM_RandomLong( 0, 9 ); - p->type = pt_vox_slowgrav; + p->type = pr_4x_slowgrav; VectorCopy( org, p->org ); VectorCopy( dir, p->vel ); @@ -1306,7 +1306,7 @@ void GAME_EXPORT R_BloodStream( const vec3_t org, const vec3_t ndir, int pcolor, p->die = cl.time + 3.0f; p->color = pcolor + COM_RandomLong( 0, 9 ); - p->type = pt_vox_slowgrav; + p->type = pr_4x_slowgrav; p->org[0] = org[0] + COM_RandomFloat( -1.0f, 1.0f ); p->org[1] = org[1] + COM_RandomFloat( -1.0f, 1.0f ); @@ -1898,8 +1898,8 @@ void GAME_EXPORT R_UserTracerParticle( float *org, float *vel, float life, int c if(( p = R_AllocTracer( org, vel, life )) != NULL ) { - p->context = deathcontext; - p->deathfunc = deathfunc; + p->userdata = deathcontext; + p->on_die = deathfunc; p->color = colorIndex; p->ramp = length; } @@ -1996,9 +1996,9 @@ void R_FreeDeadParticles( particle_t **ppparticles ) kill = *ppparticles; if( kill && kill->die < cl.time ) { - if( kill->deathfunc ) - kill->deathfunc( kill ); - kill->deathfunc = NULL; + if( kill->on_die ) + kill->on_die( kill ); + kill->on_die = NULL; *ppparticles = kill->next; kill->next = cl_free_particles; cl_free_particles = kill; @@ -2015,9 +2015,9 @@ void R_FreeDeadParticles( particle_t **ppparticles ) kill = p->next; if( kill && kill->die < cl.time ) { - if( kill->deathfunc ) - kill->deathfunc( kill ); - kill->deathfunc = NULL; + if( kill->on_die ) + kill->on_die( kill ); + kill->on_die = NULL; p->next = kill->next; kill->next = cl_free_particles; cl_free_particles = kill; @@ -2154,7 +2154,7 @@ void CL_ThinkParticle( double frametime, particle_t *p ) float grav = frametime * clgame.movevars.gravity * 0.05f; - if( p->type != pt_clientcustom ) + if( p->type != pt_custom ) { // update position. VectorMA( p->org, frametime, p->vel, p->org ); @@ -2185,7 +2185,7 @@ void CL_ThinkParticle( double frametime, particle_t *p ) p->vel[2] -= grav; break; case pt_blob: - if( p->packedColor == 255 ) + if( p->unused == 255 ) { // normal blob explosion VectorMA( p->vel, dvel, p->vel, p->vel ); @@ -2194,7 +2194,7 @@ void CL_ThinkParticle( double frametime, particle_t *p ) } // intentionally fallthrough case pt_blob2: - if( p->packedColor == 255 ) + if( p->unused == 255 ) { // normal blob explosion p->vel[0] -= p->vel[0] * dvel; @@ -2217,15 +2217,15 @@ void CL_ThinkParticle( double frametime, particle_t *p ) case pt_slowgrav: p->vel[2] -= grav; break; - case pt_vox_grav: + case pt_8x_slowgrav: p->vel[2] -= grav * 8.0f; break; - case pt_vox_slowgrav: + case pr_4x_slowgrav: p->vel[2] -= grav * 4.0f; break; - case pt_clientcustom: - if( p->callback ) - p->callback( p, frametime ); + case pt_custom: + if( p->think ) + p->think( p, frametime ); break; } } diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index cebfef4c..5078fff3 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -16,7 +16,6 @@ GNU General Public License for more details. #include "common.h" #include "client.h" #include "net_encode.h" -#include "particledef.h" #include "cl_tent.h" #include "shake.h" #include "input.h" diff --git a/engine/client/cl_parse_gs.c b/engine/client/cl_parse_gs.c index a8f9e9d7..7c6b92c0 100644 --- a/engine/client/cl_parse_gs.c +++ b/engine/client/cl_parse_gs.c @@ -16,7 +16,6 @@ GNU General Public License for more details. #include "common.h" #include "client.h" #include "net_encode.h" -#include "particledef.h" #include "cl_tent.h" #include "shake.h" #include "input.h" diff --git a/engine/client/cl_pmove.c b/engine/client/cl_pmove.c index 2ece5457..97fc7361 100644 --- a/engine/client/cl_pmove.c +++ b/engine/client/cl_pmove.c @@ -18,7 +18,6 @@ GNU General Public License for more details. #include "const.h" #include "cl_tent.h" #include "pm_local.h" -#include "particledef.h" #include "studio.h" #define MAX_FORWARD 6 // forward probes for set idealpitch diff --git a/engine/client/cl_qparse.c b/engine/client/cl_qparse.c index feadd1f3..e166411d 100644 --- a/engine/client/cl_qparse.c +++ b/engine/client/cl_qparse.c @@ -16,7 +16,6 @@ GNU General Public License for more details. #include "common.h" #include "client.h" #include "net_encode.h" -#include "particledef.h" #include "cl_tent.h" #include "shake.h" #include "input.h" diff --git a/ref/gl/gl_rmain.c b/ref/gl/gl_rmain.c index d8b14b20..d3e5e6e4 100644 --- a/ref/gl/gl_rmain.c +++ b/ref/gl/gl_rmain.c @@ -17,7 +17,6 @@ GNU General Public License for more details. #include "xash3d_mathlib.h" #include "library.h" #include "beamdef.h" -#include "particledef.h" #include "entity_types.h" diff --git a/ref/gl/gl_rpart.c b/ref/gl/gl_rpart.c index f5d7b906..b33d7e4c 100644 --- a/ref/gl/gl_rpart.c +++ b/ref/gl/gl_rpart.c @@ -68,7 +68,7 @@ void CL_DrawParticles( double frametime, particle_t *cl_active_particles, float for( p = cl_active_particles; p; p = p->next ) { - if(( p->type != pt_blob ) || ( p->packedColor == 255 )) + if(( p->type != pt_blob ) || ( p->unused == 255 )) { size = partsize; // get initial size of particle @@ -236,7 +236,7 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers ) } color = gTracerColors[p->color]; - pglColor4ub( color.r, color.g, color.b, p->packedColor ); + pglColor4ub( color.r, color.g, color.b, p->unused ); pglTexCoord2f( 0.0f, 0.8f ); pglVertex3fv( verts[2] ); @@ -257,8 +257,8 @@ void CL_DrawTracers( double frametime, particle_t *cl_active_tracers ) p->vel[1] *= scale; p->vel[2] -= gravity; - p->packedColor = 255 * (p->die - gp_cl->time) * 2; - if( p->packedColor > 255 ) p->packedColor = 255; + p->unused = 255 * (p->die - gp_cl->time) * 2; + if( p->unused > 255 ) p->unused = 255; } else if( p->type == pt_slowgrav ) { diff --git a/ref/soft/r_main.c b/ref/soft/r_main.c index 5b768bdf..7c133a80 100644 --- a/ref/soft/r_main.c +++ b/ref/soft/r_main.c @@ -17,7 +17,6 @@ GNU General Public License for more details. #include "xash3d_mathlib.h" #include "library.h" // #include "beamdef.h" -// #include "particledef.h" #include "entity_types.h" #include "mod_local.h" int r_cnumsurfs; diff --git a/ref/soft/r_part.c b/ref/soft/r_part.c index 6424fdbd..c414fe64 100644 --- a/ref/soft/r_part.c +++ b/ref/soft/r_part.c @@ -67,7 +67,7 @@ void GAME_EXPORT CL_DrawParticles( double frametime, particle_t *cl_active_parti for( p = cl_active_particles; p; p = p->next ) { - if(( p->type != pt_blob ) || ( p->packedColor == 255 )) + if(( p->type != pt_blob ) || ( p->unused == 255 )) { size = partsize; // get initial size of particle @@ -216,7 +216,7 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers vec3_t verts[4], tmp2; vec3_t tmp, normal; color24 color; - short alpha = p->packedColor; + short alpha = p->unused; // Transform point into screen space TriWorldToScreen( start, screen ); @@ -271,9 +271,9 @@ void GAME_EXPORT CL_DrawTracers( double frametime, particle_t *cl_active_tracers p->vel[1] *= scale; p->vel[2] -= gravity; - p->packedColor = 255 * ( p->die - gp_cl->time ) * 2; - if( p->packedColor > 255 ) - p->packedColor = 255; + p->unused = 255 * ( p->die - gp_cl->time ) * 2; + if( p->unused > 255 ) + p->unused = 255; } else if( p->type == pt_slowgrav ) {