diff options
author | Tim Angus <tim@ngus.net> | 2005-10-03 20:52:19 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2005-10-03 20:52:19 +0000 |
commit | 57a17f003806d9326b64317babf866d6111c0abb (patch) | |
tree | 9783aa743a70eadc3c2e6d88117d145d6d1ba3cb /src/cgame | |
parent | e6f475ab2290ff7bc847336ed1f211f2092ac602 (diff) |
* Removed jump pad code (and associated media loading)
* Removed loading of some Q3 cruft
* Spilled events attached to temporary entities are now reattached to their
original entities, fixing the missing flame bug
* Fixed "suicide god" bug
* Fixed bug where zap ignores armour
* Fixed missing particle systems when follow-spectating
* Fixed potential bug involving dodgy pointer arithmetic in CG_LoadClientInfo
* Cleaned up logic in CG_AddPlayerWeapon
* MASK_SHOT traces no longer collide with corpses
* Corpses timeout in 20 seconds instead of 60
* Improved robustness of spawn validation, fixing the bug on transit
* A crapload of whitespace fixes
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_animmapobj.c | 14 | ||||
-rw-r--r-- | src/cgame/cg_buildable.c | 174 | ||||
-rw-r--r-- | src/cgame/cg_draw.c | 396 | ||||
-rw-r--r-- | src/cgame/cg_drawtools.c | 14 | ||||
-rw-r--r-- | src/cgame/cg_ents.c | 124 | ||||
-rw-r--r-- | src/cgame/cg_event.c | 152 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 120 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 244 | ||||
-rw-r--r-- | src/cgame/cg_marks.c | 10 | ||||
-rw-r--r-- | src/cgame/cg_mem.c | 2 | ||||
-rw-r--r-- | src/cgame/cg_particles.c | 320 | ||||
-rw-r--r-- | src/cgame/cg_players.c | 216 | ||||
-rw-r--r-- | src/cgame/cg_playerstate.c | 12 | ||||
-rw-r--r-- | src/cgame/cg_predict.c | 40 | ||||
-rw-r--r-- | src/cgame/cg_ptr.c | 6 | ||||
-rw-r--r-- | src/cgame/cg_public.h | 4 | ||||
-rw-r--r-- | src/cgame/cg_scanner.c | 38 | ||||
-rw-r--r-- | src/cgame/cg_servercmds.c | 184 | ||||
-rw-r--r-- | src/cgame/cg_snapshot.c | 18 | ||||
-rw-r--r-- | src/cgame/cg_syscalls.c | 18 | ||||
-rw-r--r-- | src/cgame/cg_trails.c | 168 | ||||
-rw-r--r-- | src/cgame/cg_view.c | 126 | ||||
-rw-r--r-- | src/cgame/cg_weapons.c | 261 | ||||
-rw-r--r-- | src/cgame/tr_types.h | 4 |
24 files changed, 1311 insertions, 1354 deletions
diff --git a/src/cgame/cg_animmapobj.c b/src/cgame/cg_animmapobj.c index 6913721d..18f49b53 100644 --- a/src/cgame/cg_animmapobj.c +++ b/src/cgame/cg_animmapobj.c @@ -71,7 +71,7 @@ static void CG_RunAMOLerpFrame( lerpFrame_t *lf ) lf->frameTime = cg.time; } } - + if( anim->reversed ) lf->frame = anim->firstFrame + anim->numFrames - 1 - f; else if( anim->flipflop && f >= anim->numFrames ) @@ -132,7 +132,7 @@ void CG_ModelDoor( centity_t *cent ) if( !es->modelindex ) return; - + //create the render entity memset( &ent, 0, sizeof( ent ) ); VectorCopy( cent->lerpOrigin, ent.origin ); @@ -166,7 +166,7 @@ void CG_ModelDoor( centity_t *cent ) lf->animationTime = lf->frameTime + anim.initialLerp; cent->doorState = es->legsAnim; } - + lf->animation = &anim; //run animation @@ -193,7 +193,7 @@ static void CG_AMOAnimation( centity_t *cent, int *old, int *now, float *backLer cent->lerpFrame.oldFrameTime += delta; cent->lerpFrame.frameTime += delta; } - + CG_RunAMOLerpFrame( ¢->lerpFrame ); cent->miscTime = cg.time; } @@ -242,21 +242,21 @@ void CG_animMapObj( centity_t *cent ) VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] ); VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] ); ent.nonNormalizedAxes = qtrue; - } + } //setup animation anim.firstFrame = es->powerups; anim.numFrames = es->weapon; anim.reversed = qfalse; anim.flipflop = qfalse; - + // if numFrames is negative the animation is reversed if( anim.numFrames < 0 ) { anim.numFrames = -anim.numFrames; anim.reversed = qtrue; } - + anim.loopFrames = es->torsoAnim; if( !es->legsAnim ) diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 0c334e7b..38259dc6 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -84,7 +84,7 @@ void CG_AlienBuildableExplosion( vec3_t origin, vec3_t dir ) int i; trap_S_StartSound( origin, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.alienBuildableExplosion ); - + // allow gibs to be turned off for speed if( cg_gibs.integer ) { @@ -93,7 +93,7 @@ void CG_AlienBuildableExplosion( vec3_t origin, vec3_t dir ) velocity[ 0 ] = crandom( ) * GGIB_VELOCITY; velocity[ 1 ] = crandom( ) * GGIB_VELOCITY; velocity[ 2 ] = GGIB_JUMP + crandom( ) * GGIB_VELOCITY; - + switch( i ) { case 1: case 5: gibModel = cgs.media.alienGib1; break; @@ -101,11 +101,11 @@ void CG_AlienBuildableExplosion( vec3_t origin, vec3_t dir ) case 3: case 7: gibModel = cgs.media.alienGib3; break; case 4: case 8: gibModel = cgs.media.alienGib4; break; } - + CG_AlienBuildableExplosionFragment( origin, velocity, gibModel ); } } - + //particle system ps = CG_SpawnNewParticleSystem( cgs.media.alienBuildableDestroyedPS ); CG_SetParticleSystemOrigin( ps, origin ); @@ -187,7 +187,7 @@ void CG_HumanBuildableExplosion( vec3_t origin, vec3_t dir ) velocity[ 0 ] = crandom( ) * EXF_VELOCITY; velocity[ 1 ] = crandom( ) * EXF_VELOCITY; velocity[ 2 ] = EXF_JUMP + crandom( ) * EXF_VELOCITY; - + switch( i ) { case 1: gibModel = cgs.media.metalGib1; break; @@ -199,10 +199,10 @@ void CG_HumanBuildableExplosion( vec3_t origin, vec3_t dir ) case 7: gibModel = cgs.media.metalGib7; break; case 8: gibModel = cgs.media.metalGib8; break; } - + CG_HumanBuildableExplosionFragment( fragOrigin, velocity, gibModel ); } - + //particle system ps = CG_SpawnNewParticleSystem( cgs.media.humanBuildableDestroyedPS ); CG_SetParticleSystemOrigin( ps, origin ); @@ -287,13 +287,13 @@ static qboolean CG_ParseBuildableAnimationFile( const char *filename, buildable_ len = trap_FS_FOpenFile( filename, &f, FS_READ ); if( len <= 0 ) return qfalse; - + if( len >= sizeof( text ) - 1 ) { CG_Printf( "File %s too long\n", filename ); return qfalse; } - + trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); @@ -308,17 +308,17 @@ static qboolean CG_ParseBuildableAnimationFile( const char *filename, buildable_ token = COM_Parse( &text_p ); if( !*token ) break; - + animations[ i ].firstFrame = atoi( token ); token = COM_Parse( &text_p ); if( !*token ) break; - + animations[ i ].numFrames = atoi( token ); animations[ i ].reversed = qfalse; animations[ i ].flipflop = qfalse; - + // if numFrames is negative the animation is reversed if( animations[ i ].numFrames < 0 ) { @@ -329,17 +329,17 @@ static qboolean CG_ParseBuildableAnimationFile( const char *filename, buildable_ token = COM_Parse( &text_p ); if ( !*token ) break; - + animations[i].loopFrames = atoi( token ); token = COM_Parse( &text_p ); if( !*token ) break; - + fps = atof( token ); if( fps == 0 ) fps = 1; - + animations[ i ].frameLerp = 1000 / fps; animations[ i ].initialLerp = 1000 / fps; } @@ -349,7 +349,7 @@ static qboolean CG_ParseBuildableAnimationFile( const char *filename, buildable_ CG_Printf( "Error parsing animation file: %s\n", filename ); return qfalse; } - + return qtrue; } @@ -377,13 +377,13 @@ static qboolean CG_ParseBuildableSoundFile( const char *filename, buildable_t bu len = trap_FS_FOpenFile( filename, &f, FS_READ ); if ( len <= 0 ) return qfalse; - + if ( len >= sizeof( text ) - 1 ) { CG_Printf( "File %s too long\n", filename ); return qfalse; } - + trap_FS_Read( text, len, f ); text[len] = 0; trap_FS_FCloseFile( f ); @@ -398,15 +398,15 @@ static qboolean CG_ParseBuildableSoundFile( const char *filename, buildable_t bu token = COM_Parse( &text_p ); if ( !*token ) break; - + sounds[ i ].enabled = atoi( token ); token = COM_Parse( &text_p ); if ( !*token ) break; - + sounds[ i ].looped = atoi( token ); - + } if( i != MAX_BUILDABLE_ANIMATIONS ) @@ -414,7 +414,7 @@ static qboolean CG_ParseBuildableSoundFile( const char *filename, buildable_t bu CG_Printf( "Error parsing sound file: %s\n", filename ); return qfalse; } - + return qtrue; } /* @@ -440,20 +440,20 @@ void CG_InitBuildables( ) for( j = BANIM_NONE + 1; j < MAX_BUILDABLE_ANIMATIONS; j++ ) { strcpy( soundfile, cg_buildableSoundNames[ j - 1 ] ); - + Com_sprintf( filename, sizeof( filename ), "sound/buildables/alien/%s", soundfile ); defaultAlienSounds[ j ] = trap_S_RegisterSound( filename, qfalse ); - + Com_sprintf( filename, sizeof( filename ), "sound/buildables/human/%s", soundfile ); defaultHumanSounds[ j ] = trap_S_RegisterSound( filename, qfalse ); } - + cg.buildablesFraction = 0.0f; - + for( i = BA_NONE + 1; i < BA_NUM_BUILDABLES; i++ ) { buildableName = BG_FindNameForBuildable( i ); - + //animation.cfg Com_sprintf( filename, sizeof( filename ), "models/buildables/%s/animation.cfg", buildableName ); if ( !CG_ParseBuildableAnimationFile( filename, i ) ) @@ -591,12 +591,12 @@ static void CG_RunBuildableLerpFrame( centity_t *cent ) anim = lf->animation; if( !anim->frameLerp ) return; // shouldn't happen - + if ( cg.time < lf->animationTime ) lf->frameTime = lf->animationTime; // initial lerp else lf->frameTime = lf->oldFrameTime + anim->frameLerp; - + f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp; numFrames = anim->numFrames; if(anim->flipflop) @@ -619,14 +619,14 @@ static void CG_RunBuildableLerpFrame( centity_t *cent ) cent->buildableAnim = cent->currentState.torsoAnim; } } - + if( anim->reversed ) lf->frame = anim->firstFrame + anim->numFrames - 1 - f; else if( anim->flipflop && f >= anim->numFrames ) lf->frame = anim->firstFrame + anim->numFrames - 1 - ( f % anim->numFrames ); else lf->frame = anim->firstFrame + f; - + if( cg.time > lf->frameTime ) { lf->frameTime = cg.time; @@ -640,7 +640,7 @@ static void CG_RunBuildableLerpFrame( centity_t *cent ) if( lf->oldFrameTime > cg.time ) lf->oldFrameTime = cg.time; - + // calculate current lerp value if( lf->frameTime == lf->oldFrameTime ) lf->backlerp = 0; @@ -656,16 +656,16 @@ CG_BuildableAnimation static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *backLerp ) { entityState_t *es = ¢->currentState; - + //if no animation is set default to idle anim if( cent->buildableAnim == BANIM_NONE ) cent->buildableAnim = es->torsoAnim; - + //display the first frame of the construction anim if not yet spawned if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) { animation_t *anim = &cg_buildables[ es->modelindex ].animations[ BANIM_CONSTRUCT1 ]; - + //so that when animation starts for real it has sensible numbers cent->lerpFrame.oldFrameTime = cent->lerpFrame.frameTime = @@ -694,7 +694,7 @@ static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *b else cent->buildableAnim = cent->oldBuildableAnim = es->torsoAnim; } - + CG_RunBuildableLerpFrame( cent ); *old = cent->lerpFrame.oldFrame; @@ -717,18 +717,18 @@ static void CG_PositionAndOrientateBuildable( const vec3_t angles, const vec3_t { vec3_t forward, start, end; trace_t tr; - + AngleVectors( angles, forward, NULL, NULL ); VectorCopy( normal, outAxis[ 2 ] ); ProjectPointOnPlane( outAxis[ 0 ], forward, outAxis[ 2 ] ); - + if( !VectorNormalize( outAxis[ 0 ] ) ) { AngleVectors( angles, NULL, NULL, forward ); ProjectPointOnPlane( outAxis[ 0 ], forward, outAxis[ 2 ] ); VectorNormalize( outAxis[ 0 ] ); } - + CrossProduct( outAxis[ 0 ], outAxis[ 2 ], outAxis[ 1 ] ); outAxis[ 1 ][ 0 ] = -outAxis[ 1 ][ 0 ]; outAxis[ 1 ][ 1 ] = -outAxis[ 1 ][ 1 ]; @@ -737,13 +737,13 @@ static void CG_PositionAndOrientateBuildable( const vec3_t angles, const vec3_t VectorMA( inOrigin, -TRACE_DEPTH, normal, end ); VectorMA( inOrigin, 1.0f, normal, start ); CG_CapTrace( &tr, start, mins, maxs, end, skipNumber, MASK_PLAYERSOLID ); - + if( tr.fraction == 1.0f ) { //erm we missed completely - try again with a box trace CG_Trace( &tr, start, mins, maxs, end, skipNumber, MASK_PLAYERSOLID ); } - + VectorMA( inOrigin, tr.fraction * -TRACE_DEPTH, normal, outOrigin ); } @@ -760,9 +760,9 @@ void CG_GhostBuildable( buildable_t buildable ) vec3_t mins, maxs; trace_t tr; float scale; - + ps = &cg.predictedPlayerState; - + memset( &ent, 0, sizeof( ent ) ); BG_FindBBoxForBuildable( buildable, mins, maxs ); @@ -774,17 +774,17 @@ void CG_GhostBuildable( buildable_t buildable ) //offset on the Z axis if required VectorMA( ent.origin, BG_FindZOffsetForBuildable( buildable ), tr.plane.normal, ent.origin ); - + VectorCopy( ent.origin, ent.lightingOrigin ); VectorCopy( ent.origin, ent.oldorigin ); // don't positionally lerp at all - + ent.hModel = cg_buildables[ buildable ].models[ 0 ]; if( ps->stats[ STAT_BUILDABLE ] & SB_VALID_TOGGLEBIT ) ent.customShader = cgs.media.greenBuildShader; else ent.customShader = cgs.media.redBuildShader; - + //rescale the model scale = BG_FindModelScaleForBuildable( buildable ); @@ -793,7 +793,7 @@ void CG_GhostBuildable( buildable_t buildable ) VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] ); VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] ); VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] ); - + ent.nonNormalizedAxes = qtrue; } else @@ -814,10 +814,10 @@ static void CG_BuildableParticleEffects( centity_t *cent ) buildableTeam_t team = BG_FindTeamForBuildable( es->modelindex ); int health = es->generic1 & ~( B_POWERED_TOGGLEBIT | B_DCCED_TOGGLEBIT | B_SPAWNED_TOGGLEBIT ); float healthFrac = (float)health / B_HEALTH_SCALE; - + if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) return; - + if( team == BIT_HUMANS ) { if( healthFrac < 0.33f && !CG_IsParticleSystemValid( ¢->buildablePS ) ) @@ -866,20 +866,20 @@ static void CG_BuildableHealthBar( centity_t *cent ) health = es->generic1 & ~( B_POWERED_TOGGLEBIT | B_DCCED_TOGGLEBIT | B_SPAWNED_TOGGLEBIT ); progress = (float)health / B_HEALTH_SCALE; - + if( progress < 0.0f ) progress = 0.0f; else if( progress > 1.0f ) progress = 1.0f; - + if( progress < 0.33f ) shader = cgs.media.redBuildShader; else shader = cgs.media.greenBuildShader; - + doneWidth = ( HEALTH_BAR_WIDTH - 2 * rimWidth ) * progress; leftWidth = ( HEALTH_BAR_WIDTH - 2 * rimWidth ) - doneWidth; - + VectorCopy( cg.refdef.viewaxis[ 2 ], down ); VectorInverse( down ); VectorCopy( cg.refdef.viewaxis[ 1 ], right ); @@ -892,28 +892,28 @@ static void CG_BuildableHealthBar( centity_t *cent ) VectorMA( origin, 48.0f, es->origin2, origin ); VectorMA( origin, -HEALTH_BAR_WIDTH / 2.0f, right, origin ); VectorMA( origin, maxs[ 0 ] + 8.0f, back, origin ); - + VectorCopy( origin, origin2 ); VectorScale( right, rimWidth + doneWidth, rightLength ); VectorScale( down, HEALTH_BAR_HEIGHT, downLength ); CG_DrawPlane( origin2, downLength, rightLength, shader ); - + VectorMA( origin, rimWidth + doneWidth, right, origin2 ); VectorScale( right, leftWidth, rightLength ); VectorScale( down, rimWidth, downLength ); CG_DrawPlane( origin2, downLength, rightLength, shader ); - + VectorMA( origin, rimWidth + doneWidth, right, origin2 ); VectorMA( origin2, HEALTH_BAR_HEIGHT - rimWidth, down, origin2 ); VectorScale( right, leftWidth, rightLength ); VectorScale( down, rimWidth, downLength ); CG_DrawPlane( origin2, downLength, rightLength, shader ); - + VectorMA( origin, HEALTH_BAR_WIDTH - rimWidth, right, origin2 ); VectorScale( right, rimWidth, rightLength ); VectorScale( down, HEALTH_BAR_HEIGHT, downLength ); CG_DrawPlane( origin2, downLength, rightLength, shader ); - + if( !( es->generic1 & B_POWERED_TOGGLEBIT ) && BG_FindTeamForBuildable( es->modelindex ) == BIT_HUMANS ) { @@ -944,11 +944,11 @@ void CG_Buildable( centity_t *cent ) float scale; int health; float healthScale; - + //must be before EF_NODRAW check if( team == BIT_ALIENS ) CG_Creep( cent ); - + // if set to invisible, skip if( es->eFlags & EF_NODRAW ) { @@ -965,17 +965,17 @@ void CG_Buildable( centity_t *cent ) VectorCopy( cent->lerpOrigin, ent.lightingOrigin ); VectorCopy( es->origin2, surfNormal ); - + VectorCopy( es->angles, angles ); BG_FindBBoxForBuildable( es->modelindex, mins, maxs ); - + if( es->pos.trType == TR_STATIONARY ) CG_PositionAndOrientateBuildable( angles, ent.origin, surfNormal, es->number, mins, maxs, ent.axis, ent.origin ); - + //offset on the Z axis if required VectorMA( ent.origin, BG_FindZOffsetForBuildable( es->modelindex ), surfNormal, ent.origin ); - + VectorCopy( ent.origin, ent.oldorigin ); // don't positionally lerp at all VectorCopy( ent.origin, ent.lightingOrigin ); @@ -984,7 +984,7 @@ void CG_Buildable( centity_t *cent ) if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) { sfxHandle_t prebuildSound = cgs.media.humanBuildablePrebuild; - + if( team == BIT_HUMANS ) { ent.customShader = cgs.media.humanSpawningShader; @@ -995,7 +995,7 @@ void CG_Buildable( centity_t *cent ) trap_S_AddLoopingSound( es->number, cent->lerpOrigin, vec3_origin, prebuildSound ); } - + CG_BuildableAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp ); //rescale the model @@ -1006,26 +1006,26 @@ void CG_Buildable( centity_t *cent ) VectorScale( ent.axis[ 0 ], scale, ent.axis[ 0 ] ); VectorScale( ent.axis[ 1 ], scale, ent.axis[ 1 ] ); VectorScale( ent.axis[ 2 ], scale, ent.axis[ 2 ] ); - + ent.nonNormalizedAxes = qtrue; } else ent.nonNormalizedAxes = qfalse; - + //add to refresh list trap_R_AddRefEntityToScene( &ent ); CrossProduct( surfNormal, refNormal, xNormal ); VectorNormalize( xNormal ); rotAngle = RAD2DEG( acos( DotProduct( surfNormal, refNormal ) ) ); - + //turret barrel bit if( cg_buildables[ es->modelindex ].models[ 1 ] ) { refEntity_t turretBarrel; vec3_t flatAxis[ 3 ]; - + memset( &turretBarrel, 0, sizeof( turretBarrel ) ); turretBarrel.hModel = cg_buildables[ es->modelindex ].models[ 1 ]; @@ -1037,24 +1037,24 @@ void CG_Buildable( centity_t *cent ) RotatePointAroundVector( turretBarrel.axis[ 0 ], xNormal, flatAxis[ 0 ], -rotAngle ); RotatePointAroundVector( turretBarrel.axis[ 1 ], xNormal, flatAxis[ 1 ], -rotAngle ); RotatePointAroundVector( turretBarrel.axis[ 2 ], xNormal, flatAxis[ 2 ], -rotAngle ); - + turretBarrel.oldframe = ent.oldframe; turretBarrel.frame = ent.frame; turretBarrel.backlerp = ent.backlerp; turretBarrel.customShader = ent.customShader; - + if( scale != 1.0f ) { VectorScale( turretBarrel.axis[ 0 ], scale, turretBarrel.axis[ 0 ] ); VectorScale( turretBarrel.axis[ 1 ], scale, turretBarrel.axis[ 1 ] ); VectorScale( turretBarrel.axis[ 2 ], scale, turretBarrel.axis[ 2 ] ); - + turretBarrel.nonNormalizedAxes = qtrue; } else turretBarrel.nonNormalizedAxes = qfalse; - + trap_R_AddRefEntityToScene( &turretBarrel ); } @@ -1064,12 +1064,12 @@ void CG_Buildable( centity_t *cent ) refEntity_t turretTop; vec3_t flatAxis[ 3 ]; vec3_t swivelAngles; - + memset( &turretTop, 0, sizeof( turretTop ) ); VectorCopy( es->angles2, swivelAngles ); swivelAngles[ PITCH ] = 0.0f; - + turretTop.hModel = cg_buildables[ es->modelindex ].models[ 2 ]; CG_PositionRotatedEntityOnTag( &turretTop, &ent, ent.hModel, "tag_turret" ); @@ -1079,24 +1079,24 @@ void CG_Buildable( centity_t *cent ) RotatePointAroundVector( turretTop.axis[ 0 ], xNormal, flatAxis[ 0 ], -rotAngle ); RotatePointAroundVector( turretTop.axis[ 1 ], xNormal, flatAxis[ 1 ], -rotAngle ); RotatePointAroundVector( turretTop.axis[ 2 ], xNormal, flatAxis[ 2 ], -rotAngle ); - + turretTop.oldframe = ent.oldframe; turretTop.frame = ent.frame; turretTop.backlerp = ent.backlerp; turretTop.customShader = ent.customShader; - + if( scale != 1.0f ) { VectorScale( turretTop.axis[ 0 ], scale, turretTop.axis[ 0 ] ); VectorScale( turretTop.axis[ 1 ], scale, turretTop.axis[ 1 ] ); VectorScale( turretTop.axis[ 2 ], scale, turretTop.axis[ 2 ] ); - + turretTop.nonNormalizedAxes = qtrue; } else turretTop.nonNormalizedAxes = qfalse; - + trap_R_AddRefEntityToScene( &turretTop ); } @@ -1119,8 +1119,8 @@ void CG_Buildable( centity_t *cent ) if( es->eFlags & EF_FIRING ) { weaponInfo_t *weapon = &cg_weapons[ es->weapon ]; - - if( cg.time - cent->muzzleFlashTime > MUZZLE_FLASH_TIME || + + if( cg.time - cent->muzzleFlashTime > MUZZLE_FLASH_TIME || BG_FindProjTypeForBuildable( es->modelindex ) == WP_TESLAGEN ) { if( weapon->wim[ WPM_PRIMARY ].flashDlightColor[ 0 ] || @@ -1133,7 +1133,7 @@ void CG_Buildable( centity_t *cent ) weapon->wim[ WPM_PRIMARY ].flashDlightColor[ 2 ] ); } } - + if( weapon->wim[ WPM_PRIMARY ].firingSound ) { trap_S_AddLoopingSound( es->number, cent->lerpOrigin, vec3_origin, @@ -1142,7 +1142,7 @@ void CG_Buildable( centity_t *cent ) else if( weapon->readySound ) trap_S_AddLoopingSound( es->number, cent->lerpOrigin, vec3_origin, weapon->readySound ); } - + health = es->generic1 & ~( B_POWERED_TOGGLEBIT | B_DCCED_TOGGLEBIT | B_SPAWNED_TOGGLEBIT ); healthScale = (float)health / B_HEALTH_SCALE; @@ -1157,13 +1157,13 @@ void CG_Buildable( centity_t *cent ) } else if( team == BIT_ALIENS ) trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.alienBuildableDamage ); - + cent->lastBuildableDamageSoundTime = cg.time; } } - + cent->lastBuildableHealthScale = healthScale; - + //smoke etc for damaged buildables CG_BuildableParticleEffects( cent ); } diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index 9cb1740c..7fd6226d 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -42,21 +42,21 @@ int CG_Text_Width( const char *text, float scale, int limit ) // const unsigned char *s = text; const char *s = text; fontInfo_t *font = &cgDC.Assets.textFont; - + if( scale <= cg_smallFont.value ) font = &cgDC.Assets.smallFont; else if( scale > cg_bigFont.value ) font = &cgDC.Assets.bigFont; - + useScale = scale * font->glyphScale; out = 0; - + if( text ) { len = strlen( text ); if( limit > 0 && len > limit ) len = limit; - + count = 0; while( s && *s && count < len ) { @@ -76,7 +76,7 @@ int CG_Text_Width( const char *text, float scale, int limit ) } } } - + return out * useScale; } @@ -90,21 +90,21 @@ int CG_Text_Height( const char *text, float scale, int limit ) // const unsigned char *s = text; const char *s = text; fontInfo_t *font = &cgDC.Assets.textFont; - + if( scale <= cg_smallFont.value ) font = &cgDC.Assets.smallFont; else if( scale > cg_bigFont.value ) font = &cgDC.Assets.bigFont; - + useScale = scale * font->glyphScale; max = 0; - + if( text ) { len = strlen( text ); if( limit > 0 && len > limit ) len = limit; - + count = 0; while( s && *s && count < len ) { @@ -120,13 +120,13 @@ int CG_Text_Height( const char *text, float scale, int limit ) //hopefully this doesn't break the VM build if( max < glyph->height ) max = glyph->height; - + s++; count++; } } } - + return max * useScale; } @@ -148,33 +148,33 @@ void CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex glyphInfo_t *glyph; float useScale; fontInfo_t *font = &cgDC.Assets.textFont; - + if( scale <= cg_smallFont.value ) font = &cgDC.Assets.smallFont; else if( scale > cg_bigFont.value ) font = &cgDC.Assets.bigFont; - + useScale = scale * font->glyphScale; if( text ) { // TTimo: FIXME // const unsigned char *s = text; const char *s = text; - + trap_R_SetColor( color ); memcpy( &newColor[ 0 ], &color[ 0 ], sizeof( vec4_t ) ); len = strlen( text ); - + if( limit > 0 && len > limit ) len = limit; - + count = 0; while( s && *s && count < len ) { glyph = &font->glyphs[ (int)*s ]; //TTimo: FIXME: getting nasty warnings without the cast, //hopefully this doesn't break the VM build - + if( Q_IsColorString( s ) ) { memcpy( newColor, g_color_table[ ColorIndex( *( s + 1 ) ) ], sizeof( newColor ) ); @@ -192,16 +192,16 @@ void CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex int ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2; colorBlack[ 3 ] = newColor[ 3 ]; trap_R_SetColor( colorBlack ); - CG_Text_PaintChar( x + ofs, y - yadj + ofs, + CG_Text_PaintChar( x + ofs, y - yadj + ofs, glyph->imageWidth, glyph->imageHeight, - useScale, + useScale, glyph->s, glyph->t, glyph->s2, glyph->t2, glyph->glyph ); - + colorBlack[ 3 ] = 1.0; trap_R_SetColor( newColor ); } @@ -213,19 +213,19 @@ void CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex glow[ 1 ] = newColor[ 1 ] * 0.5; glow[ 2 ] = newColor[ 2 ] * 0.5; glow[ 3 ] = newColor[ 3 ] * 0.2; - + outer[ 0 ] = newColor[ 0 ]; outer[ 1 ] = newColor[ 1 ]; outer[ 2 ] = newColor[ 2 ]; outer[ 3 ] = newColor[ 3 ]; - + inner[ 0 ] = newColor[ 0 ] * 1.5 > 1.0f ? 1.0f : newColor[ 0 ] * 1.5; inner[ 1 ] = newColor[ 1 ] * 1.5 > 1.0f ? 1.0f : newColor[ 1 ] * 1.5; inner[ 2 ] = newColor[ 2 ] * 1.5 > 1.0f ? 1.0f : newColor[ 2 ] * 1.5; inner[ 3 ] = newColor[ 3 ]; white[ 0 ] = white[ 1 ] = white[ 2 ] = white[ 3 ] = 1.0f; - + trap_R_SetColor( glow ); CG_Text_PaintChar( x - 3, y - yadj - 3, glyph->imageWidth + 6, @@ -236,7 +236,7 @@ void CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex glyph->s2, glyph->t2, glyph->glyph ); - + trap_R_SetColor( outer ); CG_Text_PaintChar( x - 1, y - yadj - 1, glyph->imageWidth + 2, @@ -247,7 +247,7 @@ void CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex glyph->s2, glyph->t2, glyph->glyph ); - + trap_R_SetColor( inner ); CG_Text_PaintChar( x - 0.5, y - yadj - 0.5, glyph->imageWidth + 1, @@ -258,27 +258,27 @@ void CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex glyph->s2, glyph->t2, glyph->glyph ); - + trap_R_SetColor( white ); } - - - CG_Text_PaintChar( x, y - yadj, + + + CG_Text_PaintChar( x, y - yadj, glyph->imageWidth, glyph->imageHeight, - useScale, + useScale, glyph->s, glyph->t, glyph->s2, glyph->t2, glyph->glyph ); - + x += ( glyph->xSkip * useScale ) + adjust; s++; count++; } } - + trap_R_SetColor( NULL ); } } @@ -332,12 +332,12 @@ static void CG_DrawFieldPadded( int x, int y, int width, int cw, int ch, int val Com_sprintf( num, sizeof( num ), "%d", value ); l = strlen( num ); - + if( l > width ) l = width; - + orgL = l; - + x += 2; ptr = num; @@ -350,7 +350,7 @@ static void CG_DrawFieldPadded( int x, int y, int width, int cw, int ch, int val x += charWidth; continue; } - + if( *ptr == '-' ) frame = STAT_MINUS; else @@ -412,10 +412,10 @@ static void CG_DrawField( int x, int y, int width, int cw, int ch, int value ) Com_sprintf( num, sizeof( num ), "%d", value ); l = strlen( num ); - + if( l > width ) l = width; - + x += 2 + charWidth * ( width - l ); ptr = num; @@ -440,7 +440,7 @@ static void CG_DrawProgressBar( rectDef_t *rect, vec4_t color, float scale, float doneWidth, leftWidth; float tx, ty, tw, th; char textBuffer[ 8 ]; - + if( rimWidth < 0.6f ) rimWidth = 0.6f; @@ -451,12 +451,12 @@ static void CG_DrawProgressBar( rectDef_t *rect, vec4_t color, float scale, progress = 0.0f; else if( progress > 1.0f ) progress = 1.0f; - + doneWidth = ( rect->w - 2 * rimWidth ) * progress; leftWidth = ( rect->w - 2 * rimWidth ) - doneWidth; - + trap_R_SetColor( color ); - + //draw rim and bar if( align == ITEM_ALIGN_RIGHT ) { @@ -479,14 +479,14 @@ static void CG_DrawProgressBar( rectDef_t *rect, vec4_t color, float scale, } trap_R_SetColor( NULL ); - + //draw text if( scale > 0.0 ) { Com_sprintf( textBuffer, sizeof( textBuffer ), "%d%%", (int)( progress * 100 ) ); tw = CG_Text_Width( textBuffer, scale, 0 ); th = scale * 40.0f; - + switch( align ) { case ITEM_ALIGN_LEFT: @@ -507,7 +507,7 @@ static void CG_DrawProgressBar( rectDef_t *rect, vec4_t color, float scale, default: tx = ty = 0.0f; } - + CG_Text_Paint( tx, ty, scale, color, textBuffer, 0, 0, textStyle ); } } @@ -545,7 +545,7 @@ static qboolean CG_AtHighestClass( void ) { int i; qboolean superiorClasses = qfalse; - + for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { if( BG_ClassCanEvolveFromTo( @@ -576,7 +576,7 @@ static void CG_DrawPlayerCreditsValue( rectDef_t *rect, vec4_t color, qboolean p if( ( cent->currentState.weapon == WP_ABUILD || cent->currentState.weapon == WP_ABUILD2 ) && ps->stats[ STAT_MISC ] ) return; - + value = ps->persistant[ PERS_CREDIT ]; if( value > -1 ) { @@ -589,14 +589,14 @@ static void CG_DrawPlayerCreditsValue( rectDef_t *rect, vec4_t color, qboolean p color[ 3 ] = 0.0f; } } - + trap_R_SetColor( color ); if( padding ) CG_DrawFieldPadded( rect->x, rect->y, 4, rect->w / 4, rect->h, value ); else CG_DrawField( rect->x, rect->y, 1, rect->w, rect->h, value ); - + trap_R_SetColor( NULL ); } } @@ -617,7 +617,7 @@ static void CG_DrawPlayerBankValue( rectDef_t *rect, vec4_t color, qboolean padd CG_DrawFieldPadded( rect->x, rect->y, 4, rect->w / 4, rect->h, value ); else CG_DrawField( rect->x, rect->y, 1, rect->w, rect->h, value ); - + trap_R_SetColor( NULL ); } } @@ -651,7 +651,7 @@ static void CG_DrawPlayerStamina1( rectDef_t *rect, vec4_t color, qhandle_t shad progress = 0.0f; color[ 3 ] = HH_MIN_ALPHA + ( progress * HH_ALPHA_DIFF ); - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -678,7 +678,7 @@ static void CG_DrawPlayerStamina2( rectDef_t *rect, vec4_t color, qhandle_t shad progress = 0.0f; color[ 3 ] = HH_MIN_ALPHA + ( progress * HH_ALPHA_DIFF ); - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -704,7 +704,7 @@ static void CG_DrawPlayerStamina3( rectDef_t *rect, vec4_t color, qhandle_t shad progress = 0.0f; color[ 3 ] = HH_MIN_ALPHA + ( progress * HH_ALPHA_DIFF ); - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -730,7 +730,7 @@ static void CG_DrawPlayerStamina4( rectDef_t *rect, vec4_t color, qhandle_t shad progress = 0.0f; color[ 3 ] = HH_MIN_ALPHA + ( progress * HH_ALPHA_DIFF ); - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -750,7 +750,7 @@ static void CG_DrawPlayerStaminaBolt( rectDef_t *rect, vec4_t color, qhandle_t s color[ 3 ] = HH_MIN_ALPHA; else color[ 3 ] = HH_MAX_ALPHA; - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -770,7 +770,7 @@ static void CG_DrawPlayerClipsRing( rectDef_t *rect, vec4_t color, qhandle_t sha float maxDelay; cent = &cg_entities[ cg.snap->ps.clientNum ]; - + switch( cent->currentState.weapon ) { case WP_ABUILD: @@ -797,7 +797,7 @@ static void CG_DrawPlayerClipsRing( rectDef_t *rect, vec4_t color, qhandle_t sha } break; } - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -817,16 +817,16 @@ static void CG_DrawPlayerBuildTimerRing( rectDef_t *rect, vec4_t color, qhandle_ float maxDelay; cent = &cg_entities[ cg.snap->ps.clientNum ]; - + maxDelay = (float)BG_FindBuildDelayForWeapon( cent->currentState.weapon ); - + if( buildTime > maxDelay ) buildTime = maxDelay; progress = ( maxDelay - buildTime ) / maxDelay; color[ 3 ] = AH_MIN_ALPHA + ( progress * AH_ALPHA_DIFF ); - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -841,12 +841,12 @@ static void CG_DrawPlayerBoosted( rectDef_t *rect, vec4_t color, qhandle_t shade { playerState_t *ps = &cg.snap->ps; qboolean boosted = ps->stats[ STAT_STATE ] & SS_BOOSTED; - + if( boosted ) color[ 3 ] = AH_MAX_ALPHA; else color[ 3 ] = AH_MIN_ALPHA; - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -870,12 +870,12 @@ static void CG_DrawPlayerBoosterBolt( rectDef_t *rect, vec4_t color, qhandle_t s if( ps->stats[ STAT_BOOSTTIME ] > BOOST_TIME - 3000 ) { qboolean flash = ( ps->stats[ STAT_BOOSTTIME ] / 500 ) % 2; - + if( flash ) localColor[ 3 ] = 1.0f; } } - + trap_R_SetColor( localColor ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -897,7 +897,7 @@ static void CG_DrawPlayerPoisonBarbs( rectDef_t *rect, vec4_t color, qhandle_t s int iconsize, numBarbs, i; BG_UnpackAmmoArray( ps->weapon, ps->ammo, ps->powerups, &numBarbs, NULL ); - + if( height > width ) { vertical = qtrue; @@ -908,20 +908,20 @@ static void CG_DrawPlayerPoisonBarbs( rectDef_t *rect, vec4_t color, qhandle_t s vertical = qfalse; iconsize = height; } - + if( color[ 3 ] != 0.0 ) trap_R_SetColor( color ); - + for( i = 0; i < numBarbs; i ++ ) { if( vertical ) y += iconsize; else x += iconsize; - + CG_DrawPic( x, y, iconsize, iconsize, shader ); } - + trap_R_SetColor( NULL ); } @@ -939,7 +939,7 @@ static void CG_DrawPlayerWallclimbing( rectDef_t *rect, vec4_t color, qhandle_t color[ 3 ] = AH_MAX_ALPHA; else color[ 3 ] = AH_MIN_ALPHA; - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -951,7 +951,7 @@ static void CG_DrawPlayerStamina( rectDef_t *rect, vec4_t color, float scale, playerState_t *ps = &cg.snap->ps; int stamina = ps->stats[ STAT_STAMINA ]; float progress = ( (float)stamina + (float)MAX_STAMINA ) / ( (float)MAX_STAMINA * 2.0f ); - + CG_DrawProgressBar( rect, color, scale, align, textStyle, special, progress ); } @@ -987,7 +987,7 @@ static void CG_DrawPlayerAmmoValue( rectDef_t *rect, vec4_t color ) if( value > 999 ) value = 999; - + if( value > -1 ) { trap_R_SetColor( color ); @@ -1021,7 +1021,7 @@ static void CG_DrawHumanScanner( rectDef_t *rect, qhandle_t shader, vec4_t color CG_Scanner( rect, shader, color ); } - + /* ============== CG_DrawUsableBuildable @@ -1032,7 +1032,7 @@ static void CG_DrawUsableBuildable( rectDef_t *rect, qhandle_t shader, vec4_t co vec3_t view, point; trace_t trace; entityState_t *es; - + AngleVectors( cg.refdefViewAngles, view, NULL, NULL ); VectorMA( cg.refdef.vieworg, 64, view, point ); CG_Trace( &trace, cg.refdef.vieworg, NULL, NULL, @@ -1048,7 +1048,7 @@ static void CG_DrawUsableBuildable( rectDef_t *rect, qhandle_t shader, vec4_t co ( !BG_FindUsesEnergyForWeapon( cg.snap->ps.weapon ) || BG_FindInfinteAmmoForWeapon( cg.snap->ps.weapon ) ) ) return; - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -1075,15 +1075,15 @@ static void CG_DrawPlayerBuildTimer( rectDef_t *rect, vec4_t color ) case WP_ABUILD: progress = (float)ps->stats[ STAT_MISC ] / (float)ABUILDER_BASE_DELAY; break; - + case WP_ABUILD2: progress = (float)ps->stats[ STAT_MISC ] / (float)ABUILDER_ADV_DELAY; break; - + case WP_HBUILD: progress = (float)ps->stats[ STAT_MISC ] / (float)HBUILD_DELAY; break; - + case WP_HBUILD2: progress = (float)ps->stats[ STAT_MISC ] / (float)HBUILD2_DELAY; break; @@ -1095,14 +1095,14 @@ static void CG_DrawPlayerBuildTimer( rectDef_t *rect, vec4_t color ) if( !ps->stats[ STAT_MISC ] ) return; - + index = (int)( progress * 8.0f ); if( index > 7 ) index = 7; else if( index < 0 ) index = 0; - + if( cg.time - cg.lastBuildAttempt <= BUILD_DELAY_TIME ) { if( ( ( cg.time - cg.lastBuildAttempt ) / 300 ) % 2 ) @@ -1112,7 +1112,7 @@ static void CG_DrawPlayerBuildTimer( rectDef_t *rect, vec4_t color ) color[ 3 ] = 1.0f; } } - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.buildWeaponTimerPie[ index ] ); @@ -1141,7 +1141,7 @@ static void CG_DrawPlayerClipsValue( rectDef_t *rect, vec4_t color ) default: BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, NULL, &value ); - + if( value > -1 ) { trap_R_SetColor( color ); @@ -1194,7 +1194,7 @@ static void CG_DrawPlayerHealthCross( rectDef_t *rect, vec4_t color, qhandle_t s color[ 0 ] = 1.0f; color[ 1 ] = color[ 2 ] = 0.0f; } - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); @@ -1223,7 +1223,7 @@ static void CG_DrawProgressLabel( rectDef_t *rect, float text_x, float text_y, v default: tx = 0.0f; } - + if( fraction < 1.0f ) CG_Text_Paint( rect->x + text_x + tx, rect->y + text_y, scale, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL ); @@ -1283,17 +1283,17 @@ static void CG_DrawLevelShot( rectDef_t *rect ) const char *info; qhandle_t levelshot; qhandle_t detail; - + info = CG_ConfigString( CS_SERVERINFO ); s = Info_ValueForKey( info, "mapname" ); levelshot = trap_R_RegisterShaderNoMip( va( "levelshots/%s.tga", s ) ); - + if( !levelshot ) levelshot = trap_R_RegisterShaderNoMip( "gfx/2d/load_screen" ); - + trap_R_SetColor( NULL ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, levelshot ); - + // blend a detail texture over it detail = trap_R_RegisterShader( "levelShotDetail" ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, detail ); @@ -1306,16 +1306,16 @@ static void CG_DrawLoadingString( rectDef_t *rect, float text_x, float text_y, v int pos, i; char buffer[ 1024 ]; char *end; - + if( !s[ 0 ] ) return; - + strcpy( buffer, s ); tw = CG_Text_Width( s, scale, 0 ); th = scale * 40.0f; pos = i = 0; - + while( pos < strlen( s ) ) { strcpy( buffer, &s[ pos ] ); @@ -1324,10 +1324,10 @@ static void CG_DrawLoadingString( rectDef_t *rect, float text_x, float text_y, v while( tw > rect->w ) { end = strrchr( buffer, ' ' ); - + if( end == NULL ) break; - + *end = '\0'; tw = CG_Text_Width( buffer, scale, 0 ); } @@ -1349,10 +1349,10 @@ static void CG_DrawLoadingString( rectDef_t *rect, float text_x, float text_y, v default: tx = 0.0f; } - + CG_Text_Paint( tx + text_x, rect->y + text_y + i * ( th + 3 ), scale, color, buffer, 0, 0, textStyle ); - + pos += strlen( buffer ) + 1; i++; } @@ -1362,7 +1362,7 @@ static void CG_DrawLevelName( rectDef_t *rect, float text_x, float text_y, vec4_t color, float scale, int align, int textStyle ) { const char *s; - + s = CG_ConfigString( CS_MESSAGE ); CG_DrawLoadingString( rect, text_x, text_y, color, scale, align, textStyle, s ); @@ -1372,7 +1372,7 @@ static void CG_DrawMOTD( rectDef_t *rect, float text_x, float text_y, vec4_t color, float scale, int align, int textStyle ) { const char *s; - + s = CG_ConfigString( CS_MOTD ); CG_DrawLoadingString( rect, text_x, text_y, color, scale, align, textStyle, s ); @@ -1385,7 +1385,7 @@ static void CG_DrawHostname( rectDef_t *rect, float text_x, float text_y, const char *info; info = CG_ConfigString( CS_SERVERINFO ); - + Q_strncpyz( buffer, Info_ValueForKey( info, "sv_hostname" ), 1024 ); Q_CleanStr( buffer ); @@ -1434,7 +1434,7 @@ float CG_GetValue( int ownerDraw ) BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, &value, NULL ); - + return value; } break; @@ -1445,7 +1445,7 @@ float CG_GetValue( int ownerDraw ) BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, NULL, &value ); - + return value; } break; @@ -1455,7 +1455,7 @@ float CG_GetValue( int ownerDraw ) default: break; } - + return -1; } @@ -1512,19 +1512,19 @@ static void CG_Text_Paint_Limit( float *maxX, float x, float y, float scale, float max = *maxX; float useScale; fontInfo_t *font = &cgDC.Assets.textFont; - + if( scale <= cg_smallFont.value ) font = &cgDC.Assets.smallFont; else if( scale > cg_bigFont.value ) font = &cgDC.Assets.bigFont; - + useScale = scale * font->glyphScale; trap_R_SetColor( color ); - len = strlen( text ); - + len = strlen( text ); + if( limit > 0 && len > limit ) len = limit; - + count = 0; while( s && *s && count < len ) @@ -1532,7 +1532,7 @@ static void CG_Text_Paint_Limit( float *maxX, float x, float y, float scale, glyph = &font->glyphs[ (int)*s ]; //TTimo: FIXME: getting nasty warnings without the cast, //hopefully this doesn't break the VM build - + if( Q_IsColorString( s ) ) { memcpy( newColor, g_color_table[ ColorIndex( *(s+1) ) ], sizeof( newColor ) ); @@ -1544,17 +1544,17 @@ static void CG_Text_Paint_Limit( float *maxX, float x, float y, float scale, else { float yadj = useScale * glyph->top; - + if( CG_Text_Width( s, useScale, 1 ) + x > max ) { *maxX = 0; break; } - - CG_Text_PaintChar( x, y - yadj, + + CG_Text_PaintChar( x, y - yadj, glyph->imageWidth, glyph->imageHeight, - useScale, + useScale, glyph->s, glyph->t, glyph->s2, @@ -1566,7 +1566,7 @@ static void CG_Text_Paint_Limit( float *maxX, float x, float y, float scale, s++; } } - + trap_R_SetColor( NULL ); } } @@ -1594,7 +1594,7 @@ static void CG_DrawTeamSpectators( rectDef_t *rect, float scale, vec4_t color, q if( cg.time > cg.spectatorTime ) { cg.spectatorTime = cg.time + 10; - + if( cg.spectatorPaintX <= rect->x + 2 ) { if( cg.spectatorOffset < cg.spectatorLen ) @@ -1611,36 +1611,36 @@ static void CG_DrawTeamSpectators( rectDef_t *rect, float scale, vec4_t color, q else { cg.spectatorOffset = 0; - + if( cg.spectatorPaintX2 >= 0 ) cg.spectatorPaintX = cg.spectatorPaintX2; else cg.spectatorPaintX = rect->x + rect->w - 2; - + cg.spectatorPaintX2 = -1; } } else { cg.spectatorPaintX--; - + if( cg.spectatorPaintX2 >= 0 ) cg.spectatorPaintX2--; } } maxX = rect->x + rect->w - 2; - + CG_Text_Paint_Limit( &maxX, cg.spectatorPaintX, rect->y + rect->h - 3, scale, color, - &cg.spectatorList[ cg.spectatorOffset ], 0, 0 ); - + &cg.spectatorList[ cg.spectatorOffset ], 0, 0 ); + if( cg.spectatorPaintX2 >= 0 ) { float maxX2 = rect->x + rect->w - 2; CG_Text_Paint_Limit( &maxX2, cg.spectatorPaintX2, rect->y + rect->h - 3, scale, - color, cg.spectatorList, 0, cg.spectatorOffset ); + color, cg.spectatorList, 0, cg.spectatorOffset ); } - + if( cg.spectatorOffset && maxX > 0 ) { // if we have an offset ( we are skipping the first part of the string ) and we fit the string @@ -1662,7 +1662,7 @@ static void CG_DrawStageReport( rectDef_t *rect, float text_x, float text_y, { char s[ MAX_TOKEN_CHARS ]; int tx, w, kills; - + if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR && !cg.intermissionStarted ) return; @@ -1677,7 +1677,7 @@ static void CG_DrawStageReport( rectDef_t *rect, float text_x, float text_y, else if( cg.snap->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { kills = cgs.alienNextStageThreshold - cgs.alienKills; - + if( cgs.alienNextStageThreshold < 0 ) Com_sprintf( s, MAX_TOKEN_CHARS, "Stage %d", cgs.alienStage + 1 ); else if( kills == 1 ) @@ -1690,7 +1690,7 @@ static void CG_DrawStageReport( rectDef_t *rect, float text_x, float text_y, else if( cg.snap->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { kills = cgs.humanNextStageThreshold - cgs.humanKills; - + if( cgs.humanNextStageThreshold < 0 ) Com_sprintf( s, MAX_TOKEN_CHARS, "Stage %d", cgs.humanStage + 1 ); else if( kills == 1 ) @@ -1700,9 +1700,9 @@ static void CG_DrawStageReport( rectDef_t *rect, float text_x, float text_y, Com_sprintf( s, MAX_TOKEN_CHARS, "Stage %d, %d kills for next stage", cgs.humanStage + 1, kills ); } - + w = CG_Text_Width( s, scale, 0 ); - + switch( align ) { case ITEM_ALIGN_LEFT: @@ -1747,7 +1747,7 @@ static void CG_DrawFPS( rectDef_t *rect, float text_x, float text_y, if( !cg_drawFPS.integer ) return; - + // don't use serverTime, because that will be drifting to // correct for internet lag changes, timescales, timedemos, etc t = trap_Milliseconds( ); @@ -1756,25 +1756,25 @@ static void CG_DrawFPS( rectDef_t *rect, float text_x, float text_y, previousTimes[ index % FPS_FRAMES ] = frameTime; index++; - + if( index > FPS_FRAMES ) { // average multiple frames together to smooth changes out a bit total = 0; - + for( i = 0 ; i < FPS_FRAMES ; i++ ) total += previousTimes[ i ]; - + if( !total ) total = 1; - + fps = 1000 * FPS_FRAMES / total; s = va( "%d", fps ); w = CG_Text_Width( "0", scale, 0 ); strLength = CG_DrawStrlen( s ); totalWidth = CG_Text_Width( FPS_STRING, scale, 0 ) + w * strLength; - + switch( align ) { case ITEM_ALIGN_LEFT: @@ -1792,7 +1792,7 @@ static void CG_DrawFPS( rectDef_t *rect, float text_x, float text_y, default: tx = 0.0f; } - + if( scalableText ) { for( i = 0; i < strLength; i++ ) @@ -1801,7 +1801,7 @@ static void CG_DrawFPS( rectDef_t *rect, float text_x, float text_y, c[ 0 ] = s[ i ]; c[ 1 ] = '\0'; - + CG_Text_Paint( text_x + tx + i * w, rect->y + text_y, scale, color, c, 0, 0, textStyle ); } } @@ -1811,7 +1811,7 @@ static void CG_DrawFPS( rectDef_t *rect, float text_x, float text_y, CG_DrawField( rect->x, rect->y, 3, rect->w / 3, rect->h, fps ); trap_R_SetColor( NULL ); } - + if( scalableText ) CG_Text_Paint( text_x + tx + i * w, rect->y + text_y, scale, color, FPS_STRING, 0, 0, textStyle ); } @@ -1896,7 +1896,7 @@ static void CG_DrawTimer( rectDef_t *rect, float text_x, float text_y, w = CG_Text_Width( "0", scale, 0 ); strLength = CG_DrawStrlen( s ); totalWidth = w * strLength; - + switch( align ) { case ITEM_ALIGN_LEFT: @@ -1921,7 +1921,7 @@ static void CG_DrawTimer( rectDef_t *rect, float text_x, float text_y, c[ 0 ] = s[ i ]; c[ 1 ] = '\0'; - + CG_Text_Paint( text_x + tx + i * w, rect->y + text_y, scale, color, c, 0, 0, textStyle ); } } @@ -1939,11 +1939,11 @@ static void CG_DrawSnapshot( rectDef_t *rect, float text_x, float text_y, if( !cg_drawSnapshot.integer ) return; - + s = va( "time:%d snap:%d cmd:%d", cg.snap->serverTime, cg.latestSnapshotNum, cgs.serverCommandSequence ); w = CG_Text_Width( s, scale, 0 ); - + switch( align ) { case ITEM_ALIGN_LEFT: @@ -2047,7 +2047,7 @@ static void CG_DrawDisconnect( void ) // draw the phone jack if we are completely past our buffers cmdNum = trap_GetCurrentCmdNumber( ) - CMD_BACKUP + 1; trap_GetUserCmd( cmdNum, &cmd ); - + // special check for map_restart if( cmd.serverTime <= cg.snap->ps.commandTime || cmd.serverTime > cg.time ) return; @@ -2099,11 +2099,11 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y, Vector4Copy( textColor, adjustedColor ); adjustedColor[ 3 ] = 0.25f; - + trap_R_SetColor( adjustedColor ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cgs.media.whiteShader ); trap_R_SetColor( NULL ); - + // // draw the graph // @@ -2128,7 +2128,7 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y, i = ( lagometer.frameCount - 1 - a ) & ( LAG_SAMPLES - 1 ); v = lagometer.frameSamples[ i ]; v *= vscale; - + if( v > 0 ) { if( color != 1 ) @@ -2136,10 +2136,10 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y, color = 1; trap_R_SetColor( g_color_table[ ColorIndex( COLOR_YELLOW ) ] ); } - + if( v > range ) v = range; - + trap_R_DrawStretchPic( ax + aw - a, mid - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); } else if( v < 0 ) @@ -2149,11 +2149,11 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y, color = 2; trap_R_SetColor( g_color_table[ ColorIndex( COLOR_BLUE ) ] ); } - + v = -v; if( v > range ) v = range; - + trap_R_DrawStretchPic( ax + aw - a, mid, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); } } @@ -2166,7 +2166,7 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y, { i = ( lagometer.snapshotCount - 1 - a ) & ( LAG_SAMPLES - 1 ); v = lagometer.snapshotSamples[ i ]; - + if( v > 0 ) { if( lagometer.snapshotFlags[ i ] & SNAPFLAG_RATE_DELAYED ) @@ -2182,16 +2182,16 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y, if( color != 3 ) { color = 3; - + trap_R_SetColor( g_color_table[ ColorIndex( COLOR_GREEN ) ] ); } } - + v = v * vscale; - + if( v > range ) v = range; - + trap_R_DrawStretchPic( ax + aw - a, ay + ah - v, 1, v, 0, 0, 0, 0, cgs.media.whiteShader ); } else if( v < 0 ) @@ -2201,7 +2201,7 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y, color = 4; // RED for dropped snapshots trap_R_SetColor( g_color_table[ ColorIndex( COLOR_RED ) ] ); } - + trap_R_DrawStretchPic( ax + aw - a, ay + ah - range, 1, range, 0, 0, 0, 0, cgs.media.whiteShader ); } } @@ -2224,7 +2224,7 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y, ping += previousPings[ i ]; ping /= PING_FRAMES; - + s = va( "%d", ping ); ax = rect->x + ( rect->w / 2.0f ) - ( CG_Text_Width( s, scale, 0 ) / 2.0f ) + text_x; ay = rect->y + ( rect->h / 2.0f ) + ( CG_Text_Height( s, scale, 0 ) / 2.0f ) + text_y; @@ -2260,7 +2260,7 @@ static void CG_DrawConsole( rectDef_t *rect, float text_x, float text_y, vec4_t h = rect->h; textItem.text = cg.consoleText; - + textItem.parent = &dummyParent; memcpy( textItem.window.foreColor, color, sizeof( vec4_t ) ); textItem.window.flags = 0; @@ -2283,7 +2283,7 @@ static void CG_DrawConsole( rectDef_t *rect, float text_x, float text_y, vec4_t textItem.window.rect.x = x; break; } - + textItem.window.rect.y = y; textItem.window.rect.w = w; textItem.window.rect.h = h; @@ -2318,14 +2318,14 @@ void CG_DrawWeaponIcon( rectDef_t *rect, vec4_t color ) BG_UnpackAmmoArray( cent->currentState.weapon, ps->ammo, ps->powerups, &ammo, &clips ); BG_FindAmmoForWeapon( cent->currentState.weapon, &maxAmmo, NULL ); - + // don't display if dead if( cg.predictedPlayerState.stats[ STAT_HEALTH ] <= 0 ) return; if( cent->currentState.weapon == 0 ) return; - + CG_RegisterWeapon( cent->currentState.weapon ); if( clips == 0 && !BG_FindInfinteAmmoForWeapon( cent->currentState.weapon ) ) @@ -2338,7 +2338,7 @@ void CG_DrawWeaponIcon( rectDef_t *rect, vec4_t color ) color[ 1 ] = color[ 2 ] = 0.0f; } } - + if( cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_ALIENS && CG_AtHighestClass( ) ) { if( cg.time - cg.lastEvolveAttempt <= NO_CREDITS_TIME ) @@ -2347,7 +2347,7 @@ void CG_DrawWeaponIcon( rectDef_t *rect, vec4_t color ) color[ 3 ] = 0.0f; } } - + trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, cg_weapons[ cent->currentState.weapon ].weaponIcon ); trap_R_SetColor( NULL ); @@ -2388,13 +2388,13 @@ static void CG_DrawCrosshair( void ) return; wi = &cg_weapons[ cg.snap->ps.weapon ]; - + w = h = wi->crossHairSize; x = cg_crosshairX.integer; y = cg_crosshairY.integer; CG_AdjustFrom640( &x, &y, &w, &h ); - + hShader = wi->crossHair; if( hShader != 0 ) @@ -2424,7 +2424,7 @@ static void CG_ScanForCrosshairEntity( void ) CG_Trace( &trace, start, vec3_origin, vec3_origin, end, cg.snap->ps.clientNum, CONTENTS_SOLID|CONTENTS_BODY ); - + if( trace.entityNum >= MAX_CLIENTS ) return; @@ -2434,14 +2434,14 @@ static void CG_ScanForCrosshairEntity( void ) return; team = cgs.clientinfo[ trace.entityNum ].team; - + if( cg.snap->ps.persistant[ PERS_TEAM ] != TEAM_SPECTATOR ) { //only display team names of those on the same team as this player if( team != cg.snap->ps.stats[ STAT_PTEAM ] ) return; } - + // update the fade timer cg.crosshairClientNum = trace.entityNum; cg.crosshairClientTime = cg.time; @@ -2461,10 +2461,10 @@ static void CG_DrawCrosshairNames( rectDef_t *rect, float scale, int textStyle ) if( !cg_drawCrosshair.integer ) return; - + if( !cg_drawCrosshairNames.integer ) return; - + if( cg.renderingThirdPerson ) return; @@ -2616,7 +2616,7 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x, case CG_STAGE_REPORT_TEXT: CG_DrawStageReport( &rect, text_x, text_y, color, scale, align, textStyle ); break; - + //loading screen case CG_LOAD_LEVELSHOT: CG_DrawLevelShot( &rect ); @@ -2651,7 +2651,7 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x, case CG_LOAD_HOSTNAME: CG_DrawHostname( &rect, text_x, text_y, color, scale, align, textStyle ); break; - + case CG_FPS: CG_DrawFPS( &rect, text_x, text_y, scale, color, align, textStyle, qtrue ); break; @@ -2673,23 +2673,23 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x, case CG_LAGOMETER: CG_DrawLagometer( &rect, text_x, text_y, scale, color ); break; - + case CG_CONSOLE: CG_DrawConsole( &rect, text_x, text_y, color, scale, align, textStyle ); break; - + default: break; } } -void CG_MouseEvent( int x, int y ) +void CG_MouseEvent( int x, int y ) { int n; if( ( cg.predictedPlayerState.pm_type == PM_NORMAL || cg.predictedPlayerState.pm_type == PM_SPECTATOR ) && - cg.showScores == qfalse ) + cg.showScores == qfalse ) { trap_Key_SetCatcher( 0 ); return; @@ -2755,7 +2755,7 @@ CG_EventHandling void CG_EventHandling( int type ) { cgs.eventHandling = type; - + if( type == CGAME_EVENT_NONE ) CG_HideTeamMenu( ); } @@ -2790,14 +2790,14 @@ void CG_KeyEvent( int key, qboolean down ) int CG_ClientNumFromName( const char *p ) { int i; - + for( i = 0; i < cgs.maxclients; i++ ) { if( cgs.clientinfo[ i ].infoValid && Q_stricmp( cgs.clientinfo[ i ].name, p ) == 0 ) return i; } - + return -1; } @@ -2824,7 +2824,7 @@ CG_DrawLighting static void CG_DrawLighting( void ) { centity_t *cent; - + cent = &cg_entities[ cg.snap->ps.clientNum ]; //fade to black if stamina is low @@ -2873,7 +2873,7 @@ void CG_CenterPrint( const char *str, int y, int charWidth ) { if( *s == '\n' ) cg.centerPrintLines++; - + s++; } } @@ -2913,10 +2913,10 @@ static void CG_DrawCenterString( void ) { if( !start[ l ] || start[ l ] == '\n' ) break; - + linebuffer[ l ] = start[ l ]; } - + linebuffer[ l ] = 0; w = CG_Text_Width( linebuffer, 0.5, 0 ); @@ -2927,10 +2927,10 @@ static void CG_DrawCenterString( void ) while( *start && ( *start != '\n' ) ) start++; - + if( !*start ) break; - + start++; } @@ -2967,10 +2967,10 @@ static void CG_DrawVote( void ) } sec = ( VOTE_TIME - ( cg.time - cgs.voteTime ) ) / 1000; - + if( sec < 0 ) sec = 0; - + s = va( "VOTE(%i): \"%s\" Yes:%i No:%i", sec, cgs.voteString, cgs.voteYes, cgs.voteNo ); CG_Text_Paint( 8, 340, 0.3f, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL ); } @@ -3004,13 +3004,13 @@ static void CG_DrawTeamVote( void ) } sec = ( VOTE_TIME - ( cg.time - cgs.teamVoteTime[ cs_offset ] ) ) / 1000; - + if( sec < 0 ) sec = 0; - + s = va( "TEAMVOTE(%i): \"%s\" Yes:%i No:%i", sec, cgs.teamVoteString[ cs_offset ], cgs.teamVoteYes[cs_offset], cgs.teamVoteNo[ cs_offset ] ); - + CG_Text_Paint( 8, 360, 0.3f, white, s, 0, 0, ITEM_TEXTSTYLE_NORMAL ); } @@ -3022,7 +3022,7 @@ static qboolean CG_DrawScoreboard( ) if( menuScoreboard ) menuScoreboard->window.flags &= ~WINDOW_FORCED; - + if( cg_paused.integer ) { cg.deferredPlayerLoading = 0; @@ -3042,7 +3042,7 @@ static qboolean CG_DrawScoreboard( ) cg.killerName[ 0 ] = 0; firstTime = qtrue; return qfalse; - } + } if( menuScoreboard == NULL ) @@ -3055,7 +3055,7 @@ static qboolean CG_DrawScoreboard( ) CG_SetScoreSelection( menuScoreboard ); firstTime = qfalse; } - + Menu_Paint( menuScoreboard, qtrue ); } @@ -3071,7 +3071,7 @@ static void CG_DrawIntermission( void ) { if( cg_drawStatus.integer ) Menu_Paint( Menus_FindByName( "default_hud" ), qtrue ); - + cg.scoreFadeTime = cg.time; cg.scoreBoardShowing = CG_DrawScoreboard( ); } @@ -3169,7 +3169,7 @@ static void CG_Draw2D( void ) menuDef_t *menu = NULL, *defaultMenu; color[ 0 ] = color[ 1 ] = color[ 2 ] = color[ 3 ] = 1.0f; - + // if we are taking a levelshot for the menu, don't draw anything if( cg.levelShot ) return; @@ -3186,9 +3186,9 @@ static void CG_Draw2D( void ) //TA: draw the lighting effects e.g. nvg CG_DrawLighting( ); - + defaultMenu = Menus_FindByName( "default_hud" ); - + if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) { w = CG_Text_Width( SPECTATOR_STRING, 0.7f, 0 ); @@ -3196,14 +3196,14 @@ static void CG_Draw2D( void ) } else menu = Menus_FindByName( BG_FindHudNameForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] ) ); - + if( !( cg.snap->ps.stats[ STAT_STATE ] & SS_INFESTING ) && !( cg.snap->ps.stats[ STAT_STATE ] & SS_HOVELING ) && menu && ( cg.snap->ps.stats[ STAT_HEALTH ] > 0 ) ) { if( cg_drawStatus.integer ) Menu_Paint( menu, qtrue ); - + CG_DrawCrosshair( ); } else if( cg_drawStatus.integer ) @@ -3216,7 +3216,7 @@ static void CG_Draw2D( void ) // don't draw center string if scoreboard is up cg.scoreBoardShowing = CG_DrawScoreboard( ); - + if( !cg.scoreBoardShowing ) CG_DrawCenterString( ); } @@ -3259,7 +3259,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) // offset vieworg appropriately if we're doing stereo separation VectorCopy( cg.refdef.vieworg, baseOrg ); - + if( separation != 0 ) VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[ 1 ], cg.refdef.vieworg ); diff --git a/src/cgame/cg_drawtools.c b/src/cgame/cg_drawtools.c index 05c06b65..b1f0d9ab 100644 --- a/src/cgame/cg_drawtools.c +++ b/src/cgame/cg_drawtools.c @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "cg_local.h" /* @@ -28,7 +28,7 @@ void CG_DrawPlane( vec3_t origin, vec3_t down, vec3_t right, qhandle_t shader ) { polyVert_t verts[ 4 ]; vec3_t temp; - + VectorCopy( origin, verts[ 0 ].xyz ); verts[ 0 ].st[ 0 ] = 0; verts[ 0 ].st[ 1 ] = 0; @@ -36,7 +36,7 @@ void CG_DrawPlane( vec3_t origin, vec3_t down, vec3_t right, qhandle_t shader ) verts[ 0 ].modulate[ 1 ] = 255; verts[ 0 ].modulate[ 2 ] = 255; verts[ 0 ].modulate[ 3 ] = 255; - + VectorAdd( origin, right, temp ); VectorCopy( temp, verts[ 1 ].xyz ); verts[ 1 ].st[ 0 ] = 1; @@ -45,7 +45,7 @@ void CG_DrawPlane( vec3_t origin, vec3_t down, vec3_t right, qhandle_t shader ) verts[ 1 ].modulate[ 1 ] = 255; verts[ 1 ].modulate[ 2 ] = 255; verts[ 1 ].modulate[ 3 ] = 255; - + VectorAdd( origin, right, temp ); VectorAdd( temp, down, temp ); VectorCopy( temp, verts[ 2 ].xyz ); @@ -55,7 +55,7 @@ void CG_DrawPlane( vec3_t origin, vec3_t down, vec3_t right, qhandle_t shader ) verts[ 2 ].modulate[ 1 ] = 255; verts[ 2 ].modulate[ 2 ] = 255; verts[ 2 ].modulate[ 3 ] = 255; - + VectorAdd( origin, down, temp ); VectorCopy( temp, verts[ 3 ].xyz ); verts[ 3 ].st[ 0 ] = 0; @@ -64,7 +64,7 @@ void CG_DrawPlane( vec3_t origin, vec3_t down, vec3_t right, qhandle_t shader ) verts[ 3 ].modulate[ 1 ] = 255; verts[ 3 ].modulate[ 2 ] = 255; verts[ 3 ].modulate[ 3 ] = 255; - + trap_R_AddPolyToScene( shader, 4, verts ); } @@ -179,7 +179,7 @@ void CG_DrawFadePic( float x, float y, float width, float height, vec4_t fcolor, float inverse; inverse = 100 - amount; - + CG_AdjustFrom640( &x, &y, &width, &height ); finalcolor[ 0 ] = ( ( inverse * fcolor[ 0 ] ) + ( amount * tcolor[ 0 ] ) ) / 100; diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index df269155..c4adf46b 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -79,7 +79,7 @@ void CG_DrawBoundingBox( vec3_t origin, vec3_t mins, vec3_t maxs ) pmp[ 0 ] = origin[ 0 ] + maxs[ 0 ]; pmp[ 1 ] = origin[ 1 ] + mins[ 1 ]; pmp[ 2 ] = origin[ 2 ] + maxs[ 2 ]; - + ppm[ 0 ] = origin[ 0 ] + maxs[ 0 ]; ppm[ 1 ] = origin[ 1 ] + maxs[ 1 ]; ppm[ 2 ] = origin[ 2 ] + mins[ 2 ]; @@ -215,12 +215,12 @@ static void CG_EntityEffects( centity_t *cent ) { if( cent->currentState.eType != ET_SPEAKER ) { - trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, + trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.gameSounds[ cent->currentState.loopSound ] ); } else { - trap_S_AddRealLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, + trap_S_AddRealLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.gameSounds[ cent->currentState.loopSound ] ); } } @@ -328,7 +328,7 @@ static void CG_LaunchMissile( centity_t *cent ) weapon = es->weapon; if( weapon > WP_NUM_WEAPONS ) weapon = WP_NONE; - + wi = &cg_weapons[ weapon ]; weaponMode = es->generic1; @@ -359,12 +359,12 @@ static void CG_Missile( centity_t *cent ) weapon = es->weapon; if( weapon > WP_NUM_WEAPONS ) weapon = WP_NONE; - + wi = &cg_weapons[ weapon ]; weaponMode = es->generic1; - + wim = &wi->wim[ weaponMode ]; - + // calculate the axis VectorCopy( es->angles, cent->lerpAngles ); @@ -417,11 +417,11 @@ static void CG_Missile( centity_t *cent ) RotateAroundDirection( ent.axis, cg.time / 4 ); else RotateAroundDirection( ent.axis, es->time ); - + if( wim->missileAnimates ) { int timeSinceStart = cg.time - es->time; - + if( wim->missileAnimLooping ) { ent.frame = wim->missileAnimStartFrame + @@ -432,13 +432,13 @@ static void CG_Missile( centity_t *cent ) { ent.frame = wim->missileAnimStartFrame + (int)( ( timeSinceStart / 1000.0f ) * wim->missileAnimFrameRate ); - + if( ent.frame > ( wim->missileAnimStartFrame + wim->missileAnimNumFrames ) ) ent.frame = wim->missileAnimStartFrame + wim->missileAnimNumFrames; } } } - + //only refresh if there is something to display if( wim->missileSprite || wim->missileModel ) trap_R_AddRefEntityToScene( &ent ); @@ -552,7 +552,7 @@ static void CG_Portal( centity_t *cent ) #define SETBOUNDS(v1,v2,r) ((v1)[0]=(-r/2),(v1)[1]=(-r/2),(v1)[2]=(-r/2),\ (v2)[0]=(r/2),(v2)[1]=(r/2),(v2)[2]=(r/2)) #define RADIUSSTEP 0.5f - + #define FLARE_OFF 0 #define FLARE_NOFADE 1 #define FLARE_TIMEFADE 2 @@ -576,12 +576,12 @@ static void CG_LightFlare( centity_t *cent ) int entityNum; es = ¢->currentState; - + if( cg.renderingThirdPerson ) entityNum = MAGIC_TRACE_HACK; else entityNum = cg.predictedPlayerState.clientNum; - + //don't draw light flares if( cg_lightFlare.integer == FLARE_OFF ) return; @@ -589,7 +589,7 @@ static void CG_LightFlare( centity_t *cent ) //flare is "off" if( es->eFlags & EF_NODRAW ) return; - + CG_Trace( &tr, cg.refdef.vieworg, NULL, NULL, es->angles2, entityNum, MASK_SHOT ); @@ -597,16 +597,16 @@ static void CG_LightFlare( centity_t *cent ) //it definately cannot be seen if( tr.fraction < 1.0f || tr.allsolid ) return; - + memset( &flare, 0, sizeof( flare ) ); - + flare.reType = RT_SPRITE; flare.customShader = cgs.gameShaders[ es->modelindex ]; flare.shaderRGBA[ 0 ] = 0xFF; flare.shaderRGBA[ 1 ] = 0xFF; flare.shaderRGBA[ 2 ] = 0xFF; flare.shaderRGBA[ 3 ] = 0xFF; - + //flares always drawn before the rest of the scene flare.renderfx |= RF_DEPTHHACK; @@ -620,7 +620,7 @@ static void CG_LightFlare( centity_t *cent ) //flare is too close to camera to be drawn if( len < es->generic1 ) return; - + //don't bother for flares behind the view plane if( DotProduct( delta, cg.refdef.viewaxis[ 0 ] ) < 0.0 ) return; @@ -635,31 +635,31 @@ static void CG_LightFlare( centity_t *cent ) srcRadius = srLocal = flare.radius / 2.0f; else srcRadius = srLocal = len / es->origin2[ 2 ]; - + maxAngle = es->origin2[ 1 ]; if( maxAngle > 0.0f ) { float radiusMod = 1.0f - ( 180.0f - RAD2DEG( acos( DotProduct( delta, forward ) ) ) ) / maxAngle; - + if( es->eFlags & EF_NODRAW ) flare.radius *= radiusMod; else if( radiusMod < 0.0f ) flare.radius = 0.0f; - } + } if( flare.radius < 0.0f ) flare.radius = 0.0f; - + VectorMA( flare.origin, -flare.radius, delta, end ); VectorMA( cg.refdef.vieworg, flare.radius, delta, start ); - + if( cg_lightFlare.integer == FLARE_REALFADE ) { //draw "correct" albeit inefficient flares srLocal = cent->lfs.lastSrcRadius; - + //flare radius is likely to be the same as last frame so start with it do { @@ -669,9 +669,9 @@ static void CG_LightFlare( centity_t *cent ) entityNum, MASK_SHOT ); } while( ( tr.fraction == 1.0f && !tr.startsolid ) && ( srLocal < srcRadius ) ); - + srLocal -= RADIUSSTEP; - + //shink the flare until there is a los do { @@ -681,7 +681,7 @@ static void CG_LightFlare( centity_t *cent ) srLocal -= RADIUSSTEP; } while( ( tr.fraction < 1.0f || tr.startsolid ) && ( srLocal > 0.0f ) ); - + ratio = srLocal / srcRadius; cent->lfs.lastSrcRadius = srLocal; @@ -710,7 +710,7 @@ static void CG_LightFlare( centity_t *cent ) if( cent->lfs.lastTime + es->time > cg.time ) ratio = (float)( cg.time - cent->lfs.lastTime ) / es->time; } - + //fade flare down if( !cent->lfs.status ) { @@ -743,13 +743,13 @@ static void CG_LightFlare( centity_t *cent ) cent->lfs.lastRatio = ratio; cent->lfs.lastRadius = flare.radius; - + if( ratio < 1.0f ) { flare.radius *= ratio; flare.shaderRGBA[ 3 ] = (byte)( (float)flare.shaderRGBA[ 3 ] * ratio ); } - + if( flare.radius <= 0.0f ) return; @@ -774,14 +774,14 @@ static void CG_Lev2ZapChain( centity_t *cent ) { source = &cg_entities[ es->powerups ]; target = &cg_entities[ es->time ]; - + if( es->powerups == cg.predictedPlayerState.clientNum ) VectorCopy( cg.predictedPlayerState.origin, start ); else VectorCopy( source->currentState.pos.trBase, start ); - + VectorCopy( target->currentState.pos.trBase, end ); - + CG_DynamicLightningBolt( cgs.media.lightningShader, start, end, 1+((cg.time%((i+2)*(i+3)))+i)%2, 7 + (float)(i%3)*5 + 6.0*random(), qtrue, 1.0, 0, i*i*3 ); @@ -791,10 +791,10 @@ static void CG_Lev2ZapChain( centity_t *cent ) { source = &cg_entities[ es->time ]; target = &cg_entities[ es->time2 ]; - + VectorCopy( source->currentState.pos.trBase, start ); VectorCopy( target->currentState.pos.trBase, end ); - + CG_DynamicLightningBolt( cgs.media.lightningShader, start, end, 1+((cg.time%((i+2)*(i+3)))+i)%2, 7 + (float)(i%3)*5 + 6.0*random(), qtrue, 1.0, 0, i*i*3 ); @@ -804,10 +804,10 @@ static void CG_Lev2ZapChain( centity_t *cent ) { source = &cg_entities[ es->time2 ]; target = &cg_entities[ es->constantLight ]; - + VectorCopy( source->currentState.pos.trBase, start ); VectorCopy( target->currentState.pos.trBase, end ); - + CG_DynamicLightningBolt( cgs.media.lightningShader, start, end, 1+((cg.time%((i+2)*(i+3)))+i)%2, 7 + (float)(i%3)*5 + 6.0*random(), qtrue, 1.0, 0, i*i*3 ); @@ -834,7 +834,7 @@ void CG_AdjustPositionForMover( const vec3_t in, int moverNum, int fromTime, int } cent = &cg_entities[ moverNum ]; - + if( cent->currentState.eType != ET_MOVER ) { VectorCopy( in, out ); @@ -948,10 +948,10 @@ CG_CEntityPVSEnter static void CG_CEntityPVSEnter( centity_t *cent ) { entityState_t *es = ¢->currentState; - + if( cg_debugPVS.integer ) CG_Printf( "Entity %d entered PVS\n", cent->currentState.number ); - + switch( es->eType ) { case ET_MISSILE: @@ -999,7 +999,7 @@ static void CG_AddCEntity( centity_t *cent ) // event-only entities will have been dealt with already if( cent->currentState.eType >= ET_EVENTS ) return; - + // calculate the current origin CG_CalcEntityLerpPositions( cent ); @@ -1011,64 +1011,64 @@ static void CG_AddCEntity( centity_t *cent ) default: CG_Error( "Bad entity type: %i\n", cent->currentState.eType ); break; - + case ET_INVISIBLE: case ET_PUSH_TRIGGER: case ET_TELEPORT_TRIGGER: break; - + case ET_GENERAL: CG_General( cent ); break; - + case ET_CORPSE: CG_Corpse( cent ); break; - + case ET_PLAYER: CG_Player( cent ); break; - + case ET_BUILDABLE: CG_Buildable( cent ); break; - + case ET_MISSILE: CG_Missile( cent ); break; - + case ET_MOVER: CG_Mover( cent ); break; - + case ET_BEAM: CG_Beam( cent ); break; - + case ET_PORTAL: CG_Portal( cent ); break; - + case ET_SPEAKER: CG_Speaker( cent ); break; - + case ET_PARTICLE_SYSTEM: CG_ParticleSystemEntity( cent ); break; - + case ET_ANIMMAPOBJ: CG_animMapObj( cent ); break; - + case ET_MODELDOOR: CG_ModelDoor( cent ); break; - + case ET_LIGHTFLARE: CG_LightFlare( cent ); break; - + case ET_LEV2_ZAP_CHAIN: CG_Lev2ZapChain( cent ); break; @@ -1093,7 +1093,7 @@ void CG_AddPacketEntities( void ) int delta; delta = ( cg.nextSnap->serverTime - cg.snap->serverTime ); - + if( delta == 0 ) cg.frameInterpolation = 0; else @@ -1138,7 +1138,7 @@ void CG_AddPacketEntities( void ) cent = &cg_entities[ cg.snap->entities[ num ].number ]; cent->valid = qtrue; } - + for( num = 0; num < MAX_GENTITIES; num++ ) { cent = &cg_entities[ num ]; @@ -1157,7 +1157,7 @@ void CG_AddPacketEntities( void ) cent = &cg_entities[ cg.snap->entities[ num ].number ]; CG_AddCEntity( cent ); } - + //make an attempt at drawing bounding boxes of selected entity types if( cg_drawBBOX.integer ) { @@ -1166,10 +1166,10 @@ void CG_AddPacketEntities( void ) float x, zd, zu; vec3_t mins, maxs; entityState_t *es; - + cent = &cg_entities[ cg.snap->entities[ num ].number ]; es = ¢->currentState; - + switch( es->eType ) { case ET_BUILDABLE: diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c index 64f23f52..fa46fe36 100644 --- a/src/cgame/cg_event.c +++ b/src/cgame/cg_event.c @@ -42,7 +42,7 @@ static void CG_Obituary( entityState_t *ent ) if( target < 0 || target >= MAX_CLIENTS ) CG_Error( "CG_Obituary: target out of range" ); - + ci = &cgs.clientinfo[ target ]; if( attacker < 0 || attacker >= MAX_CLIENTS ) @@ -54,7 +54,7 @@ static void CG_Obituary( entityState_t *ent ) attackerInfo = CG_ConfigString( CS_PLAYERS + attacker ); targetInfo = CG_ConfigString( CS_PLAYERS + target ); - + if( !targetInfo ) return; @@ -136,7 +136,7 @@ static void CG_Obituary( entityState_t *ent ) else message = "toasted himself"; break; - + case MOD_LCANNON_SPLASH: if( gender == GENDER_FEMALE ) message = "irradiated herself"; @@ -145,7 +145,7 @@ static void CG_Obituary( entityState_t *ent ) else message = "irradiated himself"; break; - + case MOD_GRENADE: if( gender == GENDER_FEMALE ) message = "blew herself up"; @@ -154,7 +154,7 @@ static void CG_Obituary( entityState_t *ent ) else message = "blew himself up"; break; - + default: if( gender == GENDER_FEMALE ) message = "killed herself"; @@ -235,7 +235,7 @@ static void CG_Obituary( entityState_t *ent ) message = "couldn't escape"; message2 = "'s grenade"; break; - + case MOD_ABUILDER_CLAW: message = "should leave"; message2 = "'s buildings alone"; @@ -291,7 +291,7 @@ static void CG_Obituary( entityState_t *ent ) BG_FindHumanNameForClassNum( PCL_ALIEN_LEVEL4 ) ); message2 = className; break; - + case MOD_POISON: message = "should have used antitox against"; message2 = "'s poison"; @@ -302,8 +302,8 @@ static void CG_Obituary( entityState_t *ent ) BG_FindHumanNameForClassNum( PCL_ALIEN_LEVEL1 ) ); message2 = className; break; - - + + case MOD_TELEFRAG: message = "tried to invade"; message2 = "'s personal space"; @@ -398,7 +398,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) clientNum = es->clientNum; if( clientNum < 0 || clientNum >= MAX_CLIENTS ) clientNum = 0; - + ci = &cgs.clientinfo[ clientNum ]; switch( event ) @@ -418,7 +418,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) cgs.media.footsteps[ ci->footsteps ][ rand( ) & 3 ] ); } break; - + case EV_FOOTSTEP_METAL: DEBUGNAME( "EV_FOOTSTEP_METAL" ); if( cg_footsteps.integer && ci->footsteps != FOOTSTEP_NONE ) @@ -431,7 +431,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) cgs.media.footsteps[ FOOTSTEP_METAL ][ rand( ) & 3 ] ); } break; - + case EV_FOOTSTEP_SQUELCH: DEBUGNAME( "EV_FOOTSTEP_SQUELCH" ); if( cg_footsteps.integer && ci->footsteps != FOOTSTEP_NONE ) @@ -440,7 +440,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) cgs.media.footsteps[ FOOTSTEP_FLESH ][ rand( ) & 3 ] ); } break; - + case EV_FOOTSPLASH: DEBUGNAME( "EV_FOOTSPLASH" ); if( cg_footsteps.integer && ci->footsteps != FOOTSTEP_NONE ) @@ -449,7 +449,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) cgs.media.footsteps[ FOOTSTEP_SPLASH ][ rand( ) & 3 ] ); } break; - + case EV_FOOTWADE: DEBUGNAME( "EV_FOOTWADE" ); if( cg_footsteps.integer && ci->footsteps != FOOTSTEP_NONE ) @@ -458,7 +458,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) cgs.media.footsteps[ FOOTSTEP_SPLASH ][ rand( ) & 3 ] ); } break; - + case EV_SWIM: DEBUGNAME( "EV_SWIM" ); if( cg_footsteps.integer && ci->footsteps != FOOTSTEP_NONE ) @@ -472,7 +472,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) case EV_FALL_SHORT: DEBUGNAME( "EV_FALL_SHORT" ); trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.landSound ); - + if( clientNum == cg.predictedPlayerState.clientNum ) { // smooth landing z changes @@ -480,12 +480,12 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) cg.landTime = cg.time; } break; - + case EV_FALL_MEDIUM: DEBUGNAME( "EV_FALL_MEDIUM" ); // use normal pain sound trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*pain100_1.wav" ) ); - + if( clientNum == cg.predictedPlayerState.clientNum ) { // smooth landing z changes @@ -493,12 +493,12 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) cg.landTime = cg.time; } break; - + case EV_FALL_FAR: DEBUGNAME( "EV_FALL_FAR" ); trap_S_StartSound (NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, "*fall1.wav" ) ); cent->pe.painTime = cg.time; // don't play a pain sound right after this - + if( clientNum == cg.predictedPlayerState.clientNum ) { // smooth landing z changes @@ -515,28 +515,28 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) case EV_STEP_4: case EV_STEP_8: case EV_STEP_12: - case EV_STEP_16: // smooth out step up transitions + case EV_STEP_16: // smooth out step up transitions case EV_STEPDN_4: case EV_STEPDN_8: case EV_STEPDN_12: - case EV_STEPDN_16: // smooth out step down transitions + case EV_STEPDN_16: // smooth out step down transitions DEBUGNAME( "EV_STEP" ); { - float oldStep; - int delta; - int step; + float oldStep; + int delta; + int step; if( clientNum != cg.predictedPlayerState.clientNum ) break; - + // if we are interpolating, we don't need to smooth steps if( cg.demoPlayback || ( cg.snap->ps.pm_flags & PMF_FOLLOW ) || cg_nopredict.integer || cg_synchronousClients.integer ) break; - + // check for stepping up before a previous step is completed delta = cg.time - cg.stepTime; - + if( delta < steptime ) oldStep = cg.stepChange * ( steptime - delta ) / steptime; else @@ -553,7 +553,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) step = 4 * ( event - EV_STEP_4 + 1 ); cg.stepChange = oldStep + step; } - + if( cg.stepChange > MAX_STEP_CHANGE ) cg.stepChange = MAX_STEP_CHANGE; else if( cg.stepChange < -MAX_STEP_CHANGE ) @@ -563,49 +563,27 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) break; } - case EV_JUMP_PAD: - DEBUGNAME( "EV_JUMP_PAD" ); - // CG_Printf( "EV_JUMP_PAD w/effect #%i\n", es->eventParm ); - { - localEntity_t *smoke; - vec3_t up = { 0, 0, 1 }; - - - smoke = CG_SmokePuff( cent->lerpOrigin, up, - 32, - 1, 1, 1, 0.33f, - 1000, - cg.time, 0, - LEF_PUFF_DONT_SCALE, - cgs.media.smokePuffShader ); - } - - // boing sound at origin, jump sound on player - trap_S_StartSound( cent->lerpOrigin, -1, CHAN_VOICE, cgs.media.jumpPadSound ); - trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*jump1.wav" ) ); - break; - case EV_JUMP: DEBUGNAME( "EV_JUMP" ); trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*jump1.wav" ) ); - + if( BG_ClassHasAbility( cg.predictedPlayerState.stats[ STAT_PCLASS ], SCA_WALLJUMPER ) ) - { + { vec3_t surfNormal, refNormal = { 0.0f, 0.0f, 1.0f }; vec3_t rotAxis; if( clientNum != cg.predictedPlayerState.clientNum ) break; - + //set surfNormal VectorCopy( cg.predictedPlayerState.grapplePoint, surfNormal ); - + //if we are moving from one surface to another smooth the transition if( !VectorCompare( surfNormal, cg.lastNormal ) && surfNormal[ 2 ] != 1.0f ) { CrossProduct( refNormal, surfNormal, rotAxis ); VectorNormalize( rotAxis ); - + //add the op CG_addSmoothOp( rotAxis, 15.0f, 1.0f ); } @@ -613,45 +591,45 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) //copy the current normal to the lastNormal VectorCopy( surfNormal, cg.lastNormal ); } - + break; - + case EV_LEV1_GRAB: DEBUGNAME( "EV_LEV1_GRAB" ); trap_S_StartSound( NULL, es->number, CHAN_VOICE, cgs.media.alienL1Grab ); break; - + case EV_LEV4_CHARGE_PREPARE: DEBUGNAME( "EV_LEV4_CHARGE_PREPARE" ); trap_S_StartSound( NULL, es->number, CHAN_VOICE, cgs.media.alienL4ChargePrepare ); break; - + case EV_LEV4_CHARGE_START: DEBUGNAME( "EV_LEV4_CHARGE_START" ); //FIXME: stop cgs.media.alienL4ChargePrepare playing here trap_S_StartSound( NULL, es->number, CHAN_VOICE, cgs.media.alienL4ChargeStart ); break; - + case EV_TAUNT: DEBUGNAME( "EV_TAUNT" ); trap_S_StartSound( NULL, es->number, CHAN_VOICE, CG_CustomSound( es->number, "*taunt.wav" ) ); break; - + case EV_WATER_TOUCH: DEBUGNAME( "EV_WATER_TOUCH" ); trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.watrInSound ); break; - + case EV_WATER_LEAVE: DEBUGNAME( "EV_WATER_LEAVE" ); trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.watrOutSound ); break; - + case EV_WATER_UNDER: DEBUGNAME( "EV_WATER_UNDER" ); trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.watrUnSound ); break; - + case EV_WATER_CLEAR: DEBUGNAME( "EV_WATER_CLEAR" ); trap_S_StartSound( NULL, es->number, CHAN_AUTO, CG_CustomSound( es->number, "*gasp.wav" ) ); @@ -662,26 +640,25 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) // case EV_NOAMMO: DEBUGNAME( "EV_NOAMMO" ); - // trap_S_StartSound (NULL, es->number, CHAN_AUTO, cgs.media.noAmmoSound ); { } break; - + case EV_CHANGE_WEAPON: DEBUGNAME( "EV_CHANGE_WEAPON" ); trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.selectSound ); break; - + case EV_FIRE_WEAPON: DEBUGNAME( "EV_FIRE_WEAPON" ); CG_FireWeapon( cent, WPM_PRIMARY ); break; - + case EV_FIRE_WEAPON2: DEBUGNAME( "EV_FIRE_WEAPON2" ); CG_FireWeapon( cent, WPM_SECONDARY ); break; - + case EV_FIRE_WEAPON3: DEBUGNAME( "EV_FIRE_WEAPON3" ); CG_FireWeapon( cent, WPM_TERTIARY ); @@ -708,7 +685,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) DEBUGNAME( "EV_BUILD_CONSTRUCT" ); //do something useful here break; - + case EV_BUILD_DESTROY: DEBUGNAME( "EV_BUILD_DESTROY" ); //do something useful here @@ -836,7 +813,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) trap_S_StopLoopingSound( es->number ); es->loopSound = 0; break; - + case EV_DEBUG_LINE: DEBUGNAME( "EV_DEBUG_LINE" ); CG_Beam( cent ); @@ -906,7 +883,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) CG_SetParticleSystemCent( ps, cent ); CG_AttachParticleSystemToCent( ps ); } - + if( es->number == cg.clientNum ) cg.spawnTime = cg.time; break; @@ -920,7 +897,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) cg.lastEvolveAttempt = cg.time; } break; - + case EV_ALIEN_ACIDTUBE: DEBUGNAME( "EV_ALIEN_ACIDTUBE" ); { @@ -962,24 +939,31 @@ void CG_CheckEvents( centity_t *cent ) // check for event-only entities if( cent->currentState.eType > ET_EVENTS ) { + entity_event_t event = cent->currentState.eType - ET_EVENTS; + if( cent->previousEvent ) return; // already fired - + cent->previousEvent = 1; cent->currentState.event = cent->currentState.eType - ET_EVENTS; - } - else - { - // check for events riding with another entity - if( cent->currentState.event == cent->previousEvent ) - return; + + // Move the pointer to the entity that the + // event was originally attached to + if( cent->currentState.eFlags & EF_PLAYER_EVENT ) + cent = &cg_entities[ cent->currentState.otherEntityNum ]; - cent->previousEvent = cent->currentState.event; - if( ( cent->currentState.event & ~EV_EVENT_BITS ) == 0 ) - return; + cent->currentState.event = event; } + // check for events riding with another entity + if( cent->currentState.event == cent->previousEvent ) + return; + + cent->previousEvent = cent->currentState.event; + if( ( cent->currentState.event & ~EV_EVENT_BITS ) == 0 ) + return; + // calculate the position at exactly the frame time BG_EvaluateTrajectory( ¢->currentState.pos, cg.snap->serverTime, cent->lerpOrigin ); CG_SetEntitySoundPosition( cent ); diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 7af0525b..d6b07714 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -165,18 +165,18 @@ typedef enum typedef struct pMoveValues_u { pDirType_t dirType; - + //PMD_LINEAR - vec3_t dir; + vec3_t dir; float dirRandAngle; - + //PMD_POINT vec3_t point; float pointRandAngle; - + float mag; float magRandFrac; - + float parentVelFrac; float parentVelFracRandFrac; } pMoveValues_t; @@ -185,10 +185,10 @@ typedef struct pLerpValues_s { int delay; float delayRandFrac; - + float initial; float initialRandFrac; - + float final; float finalRandFrac; @@ -201,10 +201,10 @@ typedef struct baseParticle_s vec3_t displacement; float randDisplacement; float normalDisplacement; - + pMoveType_t velMoveType; pMoveValues_t velMoveValues; - + pMoveType_t accMoveType; pMoveValues_t accMoveValues; @@ -224,7 +224,7 @@ typedef struct baseParticle_s char onDeathSystemName[ MAX_QPATH ]; qhandle_t onDeathSystemHandle; - + //particle invariant stuff char shaderNames[ MAX_QPATH ][ MAX_SHADER_FRAMES ]; qhandle_t shaders[ MAX_SHADER_FRAMES ]; @@ -242,7 +242,7 @@ typedef struct baseParticleEjector_s { baseParticle_t *particles[ MAX_PARTICLES_PER_EJECTOR ]; int numParticles; - + pLerpValues_t eject; //zero period indicates creation of all particles at once int totalParticles; //can be infinite @@ -288,13 +288,13 @@ typedef struct psAttachment_s //PMT_STATIC vec3_t origin; - + //PMT_TAG refEntity_t re; //FIXME: should be pointers? refEntity_t parent; // qhandle_t model; char tagName[ MAX_STRING_CHARS ]; - + //PMT_CENT_ANGLES int centNum; @@ -306,14 +306,14 @@ typedef struct psAttachment_s typedef struct particleSystem_s { baseParticleSystem_t *class; - + psAttachmentType_t attachType; psAttachment_t attachment; qboolean attached; //is the particle system attached to anything qboolean valid; qboolean lazyRemove; //mark this system for later removal - + } particleSystem_t; @@ -326,9 +326,9 @@ typedef struct particleEjector_s int count; int totalParticles; - + int nextEjectionTime; - + qboolean valid; } particleEjector_t; @@ -338,13 +338,13 @@ typedef struct particle_s { baseParticle_t *class; particleEjector_t *parent; - + int birthTime; int lifeTime; - + vec3_t origin; vec3_t velocity; - + pMoveType_t accMoveType; pMoveValues_t accMoveValues; @@ -355,7 +355,7 @@ typedef struct particle_s pLerpValues_t radius; pLerpValues_t alpha; pLerpValues_t rotation; - + qboolean valid; int sortKey; @@ -402,7 +402,7 @@ typedef struct { float time; float timeMod; - + vec3_t rotAxis; float rotAngle; } smooth_t; @@ -494,7 +494,7 @@ typedef struct centity_s particleSystem_t *entityPS; qboolean entityPSMissing; - + qboolean valid; qboolean oldValid; } centity_t; @@ -651,12 +651,12 @@ typedef struct char headSkinName[ MAX_QPATH ]; char redTeam[ MAX_TEAMNAME ]; char blueTeam[ MAX_TEAMNAME ]; - + qboolean newAnims; // true if using the new mission pack animations qboolean fixedlegs; // true if legs yaw is always the same as torso yaw qboolean fixedtorso; // true if torso never changes yaw qboolean nonsegmented; // true if model is Q2 style nonsegmented - + vec3_t headOffset; // move head in icon views footstep_t footsteps; gender_t gender; // from model @@ -750,7 +750,7 @@ typedef struct weaponInfo_s sfxHandle_t readySound; qboolean disableIn3rdPerson; - + weaponInfoMode_t wim[ WPM_NUM_WEAPONMODES ]; } weaponInfo_t; @@ -766,7 +766,7 @@ typedef struct { qboolean looped; qboolean enabled; - + sfxHandle_t sound; } sound_t; @@ -790,13 +790,13 @@ typedef struct vec3_t alienBuildablePos[ MAX_GENTITIES ]; int alienBuildableTimes[ MAX_GENTITIES ]; int numAlienBuildables; - + vec3_t humanBuildablePos[ MAX_GENTITIES ]; int numHumanBuildables; - + vec3_t alienClientPos[ MAX_CLIENTS ]; int numAlienClients; - + vec3_t humanClientPos[ MAX_CLIENTS ]; int numHumanClients; @@ -827,7 +827,7 @@ typedef struct qboolean demoPlayback; qboolean levelShot; // taking a level menu screenshot - int deferredPlayerLoading; + int deferredPlayerLoading; qboolean loading; // don't defer players at initial startup qboolean intermissionStarted; // don't play voice rewards, because game will end shortly @@ -962,7 +962,7 @@ typedef struct int voiceChatTime; int voiceChatBufferIn; int voiceChatBufferOut; - + // warmup countdown int warmup; int warmupCount; @@ -1015,9 +1015,9 @@ typedef struct int weapon1Time; //TA: time when BUTTON_ATTACK went t->f f->t int weapon2Time; //TA: time when BUTTON_ATTACK2 went t->f f->t int weapon3Time; //TA: time when BUTTON_USE_HOLDABLE went t->f f->t - qboolean weapon1Firing; - qboolean weapon2Firing; - qboolean weapon3Firing; + qboolean weapon1Firing; + qboolean weapon2Firing; + qboolean weapon3Firing; int poisonedTime; @@ -1040,7 +1040,7 @@ typedef struct consoleLine_t consoleLines[ MAX_CONSOLE_LINES ]; int numConsoleLines; qboolean consoleValid; - + particleSystem_t *poisonCloudPS; } cg_t; @@ -1085,7 +1085,7 @@ typedef struct qhandle_t gibSpark1; qhandle_t gibSpark2; - + qhandle_t smoke2; qhandle_t machinegunBrassModel; @@ -1120,7 +1120,7 @@ typedef struct qhandle_t flameExplShader; qhandle_t creepShader; - + qhandle_t scannerShader; qhandle_t scannerBlipShader; qhandle_t scannerLineShader; @@ -1160,8 +1160,6 @@ typedef struct // sounds sfxHandle_t tracerSound; sfxHandle_t selectSound; - sfxHandle_t useNothingSound; - sfxHandle_t wearOffSound; sfxHandle_t footsteps[ FOOTSTEP_TOTAL ][ 4 ]; sfxHandle_t gibSound; sfxHandle_t gibBounce1Sound; @@ -1170,12 +1168,10 @@ typedef struct sfxHandle_t metalGibBounceSound; sfxHandle_t teleInSound; sfxHandle_t teleOutSound; - sfxHandle_t noAmmoSound; sfxHandle_t respawnSound; sfxHandle_t talkSound; sfxHandle_t landSound; sfxHandle_t fallSound; - sfxHandle_t jumpPadSound; sfxHandle_t hgrenb1aSound; sfxHandle_t hgrenb2aSound; @@ -1191,20 +1187,20 @@ typedef struct sfxHandle_t jetpackDescendSound; sfxHandle_t jetpackIdleSound; sfxHandle_t jetpackAscendSound; - + qhandle_t jetPackDescendPS; qhandle_t jetPackHoverPS; qhandle_t jetPackAscendPS; - + sfxHandle_t medkitUseSound; - + sfxHandle_t alienStageTransition; sfxHandle_t humanStageTransition; - + sfxHandle_t alienOvermindAttack; sfxHandle_t alienOvermindDying; sfxHandle_t alienOvermindSpawns; - + sfxHandle_t alienBuildableExplosion; sfxHandle_t alienBuildableDamage; sfxHandle_t alienBuildablePrebuild; @@ -1215,7 +1211,7 @@ typedef struct sfxHandle_t alienL1Grab; sfxHandle_t alienL4ChargePrepare; sfxHandle_t alienL4ChargeStart; - + qhandle_t cursor; qhandle_t selectCursor; qhandle_t sizeCursor; @@ -1227,13 +1223,13 @@ typedef struct qhandle_t larmourHeadSkin; qhandle_t larmourLegsSkin; qhandle_t larmourTorsoSkin; - + qhandle_t jetpackModel; qhandle_t jetpackFlashModel; qhandle_t battpackModel; - + sfxHandle_t repeaterUseSound; - + sfxHandle_t buildableRepairSound; sfxHandle_t buildableRepairedSound; @@ -1242,7 +1238,7 @@ typedef struct qhandle_t alienAcidTubePS; sfxHandle_t alienEvolveSound; - + qhandle_t humanBuildableDamagedPS; qhandle_t humanBuildableDestroyedPS; qhandle_t alienBuildableDamagedPS; @@ -1309,7 +1305,7 @@ typedef struct int humanKills; int alienNextStageThreshold; int humanNextStageThreshold; - + int numAlienSpawns; int numHumanSpawns; @@ -1320,13 +1316,13 @@ typedef struct qhandle_t gameShaders[ MAX_SHADERS ]; qhandle_t gameParticleSystems[ MAX_GAME_PARTICLE_SYSTEMS ]; sfxHandle_t gameSounds[ MAX_SOUNDS ]; - + int numInlineModels; qhandle_t inlineDrawModel[ MAX_MODELS ]; vec3_t inlineModelMidpoints[ MAX_MODELS ]; clientInfo_t clientinfo[ MAX_CLIENTS ]; - + //TA: corpse info clientInfo_t corpseinfo[ MAX_CLIENTS ]; @@ -1612,9 +1608,9 @@ void CG_ModelDoor( centity_t *cent ); void CG_BuildSolidList( void ); int CG_PointContents( const vec3_t point, int passEntityNum ); -void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, +void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int skipNumber, int mask ); -void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, +void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int skipNumber, int mask ); void CG_PredictPlayerState( void ); @@ -1735,7 +1731,7 @@ int CG_AddTrailJunc( int headJuncIndex, qhandle_t shader, int spawnTim int CG_AddSparkJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife, float alphaStart, float alphaEnd, float startWidth, float endWidth ); int CG_AddSmokeJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife, - float alpha, float startWidth, float endWidth ); + float alpha, float startWidth, float endWidth ); int CG_AddFireJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailLife, float alpha, float startWidth, float endWidth ); void CG_AddTrails( void ); @@ -1788,7 +1784,7 @@ 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 ); void CG_SetParticleSystemTag( particleSystem_t *ps, refEntity_t parent, qhandle_t model, char *tagName ); @@ -1805,10 +1801,10 @@ void CG_ParticleSystemEntity( centity_t *cent ); // // cg_ptr.c -// +// int CG_ReadPTRCode( void ); void CG_WritePTRCode( int code ); - + // //=============================================== @@ -1937,7 +1933,7 @@ void trap_R_SetColor( const float *rgba ); // NULL = 1,1,1,1 void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ); -int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, +int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ); void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ); diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index fd890426..be99e312 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "cg_local.h" #include "../ui/ui_shared.h" @@ -43,43 +43,43 @@ int vmMain( int command, int arg0, int arg1, int arg2, int arg3, case CG_INIT: CG_Init( arg0, arg1, arg2 ); return 0; - + case CG_SHUTDOWN: CG_Shutdown( ); return 0; - + case CG_CONSOLE_COMMAND: return CG_ConsoleCommand( ); - + case CG_DRAW_ACTIVE_FRAME: CG_DrawActiveFrame( arg0, arg1, arg2 ); return 0; - + case CG_CROSSHAIR_PLAYER: return CG_CrosshairPlayer( ); - + case CG_LAST_ATTACKER: return CG_LastAttacker( ); - + case CG_KEY_EVENT: CG_KeyEvent( arg0, arg1 ); return 0; - + case CG_MOUSE_EVENT: cgDC.cursorx = cgs.cursorX; cgDC.cursory = cgs.cursorY; CG_MouseEvent( arg0, arg1 ); return 0; - + case CG_EVENT_HANDLING: CG_EventHandling( arg0 ); return 0; - + default: CG_Error( "vmMain: unknown command %i", command ); break; } - + return -1; } @@ -308,7 +308,7 @@ static cvarTable_t cvarTable[ ] = { &cg_disableWarningDialogs, "cg_disableWarningDialogs", "0", CVAR_ARCHIVE }, { &cg_disableScannerPlane, "cg_disableScannerPlane", "0", CVAR_ARCHIVE }, { &cg_hudFiles, "cg_hudFiles", "ui/hud.txt", CVAR_ARCHIVE}, - + { &ui_currentClass, "ui_currentClass", "0", 0 }, { &ui_carriage, "ui_carriage", "", 0 }, { &ui_stages, "ui_stages", "0 0", 0 }, @@ -319,7 +319,7 @@ static cvarTable_t cvarTable[ ] = { &ui_alienTeamVoteActive, "ui_alienTeamVoteActive", "0", 0 }, { &cg_debugRandom, "cg_debugRandom", "0", 0 }, - + // the following variables are created in other parts of the system, // but we also reference them here @@ -370,7 +370,7 @@ void CG_RegisterCvars( void ) //repress standard Q3 console trap_Cvar_Set( "con_notifytime", "-2" ); - + // see if we are also running the server on this machine trap_Cvar_VariableStringBuffer( "sv_running", var, sizeof( var ) ); cgs.localServer = atoi( var ); @@ -383,7 +383,7 @@ void CG_RegisterCvars( void ) } -/* +/* =================== CG_ForceModelChange =================== @@ -397,7 +397,7 @@ static void CG_ForceModelChange( void ) const char *clientInfo; clientInfo = CG_ConfigString( CS_PLAYERS + i ); - + if( !clientInfo[ 0 ] ) continue; @@ -456,11 +456,11 @@ void CG_RemoveConsoleLine( void ) offset = cg.consoleLines[ 0 ].length; totalLength = strlen( cg.consoleText ) - offset; - + //slide up consoleText for( i = 0; i <= totalLength; i++ ) cg.consoleText[ i ] = cg.consoleText[ i + offset ]; - + //pop up the first consoleLine for( i = 0; i < cg.numConsoleLines; i++ ) cg.consoleLines[ i ] = cg.consoleLines[ i + 1 ]; @@ -481,7 +481,7 @@ void CG_TAUIConsole( const char *text ) cg.consoleLines[ cg.numConsoleLines ].length = strlen( text ); cg.numConsoleLines++; } - + } void QDECL CG_Printf( const char *msg, ... ) @@ -544,7 +544,7 @@ void QDECL Com_Printf( const char *msg, ... ) { cg.consoleLines[ cg.numConsoleLines ].length = strlen( text ); cg.numConsoleLines++; } - + CG_Printf ("%s", text); } @@ -579,7 +579,7 @@ Test if a specific file exists or not qboolean CG_FileExists( char *filename ) { fileHandle_t f; - + if( trap_FS_FOpenFile( filename, &f, FS_READ ) > 0 ) { //file exists so close it @@ -610,15 +610,13 @@ static void CG_RegisterSounds( void ) cgs.media.alienOvermindAttack = trap_S_RegisterSound( "sound/announcements/overmindattack.wav", qtrue ); cgs.media.alienOvermindDying = trap_S_RegisterSound( "sound/announcements/overminddying.wav", qtrue ); cgs.media.alienOvermindSpawns = trap_S_RegisterSound( "sound/announcements/overmindspawns.wav", qtrue ); - + cgs.media.alienL1Grab = trap_S_RegisterSound( "sound/player/level1/grab.wav", qtrue ); cgs.media.alienL4ChargePrepare = trap_S_RegisterSound( "sound/player/level4/charge_prepare.wav", qtrue ); cgs.media.alienL4ChargeStart = trap_S_RegisterSound( "sound/player/level4/charge_start.wav", qtrue ); - + cgs.media.tracerSound = trap_S_RegisterSound( "sound/weapons/machinegun/buletby1.wav", qfalse ); cgs.media.selectSound = trap_S_RegisterSound( "sound/weapons/change.wav", qfalse ); - cgs.media.wearOffSound = trap_S_RegisterSound( "sound/items/wearoff.wav", qfalse ); - cgs.media.useNothingSound = trap_S_RegisterSound( "sound/items/use_nothing.wav", qfalse ); cgs.media.gibSound = trap_S_RegisterSound( "sound/player/gibsplt1.wav", qfalse ); cgs.media.gibBounce1Sound = trap_S_RegisterSound( "sound/player/gibimp1.wav", qfalse ); cgs.media.gibBounce2Sound = trap_S_RegisterSound( "sound/player/gibimp2.wav", qfalse ); @@ -628,8 +626,6 @@ static void CG_RegisterSounds( void ) cgs.media.teleOutSound = trap_S_RegisterSound( "sound/world/teleout.wav", qfalse ); cgs.media.respawnSound = trap_S_RegisterSound( "sound/items/respawn1.wav", qfalse ); - cgs.media.noAmmoSound = trap_S_RegisterSound( "sound/weapons/noammo.wav", qfalse ); - cgs.media.talkSound = trap_S_RegisterSound( "sound/player/talk.wav", qfalse ); cgs.media.landSound = trap_S_RegisterSound( "sound/player/land1.wav", qfalse ); @@ -637,8 +633,6 @@ static void CG_RegisterSounds( void ) cgs.media.watrOutSound = trap_S_RegisterSound( "sound/player/watr_out.wav", qfalse ); cgs.media.watrUnSound = trap_S_RegisterSound( "sound/player/watr_un.wav", qfalse ); - cgs.media.jumpPadSound = trap_S_RegisterSound( "sound/world/jumppad.wav", qfalse ); - for( i = 0; i < 4; i++ ) { Com_sprintf( name, sizeof( name ), "sound/player/footsteps/step%i.wav", i + 1 ); @@ -666,10 +660,10 @@ static void CG_RegisterSounds( void ) for( i = 1 ; i < MAX_SOUNDS ; i++ ) { soundName = CG_ConfigString( CS_SOUNDS + i ); - + if( !soundName[ 0 ] ) break; - + if( soundName[ 0 ] == '*' ) continue; // custom sound @@ -680,15 +674,15 @@ static void CG_RegisterSounds( void ) cgs.media.jetpackDescendSound = trap_S_RegisterSound( "sound/upgrades/jetpack/low.wav", qfalse ); cgs.media.jetpackIdleSound = trap_S_RegisterSound( "sound/upgrades/jetpack/idle.wav", qfalse ); cgs.media.jetpackAscendSound = trap_S_RegisterSound( "sound/upgrades/jetpack/hi.wav", qfalse ); - + cgs.media.medkitUseSound = trap_S_RegisterSound( "sound/upgrades/medkit/medkit.wav", qfalse ); cgs.media.alienEvolveSound = trap_S_RegisterSound( "sound/player/alienevolve.wav", qfalse ); - + cgs.media.alienBuildableExplosion = trap_S_RegisterSound( "sound/buildables/alien/explosion.wav", qfalse ); cgs.media.alienBuildableDamage = trap_S_RegisterSound( "sound/buildables/alien/damage.wav", qfalse ); cgs.media.alienBuildablePrebuild = trap_S_RegisterSound( "sound/buildables/alien/prebuild.wav", qfalse ); - + cgs.media.humanBuildableExplosion = trap_S_RegisterSound( "sound/buildables/human/explosion.wav", qfalse ); cgs.media.humanBuildablePrebuild = trap_S_RegisterSound( "sound/buildables/human/prebuild.wav", qfalse ); cgs.media.metalGibBounceSound = trap_S_RegisterSound( "sound/buildables/human/fragmentbounce.wav", qfalse ); @@ -696,15 +690,15 @@ static void CG_RegisterSounds( void ) for( i = 0; i < 4; i++ ) cgs.media.humanBuildableDamage[ i ] = trap_S_RegisterSound( va( "sound/buildables/human/damage%d.wav", i ), qfalse ); - + cgs.media.hgrenb1aSound = trap_S_RegisterSound( "sound/weapons/grenade/hgrenb1a.wav", qfalse ); cgs.media.hgrenb2aSound = trap_S_RegisterSound( "sound/weapons/grenade/hgrenb2a.wav", qfalse ); - + cgs.media.repeaterUseSound = trap_S_RegisterSound( "sound/buildables/repeater/use.wav", qfalse ); - + cgs.media.buildableRepairSound = trap_S_RegisterSound( "sound/buildables/human/repair.wav", qfalse ); cgs.media.buildableRepairedSound = trap_S_RegisterSound( "sound/buildables/human/repaired.wav", qfalse ); - + cgs.media.lCannonWarningSound = trap_S_RegisterSound( "models/weapons/lcannon/warning.wav", qfalse ); } @@ -754,7 +748,7 @@ static void CG_RegisterGraphics( void ) trap_R_LoadWorldMap( cgs.mapname ); CG_UpdateMediaFraction( 0.66f ); - + for( i = 0; i < 11; i++ ) cgs.media.numberShaders[ i ] = trap_R_RegisterShader( sb_nums[ i ] ); @@ -773,12 +767,12 @@ static void CG_RegisterGraphics( void ) cgs.media.greenBloodTrailShader = trap_R_RegisterShader( "greenBloodTrail" ); cgs.media.greenBloodMarkShader = trap_R_RegisterShader( "greenBloodMark" ); cgs.media.explosionTrailShader = trap_R_RegisterShader( "explosionTrail" ); - + cgs.media.creepShader = trap_R_RegisterShader( "creep" ); - + cgs.media.scannerBlipShader = trap_R_RegisterShader( "gfx/2d/blip" ); cgs.media.scannerLineShader = trap_R_RegisterShader( "gfx/2d/stalk" ); - + cgs.media.waterBubbleShader = trap_R_RegisterShader( "waterBubble" ); cgs.media.tracerShader = trap_R_RegisterShader( "gfx/misc/tracer" ); @@ -787,7 +781,7 @@ static void CG_RegisterGraphics( void ) cgs.media.backTileShader = trap_R_RegisterShader( "gfx/2d/backtile" ); cgs.media.noammoShader = trap_R_RegisterShader( "icons/noammo" ); cgs.media.friendShader = trap_R_RegisterShader( "sprites/foe" ); - + //TA: building shaders cgs.media.greenBuildShader = trap_R_RegisterShader("gfx/2d/greenbuild" ); @@ -797,7 +791,7 @@ static void CG_RegisterGraphics( void ) for( i = 0; i < 8; i++ ) cgs.media.buildWeaponTimerPie[ i ] = trap_R_RegisterShader( buildWeaponTimerPieShaders[ i ] ); - + cgs.media.upgradeClassIconShader = trap_R_RegisterShader( "icons/icona_upgrade.tga" ); cgs.media.machinegunBrassModel = trap_R_RegisterModel( "models/weapons2/shells/m_shell.md3" ); @@ -822,15 +816,15 @@ static void CG_RegisterGraphics( void ) cgs.media.metalGib6 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib6.md3" ); cgs.media.metalGib7 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib7.md3" ); cgs.media.metalGib8 = trap_R_RegisterModel( "models/fx/metal_gibs/m_gib8.md3" ); - + cgs.media.gibSpark1 = trap_R_RegisterShader( "models/fx/metal_gibs/spark.jpg" ); cgs.media.gibSpark2 = trap_R_RegisterShader( "models/fx/metal_gibs/spark2.jpg" ); - + cgs.media.alienGib1 = trap_R_RegisterModel( "models/fx/alien_gibs/a_gib1.md3" ); cgs.media.alienGib2 = trap_R_RegisterModel( "models/fx/alien_gibs/a_gib2.md3" ); cgs.media.alienGib3 = trap_R_RegisterModel( "models/fx/alien_gibs/a_gib3.md3" ); cgs.media.alienGib4 = trap_R_RegisterModel( "models/fx/alien_gibs/a_gib4.md3" ); - + cgs.media.smoke2 = trap_R_RegisterModel( "models/weapons2/shells/s_shell.md3" ); cgs.media.balloonShader = trap_R_RegisterShader( "sprites/balloon3" ); @@ -873,7 +867,7 @@ static void CG_RegisterGraphics( void ) // register the inline models cgs.numInlineModels = trap_CM_NumInlineModels( ); - + for( i = 1; i < cgs.numInlineModels; i++ ) { char name[ 10 ]; @@ -881,10 +875,10 @@ static void CG_RegisterGraphics( void ) int j; Com_sprintf( name, sizeof( name ), "*%i", i ); - + cgs.inlineDrawModel[ i ] = trap_R_RegisterModel( name ); trap_R_ModelBounds( cgs.inlineDrawModel[ i ], mins, maxs ); - + for( j = 0 ; j < 3 ; j++ ) cgs.inlineModelMidpoints[ i ][ j ] = mins[ j ] + 0.5 * ( maxs[ j ] - mins[ j ] ); } @@ -895,7 +889,7 @@ static void CG_RegisterGraphics( void ) const char *modelName; modelName = CG_ConfigString( CS_MODELS + i ); - + if( !modelName[ 0 ] ) break; @@ -910,7 +904,7 @@ static void CG_RegisterGraphics( void ) const char *shaderName; shaderName = CG_ConfigString( CS_SHADERS + i ); - + if( !shaderName[ 0 ] ) break; @@ -925,7 +919,7 @@ static void CG_RegisterGraphics( void ) const char *psName; psName = CG_ConfigString( CS_PARTICLE_SYSTEMS + i ); - + if( !psName[ 0 ] ) break; @@ -934,7 +928,7 @@ static void CG_RegisterGraphics( void ) } -/* +/* ======================= CG_BuildSpectatorString @@ -943,17 +937,17 @@ CG_BuildSpectatorString void CG_BuildSpectatorString( void ) { int i; - + cg.spectatorList[ 0 ] = 0; - + for( i = 0; i < MAX_CLIENTS; i++ ) { if( cgs.clientinfo[ i ].infoValid && cgs.clientinfo[ i ].team == PTE_NONE ) Q_strcat( cg.spectatorList, sizeof( cg.spectatorList ), va( "%s " S_COLOR_WHITE, cgs.clientinfo[ i ].name ) ); } - + i = strlen( cg.spectatorList ); - + if( i != cg.spectatorLen ) { cg.spectatorLen = i; @@ -974,13 +968,13 @@ static void CG_RegisterClients( void ) int i; cg.charModelFraction = 0.0f; - + //precache all the models/sounds/etc for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { CG_PrecacheClientInfo( i, BG_FindModelNameForClass( i ), BG_FindSkinNameForClass( i ) ); - + cg.charModelFraction = (float)i / (float)PCL_NUM_CLASSES; trap_UpdateScreen( ); } @@ -988,14 +982,14 @@ static void CG_RegisterClients( void ) cgs.media.larmourHeadSkin = trap_R_RegisterSkin( "models/players/human_base/head_light.skin" ); cgs.media.larmourLegsSkin = trap_R_RegisterSkin( "models/players/human_base/lower_light.skin" ); cgs.media.larmourTorsoSkin = trap_R_RegisterSkin( "models/players/human_base/upper_light.skin" ); - + cgs.media.jetpackModel = trap_R_RegisterModel( "models/players/human_base/jetpack.md3" ); cgs.media.jetpackFlashModel = trap_R_RegisterModel( "models/players/human_base/jetpack_flash.md3" ); cgs.media.battpackModel = trap_R_RegisterModel( "models/players/human_base/battpack.md3" ); - + cg.charModelFraction = 1.0f; trap_UpdateScreen( ); - + //load all the clientinfos of clients already connected to the server for( i = 0; i < MAX_CLIENTS; i++ ) { @@ -1059,13 +1053,13 @@ char *CG_GetMenuBuffer( const char *filename ) static char buf[ MAX_MENUFILE ]; len = trap_FS_FOpenFile( filename, &f, FS_READ ); - + if( !f ) { trap_Print( va( S_COLOR_RED "menu file not found: %s, using default\n", filename ) ); return NULL; } - + if( len >= MAX_MENUFILE ) { trap_Print( va( S_COLOR_RED "menu file too large: %s is %i, max allowed is %i", @@ -1088,10 +1082,10 @@ qboolean CG_Asset_Parse( int handle ) if( !trap_PC_ReadToken( handle, &token ) ) return qfalse; - + if( Q_stricmp( token.string, "{" ) != 0 ) return qfalse; - + while( 1 ) { if( !trap_PC_ReadToken( handle, &token ) ) @@ -1104,10 +1098,10 @@ qboolean CG_Asset_Parse( int handle ) if( Q_stricmp( token.string, "font" ) == 0 ) { int pointSize; - + if( !PC_String_Parse( handle, &tempStr ) || !PC_Int_Parse( handle, &pointSize ) ) return qfalse; - + cgDC.registerFont( tempStr, pointSize, &cgDC.Assets.textFont ); continue; } @@ -1116,10 +1110,10 @@ qboolean CG_Asset_Parse( int handle ) if( Q_stricmp( token.string, "smallFont" ) == 0 ) { int pointSize; - + if( !PC_String_Parse( handle, &tempStr ) || !PC_Int_Parse( handle, &pointSize ) ) return qfalse; - + cgDC.registerFont( tempStr, pointSize, &cgDC.Assets.smallFont ); continue; } @@ -1128,7 +1122,7 @@ qboolean CG_Asset_Parse( int handle ) if( Q_stricmp( token.string, "bigfont" ) == 0 ) { int pointSize; - + if( !PC_String_Parse( handle, &tempStr ) || !PC_Int_Parse( handle, &pointSize ) ) return qfalse; @@ -1171,7 +1165,7 @@ qboolean CG_Asset_Parse( int handle ) { if( !PC_String_Parse( handle, &tempStr ) ) return qfalse; - + cgDC.Assets.itemFocusSound = trap_S_RegisterSound( tempStr, qfalse ); continue; } @@ -1223,7 +1217,7 @@ qboolean CG_Asset_Parse( int handle ) { if( !PC_Float_Parse( handle, &cgDC.Assets.shadowX ) ) return qfalse; - + continue; } @@ -1244,7 +1238,7 @@ qboolean CG_Asset_Parse( int handle ) continue; } } - + return qfalse; // bk001204 - why not? } @@ -1254,10 +1248,10 @@ void CG_ParseMenu( const char *menuFile ) int handle; handle = trap_PC_LoadSource( menuFile ); - + if( !handle ) handle = trap_PC_LoadSource( "ui/testhud.menu" ); - + if( !handle ) return; @@ -1284,7 +1278,7 @@ void CG_ParseMenu( const char *menuFile ) if( CG_Asset_Parse( handle ) ) continue; else - break; + break; } @@ -1294,7 +1288,7 @@ void CG_ParseMenu( const char *menuFile ) Menu_New( handle ); } } - + trap_PC_FreeSource( handle ); } @@ -1310,14 +1304,14 @@ qboolean CG_Load_Menu( char **p ) while( 1 ) { token = COM_ParseExt( p, qtrue ); - + if( Q_stricmp( token, "}" ) == 0 ) return qtrue; if( !token || token[ 0 ] == 0 ) return qfalse; - CG_ParseMenu( token ); + CG_ParseMenu( token ); } return qfalse; } @@ -1335,12 +1329,12 @@ void CG_LoadMenus( const char *menuFile ) start = trap_Milliseconds( ); len = trap_FS_FOpenFile( menuFile, &f, FS_READ ); - + if( !f ) { trap_Error( va( S_COLOR_YELLOW "menu file not found: %s, using default\n", menuFile ) ); len = trap_FS_FOpenFile( "ui/hud.txt", &f, FS_READ ); - + if( !f ) trap_Error( va( S_COLOR_RED "default menu file not found: ui/hud.txt, unable to continue!\n", menuFile ) ); } @@ -1356,7 +1350,7 @@ void CG_LoadMenus( const char *menuFile ) trap_FS_Read( buf, len, f ); buf[ len ] = 0; trap_FS_FCloseFile( f ); - + COM_Compress( buf ); Menu_Reset( ); @@ -1366,7 +1360,7 @@ void CG_LoadMenus( const char *menuFile ) while( 1 ) { token = COM_ParseExt( &p, qtrue ); - + if( !token || token[ 0 ] == 0 || token[ 0 ] == '}' ) break; @@ -1396,7 +1390,7 @@ static qboolean CG_OwnerDrawHandleKey( int ownerDraw, int flags, float *special, static int CG_FeederCount( float feederID ) { int i, count = 0; - + if( feederID == FEEDER_ALIENTEAM_LIST ) { for( i = 0; i < cg.numScores; i++ ) @@ -1413,7 +1407,7 @@ static int CG_FeederCount( float feederID ) count++; } } - + return count; } @@ -1424,16 +1418,16 @@ void CG_SetScoreSelection( void *p ) playerState_t *ps = &cg.snap->ps; int i, alien, human; int feeder; - + alien = human = 0; - + for( i = 0; i < cg.numScores; i++ ) { if( cg.scores[ i ].team == PTE_ALIENS ) alien++; else if( cg.scores[ i ].team == PTE_HUMANS ) human++; - + if( ps->clientNum == cg.scores[ i ].client ) cg.selectedScore = i; } @@ -1444,13 +1438,13 @@ void CG_SetScoreSelection( void *p ) feeder = FEEDER_ALIENTEAM_LIST; i = alien; - + if( cg.scores[ cg.selectedScore ].team == PTE_HUMANS ) { feeder = FEEDER_HUMANTEAM_LIST; i = human; } - + Menu_SetFeederSelection(menu, feeder, i, NULL); } @@ -1459,7 +1453,7 @@ static clientInfo_t * CG_InfoFromScoreIndex( int index, int team, int *scoreInde { int i, count; count = 0; - + for( i = 0; i < cg.numScores; i++ ) { if( cg.scores[ i ].team == team ) @@ -1472,7 +1466,7 @@ static clientInfo_t * CG_InfoFromScoreIndex( int index, int team, int *scoreInde count++; } } - + *scoreIndex = index; return &cgs.clientinfo[ cg.scores[ index ].client ]; } @@ -1501,7 +1495,7 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha else if( cg.snap->ps.pm_type == PM_SPECTATOR || cg.snap->ps.pm_flags & PMF_FOLLOW || team == cg.snap->ps.stats[ STAT_PTEAM ] || cg.intermissionStarted ) showIcons = qtrue; - + if( info && info->infoValid ) { switch( column ) @@ -1513,7 +1507,7 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha *handle = cg_weapons[ sp->weapon ].weaponIcon; } break; - + case 1: if( showIcons ) { @@ -1529,36 +1523,36 @@ static const char *CG_FeederItemText( float feederID, int index, int column, qha case WP_ALEVEL3_UPG: *handle = cgs.media.upgradeClassIconShader; break; - + default: break; } } } break; - + case 2: if( ( atoi( CG_ConfigString( CS_CLIENTS_READY ) ) & ( 1 << sp->client ) ) && cg.intermissionStarted ) return "Ready"; break; - + case 3: return info->name; break; - + case 4: return va( "%d", info->score ); break; - + case 5: return va( "%4d", sp->time ); break; - + case 6: if( sp->ping == -1 ) return "connecting"; - + return va( "%4d", sp->ping ); break; } @@ -1577,7 +1571,7 @@ static void CG_FeederSelection( float feederID, int index ) int i, count; int team = ( feederID == FEEDER_ALIENTEAM_LIST ) ? PTE_ALIENS : PTE_HUMANS; count = 0; - + for( i = 0; i < cg.numScores; i++ ) { if( cg.scores[ i ].team == team ) @@ -1593,7 +1587,7 @@ static void CG_FeederSelection( float feederID, int index ) static float CG_Cvar_Get( const char *cvar ) { char buff[ 128 ]; - + memset( buff, 0, sizeof( buff ) ); trap_Cvar_VariableStringBuffer( cvar, buff, sizeof( buff ) ); return atof( buff ); @@ -1605,7 +1599,7 @@ void CG_Text_PaintWithCursor( float x, float y, float scale, vec4_t color, const CG_Text_Paint( x, y, scale, color, text, 0, limit, style ); } -static int CG_OwnerDrawWidth( int ownerDraw, float scale ) +static int CG_OwnerDrawWidth( int ownerDraw, float scale ) { switch( ownerDraw ) { @@ -1613,7 +1607,7 @@ static int CG_OwnerDrawWidth( int ownerDraw, float scale ) return CG_Text_Width( CG_GetKillerText( ), scale, 0 ); break; } - + return 0; } @@ -1664,7 +1658,7 @@ void CG_LoadHudMenu( ) cgDC.registerModel = &trap_R_RegisterModel; cgDC.modelBounds = &trap_R_ModelBounds; cgDC.fillRect = &CG_FillRect; - cgDC.drawRect = &CG_DrawRect; + cgDC.drawRect = &CG_DrawRect; cgDC.drawSides = &CG_DrawSides; cgDC.drawTopBottom = &CG_DrawTopBottom; cgDC.clearScene = &trap_R_ClearScene; @@ -1692,8 +1686,8 @@ void CG_LoadHudMenu( ) //cgDC.getBindingBuf = &trap_Key_GetBindingBuf; //cgDC.keynumToStringBuf = &trap_Key_KeynumToStringBuf; //cgDC.executeText = &trap_Cmd_ExecuteText; - cgDC.Error = &Com_Error; - cgDC.Print = &Com_Printf; + cgDC.Error = &Com_Error; + cgDC.Print = &Com_Printf; cgDC.ownerDrawWidth = &CG_OwnerDrawWidth; //cgDC.Pause = &CG_Pause; cgDC.registerSound = &trap_S_RegisterSound; @@ -1703,14 +1697,14 @@ void CG_LoadHudMenu( ) cgDC.stopCinematic = &CG_StopCinematic; cgDC.drawCinematic = &CG_DrawCinematic; cgDC.runCinematicFrame = &CG_RunCinematicFrame; - + Init_Display( &cgDC ); Menu_Reset( ); - + trap_Cvar_VariableStringBuffer( "cg_hudFiles", buff, sizeof( buff ) ); hudSet = buff; - + if( hudSet[ 0 ] == '\0' ) hudSet = "ui/hud.txt"; @@ -1720,14 +1714,6 @@ void CG_LoadHudMenu( ) void CG_AssetCache( void ) { cgDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR ); - cgDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE ); - cgDC.Assets.fxPic[ 0 ] = trap_R_RegisterShaderNoMip( ART_FX_RED ); - cgDC.Assets.fxPic[ 1 ] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW ); - cgDC.Assets.fxPic[ 2 ] = trap_R_RegisterShaderNoMip( ART_FX_GREEN ); - cgDC.Assets.fxPic[ 3 ] = trap_R_RegisterShaderNoMip( ART_FX_TEAL ); - cgDC.Assets.fxPic[ 4 ] = trap_R_RegisterShaderNoMip( ART_FX_BLUE ); - cgDC.Assets.fxPic[ 5 ] = trap_R_RegisterShaderNoMip( ART_FX_CYAN ); - cgDC.Assets.fxPic[ 6 ] = trap_R_RegisterShaderNoMip( ART_FX_WHITE ); cgDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR ); cgDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN ); cgDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP ); @@ -1767,11 +1753,11 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) //inform UI to repress cursor whilst loading trap_Cvar_Set( "ui_loading", "1" ); - + //TA: load overrides BG_InitClassOverrides( ); BG_InitBuildableOverrides( ); - + //TA: dyn memory CG_InitMemory( ); @@ -1800,7 +1786,7 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) // check version s = CG_ConfigString( CS_GAME_VERSION ); - + if( strcmp( s, GAME_VERSION ) ) CG_Error( "Client/Server game mismatch: %s/%s", GAME_VERSION, s ); @@ -1816,19 +1802,19 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) CG_LoadParticleSystems( ); CG_UpdateMediaFraction( 0.05f ); - + CG_RegisterSounds( ); CG_UpdateMediaFraction( 0.60f ); CG_RegisterGraphics( ); CG_UpdateMediaFraction( 0.90f ); - + CG_InitWeapons( ); CG_UpdateMediaFraction( 0.95f ); - + CG_InitUpgrades( ); CG_UpdateMediaFraction( 1.0f ); - + //TA: CG_InitBuildables( ); @@ -1853,7 +1839,7 @@ void CG_Init( int serverMessageNum, int serverCommandSequence, int clientNum ) trap_S_ClearLoopingSounds( qtrue ); cg.consoleValid = qtrue; - + trap_Cvar_Set( "ui_loading", "0" ); } diff --git a/src/cgame/cg_marks.c b/src/cgame/cg_marks.c index deb31c4d..b9c09009 100644 --- a/src/cgame/cg_marks.c +++ b/src/cgame/cg_marks.c @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "cg_local.h" /* @@ -47,7 +47,7 @@ void CG_InitMarkPolys( void ) cg_activeMarkPolys.nextMark = &cg_activeMarkPolys; cg_activeMarkPolys.prevMark = &cg_activeMarkPolys; cg_freeMarkPolys = cg_markPolys; - + for( i = 0; i < MAX_MARK_POLYS - 1; i++ ) cg_markPolys[ i ].nextMark = &cg_markPolys[ i + 1 ]; } @@ -89,7 +89,7 @@ markPoly_t *CG_AllocMark( void ) // no free entities, so free the one at the end of the chain // remove the oldest active entity time = cg_activeMarkPolys.prevMark->time; - + while( cg_activeMarkPolys.prevMark && time == cg_activeMarkPolys.prevMark->time ) CG_FreeMarkPoly( cg_activeMarkPolys.prevMark ); } @@ -123,7 +123,7 @@ passed to the renderer. #define MAX_MARK_FRAGMENTS 128 #define MAX_MARK_POINTS 384 -void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, +void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, float orientation, float red, float green, float blue, float alpha, qboolean alphaFade, float radius, qboolean temporary ) { @@ -216,7 +216,7 @@ void CG_ImpactMark( qhandle_t markShader, const vec3_t origin, const vec3_t dir, mark->color[ 2 ] = blue; mark->color[ 3 ] = alpha; memcpy( mark->verts, verts, mf->numPoints * sizeof( verts[ 0 ] ) ); - markTotal++; + markTotal++; } } diff --git a/src/cgame/cg_mem.c b/src/cgame/cg_mem.c index d0cd29ec..959bd4b0 100644 --- a/src/cgame/cg_mem.c +++ b/src/cgame/cg_mem.c @@ -76,7 +76,7 @@ void *CG_Alloc( int size ) } } } - + if( !ptr && smallest ) { // We found a slot big enough diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c index 9f9ef167..b6a52d90 100644 --- a/src/cgame/cg_particles.c +++ b/src/cgame/cg_particles.c @@ -91,7 +91,7 @@ static void CG_DestroyParticle( particle_t *p ) if( p->class->onDeathSystemName[ 0 ] != '\0' ) { particleSystem_t *ps; - + ps = CG_SpawnNewParticleSystem( p->class->childSystemHandle ); if( CG_IsParticleSystemValid( &ps ) ) @@ -101,7 +101,7 @@ static void CG_DestroyParticle( particle_t *p ) CG_AttachParticleSystemToOrigin( ps ); } } - + p->valid = qfalse; } @@ -124,7 +124,7 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p for( i = 0; i < MAX_PARTICLES; i++ ) { p = &particles[ i ]; - + if( !p->valid ) { memset( p, 0, sizeof( particle_t ) ); @@ -135,49 +135,49 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p p->birthTime = cg.time; p->lifeTime = (int)CG_RandomiseValue( (float)bp->lifeTime, bp->lifeTimeRandFrac ); - + p->radius.delay = (int)CG_RandomiseValue( (float)bp->radius.delay, bp->radius.delayRandFrac ); p->radius.initial = CG_RandomiseValue( bp->radius.initial, bp->radius.initialRandFrac ); p->radius.final = CG_RandomiseValue( bp->radius.final, bp->radius.finalRandFrac ); - + p->alpha.delay = (int)CG_RandomiseValue( (float)bp->alpha.delay, bp->alpha.delayRandFrac ); p->alpha.initial = CG_RandomiseValue( bp->alpha.initial, bp->alpha.initialRandFrac ); p->alpha.final = CG_RandomiseValue( bp->alpha.final, bp->alpha.finalRandFrac ); - + p->rotation.delay = (int)CG_RandomiseValue( (float)bp->rotation.delay, bp->rotation.delayRandFrac ); p->rotation.initial = CG_RandomiseValue( bp->rotation.initial, bp->rotation.initialRandFrac ); p->rotation.final = CG_RandomiseValue( bp->rotation.final, bp->rotation.finalRandFrac ); - + switch( ps->attachType ) { case PSA_STATIC: if( !ps->attachment.staticValid ) return NULL; - + VectorCopy( ps->attachment.origin, p->origin ); break; case PSA_TAG: if( !ps->attachment.tagValid ) return NULL; - + AxisCopy( axisDefault, ps->attachment.re.axis ); CG_PositionRotatedEntityOnTag( &ps->attachment.re, &ps->attachment.parent, ps->attachment.model, ps->attachment.tagName ); VectorCopy( ps->attachment.re.origin, p->origin ); break; - + case PSA_CENT_ORIGIN: if( !ps->attachment.centValid ) return NULL; - + VectorCopy( cent->lerpOrigin, p->origin ); break; - + case PSA_PARTICLE: if( !ps->attachment.particleValid ) return NULL; - + //find a particle which has ps as a child for( j = 0; j < MAX_PARTICLES; j++ ) { @@ -193,47 +193,47 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p if( j == MAX_PARTICLES ) { //didn't find the parent, so it's probably died already - + //prevent further (expensive) attempts at particle creation ps->attachment.particleValid = qfalse; return NULL; } break; } - + VectorAdd( p->origin, bp->displacement, p->origin ); - + for( j = 0; j <= 2; j++ ) p->origin[ j ] += ( crandom( ) * bp->randDisplacement ); switch( bp->velMoveType ) { case PMT_STATIC: - + if( bp->velMoveValues.dirType == PMD_POINT ) VectorSubtract( bp->velMoveValues.point, p->origin, p->velocity ); else if( bp->velMoveValues.dirType == PMD_LINEAR ) VectorCopy( bp->velMoveValues.dir, p->velocity ); - + break; case PMT_TAG: - + if( !ps->attachment.tagValid ) return NULL; - + if( bp->velMoveValues.dirType == PMD_POINT ) VectorSubtract( ps->attachment.re.origin, p->origin, p->velocity ); else if( bp->velMoveValues.dirType == PMD_LINEAR ) VectorCopy( ps->attachment.re.axis[ 0 ], p->velocity ); - + break; case PMT_CENT_ANGLES: - + if( !ps->attachment.centValid ) return NULL; - + if( bp->velMoveValues.dirType == PMD_POINT ) VectorSubtract( cent->lerpOrigin, p->origin, p->velocity ); else if( bp->velMoveValues.dirType == PMD_LINEAR ) @@ -241,23 +241,23 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p AngleVectors( cent->lerpAngles, forward, NULL, NULL ); VectorCopy( forward, p->velocity ); } - + break; - + case PMT_NORMAL: - + if( !ps->attachment.normalValid ) return NULL; - + VectorCopy( ps->attachment.normal, p->velocity ); //normal displacement VectorNormalize( p->velocity ); VectorMA( p->origin, bp->normalDisplacement, p->velocity, p->origin ); - + break; } - + VectorNormalize( p->velocity ); CG_SpreadVector( p->velocity, bp->velMoveValues.dirRandAngle ); VectorScale( p->velocity, @@ -270,16 +270,16 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p CG_RandomiseValue( bp->velMoveValues.parentVelFrac, bp->velMoveValues.parentVelFracRandFrac ), cent->currentState.pos.trDelta, p->velocity ); } - + p->lastEvalTime = cg.time; p->valid = qtrue; - + //this particle has a child particle system attached if( bp->childSystemName[ 0 ] != '\0' ) { particleSystem_t *ps; - + ps = CG_SpawnNewParticleSystem( bp->childSystemHandle ); if( CG_IsParticleSystemValid( &ps ) ) @@ -289,7 +289,7 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p CG_AttachParticleSystemToParticle( ps ); } } - + break; } } @@ -337,13 +337,13 @@ static void CG_SpawnNewParticles( void ) { 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 + (int)CG_RandomiseValue( + pe->nextEjectionTime = cg.time + (int)CG_RandomiseValue( CG_LerpValues( pe->ejectPeriod.initial, pe->ejectPeriod.final, lerpFrac ), @@ -359,7 +359,7 @@ static void CG_SpawnNewParticles( void ) for( j = 0; j < MAX_PARTICLES; j++ ) { p = &particles[ j ]; - + if( p->valid && p->parent == pe ) count++; } @@ -389,7 +389,7 @@ static particleEjector_t *CG_SpawnNewParticleEjector( baseParticleEjector_t *bpe for( i = 0; i < MAX_PARTICLE_EJECTORS; i++ ) { pe = &particleEjectors[ i ]; - + if( !pe->valid ) { memset( pe, 0, sizeof( particleEjector_t ) ); @@ -408,10 +408,10 @@ static particleEjector_t *CG_SpawnNewParticleEjector( baseParticleEjector_t *bpe (int)round( 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; } } @@ -438,11 +438,11 @@ particleSystem_t *CG_SpawnNewParticleSystem( qhandle_t psHandle ) CG_Printf( S_COLOR_RED "ERROR: a particle system has not been registered yet\n" ); return NULL; } - + for( i = 0; i < MAX_PARTICLE_SYSTEMS; i++ ) { ps = &particleSystems[ i ]; - + if( !ps->valid ) { memset( ps, 0, sizeof( particleSystem_t ) ); @@ -452,7 +452,7 @@ particleSystem_t *CG_SpawnNewParticleSystem( qhandle_t psHandle ) ps->valid = qtrue; ps->lazyRemove = qfalse; - + for( j = 0; j < bps->numEjectors; j++ ) CG_SpawnNewParticleEjector( bps->ejectors[ j ], ps ); @@ -483,17 +483,17 @@ qhandle_t CG_RegisterParticleSystem( char *name ) for( i = 0; i < MAX_PARTICLE_SYSTEMS; i++ ) { bps = &baseParticleSystems[ i ]; - + if( !strcmp( bps->name, name ) ) { //already registered if( bps->registered ) return i + 1; - + for( j = 0; j < bps->numEjectors; j++ ) { bpe = bps->ejectors[ j ]; - + for( l = 0; l < bpe->numParticles; l++ ) { bp = bpe->particles[ l ]; @@ -508,7 +508,7 @@ qhandle_t CG_RegisterParticleSystem( char *name ) //the system deals with it CG_RegisterParticleSystem( bp->childSystemName ); } - + if( bp->onDeathSystemName[ 0 ] != '\0' ) { //don't care about a handle for children since @@ -520,7 +520,7 @@ qhandle_t CG_RegisterParticleSystem( char *name ) if( cg_debugParticles.integer >= 1 ) CG_Printf( "Registered particle system %s\n", name ); - + bps->registered = qtrue; //avoid returning 0 @@ -599,7 +599,7 @@ static void CG_ParseValueAndVariance( char *token, float *value, float *variance Q_strncpyz( varianceBuffer, token, sizeof( varianceBuffer ) ); variancePtr = strchr( valueBuffer, '~' ); - + //variance included if( variancePtr ) { @@ -607,7 +607,7 @@ static void CG_ParseValueAndVariance( char *token, float *value, float *variance variancePtr++; localValue = atof_neg( valueBuffer, allowNegative ); - + varEndPointer = strchr( variancePtr, '%' ); if( varEndPointer ) @@ -651,7 +651,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) while( 1 ) { token = COM_Parse( text_p ); - + if( !token ) break; @@ -667,7 +667,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) if( !Q_stricmp( token, "cull" ) ) { bp->bounceCull = qtrue; - + bp->bounceFrac = -1.0f; bp->bounceFracRandFrac = 0.0f; } @@ -686,7 +686,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + if( !Q_stricmp( token, "sync" ) ) bp->framerate = 0.0f; else @@ -699,10 +699,10 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) Q_strncpyz( bp->shaderNames[ bp->numFrames++ ], token, MAX_QPATH ); token = COM_ParseExt( text_p, qfalse ); } - + if( !token ) break; - + continue; } /// @@ -711,7 +711,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + if( !Q_stricmp( token, "static" ) ) bp->velMoveType = PMT_STATIC; else if( !Q_stricmp( token, "tag" ) ) @@ -728,7 +728,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + if( !Q_stricmp( token, "linear" ) ) bp->velMoveValues.dirType = PMD_LINEAR; else if( !Q_stricmp( token, "point" ) ) @@ -741,7 +741,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + CG_ParseValueAndVariance( token, &number, &randFrac, qfalse ); bp->velMoveValues.mag = number; @@ -754,7 +754,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + CG_ParseValueAndVariance( token, &number, &randFrac, qfalse ); bp->velMoveValues.parentVelFrac = number; @@ -769,18 +769,18 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + bp->velMoveValues.dir[ i ] = atof_neg( token, qtrue ); } - + token = COM_Parse( text_p ); if( !token ) break; - + CG_ParseValueAndVariance( token, NULL, &randFrac, qfalse ); bp->velMoveValues.dirRandAngle = randFrac; - + continue; } else if( !Q_stricmp( token, "velocityPoint" ) ) @@ -790,18 +790,18 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + bp->velMoveValues.point[ i ] = atof_neg( token, qtrue ); } - + token = COM_Parse( text_p ); if( !token ) break; - + CG_ParseValueAndVariance( token, NULL, &randFrac, qfalse ); bp->velMoveValues.pointRandAngle = randFrac; - + continue; } /// @@ -810,7 +810,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + if( !Q_stricmp( token, "static" ) ) bp->accMoveType = PMT_STATIC; else if( !Q_stricmp( token, "tag" ) ) @@ -827,7 +827,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + if( !Q_stricmp( token, "linear" ) ) bp->accMoveValues.dirType = PMD_LINEAR; else if( !Q_stricmp( token, "point" ) ) @@ -840,7 +840,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + CG_ParseValueAndVariance( token, &number, &randFrac, qfalse ); bp->accMoveValues.mag = number; @@ -855,18 +855,18 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + bp->accMoveValues.dir[ i ] = atof_neg( token, qtrue ); } - + token = COM_Parse( text_p ); if( !token ) break; - + CG_ParseValueAndVariance( token, NULL, &randFrac, qfalse ); bp->accMoveValues.dirRandAngle = randFrac; - + continue; } else if( !Q_stricmp( token, "accelerationPoint" ) ) @@ -876,18 +876,18 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + bp->accMoveValues.point[ i ] = atof_neg( token, qtrue ); } - + token = COM_Parse( text_p ); if( !token ) break; - + CG_ParseValueAndVariance( token, NULL, &randFrac, qfalse ); bp->accMoveValues.pointRandAngle = randFrac; - + continue; } /// @@ -898,10 +898,10 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + bp->displacement[ i ] = atof_neg( token, qtrue ); } - + token = COM_Parse( text_p ); if( !token ) break; @@ -917,7 +917,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) token = COM_Parse( text_p ); if( !token ) break; - + bp->normalDisplacement = atof_neg( token, qtrue ); continue; @@ -1077,7 +1077,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) break; Q_strncpyz( bp->childSystemName, token, MAX_QPATH ); - + continue; } else if( !Q_stricmp( token, "onDeathSystem" ) ) @@ -1087,7 +1087,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) break; Q_strncpyz( bp->onDeathSystemName, token, MAX_QPATH ); - + continue; } else if( !Q_stricmp( token, "}" ) ) @@ -1119,7 +1119,7 @@ static qboolean CG_ParseParticleEjector( baseParticleEjector_t *bpe, char **text while( 1 ) { token = COM_Parse( text_p ); - + if( !token ) break; @@ -1173,7 +1173,7 @@ static qboolean CG_ParseParticleEjector( baseParticleEjector_t *bpe, char **text break; bpe->eject.initial = atoi_neg( token, qfalse ); - + token = COM_Parse( text_p ); if( !token ) break; @@ -1182,7 +1182,7 @@ static qboolean CG_ParseParticleEjector( baseParticleEjector_t *bpe, char **text bpe->eject.final = PARTICLES_SAME_AS_INITIAL; else bpe->eject.final = atoi_neg( token, qfalse ); - + token = COM_Parse( text_p ); if( !token ) break; @@ -1243,7 +1243,7 @@ static qboolean CG_ParseParticleSystem( baseParticleSystem_t *bps, char **text_p while( 1 ) { token = COM_Parse( text_p ); - + if( !token ) break; @@ -1259,7 +1259,7 @@ static qboolean CG_ParseParticleSystem( baseParticleSystem_t *bps, char **text_p } bpe = &baseParticleEjectors[ numBaseParticleEjectors ]; - + //check for infinite count + zero period if( bpe->totalParticles == PARTICLES_INFINITE && ( bpe->eject.initial == 0.0f || bpe->eject.final == 0.0f ) ) @@ -1293,7 +1293,7 @@ static qboolean CG_ParseParticleSystem( baseParticleSystem_t *bps, char **text_p { if( cg_debugParticles.integer >= 1 ) CG_Printf( "Parsed particle system %s\n", name ); - + return qtrue; //reached the end of this particle system } else @@ -1334,7 +1334,7 @@ static qboolean CG_ParseParticleFile( const char *fileName ) CG_Printf( S_COLOR_RED "ERROR: particle file %s too long\n", fileName ); return qfalse; } - + trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); @@ -1346,7 +1346,7 @@ static qboolean CG_ParseParticleFile( const char *fileName ) while( 1 ) { token = COM_Parse( &text_p ); - + if( !token ) break; @@ -1366,9 +1366,9 @@ static qboolean CG_ParseParticleFile( const char *fileName ) return qfalse; } } - + Q_strncpyz( baseParticleSystems[ numBaseParticleSystems ].name, psName, MAX_QPATH ); - + if( !CG_ParseParticleSystem( &baseParticleSystems[ numBaseParticleSystems ], &text_p, psName ) ) { CG_Printf( S_COLOR_RED "ERROR: %s: failed to parse particle system %s\n", fileName, psName ); @@ -1377,7 +1377,7 @@ static qboolean CG_ParseParticleFile( const char *fileName ) //start parsing particle systems again psNameSet = qfalse; - + if( numBaseParticleSystems == MAX_BASEPARTICLE_SYSTEMS ) { CG_Printf( S_COLOR_RED "ERROR: maximum number of particle systems (%d) reached\n", MAX_BASEPARTICLE_EJECTORS ); @@ -1385,7 +1385,7 @@ static qboolean CG_ParseParticleFile( const char *fileName ) } else numBaseParticleSystems++; - + continue; } else @@ -1433,25 +1433,25 @@ void CG_LoadParticleSystems( void ) baseParticleSystem_t *bps = &baseParticleSystems[ i ]; memset( bps, 0, sizeof( baseParticleSystem_t ) ); } - + for( i = 0; i < MAX_BASEPARTICLE_EJECTORS; i++ ) { baseParticleEjector_t *bpe = &baseParticleEjectors[ i ]; memset( bpe, 0, sizeof( baseParticleEjector_t ) ); } - + for( i = 0; i < MAX_BASEPARTICLES; i++ ) { baseParticle_t *bp = &baseParticles[ i ]; memset( bp, 0, sizeof( baseParticle_t ) ); } - + //and bring in the new for( i = 0; i < MAX_PARTICLE_FILES; i++ ) { s[ i ] = CG_ConfigString( CS_PARTICLE_FILES + i ); - + if( strlen( s[ i ] ) > 0 ) { CG_Printf( "...loading '%s'\n", s[ i ] ); @@ -1533,7 +1533,7 @@ void CG_AttachParticleSystemToCent( particleSystem_t *ps ) CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" ); return; } - + ps->attachType = PSA_CENT_ORIGIN; ps->attached = qtrue; } @@ -1552,7 +1552,7 @@ void CG_SetParticleSystemCent( particleSystem_t *ps, centity_t *cent ) CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" ); return; } - + ps->attachment.centValid = qtrue; ps->attachment.centNum = cent->currentState.number; } @@ -1571,7 +1571,7 @@ void CG_AttachParticleSystemToTag( particleSystem_t *ps ) CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" ); return; } - + ps->attachType = PSA_TAG; ps->attached = qtrue; } @@ -1591,7 +1591,7 @@ void CG_SetParticleSystemTag( particleSystem_t *ps, refEntity_t parent, CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" ); return; } - + ps->attachment.tagValid = qtrue; ps->attachment.parent = parent; ps->attachment.model = model; @@ -1612,7 +1612,7 @@ void CG_AttachParticleSystemToOrigin( particleSystem_t *ps ) CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" ); return; } - + ps->attachType = PSA_STATIC; ps->attached = qtrue; } @@ -1631,7 +1631,7 @@ void CG_SetParticleSystemOrigin( particleSystem_t *ps, vec3_t origin ) CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" ); return; } - + ps->attachment.staticValid = qtrue; VectorCopy( origin, ps->attachment.origin ); } @@ -1650,7 +1650,7 @@ void CG_AttachParticleSystemToParticle( particleSystem_t *ps ) CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" ); return; } - + ps->attachType = PSA_PARTICLE; ps->attached = qtrue; } @@ -1669,7 +1669,7 @@ void CG_SetParticleSystemParentParticle( particleSystem_t *ps, particle_t *p ) CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" ); return; } - + ps->attachment.particleValid = qtrue; p->childSystem = ps; } @@ -1688,7 +1688,7 @@ void CG_SetParticleSystemNormal( particleSystem_t *ps, vec3_t normal ) CG_Printf( S_COLOR_YELLOW "WARNING: tried to modify a NULL particle system\n" ); return; } - + ps->attachment.normalValid = qtrue; VectorCopy( normal, ps->attachment.normal ); VectorNormalize( ps->attachment.normal ); @@ -1702,7 +1702,7 @@ CG_DestroyParticleSystem Destroy a particle system This doesn't actually invalidate anything, it just stops -particle ejectors from producing new particles so the +particle ejectors from producing new particles so the 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. @@ -1712,20 +1712,20 @@ void CG_DestroyParticleSystem( particleSystem_t **ps ) { int i; particleEjector_t *pe; - + if( *ps == NULL || !(*ps)->valid ) { CG_Printf( S_COLOR_YELLOW "WARNING: tried to destroy a NULL particle system\n" ); return; } - + if( cg_debugParticles.integer >= 1 ) CG_Printf( "PS destroyed\n" ); for( i = 0; i < MAX_PARTICLE_EJECTORS; i++ ) { pe = &particleEjectors[ i ]; - + if( pe->valid && pe->parent == *ps ) pe->totalParticles = pe->count = 0; } @@ -1750,21 +1750,21 @@ qboolean CG_IsParticleSystemInfinite( particleSystem_t *ps ) 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; - + for( i = 0; i < MAX_PARTICLE_EJECTORS; i++ ) { pe = &particleEjectors[ i ]; - + if( pe->valid && pe->parent == ps ) { if( pe->totalParticles == PARTICLES_INFINITE ) @@ -1812,15 +1812,15 @@ static void CG_GarbageCollectParticleSystems( void ) { ps = &particleSystems[ i ]; count = 0; - + //don't bother checking already invalid systems if( !ps->valid ) continue; - + for( j = 0; j < MAX_PARTICLE_EJECTORS; j++ ) { pe = &particleEjectors[ j ]; - + if( pe->valid && pe->parent == ps ) count++; } @@ -1830,7 +1830,7 @@ static void CG_GarbageCollectParticleSystems( void ) //check systems where the parent cent has left the PVS //( local player entity is always valid ) - if( ps->attachment.centValid && ps->attachment.centNum != cg.clientNum ) + if( ps->attachment.centValid && ps->attachment.centNum != cg.snap->ps.clientNum ) { if( !cg_entities[ ps->attachment.centNum ].valid ) ps->lazyRemove = qtrue; @@ -1879,37 +1879,37 @@ static void CG_EvaluateParticlePhysics( particle_t *p ) float deltaTime, bounce, radius, dot; trace_t trace; centity_t *cent; - + switch( bp->accMoveType ) { case PMT_STATIC: - + if( bp->accMoveValues.dirType == PMD_POINT ) VectorSubtract( bp->accMoveValues.point, p->origin, acceleration ); else if( bp->accMoveValues.dirType == PMD_LINEAR ) VectorCopy( bp->accMoveValues.dir, acceleration ); - + break; case PMT_TAG: - + if( !ps->attachment.tagValid ) return; - + if( bp->accMoveValues.dirType == PMD_POINT ) VectorSubtract( ps->attachment.re.origin, p->origin, acceleration ); else if( bp->accMoveValues.dirType == PMD_LINEAR ) VectorCopy( ps->attachment.re.axis[ 0 ], acceleration ); - + break; case PMT_CENT_ANGLES: - + if( !ps->attachment.centValid ) return; - + cent = &cg_entities[ ps->attachment.centNum ]; - + if( bp->accMoveValues.dirType == PMD_POINT ) VectorSubtract( cent->lerpOrigin, p->origin, acceleration ); else if( bp->accMoveValues.dirType == PMD_LINEAR ) @@ -1917,21 +1917,21 @@ static void CG_EvaluateParticlePhysics( particle_t *p ) AngleVectors( cent->lerpAngles, forward, NULL, NULL ); VectorCopy( forward, acceleration ); } - + break; - + case PMT_NORMAL: - + if( !ps->attachment.normalValid ) return; - + VectorCopy( ps->attachment.normal, acceleration ); - + break; } #define MAX_ACC_RADIUS 1000.0f - + if( bp->accMoveValues.dirType == PMD_POINT ) { //FIXME: so this fall off is a bit... odd -- it works.. @@ -1942,9 +1942,9 @@ static void CG_EvaluateParticlePhysics( particle_t *p ) scale = 1.0f; else if( scale < 0.1f ) scale = 0.1f; - + scale *= CG_RandomiseValue( bp->accMoveValues.mag, bp->accMoveValues.magRandFrac ); - + VectorNormalize( acceleration ); CG_SpreadVector( acceleration, bp->accMoveValues.dirRandAngle ); VectorScale( acceleration, scale, acceleration ); @@ -1957,13 +1957,13 @@ static void CG_EvaluateParticlePhysics( particle_t *p ) CG_RandomiseValue( bp->accMoveValues.mag, bp->accMoveValues.magRandFrac ), acceleration ); } - + radius = CG_LerpValues( p->radius.initial, p->radius.final, CG_CalculateTimeFrac( p->birthTime, p->lifeTime, p->radius.delay ) ); - + VectorSet( mins, -radius, -radius, -radius ); VectorSet( maxs, radius, radius, radius ); @@ -1973,19 +1973,19 @@ static void CG_EvaluateParticlePhysics( particle_t *p ) VectorMA( p->velocity, deltaTime, acceleration, p->velocity ); VectorMA( p->origin, deltaTime, p->velocity, newOrigin ); p->lastEvalTime = cg.time; - + if( !ps->attachment.centValid ) CG_Trace( &trace, p->origin, mins, maxs, newOrigin, -1, CONTENTS_SOLID ); else CG_Trace( &trace, p->origin, mins, maxs, newOrigin, ps->attachment.centNum, CONTENTS_SOLID ); - + //not hit anything or not a collider if( trace.fraction == 1.0f || bounce == 0.0f ) { VectorCopy( newOrigin, p->origin ); return; } - + //remove particles that get into a CONTENTS_NODROP brush if( ( trap_CM_PointContents( trace.endpos, 0 ) & CONTENTS_NODROP ) || ( bp->cullOnStartSolid && trace.startsolid ) || bp->bounceCull ) @@ -2016,17 +2016,17 @@ static void CG_Radix( int bits, int size, particle_t *source, particle_t *dest ) int count[ 256 ]; int index[ 256 ]; int i; - + memset( count, 0, sizeof( count ) ); - + for( i = 0; i < size; i++ ) count[ GETKEY( source[ i ].sortKey, bits ) ]++; index[ 0 ] = 0; - + for( i = 1; i < 256; i++ ) index[ i ] = index[ i - 1 ] + count[ i - 1 ]; - + for( i = 0; i < size; i++ ) dest[ index[ GETKEY( source[ i ].sortKey, bits ) ]++ ] = source[ i ]; } @@ -2076,20 +2076,20 @@ static void CG_CompactAndSortParticles( void ) } numParticles = i; - + //set sort keys for( i = 0; i < numParticles; i++ ) { VectorSubtract( particles[ i ].origin, cg.refdef.vieworg, 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 ]; } @@ -2109,7 +2109,7 @@ static void CG_RenderParticle( particle_t *p ) baseParticle_t *bp = p->class; vec3_t alight, dlight, lightdir; int i; - + memset( &re, 0, sizeof( refEntity_t ) ); for( i = 0; i <= 3; re.shaderRGBA[ i++ ] = 0xFF ); @@ -2119,19 +2119,19 @@ static void CG_RenderParticle( particle_t *p ) re.reType = RT_SPRITE; re.shaderTime = p->birthTime / 1000.0f; //FIXME: allow user to change? - re.shaderRGBA[ 3 ] = (byte)( (float)0xFF * + re.shaderRGBA[ 3 ] = (byte)( (float)0xFF * CG_LerpValues( p->alpha.initial, p->alpha.final, CG_CalculateTimeFrac( p->birthTime, p->lifeTime, p->alpha.delay ) ) ); - + re.radius = CG_LerpValues( p->radius.initial, p->radius.final, CG_CalculateTimeFrac( p->birthTime, p->lifeTime, p->radius.delay ) ); - + re.rotation = CG_LerpValues( p->rotation.initial, p->rotation.final, CG_CalculateTimeFrac( p->birthTime, @@ -2185,10 +2185,10 @@ void CG_AddParticles( void ) int i; particle_t *p; int numPS = 0, numPE = 0, numP = 0; - + //remove expired particle systems CG_GarbageCollectParticleSystems( ); - + //check each ejector and introduce any new particles CG_SpawnNewParticles( ); @@ -2199,7 +2199,7 @@ void CG_AddParticles( void ) for( i = 0; i < MAX_PARTICLES; i++ ) { p = &particles[ i ]; - + if( p->valid ) { if( p->birthTime + p->lifeTime > cg.time ) @@ -2218,11 +2218,11 @@ void CG_AddParticles( void ) for( i = 0; i < MAX_PARTICLE_SYSTEMS; i++ ) if( particleSystems[ i ].valid ) numPS++; - + for( i = 0; i < MAX_PARTICLE_EJECTORS; i++ ) if( particleEjectors[ i ].valid ) numPE++; - + for( i = 0; i < MAX_PARTICLES; i++ ) if( particles[ i ].valid ) numP++; @@ -2243,7 +2243,7 @@ void CG_ParticleSystemEntity( centity_t *cent ) entityState_t *es; es = ¢->currentState; - + if( es->eFlags & EF_NODRAW ) { if( CG_IsParticleSystemValid( ¢->entityPS ) && CG_IsParticleSystemInfinite( cent->entityPS ) ) @@ -2251,7 +2251,7 @@ void CG_ParticleSystemEntity( centity_t *cent ) return; } - + if( !CG_IsParticleSystemValid( ¢->entityPS ) && !cent->entityPSMissing ) { cent->entityPS = CG_SpawnNewParticleSystem( cgs.gameParticleSystems[ es->modelindex ] ); diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index 280675ca..18a32efc 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "cg_local.h" char *cg_customSoundNames[ MAX_CUSTOM_SOUNDS ] = @@ -106,7 +106,7 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) CG_Printf( "File %s too long\n", filename ); return qfalse; } - + trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); @@ -127,7 +127,7 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) { prev = text_p; // so we can unget token = COM_Parse( &text_p ); - + if( !token ) break; @@ -166,13 +166,13 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) ci->headOffset[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "sex" ) ) { token = COM_Parse( &text_p ); - + if( !token ) break; @@ -182,7 +182,7 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) ci->gender = GENDER_NEUTER; else ci->gender = GENDER_MALE; - + continue; } else if( !Q_stricmp( token, "fixedlegs" ) ) @@ -207,7 +207,7 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) text_p = prev; // unget the token break; } - + Com_Printf( "unknown token '%s' is %s\n", token, filename ); } @@ -217,7 +217,7 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) for( i = 0; i < MAX_PLAYER_ANIMATIONS; i++ ) { token = COM_Parse( &text_p ); - + if( !*token ) { if( i >= TORSO_GETFLAG && i <= TORSO_NEGATIVE ) @@ -231,12 +231,12 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) animations[ i ].flipflop = qfalse; continue; } - + break; } - + animations[ i ].firstFrame = atoi( token ); - + // leg only frames are adjusted to not count the upper body only frames if( i == LEGS_WALKCR ) skip = animations[ LEGS_WALKCR ].firstFrame - animations[ TORSO_GESTURE ].firstFrame; @@ -247,11 +247,11 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) token = COM_Parse( &text_p ); if( !*token ) break; - + animations[ i ].numFrames = atoi( token ); animations[ i ].reversed = qfalse; animations[ i ].flipflop = qfalse; - + // if numFrames is negative the animation is reversed if( animations[ i ].numFrames < 0 ) { @@ -260,14 +260,14 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) } token = COM_Parse( &text_p ); - + if( !*token ) break; animations[ i ].loopFrames = atoi( token ); token = COM_Parse( &text_p ); - + if( !*token ) break; @@ -318,20 +318,20 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) for( i = 0; i < MAX_NONSEG_PLAYER_ANIMATIONS; i++ ) { token = COM_Parse( &text_p ); - + if( !*token ) break; - + animations[ i ].firstFrame = atoi( token ); - + token = COM_Parse( &text_p ); if( !*token ) break; - + animations[ i ].numFrames = atoi( token ); animations[ i ].reversed = qfalse; animations[ i ].flipflop = qfalse; - + // if numFrames is negative the animation is reversed if( animations[ i ].numFrames < 0 ) { @@ -340,14 +340,14 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) } token = COM_Parse( &text_p ); - + if( !*token ) break; animations[ i ].loopFrames = atoi( token ); token = COM_Parse( &text_p ); - + if( !*token ) break; @@ -364,7 +364,7 @@ static qboolean CG_ParseAnimationFile( const char *filename, clientInfo_t *ci ) CG_Printf( "Error parsing animation file: %s", filename ); return qfalse; } - + // walk backward animation memcpy( &animations[ NSPA_WALKBACK ], &animations[ NSPA_WALK ], sizeof( animation_t ) ); animations[ NSPA_WALKBACK ].reversed = qtrue; @@ -553,7 +553,7 @@ static void CG_LoadClientInfo( clientInfo_t *ci ) for( i = 0; i < MAX_CUSTOM_SOUNDS; i++ ) { s = cg_customSoundNames[ i ]; - + if( !s ) break; @@ -561,7 +561,7 @@ static void CG_LoadClientInfo( clientInfo_t *ci ) if( !CG_FileExists( va( "sound/player/%s/%s", dir, s + 1 ) ) ) { //file doesn't exist - + if( i == 11 || i == 8 ) //fall or falling { ci->sounds[ i ] = trap_S_RegisterSound( "sound/null.wav", qfalse ); @@ -572,7 +572,7 @@ static void CG_LoadClientInfo( clientInfo_t *ci ) s = cg_customSoundNames[ 7 ]; //pain100_1 else if( i == 10 ) //drown s = cg_customSoundNames[ 0 ]; //death1 - + ci->sounds[ i ] = trap_S_RegisterSound( va( "sound/player/%s/%s", dir, s + 1 ), qfalse ); if( !ci->sounds[ i ] ) ci->sounds[ i ] = trap_S_RegisterSound( va( "sound/player/%s/%s", fallback, s + 1 ), qfalse ); @@ -658,10 +658,10 @@ static int CG_GetCorpseNum( pClass_t class ) for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { match = &cgs.corpseinfo[ i ]; - + if( !match->infoValid ) continue; - + if( !Q_stricmp( modelName, match->modelName ) && !Q_stricmp( skinName, match->skinName ) ) { @@ -688,7 +688,7 @@ static qboolean CG_ScanForExistingClientInfo( clientInfo_t *ci ) for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { match = &cgs.corpseinfo[ i ]; - + if( !match->infoValid ) continue; @@ -741,8 +741,8 @@ void CG_PrecacheClientInfo( pClass_t class, char *model, char *skin ) newInfo.infoValid = qtrue; //TA: actually register the models - CG_LoadClientInfo( &newInfo ); *ci = newInfo; + CG_LoadClientInfo( ci ); } @@ -815,13 +815,13 @@ void CG_NewClientInfo( int clientNum ) v = Info_ValueForKey( configstring, "g_blueteam" ); Q_strncpyz( newInfo.blueTeam, v, MAX_TEAMNAME ); - + // model v = Info_ValueForKey( configstring, "model" ); Q_strncpyz( newInfo.modelName, v, sizeof( newInfo.modelName ) ); slash = strchr( newInfo.modelName, '/' ); - + if( !slash ) { // modelName didn not include a skin name @@ -841,7 +841,7 @@ void CG_NewClientInfo( int clientNum ) Q_strncpyz( newInfo.headModelName, v, sizeof( newInfo.headModelName ) ); slash = strchr( newInfo.headModelName, '/' ); - + if( !slash ) { // modelName didn not include a skin name @@ -854,14 +854,14 @@ void CG_NewClientInfo( int clientNum ) *slash = 0; } - // scan for an existing clientinfo that matches this modelname - // so we can avoid loading checks if possible - if( !CG_ScanForExistingClientInfo( &newInfo ) ) - CG_LoadClientInfo( &newInfo ); - // replace whatever was there with the new one newInfo.infoValid = qtrue; *ci = newInfo; + + // scan for an existing clientinfo that matches this modelname + // so we can avoid loading checks if possible + if( !CG_ScanForExistingClientInfo( ci ) ) + CG_LoadClientInfo( ci ); } @@ -938,19 +938,19 @@ static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation anim = lf->animation; if( !anim->frameLerp ) return; // shouldn't happen - + if( cg.time < lf->animationTime ) lf->frameTime = lf->animationTime; // initial lerp else lf->frameTime = lf->oldFrameTime + anim->frameLerp; - + f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp; f *= speedScale; // adjust for haste, etc numFrames = anim->numFrames; - + if( anim->flipflop ) numFrames *= 2; - + if( f >= numFrames ) { f -= numFrames; @@ -967,7 +967,7 @@ static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation lf->frameTime = cg.time; } } - + if( anim->reversed ) lf->frame = anim->firstFrame + anim->numFrames - 1 - f; else if( anim->flipflop && f>=anim->numFrames ) @@ -978,7 +978,7 @@ static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation if( cg.time > lf->frameTime ) { lf->frameTime = cg.time; - + if( cg_debugAnim.integer ) CG_Printf( "Clamp lf->frameTime\n" ); } @@ -989,7 +989,7 @@ static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation if( lf->oldFrameTime > cg.time ) lf->oldFrameTime = cg.time; - + // calculate current lerp value if( lf->frameTime == lf->oldFrameTime ) lf->backlerp = 0; @@ -1108,7 +1108,7 @@ static void CG_SwingAngles( float destination, float swingTolerance, float clamp { // see if a swing should be started swing = AngleSubtract( *angle, destination ); - + if( swing > swingTolerance || swing < -swingTolerance ) *swinging = qtrue; } @@ -1120,7 +1120,7 @@ static void CG_SwingAngles( float destination, float swingTolerance, float clamp // so it doesn't seem so linear swing = AngleSubtract( destination, *angle ); scale = fabs( swing ); - + if( scale < swingTolerance * 0.5 ) scale = 0.5; else if( scale < swingTolerance ) @@ -1132,7 +1132,7 @@ static void CG_SwingAngles( float destination, float swingTolerance, float clamp if( swing >= 0 ) { move = cg.frametime * scale * speed; - + if( move >= swing ) { move = swing; @@ -1143,7 +1143,7 @@ static void CG_SwingAngles( float destination, float swingTolerance, float clamp else if( swing < 0 ) { move = cg.frametime * scale * -speed; - + if( move <= swing ) { move = swing; @@ -1171,7 +1171,7 @@ static void CG_AddPainTwitch( centity_t *cent, vec3_t torsoAngles ) float f; t = cg.time - cent->pe.painTime; - + if( t >= PAIN_TWITCH_TIME ) return; @@ -1239,7 +1239,7 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, if( dir < 0 || dir > 7 ) CG_Error( "Bad player movement angle" ); } - + legsAngles[ YAW ] = headAngles[ YAW ] + movementOffsets[ dir ]; torsoAngles[ YAW ] = headAngles[ YAW ] + 0.25 * movementOffsets[ dir ]; @@ -1258,7 +1258,7 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, CG_SwingAngles( legsAngles[ YAW ], 40, 90, cg_swingSpeed.value, ¢->pe.legs.yawAngle, ¢->pe.legs.yawing ); } - + torsoAngles[ YAW ] = cent->pe.torso.yawAngle; legsAngles[ YAW ] = cent->pe.legs.yawAngle; @@ -1275,7 +1275,7 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, // clientNum = cent->currentState.clientNum; - + if( clientNum >= 0 && clientNum < MAX_CLIENTS ) { ci = &cgs.clientinfo[ clientNum ]; @@ -1289,7 +1289,7 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, // lean towards the direction of travel VectorCopy( cent->currentState.pos.trDelta, velocity ); speed = VectorNormalize( velocity ); - + if( speed ) { vec3_t axis[ 3 ]; @@ -1311,7 +1311,7 @@ static void CG_PlayerAngles( centity_t *cent, vec3_t srcAngles, if( clientNum >= 0 && clientNum < MAX_CLIENTS ) { ci = &cgs.clientinfo[ clientNum ]; - + if( ci->fixedlegs ) { legsAngles[ YAW ] = torsoAngles[ YAW ]; @@ -1349,7 +1349,7 @@ static void CG_PlayerWWSmoothing( centity_t *cent, vec3_t in[ 3 ], vec3_t out[ 3 vec3_t ceilingNormal = { 0.0f, 0.0f, -1.0f }; float stLocal, sFraction, rotAngle; vec3_t inAxis[ 3 ], lastAxis[ 3 ], outAxis[ 3 ]; - + //set surfNormal if( !( es->eFlags & EF_WALLCLIMBCEILING ) ) VectorCopy( es->angles2, surfNormal ); @@ -1386,7 +1386,7 @@ static void CG_PlayerWWSmoothing( centity_t *cent, vec3_t in[ 3 ], vec3_t out[ 3 VectorNormalize( rotAxis ); } - + //iterate through smooth array for( i = 0; i < MAXSMOOTHS; i++ ) { @@ -1401,7 +1401,7 @@ static void CG_PlayerWWSmoothing( centity_t *cent, vec3_t in[ 3 ], vec3_t out[ 3 } } } - + //iterate through ops for( i = MAXSMOOTHS - 1; i >= 0; i-- ) { @@ -1461,7 +1461,7 @@ static void CG_PlayerNonSegAngles( centity_t *cent, vec3_t srcAngles, vec3_t non cent->pe.nonseg.yawAngle = localAngles[ YAW ]; cent->pe.nonseg.yawing = qfalse; } - + // --------- yaw ------------- // allow yaw to drift a bit @@ -1484,7 +1484,7 @@ static void CG_PlayerNonSegAngles( centity_t *cent, vec3_t srcAngles, vec3_t non if( dir < 0 || dir > 7 ) CG_Error( "Bad player movement angle" ); } - + // torso if( cent->currentState.eFlags & EF_DEAD ) { @@ -1496,21 +1496,21 @@ static void CG_PlayerNonSegAngles( centity_t *cent, vec3_t srcAngles, vec3_t non CG_SwingAngles( localAngles[ YAW ], 40, 90, cg_swingSpeed.value, ¢->pe.nonseg.yawAngle, ¢->pe.nonseg.yawing ); } - + localAngles[ YAW ] = cent->pe.nonseg.yawAngle; // --------- pitch ------------- //NO PITCH! - + // --------- roll ------------- // lean towards the direction of travel VectorCopy( cent->currentState.pos.trDelta, velocity ); speed = VectorNormalize( velocity ); - + if( speed ) { vec3_t axis[ 3 ]; @@ -1559,7 +1559,7 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso ) VectorCopy( torso->lightingOrigin, jetpack.lightingOrigin ); jetpack.shadowPlane = torso->shadowPlane; jetpack.renderfx = torso->renderfx; - + jetpack.hModel = cgs.media.jetpackModel; //identity matrix @@ -1569,7 +1569,7 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso ) CG_PositionRotatedEntityOnTag( &jetpack, torso, torso->hModel, "tag_head" ); trap_R_AddRefEntityToScene( &jetpack ); - + if( active & ( 1 << UP_JETPACK ) ) { if( es->pos.trDelta[ 2 ] > 10.0f ) @@ -1578,11 +1578,11 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso ) { if( CG_IsParticleSystemValid( ¢->jetPackPS ) ) CG_DestroyParticleSystem( ¢->jetPackPS ); - + cent->jetPackPS = CG_SpawnNewParticleSystem( cgs.media.jetPackAscendPS ); cent->jetPackState = JPS_ASCENDING; } - + trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.media.jetpackAscendSound ); } @@ -1592,11 +1592,11 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso ) { if( CG_IsParticleSystemValid( ¢->jetPackPS ) ) CG_DestroyParticleSystem( ¢->jetPackPS ); - + cent->jetPackPS = CG_SpawnNewParticleSystem( cgs.media.jetPackDescendPS ); cent->jetPackState = JPS_DESCENDING; } - + trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.media.jetpackDescendSound ); } @@ -1606,15 +1606,15 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso ) { if( CG_IsParticleSystemValid( ¢->jetPackPS ) ) CG_DestroyParticleSystem( ¢->jetPackPS ); - + cent->jetPackPS = CG_SpawnNewParticleSystem( cgs.media.jetPackHoverPS ); cent->jetPackState = JPS_HOVERING; } - + trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, cgs.media.jetpackIdleSound ); } - + memset( &flash, 0, sizeof( flash ) ); VectorCopy( torso->lightingOrigin, flash.lightingOrigin ); flash.shadowPlane = torso->shadowPlane; @@ -1628,7 +1628,7 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso ) CG_PositionRotatedEntityOnTag( &flash, &jetpack, jetpack.hModel, "tag_flash" ); trap_R_AddRefEntityToScene( &flash ); - + if( CG_IsParticleSystemValid( ¢->jetPackPS ) ) { CG_SetParticleSystemTag( cent->jetPackPS, jetpack, jetpack.hModel, "tag_flash" ); @@ -1654,7 +1654,7 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso ) VectorCopy( torso->lightingOrigin, battpack.lightingOrigin ); battpack.shadowPlane = torso->shadowPlane; battpack.renderfx = torso->renderfx; - + battpack.hModel = cgs.media.battpackModel; //identity matrix @@ -1665,13 +1665,13 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso ) trap_R_AddRefEntityToScene( &battpack ); } - + if( es->eFlags & EF_BLOBLOCKED ) { vec3_t temp, origin, up = { 0.0f, 0.0f, 1.0f }; trace_t tr; float size; - + VectorCopy( es->pos.trBase, temp ); temp[ 2 ] -= 4096.0f; @@ -1764,7 +1764,7 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane, pClass_t c BG_FindBBoxForClass( class, mins, maxs, NULL, NULL, NULL ); mins[ 2 ] = 0.0f; maxs[ 2 ] = 2.0f; - + if( es->eFlags & EF_WALLCLIMB ) { if( es->eFlags & EF_WALLCLIMBCEILING ) @@ -1772,7 +1772,7 @@ static qboolean CG_PlayerShadow( centity_t *cent, float *shadowPlane, pClass_t c else VectorCopy( es->angles2, surfNormal ); } - + *shadowPlane = 0; if( cg_shadows.integer == 0 ) @@ -1836,7 +1836,7 @@ static void CG_PlayerSplash( centity_t *cent ) // if the feet aren't in liquid, don't make a mark // this won't handle moving water brushes, but they wouldn't draw right anyway... contents = trap_CM_PointContents( end, 0 ); - + if( !( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) ) return; @@ -1845,7 +1845,7 @@ static void CG_PlayerSplash( centity_t *cent ) // if the head isn't out of liquid, don't make a mark contents = trap_CM_PointContents( start, 0 ); - + if( contents & ( CONTENTS_SOLID | CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) return; @@ -1918,7 +1918,7 @@ int CG_LightVerts( vec3_t normal, int numVerts, polyVert_t *verts ) for( i = 0; i < numVerts; i++ ) { incoming = DotProduct( normal, lightDir ); - + if( incoming <= 0 ) { verts[ i ].modulate[ 0 ] = ambientLight[ 0 ]; @@ -1926,24 +1926,24 @@ int CG_LightVerts( vec3_t normal, int numVerts, polyVert_t *verts ) verts[ i ].modulate[ 2 ] = ambientLight[ 2 ]; verts[ i ].modulate[ 3 ] = 255; continue; - } - + } + j = ( ambientLight[ 0 ] + incoming * directedLight[ 0 ] ); - + if( j > 255 ) j = 255; - + verts[ i ].modulate[ 0 ] = j; j = ( ambientLight[ 1 ] + incoming * directedLight[ 1 ] ); - + if( j > 255 ) j = 255; verts[ i ].modulate[ 1 ] = j; j = ( ambientLight[ 2 ] + incoming * directedLight[ 2 ] ); - + if( j > 255 ) j = 255; @@ -1972,7 +1972,7 @@ int CG_LightFromDirection( vec3_t point, vec3_t direction ) trap_R_LightForPoint( point, ambientLight, directedLight, lightDir ); incoming = DotProduct( direction, lightDir ); - + if( incoming <= 0 ) { result[ 0 ] = ambientLight[ 0 ]; @@ -1980,23 +1980,23 @@ int CG_LightFromDirection( vec3_t point, vec3_t direction ) result[ 2 ] = ambientLight[ 2 ]; return (int)( (float)( result[ 0 ] + result[ 1 ] + result[ 2 ] ) / 3.0f ); } - + j = ( ambientLight[ 0 ] + incoming * directedLight[ 0 ] ); - + if( j > 255 ) j = 255; result[ 0 ] = j; j = ( ambientLight[ 1 ] + incoming * directedLight[ 1 ] ); - + if( j > 255 ) j = 255; result[ 1 ] = j; j = ( ambientLight[ 2 ] + incoming * directedLight[ 2 ] ); - + if( j > 255 ) j = 255; @@ -2036,7 +2036,7 @@ CG_Player void CG_Player( centity_t *cent ) { clientInfo_t *ci; - + //TA: NOTE: legs is used for nonsegmented models // this helps reduce code to be changed refEntity_t legs; @@ -2089,7 +2089,7 @@ void CG_Player( centity_t *cent ) BG_FindBBoxForClass( class, mins, maxs, NULL, NULL, NULL ); CG_DrawBoundingBox( cent->lerpOrigin, mins, maxs ); } - + memset( &legs, 0, sizeof( legs ) ); memset( &torso, 0, sizeof( torso ) ); memset( &head, 0, sizeof( head ) ); @@ -2103,7 +2103,7 @@ void CG_Player( centity_t *cent ) AxisToAngles( tempAxis2, angles ); else VectorCopy( cent->lerpAngles, angles ); - + //normalise the pitch if( angles[ PITCH ] < -180.0f ) angles[ PITCH ] += 360.0f; @@ -2115,7 +2115,7 @@ void CG_Player( centity_t *cent ) CG_PlayerNonSegAngles( cent, angles, legs.axis ); AxisCopy( legs.axis, tempAxis ); - + //rotate the legs axis to back to the wall if( es->eFlags & EF_WALLCLIMB && BG_RotateAxis( es->angles2, legs.axis, tempAxis, qfalse, es->eFlags & EF_WALLCLIMBCEILING ) ) @@ -2184,7 +2184,7 @@ void CG_Player( centity_t *cent ) VectorSet( surfNormal, 0.0f, 0.0f, -1.0f ); else VectorCopy( es->angles2, surfNormal ); - + BG_FindBBoxForClass( class, mins, maxs, NULL, NULL, NULL ); VectorMA( legs.origin, -TRACE_DEPTH, surfNormal, end ); @@ -2208,7 +2208,7 @@ void CG_Player( centity_t *cent ) VectorScale( legs.axis[ 0 ], scale, legs.axis[ 0 ] ); VectorScale( legs.axis[ 1 ], scale, legs.axis[ 1 ] ); VectorScale( legs.axis[ 2 ], scale, legs.axis[ 2 ] ); - + legs.nonNormalizedAxes = qtrue; } @@ -2216,7 +2216,7 @@ void CG_Player( centity_t *cent ) VectorMA( legs.origin, BG_FindZOffsetForClass( class ), surfNormal, legs.origin ); VectorCopy( legs.origin, legs.lightingOrigin ); VectorCopy( legs.origin, legs.oldorigin ); // don't positionally lerp at all - + trap_R_AddRefEntityToScene( &legs ); // if the model failed, allow the default nullmodel to be displayed @@ -2234,7 +2234,7 @@ void CG_Player( centity_t *cent ) torso.customSkin = cgs.media.larmourTorsoSkin; else torso.customSkin = ci->torsoSkin; - + if( !torso.hModel ) return; @@ -2256,7 +2256,7 @@ void CG_Player( centity_t *cent ) head.customSkin = cgs.media.larmourHeadSkin; else head.customSkin = ci->headSkin; - + if( !head.hModel ) return; @@ -2285,11 +2285,11 @@ void CG_Player( centity_t *cent ) { if( CG_IsParticleSystemValid( ¢->muzzlePS ) ) CG_DestroyParticleSystem( ¢->muzzlePS ); - + if( CG_IsParticleSystemValid( ¢->jetPackPS ) ) CG_DestroyParticleSystem( ¢->jetPackPS ); } - + VectorCopy( surfNormal, cent->pe.lastNormal ); } @@ -2313,12 +2313,12 @@ void CG_Corpse( centity_t *cent ) float scale; corpseNum = CG_GetCorpseNum( es->clientNum ); - + if( corpseNum < 0 || corpseNum >= MAX_CLIENTS ) CG_Error( "Bad corpseNum on corpse entity: %d", corpseNum ); ci = &cgs.corpseinfo[ corpseNum ]; - + // it is possible to see corpses from disconnected players that may // not have valid clientinfo if( !ci->infoValid ) @@ -2333,7 +2333,7 @@ void CG_Corpse( centity_t *cent ) origin[ 2 ] -= ( liveZ[ 2 ] - deadZ[ 2 ] ); VectorCopy( es->angles, cent->lerpAngles ); - + // get the rotation information if( !ci->nonsegmented ) CG_PlayerAngles( cent, cent->lerpAngles, legs.axis, torso.axis, head.axis ); @@ -2407,10 +2407,10 @@ void CG_Corpse( centity_t *cent ) VectorScale( legs.axis[ 0 ], scale, legs.axis[ 0 ] ); VectorScale( legs.axis[ 1 ], scale, legs.axis[ 1 ] ); VectorScale( legs.axis[ 2 ], scale, legs.axis[ 2 ] ); - + legs.nonNormalizedAxes = qtrue; } - + //CG_AddRefEntityWithPowerups( &legs, es->powerups, ci->team ); trap_R_AddRefEntityToScene( &legs ); diff --git a/src/cgame/cg_playerstate.c b/src/cgame/cg_playerstate.c index df568cdd..4837df9b 100644 --- a/src/cgame/cg_playerstate.c +++ b/src/cgame/cg_playerstate.c @@ -41,7 +41,7 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) // the lower on health you are, the greater the view kick will be health = cg.snap->ps.stats[STAT_HEALTH]; - + if( health < 40 ) scale = 1; else @@ -51,7 +51,7 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) if( kick < 5 ) kick = 5; - + if( kick > 10 ) kick = 10; @@ -84,12 +84,12 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) dir[ 1 ] = left; dir[ 2 ] = 0; dist = VectorLength( dir ); - + if( dist < 0.1f ) dist = 0.1f; cg.v_dmg_roll = kick * left; - + cg.v_dmg_pitch = -kick * front; if( front <= 0.1 ) @@ -102,7 +102,7 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) // clamp the position if( cg.damageX > 1.0 ) cg.damageX = 1.0; - + if( cg.damageX < - 1.0 ) cg.damageX = -1.0; @@ -200,7 +200,7 @@ void CG_CheckChangedPredictableEvents( playerState_t *ps ) centity_t *cent; cent = &cg.predictedPlayerEntity; - + for( i = ps->eventSequence - MAX_PS_EVENTS; i < ps->eventSequence; i++ ) { // diff --git a/src/cgame/cg_predict.c b/src/cgame/cg_predict.c index d66fd653..dc6c9dd5 100644 --- a/src/cgame/cg_predict.c +++ b/src/cgame/cg_predict.c @@ -129,7 +129,7 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const if( i == cg_numSolidEntities ) BG_FindBBoxForClass( ( ent->powerups >> 8 ) & 0xFF, bmins, bmaxs, NULL, NULL, NULL ); - + cmodel = trap_CM_TempBoxModel( bmins, bmaxs ); VectorCopy( vec3_origin, angles ); VectorCopy( cent->lerpOrigin, origin ); @@ -154,7 +154,7 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const } else if( trace.startsolid ) tr->startsolid = qtrue; - + if( tr->allsolid ) return; } @@ -165,7 +165,7 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const CG_Trace ================ */ -void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, +void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int skipNumber, int mask ) { trace_t t; @@ -183,7 +183,7 @@ void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const ve CG_CapTrace ================ */ -void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, +void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int skipNumber, int mask ) { trace_t t; @@ -224,7 +224,7 @@ int CG_PointContents( const vec3_t point, int passEntityNum ) continue; cmodel = trap_CM_InlineModel( ent->modelindex ); - + if( !cmodel ) continue; @@ -280,16 +280,16 @@ static void CG_InterpolatePlayerState( qboolean grabAngles ) i = next->ps.bobCycle; if( i < prev->ps.bobCycle ) i += 256; // handle wraparound - + out->bobCycle = prev->ps.bobCycle + f * ( i - prev->ps.bobCycle ); for( i = 0; i < 3; i++ ) { out->origin[ i ] = prev->ps.origin[ i ] + f * ( next->ps.origin[ i ] - prev->ps.origin[ i ] ); - + if( !grabAngles ) out->viewangles[ i ] = LerpAngle( prev->ps.viewangles[ i ], next->ps.viewangles[ i ], f ); - + out->velocity[ i ] = prev->ps.velocity[ i ] + f * (next->ps.velocity[ i ] - prev->ps.velocity[ i ] ); } @@ -341,8 +341,6 @@ static void CG_TouchTriggerPrediction( void ) if( ent->eType == ET_TELEPORT_TRIGGER ) cg.hyperspace = qtrue; - else if( ent->eType == ET_PUSH_TRIGGER ) - BG_TouchJumpPad( &cg.predictedPlayerState, ent ); } // if we didn't touch a jump pad this pmove frame @@ -425,7 +423,7 @@ void CG_PredictPlayerState( void ) cg_pmove.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; else cg_pmove.tracemask = MASK_PLAYERSOLID; - + if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) cg_pmove.tracemask &= ~CONTENTS_BODY; // spectators can fly through bodies @@ -441,13 +439,13 @@ void CG_PredictPlayerState( void ) // the last good position we had cmdNum = current - CMD_BACKUP + 1; trap_GetUserCmd( cmdNum, &oldestCmd ); - + if( oldestCmd.serverTime > cg.snap->ps.commandTime && oldestCmd.serverTime < cg.time ) { // special check for map_restart if( cg_showmiss.integer ) CG_Printf( "exceeded PACKET_BACKUP on commands\n" ); - + return; } @@ -479,7 +477,7 @@ void CG_PredictPlayerState( void ) // run cmds moved = qfalse; - + for( cmdNum = current - CMD_BACKUP + 1; cmdNum <= current; cmdNum++ ) { // get the command @@ -510,10 +508,10 @@ void CG_PredictPlayerState( void ) { // a teleport will not cause an error decay VectorClear( cg.predictedError ); - + if( cg_showmiss.integer ) CG_Printf( "PredictionTeleport\n" ); - + cg.thisFrameTeleport = qfalse; } else @@ -527,10 +525,10 @@ void CG_PredictPlayerState( void ) if( !VectorCompare( oldPlayerState.origin, adjusted ) ) CG_Printf("prediction error\n"); } - + VectorSubtract( oldPlayerState.origin, adjusted, delta ); len = VectorLength( delta ); - + if( len > 0.1 ) { if( cg_showmiss.integer ) @@ -543,18 +541,18 @@ void CG_PredictPlayerState( void ) t = cg.time - cg.predictedErrorTime; f = ( cg_errorDecay.value - t ) / cg_errorDecay.value; - + if( f < 0 ) f = 0; if( f > 0 && cg_showmiss.integer ) CG_Printf( "Double prediction decay: %f\n", f ); - + VectorScale( cg.predictedError, f, cg.predictedError ); } else VectorClear( cg.predictedError ); - + VectorAdd( delta, cg.predictedError, cg.predictedError ); cg.predictedErrorTime = cg.oldTime; } diff --git a/src/cgame/cg_ptr.c b/src/cgame/cg_ptr.c index e0aaaf64..c31e5e40 100644 --- a/src/cgame/cg_ptr.c +++ b/src/cgame/cg_ptr.c @@ -38,7 +38,7 @@ int CG_ReadPTRCode( void ) // should never happen - malformed write if( len >= sizeof( text ) - 1 ) return 0; - + trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); @@ -59,13 +59,13 @@ void CG_WritePTRCode( int code ) fileHandle_t f; Com_sprintf( text, 16, "%d", code ); - + // open file if( trap_FS_FOpenFile( PTRC_FILE, &f, FS_WRITE ) < 0 ) return; // write the code trap_FS_Write( text, strlen( text ), f ); - + trap_FS_FCloseFile( f ); } diff --git a/src/cgame/cg_public.h b/src/cgame/cg_public.h index ecc948c1..39d1a402 100644 --- a/src/cgame/cg_public.h +++ b/src/cgame/cg_public.h @@ -14,7 +14,7 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ -#define CMD_BACKUP 64 +#define CMD_BACKUP 64 #define CMD_MASK (CMD_BACKUP - 1) // allow a lot of command backups for very fast systems // multiple commands may be combined into a single packet, so this @@ -215,7 +215,7 @@ typedef enum CG_LAST_ATTACKER, // int (*CG_LastAttacker)( void ); - CG_KEY_EVENT, + CG_KEY_EVENT, // void (*CG_KeyEvent)( int key, qboolean down ); CG_MOUSE_EVENT, diff --git a/src/cgame/cg_scanner.c b/src/cgame/cg_scanner.c index c0686865..6c2a9997 100644 --- a/src/cgame/cg_scanner.c +++ b/src/cgame/cg_scanner.c @@ -38,7 +38,7 @@ void CG_UpdateEntityPositions( void ) VectorCopy( cg.refdef.vieworg, entityPositions.origin ); VectorCopy( cg.refdefViewAngles, entityPositions.vangles ); entityPositions.lastUpdateTime = cg.time; - + entityPositions.numAlienBuildables = 0; entityPositions.numHumanBuildables = 0; entityPositions.numAlienClients = 0; @@ -47,7 +47,7 @@ void CG_UpdateEntityPositions( void ) for( i = 0; i < cg.snap->numEntities; i++ ) { cent = &cg_entities[ cg.snap->entities[ i ].number ]; - + if( cent->currentState.eType == ET_BUILDABLE ) { //TA: add to list of item positions (for creep) @@ -57,7 +57,7 @@ void CG_UpdateEntityPositions( void ) entityPositions.numAlienBuildables ] ); entityPositions.alienBuildableTimes[ entityPositions.numAlienBuildables ] = cent->miscTime; - + if( entityPositions.numAlienBuildables < MAX_GENTITIES ) entityPositions.numAlienBuildables++; } @@ -86,7 +86,7 @@ void CG_UpdateEntityPositions( void ) { VectorCopy( cent->lerpOrigin, entityPositions.humanClientPos[ entityPositions.numHumanClients ] ); - + if( entityPositions.numHumanClients < MAX_CLIENTS ) entityPositions.numHumanClients++; } @@ -126,7 +126,7 @@ static void CG_DrawBlips( rectDef_t *rect, vec3_t origin, vec4_t colour ) alphaMod = FAR_ALPHA + ( ( drawOrigin[ 1 ] + ( rect->h / 2.0f ) ) / rect->h ) * ( NEAR_ALPHA - FAR_ALPHA ); - + localColour[ 3 ] *= alphaMod; localColour[ 3 ] *= ( 0.5f + ( timeFractionSinceRefresh * 0.5f ) ); @@ -145,7 +145,7 @@ static void CG_DrawBlips( rectDef_t *rect, vec3_t origin, vec4_t colour ) CG_DrawPic( rect->x + ( rect->w / 2 ) - ( STALKWIDTH / 2 ) - drawOrigin[ 0 ], rect->y + ( rect->h / 2 ) + drawOrigin[ 1 ], STALKWIDTH, -drawOrigin[ 2 ], cgs.media.scannerLineShader ); - + CG_DrawPic( rect->x + ( rect->w / 2 ) - ( BLIPX / 2 ) - drawOrigin[ 0 ], rect->y + ( rect->h / 2 ) - ( BLIPY / 2 ) + drawOrigin[ 1 ] - drawOrigin[ 2 ], BLIPX, BLIPY, cgs.media.scannerBlipShader ); @@ -184,7 +184,7 @@ static void CG_DrawDir( rectDef_t *rect, vec3_t origin, vec4_t colour ) VectorSet( normal, 0.0f, 0.0f, 1.0f ); AngleVectors( entityPositions.vangles, view, NULL, NULL ); - + ProjectPointOnPlane( noZOrigin, origin, normal ); ProjectPointOnPlane( noZview, view, normal ); VectorNormalize( noZOrigin ); @@ -221,9 +221,9 @@ void CG_AlienSense( rectDef_t *rect ) vec3_t relOrigin; vec4_t buildable = { 1.0f, 0.0f, 0.0f, 0.7f }; vec4_t client = { 0.0f, 0.0f, 1.0f, 0.7f }; - + VectorCopy( entityPositions.origin, origin ); - + //draw human buildables for( i = 0; i < entityPositions.numHumanBuildables; i++ ) { @@ -233,7 +233,7 @@ void CG_AlienSense( rectDef_t *rect ) if( VectorLength( relOrigin ) < ALIENSENSE_RANGE ) CG_DrawDir( rect, relOrigin, buildable ); } - + //draw human clients for( i = 0; i < entityPositions.numHumanClients; i++ ) { @@ -259,13 +259,13 @@ void CG_Scanner( rectDef_t *rect, qhandle_t shader, vec4_t color ) vec4_t hIbelow; vec4_t aIabove = { 1.0f, 0.0f, 0.0f, 0.75f }; vec4_t aIbelow = { 1.0f, 0.0f, 0.0f, 0.5f }; - + Vector4Copy( color, hIabove ); hIabove[ 3 ] *= 1.5f; Vector4Copy( color, hIbelow ); - + VectorCopy( entityPositions.origin, origin ); - + //draw human buildables below scanner plane for( i = 0; i < entityPositions.numHumanBuildables; i++ ) { @@ -275,7 +275,7 @@ void CG_Scanner( rectDef_t *rect, qhandle_t shader, vec4_t color ) if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] < 0 ) ) CG_DrawBlips( rect, relOrigin, hIbelow ); } - + //draw alien buildables below scanner plane for( i = 0; i < entityPositions.numAlienBuildables; i++ ) { @@ -285,7 +285,7 @@ void CG_Scanner( rectDef_t *rect, qhandle_t shader, vec4_t color ) if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] < 0 ) ) CG_DrawBlips( rect, relOrigin, aIbelow ); } - + //draw human clients below scanner plane for( i = 0; i < entityPositions.numHumanClients; i++ ) { @@ -295,7 +295,7 @@ void CG_Scanner( rectDef_t *rect, qhandle_t shader, vec4_t color ) if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] < 0 ) ) CG_DrawBlips( rect, relOrigin, hIbelow ); } - + //draw alien buildables below scanner plane for( i = 0; i < entityPositions.numAlienClients; i++ ) { @@ -305,14 +305,14 @@ void CG_Scanner( rectDef_t *rect, qhandle_t shader, vec4_t color ) if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] < 0 ) ) CG_DrawBlips( rect, relOrigin, aIbelow ); } - + if( !cg_disableScannerPlane.integer ) { trap_R_SetColor( color ); CG_DrawPic( rect->x, rect->y, rect->w, rect->h, shader ); trap_R_SetColor( NULL ); } - + //draw human buildables above scanner plane for( i = 0; i < entityPositions.numHumanBuildables; i++ ) { @@ -332,7 +332,7 @@ void CG_Scanner( rectDef_t *rect, qhandle_t shader, vec4_t color ) if( VectorLength( relOrigin ) < HELMET_RANGE && ( relOrigin[ 2 ] > 0 ) ) CG_DrawBlips( rect, relOrigin, aIabove ); } - + //draw human clients above scanner plane for( i = 0; i < entityPositions.numHumanClients; i++ ) { diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index 3f73fb75..e2391127 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -30,7 +30,7 @@ static void CG_ParseScores( void ) int i; cg.numScores = atoi( CG_Argv( 1 ) ); - + if( cg.numScores > MAX_CLIENTS ) cg.numScores = MAX_CLIENTS; @@ -38,7 +38,7 @@ static void CG_ParseScores( void ) cg.teamScores[ 1 ] = atoi( CG_Argv( 3 ) ); memset( cg.scores, 0, sizeof( cg.scores ) ); - + if( cg_debugRandom.integer ) CG_Printf( "cg.numScores: %d\n", cg.numScores ); @@ -54,12 +54,12 @@ static void CG_ParseScores( void ) if( cg.scores[ i ].client < 0 || cg.scores[ i ].client >= MAX_CLIENTS ) cg.scores[ i ].client = 0; - + cgs.clientinfo[ cg.scores[ i ].client ].score = cg.scores[ i ].score; cgs.clientinfo[ cg.scores[ i ].client ].powerups = 0; cg.scores[ i ].team = cgs.clientinfo[ cg.scores[ i ].client ].team; - } + } } /* @@ -156,7 +156,7 @@ void CG_SetConfigValues( void ) sscanf( CG_ConfigString( CS_STAGES ), "%d %d %d %d %d %d", &cgs.alienStage, &cgs.humanStage, &cgs.alienKills, &cgs.humanKills, &cgs.alienNextStageThreshold, &cgs.humanNextStageThreshold ); sscanf( CG_ConfigString( CS_SPAWNS ), "%d %d", &cgs.numAlienSpawns, &cgs.numHumanSpawns ); - + cgs.levelStartTime = atoi( CG_ConfigString( CS_LEVEL_START_TIME ) ); cg.warmup = atoi( CG_ConfigString( CS_WARMUP ) ); } @@ -176,18 +176,18 @@ void CG_ShaderStateChanged( void ) char *n, *t; o = CG_ConfigString( CS_SHADERSTATE ); - + while( o && *o ) { n = strstr( o, "=" ); - + if( n && *n ) { strncpy( originalShader, o, n - o ); originalShader[ n - o ] = 0; n++; t = strstr( n, ":" ); - + if( t && *t ) { strncpy( newShader, n, t - n ); @@ -195,10 +195,10 @@ void CG_ShaderStateChanged( void ) } else break; - + t++; o = strstr( t, "@" ); - + if( o ) { strncpy( timeOffset, t, o - t ); @@ -281,15 +281,15 @@ static void CG_ConfigStringModified( void ) { stage_t oldAlienStage = cgs.alienStage; stage_t oldHumanStage = cgs.humanStage; - + sscanf( str, "%d %d %d %d %d %d", &cgs.alienStage, &cgs.humanStage, &cgs.alienKills, &cgs.humanKills, &cgs.alienNextStageThreshold, &cgs.humanNextStageThreshold ); - + if( cgs.alienStage != oldAlienStage ) CG_AnnounceAlienStageTransistion( oldAlienStage, cgs.alienStage ); - + if( cgs.humanStage != oldHumanStage ) CG_AnnounceHumanStageTransistion( oldHumanStage, cgs.humanStage ); } @@ -322,7 +322,7 @@ static void CG_ConfigStringModified( void ) else if( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1 ) { int cs_offset = num - CS_TEAMVOTE_TIME; - + cgs.teamVoteTime[ cs_offset ] = atoi( str ); cgs.teamVoteModified[ cs_offset ] = qtrue; @@ -426,7 +426,7 @@ static void CG_AddToTeamChat( const char *str ) str++; p -= ( p - ls ); } - + *p = 0; cgs.teamChatMsgTimes[ cgs.teamChatPos % chatHeight ] = cg.time; @@ -447,10 +447,10 @@ static void CG_AddToTeamChat( const char *str ) *p++ = *str++; continue; } - + if( *str == ' ' ) ls = p; - + *p++ = *str++; len++; } @@ -484,9 +484,9 @@ static void CG_MapRestart( void ) CG_InitLocalEntities( ); CG_InitMarkPolys( ); - // Ridah, trails - CG_ClearTrails( ); - // done. + // Ridah, trails + CG_ClearTrails( ); + // done. // make sure the "3 frags left" warnings play again cg.fraglimitWarnings = 0; @@ -526,7 +526,7 @@ static void CG_RemoveChatEscapeChar( char *text ) { if( text[ i ] == '\x19' ) continue; - + text[ l++ ] = text[ i ]; } @@ -546,7 +546,7 @@ static void CG_SetUIVars( void ) char carriageCvar[ MAX_TOKEN_CHARS ]; *carriageCvar = 0; - + //determine what the player is carrying for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) { @@ -561,12 +561,12 @@ static void CG_SetUIVars( void ) strcat( carriageCvar, va( "U%d ", i ) ); } strcat( carriageCvar, "$" ); - + trap_Cvar_Set( "ui_carriage", carriageCvar ); - + trap_Cvar_Set( "ui_stages", va( "%d %d", cgs.alienStage, cgs.humanStage ) ); } - + /* ============== @@ -585,7 +585,7 @@ void CG_Menu( int menu ) case MN_A_BUILD: trap_SendConsoleCommand( "menu tremulous_alienbuild\n" ); break; case MN_H_BUILD: trap_SendConsoleCommand( "menu tremulous_humanbuild\n" ); break; case MN_H_ARMOURY: trap_SendConsoleCommand( "menu tremulous_humanarmoury\n" ); break; - + case MN_A_TEAMFULL: trap_Cvar_Set( "ui_dialog", "The alien team has too many players. Please wait until " "slots become available or join the human team." ); @@ -607,9 +607,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There is no room to build here\n" ); - + break; - + case MN_H_NOPOWER: if( !cg_disableWarningDialogs.integer ) { @@ -619,9 +619,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There is no power remaining\n" ); - + break; - + case MN_H_NOTPOWERED: if( !cg_disableWarningDialogs.integer ) { @@ -631,9 +631,9 @@ void CG_Menu( int menu ) } else CG_Printf( "This buildable is not powered\n" ); - + break; - + case MN_H_NORMAL: if( !cg_disableWarningDialogs.integer ) { @@ -643,9 +643,9 @@ void CG_Menu( int menu ) } else CG_Printf( "Cannot build on this surface\n" ); - + break; - + case MN_H_REACTOR: if( !cg_disableWarningDialogs.integer ) { @@ -655,9 +655,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There can only be one Reactor\n" ); - + break; - + case MN_H_REPEATER: if( !cg_disableWarningDialogs.integer ) { @@ -667,9 +667,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There is no power here\n" ); - + break; - + case MN_H_NODCC: if( !cg_disableWarningDialogs.integer ) { @@ -679,9 +679,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There is no Defense Computer\n" ); - + break; - + case MN_H_TNODEWARN: if( !cg_disableWarningDialogs.integer ) { @@ -691,9 +691,9 @@ void CG_Menu( int menu ) } else CG_Printf( "This Telenode will not be powered\n" ); - + break; - + case MN_H_RPTWARN: if( !cg_disableWarningDialogs.integer ) { @@ -703,9 +703,9 @@ void CG_Menu( int menu ) } else CG_Printf( "This Repeater will not be powered\n" ); - + break; - + case MN_H_RPTWARN2: if( !cg_disableWarningDialogs.integer ) { @@ -714,9 +714,9 @@ void CG_Menu( int menu ) } else CG_Printf( "This area already has power\n" ); - + break; - + case MN_H_NOSLOTS: if( !cg_disableWarningDialogs.integer ) { @@ -726,9 +726,9 @@ void CG_Menu( int menu ) } else CG_Printf( "You have no room to carry this\n" ); - + break; - + case MN_H_NOFUNDS: if( !cg_disableWarningDialogs.integer ) { @@ -738,9 +738,9 @@ void CG_Menu( int menu ) } else CG_Printf( "Insufficient funds\n" ); - + break; - + case MN_H_ITEMHELD: if( !cg_disableWarningDialogs.integer ) { @@ -750,13 +750,13 @@ void CG_Menu( int menu ) } else CG_Printf( "You already hold this item\n" ); - + break; - - + + //=============================== - + case MN_A_NOROOM: if( !cg_disableWarningDialogs.integer ) { @@ -766,9 +766,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There is no room to build here\n" ); - + break; - + case MN_A_NOCREEP: if( !cg_disableWarningDialogs.integer ) { @@ -778,9 +778,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There is no creep here\n" ); - + break; - + case MN_A_NOOVMND: if( !cg_disableWarningDialogs.integer ) { @@ -790,9 +790,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There is no Overmind\n" ); - + break; - + case MN_A_OVERMIND: if( !cg_disableWarningDialogs.integer ) { @@ -802,9 +802,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There can only be one Overmind\n" ); - + break; - + case MN_A_NOASSERT: if( !cg_disableWarningDialogs.integer ) { @@ -814,9 +814,9 @@ void CG_Menu( int menu ) } else CG_Printf( "The Overmind cannot control any more structures\n" ); - + break; - + case MN_A_SPWNWARN: if( !cg_disableWarningDialogs.integer ) { @@ -826,9 +826,9 @@ void CG_Menu( int menu ) } else CG_Printf( "This spawn will not be controlled by an Overmind\n" ); - + break; - + case MN_A_NORMAL: if( !cg_disableWarningDialogs.integer ) { @@ -838,9 +838,9 @@ void CG_Menu( int menu ) } else CG_Printf( "Cannot build on this surface\n" ); - + break; - + case MN_A_NOEROOM: if( !cg_disableWarningDialogs.integer ) { @@ -850,9 +850,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There is no room to evolve here\n" ); - + break; - + case MN_A_TOOCLOSE: if( !cg_disableWarningDialogs.integer ) { @@ -863,9 +863,9 @@ void CG_Menu( int menu ) } else CG_Printf( "This location is too close to the enemy to evolve\n" ); - + break; - + case MN_A_NOOVMND_EVOLVE: if( !cg_disableWarningDialogs.integer ) { @@ -875,9 +875,9 @@ void CG_Menu( int menu ) } else CG_Printf( "There is no Overmind\n" ); - + break; - + case MN_A_HOVEL_OCCUPIED: if( !cg_disableWarningDialogs.integer ) { @@ -887,9 +887,9 @@ void CG_Menu( int menu ) } else CG_Printf( "This Hovel is occupied by another builder\n" ); - + break; - + case MN_A_HOVEL_BLOCKED: if( !cg_disableWarningDialogs.integer ) { @@ -899,9 +899,9 @@ void CG_Menu( int menu ) } else CG_Printf( "The exit to this Hovel is currently blocked\n" ); - + break; - + case MN_A_HOVEL_EXIT: if( !cg_disableWarningDialogs.integer ) { @@ -911,9 +911,9 @@ void CG_Menu( int menu ) } else CG_Printf( "The exit to this Hovel would always be blocked\n" ); - + break; - + case MN_A_INFEST: trap_Cvar_Set( "ui_currentClass", va( "%d %d", cg.snap->ps.stats[ STAT_PCLASS ], cg.snap->ps.persistant[ PERS_CREDIT ] ) ); @@ -973,7 +973,7 @@ static void CG_ServerCommand( void ) CG_RemoveChatEscapeChar( text ); CG_Printf( "%s\n", text ); } - + return; } @@ -986,7 +986,7 @@ static void CG_ServerCommand( void ) CG_Printf( "%s\n", text ); return; } - + if( !strcmp( cmd, "scores" ) ) { CG_ParseScores( ); @@ -1024,7 +1024,7 @@ static void CG_ServerCommand( void ) { if( trap_Argc( ) == 2 ) CG_TAUIConsole( CG_Argv( 1 ) ); - + return; } @@ -1033,10 +1033,10 @@ static void CG_ServerCommand( void ) { if( trap_Argc( ) == 2 && !cg.demoPlayback ) CG_Menu( atoi( CG_Argv( 1 ) ) ); - + return; } - + //the server thinks this client should close all menus if( !strcmp( cmd, "serverclosemenus" ) ) { @@ -1066,7 +1066,7 @@ static void CG_ServerCommand( void ) return; } - + // server requests a ptrc if( !strcmp( cmd, "ptrcrequest" ) ) { @@ -1075,28 +1075,28 @@ static void CG_ServerCommand( void ) trap_SendClientCommand( va( "ptrcverify %d", code ) ); return; } - + // server issues a ptrc if( !strcmp( cmd, "ptrcissue" ) ) { if( trap_Argc( ) == 2 ) { int code = atoi( CG_Argv( 1 ) ); - + CG_WritePTRCode( code ); } - + return; } - + // reply to ptrcverify if( !strcmp( cmd, "ptrcconfirm" ) ) { trap_SendConsoleCommand( "menu ptrc_popmenu\n" ); - + return; } - + CG_Printf( "Unknown client game command: %s\n", cmd ); } diff --git a/src/cgame/cg_snapshot.c b/src/cgame/cg_snapshot.c index 0e8103fb..4a5722ae 100644 --- a/src/cgame/cg_snapshot.c +++ b/src/cgame/cg_snapshot.c @@ -34,7 +34,7 @@ static void CG_ResetEntity( centity_t *cent ) VectorCopy( cent->currentState.origin, cent->lerpOrigin ); VectorCopy( cent->currentState.angles, cent->lerpAngles ); - + if( cent->currentState.eType == ET_PLAYER ) CG_ResetPlayerEntity( cent ); } @@ -68,7 +68,7 @@ static void CG_TransitionEntity( centity_t *cent ) CG_SetInitialSnapshot This will only happen on the very first snapshot, or -on tourney restarts. All other times will use +on tourney restarts. All other times will use CG_TransitionSnapshot instead. FIXME: Also called by map_restart? @@ -154,7 +154,7 @@ static void CG_TransitionSnapshot( void ) { cent = &cg_entities[ cg.snap->entities[ i ].number ]; CG_TransitionEntity( cent ); - + // remember time of snapshot this entity was last updated in cent->snapShotTime = cg.snap->serverTime; } @@ -253,7 +253,7 @@ static snapshot_t *CG_ReadNextSnapshot( void ) if( cg.latestSnapshotNum > cgs.processedSnapshotNum + 1000 ) { - CG_Printf( "WARNING: CG_ReadNextSnapshot: way out of range, %i > %i", + CG_Printf( "WARNING: CG_ReadNextSnapshot: way out of range, %i > %i", cg.latestSnapshotNum, cgs.processedSnapshotNum ); } @@ -274,7 +274,7 @@ static snapshot_t *CG_ReadNextSnapshot( void ) { //continue; } - + // if it succeeded, return if( r ) { @@ -325,7 +325,7 @@ void CG_ProcessSnapshots( void ) // see what the latest snapshot the client system has is trap_GetCurrentSnapshotNumber( &n, &cg.latestSnapshotTime ); - + if( n != cg.latestSnapshotNum ) { if( n < cg.latestSnapshotNum ) @@ -333,7 +333,7 @@ void CG_ProcessSnapshots( void ) // this should never happen CG_Error( "CG_ProcessSnapshots: n < cg.latestSnapshotNum" ); } - + cg.latestSnapshotNum = n; } @@ -343,7 +343,7 @@ void CG_ProcessSnapshots( void ) while( !cg.snap ) { snap = CG_ReadNextSnapshot( ); - + if( !snap ) { // we can't continue until we get a snapshot @@ -395,7 +395,7 @@ void CG_ProcessSnapshots( void ) // this can happen right after a vid_restart cg.time = cg.snap->serverTime; } - + if( cg.nextSnap != NULL && cg.nextSnap->serverTime <= cg.time ) CG_Error( "CG_ProcessSnapshots: cg.nextSnap->serverTime <= cg.time" ); } diff --git a/src/cgame/cg_syscalls.c b/src/cgame/cg_syscalls.c index b89751e2..f556035d 100644 --- a/src/cgame/cg_syscalls.c +++ b/src/cgame/cg_syscalls.c @@ -46,7 +46,7 @@ void trap_Error( const char *fmt ) int trap_Milliseconds( void ) { - return syscall( CG_MILLISECONDS ); + return syscall( CG_MILLISECONDS ); } void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ) @@ -89,7 +89,7 @@ int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) return syscall( CG_FS_FOPENFILE, qpath, f, mode ); } -void trap_FS_Read( void *buffer, int len, fileHandle_t f ) +void trap_FS_Read( void *buffer, int len, fileHandle_t f ) { syscall( CG_FS_READ, buffer, len, f ); } @@ -200,7 +200,7 @@ void trap_CM_TransformedCapsuleTrace( trace_t *results, const vec3_t start, con syscall( CG_CM_TRANSFORMEDCAPSULETRACE, results, start, end, mins, maxs, model, brushmask, origin, angles ); } -int trap_CM_MarkFragments( int numPoints, const vec3_t *points, +int trap_CM_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection, int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ) @@ -274,7 +274,7 @@ qhandle_t trap_R_RegisterSkin( const char *name ) return syscall( CG_R_REGISTERSKIN, name ); } -qhandle_t trap_R_RegisterShader( const char *name ) +qhandle_t trap_R_RegisterShader( const char *name ) { return syscall( CG_R_REGISTERSHADER, name ); } @@ -334,7 +334,7 @@ void trap_R_SetColor( const float *rgba ) syscall( CG_R_SETCOLOR, rgba ); } -void trap_R_DrawStretchPic( float x, float y, float w, float h, +void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) { syscall( CG_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), @@ -345,7 +345,7 @@ void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) { syscall( CG_R_MODELBOUNDS, model, mins, maxs ); } -int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, +int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ) { return syscall( CG_R_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName ); @@ -476,7 +476,7 @@ int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int { return syscall(CG_CIN_PLAYCINEMATIC, arg0, xpos, ypos, width, height, bits); } - + // stops playing the cinematic and ends it. should always return FMV_EOF // cinematics must be stopped in reverse order of when they are started e_status trap_CIN_StopCinematic( int handle ) @@ -490,14 +490,14 @@ e_status trap_CIN_RunCinematic( int handle ) { return syscall(CG_CIN_RUNCINEMATIC, handle); } - + // draws the current frame void trap_CIN_DrawCinematic( int handle ) { syscall(CG_CIN_DRAWCINEMATIC, handle); } - + // allows you to resize the animation dynamically void trap_CIN_SetExtents( int handle, int x, int y, int w, int h ) diff --git a/src/cgame/cg_trails.c b/src/cgame/cg_trails.c index 8839a757..30347e61 100644 --- a/src/cgame/cg_trails.c +++ b/src/cgame/cg_trails.c @@ -64,7 +64,7 @@ void CG_ClearTrails( void ) trailJuncs[ i ].inuse = qfalse; } - + trailJuncs[ MAX_TRAILJUNCS - 1 ].nextGlobal = NULL; initTrails = qtrue; @@ -89,15 +89,15 @@ trailJunc_t *CG_SpawnTrailJunc( trailJunc_t *headJunc ) // select the first free trail, and remove it from the list j = freeTrails; freeTrails = j->nextGlobal; - + if( freeTrails ) freeTrails->prevGlobal = NULL; j->nextGlobal = activeTrails; - + if( activeTrails ) activeTrails->prevGlobal = j; - + activeTrails = j; j->prevGlobal = NULL; j->inuse = qtrue; @@ -110,7 +110,7 @@ trailJunc_t *CG_SpawnTrailJunc( trailJunc_t *headJunc ) if( headJunc == headTrails ) { headTrails = headJunc->nextHead; - + if( headTrails ) headTrails->prevHead = NULL; } @@ -118,18 +118,18 @@ trailJunc_t *CG_SpawnTrailJunc( trailJunc_t *headJunc ) { if( headJunc->nextHead ) headJunc->nextHead->prevHead = headJunc->prevHead; - + if( headJunc->prevHead ) headJunc->prevHead->nextHead = headJunc->nextHead; } headJunc->prevHead = NULL; headJunc->nextHead = NULL; } - + // make us the headTrail if( headTrails ) headTrails->prevHead = j; - + j->nextHead = headTrails; j->prevHead = NULL; headTrails = j; @@ -172,7 +172,7 @@ int CG_AddTrailJunc( int headJuncIndex, qhandle_t shader, int spawnTime, int sTy headJunc = NULL; j = CG_SpawnTrailJunc( headJunc ); - + if( !j ) { // CG_Printf("couldnt spawn trail junc\n"); @@ -181,13 +181,13 @@ int CG_AddTrailJunc( int headJuncIndex, qhandle_t shader, int spawnTime, int sTy if( alphaStart > 1.0 ) alphaStart = 1.0; - + if( alphaStart < 0.0 ) alphaStart = 0.0; - + if( alphaEnd > 1.0 ) alphaEnd = 1.0; - + if( alphaEnd < 0.0 ) alphaEnd = 0.0; @@ -247,7 +247,7 @@ int CG_AddSparkJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailL headJunc = NULL; j = CG_SpawnTrailJunc( headJunc ); - + if( !j ) return 0; @@ -300,7 +300,7 @@ int CG_AddSmokeJunc( int headJuncIndex, qhandle_t shader, vec3_t pos, int trailL headJunc = NULL; j = CG_SpawnTrailJunc( headJunc ); - + if( !j ) return 0; @@ -353,33 +353,33 @@ void CG_FreeTrailJunc( trailJunc_t *junc ) // make it non-active junc->inuse = qfalse; junc->freed = qtrue; - + if( junc->nextGlobal ) junc->nextGlobal->prevGlobal = junc->prevGlobal; - + if( junc->prevGlobal ) junc->prevGlobal->nextGlobal = junc->nextGlobal; - + if( junc == activeTrails ) activeTrails = junc->nextGlobal; // if it's a head, remove it if( junc == headTrails ) headTrails = junc->nextHead; - + if( junc->nextHead ) junc->nextHead->prevHead = junc->prevHead; - + if( junc->prevHead ) junc->prevHead->nextHead = junc->nextHead; - + junc->nextHead = NULL; junc->prevHead = NULL; // stick it in the free list junc->prevGlobal = NULL; junc->nextGlobal = freeTrails; - + if( freeTrails ) freeTrails->prevGlobal = junc; @@ -428,7 +428,7 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) float sInc = 0.0f, s = 0.0f; // TTimo: init trailJunc_t *j, *jNext; vec3_t fwd, up, p, v; - + // clipping vars #define TRAIL_FADE_CLOSE_DIST 64.0 #define TRAIL_FADE_FAR_SCALE 4.0 @@ -440,48 +440,48 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) { j = trail; VectorCopy( j->pos, p ); - VectorMA( p, -j->width * 2, vup, p ); - VectorMA( p, -j->width * 2, vright, p ); + VectorMA( p, -j->width * 2, vup, p ); + VectorMA( p, -j->width * 2, vright, p ); VectorCopy( p, verts[ 0 ].xyz ); - verts[ 0 ].st[ 0 ] = 0; - verts[ 0 ].st[ 1 ] = 0; - verts[ 0 ].modulate[ 0 ] = 255; - verts[ 0 ].modulate[ 1 ] = 255; - verts[ 0 ].modulate[ 2 ] = 255; + verts[ 0 ].st[ 0 ] = 0; + verts[ 0 ].st[ 1 ] = 0; + verts[ 0 ].modulate[ 0 ] = 255; + verts[ 0 ].modulate[ 1 ] = 255; + verts[ 0 ].modulate[ 2 ] = 255; verts[ 0 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 ); VectorCopy( j->pos, p ); - VectorMA( p, -j->width * 2, vup, p ); - VectorMA( p, j->width * 2, vright, p ); - VectorCopy( p, verts[ 1 ].xyz ); - verts[ 1 ].st[ 0 ] = 0; - verts[ 1 ].st[ 1 ] = 1; - verts[ 1 ].modulate[ 0 ] = 255; - verts[ 1 ].modulate[ 1 ] = 255; - verts[ 1 ].modulate[ 2 ] = 255; - verts[ 1 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 ); + VectorMA( p, -j->width * 2, vup, p ); + VectorMA( p, j->width * 2, vright, p ); + VectorCopy( p, verts[ 1 ].xyz ); + verts[ 1 ].st[ 0 ] = 0; + verts[ 1 ].st[ 1 ] = 1; + verts[ 1 ].modulate[ 0 ] = 255; + verts[ 1 ].modulate[ 1 ] = 255; + verts[ 1 ].modulate[ 2 ] = 255; + verts[ 1 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 ); VectorCopy( j->pos, p ); - VectorMA( p, j->width * 2, vup, p ); - VectorMA( p, j->width * 2, vright, p ); - VectorCopy( p, verts[ 2 ].xyz ); - verts[ 2 ].st[ 0 ] = 1; - verts[ 2 ].st[ 1 ] = 1; - verts[ 2 ].modulate[ 0 ] = 255; - verts[ 2 ].modulate[ 1 ] = 255; - verts[ 2 ].modulate[ 2 ] = 255; - verts[ 2 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 ); + VectorMA( p, j->width * 2, vup, p ); + VectorMA( p, j->width * 2, vright, p ); + VectorCopy( p, verts[ 2 ].xyz ); + verts[ 2 ].st[ 0 ] = 1; + verts[ 2 ].st[ 1 ] = 1; + verts[ 2 ].modulate[ 0 ] = 255; + verts[ 2 ].modulate[ 1 ] = 255; + verts[ 2 ].modulate[ 2 ] = 255; + verts[ 2 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 ); VectorCopy( j->pos, p ); - VectorMA( p, j->width * 2, vup, p ); - VectorMA( p, -j->width * 2, vright, p ); - VectorCopy( p, verts[ 3 ].xyz ); - verts[ 3 ].st[ 0 ] = 1; - verts[ 3 ].st[ 1 ] = 0; - verts[ 3 ].modulate[ 0 ] = 255; - verts[ 3 ].modulate[ 1 ] = 255; - verts[ 3 ].modulate[ 2 ] = 255; - verts[ 3 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 ); + VectorMA( p, j->width * 2, vup, p ); + VectorMA( p, -j->width * 2, vright, p ); + VectorCopy( p, verts[ 3 ].xyz ); + verts[ 3 ].st[ 0 ] = 1; + verts[ 3 ].st[ 1 ] = 0; + verts[ 3 ].modulate[ 0 ] = 255; + verts[ 3 ].modulate[ 1 ] = 255; + verts[ 3 ].modulate[ 2 ] = 255; + verts[ 3 ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 ); trap_R_AddPolyToScene( cgs.media.sparkFlareShader, 4, verts ); } @@ -496,7 +496,7 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) j = trail; numJuncs = 0; sInc = 0; - + while( j ) { numJuncs++; @@ -552,7 +552,7 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) VectorMA( up, 0.3, v, up ); else VectorMA( up, -0.3, v, up ); - + VectorNormalize( up ); } } @@ -561,7 +561,7 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) { ProjectPointOntoVector( cg.refdef.vieworg, j->pos, jNext->pos, viewProj ); viewDist = Distance( viewProj, cg.refdef.vieworg ); - + if( viewDist < ( TRAIL_FADE_CLOSE_DIST * TRAIL_FADE_FAR_SCALE ) ) { if( viewDist < TRAIL_FADE_CLOSE_DIST ) @@ -584,10 +584,10 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) VectorCopy( p, verts[ i ].xyz ); verts[ i ].st[ 0 ] = s; verts[ i ].st[ 1 ] = 1.0; - + for( k = 0; k < 3; k++ ) verts[ i ].modulate[ k ] = (unsigned char)( j->color[ k ] * 255.0 ); - + verts[ i ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 ); // blend this with the previous junc @@ -607,10 +607,10 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) VectorCopy( p, verts[ i ].xyz ); verts[ i ].st[ 0 ] = s; verts[ i ].st[ 1 ] = 0.0; - + for( k = 0; k < 3; k++ ) verts[ i ].modulate[ k ] = (unsigned char)( j->color[ k ] * 255.0 ); - + verts[ i ].modulate[ 3 ] = (unsigned char)( j->alpha * 255.0 ); // blend this with the previous junc @@ -640,10 +640,10 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) VectorCopy( p, verts[ i ].xyz ); verts[ i ].st[ 0 ] = s; verts[ i ].st[ 1 ] = 0.0; - + for( k = 0; k < 3; k++ ) verts[ i ].modulate[ k ] = (unsigned char)( jNext->color[ k ] * 255.0 ); - + verts[ i ].modulate[ 3 ] = (unsigned char)( jNext->alpha * 255.0 ); i++; @@ -652,10 +652,10 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) VectorCopy( p, verts[ i ].xyz ); verts[ i ].st[ 0 ] = s; verts[ i ].st[ 1 ] = 1.0; - + for( k = 0; k < 3; k++ ) verts[ i ].modulate[ k ] = (unsigned char)( jNext->color[ k ] * 255.0 ); - + verts[ i ].modulate[ 3 ] = (unsigned char)( jNext->alpha * 255.0 ); i++; @@ -675,24 +675,24 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) VectorCopy( verts[ k ].xyz, mid.xyz ); mid.st[ 0 ] = verts[ k ].st[ 0 ]; mid.st[ 1 ] = verts[ k ].st[ 1 ]; - + for( l = 0; l < 4; l++ ) mod[ l ] = (float)verts[ k ].modulate[ l ]; - + for( n = 1; n < 4; n++ ) { VectorAdd( verts[ k + n ].xyz, mid.xyz, mid.xyz ); mid.st[ 0 ] += verts[ k + n ].st[ 0 ]; mid.st[ 1 ] += verts[ k + n ].st[ 1 ]; - + for( l = 0; l < 4; l++ ) mod[ l ] += (float)verts[ k + n ].modulate[ l ]; } - + VectorScale( mid.xyz, 0.25, mid.xyz ); mid.st[ 0 ] *= 0.25; mid.st[ 1 ] *= 0.25; - + for( l = 0; l < 4; l++ ) mid.modulate[ l ] = (unsigned char)( mod[ l ] / 4.0 ); @@ -701,13 +701,13 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) { outVerts[ numOutVerts++ ] = verts[ k + n ]; outVerts[ numOutVerts++ ] = mid; - + if( n < 3 ) outVerts[ numOutVerts++ ] = verts[ k + n + 1 ]; else outVerts[ numOutVerts++ ] = verts[ k ]; } - + } if( !( trail->flags & TJFL_NOPOLYMERGE ) ) @@ -715,7 +715,7 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) else { int k; - + for( k = 0; k < numOutVerts / 3; k++ ) trap_R_AddPolyToScene( trail->shader, 3, &outVerts[ k * 3 ] ); } @@ -729,7 +729,7 @@ void CG_AddTrailToScene( trailJunc_t *trail, int iteration, int numJuncs ) else { int k; - + for( k = 0; k < i / 4; k++ ) trap_R_AddPolyToScene( trail->shader, 4, &verts[ k * 4 ] ); } @@ -764,34 +764,34 @@ void CG_AddTrails( void ) // update the settings for each junc j = activeTrails; - + while( j ) { lifeFrac = (float)( cg.time - j->spawnTime ) / (float)( j->endTime - j->spawnTime ); - + if( lifeFrac >= 1.0 ) { j->inuse = qfalse; // flag it as dead j->width = j->widthEnd; j->alpha = j->alphaEnd; - + if( j->alpha > 1.0 ) j->alpha = 1.0; else if( j->alpha < 0.0 ) j->alpha = 0.0; - + VectorCopy( j->colorEnd, j->color ); } else { j->width = j->widthStart + ( j->widthEnd - j->widthStart ) * lifeFrac; j->alpha = j->alphaStart + ( j->alphaEnd - j->alphaStart ) * lifeFrac; - + if( j->alpha > 1.0 ) j->alpha = 1.0; else if( j->alpha < 0.0 ) j->alpha = 0.0; - + VectorSubtract( j->colorEnd, j->colorStart, j->color ); VectorMA( j->colorStart, lifeFrac, j->color, j->color ); } @@ -801,11 +801,11 @@ void CG_AddTrails( void ) // draw the trailHeads j = headTrails; - + while( j ) { jNext = j->nextHead; // in case it gets removed - + if( !j->inuse ) CG_FreeTrailJunc( j ); else diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index 454582db..0e98036d 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -68,13 +68,13 @@ void CG_TestModel_f( void ) memset( &cg.testModelEntity, 0, sizeof( cg.testModelEntity ) ); memset( &cg.testModelBarrelEntity, 0, sizeof( cg.testModelBarrelEntity ) ); - + if( trap_Argc( ) < 2 ) return; Q_strncpyz( cg.testModelName, CG_Argv( 1 ), MAX_QPATH ); cg.testModelEntity.hModel = trap_R_RegisterModel( cg.testModelName ); - + Q_strncpyz( cg.testModelBarrelName, CG_Argv( 1 ), MAX_QPATH ); cg.testModelBarrelName[ strlen( cg.testModelBarrelName ) - 4 ] = '\0'; Q_strcat( cg.testModelBarrelName, MAX_QPATH, "_barrel.md3" ); @@ -86,7 +86,7 @@ void CG_TestModel_f( void ) cg.testModelEntity.frame = 1; cg.testModelEntity.oldframe = 0; } - + if( !cg.testModelEntity.hModel ) { CG_Printf( "Can't register model\n" ); @@ -101,7 +101,7 @@ void CG_TestModel_f( void ) AnglesToAxis( angles, cg.testModelEntity.axis ); cg.testGun = qfalse; - + if( cg.testModelBarrelEntity.hModel ) { angles[ YAW ] = 0; @@ -135,10 +135,10 @@ void CG_TestModelNextFrame_f( void ) void CG_TestModelPrevFrame_f( void ) { cg.testModelEntity.frame--; - + if( cg.testModelEntity.frame < 0 ) cg.testModelEntity.frame = 0; - + CG_Printf( "frame %i\n", cg.testModelEntity.frame ); } @@ -151,7 +151,7 @@ void CG_TestModelNextSkin_f( void ) void CG_TestModelPrevSkin_f( void ) { cg.testModelEntity.skinNum--; - + if( cg.testModelEntity.skinNum < 0 ) cg.testModelEntity.skinNum = 0; @@ -165,7 +165,7 @@ static void CG_AddTestModel( void ) // re-register the model, because the level may have changed cg.testModelEntity.hModel = trap_R_RegisterModel( cg.testModelName ); cg.testModelBarrelEntity.hModel = trap_R_RegisterModel( cg.testModelBarrelName ); - + if( !cg.testModelEntity.hModel ) { CG_Printf( "Can't register model\n" ); @@ -235,7 +235,7 @@ static void CG_CalcVrect( void ) else size = cg_viewsize.integer; } - + cg.refdef.width = cgs.glconfig.vidWidth * size / 100; cg.refdef.width &= ~1; @@ -268,7 +268,7 @@ static void CG_OffsetThirdPersonView( void ) float focusDist; float forwardScale, sideScale; vec3_t surfNormal; - + if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_WALLCLIMBING ) { if( cg.predictedPlayerState.stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) @@ -278,7 +278,7 @@ static void CG_OffsetThirdPersonView( void ) } else VectorSet( surfNormal, 0.0f, 0.0f, 1.0f ); - + VectorMA( cg.refdef.vieworg, cg.predictedPlayerState.viewheight, surfNormal, cg.refdef.vieworg ); VectorCopy( cg.refdefViewAngles, focusAngles ); @@ -346,10 +346,10 @@ static void CG_OffsetThirdPersonView( void ) static void CG_StepOffset( void ) { float steptime; - int timeDelta; + int timeDelta; vec3_t normal; playerState_t *ps = &cg.predictedPlayerState; - + if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) { if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) @@ -359,31 +359,31 @@ static void CG_StepOffset( void ) } else VectorSet( normal, 0.0f, 0.0f, 1.0f ); - + if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) steptime = 200; else steptime = BG_FindSteptimeForClass( ps->stats[ STAT_PCLASS ] ); - - // smooth out stair climbing - timeDelta = cg.time - cg.stepTime; - if( timeDelta < steptime ) + + // smooth out stair climbing + timeDelta = cg.time - cg.stepTime; + if( timeDelta < steptime ) { - float stepChange = cg.stepChange - * (steptime - timeDelta) / steptime; + float stepChange = cg.stepChange + * (steptime - timeDelta) / steptime; if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) VectorMA( cg.refdef.vieworg, -stepChange, normal, cg.refdef.vieworg ); else - cg.refdef.vieworg[ 2 ] -= stepChange; - } + cg.refdef.vieworg[ 2 ] -= stepChange; + } } #define PCLOUD_ROLL_AMPLITUDE 25.0f #define PCLOUD_ROLL_FREQUENCY 0.4f #define PCLOUD_ZOOM_AMPLITUDE 15 #define PCLOUD_ZOOM_FREQUENCY 0.7f - + /* =============== @@ -405,7 +405,7 @@ static void CG_OffsetFirstPersonView( void ) float bob2; vec3_t normal, baseOrigin; playerState_t *ps = &cg.predictedPlayerState; - + if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) { if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) @@ -415,7 +415,7 @@ static void CG_OffsetFirstPersonView( void ) } else VectorSet( normal, 0.0f, 0.0f, 1.0f ); - + if( cg.snap->ps.pm_type == PM_INTERMISSION ) return; @@ -478,15 +478,15 @@ static void CG_OffsetFirstPersonView( void ) // add angles based on bob //TA: bob amount is class dependant - + if( cg.snap->ps.persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) bob2 = 0.0f; else bob2 = BG_FindBobForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] ); - + #define LEVEL4_FEEDBACK 10.0f - + //give a charging player some feedback if( ps->weapon == WP_ALEVEL4 ) { @@ -500,7 +500,7 @@ static void CG_OffsetFirstPersonView( void ) bob2 *= ( 1.0f + fraction * LEVEL4_FEEDBACK ); } } - + if( bob2 != 0.0f ) { // make sure the bob is visible even at low speeds @@ -509,20 +509,20 @@ static void CG_OffsetFirstPersonView( void ) delta = cg.bobfracsin * ( bob2 ) * speed; if( cg.predictedPlayerState.pm_flags & PMF_DUCKED ) delta *= 3; // crouching - + angles[ PITCH ] += delta; delta = cg.bobfracsin * ( bob2 ) * speed; if( cg.predictedPlayerState.pm_flags & PMF_DUCKED ) delta *= 3; // crouching accentuates roll - + if( cg.bobcycle & 1 ) delta = -delta; - + angles[ ROLL ] += delta; } #define LEVEL3_FEEDBACK 20.0f - + //provide some feedback for pouncing if( cg.predictedPlayerState.weapon == WP_ALEVEL3 || cg.predictedPlayerState.weapon == WP_ALEVEL3_UPG ) @@ -541,7 +541,7 @@ static void CG_OffsetFirstPersonView( void ) fraction1 = 1.0f; fraction2 = -sin( fraction1 * M_PI / 2 ); - + VectorMA( origin, LEVEL3_FEEDBACK * fraction2, forward, origin ); } } @@ -573,25 +573,25 @@ static void CG_OffsetFirstPersonView( void ) rFraction = 1.0f; if( uFraction > 1.0f ) uFraction = 1.0f; - + fFraction2 = -sin( fFraction * M_PI / 2 ); rFraction2 = -sin( rFraction * M_PI / 2 ); uFraction2 = -sin( uFraction * M_PI / 2 ); - + if( cmd.forwardmove > 0 ) VectorMA( origin, STRUGGLE_DIST * fFraction, forward, origin ); else if( cmd.forwardmove < 0 ) VectorMA( origin, -STRUGGLE_DIST * fFraction, forward, origin ); else cg.forwardMoveTime = cg.time; - + if( cmd.rightmove > 0 ) VectorMA( origin, STRUGGLE_DIST * rFraction, right, origin ); else if( cmd.rightmove < 0 ) VectorMA( origin, -STRUGGLE_DIST * rFraction, right, origin ); else cg.rightMoveTime = cg.time; - + if( cmd.upmove > 0 ) VectorMA( origin, STRUGGLE_DIST * uFraction, up, origin ); else if( cmd.upmove < 0 ) @@ -618,12 +618,12 @@ static void CG_OffsetFirstPersonView( void ) if( cg.predictedPlayerState.stats[ STAT_PTEAM ] == PTE_HUMANS ) { angles[PITCH] += cg.bobfracsin * bob2 * 0.5; - + //TA: heavy breathing effects //FIXME: sound if( cg.predictedPlayerState.stats[ STAT_STAMINA ] < 0 ) { float deltaBreath = (float)( - cg.predictedPlayerState.stats[ STAT_STAMINA ] < 0 ? + cg.predictedPlayerState.stats[ STAT_STAMINA ] < 0 ? -cg.predictedPlayerState.stats[ STAT_STAMINA ] : cg.predictedPlayerState.stats[ STAT_STAMINA ] ) / 200.0; float deltaAngle = cos( (float)cg.time/150.0 ) * deltaBreath; @@ -642,7 +642,7 @@ static void CG_OffsetFirstPersonView( void ) VectorMA( origin, ps->viewheight, normal, origin ); else origin[ 2 ] += cg.predictedPlayerState.viewheight; - + // smooth out duck height changes timeDelta = cg.time - cg.duckTime; if( timeDelta < DUCK_TIME) @@ -653,7 +653,7 @@ static void CG_OffsetFirstPersonView( void ) // add bob height bob = cg.bobfracsin * cg.xyspeed * bob2; - + if( bob > 6 ) bob = 6; @@ -666,7 +666,7 @@ static void CG_OffsetFirstPersonView( void ) // add fall height delta = cg.time - cg.landTime; - + if( delta < LAND_DEFLECT_TIME ) { f = delta / LAND_DEFLECT_TIME; @@ -761,7 +761,7 @@ static int CG_CalcFov( void ) fov_x = 180 - temp2; } - + // account for zooms zoomFov = BG_FindZoomFovForWeapon( cg.predictedPlayerState.weapon ); if ( zoomFov < 1 ) @@ -799,7 +799,7 @@ static int CG_CalcFov( void ) // warp if underwater contents = CG_PointContents( cg.refdef.vieworg, -1 ); - + if( contents & ( CONTENTS_WATER | CONTENTS_SLIME | CONTENTS_LAVA ) ) { phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2; @@ -821,7 +821,7 @@ static int CG_CalcFov( void ) fov_x += v; fov_y += v; } - + // set it cg.refdef.fov_x = fov_x; @@ -858,7 +858,7 @@ static void CG_DamageBlendBlob( void ) maxTime = DAMAGE_TIME; t = cg.time - cg.damageTime; - + if( t <= 0 || t >= maxTime ) return; @@ -984,7 +984,7 @@ static void CG_smoothWWTransitions( playerState_t *ps, const vec3_t in, vec3_t o VectorCopy( ps->grapplePoint, surfNormal ); else VectorCopy( ceilingNormal, surfNormal ); - + AnglesToAxis( in, inAxis ); //if we are moving from one surface to another smooth the transition @@ -1021,7 +1021,7 @@ static void CG_smoothWWTransitions( playerState_t *ps, const vec3_t in, vec3_t o timeMod = 1.0f; } - + //add the op CG_addSmoothOp( rotAxis, rotAngle, timeMod ); } @@ -1030,7 +1030,7 @@ static void CG_smoothWWTransitions( playerState_t *ps, const vec3_t in, vec3_t o for( i = MAXSMOOTHS - 1; i >= 0; i-- ) { smoothTime = (int)( cg_wwSmoothTime.integer * cg.sList[ i ].timeMod ); - + //if this op has time remaining, perform it if( cg.time < cg.sList[ i ].time + smoothTime ) { @@ -1135,7 +1135,7 @@ static int CG_CalcViewValues( void ) VectorCopy( ps->origin, cg.refdef.vieworg ); VectorCopy( ps->viewangles, cg.refdefViewAngles ); AnglesToAxis( cg.refdefViewAngles, cg.refdef.viewaxis ); - + return CG_CalcFov( ); } @@ -1169,7 +1169,7 @@ static int CG_CalcViewValues( void ) t = cg.time - cg.predictedErrorTime; f = ( cg_errorDecay.value - t ) / cg_errorDecay.value; - + if( f > 0 && f < 1 ) VectorMA( cg.refdef.vieworg, f, cg.predictedError, cg.refdef.vieworg ); else @@ -1182,7 +1182,7 @@ static int CG_CalcViewValues( void ) if( CG_IsParticleSystemValid( &cg.poisonCloudPS ) ) CG_DestroyParticleSystem( &cg.poisonCloudPS ); } - + if( cg.renderingThirdPerson ) { // back away from character @@ -1217,10 +1217,10 @@ void CG_AddBufferedSound( sfxHandle_t sfx ) { if( !sfx ) return; - + cg.soundBuffer[ cg.soundBufferIn ] = sfx; cg.soundBufferIn = ( cg.soundBufferIn + 1 ) % MAX_SOUNDBUFFER; - + if( cg.soundBufferIn == cg.soundBufferOut ) cg.soundBufferOut++; } @@ -1315,7 +1315,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo CG_AddMarks( ); CG_AddLocalEntities( ); } - + CG_AddViewWeapon( &cg.predictedPlayerState ); //after CG_AddViewWeapon @@ -1324,7 +1324,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo CG_AddParticles( ); //TA: wolf trails stuff - CG_AddTrails( ); // this must come last, so the trails dropped this frame get drawn + CG_AddTrails( ); // this must come last, so the trails dropped this frame get drawn } // add buffered sounds @@ -1333,14 +1333,14 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo // finish up the rest of the refdef if( cg.testModelEntity.hModel ) CG_AddTestModel( ); - + cg.refdef.time = cg.time; memcpy( cg.refdef.areamask, cg.snap->areamask, sizeof( cg.refdef.areamask ) ); //remove expired console lines if( cg.consoleLines[ 0 ].time + cg_consoleLatency.integer < cg.time && cg_consoleLatency.integer > 0 ) CG_RemoveConsoleLine( ); - + // update audio positions trap_S_Respatialize( cg.snap->ps.clientNum, cg.refdef.vieworg, cg.refdef.viewaxis, inwater ); @@ -1348,14 +1348,14 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo if( stereoView != STEREO_RIGHT ) { cg.frametime = cg.time - cg.oldTime; - + if( cg.frametime < 0 ) cg.frametime = 0; - + cg.oldTime = cg.time; CG_AddLagometerFrameInfo( ); } - + if( cg_timescale.value != cg_timescaleFadeEnd.value ) { if( cg_timescale.value < cg_timescaleFadeEnd.value ) @@ -1370,7 +1370,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo if( cg_timescale.value < cg_timescaleFadeEnd.value ) cg_timescale.value = cg_timescaleFadeEnd.value; } - + if( cg_timescaleFadeSpeed.value ) trap_Cvar_Set( "timescale", va( "%f", cg_timescale.value ) ); } diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index df33af35..dcef9f82 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -130,7 +130,7 @@ static void CG_ShotgunEjectBrass( centity_t *cent ) xoffset[ 2 ] = offset[ 0 ] * v[ 0 ][ 2 ] + offset[ 1 ] * v[ 1 ][ 2 ] + offset[ 2 ] * v[ 2 ][ 2 ]; VectorAdd( cent->lerpOrigin, xoffset, re->origin ); VectorCopy( re->origin, le->pos.trBase ); - + if( CG_PointContents( re->origin, -1 ) & CONTENTS_WATER ) waterScale = 0.10f; @@ -166,7 +166,7 @@ void CG_TeslaTrail( vec3_t start, vec3_t end, int srcENum, int destENum ) { localEntity_t *le; refEntity_t *re; - + //add a bunch of bolt segments le = CG_AllocLocalEntity( ); re = &le->refEntity; @@ -212,9 +212,9 @@ void CG_RegisterUpgrade( int upgradeNum ) if( !BG_FindNameForUpgrade( upgradeNum ) ) CG_Error( "Couldn't find upgrade %i", upgradeNum ); - + upgradeInfo->humanName = BG_FindHumanNameForUpgrade( upgradeNum ); - + //la la la la la, i'm not listening! if( upgradeNum == UP_GRENADE ) upgradeInfo->upgradeIcon = cg_weapons[ WP_GRENADE ].weaponIcon; @@ -256,7 +256,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p while( 1 ) { token = COM_Parse( text_p ); - + if( !token ) break; @@ -270,7 +270,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p break; wim->missileModel = trap_R_RegisterModel( token ); - + if( !wim->missileModel ) CG_Printf( S_COLOR_RED "ERROR: missile model not found %s\n", token ); @@ -279,16 +279,16 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p else if( !Q_stricmp( token, "missileSprite" ) ) { int size = 0; - + token = COM_Parse( text_p ); if( !token ) break; size = atoi( token ); - + if( size < 0 ) size = 0; - + token = COM_Parse( text_p ); if( !token ) break; @@ -296,7 +296,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p wim->missileSprite = trap_R_RegisterShader( token ); wim->missileSpriteSize = size; wim->usesSpriteMissle = qtrue; - + if( !wim->missileSprite ) CG_Printf( S_COLOR_RED "ERROR: missile sprite not found %s\n", token ); @@ -315,27 +315,27 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p token = COM_Parse( text_p ); if( !token ) break; - - wim->missileAnimStartFrame = atoi( token ); - + + wim->missileAnimStartFrame = atoi( token ); + token = COM_Parse( text_p ); if( !token ) break; - - wim->missileAnimNumFrames = atoi( token ); - + + wim->missileAnimNumFrames = atoi( token ); + token = COM_Parse( text_p ); if( !token ) break; - - wim->missileAnimFrameRate = atoi( token ); - + + wim->missileAnimFrameRate = atoi( token ); + token = COM_Parse( text_p ); if( !token ) break; - - wim->missileAnimLooping = atoi( token ); - + + wim->missileAnimLooping = atoi( token ); + continue; } else if( !Q_stricmp( token, "missileParticleSystem" ) ) @@ -345,7 +345,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p break; wim->missileParticleSystem = CG_RegisterParticleSystem( token ); - + if( !wim->missileParticleSystem ) CG_Printf( S_COLOR_RED "ERROR: missile particle system not found %s\n", token ); @@ -358,7 +358,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p break; wim->muzzleParticleSystem = CG_RegisterParticleSystem( token ); - + if( !wim->muzzleParticleSystem ) CG_Printf( S_COLOR_RED "ERROR: muzzle particle system not found %s\n", token ); @@ -371,7 +371,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p break; wim->impactParticleSystem = CG_RegisterParticleSystem( token ); - + if( !wim->impactParticleSystem ) CG_Printf( S_COLOR_RED "ERROR: impact particle system not found %s\n", token ); @@ -384,7 +384,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p break; wim->impactModel = trap_R_RegisterModel( token ); - + if( !wim->impactModel ) CG_Printf( S_COLOR_RED "ERROR: impact model not found %s\n", token ); @@ -393,7 +393,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p break; wim->impactModelShader = trap_R_RegisterShader( token ); - + if( !wim->impactModelShader ) CG_Printf( S_COLOR_RED "ERROR: impact model shader not found %s\n", token ); @@ -402,23 +402,23 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p else if( !Q_stricmp( token, "impactMark" ) ) { int size = 0; - + token = COM_Parse( text_p ); if( !token ) break; size = atoi( token ); - + if( size < 0 ) size = 0; - + token = COM_Parse( text_p ); if( !token ) break; wim->impactMark = trap_R_RegisterShader( token ); wim->impactMarkSize = size; - + if( !wim->impactMark ) CG_Printf( S_COLOR_RED "ERROR: impact mark shader not found %s\n", token ); @@ -427,47 +427,47 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p else if( !Q_stricmp( token, "impactSound" ) ) { 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->impactSound[ index ] = trap_S_RegisterSound( token, qfalse ); - + 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" ) ) @@ -480,22 +480,22 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p wim->impactDlightColor[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "impactDlight" ) ) { int size = 0; - + token = COM_Parse( text_p ); if( !token ) break; size = atoi( token ); - + if( size < 0 ) size = 0; - + wim->impactDlight = size; continue; @@ -516,7 +516,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p wim->flashDlightColor[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "continuousFlash" ) ) @@ -535,22 +535,22 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p wim->missileDlightColor[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "missileDlight" ) ) { int size = 0; - + token = COM_Parse( text_p ); if( !token ) break; size = atoi( token ); - + if( size < 0 ) size = 0; - + wim->missileDlight = size; continue; @@ -562,7 +562,7 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p break; wim->firingSound = trap_S_RegisterSound( token, qfalse ); - + continue; } else if( !Q_stricmp( token, "missileSound" ) ) @@ -572,30 +572,30 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p break; wim->missileSound = trap_S_RegisterSound( token, qfalse ); - + continue; } else if( !Q_stricmp( token, "flashSound" ) ) { 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->flashSound[ index ] = trap_S_RegisterSound( token, qfalse ); - + continue; } else if( !Q_stricmp( token, "}" ) ) @@ -637,7 +637,7 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi ) CG_Printf( "File %s too long\n", filename ); return qfalse; } - + trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); @@ -649,7 +649,7 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi ) while( 1 ) { token = COM_Parse( &text_p ); - + if( !token ) break; @@ -671,7 +671,7 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi ) //start parsing ejectors again weaponMode = WPM_NONE; - + continue; } else if( !Q_stricmp( token, "primary" ) ) @@ -692,13 +692,13 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi ) else if( !Q_stricmp( token, "weaponModel" ) ) { char path[ MAX_QPATH ]; - + token = COM_Parse( &text_p ); if( !token ) break; wi->weaponModel = trap_R_RegisterModel( token ); - + if( !wi->weaponModel ) CG_Printf( S_COLOR_RED "ERROR: weapon model not found %s\n", token ); @@ -719,7 +719,7 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi ) if( !wi->handsModel ) wi->handsModel = trap_R_RegisterModel( "models/weapons2/shotgun/shotgun_hand.md3" ); - + continue; } else if( !Q_stricmp( token, "idleSound" ) ) @@ -729,7 +729,7 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi ) break; wi->readySound = trap_S_RegisterSound( token, qfalse ); - + continue; } else if( !Q_stricmp( token, "icon" ) ) @@ -739,7 +739,7 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi ) break; wi->weaponIcon = wi->ammoIcon = trap_R_RegisterShader( token ); - + if( !wi->weaponIcon ) CG_Printf( S_COLOR_RED "ERROR: weapon icon not found %s\n", token ); @@ -748,23 +748,23 @@ static qboolean CG_ParseWeaponFile( const char *filename, weaponInfo_t *wi ) else if( !Q_stricmp( token, "crosshair" ) ) { int size = 0; - + token = COM_Parse( &text_p ); if( !token ) break; size = atoi( token ); - + if( size < 0 ) size = 0; - + token = COM_Parse( &text_p ); if( !token ) break; wi->crossHair = trap_R_RegisterShader( token ); wi->crossHairSize = size; - + if( !wi->crossHair ) CG_Printf( S_COLOR_RED "ERROR: weapon crosshair not found %s\n", token ); @@ -809,14 +809,14 @@ void CG_RegisterWeapon( int weaponNum ) if( !BG_FindNameForWeapon( weaponNum ) ) CG_Error( "Couldn't find weapon %i", weaponNum ); - + Com_sprintf( path, MAX_QPATH, "models/weapons/%s/weapon.cfg", BG_FindNameForWeapon( weaponNum ) ); - + weaponInfo->humanName = BG_FindHumanNameForWeapon( weaponNum ); if( !CG_ParseWeaponFile( path, weaponInfo ) ) Com_Printf( S_COLOR_RED "ERROR: failed to parse %s\n", path ); - + // calc midpoint for rotation trap_R_ModelBounds( weaponInfo->weaponModel, mins, maxs ); for( i = 0 ; i < 3 ; i++ ) @@ -855,7 +855,7 @@ void CG_InitWeapons( void ) for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) CG_RegisterWeapon( i ); - + cgs.media.lightningShader = trap_R_RegisterShader( "models/ammo/tesla/tesla_bolt"); cgs.media.lightningExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" ); } @@ -921,7 +921,7 @@ static void CG_CalculateWeaponPosition( vec3_t origin, vec3_t angles ) // gun angles from bobbing //TA: bob amount is class dependant bob = BG_FindBobForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] ); - + if( bob != 0 ) { angles[ ROLL ] += scale * cg.bobfracsin * 0.005; @@ -1004,12 +1004,19 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent weapon_t weaponNum; weaponMode_t weaponMode; weaponInfo_t *weapon; - centity_t *nonPredictedCent; qboolean noGunModel; + qboolean firing; weaponNum = cent->currentState.weapon; weaponMode = cent->currentState.generic1; - + + if( ( ( cent->currentState.eFlags & EF_FIRING ) && weaponMode == WPM_PRIMARY ) || + ( ( cent->currentState.eFlags & EF_FIRING2 ) && weaponMode == WPM_SECONDARY ) || + ( ( cent->currentState.eFlags & EF_FIRING3 ) && weaponMode == WPM_TERTIARY ) ) + firing = qtrue; + else + firing = qfalse; + CG_RegisterWeapon( weaponNum ); weapon = &cg_weapons[ weaponNum ]; @@ -1033,13 +1040,13 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent cg.weapon1Time = cg.time; cg.weapon1Firing = ( cg.predictedPlayerState.eFlags & EF_FIRING ); } - + if( cg.weapon2Firing != ( cg.predictedPlayerState.eFlags & EF_FIRING2 ) ) { cg.weapon2Time = cg.time; cg.weapon2Firing = ( cg.predictedPlayerState.eFlags & EF_FIRING2 ); } - + if( cg.weapon3Firing != ( cg.predictedPlayerState.eFlags & EF_FIRING3 ) ) { cg.weapon3Time = cg.time; @@ -1050,13 +1057,12 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent gun.hModel = weapon->weaponModel; noGunModel = ( ( !ps || cg.renderingThirdPerson ) && weapon->disableIn3rdPerson ) || !gun.hModel; - + if( !ps ) { // add weapon ready sound - if( ( cent->currentState.eFlags & EF_FIRING ) && weapon->wim[ weaponMode ].firingSound ) + if( firing && weapon->wim[ weaponMode ].firingSound ) { - // lightning gun and guantlet make a different sound when fire is held down trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin, vec3_origin, weapon->wim[ weaponMode ].firingSound ); } @@ -1090,15 +1096,6 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent } } - // make sure we aren't looking at cg.predictedPlayerEntity for LG - nonPredictedCent = &cg_entities[ cent->currentState.clientNum ]; - - // if the index of the nonPredictedCent is not the same as the clientNum - // then this is a fake player (like on teh single player podiums), so - // go ahead and use the cent - if( ( nonPredictedCent - cg_entities ) != cent->currentState.clientNum ) - nonPredictedCent = cent; - if( CG_IsParticleSystemValid( ¢->muzzlePS ) ) { if( ps || cg.renderingThirdPerson || @@ -1111,16 +1108,12 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent } //if the PS is infinite disable it when not firing - if( ( ( !( cent->currentState.eFlags & EF_FIRING ) && weaponMode == WPM_PRIMARY ) || - ( !( cent->currentState.eFlags & EF_FIRING2 ) && weaponMode == WPM_SECONDARY ) || - ( !( cent->currentState.eFlags & EF_FIRING3 ) && weaponMode == WPM_TERTIARY ) ) && - CG_IsParticleSystemInfinite( cent->muzzlePS ) ) + if( !firing && CG_IsParticleSystemInfinite( cent->muzzlePS ) ) CG_DestroyParticleSystem( ¢->muzzlePS ); } - + // add the flash - if( !( weapon->wim[ weaponMode ].continuousFlash && - ( nonPredictedCent->currentState.eFlags & EF_FIRING ) ) ) + if( !weapon->wim[ weaponMode ].continuousFlash || !firing ) { // impulse flash if( cg.time - cent->muzzleFlashTime > MUZZLE_FLASH_TIME ) @@ -1144,7 +1137,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent CG_PositionRotatedEntityOnTag( &flash, parent, parent->hModel, "tag_weapon" ); else CG_PositionRotatedEntityOnTag( &flash, &gun, weapon->weaponModel, "tag_flash" ); - + trap_R_AddRefEntityToScene( &flash ); } @@ -1154,7 +1147,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent if( weapon->wim[ weaponMode ].muzzleParticleSystem && cent->muzzlePsTrigger ) { cent->muzzlePS = CG_SpawnNewParticleSystem( weapon->wim[ weaponMode ].muzzleParticleSystem ); - + if( noGunModel ) CG_SetParticleSystemTag( cent->muzzlePS, *parent, parent->hModel, "tag_weapon" ); else @@ -1164,7 +1157,7 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent CG_AttachParticleSystemToTag( cent->muzzlePS ); cent->muzzlePsTrigger = qfalse; } - + // make a dlight for the flash if( weapon->wim[ weaponMode ].flashDlightColor[ 0 ] || weapon->wim[ weaponMode ].flashDlightColor[ 1 ] || @@ -1208,7 +1201,7 @@ void CG_AddViewWeapon( playerState_t *ps ) //TA: no weapon carried - can't draw it if( weapon == WP_NONE ) return; - + if( ps->pm_type == PM_INTERMISSION ) return; @@ -1221,7 +1214,7 @@ void CG_AddViewWeapon( playerState_t *ps ) if( ps->stats[ STAT_MISC ] > ( LCANNON_TOTAL_CHARGE - ( LCANNON_TOTAL_CHARGE / 3 ) ) ) trap_S_AddLoopingSound( ps->clientNum, ps->origin, vec3_origin, cgs.media.lCannonWarningSound ); } - + // no gun if in third person view if( cg.renderingThirdPerson ) return; @@ -1233,10 +1226,10 @@ void CG_AddViewWeapon( playerState_t *ps ) VectorCopy( cg.refdef.vieworg, origin ); VectorMA( origin, -8, cg.refdef.viewaxis[ 2 ], origin ); - + if( cent->muzzlePS ) CG_SetParticleSystemOrigin( cent->muzzlePS, origin ); - + //check for particle systems if( wi->wim[ weaponMode ].muzzleParticleSystem && cent->muzzlePsTrigger ) { @@ -1246,7 +1239,7 @@ void CG_AddViewWeapon( playerState_t *ps ) CG_AttachParticleSystemToOrigin( cent->muzzlePS ); cent->muzzlePsTrigger = qfalse; } - + return; } @@ -1278,7 +1271,7 @@ void CG_AddViewWeapon( playerState_t *ps ) VectorMA( hand.origin, random( ) * fraction, cg.refdef.viewaxis[ 0 ], hand.origin ); VectorMA( hand.origin, random( ) * fraction, cg.refdef.viewaxis[ 1 ], hand.origin ); } - + AnglesToAxis( angles, hand.axis ); // map torso animations to weapon animations @@ -1326,7 +1319,7 @@ static qboolean CG_WeaponSelectable( weapon_t weapon ) //TA: this is a pain in the ass //if( !ammo && !clips && !BG_FindInfinteAmmoForWeapon( i ) ) // return qfalse; - + if( !BG_InventoryContainsWeapon( weapon, cg.snap->ps.stats ) ) return qfalse; @@ -1386,7 +1379,7 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color ) else if( cg.weaponSelect > 32 && !CG_UpgradeSelectable( cg.weaponSelect ) ) CG_NextWeapon_f( ); } - + // showing weapon select clears pickup item display, but not the blend blob cg.itemPickupTime = 0; @@ -1402,9 +1395,9 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color ) iconsize = height; length = width / height; } - + selectWindow = length / 2; - + for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) { if( !BG_InventoryContainsWeapon( i, cg.snap->ps.stats ) ) @@ -1422,7 +1415,7 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color ) { if( !BG_InventoryContainsUpgrade( i, cg.snap->ps.stats ) ) continue; - + if( i == cg.weaponSelect - 32 ) selectedItem = numItems; @@ -1435,7 +1428,7 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color ) { int displacement = i - selectWindow; int item = displacement + selectedItem; - + if( ( item >= 0 ) && ( item < numItems ) ) { trap_R_SetColor( color ); @@ -1444,7 +1437,7 @@ void CG_DrawItemSelect( rectDef_t *rect, vec4_t color ) CG_DrawPic( x, y, iconsize, iconsize, cg_weapons[ items[ item ] ].weaponIcon ); else if( items[ item ] > 32 ) CG_DrawPic( x, y, iconsize, iconsize, cg_upgrades[ items[ item ] - 32 ].upgradeIcon ); - + trap_R_SetColor( NULL ); /* if( displacement == 0 ) @@ -1469,13 +1462,13 @@ void CG_DrawItemSelectText( rectDef_t *rect, float scale, int textStyle ) int x, w; char *name; float *color; - + color = CG_FadeColor( cg.weaponSelectTime, WEAPON_SELECT_TIME ); if( !color ) return; - + trap_R_SetColor( color ); - + // draw the selected name if( cg.weaponSelect <= 32 ) { @@ -1520,7 +1513,7 @@ void CG_NextWeapon_f( void ) if( !cg.snap ) return; - + if( cg.snap->ps.pm_flags & PMF_FOLLOW ) { trap_SendClientCommand( "followprev\n" ); @@ -1547,7 +1540,7 @@ void CG_NextWeapon_f( void ) break; } } - + if( i == 64 ) cg.weaponSelect = original; } @@ -1564,7 +1557,7 @@ void CG_PrevWeapon_f( void ) if( !cg.snap ) return; - + if( cg.snap->ps.pm_flags & PMF_FOLLOW ) { trap_SendClientCommand( "follownext\n" ); @@ -1579,7 +1572,7 @@ void CG_PrevWeapon_f( void ) cg.weaponSelect--; if( cg.weaponSelect == -1 ) cg.weaponSelect = 63; - + if( cg.weaponSelect <= 32 ) { if( CG_WeaponSelectable( cg.weaponSelect ) ) @@ -1591,7 +1584,7 @@ void CG_PrevWeapon_f( void ) break; } } - + if( i == 64 ) cg.weaponSelect = original; } @@ -1607,7 +1600,7 @@ void CG_Weapon_f( void ) if( !cg.snap ) return; - + if( cg.snap->ps.pm_flags & PMF_FOLLOW ) return; @@ -1650,7 +1643,7 @@ void CG_FireWeapon( centity_t *cent, weaponMode_t weaponMode ) es = ¢->currentState; weaponNum = es->weapon; - + if( weaponNum == WP_NONE ) return; @@ -1659,7 +1652,7 @@ void CG_FireWeapon( centity_t *cent, weaponMode_t weaponMode ) CG_Error( "CG_FireWeapon: ent->weapon >= WP_NUM_WEAPONS" ); return; } - + wi = &cg_weapons[ weaponNum ]; // mark the entity as muzzle flashing, so when it is added it will @@ -1668,18 +1661,18 @@ void CG_FireWeapon( centity_t *cent, weaponMode_t weaponMode ) if( wi->wim[ weaponMode ].muzzleParticleSystem ) { - if( !( CG_IsParticleSystemValid( ¢->muzzlePS ) && - CG_IsParticleSystemInfinite( cent->muzzlePS ) ) ) + if( !CG_IsParticleSystemValid( ¢->muzzlePS ) || + !CG_IsParticleSystemInfinite( cent->muzzlePS ) ) cent->muzzlePsTrigger = qtrue; } - + // play a sound for( c = 0; c < 4; c++ ) { if( !wi->wim[ weaponMode ].flashSound[ c ] ) break; } - + if( c > 0 ) { c = rand( ) % c; @@ -1726,7 +1719,7 @@ void CG_MissileHitWall( weapon_t weaponNum, weaponMode_t weaponMode, int clientN vec3_t lightColor = { 0.0f, 0.0f, 0.0f }; localEntity_t *le; weaponInfo_t *weapon = &cg_weapons[ weaponNum ]; - + mark = weapon->wim[ weaponMode ].impactMark; radius = weapon->wim[ weaponMode ].impactMarkSize; mod = weapon->wim[ weaponMode ].impactModel; @@ -1743,7 +1736,7 @@ void CG_MissileHitWall( weapon_t weaponNum, weaponMode_t weaponMode, int clientN if( !weapon->wim[ weaponMode ].impactFleshSound[ c ] ) break; } - + if( c > 0 ) { c = rand( ) % c; @@ -1759,7 +1752,7 @@ void CG_MissileHitWall( weapon_t weaponNum, weaponMode_t weaponMode, int clientN if( !weapon->wim[ weaponMode ].impactSound[ c ] ) break; } - + if( c > 0 ) { c = rand( ) % c; @@ -1776,7 +1769,7 @@ void CG_MissileHitWall( weapon_t weaponNum, weaponMode_t weaponMode, int clientN CG_SetParticleSystemNormal( partSystem, dir ); CG_AttachParticleSystemToOrigin( partSystem ); } - + // // create the explosion // @@ -1803,7 +1796,7 @@ CG_MissileHitPlayer void CG_MissileHitPlayer( weapon_t weaponNum, weaponMode_t weaponMode, vec3_t origin, vec3_t dir, int entityNum ) { weaponInfo_t *weapon = &cg_weapons[ weaponNum ]; - + CG_Bleed( origin, entityNum ); if( weapon->wim[ weaponMode ].alwaysImpact ) @@ -1921,7 +1914,7 @@ static qboolean CG_CalcMuzzlePoint( int entityNum, vec3_t muzzle ) } cent = &cg_entities[entityNum]; - + if( !cent->currentValid ) return qfalse; @@ -1929,7 +1922,7 @@ static qboolean CG_CalcMuzzlePoint( int entityNum, vec3_t muzzle ) AngleVectors( cent->currentState.apos.trBase, forward, NULL, NULL ); anim = cent->currentState.legsAnim & ~ANIM_TOGGLEBIT; - + if( anim == LEGS_WALKCR || anim == LEGS_IDLECR ) muzzle[ 2 ] += CROUCH_VIEWHEIGHT; else @@ -1960,7 +1953,7 @@ void CG_Bullet( vec3_t end, int sourceEntityNum, vec3_t normal, qboolean flesh, if( CG_CalcMuzzlePoint( sourceEntityNum, start ) ) { CG_BubbleTrail( start, end, 32 ); - + // draw a tracer if( random( ) < cg_tracerChance.value ) CG_Tracer( start, end ); @@ -2041,7 +2034,7 @@ void CG_ShotgunFire( entityState_t *es ) VectorNormalize( v ); VectorScale( v, 32, v ); VectorAdd( es->pos.trBase, v, v ); - + CG_ShotgunPattern( es->pos.trBase, es->origin2, es->eventParm, es->otherEntityNum ); } diff --git a/src/cgame/tr_types.h b/src/cgame/tr_types.h index 6bff73ba..26240a2f 100644 --- a/src/cgame/tr_types.h +++ b/src/cgame/tr_types.h @@ -13,7 +13,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #ifndef __TR_TYPES_H #define __TR_TYPES_H @@ -191,7 +191,7 @@ typedef struct qboolean textureEnvAddAvailable; int vidWidth, vidHeight; - + // aspect is the screen's physical width / height, which may be different // than scrWidth / scrHeight if the pixels are non-square // normal screens should be 4/3, but wide aspect monitors may be 16/9 |