summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_ents.c14
-rw-r--r--src/cgame/cg_local.h6
-rw-r--r--src/cgame/cg_main.c19
-rw-r--r--src/cgame/cg_particles.c43
-rw-r--r--src/cgame/cg_servercmds.c2
5 files changed, 78 insertions, 6 deletions
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c
index 869eb8c6..b56a1a40 100644
--- a/src/cgame/cg_ents.c
+++ b/src/cgame/cg_ents.c
@@ -877,6 +877,8 @@ static void CG_CEntityPVSEnter( centity_t *cent )
cent->jetPackState = JPS_OFF;
cent->buildablePS = NULL;
+
+ cent->entityPS = NULL;
}
@@ -962,6 +964,10 @@ static void CG_AddCEntity( centity_t *cent )
CG_Spriter( cent );
break;
+ case ET_PARTICLE_SYSTEM:
+ CG_ParticleSystemEntity( cent );
+ break;
+
case ET_ANIMMAPOBJ:
CG_animMapObj( cent );
break;
@@ -1079,7 +1085,6 @@ void CG_AddPacketEntities( void )
{
cent = &cg_entities[ cg.snap->entities[ num ].number ];
cent->valid = qtrue;
- CG_AddCEntity( cent );
}
for( num = 0; num < MAX_GENTITIES; num++ )
@@ -1094,5 +1099,12 @@ void CG_AddPacketEntities( void )
cent->oldValid = cent->valid;
}
+ // add each entity sent over by the server
+ for( num = 0; num < cg.snap->numEntities; num++ )
+ {
+ cent = &cg_entities[ cg.snap->entities[ num ].number ];
+ CG_AddCEntity( cent );
+ }
+
}
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 16649ab2..45b802f2 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -459,6 +459,8 @@ typedef struct centity_s
particleSystem_t *jetPackPS;
jetPackState_t jetPackState;
+ particleSystem_t *entityPS;
+
qboolean valid;
qboolean oldValid;
} centity_t;
@@ -553,7 +555,7 @@ typedef struct localEntity_s
float initRad, finalRad;
qboolean overdraw;
qboolean realLight;
- int sortKey;
+ unsigned int sortKey;
//TA: lightning bolt endpoint entities
int srcENum, destENum;
@@ -1262,6 +1264,7 @@ typedef struct
//
qhandle_t gameModels[ MAX_MODELS ];
qhandle_t gameShaders[ MAX_SHADERS ];
+ qhandle_t gameParticleSystems[ MAX_GAME_PARTICLE_SYSTEMS ];
sfxHandle_t gameSounds[ MAX_SOUNDS ];
int numInlineModels;
@@ -1745,6 +1748,7 @@ void CG_SetParticleSystemNormal( particleSystem_t *ps, vec3_t nor
void CG_AddParticles( void );
+void CG_ParticleSystemEntity( centity_t *cent );
//===============================================
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index 7a024f4c..53cecc20 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -827,7 +827,7 @@ static void CG_RegisterGraphics( void )
{
const char *modelName;
- modelName = CG_ConfigString( CS_MODELS+i );
+ modelName = CG_ConfigString( CS_MODELS + i );
if( !modelName[ 0 ] )
break;
@@ -842,13 +842,28 @@ static void CG_RegisterGraphics( void )
{
const char *shaderName;
- shaderName = CG_ConfigString( CS_SHADERS+i );
+ shaderName = CG_ConfigString( CS_SHADERS + i );
if( !shaderName[ 0 ] )
break;
cgs.gameShaders[ i ] = trap_R_RegisterShader( shaderName );
}
+
+ CG_UpdateMediaFraction( 0.9f );
+
+ // register all the server specified particle systems
+ for( i = 1; i < MAX_GAME_PARTICLE_SYSTEMS; i++ )
+ {
+ const char *psName;
+
+ psName = CG_ConfigString( CS_PARTICLE_SYSTEMS + i );
+
+ if( !psName[ 0 ] )
+ break;
+
+ cgs.gameParticleSystems[ i ] = CG_RegisterParticleSystem( (char *)psName );
+ }
}
diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c
index 44a309ea..1e9ac1fe 100644
--- a/src/cgame/cg_particles.c
+++ b/src/cgame/cg_particles.c
@@ -1549,7 +1549,7 @@ static void CG_GarbageCollectParticleSystems( void )
//check systems where the parent cent has left the PVS
//( centNum 0 - player entity, is always valid )
- if( ps->attachType == PSA_CENT_ORIGIN && ps->attachment.centNum != 0 )
+ if( ps->attachment.centValid && ps->attachment.centNum != 0 )
{
if( !cg_entities[ ps->attachment.centNum ].valid )
ps->valid = qfalse;
@@ -1800,10 +1800,17 @@ static void CG_CompactAndSortParticles( void )
for( i = 0; i < numParticles; i++ )
{
VectorSubtract( particles[ i ].origin, cg.refdef.vieworg, delta );
- particles[ i ].sortKey = DotProduct( delta, delta );
+ particles[ i ].sortKey = (int)DotProduct( delta, delta );
}
CG_RadixSort( particles, sortParticles, numParticles );
+
+ //reverse order of particles array
+ for( i = 0; i < numParticles; i++ )
+ sortParticles[ i ] = particles[ numParticles - i - 1 ];
+
+ for( i = 0; i < numParticles; i++ )
+ particles[ i ] = sortParticles[ i ];
}
/*
@@ -1942,3 +1949,35 @@ void CG_AddParticles( void )
CG_Printf( "PS: %d PE: %d P: %d\n", numPS, numPE, numP );
}
}
+
+/*
+===============
+CG_ParticleSystemEntity
+
+Particle system entity client code
+===============
+*/
+void CG_ParticleSystemEntity( centity_t *cent )
+{
+ entityState_t *es;
+
+ es = &cent->currentState;
+
+ if( es->eFlags & EF_NODRAW )
+ {
+ if( cent->entityPS != NULL && CG_IsParticleSystemInfinite( cent->entityPS ) )
+ CG_DestroyParticleSystem( cent->entityPS );
+
+ cent->entityPS = NULL;
+
+ return;
+ }
+
+ if( cent->entityPS == NULL )
+ {
+ cent->entityPS = CG_SpawnNewParticleSystem( cgs.gameParticleSystems[ es->modelindex ] );
+ CG_SetParticleSystemOrigin( cent->entityPS, cent->lerpOrigin );
+ CG_SetParticleSystemCent( cent->entityPS, cent );
+ CG_AttachParticleSystemToOrigin( cent->entityPS );
+ }
+}
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index 90e65139..fdd11783 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -349,6 +349,8 @@ static void CG_ConfigStringModified( void )
cgs.gameModels[ num - CS_MODELS ] = trap_R_RegisterModel( str );
else if( num >= CS_SHADERS && num < CS_SHADERS+MAX_SHADERS )
cgs.gameShaders[ num - CS_SHADERS ] = trap_R_RegisterShader( str );
+ else if( num >= CS_PARTICLE_SYSTEMS && num < CS_PARTICLE_SYSTEMS+MAX_GAME_PARTICLE_SYSTEMS )
+ cgs.gameParticleSystems[ num - CS_PARTICLE_SYSTEMS ] = CG_RegisterParticleSystem( (char *)str );
else if( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS )
{
if( str[ 0 ] != '*' )