summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_buildable.c26
-rw-r--r--src/cgame/cg_local.h4
-rw-r--r--src/cgame/cg_particles.c55
-rw-r--r--src/cgame/cg_players.c32
-rw-r--r--src/cgame/cg_view.c16
-rw-r--r--src/cgame/cg_weapons.c67
6 files changed, 126 insertions, 74 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c
index d788657d..2414b3d5 100644
--- a/src/cgame/cg_buildable.c
+++ b/src/cgame/cg_buildable.c
@@ -795,33 +795,26 @@ static void CG_BuildableParticleEffects( centity_t *cent )
if( team == BIT_HUMANS )
{
- if( healthFrac < 0.33f && cent->buildablePS == NULL )
+ if( healthFrac < 0.33f && !CG_IsParticleSystemValid( &cent->buildablePS ) )
{
cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.humanBuildableDamagedPS );
CG_SetParticleSystemCent( cent->buildablePS, cent );
CG_AttachParticleSystemToCent( cent->buildablePS );
}
- else if( healthFrac >= 0.33f && cent->buildablePS != NULL )
- {
- CG_DestroyParticleSystem( cent->buildablePS );
- cent->buildablePS = NULL;
- }
+ else if( healthFrac >= 0.33f && CG_IsParticleSystemValid( &cent->buildablePS ) )
+ CG_DestroyParticleSystem( &cent->buildablePS );
}
else if( team == BIT_ALIENS )
{
- if( healthFrac < 0.33f && cent->buildablePS == NULL )
+ if( healthFrac < 0.33f && !CG_IsParticleSystemValid( &cent->buildablePS ) )
{
cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.alienBuildableDamagedPS );
CG_SetParticleSystemCent( cent->buildablePS, cent );
CG_SetParticleSystemNormal( cent->buildablePS, es->origin2 );
CG_AttachParticleSystemToCent( cent->buildablePS );
}
- else if( healthFrac >= 0.33f && cent->buildablePS != NULL )
- {
- CG_DestroyParticleSystem( cent->buildablePS );
- cent->buildablePS = NULL;
- }
-
+ else if( healthFrac >= 0.33f && CG_IsParticleSystemValid( &cent->buildablePS ) )
+ CG_DestroyParticleSystem( &cent->buildablePS );
}
}
@@ -930,11 +923,8 @@ void CG_Buildable( centity_t *cent )
// if set to invisible, skip
if( es->eFlags & EF_NODRAW )
{
- if( cent->buildablePS != NULL )
- {
- CG_DestroyParticleSystem( cent->buildablePS );
- cent->buildablePS = NULL;
- }
+ if( CG_IsParticleSystemValid( &cent->buildablePS ) )
+ CG_DestroyParticleSystem( &cent->buildablePS );
return;
}
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 40644e84..3120ee18 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -689,6 +689,7 @@ typedef struct weaponInfoMode_s
qhandle_t impactMark;
qhandle_t impactMarkSize;
sfxHandle_t impactSound[ 4 ]; //random impact sound
+ sfxHandle_t impactFleshSound[ 4 ]; //random impact sound
float impactDlight;
vec3_t impactDlightColor;
} weaponInfoMode_t;
@@ -1747,9 +1748,10 @@ void CG_LoadParticleSystems( void );
qhandle_t CG_RegisterParticleSystem( char *name );
particleSystem_t *CG_SpawnNewParticleSystem( qhandle_t psHandle );
-void CG_DestroyParticleSystem( particleSystem_t *ps );
+void CG_DestroyParticleSystem( particleSystem_t **ps );
qboolean CG_IsParticleSystemInfinite( particleSystem_t *ps );
+qboolean CG_IsParticleSystemValid( particleSystem_t **ps );
void CG_SetParticleSystemCent( particleSystem_t *ps, centity_t *cent );
void CG_AttachParticleSystemToCent( particleSystem_t *ps );
diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c
index 59b5d5f9..ce0020d5 100644
--- a/src/cgame/cg_particles.c
+++ b/src/cgame/cg_particles.c
@@ -1325,7 +1325,7 @@ Attach a particle system to a centity_t
*/
void CG_AttachParticleSystemToCent( particleSystem_t *ps )
{
- if( ps == NULL )
+ if( ps == NULL || !ps->valid )
{
CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" );
return;
@@ -1344,7 +1344,7 @@ Set a particle system attachment means
*/
void CG_SetParticleSystemCent( particleSystem_t *ps, centity_t *cent )
{
- if( ps == NULL )
+ if( ps == NULL || !ps->valid )
{
CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" );
return;
@@ -1363,7 +1363,7 @@ Attach a particle system to a model tag
*/
void CG_AttachParticleSystemToTag( particleSystem_t *ps )
{
- if( ps == NULL )
+ if( ps == NULL || !ps->valid )
{
CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" );
return;
@@ -1383,7 +1383,7 @@ Set a particle system attachment means
void CG_SetParticleSystemTag( particleSystem_t *ps, refEntity_t parent,
qhandle_t model, char *tagName )
{
- if( ps == NULL )
+ if( ps == NULL || !ps->valid )
{
CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" );
return;
@@ -1404,7 +1404,7 @@ Attach a particle system to a point in space
*/
void CG_AttachParticleSystemToOrigin( particleSystem_t *ps )
{
- if( ps == NULL )
+ if( ps == NULL || !ps->valid )
{
CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" );
return;
@@ -1423,7 +1423,7 @@ Set a particle system attachment means
*/
void CG_SetParticleSystemOrigin( particleSystem_t *ps, vec3_t origin )
{
- if( ps == NULL )
+ if( ps == NULL || !ps->valid )
{
CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" );
return;
@@ -1442,7 +1442,7 @@ Set a particle system attachment means
*/
void CG_SetParticleSystemNormal( particleSystem_t *ps, vec3_t normal )
{
- if( ps == NULL )
+ if( ps == NULL || !ps->valid )
{
CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" );
return;
@@ -1461,15 +1461,17 @@ Destroy a particle system
This doesn't actually invalidate anything, it just stops
particle ejectors from producing new particles so the
-garbage collector will eventually remove this system
+garbage collector will eventually remove this system.
+However is does set the pointer to NULL so the user is
+unable to manipulate this particle system any longer.
===============
*/
-void CG_DestroyParticleSystem( particleSystem_t *ps )
+void CG_DestroyParticleSystem( particleSystem_t **ps )
{
int i;
particleEjector_t *pe;
- if( ps == NULL )
+ if( *ps == NULL || !(*ps)->valid )
{
CG_Printf( S_COLOR_YELLOW "WARNING: tried to destroy a NULL particle system\n" );
return;
@@ -1482,9 +1484,11 @@ void CG_DestroyParticleSystem( particleSystem_t *ps )
{
pe = &particleEjectors[ i ];
- if( pe->valid && pe->parent == ps )
+ if( pe->valid && pe->parent == *ps )
pe->totalParticles = pe->count = 0;
}
+
+ *ps = NULL;
}
/*
@@ -1499,7 +1503,7 @@ qboolean CG_IsParticleSystemInfinite( particleSystem_t *ps )
int i;
particleEjector_t *pe;
- if( ps == NULL )
+ if( ps == NULL || !ps->valid )
{
CG_Printf( S_COLOR_YELLOW "WARNING: tried to test a NULL particle system\n" );
return qfalse;
@@ -1523,6 +1527,25 @@ qboolean CG_IsParticleSystemInfinite( particleSystem_t *ps )
return qfalse;
}
+/*
+===============
+CG_IsParticleSystemValid
+
+Test a particle system for validity
+===============
+*/
+qboolean CG_IsParticleSystemValid( particleSystem_t **ps )
+{
+ if( *ps == NULL || ( *ps && !(*ps)->valid ) )
+ {
+ if( *ps && !(*ps)->valid )
+ *ps = NULL;
+
+ return qfalse;
+ }
+
+ return qtrue;
+}
/*
===============
@@ -1975,15 +1998,13 @@ void CG_ParticleSystemEntity( centity_t *cent )
if( es->eFlags & EF_NODRAW )
{
- if( cent->entityPS != NULL && CG_IsParticleSystemInfinite( cent->entityPS ) )
- CG_DestroyParticleSystem( cent->entityPS );
-
- cent->entityPS = NULL;
+ if( CG_IsParticleSystemValid( &cent->entityPS ) && CG_IsParticleSystemInfinite( cent->entityPS ) )
+ CG_DestroyParticleSystem( &cent->entityPS );
return;
}
- if( cent->entityPS == NULL )
+ if( !CG_IsParticleSystemValid( &cent->entityPS ) )
{
cent->entityPS = CG_SpawnNewParticleSystem( cgs.gameParticleSystems[ es->modelindex ] );
CG_SetParticleSystemOrigin( cent->entityPS, cent->lerpOrigin );
diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c
index 8c7711d8..0759927e 100644
--- a/src/cgame/cg_players.c
+++ b/src/cgame/cg_players.c
@@ -1457,8 +1457,8 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso )
{
if( cent->jetPackState != JPS_ASCENDING )
{
- if( cent->jetPackPS != NULL )
- CG_DestroyParticleSystem( cent->jetPackPS );
+ if( CG_IsParticleSystemValid( &cent->jetPackPS ) )
+ CG_DestroyParticleSystem( &cent->jetPackPS );
cent->jetPackPS = CG_SpawnNewParticleSystem( cgs.media.jetPackAscendPS );
cent->jetPackState = JPS_ASCENDING;
@@ -1471,8 +1471,8 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso )
{
if( cent->jetPackState != JPS_DESCENDING )
{
- if( cent->jetPackPS != NULL )
- CG_DestroyParticleSystem( cent->jetPackPS );
+ if( CG_IsParticleSystemValid( &cent->jetPackPS ) )
+ CG_DestroyParticleSystem( &cent->jetPackPS );
cent->jetPackPS = CG_SpawnNewParticleSystem( cgs.media.jetPackDescendPS );
cent->jetPackState = JPS_DESCENDING;
@@ -1485,8 +1485,8 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso )
{
if( cent->jetPackState != JPS_HOVERING )
{
- if( cent->jetPackPS != NULL )
- CG_DestroyParticleSystem( cent->jetPackPS );
+ if( CG_IsParticleSystemValid( &cent->jetPackPS ) )
+ CG_DestroyParticleSystem( &cent->jetPackPS );
cent->jetPackPS = CG_SpawnNewParticleSystem( cgs.media.jetPackHoverPS );
cent->jetPackState = JPS_HOVERING;
@@ -1510,25 +1510,23 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso )
CG_PositionRotatedEntityOnTag( &flash, &jetpack, jetpack.hModel, "tag_flash" );
trap_R_AddRefEntityToScene( &flash );
- if( cent->jetPackPS != NULL )
+ if( CG_IsParticleSystemValid( &cent->jetPackPS ) )
{
CG_SetParticleSystemTag( cent->jetPackPS, jetpack, jetpack.hModel, "tag_flash" );
CG_SetParticleSystemCent( cent->jetPackPS, cent );
CG_AttachParticleSystemToTag( cent->jetPackPS );
}
}
- else if( cent->jetPackPS != NULL )
+ else if( CG_IsParticleSystemValid( &cent->jetPackPS ) )
{
- CG_DestroyParticleSystem( cent->jetPackPS );
+ CG_DestroyParticleSystem( &cent->jetPackPS );
cent->jetPackState = JPS_OFF;
- cent->jetPackPS = NULL;
}
}
- else if( cent->jetPackPS != NULL )
+ else if( CG_IsParticleSystemValid( &cent->jetPackPS ) )
{
- CG_DestroyParticleSystem( cent->jetPackPS );
+ CG_DestroyParticleSystem( &cent->jetPackPS );
cent->jetPackState = JPS_OFF;
- cent->jetPackPS = NULL;
}
if( es->eFlags & EF_BLOBLOCKED )
@@ -2103,11 +2101,11 @@ void CG_Player( centity_t *cent )
//sanity check that particle systems are stopped when dead
if( es->eFlags & EF_DEAD )
{
- if( cent->muzzlePS != NULL )
- CG_DestroyParticleSystem( cent->muzzlePS );
+ if( CG_IsParticleSystemValid( &cent->muzzlePS ) )
+ CG_DestroyParticleSystem( &cent->muzzlePS );
- if( cent->jetPackPS != NULL )
- CG_DestroyParticleSystem( cent->jetPackPS );
+ if( CG_IsParticleSystemValid( &cent->jetPackPS ) )
+ CG_DestroyParticleSystem( &cent->jetPackPS );
}
}
diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c
index c3e13457..9a5b8aaf 100644
--- a/src/cgame/cg_view.c
+++ b/src/cgame/cg_view.c
@@ -1136,11 +1136,8 @@ static int CG_CalcViewValues( void )
//shut off the poison cloud effect if it's still on the go
if( cg.snap->ps.stats[ STAT_HEALTH ] <= 0 )
{
- if( cg.poisonCloudPS != NULL )
- {
- CG_DestroyParticleSystem( cg.poisonCloudPS );
- cg.poisonCloudPS = NULL;
- }
+ if( CG_IsParticleSystemValid( &cg.poisonCloudPS ) )
+ CG_DestroyParticleSystem( &cg.poisonCloudPS );
}
if( cg.renderingThirdPerson )
@@ -1274,13 +1271,18 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
CG_AddPacketEntities( ); // adter calcViewValues, so predicted player state is correct
CG_AddMarks( );
CG_AddLocalEntities( );
+ }
+
+ CG_AddViewWeapon( &cg.predictedPlayerState );
+
+ //after CG_AddViewWeapon
+ if( !cg.hyperspace )
+ {
CG_AddParticles( );
//TA: wolf trails stuff
CG_AddTrails( ); // this must come last, so the trails dropped this frame get drawn
}
-
- CG_AddViewWeapon( &cg.predictedPlayerState );
// add buffered sounds
CG_PlayBufferedSounds( );
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c
index fbb79c08..a6099915 100644
--- a/src/cgame/cg_weapons.c
+++ b/src/cgame/cg_weapons.c
@@ -447,6 +447,29 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p
continue;
}
+ else if( !Q_stricmp( token, "impactFleshSound" ) )
+ {
+ int index = 0;
+
+ token = COM_Parse( text_p );
+ if( !token )
+ break;
+
+ index = atoi( token );
+
+ if( index < 0 )
+ index = 0;
+ else if( index > 3 )
+ index = 3;
+
+ token = COM_Parse( text_p );
+ if( !token )
+ break;
+
+ wim->impactFleshSound[ index ] = trap_S_RegisterSound( token, qfalse );
+
+ continue;
+ }
else if( !Q_stricmp( token, "impactDlightColor" ) )
{
for( i = 0 ; i < 3 ; i++ )
@@ -1079,7 +1102,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
if( ( nonPredictedCent - cg_entities ) != cent->currentState.clientNum )
nonPredictedCent = cent;
- if( cent->muzzlePS )
+ if( CG_IsParticleSystemValid( &cent->muzzlePS ) )
{
if( ps || cg.renderingThirdPerson ||
cent->currentState.number != cg.predictedPlayerState.clientNum )
@@ -1095,10 +1118,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
( !( cent->currentState.eFlags & EF_FIRING2 ) && weaponMode == WPM_SECONDARY ) ||
( !( cent->currentState.eFlags & EF_FIRING3 ) && weaponMode == WPM_TERTIARY ) ) &&
CG_IsParticleSystemInfinite( cent->muzzlePS ) )
- {
- CG_DestroyParticleSystem( cent->muzzlePS );
- cent->muzzlePS = NULL;
- }
+ CG_DestroyParticleSystem( &cent->muzzlePS );
}
// add the flash
@@ -1701,18 +1721,37 @@ void CG_MissileHitWall( weapon_t weaponNum, weaponMode_t weaponMode, int clientN
VectorCopy( weapon->wim[ weaponMode ].impactDlightColor, lightColor );
ps = weapon->wim[ weaponMode ].impactParticleSystem;
- // play a sound
- for( c = 0; c < 4; c++ )
+ if( soundType == IMPACTSOUND_FLESH )
{
- if( !weapon->wim[ weaponMode ].impactSound[ c ] )
- break;
+ //flesh sound
+ for( c = 0; c < 4; c++ )
+ {
+ if( !weapon->wim[ weaponMode ].impactFleshSound[ c ] )
+ break;
+ }
+
+ if( c > 0 )
+ {
+ c = rand( ) % c;
+ if( weapon->wim[ weaponMode ].impactFleshSound[ c ] )
+ trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, weapon->wim[ weaponMode ].impactFleshSound[ c ] );
+ }
}
-
- if( c > 0 )
+ else
{
- c = rand( ) % c;
- if( weapon->wim[ weaponMode ].impactSound[ c ] )
- trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, weapon->wim[ weaponMode ].impactSound[ c ] );
+ //normal sound
+ for( c = 0; c < 4; c++ )
+ {
+ if( !weapon->wim[ weaponMode ].impactSound[ c ] )
+ break;
+ }
+
+ if( c > 0 )
+ {
+ c = rand( ) % c;
+ if( weapon->wim[ weaponMode ].impactSound[ c ] )
+ trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, weapon->wim[ weaponMode ].impactSound[ c ] );
+ }
}
//create impact particle system