diff options
Diffstat (limited to 'src/cgame')
| -rw-r--r-- | src/cgame/cg_ents.c | 16 | ||||
| -rw-r--r-- | src/cgame/cg_local.h | 10 | ||||
| -rw-r--r-- | src/cgame/cg_main.c | 2 | ||||
| -rw-r--r-- | src/cgame/cg_particles.c | 70 | ||||
| -rw-r--r-- | src/cgame/cg_weapons.c | 5 | 
5 files changed, 64 insertions, 39 deletions
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index 278309b8..09ec1bfe 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -1058,12 +1058,16 @@ void CG_AddPacketEntities( void )        {          VectorCopy( cent->lerpOrigin, cg.ep.alienBuildablePos[ cg.ep.numAlienBuildables ] );          cg.ep.alienBuildableTimes[ cg.ep.numAlienBuildables ] = cent->miscTime; -        cg.ep.numAlienBuildables++; +         +        if( cg.ep.numAlienBuildables < MAX_GENTITIES ) +          cg.ep.numAlienBuildables++;        }        else if( cent->currentState.modelindex2 == BIT_HUMANS )        {          VectorCopy( cent->lerpOrigin, cg.ep.humanBuildablePos[ cg.ep.numHumanBuildables ] ); -        cg.ep.numHumanBuildables++; + +        if( cg.ep.numHumanBuildables < MAX_GENTITIES ) +          cg.ep.numHumanBuildables++;        }      }      else if( cent->currentState.eType == ET_PLAYER ) @@ -1073,12 +1077,16 @@ void CG_AddPacketEntities( void )        if( team == PTE_ALIENS )        {          VectorCopy( cent->lerpOrigin, cg.ep.alienClientPos[ cg.ep.numAlienClients ] ); -        cg.ep.numAlienClients++; + +        if( cg.ep.numAlienClients < MAX_CLIENTS ) +          cg.ep.numAlienClients++;        }        else if( team == PTE_HUMANS )        {          VectorCopy( cent->lerpOrigin, cg.ep.humanClientPos[ cg.ep.numHumanClients ] ); -        cg.ep.numHumanClients++; +         +        if( cg.ep.numHumanClients < MAX_CLIENTS ) +          cg.ep.numHumanClients++;        }      }    } diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 4c5f36a3..62b32ea4 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -303,9 +303,9 @@ typedef struct particleSystem_s    psAttachment_t        attachment;    qboolean              attached;   //is the particle system attached to anything -  qboolean              enabled; //necessary? -      qboolean              valid; +  qboolean              lazyRemove; //mark this system for later removal +    } particleSystem_t; @@ -769,11 +769,11 @@ typedef struct  //TA:  typedef struct  { -  vec3_t    alienBuildablePos[ BA_NUM_BUILDABLES ]; -  int       alienBuildableTimes[ BA_NUM_BUILDABLES ]; +  vec3_t    alienBuildablePos[ MAX_GENTITIES ]; +  int       alienBuildableTimes[ MAX_GENTITIES ];    int       numAlienBuildables; -  vec3_t    humanBuildablePos[ BA_NUM_BUILDABLES ]; +  vec3_t    humanBuildablePos[ MAX_GENTITIES ];    int       numHumanBuildables;    vec3_t    alienClientPos[ MAX_CLIENTS ]; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index baa1146a..cd6a9333 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -721,7 +721,6 @@ static void CG_RegisterGraphics( void )    //TA: extra stuff    cgs.media.explosionShader           = trap_R_RegisterShader( "grenadeExplosion" );    cgs.media.greenBloodTrailShader     = trap_R_RegisterShader( "greenBloodTrail" ); -  cgs.media.greenBloodExplosionShader = trap_R_RegisterShader( "greenBloodExplosion" );    cgs.media.greenBloodMarkShader      = trap_R_RegisterShader( "greenBloodMark" );    cgs.media.explosionTrailShader      = trap_R_RegisterShader( "explosionTrail" ); @@ -778,6 +777,7 @@ static void CG_RegisterGraphics( void )    cgs.media.balloonShader             = trap_R_RegisterShader( "sprites/balloon3" );    cgs.media.bloodExplosionShader      = trap_R_RegisterShader( "bloodExplosion" ); +  cgs.media.greenBloodExplosionShader = trap_R_RegisterShader( "greenBloodExplosion" );    cgs.media.bulletFlashModel          = trap_R_RegisterModel( "models/weaphits/bullet.md3" );    cgs.media.ringFlashModel            = trap_R_RegisterModel( "models/weaphits/ring02.md3" ); diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c index b3139bbf..28787bd0 100644 --- a/src/cgame/cg_particles.c +++ b/src/cgame/cg_particles.c @@ -100,6 +100,8 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p      if( !p->valid )      { +      memset( p, 0, sizeof( particle_t ) ); +        //found a free slot        p->class = bp;        p->parent = pe; @@ -219,6 +221,7 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p        p->lastEvalTime = cg.time;        p->valid = qtrue; +              break;      }    } @@ -258,28 +261,29 @@ static void CG_SpawnNewParticles( void )        bpe = particleEjectors[ i ].class; -      while( pe->nextEjectionTime <= cg.time && -             ( pe->count > 0 || pe->totalParticles == PARTICLES_INFINITE ) ) +      //if this system is scheduled for removal don't make any new particles +      if( !ps->lazyRemove )        { -        for( j = 0; j < bpe->numParticles; j++ ) -          CG_SpawnNewParticle( bpe->particles[ j ], pe ); -         -        if( pe->count > 0 ) -          pe->count--; - -        //calculate next ejection time -        lerpFrac = 1.0 - ( (float)pe->count / (float)pe->totalParticles ); -        pe->nextEjectionTime = cg.time + CG_RandomiseValue(  -            CG_LerpValues( pe->ejectPeriod.initial, -                           pe->ejectPeriod.final, -                           lerpFrac ), -            pe->ejectPeriod.randFrac ); +        while( pe->nextEjectionTime <= cg.time && +               ( pe->count > 0 || pe->totalParticles == PARTICLES_INFINITE ) ) +        { +          for( j = 0; j < bpe->numParticles; j++ ) +            CG_SpawnNewParticle( bpe->particles[ j ], pe ); +           +          if( pe->count > 0 ) +            pe->count--; + +          //calculate next ejection time +          lerpFrac = 1.0 - ( (float)pe->count / (float)pe->totalParticles ); +          pe->nextEjectionTime = cg.time + CG_RandomiseValue(  +              CG_LerpValues( pe->ejectPeriod.initial, +                             pe->ejectPeriod.final, +                             lerpFrac ), +              pe->ejectPeriod.randFrac ); +        }        } -      if( !pe->parent->valid ) -        pe->valid = qfalse; -       -      if( pe->count == 0 ) +      if( pe->count == 0 || ps->lazyRemove )        {          count = 0; @@ -320,6 +324,8 @@ static particleEjector_t *CG_SpawnNewParticleEjector( baseParticleEjector_t *bpe      if( !pe->valid )      { +      memset( pe, 0, sizeof( particleEjector_t ) ); +        //found a free slot        pe->class = bpe;        pe->parent = ps; @@ -334,6 +340,10 @@ static particleEjector_t *CG_SpawnNewParticleEjector( baseParticleEjector_t *bpe          (int)CG_RandomiseValue( (float)bpe->totalParticles, bpe->totalParticlesRandFrac );        pe->valid = qtrue; +       +      if( cg_debugParticles.integer >= 1 ) +        CG_Printf( "PE %s created\n", ps->class->name ); +              break;      }    } @@ -367,14 +377,17 @@ particleSystem_t *CG_SpawnNewParticleSystem( qhandle_t psHandle )      if( !ps->valid )      { +      memset( ps, 0, sizeof( particleSystem_t ) ); +        //found a free slot        ps->class = bps; +      ps->valid = qtrue; +      ps->lazyRemove = qfalse; +              for( j = 0; j < bps->numEjectors; j++ )          CG_SpawnNewParticleEjector( bps->ejectors[ j ], ps ); -      ps->valid = qtrue; -              if( cg_debugParticles.integer >= 1 )          CG_Printf( "PS %s created\n", bps->name ); @@ -1502,12 +1515,18 @@ qboolean CG_IsParticleSystemInfinite( particleSystem_t *ps )    int               i;    particleEjector_t *pe; -  if( ps == NULL || !ps->valid ) +  if( ps == NULL )    {      CG_Printf( S_COLOR_YELLOW "WARNING: tried to test a NULL particle system\n" );      return qfalse;    } +  if( !ps->valid ) +  { +    CG_Printf( S_COLOR_YELLOW "WARNING: tried to test an invalid particle system\n" ); +    return qfalse; +  } +      //don't bother checking already invalid systems    if( !ps->valid )      return qfalse; @@ -1584,11 +1603,11 @@ static void CG_GarbageCollectParticleSystems( void )      if( ps->attachment.centValid && ps->attachment.centNum != cg.clientNum )      {        if( !cg_entities[ ps->attachment.centNum ].valid ) -        ps->valid = qfalse; +        ps->lazyRemove = qtrue;      }      if( cg_debugParticles.integer >= 1 && !ps->valid ) -      CG_Printf( "PS garbage collected\n" ); +      CG_Printf( "PS %s garbage collected\n", ps->class->name );    }  } @@ -1738,9 +1757,6 @@ static void CG_EvaluateParticlePhysics( particle_t *p )    if( ( trap_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) ||        ( bp->cullOnStartSolid && trace.startsolid ) || bp->bounceCull )    { -    if( cg_debugParticles.integer >= 1 ) -      CG_Printf( "Particle in CONTENTS_NODROP or trace.startsolid\n" ); -      p->valid = qfalse;      return;    } diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index a6099915..3b24ee11 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -180,7 +180,7 @@ void CG_TeslaTrail( vec3_t start, vec3_t end, int srcENum, int destENum )    le->srcENum = srcENum;    le->destENum = destENum;    le->vOffset = 28; -  le->maxRange = BG_FindRangeForBuildable( BA_H_TESLAGEN ); +  le->maxRange = BG_FindRangeForBuildable( BA_H_TESLAGEN ) * M_SQRT2;    VectorCopy( start, re->origin );    VectorCopy( end, re->oldorigin ); @@ -1654,7 +1654,8 @@ void CG_FireWeapon( centity_t *cent, weaponMode_t weaponMode )    if( wi->wim[ weaponMode ].muzzleParticleSystem )    { -    if( !( cent->muzzlePS && CG_IsParticleSystemInfinite( cent->muzzlePS ) ) ) +    if( !( CG_IsParticleSystemValid( ¢->muzzlePS ) && +           CG_IsParticleSystemInfinite( cent->muzzlePS ) ) )        cent->muzzlePsTrigger = qtrue;    }  | 
