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 | |
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
69 files changed, 6294 insertions, 6425 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 diff --git a/src/game/bg_lib.c b/src/game/bg_lib.c index b0f543bf..b4ba5696 100644 --- a/src/game/bg_lib.c +++ b/src/game/bg_lib.c @@ -15,7 +15,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "q_shared.h" /*- @@ -228,7 +228,7 @@ char *strcat( char *strDestination, const char *strSource ) s = strDestination; while( *s ) s++; - + while( *strSource ) *s++ = *strSource++; @@ -241,7 +241,7 @@ char *strcpy( char *strDestination, const char *strSource ) char *s; s = strDestination; - + while( *strSource ) *s++ = *strSource++; @@ -266,15 +266,15 @@ char *strrchr( const char *string, int c ) { int i, length = strlen( string ); char *p; - + for( i = length - 1; i >= 0; i-- ) { p = (char *)&string[ i ]; - + if( *p == c ) return (char *)p; } - + return (char *)0; } @@ -301,10 +301,10 @@ char *strstr( const char *string, const char *strCharSet ) if( string[ i ] != strCharSet[ i ] ) break; } - + if( !strCharSet[ i ] ) return (char *)string; - + string++; } return (char *)0; @@ -351,7 +351,7 @@ void *memmove( void *dest, const void *src, size_t count ) for( i = 0; i < count; i++ ) ( (char *)dest )[ i ] = ( (char *)src )[ i ]; } - + return dest; } @@ -803,14 +803,14 @@ double atan2( double y, double x ) { } } - return base + dir * i * ( M_PI/2048); + return base + dir * i * ( M_PI/2048); } #endif #ifdef Q3_VM -// bk001127 - guarded this tan replacement +// bk001127 - guarded this tan replacement // ld: undefined versioned symbol name tan@@GLIBC_2.0 double tan( double x ) { @@ -880,10 +880,10 @@ double acos( double x ) { float z, subp, p, q, r, w, s, c, df; int hx, ix; - + GET_FLOAT_WORD( hx, x ); ix = hx & 0x7fffffff; - + if( ix == 0x3f800000 ) { // |x|==1 if( hx > 0 ) @@ -895,12 +895,12 @@ double acos( double x ) { // |x| >= 1 return (x-x)/(x-x); // acos(|x|>1) is NaN } - + if( ix < 0x3f000000 ) { // |x| < 0.5 if( ix <= 0x23000000 ) return pio2_hi + pio2_lo;//if|x|<2**-57 - + z = x * x; subp = pS3 + z * ( pS4 + z * pS5 ); // chop up expression to keep mac register based stack happy @@ -945,7 +945,7 @@ static const float bp[ ] = { 1.0, 1.5, }, dp_h[ ] = { 0.0, 5.84960938e-01, }, /* 0x3f15c000 */ dp_l[ ] = { 0.0, 1.56322085e-06, }, /* 0x35d1cfdc */ -huge = 1.0e+30, +huge = 1.0e+30, tiny = 1.0e-30, zero = 0.0, one = 1.0, @@ -984,13 +984,13 @@ copysignf static float copysignf( float x, float y ) { unsigned int ix, iy; - + GET_FLOAT_WORD( ix, x ); GET_FLOAT_WORD( iy, y ); SET_FLOAT_WORD( x, ( ix & 0x7fffffff ) | ( iy & 0x80000000 ) ); return x; } - + /* ================== __scalbnf @@ -999,25 +999,25 @@ __scalbnf static float __scalbnf( float x, int n ) { int k, ix; - + GET_FLOAT_WORD( ix, x ); - + k = ( ix & 0x7f800000 ) >> 23; /* extract exponent */ - + if( k == 0 ) { /* 0 or subnormal x */ if( ( ix & 0x7fffffff ) == 0 ) return x; /* +-0 */ - + x *= two25; GET_FLOAT_WORD( ix, x ); k = ( ( ix & 0x7f800000 ) >> 23 ) - 25; } if( k == 0xff ) return x+x; /* NaN or Inf */ - + k = k + n; - + if( n > 50000 || k > 0xfe ) return huge * copysignf( huge, x ); /* overflow */ if ( n < -50000 ) @@ -1029,7 +1029,7 @@ static float __scalbnf( float x, int n ) } if( k <= -25 ) return tiny * copysignf( tiny, x ); /*underflow*/ - + k += 25; /* subnormal result */ SET_FLOAT_WORD( x, ( ix & 0x807fffff ) | ( k << 23 ) ); return x * twom25; @@ -1046,13 +1046,13 @@ float pow( float x, float y ) float y1, subt1, t1, t2, subr, r, s, t, u, v, w; int i, j, k, yisint, n; int hx, hy, ix, iy, is; - + /*TA: for some reason the Q3 VM goes apeshit when x = 1.0 and y > 1.0. Curiously this doesn't happen with gcc - hence this hack*/ + hence this hack*/ if( x == 1.0 ) return x; - + GET_FLOAT_WORD( hx, x ); GET_FLOAT_WORD( hy, y ); ix = hx & 0x7fffffff; @@ -1095,7 +1095,7 @@ float pow( float x, float y ) else /* (|x|<1)**-,+inf = inf,0 */ return ( hy < 0 ) ? -y : zero; } - + if( iy == 0x3f800000 ) { /* y is +-1 */ if( hy < 0 ) @@ -1103,10 +1103,10 @@ float pow( float x, float y ) else return x; } - + if( hy == 0x40000000 ) return x * x; /* y is 2 */ - + if( hy == 0x3f000000 ) { /* y is 0.5 */ if( hx >= 0 ) /* x >= +0 */ @@ -1114,7 +1114,7 @@ float pow( float x, float y ) } ax = fabs( x ); - + /* special value of x */ if( ix == 0x7f800000 || ix == 0 || ix == 0x3f800000 ) { @@ -1128,7 +1128,7 @@ float pow( float x, float y ) else if( yisint == 1 ) z = -z; /* (x<0)**odd = -(|x|**odd) */ } - + return z; } @@ -1142,7 +1142,7 @@ float pow( float x, float y ) /* over/underflow if x is not close to one */ if( ix < 0x3f7ffff8 ) return ( hy < 0 ) ? huge * huge : tiny * tiny; - + if( ix > 0x3f800007 ) return ( hy > 0 ) ? huge * huge : tiny * tiny; /* now |1-x| is tiny <= 2**-20, suffice to compute @@ -1167,10 +1167,10 @@ float pow( float x, float y ) n -= 24; GET_FLOAT_WORD( ix, ax ); } - + n += ( ( ix ) >> 23 ) - 0x7f; j = ix & 0x007fffff; - + /* determine interval */ ix = j | 0x3f800000; /* normalize ix */ if( j <= 0x1cc471 ) @@ -1236,7 +1236,7 @@ float pow( float x, float y ) p_h = y1 * t1; z = p_l + p_h; GET_FLOAT_WORD( j, z ); - + if( j > 0x43000000 ) /* if z > 128 */ return s * huge * huge; /* overflow */ else if( j == 0x43000000 ) @@ -1251,27 +1251,27 @@ float pow( float x, float y ) if( p_l <= z - p_h ) return s * tiny * tiny; /* underflow */ } - + /* * compute 2**(p_h+p_l) */ i = j & 0x7fffffff; k = ( i >> 23 ) - 0x7f; n = 0; - + if( i > 0x3f000000 ) { /* if |z| > 0.5, set n = [z+0.5] */ n = j + ( 0x00800000 >> ( k + 1 ) ); k = ( ( n & 0x7fffffff ) >> 23 ) - 0x7f; /* new k for n */ SET_FLOAT_WORD( t, n & ~( 0x007fffff >> k ) ); n = ( ( n & 0x007fffff ) | 0x00800000 ) >> ( 23 - k ); - + if( j < 0 ) n = -n; - + p_h -= t; } - + t = p_l + p_h; GET_FLOAT_WORD( is, t ); SET_FLOAT_WORD( t, is & 0xfffff000 ); @@ -1287,12 +1287,12 @@ float pow( float x, float y ) z = one - ( r - z ); GET_FLOAT_WORD( j, z ); j += (n << 23 ); - + if( ( j >> 23 ) <= 0 ) z = __scalbnf( z, n ); /* subnormal output */ else SET_FLOAT_WORD( z, j ); - + return s * z; } @@ -1324,7 +1324,7 @@ double atof( const char *string ) { if( !*string ) return 0; - + string++; } @@ -1335,12 +1335,12 @@ double atof( const char *string ) string++; sign = 1; break; - + case '-': string++; sign = -1; break; - + default: sign = 1; break; @@ -1349,7 +1349,7 @@ double atof( const char *string ) // read digits value = 0; c = string[ 0 ]; - + if( c != '.' ) { do @@ -1406,7 +1406,7 @@ double _atof( const char **stringPtr ) *stringPtr = string; return 0; } - + string++; } @@ -1417,12 +1417,12 @@ double _atof( const char **stringPtr ) string++; sign = 1; break; - + case '-': string++; sign = -1; break; - + default: sign = 1; break; @@ -1497,12 +1497,12 @@ int atoi( const char *string ) string++; sign = 1; break; - + case '-': string++; sign = -1; break; - + default: sign = 1; break; @@ -1551,12 +1551,12 @@ int _atoi( const char **stringPtr ) string++; sign = 1; break; - + case '-': string++; sign = -1; break; - + default: sign = 1; break; @@ -1569,7 +1569,7 @@ int _atoi( const char **stringPtr ) c = *string++; if( c < '0' || c > '9' ) break; - + c -= '0'; value = value * 10 + c; } while( 1 ); @@ -1673,7 +1673,7 @@ void AddFloat( char **buf_p, float fval, int width, int prec ) // write the float number digits = 0; val = (int)fval; - + do { text[ digits++ ] = '0' + val % 10; @@ -1696,10 +1696,10 @@ void AddFloat( char **buf_p, float fval, int width, int prec ) if( prec < 0 ) prec = 6; - + // write the fraction digits = 0; - + while( digits < prec ) { fval -= (int)fval; @@ -1714,7 +1714,7 @@ void AddFloat( char **buf_p, float fval, int width, int prec ) *buf++ = '.'; for( prec = 0; prec < digits; prec++ ) *buf++ = text[ prec ]; - + *buf_p = buf; } } @@ -1825,19 +1825,19 @@ reswitch: case '-': flags |= LADJUST; goto rflag; - + case '.': n = 0; while( is_digit( ( ch = *fmt++ ) ) ) n = 10 * n + ( ch - '0' ); - + prec = n < 0 ? -1 : n; goto reswitch; - + case '0': flags |= ZEROPAD; goto rflag; - + case '1': case '2': case '3': @@ -1853,21 +1853,21 @@ reswitch: n = 10 * n + ( ch - '0' ); ch = *fmt++; } while( is_digit( ch ) ); - + width = n; goto reswitch; - + case 'c': *buf_p++ = (char)*arg; arg++; break; - + case 'd': case 'i': AddInt( &buf_p, *arg, width, flags ); arg++; break; - + case 'f': AddFloat( &buf_p, *(double *)arg, width, prec ); #ifdef __LCC__ @@ -1876,21 +1876,21 @@ reswitch: arg += 2; #endif break; - + case 's': AddString( &buf_p, (char *)*arg, width, prec ); arg++; break; - + case 'v': AddVec3_t( &buf_p, (vec_t *)*arg, width, prec ); arg++; break; - + case '%': *buf_p++ = ch; break; - + default: *buf_p++ = (char)*arg; arg++; diff --git a/src/game/bg_lib.h b/src/game/bg_lib.h index 221e19e4..d31f4cf8 100644 --- a/src/game/bg_lib.h +++ b/src/game/bg_lib.h @@ -15,7 +15,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + typedef int size_t; typedef char * va_list; @@ -42,8 +42,8 @@ typedef char * va_list; // Misc functions typedef int cmp_t( const void *, const void * ); void qsort( void *a, size_t n, size_t es, cmp_t *cmp ); -void srand( unsigned seed ); -int rand( void ); +void srand( unsigned seed ); +int rand( void ); // String functions size_t strlen( const char *string ); diff --git a/src/game/bg_local.h b/src/game/bg_local.h index 88dfe5be..7e5ea46f 100644 --- a/src/game/bg_local.h +++ b/src/game/bg_local.h @@ -26,7 +26,7 @@ #define OVERCLIP 1.001f #define FALLING_THRESHOLD -900.0f //what vertical speed to start falling sound at - + // all of the locals will be zeroed before each // pmove, just to make damn sure we don't have diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index dcd33bf1..d2aefabc 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "q_shared.h" #include "bg_public.h" @@ -27,7 +27,7 @@ void trap_FS_Seek( fileHandle_t f, long offset, fsOrigin_t origin ); // fsOrigin buildableAttributes_t bg_buildableList[ ] = { { - BA_A_SPAWN, //int buildNum; + BA_A_SPAWN, //int buildNum; "eggpod", //char *buildName; "Egg", //char *humanName; "team_alien_spawn", //char *entityName; @@ -729,7 +729,7 @@ float BG_FindModelScaleForBuildable( int bclass ) if( bg_buildableList[ i ].buildNum == bclass ) return bg_buildableList[ i ].modelScale; } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindModelScaleForBuildable( %d )\n", bclass ); return 1.0f; } @@ -754,7 +754,7 @@ void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ) if( VectorLength( bg_buildableOverrideList[ bclass ].mins ) ) VectorCopy( bg_buildableOverrideList[ bclass ].mins, mins ); } - + if( maxs != NULL ) { VectorCopy( bg_buildableList[ i ].maxs, maxs ); @@ -762,14 +762,14 @@ void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ) if( VectorLength( bg_buildableOverrideList[ bclass ].maxs ) ) VectorCopy( bg_buildableOverrideList[ bclass ].maxs, maxs ); } - + return; } } - + if( mins != NULL ) VectorCopy( bg_buildableList[ 0 ].mins, mins ); - + if( maxs != NULL ) VectorCopy( bg_buildableList[ 0 ].maxs, maxs ); } @@ -793,7 +793,7 @@ float BG_FindZOffsetForBuildable( int bclass ) return bg_buildableList[ i ].zOffset; } } - + return 0.0f; } @@ -813,7 +813,7 @@ trType_t BG_FindTrajectoryForBuildable( int bclass ) return bg_buildableList[ i ].traj; } } - + return TR_GRAVITY; } @@ -833,7 +833,7 @@ float BG_FindBounceForBuildable( int bclass ) return bg_buildableList[ i ].bounce; } } - + return 0.0; } @@ -853,7 +853,7 @@ int BG_FindBuildPointsForBuildable( int bclass ) return bg_buildableList[ i ].buildPoints; } } - + return 1000; } @@ -876,7 +876,7 @@ qboolean BG_FindStagesForBuildable( int bclass, stage_t stage ) return qfalse; } } - + return qfalse; } @@ -896,7 +896,7 @@ int BG_FindHealthForBuildable( int bclass ) return bg_buildableList[ i ].health; } } - + return 1000; } @@ -916,7 +916,7 @@ int BG_FindRegenRateForBuildable( int bclass ) return bg_buildableList[ i ].regenRate; } } - + return 0; } @@ -936,7 +936,7 @@ int BG_FindSplashDamageForBuildable( int bclass ) return bg_buildableList[ i ].splashDamage; } } - + return 50; } @@ -956,7 +956,7 @@ int BG_FindSplashRadiusForBuildable( int bclass ) return bg_buildableList[ i ].splashRadius; } } - + return 200; } @@ -976,7 +976,7 @@ int BG_FindMODForBuildable( int bclass ) return bg_buildableList[ i ].meansOfDeath; } } - + return MOD_UNKNOWN; } @@ -996,7 +996,7 @@ int BG_FindTeamForBuildable( int bclass ) return bg_buildableList[ i ].team; } } - + return BIT_NONE; } @@ -1016,7 +1016,7 @@ weapon_t BG_FindBuildWeaponForBuildable( int bclass ) return bg_buildableList[ i ].buildWeapon; } } - + return BA_NONE; } @@ -1036,7 +1036,7 @@ int BG_FindAnimForBuildable( int bclass ) return bg_buildableList[ i ].idleAnim; } } - + return BANIM_IDLE1; } @@ -1056,7 +1056,7 @@ int BG_FindNextThinkForBuildable( int bclass ) return bg_buildableList[ i ].nextthink; } } - + return 100; } @@ -1076,7 +1076,7 @@ int BG_FindBuildTimeForBuildable( int bclass ) return bg_buildableList[ i ].buildTime; } } - + return 10000; } @@ -1096,7 +1096,7 @@ qboolean BG_FindUsableForBuildable( int bclass ) return bg_buildableList[ i ].usable; } } - + return qfalse; } @@ -1116,7 +1116,7 @@ int BG_FindFireSpeedForBuildable( int bclass ) return bg_buildableList[ i ].turretFireSpeed; } } - + return 1000; } @@ -1136,7 +1136,7 @@ int BG_FindRangeForBuildable( int bclass ) return bg_buildableList[ i ].turretRange; } } - + return 1000; } @@ -1156,7 +1156,7 @@ weapon_t BG_FindProjTypeForBuildable( int bclass ) return bg_buildableList[ i ].turretProjType; } } - + return WP_NONE; } @@ -1176,7 +1176,7 @@ float BG_FindMinNormalForBuildable( int bclass ) return bg_buildableList[ i ].minNormal; } } - + return 0.707f; } @@ -1196,7 +1196,7 @@ qboolean BG_FindInvertNormalForBuildable( int bclass ) return bg_buildableList[ i ].invertNormal; } } - + return qfalse; } @@ -1216,7 +1216,7 @@ int BG_FindCreepTestForBuildable( int bclass ) return bg_buildableList[ i ].creepTest; } } - + return qfalse; } @@ -1236,7 +1236,7 @@ int BG_FindCreepSizeForBuildable( int bclass ) return bg_buildableList[ i ].creepSize; } } - + return CREEP_BASESIZE; } @@ -1256,7 +1256,7 @@ int BG_FindDCCTestForBuildable( int bclass ) return bg_buildableList[ i ].dccTest; } } - + return qfalse; } @@ -1276,7 +1276,7 @@ int BG_FindUniqueTestForBuildable( int bclass ) return bg_buildableList[ i ].reactorTest; } } - + return qfalse; } @@ -1306,7 +1306,7 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO char text[ 20000 ]; fileHandle_t f; float scale; - + // load the file len = trap_FS_FOpenFile( filename, &f, FS_READ ); @@ -1318,7 +1318,7 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO Com_Printf( S_COLOR_RED "ERROR: Buildable file %s too long\n", filename ); return qfalse; } - + trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); @@ -1330,7 +1330,7 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO while( 1 ) { token = COM_Parse( &text_p ); - + if( !token ) break; @@ -1340,24 +1340,24 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO if( !Q_stricmp( token, "model" ) ) { 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; Q_strncpyz( bao->models[ index ], token, sizeof( bao->models[ 0 ] ) ); - + continue; } else if( !Q_stricmp( token, "modelScale" ) ) @@ -1367,7 +1367,7 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO break; scale = atof( token ); - + if( scale < 0.0f ) scale = 0.0f; @@ -1382,10 +1382,10 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO token = COM_Parse( &text_p ); if( !token ) break; - + bao->mins[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "maxs" ) ) @@ -1395,16 +1395,16 @@ static qboolean BG_ParseBuildableFile( const char *filename, buildableAttributeO token = COM_Parse( &text_p ); if( !token ) break; - + bao->maxs[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "zOffset" ) ) { float offset; - + token = COM_Parse( &text_p ); if( !token ) break; @@ -1439,7 +1439,7 @@ void BG_InitBuildableOverrides( void ) for( i = BA_NONE + 1; i < BA_NUM_BUILDABLES; i++ ) { bao = BG_FindOverrideForBuildable( i ); - + BG_ParseBuildableFile( va( "overrides/buildables/%s.cfg", BG_FindNameForBuildable( i ) ), bao ); } } @@ -1448,7 +1448,7 @@ void BG_InitBuildableOverrides( void ) classAttributes_t bg_classList[ ] = { - { + { PCL_NONE, //int classnum; "spectator", //char *className; "Spectator", //char *humanName; @@ -1486,7 +1486,7 @@ classAttributes_t bg_classList[ ] = 0, //int cost; 0 //int value; }, - { + { PCL_ALIEN_BUILDER0, //int classnum; "builder", //char *className; "Builder", //char *humanName; @@ -1524,7 +1524,7 @@ classAttributes_t bg_classList[ ] = ABUILDER_COST, //int cost; ABUILDER_VALUE //int value; }, - { + { PCL_ALIEN_BUILDER0_UPG, //int classnum; "builderupg", //char *classname; "Advanced Builder", //char *humanname; @@ -1917,14 +1917,14 @@ classAttributes_t bg_classList[ ] = //this isn't a real class, but a dummy to force the client to precache the model //FIXME: one day do this in a less hacky fashion PCL_HUMAN_BSUIT, "human_bsuit", "bsuit", - + "keel", - 1.0f, + 1.0f, "default", 1.0f, - - "bsuit", ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), { 0, 0, 0 }, { 0, 0, 0, }, - { 0, 0, 0, }, { 0, 0, 0, }, { 0, 0, 0, }, 0.0f, 0, 0, 0, 0.0f, 0, 0, WP_NONE, 0.0f, 0, + + "bsuit", ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), { 0, 0, 0 }, { 0, 0, 0, }, + { 0, 0, 0, }, { 0, 0, 0, }, { 0, 0, 0, }, 0.0f, 0, 0, 0, 0.0f, 0, 0, WP_NONE, 0.0f, 0, 0.0f, 1.0f, 0, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 270.0f, 1.0f, { PCL_NONE, PCL_NONE, PCL_NONE }, 0, 0 } }; @@ -2038,7 +2038,7 @@ float BG_FindModelScaleForClass( int pclass ) return bg_classList[ i ].modelScale; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindModelScaleForClass( %d )\n", pclass ); return 1.0f; } @@ -2085,7 +2085,7 @@ float BG_FindShadowScaleForClass( int pclass ) return bg_classList[ i ].shadowScale; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindShadowScaleForClass( %d )\n", pclass ); return 1.0f; } @@ -2132,7 +2132,7 @@ qboolean BG_FindStagesForClass( int pclass, stage_t stage ) return qfalse; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindStagesForClass\n" ); return qfalse; } @@ -2157,7 +2157,7 @@ void BG_FindBBoxForClass( int pclass, vec3_t mins, vec3_t maxs, vec3_t cmaxs, ve if( VectorLength( bg_classOverrideList[ pclass ].mins ) ) VectorCopy( bg_classOverrideList[ pclass ].mins, mins ); } - + if( maxs != NULL ) { VectorCopy( bg_classList[ i ].maxs, maxs ); @@ -2165,7 +2165,7 @@ void BG_FindBBoxForClass( int pclass, vec3_t mins, vec3_t maxs, vec3_t cmaxs, ve if( VectorLength( bg_classOverrideList[ pclass ].maxs ) ) VectorCopy( bg_classOverrideList[ pclass ].maxs, maxs ); } - + if( cmaxs != NULL ) { VectorCopy( bg_classList[ i ].crouchMaxs, cmaxs ); @@ -2173,7 +2173,7 @@ void BG_FindBBoxForClass( int pclass, vec3_t mins, vec3_t maxs, vec3_t cmaxs, ve if( VectorLength( bg_classOverrideList[ pclass ].crouchMaxs ) ) VectorCopy( bg_classOverrideList[ pclass ].crouchMaxs, cmaxs ); } - + if( dmins != NULL ) { VectorCopy( bg_classList[ i ].deadMins, dmins ); @@ -2181,7 +2181,7 @@ void BG_FindBBoxForClass( int pclass, vec3_t mins, vec3_t maxs, vec3_t cmaxs, ve if( VectorLength( bg_classOverrideList[ pclass ].deadMins ) ) VectorCopy( bg_classOverrideList[ pclass ].deadMins, dmins ); } - + if( dmaxs != NULL ) { VectorCopy( bg_classList[ i ].deadMaxs, dmaxs ); @@ -2193,19 +2193,19 @@ void BG_FindBBoxForClass( int pclass, vec3_t mins, vec3_t maxs, vec3_t cmaxs, ve return; } } - + if( mins != NULL ) VectorCopy( bg_classList[ 0 ].mins, mins ); - + if( maxs != NULL ) VectorCopy( bg_classList[ 0 ].maxs, maxs ); - + if( cmaxs != NULL ) VectorCopy( bg_classList[ 0 ].crouchMaxs, cmaxs ); - + if( dmins != NULL ) VectorCopy( bg_classList[ 0 ].deadMins, dmins ); - + if( dmaxs != NULL ) VectorCopy( bg_classList[ 0 ].deadMaxs, dmaxs ); } @@ -2229,7 +2229,7 @@ float BG_FindZOffsetForClass( int pclass ) return bg_classList[ i ].zOffset; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindZOffsetForClass\n" ); return 0.0f; } @@ -2249,17 +2249,17 @@ void BG_FindViewheightForClass( int pclass, int *viewheight, int *cViewheight ) { if( viewheight != NULL ) *viewheight = bg_classList[ i ].viewheight; - + if( cViewheight != NULL ) *cViewheight = bg_classList[ i ].crouchViewheight; return; } } - + if( viewheight != NULL ) *viewheight = bg_classList[ 0 ].viewheight; - + if( cViewheight != NULL ) *cViewheight = bg_classList[ 0 ].crouchViewheight; } @@ -2280,7 +2280,7 @@ int BG_FindHealthForClass( int pclass ) return bg_classList[ i ].health; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindHealthForClass\n" ); return 100; } @@ -2301,7 +2301,7 @@ float BG_FindFallDamageForClass( int pclass ) return bg_classList[ i ].fallDamage; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindFallDamageForClass\n" ); return 100; } @@ -2322,7 +2322,7 @@ int BG_FindRegenRateForClass( int pclass ) return bg_classList[ i ].regenRate; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindRegenRateForClass\n" ); return 0; } @@ -2343,7 +2343,7 @@ int BG_FindFovForClass( int pclass ) return bg_classList[ i ].fov; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindFovForClass\n" ); return 90; } @@ -2364,7 +2364,7 @@ float BG_FindBobForClass( int pclass ) return bg_classList[ i ].bob; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindBobForClass\n" ); return 0.002; } @@ -2385,7 +2385,7 @@ float BG_FindBobCycleForClass( int pclass ) return bg_classList[ i ].bobCycle; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindBobCycleForClass\n" ); return 1.0f; } @@ -2406,7 +2406,7 @@ float BG_FindSpeedForClass( int pclass ) return bg_classList[ i ].speed; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindSpeedForClass\n" ); return 1.0f; } @@ -2427,7 +2427,7 @@ float BG_FindAccelerationForClass( int pclass ) return bg_classList[ i ].acceleration; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindAccelerationForClass\n" ); return 10.0f; } @@ -2448,7 +2448,7 @@ float BG_FindAirAccelerationForClass( int pclass ) return bg_classList[ i ].airAcceleration; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindAirAccelerationForClass\n" ); return 1.0f; } @@ -2469,7 +2469,7 @@ float BG_FindFrictionForClass( int pclass ) return bg_classList[ i ].friction; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindFrictionForClass\n" ); return 6.0f; } @@ -2490,7 +2490,7 @@ float BG_FindStopSpeedForClass( int pclass ) return bg_classList[ i ].stopSpeed; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindStopSpeedForClass\n" ); return 100.0f; } @@ -2511,7 +2511,7 @@ float BG_FindJumpMagnitudeForClass( int pclass ) return bg_classList[ i ].jumpMagnitude; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindJumpMagnitudeForClass\n" ); return 270.0f; } @@ -2532,7 +2532,7 @@ float BG_FindKnockbackScaleForClass( int pclass ) return bg_classList[ i ].knockbackScale; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindKnockbackScaleForClass\n" ); return 1.0f; } @@ -2553,7 +2553,7 @@ int BG_FindSteptimeForClass( int pclass ) return bg_classList[ i ].steptime; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindSteptimeForClass\n" ); return 200; } @@ -2594,7 +2594,7 @@ weapon_t BG_FindStartWeaponForClass( int pclass ) return bg_classList[ i ].startWeapon; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindStartWeaponForClass\n" ); return WP_NONE; } @@ -2615,7 +2615,7 @@ float BG_FindBuildDistForClass( int pclass ) return bg_classList[ i ].buildDist; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindBuildDistForClass\n" ); return 0.0f; } @@ -2630,7 +2630,7 @@ int BG_ClassCanEvolveFromTo( int fclass, int tclass, int credits, int num ) int i, j, cost; cost = BG_FindCostOfClass( tclass ); - + //base case if( credits < cost ) return -1; @@ -2649,14 +2649,14 @@ int BG_ClassCanEvolveFromTo( int fclass, int tclass, int credits, int num ) for( j = 0; j < 3; j++ ) { int sub; - + cost = BG_FindCostOfClass( bg_classList[ i ].children[ j ] ); sub = BG_ClassCanEvolveFromTo( bg_classList[ i ].children[ j ], tclass, credits - cost, num + cost ); if( sub >= 0 ) return sub; } - + return -1; //may as well return by this point } } @@ -2680,7 +2680,7 @@ int BG_FindValueOfClass( int pclass ) return bg_classList[ i ].value; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindValueOfClass\n" ); return 0; } @@ -2701,7 +2701,7 @@ int BG_FindCostOfClass( int pclass ) return bg_classList[ i ].cost; } } - + Com_Printf( S_COLOR_YELLOW "WARNING: fallthrough in BG_FindCostOfClass\n" ); return 0; } @@ -2732,7 +2732,7 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides char text[ 20000 ]; fileHandle_t f; float scale = 0.0f; - + // load the file len = trap_FS_FOpenFile( filename, &f, FS_READ ); @@ -2744,7 +2744,7 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides Com_Printf( S_COLOR_RED "ERROR: Class file %s too long\n", filename ); return qfalse; } - + trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); @@ -2756,7 +2756,7 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides while( 1 ) { token = COM_Parse( &text_p ); - + if( !token ) break; @@ -2770,7 +2770,7 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides break; Q_strncpyz( cao->modelName, token, sizeof( cao->modelName ) ); - + continue; } else if( !Q_stricmp( token, "skin" ) ) @@ -2780,7 +2780,7 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides break; Q_strncpyz( cao->skinName, token, sizeof( cao->skinName ) ); - + continue; } else if( !Q_stricmp( token, "hud" ) ) @@ -2790,7 +2790,7 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides break; Q_strncpyz( cao->hudName, token, sizeof( cao->hudName ) ); - + continue; } else if( !Q_stricmp( token, "modelScale" ) ) @@ -2800,7 +2800,7 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides break; scale = atof( token ); - + if( scale < 0.0f ) scale = 0.0f; @@ -2815,7 +2815,7 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides break; scale = atof( token ); - + if( scale < 0.0f ) scale = 0.0f; @@ -2830,10 +2830,10 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides token = COM_Parse( &text_p ); if( !token ) break; - + cao->mins[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "maxs" ) ) @@ -2843,10 +2843,10 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides token = COM_Parse( &text_p ); if( !token ) break; - + cao->maxs[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "deadMins" ) ) @@ -2856,10 +2856,10 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides token = COM_Parse( &text_p ); if( !token ) break; - + cao->deadMins[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "deadMaxs" ) ) @@ -2869,10 +2869,10 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides token = COM_Parse( &text_p ); if( !token ) break; - + cao->deadMaxs[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "crouchMaxs" ) ) @@ -2882,16 +2882,16 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides token = COM_Parse( &text_p ); if( !token ) break; - + cao->crouchMaxs[ i ] = atof( token ); } - + continue; } else if( !Q_stricmp( token, "zOffset" ) ) { float offset; - + token = COM_Parse( &text_p ); if( !token ) break; @@ -2909,7 +2909,7 @@ static qboolean BG_ParseClassFile( const char *filename, classAttributeOverrides break; Q_strncpyz( cao->humanName, token, sizeof( cao->humanName ) ); - + continue; } @@ -2936,7 +2936,7 @@ void BG_InitClassOverrides( void ) for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { cao = BG_FindOverrideForClass( i ); - + BG_ParseClassFile( va( "overrides/classes/%s.cfg", BG_FindNameForClassNum( i ) ), cao ); } } @@ -3586,7 +3586,7 @@ int BG_FindPriceForWeapon( int weapon ) return bg_weapons[ i ].price; } } - + return 100; } @@ -3609,7 +3609,7 @@ qboolean BG_FindStagesForWeapon( int weapon, stage_t stage ) return qfalse; } } - + return qfalse; } @@ -3629,7 +3629,7 @@ int BG_FindSlotsForWeapon( int weapon ) return bg_weapons[ i ].slots; } } - + return SLOT_WEAPON; } @@ -3768,7 +3768,7 @@ int BG_FindRepeatRate1ForWeapon( int weapon ) if( bg_weapons[ i ].weaponNum == weapon ) return bg_weapons[ i ].repeatRate1; } - + return 1000; } @@ -3786,7 +3786,7 @@ int BG_FindRepeatRate2ForWeapon( int weapon ) if( bg_weapons[ i ].weaponNum == weapon ) return bg_weapons[ i ].repeatRate2; } - + return 1000; } @@ -3804,7 +3804,7 @@ int BG_FindRepeatRate3ForWeapon( int weapon ) if( bg_weapons[ i ].weaponNum == weapon ) return bg_weapons[ i ].repeatRate3; } - + return 1000; } @@ -3824,7 +3824,7 @@ int BG_FindReloadTimeForWeapon( int weapon ) return bg_weapons[ i ].reloadTime; } } - + return 1000; } @@ -3944,7 +3944,7 @@ int BG_FindBuildDelayForWeapon( int weapon ) return bg_weapons[ i ].buildDelay; } } - + return 0; } @@ -4080,7 +4080,7 @@ int BG_FindPriceForUpgrade( int upgrade ) return bg_upgrades[ i ].price; } } - + return 100; } @@ -4103,7 +4103,7 @@ qboolean BG_FindStagesForUpgrade( int upgrade, stage_t stage ) return qfalse; } } - + return qfalse; } @@ -4123,7 +4123,7 @@ int BG_FindSlotsForUpgrade( int upgrade ) return bg_upgrades[ i ].slots; } } - + return SLOT_NONE; } @@ -4260,18 +4260,18 @@ void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) case TR_INTERPOLATE: VectorCopy( tr->trBase, result ); break; - + case TR_LINEAR: deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds VectorMA( tr->trBase, deltaTime, tr->trDelta, result ); break; - + case TR_SINE: deltaTime = ( atTime - tr->trTime ) / (float)tr->trDuration; phase = sin( deltaTime * M_PI * 2 ); VectorMA( tr->trBase, phase, tr->trDelta, result ); break; - + case TR_LINEAR_STOP: if( atTime > tr->trTime + tr->trDuration ) atTime = tr->trTime + tr->trDuration; @@ -4279,22 +4279,22 @@ void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds if( deltaTime < 0 ) deltaTime = 0; - + VectorMA( tr->trBase, deltaTime, tr->trDelta, result ); break; - + case TR_GRAVITY: deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds VectorMA( tr->trBase, deltaTime, tr->trDelta, result ); result[ 2 ] -= 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity... break; - + case TR_BUOYANCY: deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds VectorMA( tr->trBase, deltaTime, tr->trDelta, result ); result[ 2 ] += 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity... break; - + default: Com_Error( ERR_DROP, "BG_EvaluateTrajectory: unknown trType: %i", tr->trTime ); break; @@ -4319,18 +4319,18 @@ void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t resu case TR_INTERPOLATE: VectorClear( result ); break; - + case TR_LINEAR: VectorCopy( tr->trDelta, result ); break; - + case TR_SINE: deltaTime = ( atTime - tr->trTime ) / (float)tr->trDuration; phase = cos( deltaTime * M_PI * 2 ); // derivative of sin = cos phase *= 0.5; VectorScale( tr->trDelta, phase, result ); break; - + case TR_LINEAR_STOP: if( atTime > tr->trTime + tr->trDuration ) { @@ -4339,19 +4339,19 @@ void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t resu } VectorCopy( tr->trDelta, result ); break; - + case TR_GRAVITY: deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds VectorCopy( tr->trDelta, result ); result[ 2 ] -= DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity... break; - + case TR_BUOYANCY: deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds VectorCopy( tr->trDelta, result ); result[ 2 ] += DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity... break; - + default: Com_Error( ERR_DROP, "BG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime ); break; @@ -4384,8 +4384,6 @@ char *eventnames[ ] = "EV_FALL_FAR", "EV_FALLING", - "EV_JUMP_PAD", // boing sound at origin", jump sound on player - "EV_JUMP", "EV_WATER_TOUCH", // foot touches "EV_WATER_LEAVE", // foot leaves @@ -4421,7 +4419,7 @@ char *eventnames[ ] = "EV_LEV1_GRAB", "EV_LEV4_CHARGE_PREPARE", "EV_LEV4_CHARGE_START", - + "EV_PAIN", "EV_DEATH1", "EV_DEATH2", @@ -4440,7 +4438,7 @@ char *eventnames[ ] = "EV_ALIEN_ACIDTUBE", "EV_MEDKIT_USED", - + "EV_ALIEN_EVOLVE", "EV_ALIEN_EVOLVE_FAILED", @@ -4451,9 +4449,9 @@ char *eventnames[ ] = "EV_OVERMIND_ATTACK", //TA: overmind under attack "EV_OVERMIND_DYING", //TA: overmind close to death "EV_OVERMIND_SPAWNS", //TA: overmind needs spawns - + "EV_DCC_ATTACK", //TA: dcc under attack - + "EV_RPTUSE_SOUND" //TA: trigger a sound }; @@ -4473,7 +4471,7 @@ void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerSta { char buf[ 256 ]; trap_Cvar_VariableStringBuffer( "showevents", buf, sizeof( buf ) ); - + if( atof( buf ) != 0 ) { #ifdef QAGAME @@ -4494,45 +4492,6 @@ void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerSta /* ======================== -BG_TouchJumpPad -======================== -*/ -void BG_TouchJumpPad( playerState_t *ps, entityState_t *jumppad ) -{ - vec3_t angles; - float p; - int effectNum; - - // spectators don't use jump pads - if( ps->pm_type != PM_NORMAL ) - return; - - // if we didn't hit this same jumppad the previous frame - // then don't play the event sound again if we are in a fat trigger - if( ps->jumppad_ent != jumppad->number ) - { - vectoangles( jumppad->origin2, angles); - - p = fabs( AngleNormalize180( angles[ PITCH ] ) ); - - if( p < 45 ) - effectNum = 0; - else - effectNum = 1; - - BG_AddPredictableEventToPlayerstate( EV_JUMP_PAD, effectNum, ps ); - } - - // remember hitting this jumppad this frame - ps->jumppad_ent = jumppad->number; - ps->jumppad_frame = ps->pmove_framecount; - // give the player the velocity from the jumppad - VectorCopy( jumppad->origin2, ps->velocity ); -} - - -/* -======================== BG_PlayerStateToEntityState This is done after each set of usercmd_t on the server, @@ -4554,16 +4513,16 @@ void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean s->pos.trType = TR_INTERPOLATE; VectorCopy( ps->origin, s->pos.trBase ); - + if( snap ) SnapVector( s->pos.trBase ); - + //set the trDelta for flag direction VectorCopy( ps->velocity, s->pos.trDelta ); s->apos.trType = TR_INTERPOLATE; VectorCopy( ps->viewangles, s->apos.trBase ); - + if( snap ) SnapVector( s->apos.trBase ); @@ -4584,7 +4543,7 @@ void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean s->eFlags |= EF_BLOBLOCKED; else s->eFlags &= ~EF_BLOBLOCKED; - + if( ps->externalEvent ) { s->event = ps->externalEvent; @@ -4680,7 +4639,7 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s s->clientNum = ps->clientNum; // ET_PLAYER looks here instead of at number // so corpses can also reference the proper config s->eFlags = ps->eFlags; - + if( ps->stats[STAT_HEALTH] <= 0 ) s->eFlags |= EF_DEAD; else @@ -4690,7 +4649,7 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s s->eFlags |= EF_BLOBLOCKED; else s->eFlags &= ~EF_BLOBLOCKED; - + if( ps->externalEvent ) { s->event = ps->externalEvent; @@ -4715,7 +4674,7 @@ void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s //store items held and active items in otherEntityNum s->modelindex = 0; s->modelindex2 = 0; - + for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ ) { if( BG_InventoryContainsUpgrade( i, ps->stats ) ) @@ -4750,7 +4709,7 @@ void BG_UnpackAmmoArray( int weapon, int psAmmo[ ], int psAmmo2[ ], int *ammo, i { int ammoarray[ 32 ]; int i; - + for( i = 0; i <= 15; i++ ) ammoarray[ i ] = psAmmo[ i ]; @@ -4800,7 +4759,7 @@ qboolean BG_WeaponIsFull( weapon_t weapon, int stats[ ], int psAmmo[ ], int psAm if( BG_InventoryContainsUpgrade( UP_BATTPACK, stats ) ) maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER ); - + return ( maxAmmo == ammo ) && ( maxClips == clips ); } @@ -4818,7 +4777,7 @@ void BG_AddWeaponToInventory( int weapon, int stats[ ] ) weaponList = ( stats[ STAT_WEAPONS ] & 0x0000FFFF ) | ( ( stats[ STAT_WEAPONS2 ] << 16 ) & 0xFFFF0000 ); weaponList |= ( 1 << weapon ); - + stats[ STAT_WEAPONS ] = weaponList & 0x0000FFFF; stats[ STAT_WEAPONS2 ] = ( weaponList & 0xFFFF0000 ) >> 16; @@ -4842,10 +4801,10 @@ void BG_RemoveWeaponFromInventory( int weapon, int stats[ ] ) weaponList = ( stats[ STAT_WEAPONS ] & 0x0000FFFF ) | ( ( stats[ STAT_WEAPONS2 ] << 16 ) & 0xFFFF0000 ); weaponList &= ~( 1 << weapon ); - + stats[ STAT_WEAPONS ] = weaponList & 0x0000FFFF; stats[ STAT_WEAPONS2 ] = ( weaponList & 0xFFFF0000 ) >> 16; - + stats[ STAT_SLOTS ] &= ~BG_FindSlotsForWeapon( weapon ); } @@ -4878,7 +4837,7 @@ void BG_AddUpgradeToInventory( int item, int stats[ ] ) if( stats[ STAT_SLOTS ] & BG_FindSlotsForUpgrade( item ) ) Com_Printf( S_COLOR_YELLOW "WARNING: Held items conflict with upgrade %d\n", item ); - + stats[ STAT_SLOTS ] |= BG_FindSlotsForUpgrade( item ); } @@ -4958,7 +4917,7 @@ qboolean BG_RotateAxis( vec3_t surfNormal, vec3_t inAxis[ 3 ], vec3_t ceilingNormal = { 0.0f, 0.0f, -1.0f }; vec3_t localNormal, xNormal; float rotAngle; - + //the grapplePoint being a surfNormal rotation Normal hack... see above :) if( ceiling ) { @@ -5004,13 +4963,13 @@ Find a place to build a buildable void BG_PositionBuildableRelativeToPlayer( const playerState_t *ps, const vec3_t mins, const vec3_t maxs, void (*trace)( trace_t *, const vec3_t, const vec3_t, - const vec3_t, const vec3_t, int, int ), + const vec3_t, const vec3_t, int, int ), vec3_t outOrigin, vec3_t outAngles, trace_t *tr ) { vec3_t forward, entityOrigin, targetOrigin; vec3_t angles, playerOrigin, playerNormal; float buildDist; - + if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) { if( ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) @@ -5020,7 +4979,7 @@ void BG_PositionBuildableRelativeToPlayer( const playerState_t *ps, } else VectorSet( playerNormal, 0.0f, 0.0f, 1.0f ); - + VectorCopy( ps->viewangles, angles ); VectorCopy( ps->origin, playerOrigin ); buildDist = BG_FindBuildDistForClass( ps->stats[ STAT_PCLASS ] ); @@ -5030,7 +4989,7 @@ void BG_PositionBuildableRelativeToPlayer( const playerState_t *ps, VectorNormalize( forward ); VectorMA( playerOrigin, buildDist, forward, entityOrigin ); - + VectorCopy( entityOrigin, targetOrigin ); //so buildings can be placed facing slopes @@ -5062,7 +5021,7 @@ int BG_GetValueOfHuman( playerState_t *ps ) if( BG_InventoryContainsUpgrade( i, ps->stats ) ) worth += BG_FindPriceForUpgrade( i ); } - + for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) { if( BG_InventoryContainsWeapon( i, ps->stats ) ) diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c index ed9f6c7b..88432f81 100644 --- a/src/game/bg_pmove.c +++ b/src/game/bg_pmove.c @@ -15,7 +15,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "q_shared.h" #include "bg_public.h" #include "bg_local.h" @@ -63,7 +63,7 @@ void PM_AddTouchEnt( int entityNum ) if( entityNum == ENTITYNUM_WORLD ) return; - + if( pm->numtouch == MAXTOUCH ) return; @@ -88,7 +88,7 @@ static void PM_StartTorsoAnim( int anim ) { if( pm->ps->pm_type >= PM_DEAD ) return; - + pm->ps->torsoAnim = ( ( pm->ps->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; } @@ -102,7 +102,7 @@ static void PM_StartLegsAnim( int anim ) { if( pm->ps->pm_type >= PM_DEAD ) return; - + //legsTimer is clamped too tightly for nonsegmented models if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) { @@ -172,7 +172,7 @@ static void PM_ForceLegsAnim( int anim ) pm->ps->legsTimer = 0; else pm->ps->torsoTimer = 0; - + PM_StartLegsAnim( anim ); } @@ -232,7 +232,7 @@ static void PM_Friction( void ) vec[ 2 ] = 0; // ignore slope movement speed = VectorLength( vec ); - + if( speed < 1 ) { vel[ 0 ] = 0; @@ -252,7 +252,7 @@ static void PM_Friction( void ) if( !( pm->ps->pm_flags & PMF_TIME_KNOCKBACK ) ) { float stopSpeed = BG_FindStopSpeedForClass( pm->ps->stats[ STAT_PCLASS ] ); - + control = speed < stopSpeed ? stopSpeed : speed; drop += control * BG_FindFrictionForClass( pm->ps->stats[ STAT_PCLASS ] ) * pml.frametime; } @@ -384,16 +384,16 @@ static float PM_CmdScale( usercmd_t *cmd ) if( pm->ps->weapon == WP_ALEVEL4 && pm->ps->pm_flags & PMF_CHARGE ) modifier *= ( 1.0f + ( pm->ps->stats[ STAT_MISC ] / (float)LEVEL4_CHARGE_TIME ) * ( LEVEL4_CHARGE_SPEED - 1.0f ) ); - + //slow player if charging up for a pounce if( ( pm->ps->weapon == WP_ALEVEL3 || pm->ps->weapon == WP_ALEVEL3_UPG ) && cmd->buttons & BUTTON_ATTACK2 ) modifier *= LEVEL3_POUNCE_SPEED_MOD; - + //slow the player if slow locked if( pm->ps->stats[ STAT_STATE ] & SS_SLOWLOCKED ) modifier *= ABUILDER_BLOB_SPEED_MOD; - + if( pm->ps->pm_type == PM_GRABBED ) modifier = 0.0f; @@ -413,7 +413,7 @@ static float PM_CmdScale( usercmd_t *cmd ) if( abs( cmd->upmove ) > max ) max = abs( cmd->upmove ); - + if( !max ) return 0; @@ -440,19 +440,19 @@ static void PM_SetMovementDir( void ) { if( pm->cmd.rightmove == 0 && pm->cmd.forwardmove > 0 ) pm->ps->movementDir = 0; - else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove > 0 ) + else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove > 0 ) pm->ps->movementDir = 1; else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove == 0 ) pm->ps->movementDir = 2; - else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove < 0 ) + else if( pm->cmd.rightmove < 0 && pm->cmd.forwardmove < 0 ) pm->ps->movementDir = 3; else if( pm->cmd.rightmove == 0 && pm->cmd.forwardmove < 0 ) pm->ps->movementDir = 4; - else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove < 0 ) + else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove < 0 ) pm->ps->movementDir = 5; else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove == 0 ) pm->ps->movementDir = 6; - else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove > 0 ) + else if( pm->cmd.rightmove > 0 && pm->cmd.forwardmove > 0 ) pm->ps->movementDir = 7; } else @@ -484,7 +484,7 @@ static void PM_CheckCharge( void ) pm->ps->pm_flags &= ~PMF_CHARGE; return; } - + if( pm->ps->stats[ STAT_MISC ] > 0 ) pm->ps->pm_flags |= PMF_CHARGE; else @@ -516,22 +516,22 @@ static qboolean PM_CheckPounce( void ) pml.groundPlane = qfalse; // jumping away pml.walking = qfalse; - + pm->ps->pm_flags |= PMF_CHARGE; - + pm->ps->groundEntityNum = ENTITYNUM_NONE; - + VectorMA( pm->ps->velocity, pm->ps->stats[ STAT_MISC ], pml.forward, pm->ps->velocity ); - + PM_AddEvent( EV_JUMP ); - + if( pm->cmd.forwardmove >= 0 ) { if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) PM_ForceLegsAnim( LEGS_JUMP ); else PM_ForceLegsAnim( NSPA_JUMP ); - + pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; } else @@ -540,7 +540,7 @@ static qboolean PM_CheckPounce( void ) PM_ForceLegsAnim( LEGS_JUMPB ); else PM_ForceLegsAnim( NSPA_JUMPBACK ); - + pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; } @@ -559,7 +559,7 @@ static qboolean PM_CheckWallJump( void ) float normalFraction = 1.5f; float cmdFraction = 1.0f; float upFraction = 1.5f; - + if( pm->ps->pm_flags & PMF_RESPAWNED ) return qfalse; // don't allow jump until all buttons are up @@ -587,35 +587,35 @@ static qboolean PM_CheckWallJump( void ) pm->ps->pm_flags |= PMF_JUMP_HELD; pm->ps->groundEntityNum = ENTITYNUM_NONE; - + ProjectPointOnPlane( forward, pml.forward, pm->ps->grapplePoint ); ProjectPointOnPlane( right, pml.right, pm->ps->grapplePoint ); - + VectorScale( pm->ps->grapplePoint, normalFraction, dir ); if( pm->cmd.forwardmove > 0 ) VectorMA( dir, cmdFraction, forward, dir ); else if( pm->cmd.forwardmove < 0 ) VectorMA( dir, -cmdFraction, forward, dir ); - + if( pm->cmd.rightmove > 0 ) VectorMA( dir, cmdFraction, right, dir ); else if( pm->cmd.rightmove < 0 ) VectorMA( dir, -cmdFraction, right, dir ); - + VectorMA( dir, upFraction, refNormal, dir ); VectorNormalize( dir ); - + VectorMA( pm->ps->velocity, BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ), dir, pm->ps->velocity ); - + //for a long run of wall jumps the velocity can get pretty large, this caps it if( VectorLength( pm->ps->velocity ) > LEVEL2_WALLJUMP_MAXSPEED ) { VectorNormalize( pm->ps->velocity ); VectorScale( pm->ps->velocity, LEVEL2_WALLJUMP_MAXSPEED, pm->ps->velocity ); } - + PM_AddEvent( EV_JUMP ); if( pm->cmd.forwardmove >= 0 ) @@ -624,7 +624,7 @@ static qboolean PM_CheckWallJump( void ) PM_ForceLegsAnim( LEGS_JUMP ); else PM_ForceLegsAnim( NSPA_JUMP ); - + pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; } else @@ -633,7 +633,7 @@ static qboolean PM_CheckWallJump( void ) PM_ForceLegsAnim( LEGS_JUMPB ); else PM_ForceLegsAnim( NSPA_JUMPBACK ); - + pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; } @@ -699,21 +699,21 @@ static qboolean PM_CheckJump( void ) pm->ps->stats[ STAT_STAMINA ] -= 500; pm->ps->groundEntityNum = ENTITYNUM_NONE; - + //TA: jump away from wall if( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) { vec3_t normal = { 0, 0, -1 }; - + if( !( pm->ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) ) VectorCopy( pm->ps->grapplePoint, normal ); - + VectorMA( pm->ps->velocity, BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ), normal, pm->ps->velocity ); } else pm->ps->velocity[ 2 ] = BG_FindJumpMagnitudeForClass( pm->ps->stats[ STAT_PCLASS ] ); - + PM_AddEvent( EV_JUMP ); if( pm->cmd.forwardmove >= 0 ) @@ -722,7 +722,7 @@ static qboolean PM_CheckJump( void ) PM_ForceLegsAnim( LEGS_JUMP ); else PM_ForceLegsAnim( NSPA_JUMP ); - + pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; } else @@ -731,7 +731,7 @@ static qboolean PM_CheckJump( void ) PM_ForceLegsAnim( LEGS_JUMPB ); else PM_ForceLegsAnim( NSPA_JUMPBACK ); - + pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; } @@ -764,13 +764,13 @@ static qboolean PM_CheckWaterJump( void ) VectorMA( pm->ps->origin, 30, flatforward, spot ); spot[ 2 ] += 4; cont = pm->pointcontents( spot, pm->ps->clientNum ); - + if( !( cont & CONTENTS_SOLID ) ) return qfalse; spot[ 2 ] += 16; cont = pm->pointcontents( spot, pm->ps->clientNum ); - + if( cont ) return qfalse; @@ -905,7 +905,7 @@ static void PM_JetPackMove( void ) PM_Friction( ); scale = PM_CmdScale( &pm->cmd ); - + // user intentions for( i = 0; i < 2; i++ ) wishvel[ i ] = scale * pml.forward[ i ] * pm->cmd.forwardmove + scale * pml.right[ i ] * pm->cmd.rightmove; @@ -1065,7 +1065,7 @@ static void PM_ClimbMove( void ) PM_WaterMove( ); else PM_AirMove( ); - + return; } @@ -1132,7 +1132,7 @@ static void PM_ClimbMove( void ) // slide along the ground plane PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); - + // don't decrease velocity when going up or down a slope VectorNormalize( pm->ps->velocity ); VectorScale( pm->ps->velocity, vel, pm->ps->velocity ); @@ -1295,7 +1295,7 @@ static void PM_LadderMove( void ) PM_Friction( ); scale = PM_CmdScale( &pm->cmd ); - + for( i = 0; i < 3; i++ ) wishvel[ i ] = scale * pml.forward[ i ] * pm->cmd.forwardmove + scale * pml.right[ i ] * pm->cmd.rightmove; @@ -1337,28 +1337,28 @@ static void PM_CheckLadder( void ) { vec3_t forward, end; trace_t trace; - + //test if class can use ladders if( !BG_ClassHasAbility( pm->ps->stats[ STAT_PCLASS ], SCA_CANUSELADDERS ) ) { pml.ladder = qfalse; return; } - + VectorCopy( pml.forward, forward ); forward[ 2 ] = 0.0f; - + VectorMA( pm->ps->origin, 1.0f, forward, end ); - + pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, end, pm->ps->clientNum, MASK_PLAYERSOLID ); - + if( ( trace.fraction < 1.0f ) && ( trace.surfaceFlags & SURF_LADDER ) ) pml.ladder = qtrue; else pml.ladder = qfalse; } - - + + /* ============== PM_DeadMove @@ -1375,7 +1375,7 @@ static void PM_DeadMove( void ) forward = VectorLength( pm->ps->velocity ); forward -= 20; - + if( forward <= 0 ) VectorClear( pm->ps->velocity ); else @@ -1406,7 +1406,7 @@ static void PM_NoclipMove( void ) // friction speed = VectorLength( pm->ps->velocity ); - + if( speed < 1 ) { VectorCopy( vec3_origin, pm->ps->velocity ); @@ -1421,10 +1421,10 @@ static void PM_NoclipMove( void ) // scale the velocity newspeed = speed - drop; - + if( newspeed < 0 ) newspeed = 0; - + newspeed /= speed; VectorScale( pm->ps->velocity, newspeed, pm->ps->velocity ); @@ -1438,7 +1438,7 @@ static void PM_NoclipMove( void ) for( i = 0; i < 3; i++ ) wishvel[ i ] = pml.forward[ i ] * fmove + pml.right[ i ] * smove; - + wishvel[ 2 ] += pm->cmd.upmove; VectorCopy( wishvel, wishdir ); @@ -1465,13 +1465,13 @@ static int PM_FootstepForSurface( void ) //TA: if( pm->ps->stats[ STAT_STATE ] & SS_CREEPSLOWED ) return EV_FOOTSTEP_SQUELCH; - - if( pml.groundTrace.surfaceFlags & SURF_NOSTEPS ) + + if( pml.groundTrace.surfaceFlags & SURF_NOSTEPS ) return 0; - + if( pml.groundTrace.surfaceFlags & SURF_METALSTEPS ) return EV_FOOTSTEP_METAL; - + return EV_FOOTSTEP; } @@ -1605,7 +1605,7 @@ static int PM_CorrectAllSolid( trace_t *trace ) point[ 1 ] += (float)j; point[ 2 ] += (float)k; pm->trace( trace, point, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask ); - + if( !trace->allsolid ) { point[ 0 ] = pm->ps->origin[ 0 ]; @@ -1660,7 +1660,7 @@ static void PM_GroundTraceMissed( void ) PM_ForceLegsAnim( LEGS_JUMP ); else PM_ForceLegsAnim( NSPA_JUMP ); - + pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; } else @@ -1731,11 +1731,11 @@ static void PM_GroundClimbTrace( void ) if( pm->cmd.rightmove ) { VectorCopy( pml.right, movedir ); - + if( pm->cmd.rightmove < 0 ) VectorNegate( movedir, movedir ); } - + for( i = 0; i <= 4; i++ ) { switch ( i ) @@ -1795,7 +1795,7 @@ static void PM_GroundClimbTrace( void ) { if( i == 2 ) PM_StepEvent( pm->ps->origin, trace.endpos, surfNormal ); - + VectorCopy( trace.endpos, pm->ps->origin ); } @@ -1840,10 +1840,10 @@ static void PM_GroundClimbTrace( void ) { //behold the evil mindfuck from hell //it has fucked mind like nothing has fucked mind before - + //calculate reference rotated through to trace plane RotatePointAroundVector( refTOtrace, traceCROSSref, horizontal, -traceANGref ); - + //calculate reference rotated through to surf plane then to trace plane RotatePointAroundVector( tempVec, surfCROSSref, horizontal, -surfANGref ); RotatePointAroundVector( refTOsurfTOtrace, traceCROSSsurf, tempVec, -traceANGsurf ); @@ -1871,18 +1871,18 @@ static void PM_GroundClimbTrace( void ) //construct a point representing where the player is looking VectorAdd( pm->ps->origin, lookdir, point ); - + //check whether point is on one side of the plane, if so invert the correction angle if( ( abc[ 0 ] * point[ 0 ] + abc[ 1 ] * point[ 1 ] + abc[ 2 ] * point[ 2 ] - d ) > 0 ) traceANGsurf = -traceANGsurf; - + //find the . product of the lookdir and traceCROSSsurf if( ( ldDOTtCs = DotProduct( lookdir, traceCROSSsurf ) ) < 0.0f ) { VectorInverse( traceCROSSsurf ); ldDOTtCs = DotProduct( lookdir, traceCROSSsurf ); } - + //set the correction angle traceANGsurf *= 1.0f - ldDOTtCs; @@ -1950,7 +1950,7 @@ static void PM_GroundClimbTrace( void ) vec3_t forward, rotated, angles; AngleVectors( pm->ps->viewangles, forward, NULL, NULL ); - + RotatePointAroundVector( rotated, pm->ps->grapplePoint, forward, 180.0f ); vectoangles( rotated, angles ); @@ -2035,14 +2035,14 @@ static void PM_GroundTrace( void ) vec3_t forward, rotated, angles; AngleVectors( pm->ps->viewangles, forward, NULL, NULL ); - + RotatePointAroundVector( rotated, pm->ps->grapplePoint, forward, 180.0f ); vectoangles( rotated, angles ); pm->ps->delta_angles[ YAW ] -= ANGLE2SHORT( angles[ YAW ] - pm->ps->viewangles[ YAW ] ); } } - + pm->ps->stats[ STAT_STATE ] &= ~SS_WALLCLIMBING; pm->ps->stats[ STAT_STATE ] &= ~SS_WALLCLIMBINGCEILING; pm->ps->eFlags &= ~EF_WALLCLIMB; @@ -2052,14 +2052,14 @@ static void PM_GroundTrace( void ) point[ 2 ] = pm->ps->origin[ 2 ] - 0.25f; pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask ); - + pml.groundTrace = trace; // do something corrective if the trace starts in a solid... if( trace.allsolid ) if( !PM_CorrectAllSolid( &trace ) ) return; - + //make sure that the surfNormal is reset to the ground VectorCopy( refNormal, pm->ps->grapplePoint ); @@ -2067,7 +2067,7 @@ static void PM_GroundTrace( void ) if( trace.fraction == 1.0f ) { qboolean steppedDown = qfalse; - + // try to step down if( pml.groundPlane != qfalse && PM_PredictStepMove( ) ) { @@ -2085,7 +2085,7 @@ static void PM_GroundTrace( void ) steppedDown = qtrue; } } - + if( !steppedDown ) { PM_GroundTraceMissed( ); @@ -2104,15 +2104,15 @@ static void PM_GroundTrace( void ) if( pm->cmd.rightmove ) { VectorCopy( pml.right, movedir ); - + if( pm->cmd.rightmove < 0 ) VectorNegate( movedir, movedir ); } - + //trace into direction we are moving VectorMA( pm->ps->origin, 0.25f, movedir, point ); pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, point, pm->ps->clientNum, pm->tracemask ); - + if( trace.fraction < 1.0f && !( trace.surfaceFlags & ( SURF_SKY | SURF_SLICK ) ) && ( trace.entityNum == ENTITYNUM_WORLD ) ) { @@ -2123,7 +2123,7 @@ static void PM_GroundTrace( void ) } } } - + return; } } @@ -2150,7 +2150,7 @@ static void PM_GroundTrace( void ) PM_ForceLegsAnim( LEGS_JUMPB ); else PM_ForceLegsAnim( NSPA_JUMPBACK ); - + pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; } @@ -2243,13 +2243,13 @@ static void PM_SetWaterLevel( void ) pm->waterlevel = 1; point[ 2 ] = pm->ps->origin[ 2 ] + MINS_Z + sample1; cont = pm->pointcontents( point, pm->ps->clientNum ); - + if( cont & MASK_WATER ) { pm->waterlevel = 2; point[ 2 ] = pm->ps->origin[ 2 ] + MINS_Z + sample2; cont = pm->pointcontents( point, pm->ps->clientNum ); - + if( cont & MASK_WATER ) pm->waterlevel = 3; } @@ -2401,7 +2401,7 @@ static void PM_Footsteps( void ) if( pm->ps->pm_flags & PMF_DUCKED ) { bobmove = 0.5; // ducked characters bob much faster - + if( pm->ps->pm_flags & PMF_BACKWARDS_RUN ) { if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) @@ -2430,7 +2430,7 @@ static void PM_Footsteps( void ) PM_ContinueLegsAnim( NSPA_WALK ); } } - + // ducked characters never play footsteps } else @@ -2507,7 +2507,7 @@ static void PM_Footsteps( void ) } bobmove *= BG_FindBobCycleForClass( pm->ps->stats[ STAT_PCLASS ] ); - + if( pm->ps->stats[ STAT_STATE ] & SS_SPEEDBOOST ) bobmove *= HUMAN_SPRINT_MODIFIER; @@ -2600,7 +2600,7 @@ static void PM_BeginWeaponChange( int weapon ) //reset build weapon pm->ps->stats[ STAT_BUILDABLE ] = BA_NONE; - + if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) PM_StartTorsoAnim( TORSO_DROP ); } @@ -2625,7 +2625,7 @@ static void PM_FinishWeaponChange( void ) pm->ps->weapon = weapon; pm->ps->weaponstate = WEAPON_RAISING; pm->ps->weaponTime += 250; - + if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) PM_StartTorsoAnim( TORSO_RAISE ); } @@ -2666,7 +2666,7 @@ static void PM_Weapon( void ) qboolean attack1 = qfalse; qboolean attack2 = qfalse; qboolean attack3 = qfalse; - + // don't allow attack until all buttons are up if( pm->ps->pm_flags & PMF_RESPAWNED ) return; @@ -2674,7 +2674,7 @@ static void PM_Weapon( void ) // ignore if spectator if( pm->ps->persistant[ PERS_TEAM ] == TEAM_SPECTATOR ) return; - + if( pm->ps->stats[ STAT_STATE ] & SS_INFESTING ) return; @@ -2719,12 +2719,12 @@ static void PM_Weapon( void ) BG_ActivateUpgrade( pm->cmd.weapon - 32, pm->ps->stats ); } } - pm->ps->pm_flags |= PMF_USE_ITEM_HELD; + pm->ps->pm_flags |= PMF_USE_ITEM_HELD; } } else pm->ps->pm_flags &= ~PMF_USE_ITEM_HELD; - + //something external thinks a weapon change is necessary if( pm->ps->pm_flags & PMF_WEAPON_SWITCH ) { @@ -2732,7 +2732,7 @@ static void PM_Weapon( void ) PM_BeginWeaponChange( pm->ps->persistant[ PERS_NEWWEAPON ] ); } } - + if( pm->ps->weaponTime > 0 ) return; @@ -2754,7 +2754,7 @@ static void PM_Weapon( void ) else PM_ContinueTorsoAnim( TORSO_STAND ); } - + return; } @@ -2783,7 +2783,7 @@ static void PM_Weapon( void ) if( BG_FindUsesEnergyForWeapon( pm->ps->weapon ) && BG_InventoryContainsUpgrade( UP_BATTPACK, pm->ps->stats ) ) ammo = (int)( (float)ammo * BATTPACK_MODIFIER ); - + BG_PackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, ammo, clips ); //allow some time for the weapon to be raised @@ -2792,8 +2792,8 @@ static void PM_Weapon( void ) pm->ps->weaponTime += 250; return; } - - // check for end of clip + + // check for end of clip if( ( !ammo || pm->ps->pm_flags & PMF_WEAPON_RELOAD ) && clips ) { pm->ps->pm_flags &= ~PMF_WEAPON_RELOAD; @@ -2802,13 +2802,13 @@ static void PM_Weapon( void ) //drop the weapon PM_StartTorsoAnim( TORSO_DROP ); - + addTime = BG_FindReloadTimeForWeapon( pm->ps->weapon ); pm->ps->weaponTime += addTime; return; } - + //check if non-auto primary/secondary attacks are permited switch( pm->ps->weapon ) { @@ -2823,14 +2823,14 @@ static void PM_Weapon( void ) return; } break; - + case WP_ALEVEL3: case WP_ALEVEL3_UPG: //pouncing has primary secondary AND autohit procedures attack1 = pm->cmd.buttons & BUTTON_ATTACK; attack2 = pm->cmd.buttons & BUTTON_ATTACK2; attack3 = pm->cmd.buttons & BUTTON_USE_HOLDABLE; - + if( !pm->autoWeaponHit[ pm->ps->weapon ] && !attack1 && !attack2 && !attack3 ) { pm->ps->weaponTime = 0; @@ -2843,7 +2843,7 @@ static void PM_Weapon( void ) attack1 = pm->cmd.buttons & BUTTON_ATTACK; attack2 = pm->cmd.buttons & BUTTON_ATTACK2; attack3 = pm->cmd.buttons & BUTTON_USE_HOLDABLE; - + if( ( attack1 || pm->ps->stats[ STAT_MISC ] == 0 ) && !attack2 && !attack3 ) { if( pm->ps->stats[ STAT_MISC ] < LCANNON_TOTAL_CHARGE ) @@ -2860,13 +2860,13 @@ static void PM_Weapon( void ) if( pm->ps->stats[ STAT_MISC ] > 0 ) attack1 = !attack1; break; - + default: //by default primary and secondary attacks are allowed attack1 = pm->cmd.buttons & BUTTON_ATTACK; attack2 = pm->cmd.buttons & BUTTON_ATTACK2; attack3 = pm->cmd.buttons & BUTTON_USE_HOLDABLE; - + if( !attack1 && !attack2 && !attack3 ) { pm->ps->weaponTime = 0; @@ -2932,7 +2932,7 @@ static void PM_Weapon( void ) PM_AddEvent( EV_FIRE_WEAPON ); addTime = BG_FindRepeatRate1ForWeapon( pm->ps->weapon ); break; - + case WP_ALEVEL3: case WP_ALEVEL3_UPG: pm->ps->generic1 = WPM_SECONDARY; @@ -2944,12 +2944,12 @@ static void PM_Weapon( void ) break; } } - + if( !( pm->ps->persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) { //FIXME: this should be an option in the client weapon.cfg switch( pm->ps->weapon ) - { + { case WP_FLAMER: if( pm->ps->weaponstate == WEAPON_READY ) { @@ -2960,7 +2960,7 @@ static void PM_Weapon( void ) case WP_BLASTER: PM_StartTorsoAnim( TORSO_ATTACK2 ); break; - + default: PM_StartTorsoAnim( TORSO_ATTACK ); break; @@ -2990,12 +2990,12 @@ static void PM_Weapon( void ) else if( attack3 ) PM_ForceLegsAnim( NSPA_ATTACK3 ); } - + pm->ps->torsoTimer = TIMER_ATTACK; } pm->ps->weaponstate = WEAPON_FIRING; - + // take an ammo away if not infinite if( !BG_FindInfinteAmmoForWeapon( pm->ps->weapon ) ) { @@ -3010,7 +3010,7 @@ static void PM_Weapon( void ) } else ammo--; - + BG_PackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, ammo, clips ); } else if( pm->ps->weapon == WP_ALEVEL3_UPG && attack3 ) @@ -3019,7 +3019,7 @@ static void PM_Weapon( void ) ammo--; BG_PackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, ammo, clips ); } - + //FIXME: predicted angles miss a problem?? if( pm->ps->weapon == WP_CHAINGUN ) { @@ -3035,7 +3035,7 @@ static void PM_Weapon( void ) pm->ps->delta_angles[ YAW ] -= ANGLE2SHORT( ( ( random() * 8 ) - 4 ) * ( 30.0 / (float)addTime ) ); } } - + pm->ps->weaponTime += addTime; } @@ -3064,7 +3064,7 @@ static void PM_Animate( void ) { PM_ForceLegsAnim( NSPA_GESTURE ); pm->ps->torsoTimer = TIMER_GESTURE; - + PM_AddEvent( EV_TAUNT ); } } @@ -3095,7 +3095,7 @@ static void PM_DropTimers( void ) if( pm->ps->legsTimer > 0 ) { pm->ps->legsTimer -= pml.msec; - + if( pm->ps->legsTimer < 0 ) pm->ps->legsTimer = 0; } @@ -3103,7 +3103,7 @@ static void PM_DropTimers( void ) if( pm->ps->torsoTimer > 0 ) { pm->ps->torsoTimer -= pml.msec; - + if( pm->ps->torsoTimer < 0 ) pm->ps->torsoTimer = 0; } @@ -3158,7 +3158,7 @@ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) if( !( ps->stats[ STAT_STATE ] & SS_WALLCLIMBING ) || !BG_RotateAxis( ps->grapplePoint, axis, rotaxis, qfalse, - ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) ) + ps->stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) ) AxisCopy( axis, rotaxis ); //convert the new axis back to angles @@ -3169,7 +3169,7 @@ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) { while( tempang[ i ] > 180 ) tempang[ i ] -= 360; - + while( tempang[ i ] < 180 ) tempang[ i ] += 360; } @@ -3182,10 +3182,10 @@ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) if( ps->pm_type == PM_GRABBED && !BG_InventoryContainsUpgrade( UP_BATTLESUIT, ps->stats ) ) { vec3_t dir, angles; - + ByteToDir( ps->stats[ STAT_VIEWLOCK ], dir ); vectoangles( dir, angles ); - + for( i = 0; i < 3; i++ ) { float diff = AngleSubtract( ps->viewangles[ i ], angles[ i ] ); @@ -3199,7 +3199,7 @@ void PM_UpdateViewAngles( playerState_t *ps, const usercmd_t *cmd ) ps->delta_angles[ i ] += ANGLE2SHORT( fabs( diff ) - 90.0f ); else if( diff > 90.0f ) ps->delta_angles[ i ] -= ANGLE2SHORT( fabs( diff ) - 90.0f ); - + if( diff < 0.0f ) ps->delta_angles[ i ] += ANGLE2SHORT( fabs( diff ) * 0.05f ); else if( diff > 0.0f ) @@ -3220,7 +3220,7 @@ void trap_SnapVector( float *v ); void PmoveSingle( pmove_t *pmove ) { int ammo, clips; - + pm = pmove; BG_UnpackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, &ammo, &clips ); @@ -3255,7 +3255,7 @@ void PmoveSingle( pmove_t *pmove ) pm->ps->eFlags |= EF_FIRING; else pm->ps->eFlags &= ~EF_FIRING; - + // set the firing flag for continuous beam weapons if( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION && ( pm->cmd.buttons & BUTTON_ATTACK2 ) && @@ -3263,7 +3263,7 @@ void PmoveSingle( pmove_t *pmove ) pm->ps->eFlags |= EF_FIRING2; else pm->ps->eFlags &= ~EF_FIRING2; - + // set the firing flag for continuous beam weapons if( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION && ( pm->cmd.buttons & BUTTON_USE_HOLDABLE ) && @@ -3271,7 +3271,7 @@ void PmoveSingle( pmove_t *pmove ) pm->ps->eFlags |= EF_FIRING3; else pm->ps->eFlags &= ~EF_FIRING3; - + // clear the respawned flag if attack and use are cleared if( pm->ps->stats[STAT_HEALTH] > 0 && @@ -3294,7 +3294,7 @@ void PmoveSingle( pmove_t *pmove ) // determine the time pml.msec = pmove->cmd.serverTime - pm->ps->commandTime; - + if( pml.msec < 1 ) pml.msec = 1; else if( pml.msec > 200 ) @@ -3363,10 +3363,10 @@ void PmoveSingle( pmove_t *pmove ) PM_CheckDuck( ); PM_CheckLadder( ); - + // set groundentity PM_GroundTrace( ); - + // update the viewangles PM_UpdateViewAngles( pm->ps, &pm->cmd ); diff --git a/src/game/bg_public.h b/src/game/bg_public.h index b67eaac2..ea3b7eef 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -158,7 +158,7 @@ typedef struct qboolean autoWeaponHit[ 32 ]; //FIXME: TA: remind myself later this might be a problem int framecount; - + // results (out) int numtouch; int touchents[ MAXTOUCH ]; @@ -169,18 +169,18 @@ typedef struct int waterlevel; float xyspeed; - + // for fixed msec Pmove int pmove_fixed; int pmove_msec; - + // callbacks to test the world // these will be different functions during game and cgame /*void (*trace)( trace_t *results, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask );*/ void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask ); - - + + int (*pointcontents)( const vec3_t point, int passEntityNum ); } pmove_t; @@ -319,7 +319,7 @@ typedef enum typedef enum { WPM_NONE, - + WPM_PRIMARY, WPM_SECONDARY, WPM_TERTIARY, @@ -339,7 +339,7 @@ typedef enum WP_ALEVEL3, WP_ALEVEL3_UPG, WP_ALEVEL4, - + WP_BLASTER, WP_MACHINEGUN, WP_PAIN_SAW, @@ -356,7 +356,7 @@ typedef enum WP_HIVE, WP_TESLAGEN, WP_MGTURRET, - + //build weapons must remain in a block WP_ABUILD, WP_ABUILD2, @@ -378,7 +378,7 @@ typedef enum UP_JETPACK, UP_BATTLESUIT, UP_GRENADE, - + UP_AMMO, UP_NUM_UPGRADES @@ -387,7 +387,7 @@ typedef enum typedef enum { WUT_NONE, - + WUT_ALIENS, WUT_HUMANS, @@ -410,24 +410,24 @@ typedef enum BA_A_SPAWN, BA_A_OVERMIND, - + BA_A_BARRICADE, BA_A_ACIDTUBE, BA_A_TRAPPER, BA_A_BOOSTER, BA_A_HIVE, - + BA_A_HOVEL, - + BA_H_SPAWN, - + BA_H_MGTURRET, BA_H_TESLAGEN, - + BA_H_ARMOURY, BA_H_DCC, BA_H_MEDISTAT, - + BA_H_REACTOR, BA_H_REPEATER, @@ -437,7 +437,7 @@ typedef enum typedef enum { BIT_NONE, - + BIT_ALIENS, BIT_HUMANS, @@ -498,8 +498,6 @@ typedef enum EV_FALL_FAR, EV_FALLING, - EV_JUMP_PAD, // boing sound at origin, jump sound on player - EV_JUMP, EV_WATER_TOUCH, // foot touches EV_WATER_LEAVE, // foot leaves @@ -535,7 +533,7 @@ typedef enum EV_LEV1_GRAB, EV_LEV4_CHARGE_PREPARE, EV_LEV4_CHARGE_START, - + EV_PAIN, EV_DEATH1, EV_DEATH2, @@ -565,9 +563,9 @@ typedef enum EV_OVERMIND_ATTACK, //TA: overmind under attack EV_OVERMIND_DYING, //TA: overmind close to death EV_OVERMIND_SPAWNS, //TA: overmind needs spawns - + EV_DCC_ATTACK, //TA: dcc under attack - + EV_RPTUSE_SOUND //TA: trigger a sound } entity_event_t; @@ -576,7 +574,7 @@ typedef enum MN_TEAM, MN_A_TEAMFULL, MN_H_TEAMFULL, - + //alien stuff MN_A_CLASS, MN_A_BUILD, @@ -586,7 +584,7 @@ typedef enum MN_A_NOEROOM, MN_A_TOOCLOSE, MN_A_NOOVMND_EVOLVE, - + //alien build MN_A_SPWNWARN, MN_A_OVERMIND, @@ -596,7 +594,7 @@ typedef enum MN_A_NOROOM, MN_A_NORMAL, MN_A_HOVEL_EXIT, - + //human stuff MN_H_SPAWN, MN_H_BUILD, @@ -604,7 +602,7 @@ typedef enum MN_H_NOSLOTS, MN_H_NOFUNDS, MN_H_ITEMHELD, - + //human build MN_H_REPEATER, MN_H_NOPOWER, @@ -706,7 +704,7 @@ typedef enum NSPA_PAIN1, NSPA_PAIN2, - + NSPA_DEATH1, NSPA_DEAD1, NSPA_DEATH2, @@ -715,9 +713,9 @@ typedef enum NSPA_DEAD3, MAX_NONSEG_PLAYER_ANIMATIONS, - + NSPA_WALKBACK, - + MAX_NONSEG_PLAYER_TOTALANIMATIONS } nonSegPlayerAnimNumber_t; @@ -741,11 +739,11 @@ typedef enum BANIM_PAIN1, BANIM_PAIN2, - + BANIM_DESTROY1, BANIM_DESTROY2, BANIM_DESTROYED, - + MAX_BUILDABLE_ANIMATIONS } buildableAnimNumber_t; @@ -785,11 +783,11 @@ typedef enum typedef enum { PCL_NONE, - + //builder classes PCL_ALIEN_BUILDER0, PCL_ALIEN_BUILDER0_UPG, - + //offensive classes PCL_ALIEN_LEVEL0, PCL_ALIEN_LEVEL1, @@ -799,7 +797,7 @@ typedef enum PCL_ALIEN_LEVEL3, PCL_ALIEN_LEVEL3_UPG, PCL_ALIEN_LEVEL4, - + //human class PCL_HUMAN, PCL_HUMAN_BSUIT, @@ -861,7 +859,7 @@ typedef enum MOD_SLOWBLOB, MOD_POISON, MOD_SWARM, - + MOD_HSPAWN, MOD_TESLAGEN, MOD_MGTURRET, @@ -882,36 +880,36 @@ typedef struct char *className; char *humanName; - + char *modelName; float modelScale; char *skinName; float shadowScale; - + char *hudName; - + int stages; - + vec3_t mins; vec3_t maxs; vec3_t crouchMaxs; vec3_t deadMins; vec3_t deadMaxs; float zOffset; - + int viewheight; int crouchViewheight; - + int health; float fallDamage; int regenRate; - + int abilities; - + weapon_t startWeapon; - + float buildDist; - + int fov; float bob; float bobCycle; @@ -938,7 +936,7 @@ typedef struct float shadowScale; char hudName[ MAX_QPATH ]; char humanName[ MAX_STRING_CHARS ]; - + vec3_t mins; vec3_t maxs; vec3_t crouchMaxs; @@ -965,7 +963,7 @@ typedef struct char *buildName; char *humanName; char *entityName; - + char *models[ MAX_BUILDABLE_MODELS ]; float modelScale; @@ -975,13 +973,13 @@ typedef struct trType_t traj; float bounce; - + int buildPoints; int stages; int health; int regenRate; - + int splashDamage; int splashRadius; @@ -1008,7 +1006,7 @@ typedef struct qboolean dccTest; qboolean reactorTest; -} buildableAttributes_t; +} buildableAttributes_t; typedef struct { @@ -1018,7 +1016,7 @@ typedef struct vec3_t mins; vec3_t maxs; float zOffset; -} buildableAttributeOverrides_t; +} buildableAttributeOverrides_t; //TA: weapon record typedef struct @@ -1042,7 +1040,7 @@ typedef struct int repeatRate2; int repeatRate3; int reloadTime; - + qboolean hasAltMode; qboolean hasThirdMode; @@ -1050,7 +1048,7 @@ typedef struct float zoomFov; qboolean purchasable; - + int buildDelay; WUTeam_t team; @@ -1070,9 +1068,9 @@ typedef struct char *upgradeHumanName; char *icon; - + qboolean purchasable; - + WUTeam_t team; } upgradeAttributes_t; @@ -1095,10 +1093,10 @@ qboolean BG_RotateAxis( vec3_t surfNormal, vec3_t inAxis[ 3 ], void BG_PositionBuildableRelativeToPlayer( const playerState_t *ps, const vec3_t mins, const vec3_t maxs, void (*trace)( trace_t *, const vec3_t, const vec3_t, - const vec3_t, const vec3_t, int, int ), + const vec3_t, const vec3_t, int, int ), vec3_t outOrigin, vec3_t outAngles, trace_t *tr ); int BG_GetValueOfHuman( playerState_t *ps ); - + int BG_FindBuildNumForName( char *name ); int BG_FindBuildNumForEntityName( char *name ); char *BG_FindNameForBuildable( int bclass ); @@ -1210,7 +1208,7 @@ WUTeam_t BG_FindTeamForUpgrade( int upgrade ); #define MASK_DEADSOLID (CONTENTS_SOLID|CONTENTS_PLAYERCLIP) #define MASK_WATER (CONTENTS_WATER|CONTENTS_LAVA|CONTENTS_SLIME) #define MASK_OPAQUE (CONTENTS_SOLID|CONTENTS_SLIME|CONTENTS_LAVA) -#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_CORPSE) +#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_BODY) // @@ -1221,9 +1219,9 @@ typedef enum ET_GENERAL, ET_PLAYER, ET_ITEM, - + ET_BUILDABLE, //TA: buildable type - + ET_MISSILE, ET_MOVER, ET_BEAM, @@ -1251,8 +1249,6 @@ void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t res void BG_AddPredictableEventToPlayerstate( int newEvent, int eventParm, playerState_t *ps ); -void BG_TouchJumpPad( playerState_t *ps, entityState_t *jumppad ); - void BG_PlayerStateToEntityState( playerState_t *ps, entityState_t *s, qboolean snap ); void BG_PlayerStateToEntityStateExtraPolate( playerState_t *ps, entityState_t *s, int time, qboolean snap ); diff --git a/src/game/bg_slidemove.c b/src/game/bg_slidemove.c index 2ddd952b..47f1ec04 100644 --- a/src/game/bg_slidemove.c +++ b/src/game/bg_slidemove.c @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "q_shared.h" #include "bg_public.h" #include "bg_local.h" @@ -51,7 +51,7 @@ qboolean PM_SlideMove( qboolean gravity ) float into; vec3_t endVelocity; vec3_t endClipVelocity; - + numbumps = 4; VectorCopy( pm->ps->velocity, primal_velocity ); @@ -62,11 +62,11 @@ qboolean PM_SlideMove( qboolean gravity ) endVelocity[ 2 ] -= pm->ps->gravity * pml.frametime; pm->ps->velocity[ 2 ] = ( pm->ps->velocity[ 2 ] + endVelocity[ 2 ] ) * 0.5; primal_velocity[ 2 ] = endVelocity[ 2 ]; - + if( pml.groundPlane ) { // slide along the ground plane - PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, + PM_ClipVelocity( pm->ps->velocity, pml.groundTrace.plane.normal, pm->ps->velocity, OVERCLIP ); } } @@ -135,10 +135,10 @@ qboolean PM_SlideMove( qboolean gravity ) break; } } - + if( i < numplanes ) continue; - + VectorCopy( trace.plane.normal, planes[ numplanes ] ); numplanes++; @@ -236,7 +236,7 @@ void PM_StepEvent( vec3_t from, vec3_t to, vec3_t normal ) VectorSubtract( from, to, delta ); VectorCopy( delta, dNormal ); VectorNormalize( dNormal ); - + size = DotProduct( normal, dNormal ) * VectorLength( delta ); if( size > 0.0f ) @@ -256,7 +256,7 @@ void PM_StepEvent( vec3_t from, vec3_t to, vec3_t normal ) else { size = fabs( size ); - + if( size > 2.0f ) { if( size < 7.0f ) @@ -269,7 +269,7 @@ void PM_StepEvent( vec3_t from, vec3_t to, vec3_t normal ) PM_AddEvent( EV_STEP_16 ); } } - + if( pm->debugLevel ) Com_Printf( "%i:stepped\n", c_pmove ); } @@ -299,7 +299,7 @@ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive ) } else VectorSet( normal, 0.0f, 0.0f, 1.0f ); - + VectorCopy( pm->ps->origin, start_o ); VectorCopy( pm->ps->velocity, start_v ); @@ -315,7 +315,7 @@ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive ) { if( pm->debugLevel ) Com_Printf( "%d: step down\n", c_pmove ); - + stepped = qtrue; } } @@ -339,7 +339,7 @@ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive ) // test the player position if they were a stepheight higher pm->trace( &trace, start_o, pm->mins, pm->maxs, up, pm->ps->clientNum, pm->tracemask ); - if( trace.allsolid ) + if( trace.allsolid ) { if( pm->debugLevel ) Com_Printf( "%i:bend can't step\n", c_pmove ); @@ -350,7 +350,7 @@ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive ) VectorSubtract( trace.endpos, start_o, step_v ); VectorCopy( step_v, step_vNormal ); VectorNormalize( step_vNormal ); - + stepSize = DotProduct( normal, step_vNormal ) * VectorLength( step_v ); // try slidemove from this position VectorCopy( trace.endpos, pm->ps->origin ); @@ -360,7 +360,7 @@ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive ) { if( pm->debugLevel ) Com_Printf( "%d: step up\n", c_pmove ); - + stepped = qtrue; } @@ -368,10 +368,10 @@ qboolean PM_StepSlideMove( qboolean gravity, qboolean predictive ) VectorCopy( pm->ps->origin, down ); VectorMA( down, -stepSize, normal, down ); pm->trace( &trace, pm->ps->origin, pm->mins, pm->maxs, down, pm->ps->clientNum, pm->tracemask ); - + if( !trace.allsolid ) VectorCopy( trace.endpos, pm->ps->origin ); - + if( trace.fraction < 1.0f ) PM_ClipVelocity( pm->ps->velocity, trace.plane.normal, pm->ps->velocity, OVERCLIP ); } @@ -399,7 +399,7 @@ qboolean PM_PredictStepMove( void ) if( PM_StepSlideMove( qfalse, qtrue ) ) stepped = qtrue; - + VectorCopy( velocity, pm->ps->velocity ); VectorCopy( origin, pm->ps->origin ); pml.impactSpeed = impactSpeed; diff --git a/src/game/g_active.c b/src/game/g_active.c index e90f28d0..ca9c7db4 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -54,9 +54,9 @@ void P_DamageFeedback( gentity_t *player ) client->ps.damageYaw = 255; client->damage_fromWorld = qfalse; - } - else - { + } + else + { vectoangles( client->damage_from, angles ); client->ps.damagePitch = angles[ PITCH ] / 360.0 * 256; client->ps.damageYaw = angles[ YAW ] / 360.0 * 256; @@ -196,7 +196,7 @@ void ClientImpacts( gentity_t *ent, pmove_t *pm ) gentity_t *other; memset( &trace, 0, sizeof( trace ) ); - + for( i = 0; i < pm->numtouch; i++ ) { for( j = 0; j < i; j++ ) @@ -204,10 +204,10 @@ void ClientImpacts( gentity_t *ent, pmove_t *pm ) if( pm->touchents[ j ] == pm->touchents[ i ] ) break; } - + if( j != i ) continue; // duplicated - + other = &g_entities[ pm->touchents[ i ] ]; if( ( ent->r.svFlags & SVF_BOT ) && ( ent->touch ) ) @@ -215,10 +215,10 @@ void ClientImpacts( gentity_t *ent, pmove_t *pm ) //charge attack if( ent->client->ps.weapon == WP_ALEVEL4 && - ent->client->ps.stats[ STAT_MISC ] > 0 && + ent->client->ps.stats[ STAT_MISC ] > 0 && ent->client->charging ) ChargeAttack( ent, other ); - + if( !other->touch ) continue; @@ -253,10 +253,10 @@ void G_TouchTriggers( gentity_t *ent ) BG_FindBBoxForClass( ent->client->ps.stats[ STAT_PCLASS ], pmins, pmaxs, NULL, NULL, NULL ); - + VectorAdd( ent->client->ps.origin, pmins, mins ); VectorAdd( ent->client->ps.origin, pmaxs, maxs ); - + VectorSubtract( mins, range, mins ); VectorAdd( maxs, range, maxs ); @@ -266,7 +266,7 @@ void G_TouchTriggers( gentity_t *ent ) VectorAdd( ent->client->ps.origin, ent->r.mins, mins ); VectorAdd( ent->client->ps.origin, ent->r.maxs, maxs ); - for( i = 0; i < num; i++ ) + for( i = 0; i < num; i++ ) { hit = &g_entities[ touch[ i ] ]; @@ -358,7 +358,7 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) G_TouchTriggers( ent ); trap_UnlinkEntity( ent ); - + if( ( client->buttons & BUTTON_ATTACK ) && !( client->oldbuttons & BUTTON_ATTACK ) ) { //if waiting in a queue remove from the queue @@ -368,7 +368,7 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) G_RemoveFromSpawnQueue( &level.alienSpawnQueue, client->ps.clientNum ); else if( client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) G_RemoveFromSpawnQueue( &level.humanSpawnQueue, client->ps.clientNum ); - + client->pers.classSelection = PCL_NONE; client->ps.stats[ STAT_PCLASS ] = PCL_NONE; } @@ -382,7 +382,7 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) G_TriggerMenu( client->ps.clientNum, MN_H_SPAWN ); } } - + //set the queue position for the client side if( client->ps.pm_flags & PMF_QUEUED ) { @@ -436,14 +436,14 @@ qboolean ClientInactivityTimer( gclient_t *client ) trap_DropClient( client - level.clients, "Dropped due to inactivity" ); return qfalse; } - + if( level.time > client->inactivityTime - 10000 && !client->inactivityWarning ) { client->inactivityWarning = qtrue; G_SendCommandFromServer( client - level.clients, "cp \"Ten seconds until inactivity drop!\n\"" ); } } - + return qtrue; } @@ -461,10 +461,10 @@ void ClientTimerActions( gentity_t *ent, int msec ) int aForward, aRight; ucmd = &ent->client->pers.cmd; - + aForward = abs( ucmd->forwardmove ); aRight = abs( ucmd->rightmove ); - + client = ent->client; client->time100 += msec; client->time1000 += msec; @@ -480,7 +480,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) if( BG_InventoryContainsUpgrade( UP_JETPACK, client->ps.stats ) && BG_UpgradeIsActive( UP_JETPACK, client->ps.stats ) ) client->ps.stats[ STAT_STATE ] &= ~SS_SPEEDBOOST; - + if( ( client->ps.stats[ STAT_STATE ] & SS_SPEEDBOOST ) && ucmd->upmove >= 0 ) { //subtract stamina @@ -488,16 +488,16 @@ void ClientTimerActions( gentity_t *ent, int msec ) client->ps.stats[ STAT_STAMINA ] -= STAMINA_LARMOUR_TAKE; else client->ps.stats[ STAT_STAMINA ] -= STAMINA_SPRINT_TAKE; - + if( client->ps.stats[ STAT_STAMINA ] < -MAX_STAMINA ) client->ps.stats[ STAT_STAMINA ] = -MAX_STAMINA; } - + if( ( aForward <= 64 && aForward > 5 ) || ( aRight <= 64 && aRight > 5 ) ) { //restore stamina client->ps.stats[ STAT_STAMINA ] += STAMINA_WALK_RESTORE; - + if( client->ps.stats[ STAT_STAMINA ] > MAX_STAMINA ) client->ps.stats[ STAT_STAMINA ] = MAX_STAMINA; } @@ -505,7 +505,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) { //restore stamina faster client->ps.stats[ STAT_STAMINA ] += STAMINA_STOP_RESTORE; - + if( client->ps.stats[ STAT_STAMINA ] > MAX_STAMINA ) client->ps.stats[ STAT_STAMINA ] = MAX_STAMINA; } @@ -541,7 +541,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) //client is charging up for a... charge if( client->ps.weapon == WP_ALEVEL4 ) { - if( client->ps.stats[ STAT_MISC ] < LEVEL4_CHARGE_TIME && ucmd->buttons & BUTTON_ATTACK2 && + if( client->ps.stats[ STAT_MISC ] < LEVEL4_CHARGE_TIME && ucmd->buttons & BUTTON_ATTACK2 && !client->charging ) { client->charging = qfalse; //should already be off, just making sure @@ -552,9 +552,9 @@ void ClientTimerActions( gentity_t *ent, int msec ) //trigger charge sound...is quite annoying //if( client->ps.stats[ STAT_MISC ] <= 0 ) // G_AddEvent( ent, EV_LEV4_CHARGE_PREPARE, 0 ); - + client->ps.stats[ STAT_MISC ] += (int)( 100 * (float)LEVEL4_CHARGE_CHARGE_RATIO ); - + if( client->ps.stats[ STAT_MISC ] > LEVEL4_CHARGE_TIME ) client->ps.stats[ STAT_MISC ] = LEVEL4_CHARGE_TIME; } @@ -568,10 +568,10 @@ void ClientTimerActions( gentity_t *ent, int msec ) if( client->ps.stats[ STAT_MISC ] > LEVEL4_MIN_CHARGE_TIME ) { client->ps.stats[ STAT_MISC ] -= 100; - + if( client->charging == qfalse ) G_AddEvent( ent, EV_LEV4_CHARGE_START, 0 ); - + client->charging = qtrue; client->ps.stats[ STAT_STATE ] |= SS_CHARGING; @@ -585,8 +585,8 @@ void ClientTimerActions( gentity_t *ent, int msec ) } else client->ps.stats[ STAT_MISC ] = 0; - - + + if( client->ps.stats[ STAT_MISC ] <= 0 ) { client->ps.stats[ STAT_MISC ] = 0; @@ -600,19 +600,19 @@ void ClientTimerActions( gentity_t *ent, int msec ) if( client->ps.weapon == WP_LUCIFER_CANNON ) { int ammo; - + BG_UnpackAmmoArray( WP_LUCIFER_CANNON, client->ps.ammo, client->ps.powerups, &ammo, NULL ); - + if( client->ps.stats[ STAT_MISC ] < LCANNON_TOTAL_CHARGE && ucmd->buttons & BUTTON_ATTACK ) client->ps.stats[ STAT_MISC ] += ( 100.0f / LCANNON_CHARGE_TIME ) * LCANNON_TOTAL_CHARGE; - + if( client->ps.stats[ STAT_MISC ] > LCANNON_TOTAL_CHARGE ) client->ps.stats[ STAT_MISC ] = LCANNON_TOTAL_CHARGE; if( client->ps.stats[ STAT_MISC ] > ( ammo * LCANNON_TOTAL_CHARGE ) / 10 ) client->ps.stats[ STAT_MISC ] = ammo * LCANNON_TOTAL_CHARGE / 10; } - + switch( client->ps.weapon ) { case WP_ABUILD: @@ -624,7 +624,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) { int dist = BG_FindBuildDistForClass( ent->client->ps.stats[ STAT_PCLASS ] ); vec3_t dummy; - + if( G_itemFits( ent, client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, dist, dummy ) == IBE_NONE ) client->ps.stats[ STAT_BUILDABLE ] |= SB_VALID_TOGGLEBIT; @@ -635,11 +635,11 @@ void ClientTimerActions( gentity_t *ent, int msec ) //update build timer if( client->ps.stats[ STAT_MISC ] > 0 ) client->ps.stats[ STAT_MISC ] -= 100; - + if( client->ps.stats[ STAT_MISC ] < 0 ) client->ps.stats[ STAT_MISC ] = 0; break; - + default: break; } @@ -647,7 +647,7 @@ void ClientTimerActions( gentity_t *ent, int msec ) if( client->ps.stats[ STAT_STATE ] & SS_MEDKIT_ACTIVE ) { int remainingStartupTime = MEDKIT_STARTUP_TIME - ( level.time - client->lastMedKitTime ); - + if( remainingStartupTime < 0 ) { if( ent->health < ent->client->ps.stats[ STAT_MAX_HEALTH ] && @@ -690,19 +690,19 @@ void ClientTimerActions( gentity_t *ent, int msec ) if( client->ps.stats[ STAT_STATE ] & SS_POISONCLOUDED ) G_Damage( ent, client->lastPoisonCloudedClient, client->lastPoisonCloudedClient, NULL, NULL, LEVEL1_PCLOUD_DMG, 0, MOD_LEVEL1_PCLOUD ); - + //client is poisoned if( client->ps.stats[ STAT_STATE ] & SS_POISONED ) { int i; int seconds = ( ( level.time - client->lastPoisonTime ) / 1000 ) + 1; int damage = ALIEN_POISON_DMG, damage2 = 0; - + for( i = 0; i < seconds; i++ ) { if( i == seconds - 1 ) damage2 = damage; - + damage *= ALIEN_POISON_DIVIDER; } @@ -721,15 +721,15 @@ void ClientTimerActions( gentity_t *ent, int msec ) int i, num; gentity_t *boostEntity; float modifier = 1.0f; - + VectorAdd( client->ps.origin, range, maxs ); VectorSubtract( client->ps.origin, range, mins ); - + num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { boostEntity = &g_entities[ entityList[ i ] ]; - + if( boostEntity->client && boostEntity->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS && boostEntity->client->ps.stats[ STAT_PCLASS ] == PCL_ALIEN_LEVEL4 ) { @@ -744,8 +744,8 @@ void ClientTimerActions( gentity_t *ent, int msec ) break; } } - - if( ent->health < client->ps.stats[ STAT_MAX_HEALTH ] && + + if( ent->health > 0 && ent->health < client->ps.stats[ STAT_MAX_HEALTH ] && ( ent->lastDamageTime + ALIEN_REGEN_DAMAGE_TIME ) < level.time ) ent->health += BG_FindRegenRateForClass( client->ps.stats[ STAT_PCLASS ] ) * modifier; @@ -753,18 +753,18 @@ void ClientTimerActions( gentity_t *ent, int msec ) ent->health = client->ps.stats[ STAT_MAX_HEALTH ]; } } - + while( client->time10000 >= 10000 ) { client->time10000 -= 10000; - + if( client->ps.weapon == WP_ALEVEL3_UPG ) { int ammo, maxAmmo; - + BG_FindAmmoForWeapon( WP_ALEVEL3_UPG, &maxAmmo, NULL ); BG_UnpackAmmoArray( WP_ALEVEL3_UPG, client->ps.ammo, client->ps.powerups, &ammo, NULL ); - + if( ammo < maxAmmo ) { ammo++; @@ -841,12 +841,12 @@ void ClientEvents( gentity_t *ent, int oldEventSequence ) damage = (int)( (float)BG_FindHealthForClass( class ) * BG_FindFallDamageForClass( class ) * fallDistance ); - + VectorSet( dir, 0, 0, 1 ); BG_FindBBoxForClass( class, mins, NULL, NULL, NULL, NULL ); mins[ 0 ] = mins[ 1 ] = 0.0f; VectorAdd( client->ps.origin, mins, point ); - + ent->pain_debounce_time = level.time + 200; // no normal pain sound G_Damage( ent, NULL, NULL, dir, point, damage, DAMAGE_NO_LOCDAMAGE, MOD_FALLING ); break; @@ -868,30 +868,30 @@ void ClientEvents( gentity_t *ent, int oldEventSequence ) if( ent->s.weapon == WP_GRENADE ) { int j; - + BG_RemoveWeaponFromInventory( ent->s.weapon, ent->client->ps.stats ); - + //switch to the first non blaster weapon for( j = WP_NONE + 1; j < WP_NUM_WEAPONS; j++ ) { if( j == WP_BLASTER ) continue; - + if( BG_InventoryContainsWeapon( j, ent->client->ps.stats ) ) { G_ForceWeaponChange( ent, j ); break; } } - + //only got the blaster to switch to if( j == WP_NUM_WEAPONS ) G_ForceWeaponChange( ent, WP_BLASTER ); - + //update ClientInfo ClientUserinfoChanged( ent->client->ps.clientNum ); } - + break; default: @@ -908,34 +908,34 @@ SendPendingPredictableEvents */ void SendPendingPredictableEvents( playerState_t *ps ) { - gentity_t *t; - int event, seq; - int extEvent, number; + gentity_t *t; + int event, seq; + int extEvent, number; - // if there are still events pending - if( ps->entityEventSequence < ps->eventSequence ) + // if there are still events pending + if( ps->entityEventSequence < ps->eventSequence ) { - // create a temporary entity for this event which is sent to everyone - // except the client who generated the event - seq = ps->entityEventSequence & ( MAX_PS_EVENTS - 1 ); - event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 ); - // set external event to zero before calling BG_PlayerStateToEntityState - extEvent = ps->externalEvent; - ps->externalEvent = 0; - // create temporary entity for event - t = G_TempEntity( ps->origin, event ); - number = t->s.number; - BG_PlayerStateToEntityState( ps, &t->s, qtrue ); - t->s.number = number; - t->s.eType = ET_EVENTS + event; - t->s.eFlags |= EF_PLAYER_EVENT; - t->s.otherEntityNum = ps->clientNum; - // send to everyone except the client who generated the event - t->r.svFlags |= SVF_NOTSINGLECLIENT; - t->r.singleClient = ps->clientNum; - // set back external event - ps->externalEvent = extEvent; - } + // create a temporary entity for this event which is sent to everyone + // except the client who generated the event + seq = ps->entityEventSequence & ( MAX_PS_EVENTS - 1 ); + event = ps->events[ seq ] | ( ( ps->entityEventSequence & 3 ) << 8 ); + // set external event to zero before calling BG_PlayerStateToEntityState + extEvent = ps->externalEvent; + ps->externalEvent = 0; + // create temporary entity for event + t = G_TempEntity( ps->origin, event ); + number = t->s.number; + BG_PlayerStateToEntityState( ps, &t->s, qtrue ); + t->s.number = number; + t->s.eType = ET_EVENTS + event; + t->s.eFlags |= EF_PLAYER_EVENT; + t->s.otherEntityNum = ps->clientNum; + // send to everyone except the client who generated the event + t->r.svFlags |= SVF_NOTSINGLECLIENT; + t->r.singleClient = ps->clientNum; + // set back external event + ps->externalEvent = extEvent; + } } /* @@ -962,7 +962,7 @@ void ClientThink_real( gentity_t *ent ) // don't think if the client is not yet connected (and thus not yet spawned in) if( client->pers.connected != CON_CONNECTED ) return; - + // mark the time, so the connection sprite can be removed ucmd = &ent->client->pers.cmd; @@ -972,7 +972,7 @@ void ClientThink_real( gentity_t *ent ) ucmd->serverTime = level.time + 200; // G_Printf("serverTime <<<<<\n" ); } - + if( ucmd->serverTime < level.time - 1000 ) { ucmd->serverTime = level.time - 1000; @@ -984,10 +984,10 @@ void ClientThink_real( gentity_t *ent ) // to check for follow toggles if( msec < 1 && client->sess.spectatorState != SPECTATOR_FOLLOW ) return; - + if( msec > 200 ) msec = 200; - + if( pmove_msec.integer < 8 ) trap_Cvar_Set( "pmove_msec", "8" ); else if( pmove_msec.integer > 33 ) @@ -999,7 +999,7 @@ void ClientThink_real( gentity_t *ent ) //if (ucmd->serverTime - client->ps.commandTime <= 0) // return; } - + // // check for exiting intermission // @@ -1014,7 +1014,7 @@ void ClientThink_real( gentity_t *ent ) { if( client->sess.spectatorState == SPECTATOR_SCOREBOARD ) return; - + SpectatorThink( ent, ucmd ); return; } @@ -1061,11 +1061,11 @@ void ClientThink_real( gentity_t *ent ) if( client->ps.stats[ STAT_STATE ] & SS_POISONCLOUDED && client->lastPoisonCloudedTime + LEVEL1_PCLOUD_TIME < level.time ) client->ps.stats[ STAT_STATE ] &= ~SS_POISONCLOUDED; - + if( client->ps.stats[ STAT_STATE ] & SS_POISONED && client->lastPoisonTime + ALIEN_POISON_TIME < level.time ) client->ps.stats[ STAT_STATE ] &= ~SS_POISONED; - + client->ps.gravity = g_gravity.value; if( BG_InventoryContainsUpgrade( UP_MEDKIT, client->ps.stats ) && @@ -1083,42 +1083,42 @@ void ClientThink_real( gentity_t *ent ) //remove anti toxin BG_DeactivateUpgrade( UP_MEDKIT, client->ps.stats ); BG_RemoveUpgradeFromInventory( UP_MEDKIT, client->ps.stats ); - + client->ps.stats[ STAT_STATE ] &= ~SS_POISONED; client->poisonImmunityTime = level.time + MEDKIT_POISON_IMMUNITY_TIME; - + client->ps.stats[ STAT_STATE ] |= SS_MEDKIT_ACTIVE; client->lastMedKitTime = level.time; client->medKitHealthToRestore = client->ps.stats[ STAT_MAX_HEALTH ] - client->ps.stats[ STAT_HEALTH ]; client->medKitIncrementTime = level.time + ( MEDKIT_STARTUP_TIME / MEDKIT_STARTUP_SPEED ); - + G_AddEvent( ent, EV_MEDKIT_USED, 0 ); } } - + if( BG_InventoryContainsUpgrade( UP_GRENADE, client->ps.stats ) && BG_UpgradeIsActive( UP_GRENADE, client->ps.stats ) ) { int lastWeapon = ent->s.weapon; - + //remove anti toxin BG_DeactivateUpgrade( UP_GRENADE, client->ps.stats ); BG_RemoveUpgradeFromInventory( UP_GRENADE, client->ps.stats ); - + //M-M-M-M-MONSTER HACK ent->s.weapon = WP_GRENADE; FireWeapon( ent ); ent->s.weapon = lastWeapon; } - + // set speed client->ps.speed = g_speed.value * BG_FindSpeedForClass( client->ps.stats[ STAT_PCLASS ] ); if( client->lastCreepSlowTime + CREEP_TIMEOUT < level.time ) client->ps.stats[ STAT_STATE ] &= ~SS_CREEPSLOWED; - + //randomly disable the jet pack if damaged if( BG_InventoryContainsUpgrade( UP_JETPACK, client->ps.stats ) && BG_UpgradeIsActive( UP_JETPACK, client->ps.stats ) ) @@ -1133,7 +1133,7 @@ void ClientThink_real( gentity_t *ent ) if( !level.reactorPresent ) BG_DeactivateUpgrade( UP_JETPACK, client->ps.stats ); } - + // set up for pmove oldEventSequence = client->ps.eventSequence; @@ -1169,19 +1169,19 @@ void ClientThink_real( gentity_t *ent ) ent->flags &= ~FL_FORCE_GESTURE; ent->client->pers.cmd.buttons |= BUTTON_GESTURE; } - + pm.ps = &client->ps; pm.cmd = *ucmd; - + if( pm.ps->pm_type == PM_DEAD ) pm.tracemask = MASK_PLAYERSOLID; // & ~CONTENTS_BODY; - + if( pm.ps->stats[ STAT_STATE ] & SS_INFESTING || pm.ps->stats[ STAT_STATE ] & SS_HOVELING ) pm.tracemask = MASK_PLAYERSOLID & ~CONTENTS_BODY; else pm.tracemask = MASK_PLAYERSOLID; - + pm.trace = trap_Trace; pm.pointcontents = trap_PointContents; pm.debugLevel = g_debugMove.integer; @@ -1229,7 +1229,7 @@ void ClientThink_real( gentity_t *ent ) // link entity now, after any personal teleporters have been used trap_LinkEntity( ent ); - + // NOTE: now copy the exact origin over otherwise clients can be snapped into solid VectorCopy( ent->client->ps.origin, ent->r.currentOrigin ); VectorCopy( ent->client->ps.origin, ent->s.origin ); @@ -1240,7 +1240,7 @@ void ClientThink_real( gentity_t *ent ) // save results of triggers and client events if( ent->client->ps.eventSequence != oldEventSequence ) ent->eventTime = level.time; - + // swap and latch button actions client->oldbuttons = client->buttons; client->buttons = ucmd->buttons; @@ -1256,7 +1256,7 @@ void ClientThink_real( gentity_t *ent ) if( client->ps.stats[ STAT_STATE ] & SS_HOVELING ) { gentity_t *hovel = client->hovel; - + //only let the player out if there is room if( !AHovel_Blocked( hovel, ent, qtrue ) ) { @@ -1266,7 +1266,7 @@ void ClientThink_real( gentity_t *ent ) //client leaves hovel client->ps.stats[ STAT_STATE ] &= ~SS_HOVELING; - + //hovel is empty G_setBuildableAnim( hovel, BANIM_ATTACK2, qfalse ); hovel->active = qfalse; @@ -1280,14 +1280,14 @@ void ClientThink_real( gentity_t *ent ) else { #define USE_OBJECT_RANGE 64 - + int entityList[ MAX_GENTITIES ]; vec3_t range = { USE_OBJECT_RANGE, USE_OBJECT_RANGE, USE_OBJECT_RANGE }; vec3_t mins, maxs; int i, num; int j; qboolean upgrade = qfalse; - + //TA: look for object infront of player AngleVectors( client->ps.viewangles, view, NULL, NULL ); VectorMA( client->ps.origin, USE_OBJECT_RANGE, view, point ); @@ -1303,19 +1303,19 @@ void ClientThink_real( gentity_t *ent ) VectorAdd( client->ps.origin, range, maxs ); VectorSubtract( client->ps.origin, range, mins ); - + num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { traceEnt = &g_entities[ entityList[ i ] ]; - + if( traceEnt && traceEnt->biteam == client->ps.stats[ STAT_PTEAM ] && traceEnt->use ) { traceEnt->use( traceEnt, ent, ent ); //other and activator are the same in this context break; } } - + if( i == num && client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { for( j = PCL_NONE + 1; j < PCL_NUM_CLASSES; j++ ) @@ -1328,7 +1328,7 @@ void ClientThink_real( gentity_t *ent ) break; } } - + if( upgrade ) { //no nearby objects and alien - show class menu @@ -1343,7 +1343,7 @@ void ClientThink_real( gentity_t *ent ) } } } - + // check for respawning if( client->ps.stats[ STAT_HEALTH ] <= 0 ) { @@ -1374,15 +1374,6 @@ void ClientThink_real( gentity_t *ent ) client->retriggerArmouryMenu = 0; } - if( ent->suicideTime > 0 && ent->suicideTime < level.time ) - { - ent->flags &= ~FL_GODMODE; - ent->client->ps.stats[ STAT_HEALTH ] = ent->health = 0; - player_die( ent, ent, ent, 100000, MOD_SUICIDE ); - - ent->suicideTime = 0; - } - // Give clients some credit periodically if( ent->client->lastKillTime + FREEKILL_PERIOD < level.time ) { @@ -1401,6 +1392,15 @@ void ClientThink_real( gentity_t *ent ) // perform once-a-second actions ClientTimerActions( ent, msec ); + + if( ent->suicideTime > 0 && ent->suicideTime < level.time ) + { + ent->flags &= ~FL_GODMODE; + ent->client->ps.stats[ STAT_HEALTH ] = ent->health = 0; + player_die( ent, ent, ent, 100000, MOD_SUICIDE ); + + ent->suicideTime = 0; + } } /* @@ -1430,7 +1430,7 @@ void G_RunClient( gentity_t *ent ) { if( !( ent->r.svFlags & SVF_BOT ) && !g_synchronousClients.integer ) return; - + ent->client->pers.cmd.serverTime = level.time; ClientThink_real( ent ); } @@ -1455,7 +1455,7 @@ void SpectatorClientEndFrame( gentity_t *ent ) if( clientNum >= 0 ) { cl = &level.clients[ clientNum ]; - + if( cl->pers.connected == CON_CONNECTED && cl->sess.sessionTeam != TEAM_SPECTATOR ) { flags = ( cl->ps.eFlags & ~( EF_VOTED | EF_TEAMVOTED ) ) | @@ -1517,7 +1517,7 @@ void ClientEndFrame( gentity_t *ent ) BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue ); else BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue ); - + SendPendingPredictableEvents( &ent->client->ps ); } diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index fef7697c..923d210f 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -26,9 +26,9 @@ void G_setBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim, qboolean fo if( force ) localAnim |= ANIM_FORCEBIT; - + localAnim |= ( ( ent->s.legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ); - + ent->s.legsAnim = localAnim; } @@ -51,7 +51,8 @@ G_CheckSpawnPoint Check if a spawn at a specified point is valid =============== */ -gentity_t *G_CheckSpawnPoint( vec3_t origin, vec3_t normal, buildable_t spawn, vec3_t spawnOrigin ) +gentity_t *G_CheckSpawnPoint( int spawnNum, vec3_t origin, vec3_t normal, + buildable_t spawn, vec3_t spawnOrigin ) { float displacement; vec3_t mins, maxs; @@ -65,17 +66,22 @@ gentity_t *G_CheckSpawnPoint( vec3_t origin, vec3_t normal, buildable_t spawn, v { VectorSet( cmins, -MAX_ALIEN_BBOX, -MAX_ALIEN_BBOX, -MAX_ALIEN_BBOX ); VectorSet( cmaxs, MAX_ALIEN_BBOX, MAX_ALIEN_BBOX, MAX_ALIEN_BBOX ); - + displacement = ( maxs[ 2 ] + MAX_ALIEN_BBOX ) * M_ROOT3; VectorMA( origin, displacement, normal, localOrigin ); - + + trap_Trace( &tr, origin, NULL, NULL, localOrigin, spawnNum, MASK_SHOT ); + + if( tr.entityNum != ENTITYNUM_NONE ) + return &g_entities[ tr.entityNum ]; + trap_Trace( &tr, localOrigin, cmins, cmaxs, localOrigin, -1, MASK_SHOT ); if( tr.entityNum == ENTITYNUM_NONE ) { if( spawnOrigin != NULL ) VectorCopy( localOrigin, spawnOrigin ); - + return NULL; } else @@ -87,14 +93,19 @@ gentity_t *G_CheckSpawnPoint( vec3_t origin, vec3_t normal, buildable_t spawn, v VectorCopy( origin, localOrigin ); localOrigin[ 2 ] += maxs[ 2 ] + fabs( cmins[ 2 ] ) + 1.0f; - + + trap_Trace( &tr, origin, NULL, NULL, localOrigin, spawnNum, MASK_SHOT ); + + if( tr.entityNum != ENTITYNUM_NONE ) + return &g_entities[ tr.entityNum ]; + trap_Trace( &tr, localOrigin, cmins, cmaxs, localOrigin, -1, MASK_SHOT ); - + if( tr.entityNum == ENTITYNUM_NONE ) { if( spawnOrigin != NULL ) VectorCopy( localOrigin, spawnOrigin ); - + return NULL; } else @@ -115,7 +126,7 @@ static int G_NumberOfDependants( gentity_t *self ) { int i, n = 0; gentity_t *ent; - + for ( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { if( ent->s.eType != ET_BUILDABLE ) @@ -149,18 +160,18 @@ static qboolean findPower( gentity_t *self ) if( self->biteam != BIT_HUMANS ) return qfalse; - + //reactor is always powered if( self->s.modelindex == BA_H_REACTOR ) return qtrue; - + //if this already has power then stop now if( self->parentNode && self->parentNode->powered ) return qtrue; - + //reset parent self->parentNode = NULL; - + //iterate through entities for ( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { @@ -185,9 +196,9 @@ static qboolean findPower( gentity_t *self ) //if there were no power items nearby give up if( !foundPower ) return qfalse; - + //bleh - if( ( closestPower->s.modelindex == BA_H_REACTOR && ( minDistance <= REACTOR_BASESIZE ) ) || + if( ( closestPower->s.modelindex == BA_H_REACTOR && ( minDistance <= REACTOR_BASESIZE ) ) || ( closestPower->s.modelindex == BA_H_REPEATER && ( minDistance <= REPEATER_BASESIZE ) && closestPower->powered ) ) { @@ -236,14 +247,14 @@ static qboolean findDCC( gentity_t *self ) if( self->biteam != BIT_HUMANS ) return qfalse; - + //if this already has dcc then stop now if( self->dccNode && self->dccNode->powered ) return qtrue; - + //reset parent self->dccNode = NULL; - + //iterate through entities for( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { @@ -267,7 +278,7 @@ static qboolean findDCC( gentity_t *self ) //if there were no power items nearby give up if( !foundDCC ) return qfalse; - + self->dccNode = closestDCC; return qtrue; @@ -304,14 +315,14 @@ static qboolean findOvermind( gentity_t *self ) if( self->biteam != BIT_ALIENS ) return qfalse; - + //if this already has overmind then stop now if( self->overmindNode && self->overmindNode->health > 0 ) return qtrue; - + //reset parent self->overmindNode = NULL; - + //iterate through entities for( i = 1, ent = g_entities + i; i < level.num_entities; i++, ent++ ) { @@ -365,7 +376,7 @@ static qboolean findCreep( gentity_t *self ) //don't check for creep if flying through the air if( self->s.groundEntityNum == -1 ) return qtrue; - + //if self does not have a parentNode or it's parentNode is invalid find a new one if( ( self->parentNode == NULL ) || !self->parentNode->inuse ) { @@ -386,7 +397,7 @@ static qboolean findCreep( gentity_t *self ) } } } - + if( minDistance <= CREEP_BASESIZE ) { self->parentNode = closestSpawn; @@ -438,13 +449,13 @@ static void creepSlow( gentity_t *self ) VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); - + //find humans num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { enemy = &g_entities[ entityList[ i ] ]; - + if( enemy->client && enemy->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS && enemy->client->ps.groundEntityNum != ENTITYNUM_NONE && G_Visible( self, enemy ) ) @@ -504,7 +515,7 @@ void A_CreepRecede( gentity_t *self ) ( 1.0f - ( (float)( level.time - self->buildTime ) / (float)BG_FindBuildTimeForBuildable( self->s.modelindex ) ) ) ) ); } - + //creep is still receeding if( ( self->timestamp + 10000 ) > level.time ) self->nextthink = level.time + 500; @@ -537,7 +548,7 @@ void ASpawn_Melt( gentity_t *self ) { self->s.eFlags |= EF_DEAD; G_AddEvent( self, EV_BUILD_DESTROY, 0 ); - + if( self->spawned ) self->s.time = -level.time; else @@ -546,7 +557,7 @@ void ASpawn_Melt( gentity_t *self ) ( 1.0f - ( (float)( level.time - self->buildTime ) / (float)BG_FindBuildTimeForBuildable( self->s.modelindex ) ) ) ) ); } - + //not dead yet if( ( self->timestamp + 10000 ) > level.time ) self->nextthink = level.time + 500; @@ -577,7 +588,7 @@ void ASpawn_Blast( gentity_t *self ) self->timestamp = level.time; self->think = ASpawn_Melt; self->nextthink = level.time + 500; //wait .5 seconds before damaging others - + self->r.contents = 0; //stop collisions... trap_LinkEntity( self ); //...requires a relink } @@ -596,14 +607,14 @@ void ASpawn_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int self->die = nullDieFunction; self->think = ASpawn_Blast; - + if( self->spawned ) self->nextthink = level.time + 5000; else self->nextthink = level.time; //blast immediately - + self->s.eFlags &= ~EF_FIRING; //prevent any firing effects - + if( attacker && attacker->client && attacker->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { if( self->s.modelindex == BA_A_OVERMIND ) @@ -624,12 +635,13 @@ void ASpawn_Think( gentity_t *self ) { gentity_t *ent; - if( self->spawned ) + if( self->spawned ) { //only suicide if at rest if( self->s.groundEntityNum ) { - if( ( ent = G_CheckSpawnPoint( self->s.origin, self->s.origin2, BA_A_SPAWN, NULL ) ) != NULL ) + if( ( ent = G_CheckSpawnPoint( self->s.number, self->s.origin, + self->s.origin2, BA_A_SPAWN, NULL ) ) != NULL ) { if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD || ent->s.eType == ET_MOVER ) @@ -692,7 +704,7 @@ void AOvermind_Think( gentity_t *self ) VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); - + if( self->spawned && ( self->health > 0 ) ) { //do some damage @@ -700,7 +712,7 @@ void AOvermind_Think( gentity_t *self ) for( i = 0; i < num; i++ ) { enemy = &g_entities[ entityList[ i ] ]; - + if( enemy->client && enemy->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { self->timestamp = level.time; @@ -716,7 +728,7 @@ void AOvermind_Think( gentity_t *self ) self->overmindSpawnsTimer = level.time + OVERMIND_SPAWNS_PERIOD; G_BroadcastEvent( EV_OVERMIND_SPAWNS, 0 ); } - + //overmind dying if( self->health < ( OVERMIND_HEALTH / 10.0f ) && level.time > self->overmindDyingTimer ) { @@ -730,7 +742,7 @@ void AOvermind_Think( gentity_t *self ) self->overmindAttackTimer = level.time + OVERMIND_ATTACK_PERIOD; G_BroadcastEvent( EV_OVERMIND_ATTACK, 0 ); } - + self->lastHealth = self->health; } else @@ -790,7 +802,7 @@ void ABarricade_Blast( gentity_t *self ) self->timestamp = level.time; self->think = A_CreepRecede; self->nextthink = level.time + 500; //wait .5 seconds before damaging others - + self->r.contents = 0; //stop collisions... trap_LinkEntity( self ); //...requires a relink } @@ -806,11 +818,11 @@ void ABarricade_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, { G_setBuildableAnim( self, BANIM_DESTROY1, qtrue ); G_setIdleBuildableAnim( self, BANIM_DESTROYED ); - + self->die = nullDieFunction; self->think = ABarricade_Blast; self->s.eFlags &= ~EF_FIRING; //prevent any firing effects - + if( self->spawned ) self->nextthink = level.time + 5000; else @@ -832,7 +844,7 @@ void ABarricade_Think( gentity_t *self ) G_Damage( self, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE ); return; } - + creepSlow( self ); self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex ); @@ -864,7 +876,7 @@ void AAcidTube_Damage( gentity_t *self ) self->s.eFlags |= EF_FIRING; G_AddEvent( self, EV_ALIEN_ACIDTUBE, DirToByte( self->s.origin2 ) ); } - + if( ( self->timestamp + ACIDTUBE_REPEAT ) > level.time ) self->think = AAcidTube_Damage; else @@ -900,22 +912,22 @@ void AAcidTube_Think( gentity_t *self ) VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); - + //if there is no creep nearby die if( !findCreep( self ) ) { G_Damage( self, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE ); return; } - - if( self->spawned && findOvermind( self ) ) + + if( self->spawned && findOvermind( self ) ) { //do some damage num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { enemy = &g_entities[ entityList[ i ] ]; - + if( !G_Visible( self, enemy ) ) continue; @@ -960,10 +972,10 @@ void AHive_Think( gentity_t *self ) vec3_t dirToTarget; self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex ); - + VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); - + //if there is no creep nearby die if( !findCreep( self ) ) { @@ -973,15 +985,15 @@ void AHive_Think( gentity_t *self ) if( self->timestamp < level.time ) self->active = qfalse; //nothing has returned in HIVE_REPEAT seconds, forget about it - - if( self->spawned && !self->active && findOvermind( self ) ) + + if( self->spawned && !self->active && findOvermind( self ) ) { //do some damage num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { enemy = &g_entities[ entityList[ i ] ]; - + if( enemy->health <= 0 ) continue; @@ -993,11 +1005,11 @@ void AHive_Think( gentity_t *self ) self->active = qtrue; self->target_ent = enemy; self->timestamp = level.time + HIVE_REPEAT; - + VectorSubtract( enemy->s.pos.trBase, self->s.pos.trBase, dirToTarget ); VectorNormalize( dirToTarget ); vectoangles( dirToTarget, self->turretAim ); - + //fire at target FireWeapon( self ); G_setBuildableAnim( self, BANIM_ATTACK1, qfalse ); @@ -1036,7 +1048,7 @@ qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideEx BG_FindBBoxForBuildable( BA_A_HOVEL, NULL, hovelMaxs ); BG_FindBBoxForClass( player->client->ps.stats[ STAT_PCLASS ], mins, maxs, NULL, NULL, NULL ); - + VectorCopy( hovel->s.origin2, normal ); AngleVectors( hovel->s.angles, forward, NULL, NULL ); VectorInverse( forward ); @@ -1048,21 +1060,21 @@ qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideEx vectoangles( forward, angles ); VectorMA( origin, HOVEL_TRACE_DEPTH, normal, start ); - + //compute a place up in the air to start the real trace trap_Trace( &tr, origin, mins, maxs, start, player->s.number, MASK_PLAYERSOLID ); VectorMA( origin, ( HOVEL_TRACE_DEPTH * tr.fraction ) - 1.0f, normal, start ); VectorMA( origin, -HOVEL_TRACE_DEPTH, normal, end ); - + trap_Trace( &tr, start, mins, maxs, end, player->s.number, MASK_PLAYERSOLID ); - + if( tr.startsolid ) return qtrue; VectorCopy( tr.endpos, origin ); - + trap_Trace( &tr, origin, mins, maxs, origin, player->s.number, MASK_PLAYERSOLID ); - + if( provideExit ) { G_SetOrigin( player, origin ); @@ -1070,7 +1082,7 @@ qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideEx VectorCopy( vec3_origin, player->client->ps.velocity ); SetClientViewAngle( player, angles ); } - + if( tr.fraction < 1.0f ) return qtrue; else @@ -1106,8 +1118,8 @@ Called when an alien uses a hovel void AHovel_Use( gentity_t *self, gentity_t *other, gentity_t *activator ) { vec3_t hovelOrigin, hovelAngles, inverseNormal; - - if( self->spawned && findOvermind( self ) ) + + if( self->spawned && findOvermind( self ) ) { if( self->active ) { @@ -1169,7 +1181,7 @@ void AHovel_Think( gentity_t *self ) else G_setIdleBuildableAnim( self, BANIM_IDLE1 ); } - + creepSlow( self ); self->nextthink = level.time + 200; @@ -1199,31 +1211,31 @@ void AHovel_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int self->timestamp = level.time; self->think = ASpawn_Melt; self->nextthink = level.time + 500; //wait .5 seconds before damaging others - + //if the hovel is occupied free the occupant if( self->active ) { gentity_t *builder = self->builder; vec3_t newOrigin; vec3_t newAngles; - + VectorCopy( self->s.angles, newAngles ); newAngles[ ROLL ] = 0; - + VectorCopy( self->s.origin, newOrigin ); VectorMA( newOrigin, 1.0f, self->s.origin2, newOrigin ); - + //prevent lerping builder->client->ps.eFlags ^= EF_TELEPORT_BIT; - + G_SetOrigin( builder, newOrigin ); VectorCopy( newOrigin, builder->client->ps.origin ); SetClientViewAngle( builder, newAngles ); - + //client leaves hovel builder->client->ps.stats[ STAT_STATE ] &= ~SS_HOVELING; } - + self->r.contents = 0; //stop collisions... trap_LinkEntity( self ); //...requires a relink } @@ -1248,10 +1260,10 @@ void ABooster_Touch( gentity_t *self, gentity_t *other, trace_t *trace ) { int maxAmmo, maxClips; gclient_t *client = other->client; - + if( !self->spawned ) return; - + if( !findOvermind( self ) ) return; @@ -1260,15 +1272,15 @@ void ABooster_Touch( gentity_t *self, gentity_t *other, trace_t *trace ) if( client && client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) return; - + //only allow boostage once every 30 seconds if( client->lastBoostedTime + BOOSTER_INTERVAL > level.time ) return; - + //restore ammo, if any BG_FindAmmoForWeapon( client->ps.weapon, &maxAmmo, &maxClips ); BG_PackAmmoArray( client->ps.weapon, client->ps.ammo, client->ps.powerups, maxAmmo, maxClips ); - + if( !( client->ps.stats[ STAT_STATE ] & SS_BOOSTED ) ) { client->ps.stats[ STAT_STATE ] |= SS_BOOSTED; @@ -1295,7 +1307,7 @@ void ADef_FireOnEnemy( gentity_t *self, int firespeed, float range ) vec3_t halfAcceleration, thirdJerk; float distanceToTarget = BG_FindRangeForBuildable( self->s.modelindex ); int i; - + VectorScale( self->enemy->acceleration, 1.0f / 2.0f, halfAcceleration ); VectorScale( self->enemy->jerk, 1.0f / 3.0f, thirdJerk ); @@ -1308,7 +1320,7 @@ void ADef_FireOnEnemy( gentity_t *self, int firespeed, float range ) { VectorSubtract( self->enemy->s.pos.trBase, self->s.pos.trBase, dirToTarget ); distanceToTarget = VectorLength( dirToTarget ); - + G_LogPrintf( "ADef_FireOnEnemy failed.\n" " %dth iteration\n enemy location: %v\n" " enemy accleration: %v\n enemy jerk: %v\n" @@ -1316,9 +1328,9 @@ void ADef_FireOnEnemy( gentity_t *self, int firespeed, float range ) i, self->enemy->s.pos.trBase, self->enemy->acceleration, self->enemy->jerk, self->s.pos.trBase, distanceToTarget ); - return; + return; } - + VectorMA( self->enemy->s.pos.trBase, time, self->enemy->s.pos.trDelta, dirToTarget ); VectorMA( dirToTarget, time * time, halfAcceleration, dirToTarget ); @@ -1328,7 +1340,7 @@ void ADef_FireOnEnemy( gentity_t *self, int firespeed, float range ) distanceToTarget -= self->enemy->r.maxs[ 0 ]; } - + VectorNormalize( dirToTarget ); vectoangles( dirToTarget, self->turretAim ); @@ -1400,7 +1412,7 @@ void ADef_FindEnemy( gentity_t *ent, int range ) //if target is not valid keep searching if( !ADef_CheckTarget( ent, target, range ) ) continue; - + //we found a target ent->enemy = target; return; @@ -1442,7 +1454,7 @@ void ATrapper_Think( gentity_t *self ) //if a new target cannot be found don't do anything if( !self->enemy ) return; - + //if we are pointing at our target and we can fire shoot it if( self->count < level.time ) ADef_FireOnEnemy( self, firespeed, range ); @@ -1480,7 +1492,7 @@ void HRepeater_Think( gentity_t *self ) reactor = qtrue; } } - + if( G_NumberOfDependants( self ) == 0 ) { //if no dependants for x seconds then disappear @@ -1511,7 +1523,7 @@ void HRepeater_Use( gentity_t *self, gentity_t *other, gentity_t *activator ) if( !self->spawned ) return; - + G_GiveClientMaxAmmo( self, qtrue ); } @@ -1535,7 +1547,7 @@ void HReactor_Think( gentity_t *self ) VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); - + if( self->spawned && ( self->health > 0 ) ) { //do some damage @@ -1543,22 +1555,22 @@ void HReactor_Think( gentity_t *self ) for( i = 0; i < num; i++ ) { enemy = &g_entities[ entityList[ i ] ]; - + if( enemy->client && enemy->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { self->timestamp = level.time; G_SelectiveRadiusDamage( self->s.pos.trBase, self, REACTOR_ATTACK_DAMAGE, REACTOR_ATTACK_RANGE, self, MOD_REACTOR, PTE_HUMANS ); - + tent = G_TempEntity( enemy->s.pos.trBase, EV_TESLATRAIL ); VectorCopy( self->s.pos.trBase, tent->s.origin2 ); - + tent->s.generic1 = self->s.number; //src tent->s.clientNum = enemy->s.number; //dest } } - + //reactor under attack if( self->health < self->lastHealth && level.time > level.humanBaseAttackTimer && G_isDCC( ) ) @@ -1566,7 +1578,7 @@ void HReactor_Think( gentity_t *self ) level.humanBaseAttackTimer = level.time + DCC_ATTACK_PERIOD; G_BroadcastEvent( EV_DCC_ATTACK, 0 ); } - + self->lastHealth = self->health; } @@ -1591,7 +1603,7 @@ void HArmoury_Activate( gentity_t *self, gentity_t *other, gentity_t *activator //only humans can activate this if( activator->client->ps.stats[ STAT_PTEAM ] != PTE_HUMANS ) return; - + //if this is powered then call the armoury menu if( self->powered ) G_TriggerMenu( activator->client->ps.clientNum, MN_H_ARMOURY ); @@ -1611,7 +1623,7 @@ void HArmoury_Think( gentity_t *self ) { //make sure we have power self->nextthink = level.time + POWER_REFRESH_TIME; - + self->powered = findPower( self ); } @@ -1635,7 +1647,7 @@ void HDCC_Think( gentity_t *self ) { //make sure we have power self->nextthink = level.time + POWER_REFRESH_TIME; - + self->powered = findPower( self ); } @@ -1667,7 +1679,7 @@ void HMedistat_Think( gentity_t *self ) self->nextthink = level.time + POWER_REFRESH_TIME; return; } - + if( self->spawned ) { VectorAdd( self->s.origin, self->r.maxs, maxs ); @@ -1675,7 +1687,7 @@ void HMedistat_Think( gentity_t *self ) mins[ 2 ] += fabs( self->r.mins[ 2 ] ) + self->r.maxs[ 2 ]; maxs[ 2 ] += 60; //player height - + //if active use the healing idle if( self->active ) G_setIdleBuildableAnim( self, BANIM_IDLE2 ); @@ -1685,7 +1697,7 @@ void HMedistat_Think( gentity_t *self ) for( i = 0; i < num; i++ ) { player = &g_entities[ entityList[ i ] ]; - + if( player->client && player->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { if( player->health < player->client->ps.stats[ STAT_MAX_HEALTH ] && @@ -1698,19 +1710,19 @@ void HMedistat_Think( gentity_t *self ) if( !occupied ) { self->enemy = NULL; - + //look for something to heal for( i = 0; i < num; i++ ) { player = &g_entities[ entityList[ i ] ]; - + if( player->client && player->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { if( player->health < player->client->ps.stats[ STAT_MAX_HEALTH ] && player->client->ps.pm_type != PM_DEAD ) { self->enemy = player; - + //start the heal anim if( !self->active ) { @@ -1729,17 +1741,17 @@ void HMedistat_Think( gentity_t *self ) { G_setBuildableAnim( self, BANIM_CONSTRUCT2, qtrue ); G_setIdleBuildableAnim( self, BANIM_IDLE1 ); - + self->active = qfalse; } else if( self->enemy ) //heal! { if( self->enemy->client && self->enemy->client->ps.stats[ STAT_STATE ] & SS_POISONED ) self->enemy->client->ps.stats[ STAT_STATE ] &= ~SS_POISONED; - + if( self->enemy->client && self->enemy->client->ps.stats[ STAT_STATE ] & SS_MEDKIT_ACTIVE ) self->enemy->client->ps.stats[ STAT_STATE ] &= ~SS_MEDKIT_ACTIVE; - + self->enemy->health++; //if they're completely healed, give them a medkit @@ -1792,12 +1804,12 @@ qboolean HMGTurret_TrackEnemy( gentity_t *self ) VectorSubtract( self->enemy->s.pos.trBase, self->s.pos.trBase, dirToTarget ); VectorNormalize( dirToTarget ); - + CrossProduct( self->s.origin2, refNormal, xNormal ); VectorNormalize( xNormal ); rotAngle = RAD2DEG( acos( DotProduct( self->s.origin2, refNormal ) ) ); RotatePointAroundVector( dttAdjusted, xNormal, dirToTarget, rotAngle ); - + vectoangles( dttAdjusted, angleToTarget ); angularDiff[ PITCH ] = AngleSubtract( self->s.angles2[ PITCH ], angleToTarget[ PITCH ] ); @@ -1815,10 +1827,10 @@ qboolean HMGTurret_TrackEnemy( gentity_t *self ) temp = fabs( self->s.angles2[ PITCH ] ); if( temp > 180 ) temp -= 360; - + if( temp < -MGTURRET_VERTICALCAP ) self->s.angles2[ PITCH ] = (-360) + MGTURRET_VERTICALCAP; - + //if not pointing at our target then move accordingly if( angularDiff[ YAW ] < (-accuracyTolerance) ) self->s.angles2[ YAW ] += angularSpeed; @@ -1826,7 +1838,7 @@ qboolean HMGTurret_TrackEnemy( gentity_t *self ) self->s.angles2[ YAW ] -= angularSpeed; else self->s.angles2[ YAW ] = angleToTarget[ YAW ]; - + AngleVectors( self->s.angles2, dttAdjusted, NULL, NULL ); RotatePointAroundVector( dirToTarget, xNormal, dttAdjusted, -rotAngle ); vectoangles( dirToTarget, self->turretAim ); @@ -1835,7 +1847,7 @@ qboolean HMGTurret_TrackEnemy( gentity_t *self ) if( abs( angleToTarget[ YAW ] - self->s.angles2[ YAW ] ) <= accuracyTolerance && abs( angleToTarget[ PITCH ] - self->s.angles2[ PITCH ] ) <= accuracyTolerance ) return qtrue; - + return qfalse; } @@ -1851,7 +1863,7 @@ qboolean HMGTurret_CheckTarget( gentity_t *self, gentity_t *target, qboolean ign { trace_t trace; gentity_t *traceEnt; - + if( !target ) return qfalse; @@ -1860,10 +1872,10 @@ qboolean HMGTurret_CheckTarget( gentity_t *self, gentity_t *target, qboolean ign if( target->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) return qfalse; - + if( target->health <= 0 ) return qfalse; - + if( Distance( self->s.origin, target->s.pos.trBase ) > MGTURRET_RANGE ) return qfalse; @@ -1872,7 +1884,7 @@ qboolean HMGTurret_CheckTarget( gentity_t *self, gentity_t *target, qboolean ign return qfalse; trap_Trace( &trace, self->s.pos.trBase, NULL, NULL, target->s.pos.trBase, self->s.number, MASK_SHOT ); - + traceEnt = &g_entities[ trace.entityNum ]; if( !traceEnt->client ) @@ -1903,19 +1915,19 @@ void HMGTurret_FindEnemy( gentity_t *self ) VectorSet( range, MGTURRET_RANGE, MGTURRET_RANGE, MGTURRET_RANGE ); VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); - + //find aliens num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { target = &g_entities[ entityList[ i ] ]; - + if( target->client && target->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { //if target is not valid keep searching if( !HMGTurret_CheckTarget( self, target, qfalse ) ) continue; - + //we found a target self->enemy = target; return; @@ -1928,20 +1940,20 @@ void HMGTurret_FindEnemy( gentity_t *self ) for( i = 0; i < num; i++ ) { target = &g_entities[ entityList[ i ] ]; - + if( target->client && target->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { //if target is not valid keep searching if( !HMGTurret_CheckTarget( self, target, qtrue ) ) continue; - + //we found a target self->enemy = target; return; } } } - + //couldn't find a target self->enemy = NULL; } @@ -1962,19 +1974,19 @@ void HMGTurret_Think( gentity_t *self ) //used for client side muzzle flashes self->s.eFlags &= ~EF_FIRING; - + //if not powered don't do anything and check again for power next think if( !( self->powered = findPower( self ) ) ) { self->nextthink = level.time + POWER_REFRESH_TIME; return; } - + if( self->spawned ) { //find a dcc for self self->dcced = findDCC( self ); - + //if the current target is not valid find a new one if( !HMGTurret_CheckTarget( self, self->enemy, qfalse ) ) { @@ -1987,7 +1999,7 @@ void HMGTurret_Think( gentity_t *self ) //if a new target cannot be found don't do anything if( !self->enemy ) return; - + self->enemy->targeted = self; //if we are pointing at our target and we can fire shoot it @@ -1995,7 +2007,7 @@ void HMGTurret_Think( gentity_t *self ) { //fire at target FireWeapon( self ); - + self->s.eFlags |= EF_FIRING; G_AddEvent( self, EV_FIRE_WEAPON, 0 ); G_setBuildableAnim( self, BANIM_ATTACK1, qfalse ); @@ -2038,22 +2050,22 @@ void HTeslaGen_Think( gentity_t *self ) self->nextthink = level.time + POWER_REFRESH_TIME; return; } - + if( self->spawned && self->count < level.time ) { //used to mark client side effects self->s.eFlags &= ~EF_FIRING; - + VectorSet( range, TESLAGEN_RANGE, TESLAGEN_RANGE, TESLAGEN_RANGE ); VectorAdd( self->s.origin, range, maxs ); VectorSubtract( self->s.origin, range, mins ); - + //find aliens num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { enemy = &g_entities[ entityList[ i ] ]; - + if( enemy->client && enemy->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS && enemy->health > 0 ) { @@ -2107,7 +2119,7 @@ void HSpawn_Disappear( gentity_t *self ) self->think = freeBuildable; self->nextthink = level.time + 100; - + self->r.contents = 0; //stop collisions... trap_LinkEntity( self ); //...requires a relink } @@ -2139,7 +2151,7 @@ void HSpawn_Blast( gentity_t *self ) self->think = freeBuildable; self->nextthink = level.time + 100; - + self->r.contents = 0; //stop collisions... trap_LinkEntity( self ); //...requires a relink } @@ -2157,11 +2169,11 @@ void HSpawn_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int //pretty events and cleanup G_setBuildableAnim( self, BANIM_DESTROY1, qtrue ); G_setIdleBuildableAnim( self, BANIM_DESTROYED ); - + self->die = nullDieFunction; self->powered = qfalse; //free up power self->s.eFlags &= ~EF_FIRING; //prevent any firing effects - + if( self->spawned ) { self->think = HSpawn_Blast; @@ -2201,7 +2213,8 @@ void HSpawn_Think( gentity_t *self ) //only suicide if at rest if( self->s.groundEntityNum ) { - if( ( ent = G_CheckSpawnPoint( self->s.origin, self->s.origin2, BA_H_SPAWN, NULL ) ) != NULL ) + if( ( ent = G_CheckSpawnPoint( self->s.number, self->s.origin, + self->s.origin2, BA_H_SPAWN, NULL ) ) != NULL ) { if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD || ent->s.eType == ET_MOVER ) @@ -2214,7 +2227,7 @@ void HSpawn_Think( gentity_t *self ) G_FreeEntity( ent ); //quietly remove } } - + //spawn under attack if( self->health < self->lastHealth && level.time > level.humanBaseAttackTimer && G_isDCC( ) ) @@ -2222,7 +2235,7 @@ void HSpawn_Think( gentity_t *self ) level.humanBaseAttackTimer = level.time + DCC_ATTACK_PERIOD; G_BroadcastEvent( EV_DCC_ATTACK, 0 ); } - + self->lastHealth = self->health; } @@ -2257,10 +2270,10 @@ void G_BuildableTouchTriggers( gentity_t *ent ) return; BG_FindBBoxForBuildable( ent->s.modelindex, bmins, bmaxs ); - + VectorAdd( ent->s.origin, bmins, mins ); VectorAdd( ent->s.origin, bmaxs, maxs ); - + VectorSubtract( mins, range, mins ); VectorAdd( maxs, range, maxs ); @@ -2269,7 +2282,7 @@ void G_BuildableTouchTriggers( gentity_t *ent ) VectorAdd( ent->s.origin, bmins, mins ); VectorAdd( ent->s.origin, bmaxs, maxs ); - for( i = 0; i < num; i++ ) + for( i = 0; i < num; i++ ) { hit = &g_entities[ touch[ i ] ]; @@ -2282,7 +2295,7 @@ void G_BuildableTouchTriggers( gentity_t *ent ) //ignore buildables not yet spawned if( !ent->spawned ) continue; - + if( !trap_EntityContact( mins, maxs, hit ) ) continue; @@ -2315,15 +2328,15 @@ void G_BuildableThink( gentity_t *ent, int msec ) if( ent->buildTime + bTime < level.time ) ent->spawned = qtrue; } - + ent->s.generic1 = (int)( ( (float)ent->health / (float)bHealth ) * B_HEALTH_SCALE ); if( ent->s.generic1 < 0 ) ent->s.generic1 = 0; - + if( ent->powered ) ent->s.generic1 |= B_POWERED_TOGGLEBIT; - + if( ent->dcced ) ent->s.generic1 |= B_DCCED_TOGGLEBIT; @@ -2335,13 +2348,13 @@ void G_BuildableThink( gentity_t *ent, int msec ) if( ent->time1000 >= 1000 ) { ent->time1000 -= 1000; - + if( !ent->spawned ) ent->health += (int)( ceil( (float)bHealth / (float)( bTime * 0.001 ) ) ); else if( ent->biteam == BIT_ALIENS && ent->health > 0 && ent->health < bHealth && bRegen && ( ent->lastDamageTime + ALIEN_REGEN_DAMAGE_TIME ) < level.time ) ent->health += bRegen; - + if( ent->health > bHealth ) ent->health = bHealth; } @@ -2351,13 +2364,13 @@ void G_BuildableThink( gentity_t *ent, int msec ) if( ent->clientSpawnTime > 0 ) ent->clientSpawnTime -= msec; - + if( ent->clientSpawnTime < 0 ) ent->clientSpawnTime = 0; //check if this buildable is touching any triggers G_BuildableTouchTriggers( ent ); - + //fall back on normal physics routines G_Physics( ent, msec ); } @@ -2377,19 +2390,19 @@ qboolean G_BuildableRange( vec3_t origin, float r, buildable_t buildable ) vec3_t mins, maxs; int i, num; gentity_t *ent; - + VectorSet( range, r, r, r ); VectorAdd( origin, range, maxs ); VectorSubtract( origin, range, mins ); - + num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { ent = &g_entities[ entityList[ i ] ]; - + if( ent->s.eType != ET_BUILDABLE ) continue; - + if( ent->biteam == BIT_HUMANS && !ent->powered ) continue; @@ -2423,7 +2436,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance playerState_t *ps = &ent->client->ps; BG_FindBBoxForBuildable( buildable, mins, maxs ); - + BG_PositionBuildableRelativeToPlayer( ps, mins, maxs, trap_Trace, entity_origin, angles, &tr1 ); trap_Trace( &tr2, entity_origin, mins, maxs, entity_origin, ent->s.number, MASK_PLAYERSOLID ); @@ -2434,7 +2447,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance //this item does not fit here if( tr2.fraction < 1.0 || tr3.fraction < 1.0 ) return IBE_NOROOM; //NO other reason is allowed to override this - + VectorCopy( tr1.plane.normal, normal ); minNormal = BG_FindMinNormalForBuildable( buildable ); invert = BG_FindInvertNormalForBuildable( buildable ); @@ -2442,12 +2455,12 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance //can we build at this angle? if( !( normal[ 2 ] >= minNormal || ( invert && normal[ 2 ] <= -minNormal ) ) ) return IBE_NORMAL; - + if( tr1.entityNum != ENTITYNUM_WORLD ) return IBE_NORMAL; //check there is enough room to spawn from (presuming this is a spawn) - if( G_CheckSpawnPoint( origin, normal, buildable, NULL ) != NULL ) + if( G_CheckSpawnPoint( -1, origin, normal, buildable, NULL ) != NULL ) return IBE_NORMAL; contents = trap_PointContents( entity_origin, -1 ); @@ -2459,21 +2472,21 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance if( buildable == BA_A_HOVEL ) { vec3_t builderMins, builderMaxs; - + //this assumes the adv builder is the biggest thing that'll use the hovel BG_FindBBoxForClass( PCL_ALIEN_BUILDER0_UPG, builderMins, builderMaxs, NULL, NULL, NULL ); if( APropHovel_Blocked( angles, origin, normal, ent ) ) reason = IBE_HOVELEXIT; } - + //check there is creep near by for building on if( BG_FindCreepTestForBuildable( buildable ) ) { if( !isCreep( entity_origin ) ) reason = IBE_NOCREEP; } - + //check permission to build here if( tr1.surfaceFlags & SURF_NOALIENBUILD || tr1.surfaceFlags & SURF_NOBUILD || contents & CONTENTS_NOALIENBUILD || contents & CONTENTS_NOBUILD ) @@ -2491,7 +2504,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance //if none found... if( i >= level.num_entities && buildable != BA_A_OVERMIND ) reason = IBE_NOOVERMIND; - + //can we only have one of these? if( BG_FindUniqueTestForBuildable( buildable ) ) { @@ -2524,7 +2537,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance //this buildable requires a DCC if( BG_FindDCCTestForBuildable( buildable ) && !G_isDCC( ) ) reason = IBE_NODCC; - + //check that there is a parent reactor when building a repeater if( buildable == BA_H_REPEATER ) { @@ -2533,16 +2546,16 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance if( tempent->s.eType != ET_BUILDABLE ) continue; - if( tempent->s.modelindex == BA_H_REACTOR ) + if( tempent->s.modelindex == BA_H_REACTOR ) break; } - + if( i >= level.num_entities ) reason = IBE_RPTWARN; else if( G_isPower( entity_origin ) ) reason = IBE_RPTWARN2; } - + //check permission to build here if( tr1.surfaceFlags & SURF_NOHUMANBUILD || tr1.surfaceFlags & SURF_NOBUILD || contents & CONTENTS_NOHUMANBUILD || contents & CONTENTS_NOBUILD ) @@ -2556,7 +2569,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance if( tempent->s.eType != ET_BUILDABLE ) continue; - if( tempent->s.modelindex == BA_H_REACTOR ) + if( tempent->s.modelindex == BA_H_REACTOR ) { reason = IBE_REACTOR; break; @@ -2590,19 +2603,19 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin built->s.eType = ET_BUILDABLE; built->classname = BG_FindEntityNameForBuildable( buildable ); - + built->s.modelindex = buildable; //so we can tell what this is on the client side built->biteam = built->s.modelindex2 = BG_FindTeamForBuildable( buildable ); BG_FindBBoxForBuildable( buildable, built->r.mins, built->r.maxs ); built->health = 1; - + built->splashDamage = BG_FindSplashDamageForBuildable( buildable ); built->splashRadius = BG_FindSplashRadiusForBuildable( buildable ); built->splashMethodOfDeath = BG_FindMODForBuildable( buildable ); - + built->nextthink = BG_FindNextThinkForBuildable( buildable ); - + built->takedamage = qtrue; built->spawned = qfalse; built->buildTime = built->s.time = level.time; @@ -2615,96 +2628,96 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin built->think = ASpawn_Think; built->pain = ASpawn_Pain; break; - + case BA_A_BARRICADE: built->die = ABarricade_Die; built->think = ABarricade_Think; built->pain = ABarricade_Pain; break; - + case BA_A_BOOSTER: built->die = ABarricade_Die; built->think = ABarricade_Think; built->pain = ABarricade_Pain; built->touch = ABooster_Touch; break; - + case BA_A_ACIDTUBE: built->die = ABarricade_Die; built->think = AAcidTube_Think; built->pain = ASpawn_Pain; break; - + case BA_A_HIVE: built->die = ABarricade_Die; built->think = AHive_Think; built->pain = ASpawn_Pain; break; - + case BA_A_TRAPPER: built->die = ABarricade_Die; built->think = ATrapper_Think; built->pain = ASpawn_Pain; break; - + case BA_A_OVERMIND: built->die = ASpawn_Die; built->think = AOvermind_Think; built->pain = ASpawn_Pain; break; - + case BA_A_HOVEL: built->die = AHovel_Die; built->use = AHovel_Use; built->think = AHovel_Think; built->pain = ASpawn_Pain; break; - + case BA_H_SPAWN: built->die = HSpawn_Die; built->think = HSpawn_Think; break; - + case BA_H_MGTURRET: built->die = HSpawn_Die; built->think = HMGTurret_Think; break; - + case BA_H_TESLAGEN: built->die = HSpawn_Die; built->think = HTeslaGen_Think; break; - + case BA_H_ARMOURY: built->think = HArmoury_Think; built->die = HSpawn_Die; built->use = HArmoury_Activate; break; - + case BA_H_DCC: built->think = HDCC_Think; built->die = HSpawn_Die; break; - + case BA_H_MEDISTAT: built->think = HMedistat_Think; built->die = HSpawn_Die; break; - + case BA_H_REACTOR: built->think = HReactor_Think; built->die = HSpawn_Die; built->use = HRepeater_Use; built->powered = built->active = qtrue; break; - + case BA_H_REPEATER: built->think = HRepeater_Think; built->die = HSpawn_Die; built->use = HRepeater_Use; built->count = -1; break; - + default: //erk break; @@ -2729,14 +2742,14 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin built->s.pos.trTime = level.time; built->physicsBounce = BG_FindBounceForBuildable( buildable ); built->s.groundEntityNum = -1; - + if( builder->client && builder->client->ps.stats[ STAT_STATE ] & SS_WALLCLIMBING ) { if( builder->client->ps.stats[ STAT_STATE ] & SS_WALLCLIMBINGCEILING ) VectorSet( normal, 0.0f, 0.0f, -1.0f ); else VectorCopy( builder->client->ps.grapplePoint, normal ); - + //gently nudge the buildable onto the surface :) VectorScale( normal, -50.0f, built->s.pos.trDelta ); } @@ -2748,21 +2761,21 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin if( built->s.generic1 < 0 ) built->s.generic1 = 0; - + if( ( built->powered = findPower( built ) ) ) built->s.generic1 |= B_POWERED_TOGGLEBIT; - + if( ( built->dcced = findDCC( built ) ) ) built->s.generic1 |= B_DCCED_TOGGLEBIT; - + built->s.generic1 &= ~B_SPAWNED_TOGGLEBIT; VectorCopy( normal, built->s.origin2 ); - + G_AddEvent( built, EV_BUILD_CONSTRUCT, 0 ); G_setIdleBuildableAnim( built, BG_FindAnimForBuildable( buildable ) ); - + if( built->builtBy >= 0 ) G_setBuildableAnim( built, BANIM_CONSTRUCT1, qtrue ); @@ -2782,7 +2795,7 @@ qboolean G_ValidateBuild( gentity_t *ent, buildable_t buildable ) vec3_t origin; dist = BG_FindBuildDistForClass( ent->client->ps.stats[ STAT_PCLASS ] ); - + switch( G_itemFits( ent, buildable, dist, origin ) ) { case IBE_NONE: @@ -2841,21 +2854,21 @@ qboolean G_ValidateBuild( gentity_t *ent, buildable_t buildable ) case IBE_NOPOWER: G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOPOWER ); return qfalse; - + case IBE_NODCC: G_TriggerMenu( ent->client->ps.clientNum, MN_H_NODCC ); return qfalse; - + case IBE_SPWNWARN: G_TriggerMenu( ent->client->ps.clientNum, MN_A_SPWNWARN ); G_buildItem( ent, buildable, origin, ent->s.apos.trBase ); return qtrue; - + case IBE_TNODEWARN: G_TriggerMenu( ent->client->ps.clientNum, MN_H_TNODEWARN ); G_buildItem( ent, buildable, origin, ent->s.apos.trBase ); return qtrue; - + case IBE_RPTWARN: G_TriggerMenu( ent->client->ps.clientNum, MN_H_RPTWARN ); G_buildItem( ent, buildable, origin, ent->s.apos.trBase ); @@ -2894,7 +2907,7 @@ void FinishSpawningBuildable( gentity_t *ent ) built->spawned = qtrue; //map entities are already spawned built->health = BG_FindHealthForBuildable( buildable ); built->s.generic1 |= B_SPAWNED_TOGGLEBIT; - + // drop to floor if( buildable != BA_NONE && BG_FindTrajectoryForBuildable( buildable ) == TR_BUOYANCY ) VectorSet( dest, built->s.origin[ 0 ], built->s.origin[ 1 ], built->s.origin[ 2 ] + 4096 ); @@ -2902,7 +2915,7 @@ void FinishSpawningBuildable( gentity_t *ent ) VectorSet( dest, built->s.origin[ 0 ], built->s.origin[ 1 ], built->s.origin[ 2 ] - 4096 ); trap_Trace( &tr, built->s.origin, built->r.mins, built->r.maxs, dest, built->s.number, built->clipmask ); - + if( tr.startsolid ) { G_Printf( S_COLOR_YELLOW "FinishSpawningBuildable: %s startsolid at %s\n", built->classname, vtos( built->s.origin ) ); diff --git a/src/game/g_client.c b/src/game/g_client.c index d137b9bb..d8fb60a9 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -13,7 +13,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "g_local.h" // g_client.c -- client functions that don't happen every frame @@ -33,7 +33,7 @@ void SP_info_player_deathmatch( gentity_t *ent ) int i; G_SpawnInt( "nobots", "0", &i); - + if( i ) ent->flags |= FL_NO_BOTS; @@ -98,9 +98,9 @@ void G_AddCreditToClient( gclient_t *client, short credit, qboolean cap ) return; } } - + client->ps.persistant[ PERS_CREDIT ] += credit; - + if( cap ) { if( client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) @@ -114,7 +114,7 @@ void G_AddCreditToClient( gclient_t *client, short credit, qboolean cap ) client->ps.persistant[ PERS_CREDIT ] = HUMAN_MAX_CREDITS; } } - + if( client->ps.persistant[ PERS_CREDIT ] < 0 ) client->ps.persistant[ PERS_CREDIT ] = 0; } @@ -179,7 +179,7 @@ gentity_t *SelectNearestDeathmatchSpawnPoint( vec3_t from ) { VectorSubtract( spot->s.origin, from, delta ); dist = VectorLength( delta ); - + if( dist < nearestDist ) { nearestDist = dist; @@ -252,31 +252,31 @@ gentity_t *SelectRandomFurthestSpawnPoint ( vec3_t avoidPoint, vec3_t origin, ve VectorSubtract( spot->s.origin, avoidPoint, delta ); dist = VectorLength( delta ); - + for( i = 0; i < numSpots; i++ ) { if( dist > list_dist[ i ] ) { if( numSpots >= 64 ) numSpots = 64 - 1; - + for( j = numSpots; j > i; j-- ) { list_dist[ j ] = list_dist[ j - 1 ]; list_spot[ j ] = list_spot[ j - 1 ]; } - + list_dist[ i ] = dist; list_spot[ i ] = spot; numSpots++; - + if( numSpots > 64 ) numSpots = 64; - + break; } } - + if( i >= numSpots && numSpots < 64 ) { list_dist[ numSpots ] = dist; @@ -284,14 +284,14 @@ gentity_t *SelectRandomFurthestSpawnPoint ( vec3_t avoidPoint, vec3_t origin, ve numSpots++; } } - + if( !numSpots ) { spot = G_Find( NULL, FOFS( classname ), "info_player_deathmatch" ); - + if( !spot ) G_Error( "Couldn't find a spawn point" ); - + VectorCopy( spot->s.origin, origin ); origin[ 2 ] += 9; VectorCopy( spot->s.angles, angles ); @@ -324,7 +324,7 @@ gentity_t *SelectAlienSpawnPoint( vec3_t preference ) if( level.numAlienSpawns <= 0 ) return NULL; - + count = 0; spot = NULL; @@ -333,7 +333,7 @@ gentity_t *SelectAlienSpawnPoint( vec3_t preference ) { if( !spot->spawned ) continue; - + if( spot->health <= 0 ) continue; @@ -342,10 +342,11 @@ gentity_t *SelectAlienSpawnPoint( vec3_t preference ) if( spot->clientSpawnTime > 0 ) continue; - - if( G_CheckSpawnPoint( spot->s.origin, spot->s.origin2, BA_A_SPAWN, NULL ) != NULL ) + + if( G_CheckSpawnPoint( spot->s.number, spot->s.origin, + spot->s.origin2, BA_A_SPAWN, NULL ) != NULL ) continue; - + spots[ count ] = spot; count++; } @@ -372,7 +373,7 @@ gentity_t *SelectHumanSpawnPoint( vec3_t preference ) if( level.numHumanSpawns <= 0 ) return NULL; - + count = 0; spot = NULL; @@ -381,7 +382,7 @@ gentity_t *SelectHumanSpawnPoint( vec3_t preference ) { if( !spot->spawned ) continue; - + if( spot->health <= 0 ) continue; @@ -390,10 +391,11 @@ gentity_t *SelectHumanSpawnPoint( vec3_t preference ) if( spot->clientSpawnTime > 0 ) continue; - - if( G_CheckSpawnPoint( spot->s.origin, spot->s.origin2, BA_H_SPAWN, NULL ) != NULL ) + + if( G_CheckSpawnPoint( spot->s.number, spot->s.origin, + spot->s.origin2, BA_H_SPAWN, NULL ) != NULL ) continue; - + spots[ count ] = spot; count++; } @@ -439,15 +441,15 @@ gentity_t *SelectTremulousSpawnPoint( pTeam_t team, vec3_t preference, vec3_t or return NULL; if( team == PTE_ALIENS ) - G_CheckSpawnPoint( spot->s.origin, spot->s.origin2, BA_A_SPAWN, origin ); + G_CheckSpawnPoint( spot->s.number, spot->s.origin, spot->s.origin2, BA_A_SPAWN, origin ); else if( team == PTE_HUMANS ) - G_CheckSpawnPoint( spot->s.origin, spot->s.origin2, BA_H_SPAWN, origin ); + G_CheckSpawnPoint( spot->s.number, spot->s.origin, spot->s.origin2, BA_H_SPAWN, origin ); VectorCopy( spot->s.angles, angles ); angles[ ROLL ] = 0; return spot; - + } @@ -571,18 +573,18 @@ void BodySink( gentity_t *ent ) if( !ent->active ) { ent->active = qtrue; - + //sinking bodies can't be infested ent->killedBy = ent->s.powerups = MAX_CLIENTS; ent->timestamp = level.time; } - + if( level.time - ent->timestamp > 6500 ) { G_FreeEntity( ent ); return; } - + ent->nextthink = level.time + 100; ent->s.pos.trBase[ 2 ] -= 1; } @@ -629,7 +631,7 @@ void SpawnCorpse( gentity_t *ent ) contents = trap_PointContents( origin, -1 ); if( contents & CONTENTS_NODROP ) return; - + body = G_Spawn( ); VectorCopy( ent->s.apos.trBase, body->s.angles ); @@ -639,10 +641,9 @@ void SpawnCorpse( gentity_t *ent ) body->timestamp = level.time; body->s.event = 0; body->r.contents = CONTENTS_CORPSE; - body->clipmask = MASK_DEADSOLID; body->s.clientNum = ent->client->ps.stats[ STAT_PCLASS ]; body->nonSegModel = ent->client->ps.persistant[ PERS_STATE ] & PS_NONSEGMODEL; - + if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) body->classname = "humanCorpse"; else @@ -651,8 +652,8 @@ void SpawnCorpse( gentity_t *ent ) body->s.powerups = MAX_CLIENTS; body->think = BodySink; - body->nextthink = level.time + 60000; - + body->nextthink = level.time + 20000; + body->s.legsAnim = ent->s.legsAnim; if( !body->nonSegModel ) @@ -698,11 +699,11 @@ void SpawnCorpse( gentity_t *ent ) body->health = ent->health = ent->client->ps.stats[ STAT_HEALTH ]; ent->health = 0; - + //change body dimensions BG_FindBBoxForClass( ent->client->ps.stats[ STAT_PCLASS ], NULL, NULL, NULL, body->r.mins, body->r.maxs ); vDiff = body->r.mins[ 2 ] - ent->r.mins[ 2 ]; - + //drop down to match the *model* origins of ent and body VectorSet( dest, origin[ 0 ], origin[ 1 ], origin[ 2 ] - vDiff ); trap_Trace( &tr, origin, body->r.mins, body->r.maxs, dest, body->s.number, body->clipmask ); @@ -713,7 +714,7 @@ void SpawnCorpse( gentity_t *ent ) body->s.pos.trType = TR_GRAVITY; body->s.pos.trTime = level.time; VectorCopy( ent->client->ps.velocity, body->s.pos.trDelta ); - + VectorCopy ( body->s.pos.trBase, body->r.currentOrigin ); trap_LinkEntity( body ); } @@ -739,7 +740,7 @@ void SetClientViewAngle( gentity_t *ent, vec3_t angle ) cmdAngle = ANGLE2SHORT( angle[ i ] ); ent->client->ps.delta_angles[ i ] = cmdAngle - ent->client->pers.cmd.angles[ i ]; } - + VectorCopy( angle, ent->s.angles ); VectorCopy( ent->s.angles, ent->client->ps.viewangles ); } @@ -755,12 +756,6 @@ void respawn( gentity_t *ent ) //TA: Clients can't respawn - they must go thru the class cmd ClientSpawn( ent, NULL, NULL, NULL ); - - //FIXME: need different spawn effects for different teams - - // add a teleportation effect - //tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN ); - //tent->s.clientNum = ent->s.clientNum; } /* @@ -863,7 +858,7 @@ static void ClientCleanName( const char *in, char *out, int outSize ) colorlessLen++; len++; } - + *out = 0; // don't allow empty names @@ -894,7 +889,7 @@ static qboolean G_NonSegModel( const char *filename ) G_Printf( "File not found: %s\n", filename ); return qfalse; } - + if( len <= 0 ) return qfalse; @@ -903,7 +898,7 @@ static qboolean G_NonSegModel( const char *filename ) G_Printf( "File %s too long\n", filename ); return qfalse; } - + trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); @@ -915,7 +910,7 @@ static qboolean G_NonSegModel( const char *filename ) while( 1 ) { token = COM_Parse( &text_p ); - + //EOF if( !token[ 0 ] ) break; @@ -966,13 +961,13 @@ void ClientUserinfoChanged( int clientNum ) // check for local client s = Info_ValueForKey( userinfo, "ip" ); - + if( !strcmp( s, "localhost" ) ) client->pers.localClient = qtrue; // check the item prediction s = Info_ValueForKey( userinfo, "cg_predictItems" ); - + if( !atoi( s ) ) client->pers.predictItemPickup = qfalse; else @@ -1001,7 +996,7 @@ void ClientUserinfoChanged( int clientNum ) // set max health health = atoi( Info_ValueForKey( userinfo, "handicap" ) ); client->pers.maxHealth = health; - + if( client->pers.maxHealth < 1 || client->pers.maxHealth > 100 ) client->pers.maxHealth = 100; @@ -1046,7 +1041,7 @@ void ClientUserinfoChanged( int clientNum ) // wallwalk follow s = Info_ValueForKey( userinfo, "cg_wwFollow" ); - + if( atoi( s ) ) client->ps.persistant[ PERS_STATE ] |= PS_WALLCLIMBINGFOLLOW; else @@ -1054,7 +1049,7 @@ void ClientUserinfoChanged( int clientNum ) // wallwalk toggle s = Info_ValueForKey( userinfo, "cg_wwToggle" ); - + if( atoi( s ) ) client->ps.persistant[ PERS_STATE ] |= PS_WALLCLIMBINGTOGGLE; else @@ -1062,7 +1057,7 @@ void ClientUserinfoChanged( int clientNum ) // teamInfo s = Info_ValueForKey( userinfo, "teamoverlay" ); - + if( ! *s || atoi( s ) != 0 ) client->pers.teamInfo = qtrue; else @@ -1083,7 +1078,7 @@ void ClientUserinfoChanged( int clientNum ) team = PTE_NONE; else team = client->ps.stats[ STAT_PTEAM ]; - + // send over a subset of the userinfo keys so other clients can // print scoreboards, display models, and play custom sounds s = va( "n\\%s\\t\\%i\\model\\%s\\hmodel\\%s\\g_redteam\\%s\\g_blueteam\\%s\\c1\\%s\\c2\\%s\\hc\\%i\\w\\%i\\l\\%i\\tt\\%d\\tl\\%d", @@ -1137,7 +1132,7 @@ char *ClientConnect( int clientNum, qboolean firstTime, qboolean isBot ) // check for a password value = Info_ValueForKey( userinfo, "password" ); - + if( g_password.string[ 0 ] && Q_stricmp( g_password.string, "none" ) && strcmp( g_password.string, value ) != 0 ) return "Invalid password"; @@ -1221,14 +1216,14 @@ void ClientBegin( int clientNum ) tent = G_TempEntity( ent->client->ps.origin, EV_PLAYER_TELEPORT_IN ); tent->s.clientNum = ent->s.clientNum; } - + G_InitCommandQueue( clientNum ); G_SendCommandFromServer( -1, va( "print \"%s" S_COLOR_WHITE " entered the game\n\"", client->pers.netname ) ); // request the clients PTR code G_SendCommandFromServer( ent - g_entities, "ptrcrequest" ); - + G_LogPrintf( "ClientBegin: %i\n", clientNum ); // count current clients and rank for scoreboard @@ -1262,7 +1257,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles vec3_t up = { 0.0f, 0.0f, 1.0f }; int maxAmmo, maxClips; weapon_t weapon; - + index = ent - g_entities; client = ent->client; @@ -1283,10 +1278,10 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles if( origin != NULL ) VectorCopy( origin, spawn_origin ); - + if( angles != NULL ) VectorCopy( angles, spawn_angles ); - + // find a spawn point // do it before setting health back up, so farthest // ranging doesn't count this client @@ -1308,7 +1303,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles } spawnPoint = spawn; - + if( ent != spawn ) { //start spawn animation on spawnPoint @@ -1331,21 +1326,21 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles saved = client->pers; savedSess = client->sess; savedPing = client->ps.ping; - + for( i = 0; i < MAX_PERSISTANT; i++ ) persistant[ i ] = client->ps.persistant[ i ]; - + eventSequence = client->ps.eventSequence; memset( client, 0, sizeof( *client ) ); - + client->pers = saved; client->sess = savedSess; client->ps.ping = savedPing; client->lastkilled_client = -1; - + for( i = 0; i < MAX_PERSISTANT; i++ ) client->ps.persistant[ i ] = persistant[ i ]; - + client->ps.eventSequence = eventSequence; // increment the spawncount so the client will detect the respawn @@ -1380,7 +1375,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles client->ps.eFlags = flags; client->ps.clientNum = index; - + BG_FindBBoxForClass( ent->client->pers.classSelection, ent->r.mins, ent->r.maxs, NULL, NULL, NULL ); if( client->sess.sessionTeam != TEAM_SPECTATOR ) @@ -1400,21 +1395,21 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles weapon = BG_FindStartWeaponForClass( ent->client->pers.classSelection ); else weapon = WP_NONE; - + BG_FindAmmoForWeapon( weapon, &maxAmmo, &maxClips ); BG_AddWeaponToInventory( weapon, client->ps.stats ); BG_PackAmmoArray( weapon, client->ps.ammo, client->ps.powerups, maxAmmo, maxClips ); ent->client->ps.stats[ STAT_PCLASS ] = ent->client->pers.classSelection; ent->client->ps.stats[ STAT_PTEAM ] = ent->client->pers.teamSelection; - + ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; ent->client->ps.stats[ STAT_STATE ] = 0; VectorSet( ent->client->ps.grapplePoint, 0.0f, 0.0f, 1.0f ); // health will count down towards max_health ent->health = client->ps.stats[ STAT_HEALTH ] = client->ps.stats[ STAT_MAX_HEALTH ]; //* 1.25; - + //if evolving scale health if( ent == spawn ) { @@ -1425,9 +1420,9 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles //clear the credits array for( i = 0; i < MAX_CLIENTS; i++ ) ent->credits[ i ] = 0; - + client->ps.stats[ STAT_STAMINA ] = MAX_STAMINA; - + G_SetOrigin( ent, spawn_origin ); VectorCopy( spawn_origin, client->ps.origin ); @@ -1447,11 +1442,11 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles { spawn_angles[ YAW ] += 180.0f; AngleNormalize360( spawn_angles[ YAW ] ); - + if( spawnPoint->s.origin2[ 2 ] > 0.0f ) { vec3_t forward, dir; - + AngleVectors( spawn_angles, forward, NULL, NULL ); VectorScale( forward, F_VEL, forward ); VectorAdd( spawnPoint->s.origin2, forward, dir ); @@ -1459,7 +1454,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles VectorScale( dir, UP_VEL, client->ps.velocity ); } - + G_AddPredictableEvent( ent, EV_PLAYER_RESPAWN, 0 ); } } @@ -1511,7 +1506,7 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles // select the highest weapon number available, after any // spawn given items have fired client->ps.weapon = 1; - + for( i = WP_NUM_WEAPONS - 1; i > 0 ; i-- ) { if( BG_InventoryContainsWeapon( i, client->ps.stats ) ) @@ -1566,7 +1561,7 @@ void ClientDisconnect( int clientNum ) int i; ent = g_entities + clientNum; - + if( !ent->client ) return; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 5a6e516e..606d1875 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -13,7 +13,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "g_local.h" /* @@ -32,13 +32,13 @@ void G_SanitiseName( char *in, char *out ) in += 2; // skip color code continue; } - + if( *in < 32 ) { in++; continue; } - + *out++ = tolower( *in++ ); } @@ -64,7 +64,7 @@ int G_ClientNumberFromString( gentity_t *to, char *s ) if( s[ 0 ] >= '0' && s[ 0 ] <= '9' ) { idnum = atoi( s ); - + if( idnum < 0 || idnum >= level.maxclients ) { G_SendCommandFromServer( to - g_entities, va( "print \"Bad client slot: %i\n\"", idnum ) ); @@ -72,26 +72,26 @@ int G_ClientNumberFromString( gentity_t *to, char *s ) } cl = &level.clients[ idnum ]; - + if( cl->pers.connected != CON_CONNECTED ) { G_SendCommandFromServer( to - g_entities, va( "print \"Client %i is not active\n\"", idnum ) ); return -1; } - + return idnum; } // check for a name match G_SanitiseName( s, s2 ); - + for( idnum = 0, cl = level.clients; idnum < level.maxclients; idnum++, cl++ ) { if( cl->pers.connected != CON_CONNECTED ) continue; - + G_SanitiseName( cl->pers.netname, n2 ); - + if( !strcmp( n2, s2 ) ) return idnum; } @@ -137,7 +137,7 @@ void ScoreboardMessage( gentity_t *ent ) if( cl->ps.stats[ STAT_HEALTH ] > 0 ) { weapon = cl->ps.weapon; - + if( BG_InventoryContainsUpgrade( UP_BATTLESUIT, cl->ps.stats ) ) upgrade = UP_BATTLESUIT; else if( BG_InventoryContainsUpgrade( UP_JETPACK, cl->ps.stats ) ) @@ -156,16 +156,16 @@ void ScoreboardMessage( gentity_t *ent ) weapon = WP_NONE; upgrade = UP_NONE; } - + Com_sprintf( entry, sizeof( entry ), " %d %d %d %d %d %d", level.sortedClients[ i ], cl->ps.persistant[ PERS_SCORE ], ping, ( level.time - cl->pers.enterTime ) / 60000, weapon, upgrade ); - + j = strlen( entry ); - + if( stringlength + j > 1024 ) break; - + strcpy( string + stringlength, entry ); stringlength += j; } @@ -201,11 +201,11 @@ qboolean CheatsOk( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, va( "print \"Cheats are not enabled on this server\n\"" ) ); return qfalse; } - + if( ent->health <= 0 ) { G_SendCommandFromServer( ent-g_entities, va( "print \"You must be alive to use this command\n\"" ) ); - return qfalse; + return qfalse; } return qtrue; @@ -226,18 +226,18 @@ char *ConcatArgs( int start ) len = 0; c = trap_Argc( ); - + for( i = start; i < c; i++ ) { trap_Argv( i, arg, sizeof( arg ) ); tlen = strlen( arg ); - + if( len + tlen >= MAX_STRING_CHARS - 1 ) break; memcpy( line + len, arg, tlen ); len += tlen; - + if( i != c - 1 ) { line[ len ] = ' '; @@ -312,7 +312,7 @@ void Cmd_God_f( gentity_t *ent ) return; ent->flags ^= FL_GODMODE; - + if( !( ent->flags & FL_GODMODE ) ) msg = "godmode OFF\n"; else @@ -339,7 +339,7 @@ void Cmd_Notarget_f( gentity_t *ent ) return; ent->flags ^= FL_NOTARGET; - + if( !( ent->flags & FL_NOTARGET ) ) msg = "notarget OFF\n"; else @@ -405,16 +405,16 @@ void Cmd_Kill_f( gentity_t *ent ) if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_NONE ) return; - + if( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING ) return; - + if( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) { G_SendCommandFromServer( ent-g_entities, "print \"Leave the hovel first (use your destroy key)\n\"" ); return; } - + if( ent->health <= 0 ) return; @@ -457,13 +457,13 @@ void G_ChangeTeam( gentity_t *ent, pTeam_t newTeam ) G_RemoveFromSpawnQueue( &level.alienSpawnQueue, ent->client->ps.clientNum ); else if( oldTeam == PTE_HUMANS ) G_RemoveFromSpawnQueue( &level.humanSpawnQueue, ent->client->ps.clientNum ); - + level.bankCredits[ ent->client->ps.clientNum ] = 0; ent->client->ps.persistant[ PERS_CREDIT ] = 0; ent->client->pers.classSelection = PCL_NONE; ClientSpawn( ent, NULL, NULL, NULL ); } - + ent->client->pers.joinedATeam = qtrue; //update ClientInfo @@ -497,7 +497,7 @@ void Cmd_Team_f( gentity_t *ent ) G_TriggerMenu( ent->client->ps.clientNum, MN_A_TEAMFULL ); return; } - + team = PTE_ALIENS; } else if( !Q_stricmp( s, "humans" ) ) @@ -507,7 +507,7 @@ void Cmd_Team_f( gentity_t *ent ) G_TriggerMenu( ent->client->ps.clientNum, MN_H_TEAMFULL ); return; } - + team = PTE_HUMANS; } else if( !Q_stricmp( s, "auto" ) ) @@ -526,7 +526,7 @@ void Cmd_Team_f( gentity_t *ent ) } G_ChangeTeam( ent, team ); - + if( team == PTE_ALIENS ) G_SendCommandFromServer( -1, va( "print \"%s" S_COLOR_WHITE " joined the aliens\n\"", ent->client->pers.netname ) ); else if( team == PTE_HUMANS ) @@ -543,13 +543,13 @@ static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, cons { if( !other ) return; - + if( !other->inuse ) return; - + if( !other->client ) return; - + if( other->client->pers.connected != CON_CONNECTED ) return; @@ -582,20 +582,20 @@ void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) Q_COLOR_ESCAPE, COLOR_WHITE ); color = COLOR_GREEN; break; - + case SAY_TEAM: G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText ); if( Team_GetLocationMsg( ent, location, sizeof( location ) ) ) - Com_sprintf( name, sizeof( name ), EC"(%s%c%c"EC") (%s)"EC": ", + Com_sprintf( name, sizeof( name ), EC"(%s%c%c"EC") (%s)"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location ); else - Com_sprintf( name, sizeof( name ), EC"(%s%c%c"EC")"EC": ", + Com_sprintf( name, sizeof( name ), EC"(%s%c%c"EC")"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE ); color = COLOR_CYAN; break; - + case SAY_TELL: - if( target && + if( target && target->client->ps.stats[ STAT_PTEAM ] == ent->client->ps.stats[ STAT_PTEAM ] && Team_GetLocationMsg( ent, location, sizeof( location ) ) ) Com_sprintf( name, sizeof( name ), EC"[%s%c%c"EC"] (%s)"EC": ", @@ -665,7 +665,7 @@ static void Cmd_Tell_f( gentity_t *ent ) trap_Argv( 1, arg, sizeof( arg ) ); targetNum = atoi( arg ); - + if( targetNum < 0 || targetNum >= level.maxclients ) return; @@ -715,13 +715,13 @@ void Cmd_CallVote_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, "print \"A vote is already in progress\n\"" ); return; } - + if( ent->client->pers.voteCount >= MAX_VOTE_COUNT ) { G_SendCommandFromServer( ent-g_entities, "print \"You have called the maximum number of votes\n\"" ); return; } - + if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_NONE ) { G_SendCommandFromServer( ent-g_entities, "print \"Not allowed to call a vote as spectator\n\"" ); @@ -767,7 +767,7 @@ void Cmd_CallVote_f( gentity_t *ent ) char s[ MAX_STRING_CHARS ]; trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof( s ) ); - + if( *s ) Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s; set nextmap \"%s\"", arg1, arg2, s ); else @@ -780,13 +780,13 @@ void Cmd_CallVote_f( gentity_t *ent ) char s[ MAX_STRING_CHARS ]; trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof( s ) ); - + if( !*s ) { G_SendCommandFromServer( ent-g_entities, "print \"nextmap not set\n\"" ); return; } - + Com_sprintf( level.voteString, sizeof( level.voteString ), "vstr nextmap" ); Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString ); } @@ -828,7 +828,7 @@ void Cmd_Vote_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, "print \"No vote in progress\n\"" ); return; } - + if( ent->client->ps.eFlags & EF_VOTED ) { G_SendCommandFromServer( ent-g_entities, "print \"Vote already cast\n\"" ); @@ -874,7 +874,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) char arg2[ MAX_STRING_TOKENS ]; team = ent->client->ps.stats[ STAT_PTEAM ]; - + if( team == PTE_HUMANS ) cs_offset = 0; else if( team == PTE_ALIENS ) @@ -893,13 +893,13 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, "print \"A team vote is already in progress\n\"" ); return; } - + if( ent->client->pers.teamVoteCount >= MAX_VOTE_COUNT ) { G_SendCommandFromServer( ent-g_entities, "print \"You have called the maximum number of team votes\n\"" ); return; } - + if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_NONE ) { G_SendCommandFromServer( ent-g_entities, "print \"Not allowed to call a vote as spectator\n\"" ); @@ -909,7 +909,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) // make sure it is a valid command to vote on trap_Argv( 1, arg1, sizeof( arg1 ) ); trap_Argv( 2, arg2, sizeof( arg2 ) ); - + if( strchr( arg1, ';' ) || strchr( arg2, ';' ) ) { G_SendCommandFromServer( ent-g_entities, "print \"Invalid team vote string\n\"" ); @@ -922,22 +922,22 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) Q_strncpyz( kickee, arg2, sizeof( kickee ) ); Q_CleanStr( kickee ); - + for( i = 0; i < level.maxclients; i++ ) { if( level.clients[ i ].pers.connected == CON_DISCONNECTED ) continue; - + if( level.clients[ i ].ps.stats[ STAT_PTEAM ] != team ) continue; - + Q_strncpyz( netname, level.clients[ i ].pers.netname, sizeof( netname ) ); Q_CleanStr( netname ); - + if( !Q_stricmp( netname, kickee ) ) break; } - + if( i >= level.maxclients ) { G_SendCommandFromServer( ent-g_entities, va( "print \"%s is not a valid player on your team\n\"", arg2 ) ); @@ -958,7 +958,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) { if( level.clients[ i ].pers.connected == CON_DISCONNECTED ) continue; - + if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team ) G_SendCommandFromServer( i, va("print \"%s called a team vote\n\"", ent->client->pers.netname ) ); } @@ -973,7 +973,7 @@ void Cmd_CallTeamVote_f( gentity_t *ent ) if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == team ) level.clients[ i ].ps.eFlags &= ~EF_TEAMVOTED; } - + ent->client->ps.eFlags |= EF_TEAMVOTED; trap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, va( "%i", level.teamVoteTime[ cs_offset ] ) ); @@ -1006,13 +1006,13 @@ void Cmd_TeamVote_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, "print \"No team vote in progress\n\"" ); return; } - + if( ent->client->ps.eFlags & EF_TEAMVOTED ) { G_SendCommandFromServer( ent-g_entities, "print \"Team vote already cast\n\"" ); return; } - + if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_NONE ) { G_SendCommandFromServer( ent-g_entities, "print \"Not allowed to vote as spectator\n\"" ); @@ -1033,7 +1033,7 @@ void Cmd_TeamVote_f( gentity_t *ent ) else { level.teamVoteNo[ cs_offset ]++; - trap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va( "%i", level.teamVoteNo[ cs_offset ] ) ); + trap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va( "%i", level.teamVoteNo[ cs_offset ] ) ); } // a majority will be determined in TeamCheckVote, which will also account @@ -1057,7 +1057,7 @@ void Cmd_SetViewpos_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, va( "print \"Cheats are not enabled on this server\n\"" ) ); return; } - + if( trap_Argc( ) != 5 ) { G_SendCommandFromServer( ent-g_entities, va( "print \"usage: setviewpos x y z yaw\n\"" ) ); @@ -1065,7 +1065,7 @@ void Cmd_SetViewpos_f( gentity_t *ent ) } VectorClear( angles ); - + for( i = 0 ; i < 3 ; i++ ) { trap_Argv( i + 1, buffer, sizeof( buffer ) ); @@ -1095,8 +1095,8 @@ void Cmd_Class_f( gentity_t *ent ) vec3_t infestOrigin; int allowedClasses[ PCL_NUM_CLASSES ]; int numClasses = 0; - pClass_t currentClass = ent->client->ps.stats[ STAT_PCLASS ]; - + pClass_t currentClass = ent->client->ps.stats[ STAT_PCLASS ]; + int numLevels; vec3_t fromMins, fromMaxs, toMins, toMaxs; vec3_t temp; @@ -1106,10 +1106,10 @@ void Cmd_Class_f( gentity_t *ent ) vec3_t mins, maxs; int num; gentity_t *other; - + if( ent->client->ps.stats[ STAT_HEALTH ] <= 0 ) return; - + clientNum = ent->client - level.clients; trap_Argv( 1, s, sizeof( s ) ); @@ -1126,7 +1126,7 @@ void Cmd_Class_f( gentity_t *ent ) allowedClasses[ 1 ] = PCL_ALIEN_LEVEL0; numClasses = 2; } - + if( ent->client->pers.teamSelection == PTE_ALIENS && !( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING ) && !( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) && @@ -1139,12 +1139,12 @@ void Cmd_Class_f( gentity_t *ent ) //check there are no humans nearby VectorAdd( ent->client->ps.origin, range, maxs ); VectorSubtract( ent->client->ps.origin, range, mins ); - + num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { other = &g_entities[ entityList[ i ] ]; - + if( ( other->client && other->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) || ( other->s.eType == ET_BUILDABLE && other->biteam == BIT_HUMANS ) ) { @@ -1160,7 +1160,7 @@ void Cmd_Class_f( gentity_t *ent ) G_TriggerMenu( clientNum, MN_A_NOOVMND_EVOLVE ); return; } - + //guard against selling the HBUILD weapons exploit if( ( currentClass == PCL_ALIEN_BUILDER0 || currentClass == PCL_ALIEN_BUILDER0_UPG ) && @@ -1169,7 +1169,7 @@ void Cmd_Class_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, va( "print \"Cannot evolve until build timer expires\n\"" ) ); return; } - + //evolve now ent->client->pers.classSelection = BG_FindClassNumForName( s ); @@ -1178,7 +1178,7 @@ void Cmd_Class_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, va( "print \"Unknown class\n\"" ) ); return; } - + numLevels = BG_ClassCanEvolveFromTo( currentClass, ent->client->pers.classSelection, (short)ent->client->ps.persistant[ PERS_CREDIT ], 0 ); @@ -1189,7 +1189,7 @@ void Cmd_Class_f( gentity_t *ent ) toMins, toMaxs, NULL, NULL, NULL ); VectorCopy( ent->s.pos.trBase, infestOrigin ); - + infestOrigin[ 2 ] += ( fabs( toMins[ 2 ] ) - fabs( fromMins[ 2 ] ) ) + 1.0f; VectorCopy( infestOrigin, temp ); temp[ 2 ] += EVOLVE_TRACE_HEIGHT; @@ -1198,14 +1198,14 @@ void Cmd_Class_f( gentity_t *ent ) trap_Trace( &tr, infestOrigin, toMins, toMaxs, temp, ent->s.number, MASK_SHOT ); VectorCopy( infestOrigin, temp ); temp[ 2 ] += ( EVOLVE_TRACE_HEIGHT * tr.fraction ) - 1.0f; - + //trace down to the ground so that we can evolve on slopes trap_Trace( &tr, temp, toMins, toMaxs, infestOrigin, ent->s.number, MASK_SHOT ); VectorCopy( tr.endpos, infestOrigin ); - + //make REALLY sure trap_Trace( &tr2, ent->s.pos.trBase, NULL, NULL, infestOrigin, ent->s.number, MASK_SHOT ); - + //check there is room to evolve if( !tr.startsolid && tr2.fraction == 1.0f ) { @@ -1219,10 +1219,10 @@ void Cmd_Class_f( gentity_t *ent ) ent->client->pers.evolveHealthFraction = 0.0f; else if( ent->client->pers.evolveHealthFraction > 1.0f ) ent->client->pers.evolveHealthFraction = 1.0f; - + //remove credit G_AddCreditToClient( ent->client, -(short)numLevels, qtrue ); - + ClientUserinfoChanged( clientNum ); VectorCopy( infestOrigin, ent->s.pos.trBase ); ClientSpawn( ent, ent, ent->s.pos.trBase, ent->s.apos.trBase ); @@ -1324,7 +1324,7 @@ void Cmd_Destroy_f( gentity_t *ent, qboolean deconstruct ) if( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) G_Damage( ent->client->hovel, ent, ent, forward, ent->s.origin, 10000, 0, MOD_SUICIDE ); - + if( !( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING ) ) { AngleVectors( ent->client->ps.viewangles, forward, NULL, NULL ); @@ -1349,7 +1349,7 @@ void Cmd_Destroy_f( gentity_t *ent, qboolean deconstruct ) G_Damage( traceEnt, ent, ent, forward, tr.endpos, 10000, 0, MOD_SUICIDE ); else G_FreeEntity( traceEnt ); - + ent->client->ps.stats[ STAT_MISC ] += BG_FindBuildDelayForWeapon( ent->s.weapon ) >> 2; } @@ -1375,7 +1375,7 @@ void Cmd_ActivateItem_f( gentity_t *ent ) if( ent->client->pers.teamSelection != PTE_HUMANS ) return; - + if( upgrade != UP_NONE && BG_InventoryContainsUpgrade( upgrade, ent->client->ps.stats ) ) BG_ActivateUpgrade( upgrade, ent->client->ps.stats ); else if( weapon != WP_NONE && BG_InventoryContainsWeapon( weapon, ent->client->ps.stats ) ) @@ -1402,7 +1402,7 @@ void Cmd_DeActivateItem_f( gentity_t *ent ) if( ent->client->pers.teamSelection != PTE_HUMANS ) return; - + if( BG_InventoryContainsUpgrade( upgrade, ent->client->ps.stats ) ) BG_DeactivateUpgrade( upgrade, ent->client->ps.stats ); else @@ -1452,7 +1452,7 @@ void Cmd_ToggleItem_f( gentity_t *ent ) if( i == WP_NUM_WEAPONS ) weapon = WP_BLASTER; } - + G_ForceWeaponChange( ent, weapon ); } else if( BG_InventoryContainsUpgrade( upgrade, ent->client->ps.stats ) ) @@ -1492,14 +1492,14 @@ void Cmd_Buy_f( gentity_t *ent ) } trap_Argv( 1, s, sizeof( s ) ); - + //aliens don't buy stuff if( ent->client->pers.teamSelection != PTE_HUMANS ) return; weapon = BG_FindWeaponNumForName( s ); upgrade = BG_FindUpgradeNumForName( s ); - + //special case to keep norf happy if( weapon == WP_NONE && upgrade == UP_AMMO ) { @@ -1526,50 +1526,50 @@ void Cmd_Buy_f( gentity_t *ent ) G_TriggerMenu( ent->client->ps.clientNum, MN_H_ITEMHELD ); return; } - + //can afford this? if( BG_FindPriceForWeapon( weapon ) > (short)ent->client->ps.persistant[ PERS_CREDIT ] ) { G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); return; } - + //have space to carry this? if( BG_FindSlotsForWeapon( weapon ) & ent->client->ps.stats[ STAT_SLOTS ] ) { G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOSLOTS ); return; } - + if( BG_FindTeamForWeapon( weapon ) != WUT_HUMANS ) { //shouldn't need a fancy dialog G_SendCommandFromServer( ent-g_entities, va( "print \"You can't buy alien items\n\"" ) ); return; } - + //are we /allowed/ to buy this? if( !BG_FindPurchasableForWeapon( weapon ) ) { G_SendCommandFromServer( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); return; } - + //are we /allowed/ to buy this? if( !BG_FindStagesForWeapon( weapon, g_humanStage.integer ) ) { G_SendCommandFromServer( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); return; } - + //add to inventory BG_AddWeaponToInventory( weapon, ent->client->ps.stats ); BG_FindAmmoForWeapon( weapon, &maxAmmo, &maxClips ); - + if( BG_FindUsesEnergyForWeapon( weapon ) && BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) ) maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER ); - + BG_PackAmmoArray( weapon, ent->client->ps.ammo, ent->client->ps.powerups, maxAmmo, maxClips ); @@ -1577,7 +1577,7 @@ void Cmd_Buy_f( gentity_t *ent ) //set build delay/pounce etc to 0 ent->client->ps.stats[ STAT_MISC ] = 0; - + //subtract from funds G_AddCreditToClient( ent->client, -(short)BG_FindPriceForWeapon( weapon ), qfalse ); } @@ -1589,42 +1589,42 @@ void Cmd_Buy_f( gentity_t *ent ) G_TriggerMenu( ent->client->ps.clientNum, MN_H_ITEMHELD ); return; } - + //can afford this? if( BG_FindPriceForUpgrade( upgrade ) > (short)ent->client->ps.persistant[ PERS_CREDIT ] ) { G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOFUNDS ); return; } - + //have space to carry this? if( BG_FindSlotsForUpgrade( upgrade ) & ent->client->ps.stats[ STAT_SLOTS ] ) { G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOSLOTS ); return; } - + if( BG_FindTeamForUpgrade( upgrade ) != WUT_HUMANS ) { //shouldn't need a fancy dialog G_SendCommandFromServer( ent-g_entities, va( "print \"You can't buy alien items\n\"" ) ); return; } - + //are we /allowed/ to buy this? if( !BG_FindPurchasableForUpgrade( upgrade ) ) { G_SendCommandFromServer( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); return; } - + //are we /allowed/ to buy this? if( !BG_FindStagesForUpgrade( upgrade, g_humanStage.integer ) ) { G_SendCommandFromServer( ent-g_entities, va( "print \"You can't buy this item\n\"" ) ); return; } - + if( upgrade == UP_AMMO ) G_GiveClientMaxAmmo( ent, buyingEnergyAmmo ); else @@ -1632,7 +1632,7 @@ void Cmd_Buy_f( gentity_t *ent ) //add to inventory BG_AddUpgradeToInventory( upgrade, ent->client->ps.stats ); } - + if( upgrade == UP_BATTPACK ) G_GiveClientMaxAmmo( ent, qtrue ); @@ -1643,16 +1643,16 @@ void Cmd_Buy_f( gentity_t *ent ) { G_SendCommandFromServer( ent-g_entities, va( "print \"Unknown item\n\"" ) ); } - + if( trap_Argc( ) >= 2 ) { trap_Argv( 2, s, sizeof( s ) ); - + //retrigger the armoury menu if( !Q_stricmp( s, "retrigger" ) ) ent->client->retriggerArmouryMenu = level.framenum + RAM_FRAMES; } - + //update ClientInfo ClientUserinfoChanged( ent->client->ps.clientNum ); } @@ -1684,7 +1684,7 @@ void Cmd_Sell_f( gentity_t *ent ) weapon = BG_FindWeaponNumForName( s ); upgrade = BG_FindUpgradeNumForName( s ); - + if( weapon != WP_NONE ) { //are we /allowed/ to sell this? @@ -1693,7 +1693,7 @@ void Cmd_Sell_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, va( "print \"You can't sell this weapon\n\"" ) ); return; } - + //remove weapon if carried if( BG_InventoryContainsWeapon( weapon, ent->client->ps.stats ) ) { @@ -1704,7 +1704,7 @@ void Cmd_Sell_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, va( "print \"Cannot sell until build timer expires\n\"" ) ); return; } - + BG_RemoveWeaponFromInventory( weapon, ent->client->ps.stats ); //add to funds @@ -1730,7 +1730,7 @@ void Cmd_Sell_f( gentity_t *ent ) if( upgrade == UP_BATTPACK ) G_GiveClientMaxAmmo( ent, qtrue ); - + //add to funds G_AddCreditToClient( ent->client, (short)BG_FindPriceForUpgrade( upgrade ), qfalse ); } @@ -1746,7 +1746,7 @@ void Cmd_Sell_f( gentity_t *ent ) G_SendCommandFromServer( ent-g_entities, va( "print \"Cannot sell until build timer expires\n\"" ) ); continue; } - + if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) && BG_FindPurchasableForWeapon( i ) ) { @@ -1755,7 +1755,7 @@ void Cmd_Sell_f( gentity_t *ent ) //add to funds G_AddCreditToClient( ent->client, (short)BG_FindPriceForWeapon( i ), qfalse ); } - + //if we have this weapon selected, force a new selection if( i == ent->client->ps.weapon ) G_ForceWeaponChange( ent, WP_NONE ); @@ -1774,7 +1774,7 @@ void Cmd_Sell_f( gentity_t *ent ) if( i == UP_BATTPACK ) { int j; - + //remove energy for( j = WP_NONE; j < WP_NUM_WEAPONS; j++ ) { @@ -1786,7 +1786,7 @@ void Cmd_Sell_f( gentity_t *ent ) } } } - + //add to funds G_AddCreditToClient( ent->client, (short)BG_FindPriceForUpgrade( i ), qfalse ); } @@ -1794,16 +1794,16 @@ void Cmd_Sell_f( gentity_t *ent ) } else G_SendCommandFromServer( ent-g_entities, va( "print \"Unknown item\n\"" ) ); - + if( trap_Argc( ) >= 2 ) { trap_Argv( 2, s, sizeof( s ) ); - + //retrigger the armoury menu if( !Q_stricmp( s, "retrigger" ) ) ent->client->retriggerArmouryMenu = level.framenum + RAM_FRAMES; } - + //update ClientInfo ClientUserinfoChanged( ent->client->ps.clientNum ); } @@ -1826,7 +1826,7 @@ void Cmd_Build_f( gentity_t *ent ) buildable = BG_FindBuildNumForName( s ); team = ent->client->ps.stats[ STAT_PTEAM ]; - + if( buildable != BA_NONE && ( ( 1 << ent->client->ps.weapon ) & BG_FindBuildWeaponForBuildable( buildable ) ) && !( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING ) && @@ -1835,7 +1835,7 @@ void Cmd_Build_f( gentity_t *ent ) ( team == PTE_HUMANS && BG_FindStagesForBuildable( buildable, g_humanStage.integer ) ) ) ) { dist = BG_FindBuildDistForClass( ent->client->ps.stats[ STAT_PCLASS ] ); - + //these are the errors displayed when the builder first selects something to use switch( G_itemFits( ent, buildable, dist, origin ) ) { @@ -1873,11 +1873,11 @@ void Cmd_Build_f( gentity_t *ent ) case IBE_NOPOWER: G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOPOWER ); break; - + case IBE_NOCREEP: G_TriggerMenu( ent->client->ps.clientNum, MN_A_NOCREEP ); break; - + case IBE_NODCC: G_TriggerMenu( ent->client->ps.clientNum, MN_H_NODCC ); break; @@ -1904,7 +1904,7 @@ void Cmd_Boost_f( gentity_t *ent ) if( ent->client->pers.cmd.buttons & BUTTON_WALKING ) return; - + if( ( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) && ( ent->client->ps.stats[ STAT_STAMINA ] > 0 ) ) ent->client->ps.stats[ STAT_STATE ] |= SS_SPEEDBOOST; @@ -1930,8 +1930,8 @@ to free floating spectator mode */ void G_StopFollowing( gentity_t *ent ) { - ent->client->ps.persistant[ PERS_TEAM ] = TEAM_SPECTATOR; - ent->client->sess.sessionTeam = TEAM_SPECTATOR; + ent->client->ps.persistant[ PERS_TEAM ] = TEAM_SPECTATOR; + ent->client->sess.sessionTeam = TEAM_SPECTATOR; ent->client->sess.spectatorState = SPECTATOR_FREE; ent->client->sess.spectatorClient = -1; ent->client->ps.pm_flags &= ~PMF_FOLLOW; @@ -1960,7 +1960,7 @@ qboolean G_FollowNewClient( gentity_t *ent, int dir ) int clientnum = ent->client->sess.spectatorClient; int original = clientnum; qboolean selectAny = qfalse; - + if( dir > 1 ) dir = 1; else if( dir < -1 ) @@ -1977,21 +1977,21 @@ qboolean G_FollowNewClient( gentity_t *ent, int dir ) clientnum = original = 0; selectAny = qtrue; } - + do { clientnum += dir; - + if( clientnum >= level.maxclients ) clientnum = 0; - + if( clientnum < 0 ) clientnum = level.maxclients - 1; // avoid selecting existing follow target if( clientnum == original && !selectAny ) continue; //effectively break; - + // can't follow self if( &level.clients[ clientnum ] == ent->client ) continue; @@ -2008,7 +2008,7 @@ qboolean G_FollowNewClient( gentity_t *ent, int dir ) ent->client->sess.spectatorClient = clientnum; ent->client->sess.spectatorState = SPECTATOR_FOLLOW; return qtrue; - + } while( clientnum != original ); return qfalse; @@ -2035,7 +2035,7 @@ void Cmd_Follow_f( gentity_t *ent, qboolean toggle ) { trap_Argv( 1, arg, sizeof( arg ) ); i = G_ClientNumberFromString( ent, arg ); - + if( i == -1 ) return; @@ -2096,7 +2096,7 @@ void Cmd_PTRCVerify_f( gentity_t *ent ) if( G_VerifyPTRC( code ) ) { connection = G_FindConnectionForCode( code ); - + // valid code if( connection->clientTeam != PTE_NONE ) G_SendCommandFromServer( ent->client->ps.clientNum, "ptrcconfirm" ); @@ -2108,7 +2108,7 @@ void Cmd_PTRCVerify_f( gentity_t *ent ) { // invalid code -- generate a new one connection = G_GenerateNewConnection( ent->client ); - + if( connection ) { G_SendCommandFromServer( ent->client->ps.clientNum, @@ -2153,7 +2153,7 @@ void Cmd_PTRCRestore_f( gentity_t *ent ) { // set the correct team G_ChangeTeam( ent, connection->clientTeam ); - + // set the correct credit ent->client->ps.persistant[ PERS_CREDIT ] = 0; G_AddCreditToClient( ent->client, connection->clientCredit, qtrue ); @@ -2181,7 +2181,7 @@ void Cmd_Test_f( gentity_t *ent ) ent->client->lastPoisonCloudedTime = level.time; ent->client->lastPoisonCloudedClient = ent; G_SendCommandFromServer( ent->client->ps.clientNum, "poisoncloud" );*/ - + /* ent->client->ps.stats[ STAT_STATE ] |= SS_POISONED; ent->client->lastPoisonTime = level.time; ent->client->lastPoisonClient = ent;*/ @@ -2209,19 +2209,19 @@ void ClientCommand( int clientNum ) Cmd_Say_f( ent, SAY_ALL, qfalse ); return; } - + if( Q_stricmp( cmd, "say_team" ) == 0 ) { Cmd_Say_f( ent, SAY_TEAM, qfalse ); return; } - + if( Q_stricmp( cmd, "tell" ) == 0 ) { Cmd_Tell_f( ent ); return; } - + if( Q_stricmp( cmd, "score" ) == 0 ) { Cmd_Score_f( ent ); @@ -2276,12 +2276,12 @@ void ClientCommand( int clientNum ) Cmd_Vote_f( ent ); else if( Q_stricmp( cmd, "callteamvote" ) == 0 ) Cmd_CallTeamVote_f( ent ); - else if( Q_stricmp( cmd, "follow" ) == 0 ) - Cmd_Follow_f( ent, qfalse ); - else if( Q_stricmp (cmd, "follownext") == 0) - Cmd_FollowCycle_f( ent, 1 ); - else if( Q_stricmp( cmd, "followprev" ) == 0 ) - Cmd_FollowCycle_f( ent, -1 ); + else if( Q_stricmp( cmd, "follow" ) == 0 ) + Cmd_Follow_f( ent, qfalse ); + else if( Q_stricmp (cmd, "follownext") == 0) + Cmd_FollowCycle_f( ent, 1 ); + else if( Q_stricmp( cmd, "followprev" ) == 0 ) + Cmd_FollowCycle_f( ent, -1 ); else if( Q_stricmp( cmd, "teamvote" ) == 0 ) Cmd_TeamVote_f( ent ); else if( Q_stricmp( cmd, "setviewpos" ) == 0 ) diff --git a/src/game/g_combat.c b/src/game/g_combat.c index 29032050..fb822c3c 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -137,7 +137,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int char *killerName, *obit; float totalDamage = 0.0f; gentity_t *player; - + if( self->client->ps.pm_type == PM_DEAD ) return; @@ -163,7 +163,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int if( attacker ) { killer = attacker->s.number; - + if( attacker->client ) killerName = attacker->client->pers.netname; else @@ -211,11 +211,11 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int if( attacker && attacker->client ) { attacker->client->lastkilled_client = self->s.number; - + if( attacker == self || OnSameTeam( self, attacker ) ) { AddScore( attacker, -1 ); - + //punish team kills and suicides if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) G_AddCreditToClient( attacker->client, -1, qtrue ); @@ -235,7 +235,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int //total up all the damage done by every client for( i = 0; i < MAX_CLIENTS; i++ ) totalDamage += (float)self->credits[ i ]; - + // if players did more than DAMAGE_FRACTION_FOR_KILL increment the stage counters if( totalDamage >= ( self->client->ps.stats[ STAT_MAX_HEALTH ] * DAMAGE_FRACTION_FOR_KILL ) ) { @@ -244,27 +244,27 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int else if( self->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) trap_Cvar_Set( "g_humanKills", va( "%d", g_humanKills.integer + 1 ) ); } - + if( totalDamage > 0.0f ) { if( self->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { //nice simple happy bouncy human land float classValue = BG_FindValueOfClass( self->client->ps.stats[ STAT_PCLASS ] ); - + for( i = 0; i < MAX_CLIENTS; i++ ) { player = g_entities + i; if( !player->client ) continue; - + if( player->client->ps.stats[ STAT_PTEAM ] != PTE_HUMANS ) continue; if( !self->credits[ i ] ) continue; - + //add credit G_AddCreditToClient( player->client, (int)( classValue * ( (float)self->credits[ i ] / totalDamage ) ), qtrue ); @@ -276,27 +276,27 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int float humanValue = BG_GetValueOfHuman( &self->client->ps ); int frags; int unclaimedFrags = (int)humanValue; - + for( i = 0; i < MAX_CLIENTS; i++ ) { player = g_entities + i; if( !player->client ) continue; - + if( player->client->ps.stats[ STAT_PTEAM ] != PTE_ALIENS ) continue; - + //this client did no damage if( !self->credits[ i ] ) continue; - + //nothing left to claim if( !unclaimedFrags ) break; - + frags = (int)floor( humanValue * ( (float)self->credits[ i ] / totalDamage ) ); - + if( frags > 0 ) { //add kills @@ -317,12 +317,12 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int //have enough credit to claim even one frag //so simply give the top <unclaimedFrags> clients //a frag each - + for( i = 0; i < unclaimedFrags; i++ ) { int maximum = 0; int topClient = 0; - + for( j = 0; j < MAX_CLIENTS; j++ ) { //this client did no damage @@ -339,7 +339,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int if( maximum > 0 ) { player = g_entities + topClient; - + //add kills G_AddCreditToClient( player->client, 1, qtrue ); @@ -350,9 +350,9 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int } } } - + Cmd_Score_f( self ); // show scores - + // send updated scores to any clients that are following this one, // or they would get stale scoreboards for( i = 0 ; i < level.maxclients ; i++ ) @@ -362,10 +362,10 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int client = &level.clients[ i ]; if( client->pers.connected != CON_CONNECTED ) continue; - + if( client->sess.sessionTeam != TEAM_SPECTATOR ) continue; - + if( client->sess.spectatorClient == self->s.number ) Cmd_Score_f( g_entities + i ); } @@ -435,7 +435,7 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int self->client->ps.legsAnim = ( ( self->client->ps.legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; - + if( !( self->client->ps.persistant[ PERS_STATE ] & PS_NONSEGMODEL ) ) { self->client->ps.torsoAnim = @@ -461,29 +461,29 @@ G_ParseArmourScript */ void G_ParseArmourScript( char *buf, int upgrade ) { - char *token; - int count; + char *token; + int count; - count = 0; + count = 0; - while( 1 ) + while( 1 ) { - token = COM_Parse( &buf ); - - if( !token[0] ) - break; - - if( strcmp( token, "{" ) ) + token = COM_Parse( &buf ); + + if( !token[0] ) + break; + + if( strcmp( token, "{" ) ) { - G_Printf( "Missing { in armour file\n" ); - break; - } + G_Printf( "Missing { in armour file\n" ); + break; + } - if( count == MAX_ARMOUR_REGIONS ) + if( count == MAX_ARMOUR_REGIONS ) { - G_Printf( "Max armour regions exceeded in locdamage file\n" ); - break; - } + G_Printf( "Max armour regions exceeded in locdamage file\n" ); + break; + } //default g_armourRegions[ upgrade ][ count ].minHeight = 0.0; @@ -492,63 +492,63 @@ void G_ParseArmourScript( char *buf, int upgrade ) g_armourRegions[ upgrade ][ count ].maxAngle = 360; g_armourRegions[ upgrade ][ count ].modifier = 1.0; g_armourRegions[ upgrade ][ count ].crouch = qfalse; - + while( 1 ) { - token = COM_ParseExt( &buf, qtrue ); - - if( !token[0] ) + token = COM_ParseExt( &buf, qtrue ); + + if( !token[0] ) { - G_Printf( "Unexpected end of armour file\n" ); - break; - } - - if( !Q_stricmp( token, "}" ) ) + G_Printf( "Unexpected end of armour file\n" ); + break; + } + + if( !Q_stricmp( token, "}" ) ) { - break; + break; } else if( !strcmp( token, "minHeight" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "0" ); + if ( !token[0] ) + strcpy( token, "0" ); g_armourRegions[ upgrade ][ count ].minHeight = atof( token ); } else if( !strcmp( token, "maxHeight" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "100" ); + if ( !token[0] ) + strcpy( token, "100" ); g_armourRegions[ upgrade ][ count ].maxHeight = atof( token ); } else if( !strcmp( token, "minAngle" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "0" ); + if ( !token[0] ) + strcpy( token, "0" ); g_armourRegions[ upgrade ][ count ].minAngle = atoi( token ); } else if( !strcmp( token, "maxAngle" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "360" ); + if ( !token[0] ) + strcpy( token, "360" ); g_armourRegions[ upgrade ][ count ].maxAngle = atoi( token ); } else if( !strcmp( token, "modifier" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "1.0" ); + if ( !token[0] ) + strcpy( token, "1.0" ); g_armourRegions[ upgrade ][ count ].modifier = atof( token ); } @@ -556,11 +556,11 @@ void G_ParseArmourScript( char *buf, int upgrade ) { g_armourRegions[ upgrade ][ count ].crouch = qtrue; } - } + } g_numArmourRegions[ upgrade ]++; count++; - } + } } @@ -571,29 +571,29 @@ G_ParseDmgScript */ void G_ParseDmgScript( char *buf, int class ) { - char *token; - int count; + char *token; + int count; - count = 0; + count = 0; - while( 1 ) + while( 1 ) { - token = COM_Parse( &buf ); - - if( !token[0] ) - break; - - if( strcmp( token, "{" ) ) + token = COM_Parse( &buf ); + + if( !token[0] ) + break; + + if( strcmp( token, "{" ) ) { - G_Printf( "Missing { in locdamage file\n" ); - break; - } + G_Printf( "Missing { in locdamage file\n" ); + break; + } - if( count == MAX_LOCDAMAGE_REGIONS ) + if( count == MAX_LOCDAMAGE_REGIONS ) { - G_Printf( "Max damage regions exceeded in locdamage file\n" ); - break; - } + G_Printf( "Max damage regions exceeded in locdamage file\n" ); + break; + } //default g_damageRegions[ class ][ count ].minHeight = 0.0; @@ -602,63 +602,63 @@ void G_ParseDmgScript( char *buf, int class ) g_damageRegions[ class ][ count ].maxAngle = 360; g_damageRegions[ class ][ count ].modifier = 1.0; g_damageRegions[ class ][ count ].crouch = qfalse; - + while( 1 ) { - token = COM_ParseExt( &buf, qtrue ); - - if( !token[0] ) + token = COM_ParseExt( &buf, qtrue ); + + if( !token[0] ) { - G_Printf( "Unexpected end of locdamage file\n" ); - break; - } - - if( !Q_stricmp( token, "}" ) ) + G_Printf( "Unexpected end of locdamage file\n" ); + break; + } + + if( !Q_stricmp( token, "}" ) ) { - break; + break; } else if( !strcmp( token, "minHeight" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "0" ); + if ( !token[0] ) + strcpy( token, "0" ); g_damageRegions[ class ][ count ].minHeight = atof( token ); } else if( !strcmp( token, "maxHeight" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "100" ); + if ( !token[0] ) + strcpy( token, "100" ); g_damageRegions[ class ][ count ].maxHeight = atof( token ); } else if( !strcmp( token, "minAngle" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "0" ); + if ( !token[0] ) + strcpy( token, "0" ); g_damageRegions[ class ][ count ].minAngle = atoi( token ); } else if( !strcmp( token, "maxAngle" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "360" ); + if ( !token[0] ) + strcpy( token, "360" ); g_damageRegions[ class ][ count ].maxAngle = atoi( token ); } else if( !strcmp( token, "modifier" ) ) { - token = COM_ParseExt( &buf, qfalse ); + token = COM_ParseExt( &buf, qfalse ); - if ( !token[0] ) - strcpy( token, "1.0" ); + if ( !token[0] ) + strcpy( token, "1.0" ); g_damageRegions[ class ][ count ].modifier = atof( token ); } @@ -666,15 +666,15 @@ void G_ParseDmgScript( char *buf, int class ) { g_damageRegions[ class ][ count ].crouch = qtrue; } - } + } g_numDamageRegions[ class ]++; count++; - } + } } -/* +/* ============ G_CalcDamageModifier ============ @@ -693,7 +693,7 @@ static float G_CalcDamageModifier( vec3_t point, gentity_t *targ, gentity_t *att if( point == NULL ) return 1.0f; - clientHeight = targ->r.maxs[ 2 ] - targ->r.mins[ 2 ]; + clientHeight = targ->r.maxs[ 2 ] - targ->r.mins[ 2 ]; if( targ->client->ps.stats[ STAT_STATE ] & SS_WALLCLIMBING ) VectorCopy( targ->client->ps.grapplePoint, normal ); @@ -702,25 +702,25 @@ static float G_CalcDamageModifier( vec3_t point, gentity_t *targ, gentity_t *att VectorMA( targ->r.currentOrigin, targ->r.mins[ 2 ], normal, floor ); VectorSubtract( point, floor, pMINUSfloor ); - + hitRelative = DotProduct( normal, pMINUSfloor ) / VectorLength( normal ); if( hitRelative < 0.0f ) hitRelative = 0.0f; - + if( hitRelative > clientHeight ) hitRelative = clientHeight; hitRatio = hitRelative / clientHeight; - - VectorSubtract( targ->r.currentOrigin, point, bulletPath ); + + VectorSubtract( targ->r.currentOrigin, point, bulletPath ); vectoangles( bulletPath, bulletAngle ); clientRotation = targ->client->ps.viewangles[ YAW ]; bulletRotation = bulletAngle[ YAW ]; hitRotation = abs( clientRotation - bulletRotation ); - + hitRotation = hitRotation % 360; // Keep it in the 0-359 range if( !( dflags & DAMAGE_NO_LOCDAMAGE ) ) @@ -728,7 +728,7 @@ static float G_CalcDamageModifier( vec3_t point, gentity_t *targ, gentity_t *att for( i = 0; i < g_numDamageRegions[ class ]; i++ ) { qboolean rotationBound; - + if( g_damageRegions[ class ][ i ].minAngle > g_damageRegions[ class ][ i ].maxAngle ) { @@ -741,7 +741,7 @@ static float G_CalcDamageModifier( vec3_t point, gentity_t *targ, gentity_t *att rotationBound = ( hitRotation >= g_damageRegions[ class ][ i ].minAngle && hitRotation <= g_damageRegions[ class ][ i ].maxAngle ); } - + if( rotationBound && hitRatio >= g_damageRegions[ class ][ i ].minHeight && hitRatio <= g_damageRegions[ class ][ i ].maxHeight && @@ -758,7 +758,7 @@ static float G_CalcDamageModifier( vec3_t point, gentity_t *targ, gentity_t *att for( j = 0; j < g_numArmourRegions[ i ]; j++ ) { qboolean rotationBound; - + if( g_armourRegions[ i ][ j ].minAngle > g_armourRegions[ i ][ j ].maxAngle ) { @@ -771,7 +771,7 @@ static float G_CalcDamageModifier( vec3_t point, gentity_t *targ, gentity_t *att rotationBound = ( hitRotation >= g_armourRegions[ i ][ j ].minAngle && hitRotation <= g_armourRegions[ i ][ j ].maxAngle ); } - + if( rotationBound && hitRatio >= g_armourRegions[ i ][ j ].minHeight && hitRatio <= g_armourRegions[ i ][ j ].maxHeight && @@ -781,7 +781,7 @@ static float G_CalcDamageModifier( vec3_t point, gentity_t *targ, gentity_t *att } } } - + return modifier; } @@ -796,9 +796,9 @@ void G_InitDamageLocations( void ) char *modelName; char filename[ MAX_QPATH ]; int i; - int len; - fileHandle_t fileHandle; - char buffer[ MAX_LOCDAMAGE_TEXT ]; + int len; + fileHandle_t fileHandle; + char buffer[ MAX_LOCDAMAGE_TEXT ]; for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { @@ -811,7 +811,7 @@ void G_InitDamageLocations( void ) G_Printf( va( S_COLOR_RED "file not found: %s\n", filename ) ); continue; } - + if( len >= MAX_LOCDAMAGE_TEXT ) { G_Printf( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_LOCDAMAGE_TEXT ) ); @@ -822,21 +822,21 @@ void G_InitDamageLocations( void ) trap_FS_Read( buffer, len, fileHandle ); buffer[len] = 0; trap_FS_FCloseFile( fileHandle ); - + G_ParseDmgScript( buffer, i ); } - + for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ ) { modelName = BG_FindNameForUpgrade( i ); Com_sprintf( filename, sizeof( filename ), "armour/%s.armour", modelName ); len = trap_FS_FOpenFile( filename, &fileHandle, FS_READ ); - + //no file - no parsage if ( !fileHandle ) continue; - + if( len >= MAX_LOCDAMAGE_TEXT ) { G_Printf( va( S_COLOR_RED "file too large: %s is %i, max allowed is %i", filename, len, MAX_LOCDAMAGE_TEXT ) ); @@ -847,7 +847,7 @@ void G_InitDamageLocations( void ) trap_FS_Read( buffer, len, fileHandle ); buffer[len] = 0; trap_FS_FCloseFile( fileHandle ); - + G_ParseArmourScript( buffer, i ); } } @@ -906,7 +906,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, if( !inflictor ) inflictor = &g_entities[ ENTITYNUM_WORLD ]; - + if( !attacker ) attacker = &g_entities[ ENTITYNUM_WORLD ]; @@ -916,13 +916,13 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, if( targ->use && ( targ->moverState == MOVER_POS1 || targ->moverState == ROTATOR_POS1 ) ) targ->use( targ, inflictor, attacker ); - + return; } client = targ->client; - if( client ) + if( client ) { if( client->noclip ) return; @@ -940,10 +940,10 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, knockback = (int)( (float)knockback * BG_FindKnockbackScaleForClass( targ->client->ps.stats[ STAT_PCLASS ] ) ); } - + if( knockback > 200 ) knockback = 200; - + if( targ->flags & FL_NO_KNOCKBACK ) knockback = 0; @@ -970,10 +970,10 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, t = knockback * 2; if( t < 50 ) t = 50; - + if( t > 200 ) t = 200; - + targ->client->ps.pm_time = t; targ->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; } @@ -1019,11 +1019,11 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, client->ps.persistant[ PERS_ATTACKER ] = attacker->s.number; else client->ps.persistant[ PERS_ATTACKER ] = ENTITYNUM_WORLD; - + client->damage_armor += asave; client->damage_blood += take; client->damage_knockback += knockback; - + if( dir ) { VectorCopy ( dir, client->damage_from ); @@ -1058,7 +1058,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, if( take < 1 ) take = 1; - + if( g_debugDamage.integer ) { G_Printf( "%i: client:%i health:%i damage:%i armor:%i\n", level.time, targ->s.number, @@ -1072,7 +1072,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, if( targ->client ) targ->client->ps.stats[ STAT_HEALTH ] = targ->health; - + targ->lastDamageTime = level.time; //TA: add to the attackers "account" on the target @@ -1194,7 +1194,7 @@ qboolean G_SelectiveRadiusDamage( vec3_t origin, gentity_t *attacker, float dama if( ent == ignore ) continue; - + if( !ent->takedamage ) continue; @@ -1265,7 +1265,7 @@ qboolean G_RadiusDamage( vec3_t origin, gentity_t *attacker, float damage, if( ent == ignore ) continue; - + if( !ent->takedamage ) continue; diff --git a/src/game/g_local.h b/src/game/g_local.h index a56993fc..9b3aeb0e 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -14,7 +14,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + #include "q_shared.h" #include "bg_public.h" #include "g_public.h" @@ -50,12 +50,12 @@ typedef enum MOVER_POS2, MOVER_1TO2, MOVER_2TO1, - + ROTATOR_POS1, ROTATOR_POS2, ROTATOR_1TO2, ROTATOR_2TO1, - + MODEL_POS1, MODEL_POS2, MODEL_1TO2, @@ -186,7 +186,7 @@ struct gentity_s pTeam_t stageTeam; stage_t stageStage; - + int biteam; //TA: buildable item team gentity_t *parentNode; //TA: for creep and defence/spawn dependencies qboolean active; //TA: for power repeater, but could be useful elsewhere @@ -228,7 +228,7 @@ struct gentity_s int triggerGravity; //TA: gravity for this trigger int suicideTime; //TA: when the client will suicide - + int lastDamageTime; }; @@ -357,7 +357,7 @@ struct gclient_s int latched_buttons; vec3_t oldOrigin; - + // sum up damage over an entire frame, so // shotgun blasts give a single big kick int damage_armor; // damage absorbed by armor @@ -429,7 +429,7 @@ struct gclient_s typedef struct spawnQueue_s { int clients[ MAX_CLIENTS ]; - + int front, back; } spawnQueue_t; @@ -453,7 +453,7 @@ typedef struct damageRegion_s { float minHeight, maxHeight; int minAngle, maxAngle; - + float modifier; qboolean crouch; @@ -467,7 +467,7 @@ typedef struct armourRegion_s { float minHeight, maxHeight; int minAngle, maxAngle; - + float modifier; qboolean crouch; @@ -560,18 +560,18 @@ typedef struct //TA: extra stuff: int numAlienSpawns; int numHumanSpawns; - + int numAlienClients; int numHumanClients; - + float averageNumAlienClients; int numAlienSamples; float averageNumHumanClients; int numHumanSamples; - + int numLiveAlienClients; int numLiveHumanClients; - + int alienBuildPoints; int humanBuildPoints; int humanBuildPointsPowered; @@ -625,14 +625,14 @@ void G_Physics( gentity_t *ent, int msec ); typedef enum { IBE_NONE, - + IBE_NOOVERMIND, IBE_OVERMIND, IBE_NOASSERT, IBE_SPWNWARN, IBE_NOCREEP, IBE_HOVELEXIT, - + IBE_REACTOR, IBE_REPEATER, IBE_TNODEWARN, @@ -640,7 +640,7 @@ typedef enum IBE_RPTWARN2, IBE_NOPOWER, IBE_NODCC, - + IBE_NORMAL, IBE_NOROOM, IBE_PERMISSION, @@ -649,12 +649,13 @@ typedef enum } itemBuildError_t; qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideExit ); -gentity_t *G_CheckSpawnPoint( vec3_t origin, vec3_t normal, buildable_t spawn, vec3_t spawnOrigin ); +gentity_t *G_CheckSpawnPoint( int spawnNum, vec3_t origin, vec3_t normal, + buildable_t spawn, vec3_t spawnOrigin ); qboolean G_isPower( vec3_t origin ); qboolean G_isDCC( void ); qboolean G_isOvermind( void ); - + void G_BuildableThink( gentity_t *ent, int msec ); qboolean G_BuildableRange( vec3_t origin, float r, buildable_t buildable ); itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance, vec3_t origin ); @@ -947,9 +948,9 @@ typedef enum typedef struct mapRotationCondition_s { char dest[ MAX_QPATH ]; - + qboolean unconditional; - + mapConditionVariable_t lhs; mapConditionOperator_t op; @@ -960,7 +961,7 @@ typedef struct mapRotationCondition_s typedef struct mapRotationEntry_s { char name[ MAX_QPATH ]; - + char postCmds[ MAX_QPATH ][ MAX_MAP_COMMANDS ]; int numCmds; @@ -971,7 +972,7 @@ typedef struct mapRotationEntry_s typedef struct mapRotation_s { char name[ MAX_QPATH ]; - + mapRotationEntry_t maps[ MAX_MAP_ROTATION_MAPS ]; int numMaps; int currentMap; @@ -989,7 +990,7 @@ qboolean G_StartMapRotation( char *name, qboolean changeMap ); void G_StopMapRotation( void ); qboolean G_MapRotationActive( void ); void G_InitMapRotations( void ); - + // // g_ptr.c // diff --git a/src/game/g_main.c b/src/game/g_main.c index abde0daf..700c5782 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -160,7 +160,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_smoothClients, "g_smoothClients", "1", 0, 0, qfalse}, { &pmove_fixed, "pmove_fixed", "0", CVAR_SYSTEMINFO, 0, qfalse}, { &pmove_msec, "pmove_msec", "8", CVAR_SYSTEMINFO, 0, qfalse}, - + { &g_humanBuildPoints, "g_humanBuildPoints", "100", 0, 0, qfalse }, { &g_alienBuildPoints, "g_alienBuildPoints", "100", 0, 0, qfalse }, { &g_humanStage, "g_humanStage", "0", 0, 0, qfalse }, @@ -178,7 +178,7 @@ static cvarTable_t gameCvarTable[ ] = { &g_currentMapRotation, "g_currentMapRotation", "-1", 0, 0, qfalse }, // -1 = NOT_ROTATING { &g_currentMap, "g_currentMap", "0", 0, 0, qfalse }, { &g_initialMapRotation, "g_initialMapRotation", "", CVAR_ARCHIVE, 0, qfalse }, - + { &g_rankings, "g_rankings", "0", 0, 0, qfalse} }; @@ -210,38 +210,38 @@ int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, case GAME_INIT: G_InitGame( arg0, arg1, arg2 ); return 0; - + case GAME_SHUTDOWN: G_ShutdownGame( arg0 ); return 0; - + case GAME_CLIENT_CONNECT: return (int)ClientConnect( arg0, arg1, arg2 ); - + case GAME_CLIENT_THINK: ClientThink( arg0 ); return 0; - + case GAME_CLIENT_USERINFO_CHANGED: ClientUserinfoChanged( arg0 ); return 0; - + case GAME_CLIENT_DISCONNECT: ClientDisconnect( arg0 ); return 0; - + case GAME_CLIENT_BEGIN: ClientBegin( arg0 ); return 0; - + case GAME_CLIENT_COMMAND: ClientCommand( arg0 ); return 0; - + case GAME_RUN_FRAME: G_RunFrame( arg0 ); return 0; - + case GAME_CONSOLE_COMMAND: return ConsoleCommand( ); } @@ -265,7 +265,7 @@ void QDECL G_Printf( const char *fmt, ... ) Com_sprintf( clientText, 1048, "gprintf \"%s\"", text ); G_SendCommandFromServer( -1, clientText ); } - + trap_Printf( text ); } @@ -300,33 +300,33 @@ void G_FindTeams( void ) c = 0; c2 = 0; - + for( i = 1, e = g_entities+i; i < level.num_entities; i++, e++ ) { if( !e->inuse ) continue; - + if( !e->team ) continue; - + if( e->flags & FL_TEAMSLAVE ) continue; - + e->teammaster = e; c++; c2++; - + for( j = i + 1, e2 = e + 1; j < level.num_entities; j++, e2++ ) { if( !e2->inuse ) continue; - + if( !e2->team ) continue; - + if( e2->flags & FL_TEAMSLAVE ) continue; - + if( !strcmp( e->team, e2->team ) ) { c2++; @@ -368,7 +368,7 @@ void G_RegisterCvars( void ) { trap_Cvar_Register( cv->vmCvar, cv->cvarName, cv->defaultString, cv->cvarFlags ); - + if( cv->vmCvar ) cv->modificationCount = cv->vmCvar->modificationCount; @@ -436,13 +436,13 @@ static void G_GenerateParticleFileList( void ) numFiles = trap_FS_GetFileList( "scripts", ".particle", fileList, MAX_PARTICLE_FILES * MAX_QPATH ); filePtr = fileList; - + for( i = 0; i < numFiles; i++, filePtr += fileLen + 1 ) { fileLen = strlen( filePtr ); strcpy( fileName, "scripts/" ); strcat( fileName, filePtr ); - trap_SetConfigstring( CS_PARTICLE_FILES + i, fileName ); + trap_SetConfigstring( CS_PARTICLE_FILES + i, fileName ); } } @@ -483,7 +483,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) trap_FS_FOpenFile( g_log.string, &level.logFile, FS_APPEND_SYNC ); else trap_FS_FOpenFile( g_log.string, &level.logFile, FS_APPEND ); - + if( !level.logFile ) G_Printf( "WARNING: Couldn't open logfile: %s\n", g_log.string ); else @@ -491,7 +491,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) char serverinfo[ MAX_INFO_STRING ]; trap_GetServerinfo( serverinfo, sizeof( serverinfo ) ); - + G_LogPrintf( "------------------------------------------------------------\n" ); G_LogPrintf( "InitGame: %s\n", serverinfo ); } @@ -522,7 +522,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) &level.clients[ 0 ].ps, sizeof( level.clients[ 0 ] ) ); trap_SetConfigstring( CS_INTERMISSION, "0" ); - + // parse the key/value pairs and spawn gentities G_SpawnEntitiesFromString( ); @@ -537,7 +537,7 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) G_InitMapRotations( ); G_InitSpawnQueue( &level.alienSpawnQueue ); G_InitSpawnQueue( &level.humanSpawnQueue ); - + if( g_debugMapRotation.integer ) G_PrintRotations( ); @@ -653,7 +653,7 @@ Initialise a spawn queue void G_InitSpawnQueue( spawnQueue_t *sq ) { int i; - + sq->back = sq->front = 0; sq->back = QUEUE_MINUS1( sq->back ); @@ -678,7 +678,7 @@ int G_GetSpawnQueueLength( spawnQueue_t *sq ) while( length >= MAX_CLIENTS ) length -= MAX_CLIENTS; - + return length; } @@ -692,13 +692,13 @@ Remove from front element from a spawn queue int G_PopSpawnQueue( spawnQueue_t *sq ) { int clientNum = sq->clients[ sq->front ]; - + if( G_GetSpawnQueueLength( sq ) > 0 ) { sq->clients[ sq->front ] = -1; sq->front = QUEUE_PLUS1( sq->front ); g_entities[ clientNum ].client->ps.pm_flags &= ~PMF_QUEUED; - + return clientNum; } else @@ -716,7 +716,7 @@ int G_PeekSpawnQueue( spawnQueue_t *sq ) { return sq->clients[ sq->front ]; } - + /* ============ G_PushSpawnQueue @@ -755,13 +755,13 @@ qboolean G_RemoveFromSpawnQueue( spawnQueue_t *sq, int clientNum ) do { sq->clients[ i ] = sq->clients[ QUEUE_PLUS1( i ) ]; - + i = QUEUE_PLUS1( i ); } while( i != QUEUE_PLUS1( sq->back ) ); sq->back = QUEUE_MINUS1( sq->back ); g_entities[ clientNum ].client->ps.pm_flags &= ~PMF_QUEUED; - + return qtrue; } @@ -815,7 +815,7 @@ void G_PrintSpawnQueue( spawnQueue_t *sq ) int length = G_GetSpawnQueueLength( sq ); G_Printf( "l:%d f:%d b:%d :", length, sq->front, sq->back ); - + if( length > 0 ) { do @@ -871,7 +871,7 @@ void G_SpawnClients( pTeam_t team ) if( clientNum < 0 ) return; - + ent = &g_entities[ clientNum ]; ent->client->sess.sessionTeam = TEAM_FREE; @@ -895,7 +895,7 @@ void G_CountSpawns( void ) level.numAlienSpawns = 0; level.numHumanSpawns = 0; - + for( i = 1, ent = g_entities + i ; i < level.num_entities ; i++, ent++ ) { if( !ent->inuse ) @@ -903,11 +903,11 @@ void G_CountSpawns( void ) if( ent->s.modelindex == BA_A_SPAWN && ent->health > 0 ) level.numAlienSpawns++; - + if( ent->s.modelindex == BA_H_SPAWN && ent->health > 0 ) level.numHumanSpawns++; } - + //let the client know how many spawns there are trap_SetConfigstring( CS_SPAWNS, va( "%d %d", level.numAlienSpawns, level.numHumanSpawns ) ); @@ -942,13 +942,13 @@ void G_CalculateBuildPoints( void ) localHTP = g_humanBuildPoints.integer; localATP = g_alienBuildPoints.integer; } - + level.humanBuildPoints = level.humanBuildPointsPowered = localHTP; level.alienBuildPoints = localATP; level.reactorPresent = qfalse; level.overmindPresent = qfalse; - + for( i = 1, ent = g_entities + i ; i < level.num_entities ; i++, ent++ ) { if( !ent->inuse ) @@ -958,7 +958,7 @@ void G_CalculateBuildPoints( void ) continue; buildable = ent->s.modelindex; - + if( buildable != BA_NONE ) { if( buildable == BA_H_REACTOR && ent->spawned && ent->health > 0 ) @@ -987,13 +987,13 @@ void G_CalculateBuildPoints( void ) level.humanBuildPointsPowered -= level.humanBuildPoints; level.humanBuildPoints = 0; } - + if( level.alienBuildPoints < 0 ) { localATP -= level.alienBuildPoints; level.alienBuildPoints = 0; } - + trap_SetConfigstring( CS_BUILDPOINTS, va( "%d %d %d %d %d", level.alienBuildPoints, localATP, @@ -1009,24 +1009,24 @@ void G_CalculateBuildPoints( void ) if( alienPlayerCountMod < 0.1f ) alienPlayerCountMod = 0.1f; - + if( humanPlayerCountMod < 0.1f ) humanPlayerCountMod = 0.1f; - + if( g_alienStage.integer == S1 && g_alienMaxStage.integer > S1 ) alienNextStageThreshold = (int)( ceil( (float)g_alienStage2Threshold.integer * alienPlayerCountMod ) ); else if( g_alienStage.integer == S2 && g_alienMaxStage.integer > S2 ) alienNextStageThreshold = (int)( ceil( (float)g_alienStage3Threshold.integer * alienPlayerCountMod ) ); else alienNextStageThreshold = -1; - + if( g_humanStage.integer == S1 && g_humanMaxStage.integer > S1 ) humanNextStageThreshold = (int)( ceil( (float)g_humanStage2Threshold.integer * humanPlayerCountMod ) ); else if( g_humanStage.integer == S2 && g_humanMaxStage.integer > S2 ) humanNextStageThreshold = (int)( ceil( (float)g_humanStage3Threshold.integer * humanPlayerCountMod ) ); else humanNextStageThreshold = -1; - + trap_SetConfigstring( CS_STAGES, va( "%d %d %d %d %d %d", g_alienStage.integer, g_humanStage.integer, g_alienKills.integer, g_humanKills.integer, @@ -1046,10 +1046,10 @@ void G_CalculateStages( void ) if( alienPlayerCountMod < 0.1f ) alienPlayerCountMod = 0.1f; - + if( humanPlayerCountMod < 0.1f ) humanPlayerCountMod = 0.1f; - + if( g_alienKills.integer >= (int)( ceil( (float)g_alienStage2Threshold.integer * alienPlayerCountMod ) ) && g_alienStage.integer == S1 && g_alienMaxStage.integer > S1 ) @@ -1057,7 +1057,7 @@ void G_CalculateStages( void ) G_Checktrigger_stages( PTE_ALIENS, S2 ); trap_Cvar_Set( "g_alienStage", va( "%d", S2 ) ); } - + if( g_alienKills.integer >= (int)( ceil( (float)g_alienStage3Threshold.integer * alienPlayerCountMod ) ) && g_alienStage.integer == S2 && g_alienMaxStage.integer > S2 ) @@ -1100,13 +1100,13 @@ void G_CalculateAvgPlayers( void ) level.numAlienSamples = 0; trap_Cvar_Set( "g_alienKills", "0" ); } - + if( !level.numHumanClients ) { level.numHumanSamples = 0; trap_Cvar_Set( "g_humanKills", "0" ); } - + //calculate average number of clients for stats level.averageNumAlienClients = ( ( level.averageNumAlienClients * level.numAlienSamples ) @@ -1137,7 +1137,7 @@ void CalculateRanks( void ) int score; int newScore; gclient_t *cl; - + level.follow1 = -1; level.follow2 = -1; level.numConnectedClients = 0; @@ -1187,7 +1187,7 @@ void CalculateRanks( void ) level.numPlayingClients++; if( !(g_entities[ i ].r.svFlags & SVF_BOT) ) level.numVotingClients++; - + if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) level.numteamVotingClients[ 0 ]++; else if( level.clients[ i ].ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) @@ -1213,7 +1213,7 @@ void CalculateRanks( void ) { cl = &level.clients[ level.sortedClients[ i ] ]; newScore = cl->ps.persistant[ PERS_SCORE ]; - + if( i == 0 || newScore != score ) { rank = i; @@ -1226,7 +1226,7 @@ void CalculateRanks( void ) level.clients[ level.sortedClients[ i - 1 ] ].ps.persistant[ PERS_RANK ] = rank; level.clients[ level.sortedClients[ i ] ].ps.persistant[ PERS_RANK ] = rank; } - + score = newScore; } @@ -1296,10 +1296,10 @@ If a new client connects, this will be called after the spawn function. */ void MoveClientToIntermission( gentity_t *ent ) { - // take out of follow mode if needed - if( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) - G_StopFollowing( ent ); - + // take out of follow mode if needed + if( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) + G_StopFollowing( ent ); + // move to the spot VectorCopy( level.intermission_origin, ent->s.origin ); VectorCopy( level.intermission_origin, ent->client->ps.origin ); @@ -1332,7 +1332,7 @@ void FindIntermissionPoint( void ) // find the intermission spot ent = G_Find( NULL, FOFS( classname ), "info_player_intermission" ); - + if( !ent ) { // the map creator forgot to put in an intermission point... SelectSpawnPoint( vec3_origin, level.intermission_origin, level.intermission_angle ); @@ -1345,7 +1345,7 @@ void FindIntermissionPoint( void ) if( ent->target ) { target = G_PickTarget( ent->target ); - + if( target ) { VectorSubtract( target->s.origin, level.intermission_origin, dir ); @@ -1376,14 +1376,14 @@ void BeginIntermission( void ) for( i = 0; i < level.maxclients; i++ ) { client = g_entities + i; - + if( !client->inuse ) continue; - + // respawn if dead if( client->health <= 0 ) respawn(client); - + MoveClientToIntermission( client ); } @@ -1506,7 +1506,7 @@ void LogExit( const char *string ) if( cl->ps.stats[ STAT_PTEAM ] == PTE_NONE ) continue; - + if( cl->pers.connected == CON_CONNECTING ) continue; @@ -1555,7 +1555,7 @@ void CheckIntermissionExit( void ) ExitLevel( ); return; } - + // see which players are ready ready = 0; notReady = 0; @@ -1566,7 +1566,7 @@ void CheckIntermissionExit( void ) cl = level.clients + i; if( cl->pers.connected != CON_CONNECTED ) continue; - + if( cl->ps.stats[ STAT_PTEAM ] == PTE_NONE ) continue; @@ -1668,7 +1668,7 @@ void CheckExitRules( void ) level.intermissionQueued = 0; BeginIntermission( ); } - + return; } @@ -1677,12 +1677,12 @@ void CheckExitRules( void ) if( level.time - level.startTime >= g_timelimit.integer * 60000 ) { G_SendCommandFromServer( -1, "print \"Timelimit hit\n\"" ); - + G_LogPrintf( "STATS T:L A:%f H:%f M:%s D:%d AS:%d HS:%d\n", level.averageNumAlienClients, level.averageNumHumanClients, s, level.time - level.startTime, g_alienStage.integer, g_humanStage.integer ); - + level.lastWin = PTE_NONE; LogExit( "Timelimit hit." ); return; @@ -1702,7 +1702,7 @@ void CheckExitRules( void ) level.averageNumAlienClients, level.averageNumHumanClients, s, level.time - level.startTime, g_alienStage.integer, g_humanStage.integer ); - + LogExit( "Humans win." ); return; } @@ -1718,7 +1718,7 @@ void CheckExitRules( void ) level.averageNumAlienClients, level.averageNumHumanClients, s, level.time - level.startTime, g_alienStage.integer, g_humanStage.integer ); - + LogExit( "Aliens win." ); return; } @@ -1758,10 +1758,10 @@ void CheckVote( void ) else trap_SendConsoleCommand( EXEC_APPEND, va( "%s\n", level.voteString ) ); } - + if( !level.voteTime ) return; - + if( level.time - level.voteTime >= VOTE_TIME ) { if( level.voteYes > level.voteNo ) @@ -1795,7 +1795,7 @@ void CheckVote( void ) return; } } - + level.voteTime = 0; trap_SetConfigstring( CS_VOTE_TIME, "" ); } @@ -1819,7 +1819,7 @@ void CheckTeamVote( int team ) if( !level.teamVoteTime[ cs_offset ] ) return; - + if( level.time - level.teamVoteTime[ cs_offset ] >= VOTE_TIME ) { G_SendCommandFromServer( -1, "print \"Team vote failed\n\"" ); @@ -1844,7 +1844,7 @@ void CheckTeamVote( int team ) return; } } - + level.teamVoteTime[ cs_offset ] = 0; trap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, "" ); } @@ -1862,7 +1862,7 @@ void CheckCvars( void ) if( g_password.modificationCount != lastMod ) { lastMod = g_password.modificationCount; - + if( *g_password.string && Q_stricmp( g_password.string, "none" ) ) trap_Cvar_Set( "g_needpass", "1" ); else @@ -1884,14 +1884,14 @@ void G_RunThink( gentity_t *ent ) thinktime = ent->nextthink; if( thinktime <= 0 ) return; - + if( thinktime > level.time ) return; ent->nextthink = 0; if( !ent->think ) G_Error( "NULL ent->think" ); - + ent->think( ent ); } @@ -1930,7 +1930,7 @@ void G_RunFrame( int levelTime ) gentity_t *ent; int msec; int start, end; - + // if we are waiting for the level to restart, do nothing if( level.restarted ) return; @@ -1951,7 +1951,7 @@ void G_RunFrame( int levelTime ) // start = trap_Milliseconds( ); ent = &g_entities[ 0 ]; - + for( i = 0; i < level.num_entities; i++, ent++ ) { if( !ent->inuse ) @@ -1970,7 +1970,7 @@ void G_RunFrame( int levelTime ) //ent->client->ps.events[1] = 0; } } - + if( ent->freeAfterEvent ) { // tempEntities or dropped items completely go away after their event @@ -2013,13 +2013,13 @@ void G_RunFrame( int levelTime ) G_Physics( ent, msec ); continue; } - + if( ent->s.eType == ET_MOVER ) { G_RunMover( ent ); continue; } - + if( i < MAX_CLIENTS ) { G_RunClient( ent ); @@ -2031,16 +2031,16 @@ void G_RunFrame( int levelTime ) end = trap_Milliseconds(); start = trap_Milliseconds(); - + // perform final fixups on the players ent = &g_entities[ 0 ]; - + for( i = 0; i < level.maxclients; i++, ent++ ) { if( ent->inuse ) ClientEndFrame( ent ); } - + end = trap_Milliseconds(); //TA: @@ -2054,7 +2054,7 @@ void G_RunFrame( int levelTime ) //send any pending commands G_ProcessCommandQueues( ); - + // see if it is time to end the level CheckExitRules( ); diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c index c6010c34..fb98c4a8 100644 --- a/src/game/g_maprotation.c +++ b/src/game/g_maprotation.c @@ -32,7 +32,7 @@ static qboolean G_ParseMapCommandSection( mapRotationEntry_t *mre, char **text_p while( 1 ) { token = COM_Parse( text_p ); - + if( !token ) break; @@ -53,7 +53,7 @@ static qboolean G_ParseMapCommandSection( mapRotationEntry_t *mre, char **text_p Q_strcat( mre->postCmds[ mre->numCmds ], sizeof( mre->postCmds[ 0 ] ), " " ); token = COM_ParseExt( text_p, qfalse ); } - + if( mre->numCmds == MAX_MAP_COMMANDS ) { G_Printf( S_COLOR_RED "ERROR: maximum number of map commands (%d) reached\n", @@ -85,7 +85,7 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p ) while( 1 ) { token = COM_Parse( text_p ); - + if( !token ) break; @@ -105,17 +105,17 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p ) G_Printf( S_COLOR_RED "ERROR: failed to parse map command section\n" ); return qfalse; } - + mnSet = qfalse; continue; } else if( !Q_stricmp( token, "goto" ) ) { token = COM_Parse( text_p ); - + if( !token ) break; - + mrc = &mre->conditions[ mre->numConditions ]; mrc->unconditional = qtrue; Q_strncpyz( mrc->dest, token, sizeof( mrc->dest ) ); @@ -134,21 +134,21 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p ) else if( !Q_stricmp( token, "if" ) ) { token = COM_Parse( text_p ); - + if( !token ) break; - + mrc = &mre->conditions[ mre->numConditions ]; - + if( !Q_stricmp( token, "numClients" ) ) { mrc->lhs = MCV_NUMCLIENTS; - + token = COM_Parse( text_p ); - + if( !token ) break; - + if( !Q_stricmp( token, "<" ) ) mrc->op = MCO_LT; else if( !Q_stricmp( token, ">" ) ) @@ -160,23 +160,23 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p ) G_Printf( S_COLOR_RED "ERROR: invalid operator in expression: %s\n", token ); return qfalse; } - + token = COM_Parse( text_p ); - + if( !token ) break; - + mrc->numClients = atoi( token ); } else if( !Q_stricmp( token, "lastWin" ) ) { mrc->lhs = MCV_LASTWIN; - + token = COM_Parse( text_p ); - + if( !token ) break; - + if( !Q_stricmp( token, "aliens" ) ) mrc->lastWin = PTE_ALIENS; else if( !Q_stricmp( token, "humans" ) ) @@ -196,10 +196,10 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p ) } token = COM_Parse( text_p ); - + if( !token ) break; - + mrc->unconditional = qfalse; Q_strncpyz( mrc->dest, token, sizeof( mrc->dest ) ); @@ -218,7 +218,7 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p ) return qtrue; //reached the end of this map rotation mre = &mr->maps[ mr->numMaps ]; - + if( mr->numMaps == MAX_MAP_ROTATION_MAPS ) { G_Printf( S_COLOR_RED "ERROR: maximum number of maps in one rotation (%d) reached\n", @@ -227,7 +227,7 @@ static qboolean G_ParseMapRotation( mapRotation_t *mr, char **text_p ) } else mr->numMaps++; - + Q_strncpyz( mre->name, token, sizeof( mre->name ) ); mnSet = qtrue; } @@ -263,7 +263,7 @@ static qboolean G_ParseMapRotationFile( const char *fileName ) G_Printf( S_COLOR_RED "ERROR: map rotation file %s too long\n", fileName ); return qfalse; } - + trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); @@ -275,7 +275,7 @@ static qboolean G_ParseMapRotationFile( const char *fileName ) while( 1 ) { token = COM_Parse( &text_p ); - + if( !token ) break; @@ -295,9 +295,9 @@ static qboolean G_ParseMapRotationFile( const char *fileName ) return qfalse; } } - + Q_strncpyz( mapRotations.rotations[ mapRotations.numRotations ].name, mrName, MAX_QPATH ); - + if( !G_ParseMapRotation( &mapRotations.rotations[ mapRotations.numRotations ], &text_p ) ) { G_Printf( S_COLOR_RED "ERROR: %s: failed to parse map rotation %s\n", fileName, mrName ); @@ -306,7 +306,7 @@ static qboolean G_ParseMapRotationFile( const char *fileName ) //start parsing particle systems again mrNameSet = qfalse; - + if( mapRotations.numRotations == MAX_MAP_ROTATIONS ) { G_Printf( S_COLOR_RED "ERROR: maximum number of map rotations (%d) reached\n", @@ -315,7 +315,7 @@ static qboolean G_ParseMapRotationFile( const char *fileName ) } else mapRotations.numRotations++; - + continue; } else @@ -352,7 +352,7 @@ void G_PrintRotations( void ) int i, j, k; G_Printf( "Map rotations as parsed:\n\n" ); - + for( i = 0; i < mapRotations.numRotations; i++ ) { G_Printf( "rotation: %s\n{\n", mapRotations.rotations[ i ].name ); @@ -368,7 +368,7 @@ void G_PrintRotations( void ) } G_Printf( " }\n" ); - + for( k = 0; k < mapRotations.rotations[ i ].maps[ j ].numConditions; k++ ) { G_Printf( " conditional: %s\n", @@ -376,10 +376,10 @@ void G_PrintRotations( void ) } } - + G_Printf( "}\n" ); } - + G_Printf( "Total memory used: %d bytes\n", sizeof( mapRotations ) ); } @@ -396,7 +396,7 @@ static int *G_GetCurrentMapArray( void ) int i = 0; char text[ MAX_MAP_ROTATIONS * 2 ]; char *text_p, *token; - + Q_strncpyz( text, g_currentMap.string, sizeof( text ) ); text_p = text; @@ -404,16 +404,16 @@ static int *G_GetCurrentMapArray( void ) while( 1 ) { token = COM_Parse( &text_p ); - + if( !token ) break; if( !Q_stricmp( token, "" ) ) break; - + currentMap[ i++ ] = atoi( token ); } - + return currentMap; } @@ -429,7 +429,7 @@ static void G_SetCurrentMap( int currentMap, int rotation ) char text[ MAX_MAP_ROTATIONS * 2 ] = { 0 }; int *p = G_GetCurrentMapArray( ); int i; - + p[ rotation ] = currentMap; for( i = 0; i < mapRotations.numRotations; i++ ) @@ -449,7 +449,7 @@ Return the current map in some rotation static int G_GetCurrentMap( int rotation ) { int *p = G_GetCurrentMapArray( ); - + return p[ rotation ]; } @@ -465,10 +465,10 @@ static void G_IssueMapChange( int rotation ) int i; int map = G_GetCurrentMap( rotation ); char cmd[ MAX_TOKEN_CHARS ]; - + trap_SendConsoleCommand( EXEC_APPEND, va( "map %s\n", mapRotations.rotations[ rotation ].maps[ map ].name ) ); - + for( i = 0; i < mapRotations.rotations[ rotation ].maps[ map ].numCmds; i++ ) { Q_strncpyz( cmd, mapRotations.rotations[ rotation ].maps[ map ].postCmds[ i ], @@ -498,7 +498,7 @@ static mapConditionType_t G_ResolveConditionDestination( int *n, char *name ) return MCT_MAP; } } - + //...then search the rotation names for( i = 0; i < mapRotations.numRotations; i++ ) { @@ -508,7 +508,7 @@ static mapConditionType_t G_ResolveConditionDestination( int *n, char *name ) return MCT_ROTATION; } } - + //this should probably be prevented by a 2nd pass at compile time //but i'm lazy (FIXME) return MCT_ERR; @@ -555,7 +555,7 @@ static qboolean G_EvaluateMapCondition( mapRotationCondition_t *mrc ) G_Printf( S_COLOR_RED "ERROR: malformed map switch condition\n" ); break; } - + return qfalse; } @@ -577,9 +577,9 @@ qboolean G_AdvanceMapRotation( void ) if( ( currentRotation = g_currentMapRotation.integer ) == NOT_ROTATING ) return qfalse; - + currentMap = G_GetCurrentMap( currentRotation ); - + mr = &mapRotations.rotations[ currentRotation ]; mre = &mr->maps[ currentMap ]; nextMap = ( currentMap + 1 ) % mr->numMaps; @@ -591,7 +591,7 @@ qboolean G_AdvanceMapRotation( void ) if( mrc->unconditional || G_EvaluateMapCondition( mrc ) ) { mct = G_ResolveConditionDestination( &n, mrc->dest ); - + switch( mct ) { case MCT_MAP: @@ -611,7 +611,7 @@ qboolean G_AdvanceMapRotation( void ) } } } - + G_SetCurrentMap( nextMap, currentRotation ); G_IssueMapChange( currentRotation ); @@ -641,7 +641,7 @@ qboolean G_StartMapRotation( char *name, qboolean changeMap ) break; } } - + if( i == mapRotations.numRotations ) return qfalse; else @@ -689,7 +689,7 @@ void G_InitMapRotations( void ) if( trap_FS_FOpenFile( fileName, &f, FS_READ ) > 0 ) { trap_FS_FCloseFile( f ); - + if( !G_ParseMapRotationFile( fileName ) ) G_Printf( S_COLOR_RED "ERROR: failed to parse %s file\n", fileName ); } diff --git a/src/game/g_mem.c b/src/game/g_mem.c index c553859b..2f3ed5c7 100644 --- a/src/game/g_mem.c +++ b/src/game/g_mem.c @@ -8,194 +8,194 @@ #include "g_local.h" -#define POOLSIZE (256 * 1024) -#define FREEMEMCOOKIE ((int)0xDEADBE3F) // Any unlikely to be used value -#define ROUNDBITS 31 // Round to 32 bytes +#define POOLSIZE (256 * 1024) +#define FREEMEMCOOKIE ((int)0xDEADBE3F) // Any unlikely to be used value +#define ROUNDBITS 31 // Round to 32 bytes struct freememnode { - // Size of ROUNDBITS - int cookie, size; // Size includes node (obviously) - struct freememnode *prev, *next; + // Size of ROUNDBITS + int cookie, size; // Size includes node (obviously) + struct freememnode *prev, *next; }; -static char memoryPool[POOLSIZE]; +static char memoryPool[POOLSIZE]; static struct freememnode *freehead; -static int freemem; +static int freemem; void *G_Alloc( int size ) { - // Find a free block and allocate. - // Does two passes, attempts to fill same-sized free slot first. - - struct freememnode *fmn, *prev, *next, *smallest; - int allocsize, smallestsize; - char *endptr; - int *ptr; - - allocsize = ( size + sizeof(int) + ROUNDBITS ) & ~ROUNDBITS; // Round to 32-byte boundary - ptr = NULL; - - smallest = NULL; - smallestsize = POOLSIZE + 1; // Guaranteed not to miss any slots :) - for( fmn = freehead; fmn; fmn = fmn->next ) - { - if( fmn->cookie != FREEMEMCOOKIE ) - G_Error( "G_Alloc: Memory corruption detected!\n" ); - - if( fmn->size >= allocsize ) - { - // We've got a block - if( fmn->size == allocsize ) - { - // Same size, just remove - - prev = fmn->prev; - next = fmn->next; - if( prev ) - prev->next = next; // Point previous node to next - if( next ) - next->prev = prev; // Point next node to previous - if( fmn == freehead ) - freehead = next; // Set head pointer to next - ptr = (int *) fmn; - break; // Stop the loop, this is fine - } - else + // Find a free block and allocate. + // Does two passes, attempts to fill same-sized free slot first. + + struct freememnode *fmn, *prev, *next, *smallest; + int allocsize, smallestsize; + char *endptr; + int *ptr; + + allocsize = ( size + sizeof(int) + ROUNDBITS ) & ~ROUNDBITS; // Round to 32-byte boundary + ptr = NULL; + + smallest = NULL; + smallestsize = POOLSIZE + 1; // Guaranteed not to miss any slots :) + for( fmn = freehead; fmn; fmn = fmn->next ) + { + if( fmn->cookie != FREEMEMCOOKIE ) + G_Error( "G_Alloc: Memory corruption detected!\n" ); + + if( fmn->size >= allocsize ) + { + // We've got a block + if( fmn->size == allocsize ) { - // Keep track of the smallest free slot - if( fmn->size < smallestsize ) - { - smallest = fmn; - smallestsize = fmn->size; - } - } - } - } - - if( !ptr && smallest ) - { - // We found a slot big enough - smallest->size -= allocsize; - endptr = (char *) smallest + smallest->size; - ptr = (int *) endptr; - } - - if( ptr ) - { - freemem -= allocsize; - if( g_debugAlloc.integer ) - G_Printf( "G_Alloc of %i bytes (%i left)\n", allocsize, freemem ); - memset( ptr, 0, allocsize ); - *ptr++ = allocsize; // Store a copy of size for deallocation - return( (void *) ptr ); - } - - G_Error( "G_Alloc: failed on allocation of %i bytes\n", size ); - return( NULL ); + // Same size, just remove + + prev = fmn->prev; + next = fmn->next; + if( prev ) + prev->next = next; // Point previous node to next + if( next ) + next->prev = prev; // Point next node to previous + if( fmn == freehead ) + freehead = next; // Set head pointer to next + ptr = (int *) fmn; + break; // Stop the loop, this is fine + } + else + { + // Keep track of the smallest free slot + if( fmn->size < smallestsize ) + { + smallest = fmn; + smallestsize = fmn->size; + } + } + } + } + + if( !ptr && smallest ) + { + // We found a slot big enough + smallest->size -= allocsize; + endptr = (char *) smallest + smallest->size; + ptr = (int *) endptr; + } + + if( ptr ) + { + freemem -= allocsize; + if( g_debugAlloc.integer ) + G_Printf( "G_Alloc of %i bytes (%i left)\n", allocsize, freemem ); + memset( ptr, 0, allocsize ); + *ptr++ = allocsize; // Store a copy of size for deallocation + return( (void *) ptr ); + } + + G_Error( "G_Alloc: failed on allocation of %i bytes\n", size ); + return( NULL ); } void G_Free( void *ptr ) { - // Release allocated memory, add it to the free list. - - struct freememnode *fmn; - char *freeend; - int *freeptr; - - freeptr = ptr; - freeptr--; - - freemem += *freeptr; - if( g_debugAlloc.integer ) - G_Printf( "G_Free of %i bytes (%i left)\n", *freeptr, freemem ); - - for( fmn = freehead; fmn; fmn = fmn->next ) - { - freeend = ((char *) fmn) + fmn->size; - if( freeend == (char *) freeptr ) - { - // Released block can be merged to an existing node - - fmn->size += *freeptr; // Add size of node. - return; - } - } - // No merging, add to head of list - - fmn = (struct freememnode *) freeptr; - fmn->size = *freeptr; // Set this first to avoid corrupting *freeptr - fmn->cookie = FREEMEMCOOKIE; - fmn->prev = NULL; - fmn->next = freehead; - freehead->prev = fmn; - freehead = fmn; + // Release allocated memory, add it to the free list. + + struct freememnode *fmn; + char *freeend; + int *freeptr; + + freeptr = ptr; + freeptr--; + + freemem += *freeptr; + if( g_debugAlloc.integer ) + G_Printf( "G_Free of %i bytes (%i left)\n", *freeptr, freemem ); + + for( fmn = freehead; fmn; fmn = fmn->next ) + { + freeend = ((char *) fmn) + fmn->size; + if( freeend == (char *) freeptr ) + { + // Released block can be merged to an existing node + + fmn->size += *freeptr; // Add size of node. + return; + } + } + // No merging, add to head of list + + fmn = (struct freememnode *) freeptr; + fmn->size = *freeptr; // Set this first to avoid corrupting *freeptr + fmn->cookie = FREEMEMCOOKIE; + fmn->prev = NULL; + fmn->next = freehead; + freehead->prev = fmn; + freehead = fmn; } void G_InitMemory( void ) { - // Set up the initial node - - freehead = (struct freememnode *)memoryPool; - freehead->cookie = FREEMEMCOOKIE; - freehead->size = POOLSIZE; - freehead->next = NULL; - freehead->prev = NULL; - freemem = sizeof( memoryPool ); + // Set up the initial node + + freehead = (struct freememnode *)memoryPool; + freehead->cookie = FREEMEMCOOKIE; + freehead->size = POOLSIZE; + freehead->next = NULL; + freehead->prev = NULL; + freemem = sizeof( memoryPool ); } void G_DefragmentMemory( void ) { - // If there's a frenzy of deallocation and we want to - // allocate something big, this is useful. Otherwise... - // not much use. - - struct freememnode *startfmn, *endfmn, *fmn; - - for( startfmn = freehead; startfmn; ) - { - endfmn = (struct freememnode *)(((char *) startfmn) + startfmn->size); - for( fmn = freehead; fmn; ) - { - if( fmn->cookie != FREEMEMCOOKIE ) - G_Error( "G_DefragmentMemory: Memory corruption detected!\n" ); - - if( fmn == endfmn ) - { - // We can add fmn onto startfmn. - - if( fmn->prev ) - fmn->prev->next = fmn->next; - if( fmn->next ) - { - if( !(fmn->next->prev = fmn->prev) ) - freehead = fmn->next; // We're removing the head node - } - startfmn->size += fmn->size; - memset( fmn, 0, sizeof(struct freememnode) ); // A redundant call, really. - - startfmn = freehead; - endfmn = fmn = NULL; // Break out of current loop - } - else - fmn = fmn->next; - } - - if( endfmn ) - startfmn = startfmn->next; // endfmn acts as a 'restart' flag here - } + // If there's a frenzy of deallocation and we want to + // allocate something big, this is useful. Otherwise... + // not much use. + + struct freememnode *startfmn, *endfmn, *fmn; + + for( startfmn = freehead; startfmn; ) + { + endfmn = (struct freememnode *)(((char *) startfmn) + startfmn->size); + for( fmn = freehead; fmn; ) + { + if( fmn->cookie != FREEMEMCOOKIE ) + G_Error( "G_DefragmentMemory: Memory corruption detected!\n" ); + + if( fmn == endfmn ) + { + // We can add fmn onto startfmn. + + if( fmn->prev ) + fmn->prev->next = fmn->next; + if( fmn->next ) + { + if( !(fmn->next->prev = fmn->prev) ) + freehead = fmn->next; // We're removing the head node + } + startfmn->size += fmn->size; + memset( fmn, 0, sizeof(struct freememnode) ); // A redundant call, really. + + startfmn = freehead; + endfmn = fmn = NULL; // Break out of current loop + } + else + fmn = fmn->next; + } + + if( endfmn ) + startfmn = startfmn->next; // endfmn acts as a 'restart' flag here + } } void Svcmd_GameMem_f( void ) { - // Give a breakdown of memory + // Give a breakdown of memory - struct freememnode *fmn; + struct freememnode *fmn; - G_Printf( "Game memory status: %i out of %i bytes allocated\n", POOLSIZE - freemem, POOLSIZE ); + G_Printf( "Game memory status: %i out of %i bytes allocated\n", POOLSIZE - freemem, POOLSIZE ); - for( fmn = freehead; fmn; fmn = fmn->next ) - G_Printf( " %dd: %d bytes free.\n", fmn, fmn->size ); - G_Printf( "Status complete.\n" ); + for( fmn = freehead; fmn; fmn = fmn->next ) + G_Printf( " %dd: %d bytes free.\n", fmn, fmn->size ); + G_Printf( "Status complete.\n" ); } diff --git a/src/game/g_misc.c b/src/game/g_misc.c index 99eff1ab..b7172ea3 100644 --- a/src/game/g_misc.c +++ b/src/game/g_misc.c @@ -265,17 +265,17 @@ Spawn function for particle system void SP_misc_particle_system( gentity_t *self ) { char *s; - + G_SetOrigin( self, self->s.origin ); G_SpawnString( "psName", "", &s ); - + //add the particle system to the client precache list self->s.modelindex = G_ParticleSystemIndex( s ); if( self->spawnflags & 1 ) self->s.eFlags |= EF_NODRAW; - + self->use = SP_use_particle_system; self->s.eType = ET_PARTICLE_SYSTEM; trap_LinkEntity( self ); @@ -323,16 +323,16 @@ void SP_misc_anim_model( gentity_t *self ) self->s.weapon = (int)self->animation[ 1 ]; self->s.torsoAnim = (int)self->animation[ 2 ]; self->s.legsAnim = (int)self->animation[ 3 ]; - + self->s.angles2[ 0 ] = self->pos2[ 0 ]; - + //add the model to the client precache list self->s.modelindex = G_ModelIndex( self->model ); self->use = SP_use_anim_model; self->s.eType = ET_ANIMMAPOBJ; - + trap_LinkEntity( self ); } @@ -405,18 +405,18 @@ void SP_misc_light_flare( gentity_t *self ) self->s.eType = ET_LIGHTFLARE; self->s.modelindex = G_ShaderIndex( self->targetShaderName ); VectorCopy( self->pos2, self->s.origin2 ); - + //try to find a spot near to the flare which is empty. This //is used to facilitate visibility testing findEmptySpot( self->s.origin, 8.0f, self->s.angles2 ); - + self->use = SP_use_light_flare; - + G_SpawnFloat( "speed", "200", &self->speed ); self->s.time = self->speed; G_SpawnInt( "mindist", "0", &self->s.generic1 ); - + if( self->spawnflags & 1 ) self->s.eFlags |= EF_NODRAW; diff --git a/src/game/g_missile.c b/src/game/g_missile.c index 1d30974d..c55ab11f 100644 --- a/src/game/g_missile.c +++ b/src/game/g_missile.c @@ -112,19 +112,19 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) ( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) ) { G_BounceMissile( ent, trace ); - + //only play a sound if requested if( !( ent->s.eFlags & EF_NO_BOUNCE_SOUND ) ) G_AddEvent( ent, EV_GRENADE_BOUNCE, 0 ); return; } - + if( !strcmp( ent->classname, "grenade" ) ) { //grenade doesn't explode on impact G_BounceMissile( ent, trace ); - + //only play a sound if requested if( !( ent->s.eFlags & EF_NO_BOUNCE_SOUND ) ) G_AddEvent( ent, EV_GRENADE_BOUNCE, 0 ); @@ -159,7 +159,7 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) G_Printf( S_COLOR_YELLOW "WARNING: hive entity has no parent in G_MissileImpact\n" ); else ent->parent->active = qfalse; - + G_FreeEntity( ent ); return; } @@ -170,7 +170,7 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) ent->think = AHive_ReturnToHive; ent->nextthink = level.time + FRAMETIME; - + //only damage humans if( other->client && other->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) returnAfterDamage = qtrue; @@ -178,7 +178,7 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) return; } } - + // impact damage if( other->takedamage ) { @@ -190,8 +190,8 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) BG_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity ); if( VectorLength( velocity ) == 0 ) velocity[ 2 ] = 1; // stepped on a grenade - - G_Damage( other, ent, attacker, velocity, ent->s.origin, ent->damage, + + G_Damage( other, ent, attacker, velocity, ent->s.origin, ent->damage, 0, ent->methodOfDeath ); } } @@ -223,7 +223,7 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) // splash damage (doesn't apply to person directly hit) if( ent->splashDamage ) - G_RadiusDamage( trace->endpos, ent->parent, ent->splashDamage, ent->splashRadius, + G_RadiusDamage( trace->endpos, ent->parent, ent->splashDamage, ent->splashRadius, other, ent->splashMethodOfDeath ); trap_LinkEntity( ent ); @@ -247,7 +247,7 @@ void G_RunMissile( gentity_t *ent ) // ignore interactions with the missile owner passent = ent->r.ownerNum; - + // trace a line from the previous position to the current position trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, passent, ent->clipmask ); @@ -272,7 +272,7 @@ void G_RunMissile( gentity_t *ent ) // If grapple, reset owner if( ent->parent && ent->parent->client && ent->parent->client->hook == ent ) ent->parent->client->hook = NULL; - + G_FreeEntity( ent ); return; } @@ -332,7 +332,7 @@ gentity_t *fire_flamer( gentity_t *self, vec3_t start, vec3_t dir ) VectorCopy( start, bolt->r.currentOrigin ); return bolt; -} +} //============================================================================= @@ -533,7 +533,7 @@ void AHive_ReturnToHive( gentity_t *self ) G_Printf( S_COLOR_YELLOW "WARNING: AHive_ReturnToHive called with no self->parent\n" ); return; } - + trap_UnlinkEntity( self->parent ); trap_Trace( &tr, self->r.currentOrigin, self->r.mins, self->r.maxs, self->parent->r.currentOrigin, self->r.ownerNum, self->clipmask ); @@ -554,7 +554,7 @@ void AHive_ReturnToHive( gentity_t *self ) { VectorSubtract( self->parent->r.currentOrigin, self->r.currentOrigin, dir ); VectorNormalize( dir ); - + //change direction towards the hive VectorScale( dir, HIVE_SPEED, self->s.pos.trDelta ); SnapVector( self->s.pos.trDelta ); // save net bandwidth @@ -577,7 +577,7 @@ void AHive_SearchAndDestroy( gentity_t *self ) { vec3_t dir; trace_t tr; - + trap_Trace( &tr, self->r.currentOrigin, self->r.mins, self->r.maxs, self->target_ent->r.currentOrigin, self->r.ownerNum, self->clipmask ); @@ -595,7 +595,7 @@ void AHive_SearchAndDestroy( gentity_t *self ) { VectorSubtract( self->target_ent->r.currentOrigin, self->r.currentOrigin, dir ); VectorNormalize( dir ); - + //change direction towards the player VectorScale( dir, HIVE_SPEED, self->s.pos.trDelta ); SnapVector( self->s.pos.trDelta ); // save net bandwidth diff --git a/src/game/g_mover.c b/src/game/g_mover.c index 822b8129..c3879b5b 100644 --- a/src/game/g_mover.c +++ b/src/game/g_mover.c @@ -85,7 +85,7 @@ G_TransposeMatrix void G_TransposeMatrix( vec3_t matrix[ 3 ], vec3_t transpose[ 3 ] ) { int i, j; - + for( i = 0; i < 3; i++ ) { for( j = 0; j < 3; j++ ) @@ -141,7 +141,7 @@ qboolean G_TryPushingEntity( gentity_t *check, gentity_t *pusher, vec3_t move, v pushed_p->ent = check; VectorCopy( check->s.pos.trBase, pushed_p->origin ); VectorCopy( check->s.apos.trBase, pushed_p->angles ); - + if( check->client ) { pushed_p->deltayaw = check->client->ps.delta_angles[ YAW ]; @@ -149,23 +149,23 @@ qboolean G_TryPushingEntity( gentity_t *check, gentity_t *pusher, vec3_t move, v } pushed_p++; - // try moving the contacted entity + // try moving the contacted entity // figure movement due to the pusher's amove G_CreateRotationMatrix( amove, transpose ); G_TransposeMatrix( transpose, matrix ); - + if( check->client ) VectorSubtract( check->client->ps.origin, pusher->r.currentOrigin, org ); else VectorSubtract( check->s.pos.trBase, pusher->r.currentOrigin, org ); - + VectorCopy( org, org2 ); G_RotatePoint( org2, matrix ); VectorSubtract( org2, org, move2 ); // add movement VectorAdd( check->s.pos.trBase, move, check->s.pos.trBase ); VectorAdd( check->s.pos.trBase, move2, check->s.pos.trBase ); - + if( check->client ) { VectorAdd( check->client->ps.origin, move, check->client->ps.origin ); @@ -179,7 +179,7 @@ qboolean G_TryPushingEntity( gentity_t *check, gentity_t *pusher, vec3_t move, v check->s.groundEntityNum = -1; block = G_TestEntityPosition( check ); - + if( !block ) { // pushed ok @@ -187,7 +187,7 @@ qboolean G_TryPushingEntity( gentity_t *check, gentity_t *pusher, vec3_t move, v VectorCopy( check->client->ps.origin, check->r.currentOrigin ); else VectorCopy( check->s.pos.trBase, check->r.currentOrigin ); - + trap_LinkEntity( check ); return qtrue; } @@ -196,13 +196,13 @@ qboolean G_TryPushingEntity( gentity_t *check, gentity_t *pusher, vec3_t move, v // this is only relevent for riding entities, not pushed // Sliding trapdoors can cause this. VectorCopy( ( pushed_p - 1 )->origin, check->s.pos.trBase ); - + if( check->client ) VectorCopy( ( pushed_p - 1 )->origin, check->client->ps.origin ); VectorCopy( ( pushed_p - 1 )->angles, check->s.apos.trBase ); block = G_TestEntityPosition( check ); - + if( !block ) { check->s.groundEntityNum = -1; @@ -245,7 +245,7 @@ qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t ** float radius; radius = RadiusFromBounds( pusher->r.mins, pusher->r.maxs ); - + for( i = 0 ; i < 3 ; i++ ) { mins[ i ] = pusher->r.currentOrigin[ i ] + move[ i ] - radius; @@ -305,7 +305,7 @@ qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t ** || check->r.absmax[ 1 ] <= mins[ 1 ] || check->r.absmax[ 2 ] <= mins[ 2 ] ) continue; - + // see if the ent's bbox is inside the pusher's final position // this does allow a fast moving object to pass through a thin entity... if( !G_TestEntityPosition( check ) ) @@ -336,16 +336,16 @@ qboolean G_MoverPush( gentity_t *pusher, vec3_t move, vec3_t amove, gentity_t ** { VectorCopy( p->origin, p->ent->s.pos.trBase ); VectorCopy( p->angles, p->ent->s.apos.trBase ); - + if( p->ent->client ) { p->ent->client->ps.delta_angles[ YAW ] = p->deltayaw; VectorCopy( p->origin, p->ent->client->ps.origin ); } - + trap_LinkEntity( p->ent ); } - + return qfalse; } @@ -468,19 +468,19 @@ void SetMoverState( gentity_t *ent, moverState_t moverState, int time ) ent->s.pos.trTime = time; ent->s.apos.trTime = time; - + switch( moverState ) { case MOVER_POS1: VectorCopy( ent->pos1, ent->s.pos.trBase ); ent->s.pos.trType = TR_STATIONARY; break; - + case MOVER_POS2: VectorCopy( ent->pos2, ent->s.pos.trBase ); ent->s.pos.trType = TR_STATIONARY; break; - + case MOVER_1TO2: VectorCopy( ent->pos1, ent->s.pos.trBase ); VectorSubtract( ent->pos2, ent->pos1, delta ); @@ -488,7 +488,7 @@ void SetMoverState( gentity_t *ent, moverState_t moverState, int time ) VectorScale( delta, f, ent->s.pos.trDelta ); ent->s.pos.trType = TR_LINEAR_STOP; break; - + case MOVER_2TO1: VectorCopy( ent->pos2, ent->s.pos.trBase ); VectorSubtract( ent->pos1, ent->pos2, delta ); @@ -501,12 +501,12 @@ void SetMoverState( gentity_t *ent, moverState_t moverState, int time ) VectorCopy( ent->pos1, ent->s.apos.trBase ); ent->s.apos.trType = TR_STATIONARY; break; - + case ROTATOR_POS2: VectorCopy( ent->pos2, ent->s.apos.trBase ); ent->s.apos.trType = TR_STATIONARY; break; - + case ROTATOR_1TO2: VectorCopy( ent->pos1, ent->s.apos.trBase ); VectorSubtract( ent->pos2, ent->pos1, delta ); @@ -514,7 +514,7 @@ void SetMoverState( gentity_t *ent, moverState_t moverState, int time ) VectorScale( delta, f, ent->s.apos.trDelta ); ent->s.apos.trType = TR_LINEAR_STOP; break; - + case ROTATOR_2TO1: VectorCopy( ent->pos2, ent->s.apos.trBase ); VectorSubtract( ent->pos1, ent->pos2, delta ); @@ -525,20 +525,20 @@ void SetMoverState( gentity_t *ent, moverState_t moverState, int time ) case MODEL_POS1: break; - + case MODEL_POS2: break; default: break; } - + if( moverState >= MOVER_POS1 && moverState <= MOVER_2TO1 ) BG_EvaluateTrajectory( &ent->s.pos, level.time, ent->r.currentOrigin ); if( moverState >= ROTATOR_POS1 && moverState <= ROTATOR_2TO1 ) BG_EvaluateTrajectory( &ent->s.apos, level.time, ent->r.currentAngles ); - + trap_LinkEntity( ent ); } @@ -610,7 +610,7 @@ void Think_ClosedModelDoor( gentity_t *ent ) // close areaportals if( ent->teammaster == ent || !ent->teammaster ) trap_AdjustAreaPortalState( ent, qfalse ); - + ent->moverState = MODEL_POS1; } @@ -654,14 +654,14 @@ void Think_CloseModelDoor( gentity_t *ent ) { //set brush non-solid trap_UnlinkEntity( ent->clipBrush ); - + ent->nextthink = level.time + ent->wait; return; } - + //toggle door state ent->s.legsAnim = qfalse; - + // play sound if( ent->sound2to1 ) G_AddEvent( ent, EV_GENERAL_SOUND, ent->sound2to1 ); @@ -682,7 +682,7 @@ void Think_OpenModelDoor( gentity_t *ent ) { //set brush non-solid trap_UnlinkEntity( ent->clipBrush ); - + // looping sound ent->s.loopSound = ent->soundLoop; @@ -691,7 +691,7 @@ void Think_OpenModelDoor( gentity_t *ent ) G_AddEvent( ent, EV_GENERAL_SOUND, ent->soundPos2 ); ent->moverState = MODEL_POS2; - + // return to pos1 after a delay ent->think = Think_CloseModelDoor; ent->nextthink = level.time + ent->wait; @@ -762,7 +762,7 @@ void Reached_BinaryMover( gentity_t *ent ) // fire targets if( !ent->activator ) ent->activator = ent; - + G_UseTargets( ent, ent->activator ); } else if( ent->moverState == ROTATOR_2TO1 ) @@ -796,7 +796,7 @@ void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ) // if this is a non-client-usable door return if( ent->targetname && other && other->client ) return; - + // only the master should be used if( ent->flags & FL_TEAMSLAVE ) { @@ -833,7 +833,7 @@ void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ) // only partway down before reversing total = ent->s.pos.trDuration; partial = level.time - ent->s.pos.trTime; - + if( partial > total ) partial = total; @@ -847,7 +847,7 @@ void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ) // only partway up before reversing total = ent->s.pos.trDuration; partial = level.time - ent->s.pos.trTime; - + if( partial > total ) partial = total; @@ -883,7 +883,7 @@ void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ) // only partway down before reversing total = ent->s.apos.trDuration; partial = level.time - ent->s.apos.trTime; - + if( partial > total ) partial = total; @@ -897,7 +897,7 @@ void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ) // only partway up before reversing total = ent->s.apos.trDuration; partial = level.time - ent->s.apos.trTime; - + if( partial > total ) partial = total; @@ -910,7 +910,7 @@ void Use_BinaryMover( gentity_t *ent, gentity_t *other, gentity_t *activator ) { //toggle door state ent->s.legsAnim = qtrue; - + ent->think = Think_OpenModelDoor; ent->nextthink = level.time + ent->speed; @@ -965,7 +965,7 @@ void InitMover( gentity_t *ent ) // if the "color" or "light" keys are set, setup constantLight lightSet = G_SpawnFloat( "light", "100", &light ); colorSet = G_SpawnVector( "color", "1 1 1", color ); - + if( lightSet || colorSet ) { int r, g, b, i; @@ -1010,7 +1010,7 @@ void InitMover( gentity_t *ent ) VectorScale( move, ent->speed, ent->s.pos.trDelta ); ent->s.pos.trDuration = distance * 1000 / ent->speed; - + if( ent->s.pos.trDuration <= 0 ) ent->s.pos.trDuration = 1; } @@ -1045,31 +1045,31 @@ void InitRotator( gentity_t *ent ) // if the "color" or "light" keys are set, setup constantLight lightSet = G_SpawnFloat( "light", "100", &light ); colorSet = G_SpawnVector( "color", "1 1 1", color ); - + if( lightSet || colorSet ) { int r, g, b, i; r = color[ 0 ] * 255; - + if( r > 255 ) r = 255; - + g = color[ 1 ] * 255; - + if( g > 255 ) g = 255; - + b = color[ 2 ] * 255; - + if( b > 255 ) b = 255; - + i = light / 4; - + if( i > 255 ) i = 255; - + ent->s.constantLight = r | ( g << 8 ) | ( b << 16 ) | ( i << 24 ); } @@ -1089,13 +1089,13 @@ void InitRotator( gentity_t *ent ) // calculate time to reach second position from speed VectorSubtract( ent->pos2, ent->pos1, move ); angle = VectorLength( move ); - + if( !ent->speed ) ent->speed = 120; - + VectorScale( move, ent->speed, ent->s.apos.trDelta ); ent->s.apos.trDuration = angle * 1000 / ent->speed; - + if( ent->s.apos.trDuration <= 0 ) ent->s.apos.trDuration = 1; } @@ -1148,7 +1148,7 @@ static void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_ axis = ent->count; VectorClear( dir ); - + if( fabs( other->s.origin[ axis ] - ent->r.absmax[ axis ] ) < fabs( other->s.origin[ axis ] - ent->r.absmin[ axis ] ) ) { @@ -1160,15 +1160,15 @@ static void Touch_DoorTriggerSpectator( gentity_t *ent, gentity_t *other, trace_ origin[ axis ] = ent->r.absmax[ axis ] + 20; dir[ axis ] = 1; } - + for( i = 0; i < 3; i++ ) { if( i == axis ) continue; - + origin[ i ] = ( ent->r.absmin[ i ] + ent->r.absmax[ i ] ) * 0.5; } - + vectoangles( dir, angles ); TeleportPlayer( other, origin, angles ); } @@ -1188,7 +1188,7 @@ static void manualDoorTriggerSpectator( gentity_t *door, gentity_t *player ) gentity_t triggerHull; int best, i; vec3_t mins, maxs; - + //don't skip a door that is already open if( door->moverState == MOVER_1TO2 || door->moverState == MOVER_POS2 || @@ -1197,7 +1197,7 @@ static void manualDoorTriggerSpectator( gentity_t *door, gentity_t *player ) door->moverState == MODEL_1TO2 || door->moverState == MODEL_POS2 ) return; - + // find the bounds of everything on the team VectorCopy( door->r.absmin, mins ); VectorCopy( door->r.absmax, maxs ); @@ -1215,7 +1215,7 @@ static void manualDoorTriggerSpectator( gentity_t *door, gentity_t *player ) if( maxs[ i ] - mins[ i ] < maxs[ best ] - mins[ best ] ) best = i; } - + maxs[ best ] += 60; mins[ best ] -= 60; @@ -1239,11 +1239,11 @@ void manualTriggerSpectator( gentity_t *trigger, gentity_t *player ) gentity_t *targets[ MAX_GENTITIES ]; int i = 0, j; float minDistance = (float)INFINITE; - + //restrict this hack to trigger_multiple only for now if( strcmp( trigger->classname, "trigger_multiple" ) ) return; - + if( !trigger->target ) return; @@ -1254,7 +1254,7 @@ void manualTriggerSpectator( gentity_t *trigger, gentity_t *player ) targets[ i++ ] = t; else if( t == trigger ) G_Printf( "WARNING: Entity used itself.\n" ); - + if( !trigger->inuse ) { G_Printf( "triggerity was removed while using targets\n" ); @@ -1266,12 +1266,12 @@ void manualTriggerSpectator( gentity_t *trigger, gentity_t *player ) if( i > 0 ) { gentity_t *closest = NULL; - + //pick the closest door for( j = 0; j < i; j++ ) { float d = Distance( player->r.currentOrigin, targets[ j ]->r.currentOrigin ); - + if( d < minDistance ) { minDistance = d; @@ -1295,7 +1295,7 @@ void Touch_DoorTrigger( gentity_t *ent, gentity_t *other, trace_t *trace ) //buildables don't trigger movers if( other->s.eType == ET_BUILDABLE ) return; - + if( other->client && other->client->sess.sessionTeam == TEAM_SPECTATOR ) { // if the door is not open and not opening @@ -1350,7 +1350,7 @@ void Think_SpawnNewDoorTrigger( gentity_t *ent ) if( maxs[ i ] - mins[ i ] < maxs[ best ] - mins[ best ] ) best = i; } - + maxs[ best ] += 60; mins[ best ] -= 60; @@ -1404,7 +1404,7 @@ void SP_func_door( gentity_t *ent ) ent->sound2to1 = G_SoundIndex( s ); G_SpawnString( "sound1to2", "sound/movers/doors/dr1_strt.wav", &s ); ent->sound1to2 = G_SoundIndex( s ); - + G_SpawnString( "soundPos2", "sound/movers/doors/dr1_end.wav", &s ); ent->soundPos2 = G_SoundIndex( s ); G_SpawnString( "soundPos1", "sound/movers/doors/dr1_end.wav", &s ); @@ -1419,7 +1419,7 @@ void SP_func_door( gentity_t *ent ) // default wait of 2 seconds if( !ent->wait ) ent->wait = 2; - + ent->wait *= 1000; // default lip of 8 units @@ -1480,7 +1480,7 @@ void SP_func_door( gentity_t *ent ) * TOGGLE wait in both the start and end states for a trigger event. * X_AXIS open on the X-axis instead of the Z-axis * Y_AXIS open on the Y-axis instead of the Z-axis - * + * * You need to have an origin brush as part of this entity. The center of that brush will be * the point around which it is rotated. It will rotate around the Z axis by default. You can * check either the X_AXIS or Y_AXIS box to change that. @@ -1500,7 +1500,7 @@ void SP_func_door_rotating( gentity_t *ent ) ent->sound2to1 = G_SoundIndex( s ); G_SpawnString( "sound1to2", "sound/movers/doors/dr1_strt.wav", &s ); ent->sound1to2 = G_SoundIndex( s ); - + G_SpawnString( "soundPos2", "sound/movers/doors/dr1_end.wav", &s ); ent->soundPos2 = G_SoundIndex( s ); G_SpawnString( "soundPos1", "sound/movers/doors/dr1_end.wav", &s ); @@ -1511,77 +1511,77 @@ void SP_func_door_rotating( gentity_t *ent ) //default speed of 120 if( !ent->speed ) ent->speed = 120; - + // if speed is negative, positize it and add reverse flag if( ent->speed < 0 ) { ent->speed *= -1; ent->spawnflags |= 8; } - + // default of 2 seconds if( !ent->wait ) ent->wait = 2; - + ent->wait *= 1000; - + // set the axis of rotation VectorClear( ent->movedir ); VectorClear( ent->s.angles ); - + if( ent->spawnflags & 32 ) ent->movedir[ 2 ] = 1.0; else if( ent->spawnflags & 64 ) ent->movedir[ 0 ] = 1.0; else ent->movedir[ 1 ] = 1.0; - + // reverse direction if necessary if( ent->spawnflags & 8 ) VectorNegate ( ent->movedir, ent->movedir ); - + // default distance of 90 degrees. This is something the mapper should not // leave out, so we'll tell him if he does. if( !ent->rotatorAngle ) { G_Printf( "%s at %s with no rotatorAngle set.\n", ent->classname, vtos( ent->s.origin ) ); - + ent->rotatorAngle = 90.0; } - + VectorCopy( ent->s.angles, ent->pos1 ); trap_SetBrushModel( ent, ent->model ); VectorMA( ent->pos1, ent->rotatorAngle, ent->movedir, ent->pos2 ); - + // if "start_open", reverse position 1 and 2 if( ent->spawnflags & 1 ) { vec3_t temp; - + VectorCopy( ent->pos2, temp ); VectorCopy( ent->s.angles, ent->pos2 ); VectorCopy( temp, ent->pos1 ); VectorNegate( ent->movedir, ent->movedir ); } - + // set origin VectorCopy( ent->s.origin, ent->s.pos.trBase ); VectorCopy( ent->s.pos.trBase, ent->r.currentOrigin ); - + InitRotator( ent ); - + ent->nextthink = level.time + FRAMETIME; - + if( !( ent->flags & FL_TEAMSLAVE ) ) { int health; - + G_SpawnInt( "health", "0", &health ); - + if( health ) ent->takedamage = qtrue; - + if( ent->targetname || health ) { // non touch/shoot doors @@ -1618,7 +1618,7 @@ void SP_func_door_model( gentity_t *ent ) ent->sound2to1 = G_SoundIndex( s ); G_SpawnString( "sound1to2", "sound/movers/doors/dr1_strt.wav", &s ); ent->sound1to2 = G_SoundIndex( s ); - + G_SpawnString( "soundPos2", "sound/movers/doors/dr1_end.wav", &s ); ent->soundPos2 = G_SoundIndex( s ); G_SpawnString( "soundPos1", "sound/movers/doors/dr1_end.wav", &s ); @@ -1631,7 +1631,7 @@ void SP_func_door_model( gentity_t *ent ) //default wait of 2 seconds if( ent->wait <= 0 ) ent->wait = 2; - + ent->wait *= 1000; //brush model @@ -1640,18 +1640,18 @@ void SP_func_door_model( gentity_t *ent ) trap_SetBrushModel( clipBrush, clipBrush->model ); clipBrush->s.eType = ET_INVISIBLE; trap_LinkEntity( clipBrush ); - + //copy the bounds back from the clipBrush so the //triggers can be made VectorCopy( clipBrush->r.absmin, ent->r.absmin ); VectorCopy( clipBrush->r.absmax, ent->r.absmax ); VectorCopy( clipBrush->r.mins, ent->r.mins ); VectorCopy( clipBrush->r.maxs, ent->r.maxs ); - + G_SpawnVector( "modelOrigin", "0 0 0", ent->s.origin ); G_SpawnVector( "scale", "1 1 1", ent->s.origin2 ); - + // if the "model2" key is set, use a seperate model // for drawing, but clip against the brushes if( !ent->model2 ) @@ -1666,7 +1666,7 @@ void SP_func_door_model( gentity_t *ent ) // if the "color" or "light" keys are set, setup constantLight lightSet = G_SpawnFloat( "light", "100", &light ); colorSet = G_SpawnVector( "color", "1 1 1", color ); - + if( lightSet || colorSet ) { int r, g, b, i; @@ -1704,16 +1704,16 @@ void SP_func_door_model( gentity_t *ent ) ent->s.apos.trTime = 0; ent->s.apos.trDuration = 0; VectorClear( ent->s.apos.trDelta ); - + ent->s.powerups = (int)ent->animation[ 0 ]; //first frame ent->s.weapon = abs( (int)ent->animation[ 1 ] ); //number of frames - + //must be at least one frame -- mapper has forgotten animation key if( ent->s.weapon == 0 ) ent->s.weapon = 1; - + ent->s.torsoAnim = ent->s.weapon * ( 1000.0f / ent->speed ); //framerate - + trap_LinkEntity( ent ); if( !( ent->flags & FL_TEAMSLAVE ) ) @@ -1809,7 +1809,7 @@ void SpawnPlatTrigger( gentity_t *ent ) tmin[ 0 ] = ent->pos1[ 0 ] + ( ent->r.mins[ 0 ] + ent->r.maxs[ 0 ] ) * 0.5; tmax[ 0 ] = tmin[ 0 ] + 1; } - + if( tmax[ 1 ] <= tmin[ 1 ] ) { tmin[ 1 ] = ent->pos1[ 1 ] + ( ent->r.mins[ 1 ] + ent->r.maxs[ 1 ] ) * 0.5; @@ -1843,7 +1843,7 @@ void SP_func_plat( gentity_t *ent ) ent->sound2to1 = G_SoundIndex( s ); G_SpawnString( "sound1to2", "sound/movers/plats/pt1_strt.wav", &s ); ent->sound1to2 = G_SoundIndex( s ); - + G_SpawnString( "soundPos2", "sound/movers/plats/pt1_end.wav", &s ); ent->soundPos2 = G_SoundIndex( s ); G_SpawnString( "soundPos1", "sound/movers/plats/pt1_end.wav", &s ); @@ -1938,7 +1938,7 @@ void SP_func_button( gentity_t *ent ) if( !ent->wait ) ent->wait = 1; - + ent->wait *= 1000; // first position @@ -2033,7 +2033,7 @@ void Reached_Train( gentity_t *ent ) // otherwise use the train's speed speed = ent->speed; } - + if( speed < 1 ) speed = 1; @@ -2056,7 +2056,7 @@ void Reached_Train( gentity_t *ent ) ent->s.pos.trType = TR_STATIONARY; return; } - + // if there is a "wait" value on the target, don't start moving yet if( next->wait ) { @@ -2074,7 +2074,7 @@ Start_Train void Start_Train( gentity_t *ent, gentity_t *other, gentity_t *activator ) { vec3_t move; - + //recalculate duration as the mover is highly //unlikely to be right on a path_corner VectorSubtract( ent->pos2, ent->pos1, move ); @@ -2092,12 +2092,12 @@ Stop_Train void Stop_Train( gentity_t *ent, gentity_t *other, gentity_t *activator ) { vec3_t origin; - + //get current origin BG_EvaluateTrajectory( &ent->s.pos, level.time, origin ); VectorCopy( origin, ent->pos1 ); SetMoverState( ent, MOVER_POS1, level.time ); - + ent->spawnflags |= TRAIN_START_OFF; } @@ -2132,7 +2132,7 @@ void Think_SetupTrainTargets( gentity_t *ent ) gentity_t *path, *next, *start; ent->nextTrain = G_Find( NULL, FOFS( targetname ), ent->target ); - + if( !ent->nextTrain ) { G_Printf( "func_train at %s with an unfound target\n", @@ -2160,7 +2160,7 @@ void Think_SetupTrainTargets( gentity_t *ent ) do { next = G_Find( next, FOFS( targetname ), path->target ); - + if( !next ) { G_Printf( "Train corner at %s without a target path_corner\n", @@ -2206,10 +2206,10 @@ void Blocked_Train( gentity_t *self, gentity_t *other ) Stop_Train( self, other, other ); else { - if( !other->client ) - { + if( !other->client ) + { //whatever is blocking the train isn't a client - + //KILL!!1!!! G_Damage( other, self, self, NULL, NULL, 10000, 0, MOD_CRUSH ); @@ -2219,7 +2219,7 @@ void Blocked_Train( gentity_t *self, gentity_t *other ) { vec3_t dir; gentity_t *tent; - + if( other->biteam == BIT_ALIENS ) { VectorCopy( other->s.origin2, dir ); @@ -2233,13 +2233,13 @@ void Blocked_Train( gentity_t *self, gentity_t *other ) tent->s.eventParm = DirToByte( dir ); } } - + //if it's still around free it if( other ) G_FreeEntity( other ); - + return; - } + } G_Damage( other, self, self, NULL, NULL, 10000, 0, MOD_CRUSH ); } @@ -2348,7 +2348,7 @@ void SP_func_rotating( gentity_t *ent ) ent->s.apos.trDelta[ 0 ] = ent->speed; else ent->s.apos.trDelta[ 1 ] = ent->speed; - + if( !ent->damage ) ent->damage = 2; @@ -2446,7 +2446,7 @@ void SP_func_pendulum( gentity_t *ent ) // find pendulum length length = fabs( ent->r.mins[ 2 ] ); - + if( length < 8 ) length = 8; diff --git a/src/game/g_physics.c b/src/game/g_physics.c index 63abaf9e..c6c03f69 100644 --- a/src/game/g_physics.c +++ b/src/game/g_physics.c @@ -82,7 +82,7 @@ void G_Physics( gentity_t *ent, int msec ) trace_t tr; int contents; int mask; - + // if groundentity has been set to -1, it may have been pushed off an edge if( ent->s.groundEntityNum == -1 ) { @@ -100,7 +100,7 @@ void G_Physics( gentity_t *ent, int msec ) ent->s.pos.trTime = level.time; } } - + // trace a line from the previous position to the current position if( ent->clipmask ) mask = ent->clipmask; @@ -120,7 +120,7 @@ void G_Physics( gentity_t *ent, int msec ) VectorMA( origin, -2.0f, ent->s.origin2, origin ); trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, ent->s.number, mask ); - + if( tr.fraction == 1.0f ) ent->s.groundEntityNum = -1; @@ -145,7 +145,7 @@ void G_Physics( gentity_t *ent, int msec ) // check think function G_RunThink( ent ); - if( tr.fraction == 1.0f ) + if( tr.fraction == 1.0f ) return; // if it is in a nodrop volume, remove it diff --git a/src/game/g_ptr.c b/src/game/g_ptr.c index 861f4b87..f597a196 100644 --- a/src/game/g_ptr.c +++ b/src/game/g_ptr.c @@ -27,7 +27,7 @@ Callback to detect ptrc clashes static qboolean G_CheckForUniquePTRC( int code ) { int i; - + if( code == 0 ) return qfalse; @@ -36,7 +36,7 @@ static qboolean G_CheckForUniquePTRC( int code ) if( connections[ i ].ptrCode == code ) return qfalse; } - + return qtrue; } @@ -70,7 +70,7 @@ connectionRecord_t *G_GenerateNewConnection( gclient_t *client ) // this should be really random srand( trap_Milliseconds( ) ); - + // there is a very very small possibility that this // will loop infinitely do @@ -105,16 +105,16 @@ Check a PTR code for validity qboolean G_VerifyPTRC( int code ) { int i; - + if( code == 0 ) return qfalse; - + for( i = 0; i < MAX_CLIENTS; i++ ) { if( connections[ i ].ptrCode == code ) return qtrue; } - + return qfalse; } @@ -128,7 +128,7 @@ Finds a connection for a given code connectionRecord_t *G_FindConnectionForCode( int code ) { int i; - + if( code == 0 ) return NULL; diff --git a/src/game/g_public.h b/src/game/g_public.h index 2d639cad..e5652b79 100644 --- a/src/game/g_public.h +++ b/src/game/g_public.h @@ -33,13 +33,13 @@ #define SVF_PORTAL 0x00000040 // merge a second pvs at origin2 into snapshots #define SVF_USE_CURRENT_ORIGIN 0x00000080 // entity->r.currentOrigin instead of entity->s.origin // for link position (missiles and movers) -#define SVF_SINGLECLIENT 0x00000100 // only send to a single client (entityShared_t->singleClient) -#define SVF_NOSERVERINFO 0x00000200 // don't send CS_SERVERINFO updates to this client - // so that it can be updated for ping tools without - // lagging clients -#define SVF_CAPSULE 0x00000400 // use capsule for collision detection instead of bbox -#define SVF_NOTSINGLECLIENT 0x00000800 // send entity to everyone but one client - // (entityShared_t->singleClient) +#define SVF_SINGLECLIENT 0x00000100 // only send to a single client (entityShared_t->singleClient) +#define SVF_NOSERVERINFO 0x00000200 // don't send CS_SERVERINFO updates to this client + // so that it can be updated for ping tools without + // lagging clients +#define SVF_CAPSULE 0x00000400 // use capsule for collision detection instead of bbox +#define SVF_NOTSINGLECLIENT 0x00000800 // send entity to everyone but one client + // (entityShared_t->singleClient) //=============================================================== diff --git a/src/game/g_session.c b/src/game/g_session.c index d05e81e1..1dcb8883 100644 --- a/src/game/g_session.c +++ b/src/game/g_session.c @@ -36,22 +36,22 @@ Called on game shutdown */ void G_WriteClientSessionData( gclient_t *client ) { - const char *s; - const char *var; - - s = va( "%i %i %i %i %i %i %i", - client->sess.sessionTeam, - client->sess.spectatorTime, - client->sess.spectatorState, - client->sess.spectatorClient, - client->sess.wins, - client->sess.losses, + const char *s; + const char *var; + + s = va( "%i %i %i %i %i %i %i", + client->sess.sessionTeam, + client->sess.spectatorTime, + client->sess.spectatorState, + client->sess.spectatorClient, + client->sess.wins, + client->sess.losses, client->sess.teamLeader - ); + ); - var = va( "session%i", client - level.clients ); + var = va( "session%i", client - level.clients ); - trap_Cvar_Set( var, s ); + trap_Cvar_Set( var, s ); } /* @@ -63,26 +63,26 @@ Called on a reconnect */ void G_ReadSessionData( gclient_t *client ) { - char s[ MAX_STRING_CHARS ]; - const char *var; + char s[ MAX_STRING_CHARS ]; + const char *var; // bk001205 - format int teamLeader; int spectatorState; int sessionTeam; - var = va( "session%i", client - level.clients ); - trap_Cvar_VariableStringBuffer( var, s, sizeof(s) ); + var = va( "session%i", client - level.clients ); + trap_Cvar_VariableStringBuffer( var, s, sizeof(s) ); - sscanf( s, "%i %i %i %i %i %i %i", - &sessionTeam, - &client->sess.spectatorTime, - &spectatorState, - &client->sess.spectatorClient, - &client->sess.wins, - &client->sess.losses, + sscanf( s, "%i %i %i %i %i %i %i", + &sessionTeam, + &client->sess.spectatorTime, + &spectatorState, + &client->sess.spectatorClient, + &client->sess.wins, + &client->sess.losses, &teamLeader - ); + ); // bk001205 - format issues client->sess.sessionTeam = (team_t)sessionTeam; @@ -100,12 +100,12 @@ Called on a first-time connect */ void G_InitSessionData( gclient_t *client, char *userinfo ) { - clientSession_t *sess; - const char *value; + clientSession_t *sess; + const char *value; - sess = &client->sess; + sess = &client->sess; - // initial team determination + // initial team determination value = Info_ValueForKey( userinfo, "team" ); if( value[ 0 ] == 's' ) { @@ -114,18 +114,18 @@ void G_InitSessionData( gclient_t *client, char *userinfo ) } else { - if( g_maxGameClients.integer > 0 && + if( g_maxGameClients.integer > 0 && level.numNonSpectatorClients >= g_maxGameClients.integer ) sess->sessionTeam = TEAM_SPECTATOR; else sess->sessionTeam = TEAM_FREE; } - sess->spectatorState = SPECTATOR_FREE; - sess->spectatorTime = level.time; + sess->spectatorState = SPECTATOR_FREE; + sess->spectatorTime = level.time; sess->spectatorClient = -1; - G_WriteClientSessionData( client ); + G_WriteClientSessionData( client ); } @@ -137,14 +137,14 @@ G_WriteSessionData */ void G_WriteSessionData( void ) { - int i; + int i; //TA: ? - trap_Cvar_Set( "session", va( "%i", 0 ) ); + trap_Cvar_Set( "session", va( "%i", 0 ) ); - for( i = 0 ; i < level.maxclients ; i++ ) + for( i = 0 ; i < level.maxclients ; i++ ) { - if( level.clients[ i ].pers.connected == CON_CONNECTED ) - G_WriteClientSessionData( &level.clients[ i ] ); - } + if( level.clients[ i ].pers.connected == CON_CONNECTED ) + G_WriteClientSessionData( &level.clients[ i ] ); + } } diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index 5e9e6da0..2c279757 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -231,7 +231,7 @@ spawn_t spawns[ ] = //TA: extra bits { "info_alien_intermission", SP_info_alien_intermission }, { "info_human_intermission", SP_info_human_intermission }, - + { "info_null", SP_info_null }, { "info_notnull", SP_info_notnull }, // use target_position instead @@ -292,7 +292,7 @@ spawn_t spawns[ ] = { "misc_particle_system", SP_misc_particle_system }, { "misc_anim_model", SP_misc_anim_model }, { "misc_light_flare", SP_misc_light_flare }, - + { 0, 0 } }; @@ -348,7 +348,7 @@ qboolean G_CallSpawn( gentity_t *ent ) return qtrue; } } - + G_Printf( "%s doesn't have a spawn function\n", ent->classname ); return qfalse; } @@ -421,39 +421,39 @@ void G_ParseField( const char *key, const char *value, gentity_t *ent ) case F_LSTRING: *(char **)( b + f->ofs ) = G_NewString( value ); break; - + case F_VECTOR: sscanf( value, "%f %f %f", &vec[ 0 ], &vec[ 1 ], &vec[ 2 ] ); - + ( (float *)( b + f->ofs ) )[ 0 ] = vec[ 0 ]; ( (float *)( b + f->ofs ) )[ 1 ] = vec[ 1 ]; ( (float *)( b + f->ofs ) )[ 2 ] = vec[ 2 ]; break; - + case F_VECTOR4: sscanf( value, "%f %f %f %f", &vec4[ 0 ], &vec4[ 1 ], &vec4[ 2 ], &vec4[ 3 ] ); - + ( (float *)( b + f->ofs ) )[ 0 ] = vec4[ 0 ]; ( (float *)( b + f->ofs ) )[ 1 ] = vec4[ 1 ]; ( (float *)( b + f->ofs ) )[ 2 ] = vec4[ 2 ]; ( (float *)( b + f->ofs ) )[ 3 ] = vec4[ 3 ]; break; - + case F_INT: *(int *)( b + f->ofs ) = atoi( value ); break; - + case F_FLOAT: *(float *)( b + f->ofs ) = atof( value ); break; - + case F_ANGLEHACK: v = atof( value ); ( (float *)( b + f->ofs ) )[ 0 ] = 0; ( (float *)( b + f->ofs ) )[ 1 ] = v; ( (float *)( b + f->ofs ) )[ 2 ] = 0; break; - + default: case F_IGNORE: break; @@ -479,7 +479,7 @@ void G_SpawnGEntityFromSpawnVars( void ) { int i; gentity_t *ent; - + // get the next free entity ent = G_Spawn( ); @@ -487,7 +487,7 @@ void G_SpawnGEntityFromSpawnVars( void ) G_ParseField( level.spawnVars[ i ][ 0 ], level.spawnVars[ i ][ 1 ], ent ); G_SpawnInt( "notq3a", "0", &i ); - + if( i ) { G_FreeEntity( ent ); @@ -551,7 +551,7 @@ qboolean G_ParseSpawnVars( void ) // end of spawn string return qfalse; } - + if( com_token[ 0 ] != '{' ) G_Error( "G_ParseSpawnVars: found %s when expecting {", com_token ); @@ -597,7 +597,7 @@ void SP_worldspawn( void ) char *s; G_SpawnString( "classname", "", &s ); - + if( Q_stricmp( s, "worldspawn" ) ) G_Error( "SP_worldspawn: The first entity isn't 'worldspawn'" ); diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index 0c5c3b27..efe76991 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -95,11 +95,11 @@ static qboolean StringToFilter( char *s, ipFilter_t *f ) s++; if ( !*s ) break; - + s++; continue; } - + G_Printf( "Bad filter address: %s\n", s ); return qfalse; } @@ -107,15 +107,15 @@ static qboolean StringToFilter( char *s, ipFilter_t *f ) j = 0; while( *s >= '0' && *s <= '9' ) num[ j++ ] = *s++; - + num[ j ] = 0; b[ i ] = atoi( num ); - + m[ i ] = 255; if( !*s ) break; - + s++; } @@ -132,43 +132,43 @@ UpdateIPBans */ static void UpdateIPBans( void ) { - byte b[ 4 ]; - byte m[ 4 ]; - int i, j; - char iplist_final[ MAX_CVAR_VALUE_STRING ]; - char ip[ 64 ]; - - *iplist_final = 0; - - for( i = 0 ; i < numIPFilters ; i++ ) - { - if( ipFilters[ i ].compare == 0xffffffff ) - continue; - - *(unsigned *)b = ipFilters[ i ].compare; - *(unsigned *)m = ipFilters[ i ].mask; - *ip = 0; - - for( j = 0 ; j < 4 ; j++ ) - { - if( m[ j ] != 255 ) - Q_strcat( ip, sizeof( ip ), "*" ); - else - Q_strcat( ip, sizeof( ip ), va( "%i", b[ j ] ) ); - - Q_strcat( ip, sizeof( ip ), ( j < 3 ) ? "." : " " ); - } - - if( strlen( iplist_final ) + strlen( ip ) < MAX_CVAR_VALUE_STRING ) - Q_strcat( iplist_final, sizeof( iplist_final ), ip ); - else - { - Com_Printf( "g_banIPs overflowed at MAX_CVAR_VALUE_STRING\n" ); - break; - } - } - - trap_Cvar_Set( "g_banIPs", iplist_final ); + byte b[ 4 ]; + byte m[ 4 ]; + int i, j; + char iplist_final[ MAX_CVAR_VALUE_STRING ]; + char ip[ 64 ]; + + *iplist_final = 0; + + for( i = 0 ; i < numIPFilters ; i++ ) + { + if( ipFilters[ i ].compare == 0xffffffff ) + continue; + + *(unsigned *)b = ipFilters[ i ].compare; + *(unsigned *)m = ipFilters[ i ].mask; + *ip = 0; + + for( j = 0 ; j < 4 ; j++ ) + { + if( m[ j ] != 255 ) + Q_strcat( ip, sizeof( ip ), "*" ); + else + Q_strcat( ip, sizeof( ip ), va( "%i", b[ j ] ) ); + + Q_strcat( ip, sizeof( ip ), ( j < 3 ) ? "." : " " ); + } + + if( strlen( iplist_final ) + strlen( ip ) < MAX_CVAR_VALUE_STRING ) + Q_strcat( iplist_final, sizeof( iplist_final ), ip ); + else + { + Com_Printf( "g_banIPs overflowed at MAX_CVAR_VALUE_STRING\n" ); + break; + } + } + + trap_Cvar_Set( "g_banIPs", iplist_final ); } /* @@ -193,10 +193,10 @@ qboolean G_FilterPacket( char *from ) m[ i ] = m[ i ] * 10 + ( *p - '0' ); p++; } - + if( !*p || *p == ':' ) break; - + i++, p++; } @@ -221,7 +221,7 @@ static void AddIP( char *str ) for( i = 0 ; i < numIPFilters ; i++ ) if( ipFilters[ i ].compare == 0xffffffff ) break; // free spot - + if( i == numIPFilters ) { if( numIPFilters == MAX_IPFILTERS ) @@ -229,7 +229,7 @@ static void AddIP( char *str ) G_Printf( "IP filter list is full\n" ); return; } - + numIPFilters++; } @@ -254,16 +254,16 @@ void G_ProcessIPBans( void ) for( t = s = g_banIPs.string; *t; /* */ ) { s = strchr( s, ' ' ); - + if( !s ) break; - + while( *s == ' ' ) *s++ = 0; - + if( *t ) AddIP( t ); - + t = s; } } @@ -338,14 +338,14 @@ void Svcmd_EntityList_f( void ) gentity_t *check; check = g_entities + 1; - + for( e = 1; e < level.num_entities; e++, check++ ) { if( !check->inuse ) continue; G_Printf( "%3i:", e ); - + switch( check->s.eType ) { case ET_GENERAL: @@ -394,7 +394,7 @@ void Svcmd_EntityList_f( void ) if( check->classname ) G_Printf( "%s", check->classname ); - + G_Printf( "\n" ); } } @@ -409,7 +409,7 @@ gclient_t *ClientForString( const char *s ) if( s[ 0 ] >= '0' && s[ 0 ] <= '9' ) { idnum = atoi( s ); - + if( idnum < 0 || idnum >= level.maxclients ) { Com_Printf( "Bad client slot: %i\n", idnum ); @@ -417,13 +417,13 @@ gclient_t *ClientForString( const char *s ) } cl = &level.clients[ idnum ]; - + if( cl->pers.connected == CON_DISCONNECTED ) { G_Printf( "Client %i is not connected\n", idnum ); return NULL; } - + return cl; } @@ -458,7 +458,7 @@ void Svcmd_ForceTeam_f( void ) // find the player trap_Argv( 1, str, sizeof( str ) ); cl = ClientForString( str ); - + if( !cl ) return; @@ -521,7 +521,7 @@ qboolean ConsoleCommand( void ) if( Q_stricmp( cmd, "mapRotation" ) == 0 ) { char *rotationName = ConcatArgs( 1 ); - + if( !G_StartMapRotation( rotationName, qfalse ) ) G_Printf( "Can't find map rotation %s\n", rotationName ); @@ -539,7 +539,7 @@ qboolean ConsoleCommand( void ) { int i; gentity_t *e; - + for( i = 1, e = g_entities + i; i < level.num_entities; i++, e++ ) { if( e->s.modelindex == BA_H_SPAWN ) @@ -548,12 +548,12 @@ qboolean ConsoleCommand( void ) return qtrue; } - + if( Q_stricmp( cmd, "humanWin" ) == 0 ) { int i; gentity_t *e; - + for( i = 1, e = g_entities + i; i < level.num_entities; i++, e++ ) { if( e->s.modelindex == BA_A_SPAWN ) @@ -562,7 +562,7 @@ qboolean ConsoleCommand( void ) return qtrue; } - + if( g_dedicated.integer ) { if( Q_stricmp( cmd, "say" ) == 0 ) @@ -570,12 +570,12 @@ qboolean ConsoleCommand( void ) G_SendCommandFromServer( -1, va( "print \"server: %s\n\"", ConcatArgs( 1 ) ) ); return qtrue; } - + // everything else will also be printed as a say command G_SendCommandFromServer( -1, va( "print \"server: %s\n\"", ConcatArgs( 0 ) ) ); return qtrue; } - + return qfalse; } diff --git a/src/game/g_syscalls.c b/src/game/g_syscalls.c index 6a3f70c4..93035395 100644 --- a/src/game/g_syscalls.c +++ b/src/game/g_syscalls.c @@ -46,7 +46,7 @@ void trap_Error( const char *fmt ) int trap_Milliseconds( void ) { - return syscall( G_MILLISECONDS ); + return syscall( G_MILLISECONDS ); } int trap_Argc( void ) { diff --git a/src/game/g_target.c b/src/game/g_target.c index f57f173e..216b2550 100644 --- a/src/game/g_target.c +++ b/src/game/g_target.c @@ -88,7 +88,7 @@ void Use_Target_Print( gentity_t *ent, gentity_t *other, gentity_t *activator ) G_TeamCommand( PTE_HUMANS, va( "cp \"%s\"", ent->message ) ); if( ent->spawnflags & 2 ) G_TeamCommand( PTE_ALIENS, va( "cp \"%s\"", ent->message ) ); - + return; } @@ -191,9 +191,9 @@ void target_teleporter_use( gentity_t *self, gentity_t *other, gentity_t *activa if( !activator->client ) return; - + dest = G_PickTarget( self->target ); - + if( !dest ) { G_Printf( "Couldn't find teleporter destination\n" ); @@ -239,7 +239,7 @@ void target_relay_use( gentity_t *self, gentity_t *other, gentity_t *activator ) ent = G_PickTarget( self->target ); if( ent && ent->use ) ent->use( ent, self, activator ); - + return; } @@ -328,31 +328,31 @@ target_rumble_think */ void target_rumble_think( gentity_t *self ) { - int i; - gentity_t *ent; - - if( self->last_move_time < level.time ) - self->last_move_time = level.time + 0.5; - - for( i = 0, ent = g_entities + i; i < level.num_entities; i++, ent++ ) - { - if( !ent->inuse ) - continue; - - if( !ent->client ) - continue; - - if( ent->client->ps.groundEntityNum == ENTITYNUM_NONE ) - continue; - - ent->client->ps.groundEntityNum = ENTITYNUM_NONE; - ent->client->ps.velocity[ 0 ] += crandom( ) * 150; - ent->client->ps.velocity[ 1 ] += crandom( ) * 150; - ent->client->ps.velocity[ 2 ] = self->speed; - } - - if( level.time < self->timestamp ) - self->nextthink = level.time + FRAMETIME; + int i; + gentity_t *ent; + + if( self->last_move_time < level.time ) + self->last_move_time = level.time + 0.5; + + for( i = 0, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + { + if( !ent->inuse ) + continue; + + if( !ent->client ) + continue; + + if( ent->client->ps.groundEntityNum == ENTITYNUM_NONE ) + continue; + + ent->client->ps.groundEntityNum = ENTITYNUM_NONE; + ent->client->ps.velocity[ 0 ] += crandom( ) * 150; + ent->client->ps.velocity[ 1 ] += crandom( ) * 150; + ent->client->ps.velocity[ 2 ] = self->speed; + } + + if( level.time < self->timestamp ) + self->nextthink = level.time + FRAMETIME; } /* @@ -362,10 +362,10 @@ target_rumble_use */ void target_rumble_use( gentity_t *self, gentity_t *other, gentity_t *activator ) { - self->timestamp = level.time + ( self->count * FRAMETIME ); - self->nextthink = level.time + FRAMETIME; - self->activator = activator; - self->last_move_time = 0; + self->timestamp = level.time + ( self->count * FRAMETIME ); + self->nextthink = level.time + FRAMETIME; + self->activator = activator; + self->last_move_time = 0; } /* @@ -375,18 +375,18 @@ SP_target_rumble */ void SP_target_rumble( gentity_t *self ) { - if( !self->targetname ) + if( !self->targetname ) { - G_Printf( S_COLOR_YELLOW "WARNING: untargeted %s at %s\n", self->classname, + G_Printf( S_COLOR_YELLOW "WARNING: untargeted %s at %s\n", self->classname, vtos( self->s.origin ) ); } - if( !self->count ) - self->count = 10; + if( !self->count ) + self->count = 10; - if( !self->speed ) - self->speed = 100; + if( !self->speed ) + self->speed = 100; - self->think = target_rumble_think; - self->use = target_rumble_use; + self->think = target_rumble_think; + self->use = target_rumble_use; } diff --git a/src/game/g_team.c b/src/game/g_team.c index f4e035b9..ffe28c39 100644 --- a/src/game/g_team.c +++ b/src/game/g_team.c @@ -24,7 +24,7 @@ void QDECL PrintMsg( gentity_t *ent, const char *fmt, ... ) char *p; va_start( argptr,fmt ); - + if( vsprintf( msg, fmt, argptr ) > sizeof( msg ) ) G_Error ( "PrintMsg overrun" ); @@ -112,10 +112,10 @@ qboolean Team_GetLocationMsg( gentity_t *ent, char *loc, int loclen ) { if( best->count < 0 ) best->count = 0; - + if( best->count > 7 ) best->count = 7; - + Com_sprintf( loc, loclen, "%c%c%s" S_COLOR_WHITE, Q_COLOR_ESCAPE, best->count + '0', best->message ); } else @@ -162,7 +162,7 @@ void TeamplayInfoMessage( gentity_t *ent ) for( i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++ ) { player = g_entities + level.sortedClients[ i ]; - + if( player->inuse && player->client->sess.sessionTeam == ent->client->sess.sessionTeam ) clients[ cnt++ ] = level.sortedClients[ i ]; @@ -178,12 +178,12 @@ void TeamplayInfoMessage( gentity_t *ent ) for( i = 0, cnt = 0; i < g_maxclients.integer && cnt < TEAM_MAXOVERLAY; i++) { player = g_entities + i; - + if( player->inuse && player->client->sess.sessionTeam == ent->client->sess.sessionTeam ) { h = player->client->ps.stats[ STAT_HEALTH ]; - + if( h < 0 ) h = 0; @@ -192,12 +192,12 @@ void TeamplayInfoMessage( gentity_t *ent ) // level.sortedClients[i], player->client->pers.teamState.location, h, a, i, player->client->pers.teamState.location, h, a, player->client->ps.weapon, player->s.powerups ); - + j = strlen( entry ); - + if( stringlength + j > sizeof( string ) ) break; - + strcpy( string + stringlength, entry ); stringlength += j; cnt++; @@ -227,7 +227,7 @@ void CheckTeamStatus( void ) { loc = Team_GetLocation( ent ); - + if( loc ) ent->client->pers.teamState.location = loc->health; else diff --git a/src/game/g_trigger.c b/src/game/g_trigger.c index aff816dc..e928cc69 100644 --- a/src/game/g_trigger.c +++ b/src/game/g_trigger.c @@ -149,8 +149,6 @@ void trigger_push_touch( gentity_t *self, gentity_t *other, trace_t *trace ) { if( !other->client ) return; - - BG_TouchJumpPad( &other->client->ps, &self->s ); } @@ -172,7 +170,7 @@ void AimAtTarget( gentity_t *self ) VectorScale( origin, 0.5, origin ); ent = G_PickTarget( self->target ); - + if( !ent ) { G_FreeEntity( self ); @@ -182,7 +180,7 @@ void AimAtTarget( gentity_t *self ) height = ent->s.origin[ 2 ] - origin[ 2 ]; gravity = g_gravity.value; time = sqrt( height / ( 0.5 * gravity ) ); - + if( !time ) { G_FreeEntity( self ); @@ -266,7 +264,7 @@ void SP_target_push( gentity_t *self ) self->think = AimAtTarget; self->nextthink = level.time + FRAMETIME; } - + self->use = Use_target_push; } @@ -284,7 +282,7 @@ void trigger_teleporter_touch( gentity_t *self, gentity_t *other, trace_t *trace if( !other->client ) return; - + if( other->client->ps.pm_type == PM_DEAD ) return; @@ -295,7 +293,7 @@ void trigger_teleporter_touch( gentity_t *self, gentity_t *other, trace_t *trace dest = G_PickTarget( self->target ); - + if( !dest ) { G_Printf( "Couldn't find teleporter destination\n" ); @@ -386,7 +384,7 @@ void hurt_touch( gentity_t *self, gentity_t *other, trace_t *trace ) dflags = DAMAGE_NO_PROTECTION; else dflags = 0; - + G_Damage( other, self, self, NULL, NULL, self->damage, dflags, MOD_TRIGGER_HURT ); } @@ -572,7 +570,7 @@ void trigger_buildable_trigger( gentity_t *self, gentity_t *activator ) } } } - + if( self->wait > 0 ) { self->think = multi_wait; @@ -598,7 +596,7 @@ void trigger_buildable_touch( gentity_t *ent, gentity_t *other, trace_t *trace ) //only triggered by buildables if( other->s.eType != ET_BUILDABLE ) return; - + trigger_buildable_trigger( ent, other ); } @@ -632,9 +630,9 @@ void SP_trigger_buildable( gentity_t *self ) self->random = self->wait - FRAMETIME; G_Printf( S_COLOR_YELLOW "WARNING: trigger_buildable has random >= wait\n" ); } - + G_SpawnString( "buildables", "", &buffer ); - + p = q = buffer; while( *p != '\0' ) @@ -645,19 +643,19 @@ void SP_trigger_buildable( gentity_t *self ) if( *p == '\0' ) EOS = qtrue; - + *p = '\0'; //strip leading whitespace while( *q == ' ' ) q++; - + self->bTriggers[ i ] = BG_FindBuildNumForName( q ); if( self->bTriggers[ i ] == BA_NONE ) G_Printf( S_COLOR_YELLOW "WARNING: unknown buildable %s in trigger_buildable\n", q ); else i++; - + if( !EOS ) { p++; @@ -668,7 +666,7 @@ void SP_trigger_buildable( gentity_t *self ) } self->bTriggers[ i ] = BA_NONE; - + self->touch = trigger_buildable_touch; self->use = trigger_buildable_use; @@ -689,10 +687,10 @@ void trigger_class_trigger( gentity_t *self, gentity_t *activator ) //sanity check if( !activator->client ) return; - + if( activator->client->ps.stats[ STAT_PTEAM ] != PTE_ALIENS ) return; - + self->activator = activator; if( self->nextthink ) return; // can't retrigger until the wait is over @@ -712,7 +710,7 @@ void trigger_class_trigger( gentity_t *self, gentity_t *activator ) } } } - + if( self->wait > 0 ) { self->think = multi_wait; @@ -738,7 +736,7 @@ void trigger_class_touch( gentity_t *ent, gentity_t *other, trace_t *trace ) //only triggered by clients if( !other->client ) return; - + trigger_class_trigger( ent, other ); } @@ -772,9 +770,9 @@ void SP_trigger_class( gentity_t *self ) self->random = self->wait - FRAMETIME; G_Printf( S_COLOR_YELLOW "WARNING: trigger_class has random >= wait\n" ); } - + G_SpawnString( "classes", "", &buffer ); - + p = q = buffer; while( *p != '\0' ) @@ -785,19 +783,19 @@ void SP_trigger_class( gentity_t *self ) if( *p == '\0' ) EOS = qtrue; - + *p = '\0'; //strip leading whitespace while( *q == ' ' ) q++; - + self->cTriggers[ i ] = BG_FindClassNumForName( q ); if( self->cTriggers[ i ] == PCL_NONE ) G_Printf( S_COLOR_YELLOW "WARNING: unknown class %s in trigger_class\n", q ); else i++; - + if( !EOS ) { p++; @@ -808,7 +806,7 @@ void SP_trigger_class( gentity_t *self ) } self->cTriggers[ i ] = PCL_NONE; - + self->touch = trigger_class_touch; self->use = trigger_class_use; @@ -832,7 +830,7 @@ void trigger_equipment_trigger( gentity_t *self, gentity_t *activator ) if( activator->client->ps.stats[ STAT_PTEAM ] != PTE_HUMANS ) return; - + self->activator = activator; if( self->nextthink ) return; // can't retrigger until the wait is over @@ -851,7 +849,7 @@ void trigger_equipment_trigger( gentity_t *self, gentity_t *activator ) return; } } - + for( i = 0; self->uTriggers[ i ] != UP_NONE; i++ ) { if( BG_InventoryContainsUpgrade( self->uTriggers[ i ], activator->client->ps.stats ) ) @@ -861,7 +859,7 @@ void trigger_equipment_trigger( gentity_t *self, gentity_t *activator ) } } } - + if( self->wait > 0 ) { self->think = multi_wait; @@ -887,7 +885,7 @@ void trigger_equipment_touch( gentity_t *ent, gentity_t *other, trace_t *trace ) //only triggered by clients if( !other->client ) return; - + trigger_equipment_trigger( ent, other ); } @@ -921,9 +919,9 @@ void SP_trigger_equipment( gentity_t *self ) self->random = self->wait - FRAMETIME; G_Printf( S_COLOR_YELLOW "WARNING: trigger_equipment has random >= wait\n" ); } - + G_SpawnString( "equipment", "", &buffer ); - + p = q = buffer; while( *p != '\0' ) @@ -934,23 +932,23 @@ void SP_trigger_equipment( gentity_t *self ) if( *p == '\0' ) EOS = qtrue; - + *p = '\0'; //strip leading whitespace while( *q == ' ' ) q++; - + self->wTriggers[ i ] = BG_FindWeaponNumForName( q ); self->uTriggers[ j ] = BG_FindUpgradeNumForName( q ); - + if( self->wTriggers[ i ] == WP_NONE && self->uTriggers[ j ] == UP_NONE ) G_Printf( S_COLOR_YELLOW "WARNING: unknown equipment %s in trigger_class\n", q ); else if( self->wTriggers[ i ] != WP_NONE ) i++; else if( self->uTriggers[ j ] != UP_NONE ) j++; - + if( !EOS ) { p++; @@ -962,7 +960,7 @@ void SP_trigger_equipment( gentity_t *self ) self->wTriggers[ i ] = WP_NONE; self->uTriggers[ j ] = UP_NONE; - + self->touch = trigger_equipment_touch; self->use = trigger_equipment_use; @@ -981,7 +979,7 @@ void trigger_gravity_touch( gentity_t *ent, gentity_t *other, trace_t *trace ) //only triggered by clients if( !other->client ) return; - + other->client->ps.gravity = ent->triggerGravity; } @@ -1007,7 +1005,7 @@ SP_trigger_gravity void SP_trigger_gravity( gentity_t *self ) { G_SpawnInt( "gravity", "800", &self->triggerGravity ); - + self->touch = trigger_gravity_touch; self->use = trigger_gravity_use; @@ -1049,14 +1047,14 @@ void trigger_heal_touch( gentity_t *self, gentity_t *other, trace_t *trace ) else self->timestamp = level.time + FRAMETIME; - max = other->client->ps.stats[ STAT_MAX_HEALTH ]; - + max = other->client->ps.stats[ STAT_MAX_HEALTH ]; + other->health += self->damage; - if( other->health > max ) - other->health = max; - - other->client->ps.stats[ STAT_HEALTH ] = other->health; + if( other->health > max ) + other->health = max; + + other->client->ps.stats[ STAT_HEALTH ] = other->health; } /* @@ -1067,7 +1065,7 @@ SP_trigger_heal void SP_trigger_heal( gentity_t *self ) { G_SpawnInt( "heal", "5", &self->damage ); - + self->touch = trigger_heal_touch; self->use = trigger_heal_use; @@ -1102,10 +1100,10 @@ void trigger_ammo_touch( gentity_t *self, gentity_t *other, trace_t *trace ) if( BG_FindUsesEnergyForWeapon( other->client->ps.weapon ) && self->spawnflags & 2 ) return; - + if( !BG_FindUsesEnergyForWeapon( other->client->ps.weapon ) && self->spawnflags & 4 ) return; - + if( self->spawnflags & 1 ) self->timestamp = level.time + 1000; else @@ -1127,7 +1125,7 @@ void trigger_ammo_touch( gentity_t *self, gentity_t *other, trace_t *trace ) } else ammo += self->damage; - + BG_PackAmmoArray( other->client->ps.weapon, other->client->ps.ammo, other->client->ps.powerups, ammo, clips ); } @@ -1140,7 +1138,7 @@ SP_trigger_ammo void SP_trigger_ammo( gentity_t *self ) { G_SpawnInt( "ammo", "1", &self->damage ); - + self->touch = trigger_ammo_touch; InitTrigger( self ); diff --git a/src/game/g_utils.c b/src/game/g_utils.c index a7d66fd5..fa4b5f23 100644 --- a/src/game/g_utils.c +++ b/src/game/g_utils.c @@ -43,7 +43,7 @@ void AddRemap( const char *oldShader, const char *newShader, float timeOffset ) return; } } - + if( remapCount < MAX_SHADER_REMAPS ) { strcpy( remappedShaders[ remapCount ].newShader,newShader ); @@ -58,9 +58,9 @@ const char *BuildShaderStateConfig( ) static char buff[ MAX_STRING_CHARS * 4 ]; char out[ ( MAX_QPATH * 2 ) + 5 ]; int i; - + memset( buff, 0, MAX_STRING_CHARS ); - + for( i = 0; i < remapCount; i++ ) { Com_sprintf( out, ( MAX_QPATH * 2 ) + 5, "%s=%s:%5.2f@", remappedShaders[ i ].oldShader, @@ -103,7 +103,7 @@ int G_FindConfigstringIndex( char *name, int start, int max, qboolean create ) return i; } - if( !create ) + if( !create ) return 0; if( i == max ) @@ -187,10 +187,10 @@ gentity_t *G_Find( gentity_t *from, int fieldofs, const char *match ) if( !from->inuse ) continue; s = *(char **)( (byte *)from + fieldofs ); - + if( !s ) continue; - + if( !Q_stricmp( s, match ) ) return from; } @@ -223,12 +223,12 @@ gentity_t *G_PickTarget( char *targetname ) while( 1 ) { ent = G_Find( ent, FOFS( targetname ), targetname ); - + if( !ent ) break; - + choice[ num_choices++ ] = ent; - + if( num_choices == MAXCHOICES ) break; } @@ -257,7 +257,7 @@ match (string)self.target and call their .use function void G_UseTargets( gentity_t *ent, gentity_t *activator ) { gentity_t *t; - + if( !ent ) return; @@ -281,7 +281,7 @@ void G_UseTargets( gentity_t *ent, gentity_t *activator ) if( t->use ) t->use( t, ent, activator ); } - + if( !ent->inuse ) { G_Printf( "entity was removed while using targets\n" ); @@ -365,7 +365,7 @@ void G_SetMovedir( vec3_t angles, vec3_t movedir ) VectorCopy( MOVEDIR_DOWN, movedir ); else AngleVectors( angles, movedir, NULL, NULL ); - + VectorClear( angles ); } @@ -373,7 +373,7 @@ void G_SetMovedir( vec3_t angles, vec3_t movedir ) float vectoyaw( const vec3_t vec ) { float yaw; - + if( vec[ YAW ] == 0 && vec[ PITCH ] == 0 ) { yaw = 0; @@ -425,13 +425,13 @@ gentity_t *G_Spawn( void ) e = NULL; // shut up warning i = 0; // shut up warning - + for( force = 0; force < 2; force++ ) { // if we go through all entities and can't find one to free, // override the normal minimum times before use e = &g_entities[ MAX_CLIENTS ]; - + for( i = MAX_CLIENTS; i < level.num_entities; i++, e++ ) { if( e->inuse ) @@ -446,24 +446,24 @@ gentity_t *G_Spawn( void ) G_InitGentity( e ); return e; } - + if( i != MAX_GENTITIES ) break; } - + if( i == ENTITYNUM_MAX_NORMAL ) { for( i = 0; i < MAX_GENTITIES; i++ ) G_Printf( "%4i: %s\n", i, g_entities[ i ].classname ); - + G_Error( "G_Spawn: no free entities" ); } - + // open up a new slot level.num_entities++; // let the server system know that there are more entities - trap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ), + trap_LocateGameData( level.gentities, level.num_entities, sizeof( gentity_t ), &level.clients[ 0 ].ps, sizeof( level.clients[ 0 ] ) ); G_InitGentity( e ); @@ -482,7 +482,7 @@ qboolean G_EntitiesFree( void ) gentity_t *e; e = &g_entities[ MAX_CLIENTS ]; - + for( i = MAX_CLIENTS; i < level.num_entities; i++, e++ ) { if( e->inuse ) @@ -491,7 +491,7 @@ qboolean G_EntitiesFree( void ) // slot available return qtrue; } - + return qfalse; } @@ -579,14 +579,14 @@ void G_KillBox( gentity_t *ent ) for( i = 0; i < num; i++ ) { hit = &g_entities[ touch[ i ] ]; - + if( !hit->client ) continue; //TA: impossible to telefrag self if( ent == hit ) continue; - + // nail it G_Damage( hit, ent, ent, NULL, NULL, 100000, DAMAGE_NO_PROTECTION, MOD_TELEFRAG ); @@ -805,7 +805,7 @@ static qboolean G_ReadyToDequeue( commandQueue_t *cq ) { if( !cq ) return qfalse; - + return cq->front && cq->nextCommandTime <= level.time; } @@ -828,7 +828,7 @@ void G_ProcessCommandQueues( void ) if( !G_ClientIsLagging( cl ) && G_ReadyToDequeue( cq ) ) { const char *command = G_PopCommandQueue( cq ); - + if( command ) trap_SendServerCommand( i, command ); } @@ -844,12 +844,12 @@ void G_InitCommandQueue( int clientNum ) { int i; commandQueue_t *cq = &queuedCommands[ clientNum ]; - + if( clientNum >= 0 && clientNum < MAX_CLIENTS ) { cq->front = cq->back = NULL; cq->nextCommandTime = 0; - + for( i = 0; i < MAX_QUEUE_COMMANDS; i++ ) { commandQueueElement_t *cqe = &cq->pool[ i ]; @@ -872,18 +872,18 @@ void G_SendCommandFromServer( int clientNum, const char *cmd ) if( clientNum < 0 ) cq = NULL; - + if( strlen( cmd ) > 1022 ) { G_LogPrintf( "G_SendCommandFromServer( %d, ... ) length exceeds 1022.\n", clientNum ); G_LogPrintf( "cmd [%s]\n", cmd ); return; - } - + } + if( cq ) { gclient_t *cl = &level.clients[ clientNum ]; - + if( cq->nextCommandTime > level.time || G_ClientIsLagging( cl ) ) { //can't send yet, so queue the command up @@ -928,20 +928,20 @@ gentity_t *G_FindRadius( gentity_t *from, vec3_t org, float rad ) { vec3_t eorg; int j; - + if( !from ) from = g_entities; else from++; - + for( ; from < &g_entities[ level.num_entities ]; from++ ) { if( !from->inuse ) continue; - + for( j = 0; j < 3; j++ ) eorg[ j ] = org[ j ] - ( from->r.currentOrigin[ j ] + ( from->r.mins[ j ] + from->r.maxs[ j ] ) * 0.5 ); - + if( VectorLength( eorg ) > rad ) continue; @@ -963,10 +963,10 @@ qboolean G_Visible( gentity_t *ent1, gentity_t *ent2 ) trace_t trace; trap_Trace( &trace, ent1->s.pos.trBase, NULL, NULL, ent2->s.pos.trBase, ent1->s.number, MASK_SHOT ); - + if( trace.contents & CONTENTS_SOLID ) return qfalse; - + return qtrue; } @@ -982,7 +982,7 @@ gentity_t *G_ClosestEnt( vec3_t origin, gentity_t **entities, int numEntities ) int i; float nd, d = 1000000.0f; gentity_t *closestEnt = NULL; - + for( i = 0; i < numEntities; i++ ) { gentity_t *ent = entities[ i ]; @@ -1053,7 +1053,7 @@ int DebugLine( vec3_t start, vec3_t end, int color ) VectorSubtract( end, start, dir ); VectorNormalize( dir ); dot = DotProduct( dir, up ); - + if( dot > 0.99 || dot < -0.99 ) VectorSet( cross, 1, 0, 0 ); else diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c index ed1b67cb..34174e4d 100644 --- a/src/game/g_weapon.c +++ b/src/game/g_weapon.c @@ -29,11 +29,11 @@ G_ForceWeaponChange void G_ForceWeaponChange( gentity_t *ent, weapon_t weapon ) { int i; - + if( ent ) { ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH; - + if( weapon == WP_NONE ) { //switch to the first non blaster weapon @@ -41,14 +41,14 @@ void G_ForceWeaponChange( gentity_t *ent, weapon_t weapon ) { if( i == WP_BLASTER ) continue; - + if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) ) { ent->client->ps.persistant[ PERS_NEWWEAPON ] = i; break; } } - + //only got the blaster to switch to if( i == WP_NUM_WEAPONS ) ent->client->ps.persistant[ PERS_NEWWEAPON ] = WP_BLASTER; @@ -75,25 +75,25 @@ void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo ) weaponType = BG_FindUsesEnergyForWeapon( i ); else weaponType = !BG_FindUsesEnergyForWeapon( i ); - + if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) && weaponType && !BG_FindInfinteAmmoForWeapon( i ) && !BG_WeaponIsFull( i, ent->client->ps.stats, ent->client->ps.ammo, ent->client->ps.powerups ) ) { BG_FindAmmoForWeapon( i, &maxAmmo, &maxClips ); - + if( buyingEnergyAmmo ) { G_AddEvent( ent, EV_RPTUSE_SOUND, 0 ); - + if( BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) ) maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER ); } BG_PackAmmoArray( i, ent->client->ps.ammo, ent->client->ps.powerups, maxAmmo, maxClips ); - + restoredAmmo = qtrue; } } @@ -250,28 +250,28 @@ SHOTGUN // this should match CG_ShotgunPattern void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) { - int i; - float r, u; - vec3_t end; - vec3_t forward, right, up; - trace_t tr; - gentity_t *traceEnt; - - // derive the right and up vectors from the forward vector, because - // the client won't have any other information - VectorNormalize2( origin2, forward ); - PerpendicularVector( right, forward ); - CrossProduct( forward, right, up ); - - // generate the "random" spread pattern - for( i = 0; i < SHOTGUN_PELLETS; i++ ) + int i; + float r, u; + vec3_t end; + vec3_t forward, right, up; + trace_t tr; + gentity_t *traceEnt; + + // derive the right and up vectors from the forward vector, because + // the client won't have any other information + VectorNormalize2( origin2, forward ); + PerpendicularVector( right, forward ); + CrossProduct( forward, right, up ); + + // generate the "random" spread pattern + for( i = 0; i < SHOTGUN_PELLETS; i++ ) { - r = Q_crandom( &seed ) * SHOTGUN_SPREAD * 16; - u = Q_crandom( &seed ) * SHOTGUN_SPREAD * 16; - VectorMA( origin, 8192 * 16, forward, end ); - VectorMA( end, r, right, end ); - VectorMA( end, u, up, end ); - + r = Q_crandom( &seed ) * SHOTGUN_SPREAD * 16; + u = Q_crandom( &seed ) * SHOTGUN_SPREAD * 16; + VectorMA( origin, 8192 * 16, forward, end ); + VectorMA( end, r, right, end ); + VectorMA( end, u, up, end ); + trap_Trace( &tr, origin, NULL, NULL, end, ent->s.number, MASK_SHOT ); traceEnt = &g_entities[ tr.entityNum ]; @@ -279,24 +279,24 @@ void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, gentity_t *ent ) if( !( tr.surfaceFlags & SURF_NOIMPACT ) ) { if( traceEnt->takedamage ) - G_Damage( traceEnt, ent, ent, forward, tr.endpos, SHOTGUN_DMG, 0, MOD_SHOTGUN ); + G_Damage( traceEnt, ent, ent, forward, tr.endpos, SHOTGUN_DMG, 0, MOD_SHOTGUN ); } - } + } } void shotgunFire( gentity_t *ent ) { - gentity_t *tent; + gentity_t *tent; - // send shotgun blast - tent = G_TempEntity( muzzle, EV_SHOTGUN ); - VectorScale( forward, 4096, tent->s.origin2 ); - SnapVector( tent->s.origin2 ); - tent->s.eventParm = rand() & 255; // seed for spread pattern - tent->s.otherEntityNum = ent->s.number; + // send shotgun blast + tent = G_TempEntity( muzzle, EV_SHOTGUN ); + VectorScale( forward, 4096, tent->s.origin2 ); + SnapVector( tent->s.origin2 ); + tent->s.eventParm = rand() & 255; // seed for spread pattern + tent->s.otherEntityNum = ent->s.number; - ShotgunPattern( tent->s.pos.trBase, tent->s.origin2, tent->s.eventParm, ent ); + ShotgunPattern( tent->s.pos.trBase, tent->s.origin2, tent->s.eventParm, ent ); } /* @@ -532,11 +532,11 @@ void painSawFire( gentity_t *ent ) if( traceEnt->takedamage ) { vec3_t temp; - + //hack to get the particle system to line up with the weapon VectorCopy( tr.endpos, temp ); temp[ 2 ] -= 10.0f; - + if( traceEnt->client ) { tent = G_TempEntity( temp, EV_MISSILE_HIT ); @@ -544,7 +544,7 @@ void painSawFire( gentity_t *ent ) } else tent = G_TempEntity( temp, EV_MISSILE_MISS ); - + tent->s.eventParm = DirToByte( tr.plane.normal ); tent->s.weapon = ent->s.weapon; tent->s.generic1 = ent->s.generic1; //weaponMode @@ -575,7 +575,7 @@ void LCChargeFire( gentity_t *ent, qboolean secondary ) m = fire_luciferCannon( ent, muzzle, forward, LCANNON_SECONDARY_DAMAGE, LCANNON_SECONDARY_RADIUS ); else m = fire_luciferCannon( ent, muzzle, forward, ent->client->ps.stats[ STAT_MISC ], LCANNON_RADIUS ); - + ent->client->ps.stats[ STAT_MISC ] = 0; } @@ -611,7 +611,7 @@ void teslaFire( gentity_t *ent ) //so the client side knows ent->s.eFlags |= EF_FIRING; - + if( traceEnt->takedamage ) { G_Damage( traceEnt, ent, ent, forward, tr.endpos, @@ -625,10 +625,10 @@ void teslaFire( gentity_t *ent ) tent = G_TempEntity( tr.endpos, EV_TESLATRAIL ); VectorCopy( muzzle, tent->s.origin2 ); - + tent->s.generic1 = ent->s.number; //src tent->s.clientNum = traceEnt->s.number; //dest - + // move origin a bit to come closer to the drawn gun muzzle VectorMA( tent->s.origin2, 28, up, tent->s.origin2 ); @@ -665,7 +665,7 @@ void cancelBuildFire( gentity_t *ent ) ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; return; } - + //repair buildable if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { @@ -720,7 +720,7 @@ void buildFire( gentity_t *ent, dynMenu_t menu ) G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum ); return; } - + if( G_ValidateBuild( ent, ent->client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT ) ) { if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS && !G_isOvermind( ) ) @@ -737,7 +737,7 @@ void buildFire( gentity_t *ent, dynMenu_t menu ) else ent->client->ps.stats[ STAT_MISC ] += BG_FindBuildDelayForWeapon( ent->s.weapon ); - + ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; // don't want it bigger than 32k @@ -801,7 +801,7 @@ qboolean CheckVenomAttack( gentity_t *ent ) if( !traceEnt->takedamage ) return qfalse; - + if( !traceEnt->client && !traceEnt->s.eType == ET_BUILDABLE ) return qfalse; @@ -815,7 +815,7 @@ qboolean CheckVenomAttack( gentity_t *ent ) //hackery damage *= 0.5f; } - + if( traceEnt->client ) { if( traceEnt->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) @@ -873,12 +873,12 @@ void CheckGrabAttack( gentity_t *ent ) if( !traceEnt->takedamage ) return; - + if( traceEnt->client ) { if( traceEnt->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) return; - + if( traceEnt->client->ps.stats[ STAT_HEALTH ] <= 0 ) return; @@ -886,11 +886,11 @@ void CheckGrabAttack( gentity_t *ent ) { AngleVectors( traceEnt->client->ps.viewangles, dir, NULL, NULL ); traceEnt->client->ps.stats[ STAT_VIEWLOCK ] = DirToByte( dir ); - + //event for client side grab effect G_AddPredictableEvent( ent, EV_LEV1_GRAB, 0 ); } - + traceEnt->client->ps.stats[ STAT_STATE ] |= SS_GRABBED; if( ent->client->ps.weapon == WP_ALEVEL1 ) @@ -922,25 +922,25 @@ void poisonCloud( gentity_t *ent ) int i, num; gentity_t *humanPlayer; trace_t tr; - + VectorAdd( ent->client->ps.origin, range, maxs ); VectorSubtract( ent->client->ps.origin, range, mins ); - + num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { humanPlayer = &g_entities[ entityList[ i ] ]; - + if( humanPlayer->client && humanPlayer->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { if( BG_InventoryContainsUpgrade( UP_LIGHTARMOUR, humanPlayer->client->ps.stats ) ) continue; - + if( BG_InventoryContainsUpgrade( UP_BATTLESUIT, humanPlayer->client->ps.stats ) ) continue; - + trap_Trace( &tr, muzzle, NULL, NULL, humanPlayer->s.origin, humanPlayer->s.number, MASK_SHOT ); - + //can't see target from here if( tr.entityNum == ENTITYNUM_WORLD ) continue; @@ -986,21 +986,21 @@ static gentity_t *G_FindNewZapTarget( gentity_t *ent ) VectorScale( range, 1.0f / M_ROOT3, range ); VectorAdd( ent->s.origin, range, maxs ); VectorSubtract( ent->s.origin, range, mins ); - + num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) { enemy = &g_entities[ entityList[ i ] ]; - + if( ( ( enemy->client && enemy->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) || ( enemy->s.eType == ET_BUILDABLE && BG_FindTeamForBuildable( enemy->s.modelindex ) == BIT_HUMANS ) ) && enemy->health > 0 ) { qboolean foundOldTarget = qfalse; - + trap_Trace( &tr, muzzle, NULL, NULL, enemy->s.origin, ent->s.number, MASK_SHOT ); - + //can't see target from here if( tr.entityNum == ENTITYNUM_WORLD ) continue; @@ -1025,7 +1025,7 @@ static gentity_t *G_FindNewZapTarget( gentity_t *ent ) // enemy is already targetted if( foundOldTarget ) continue; - + return enemy; } } @@ -1042,7 +1042,7 @@ static void G_UpdateZapEffect( zap_t *zap ) { int j; gentity_t *effect = zap->effectChannel; - + effect->s.eType = ET_LEV2_ZAP_CHAIN; effect->classname = "lev2zapchain"; G_SetOrigin( effect, zap->creator->s.origin ); @@ -1053,7 +1053,7 @@ static void G_UpdateZapEffect( zap_t *zap ) for( j = 0; j < zap->numTargets; j++ ) { int number = zap->targets[ j ]->s.number; - + switch( j ) { case 0: effect->s.time = number; break; @@ -1083,22 +1083,22 @@ static void G_CreateNewZap( gentity_t *creator, gentity_t *target ) if( !zap->used ) { zap->used = qtrue; - + zap->timeToLive = LEVEL2_AREAZAP_TIME; - + zap->creator = creator; - + zap->targets[ 0 ] = target; zap->numTargets = 1; for( j = 1; j < MAX_ZAP_TARGETS && zap->targets[ j - 1 ]; j++ ) { zap->targets[ j ] = G_FindNewZapTarget( zap->targets[ j - 1 ] ); - + if( zap->targets[ j ] ) zap->numTargets++; } - + zap->effectChannel = G_Spawn( ); G_UpdateZapEffect( zap ); @@ -1135,7 +1135,7 @@ void G_UpdateZaps( int msec ) source = zap->creator; else source = zap->targets[ j - 1 ]; - + if( target->health <= 0 || !target->inuse || //early out VectorDistance( source->s.origin, target->s.origin ) > LEVEL2_AREAZAP_RANGE ) { @@ -1145,7 +1145,6 @@ void G_UpdateZaps( int msec ) if( !target ) zap->numTargets = j; } - } if( zap->numTargets ) @@ -1154,26 +1153,30 @@ void G_UpdateZaps( int msec ) { gentity_t *source; gentity_t *target = zap->targets[ j ]; - float r = 1.0f / zap->numTargets; - float damageFraction = 2 * r - 2 * j * r * r - r * r; - + float r = 1.0f / zap->numTargets; + float damageFraction = 2 * r - 2 * j * r * r - r * r; + vec3_t forward; + if( j == 0 ) source = zap->creator; else source = zap->targets[ j - 1 ]; - + damage = ceil( ( (float)msec / LEVEL2_AREAZAP_TIME ) * LEVEL2_AREAZAP_DMG * damageFraction ); + VectorSubtract( target->s.origin, source->s.origin, forward ); + VectorNormalize( forward ); + //do the damage if( damage ) - G_Damage( target, source, zap->creator, NULL, NULL, + G_Damage( target, source, zap->creator, forward, target->s.origin, damage, DAMAGE_NO_KNOCKBACK | DAMAGE_NO_LOCDAMAGE, MOD_LEVEL2_ZAP ); } } - + G_UpdateZapEffect( zap ); - + zap->timeToLive -= msec; if( zap->timeToLive <= 0 || zap->numTargets == 0 || zap->creator->health <= 0 ) @@ -1208,7 +1211,7 @@ void areaZapFire( gentity_t *ent ) VectorMA( muzzle, LEVEL2_AREAZAP_RANGE, forward, end ); trap_Trace( &tr, muzzle, mins, maxs, end, ent->s.number, MASK_SHOT ); - + if( tr.surfaceFlags & SURF_NOIMPACT ) return; @@ -1264,12 +1267,12 @@ qboolean CheckPounceAttack( gentity_t *ent ) VectorMA( muzzle, LEVEL3_POUNCE_RANGE, forward, end ); - trap_Trace( &tr, muzzle, mins, maxs, end, ent->s.number, MASK_SHOT ); + trap_Trace( &tr, ent->s.origin, mins, maxs, end, ent->s.number, MASK_SHOT ); //miss if( tr.fraction >= 1.0 ) return qfalse; - + if( tr.surfaceFlags & SURF_NOIMPACT ) return qfalse; @@ -1293,7 +1296,7 @@ qboolean CheckPounceAttack( gentity_t *ent ) G_Damage( traceEnt, ent, ent, forward, tr.endpos, damage, DAMAGE_NO_KNOCKBACK, MOD_LEVEL3_POUNCE ); ent->client->allowedToPounce = qfalse; - + return qtrue; } @@ -1325,16 +1328,16 @@ void ChargeAttack( gentity_t *ent, gentity_t *victim ) gentity_t *tent; int damage; vec3_t forward, normal; - + if( level.time < victim->chargeRepeat ) return; victim->chargeRepeat = level.time + LEVEL4_CHARGE_REPEAT; - + VectorSubtract( victim->s.origin, ent->s.origin, forward ); VectorNormalize( forward ); VectorNegate( forward, normal ); - + if( victim->client ) { tent = G_TempEntity( victim->s.origin, EV_MISSILE_HIT ); @@ -1346,7 +1349,7 @@ void ChargeAttack( gentity_t *ent, gentity_t *victim ) if( !victim->takedamage ) return; - + damage = (int)( ( (float)ent->client->ps.stats[ STAT_MISC ] / (float)LEVEL4_CHARGE_TIME ) * LEVEL4_CHARGE_DMG ); G_Damage( victim, ent, ent, forward, victim->s.origin, damage, 0, MOD_LEVEL4_CHARGE ); @@ -1396,11 +1399,11 @@ void FireWeapon3( gentity_t *ent ) case WP_ALEVEL3_UPG: bounceBallFire( ent ); break; - + case WP_ABUILD2: slowBlobFire( ent ); break; - + default: break; } @@ -1434,11 +1437,11 @@ void FireWeapon2( gentity_t *ent ) case WP_ALEVEL2_UPG: areaZapFire( ent ); break; - + case WP_LUCIFER_CANNON: LCChargeFire( ent, qtrue ); break; - + case WP_ABUILD: case WP_ABUILD2: case WP_HBUILD: @@ -1523,7 +1526,7 @@ void FireWeapon( gentity_t *ent ) case WP_GRENADE: throwGrenade( ent ); break; - + case WP_LOCKBLOB_LAUNCHER: lockBlobLauncherFire( ent ); break; @@ -1536,7 +1539,7 @@ void FireWeapon( gentity_t *ent ) case WP_MGTURRET: bulletFire( ent, MGTURRET_SPREAD, MGTURRET_DMG, MOD_MGTURRET ); break; - + case WP_ABUILD: case WP_ABUILD2: buildFire( ent, MN_A_BUILD ); diff --git a/src/game/q_math.c b/src/game/q_math.c index 2600459c..62c5a5a8 100644 --- a/src/game/q_math.c +++ b/src/game/q_math.c @@ -49,86 +49,86 @@ vec4_t g_color_table[8] = vec3_t bytedirs[NUMVERTEXNORMALS] = { -{-0.525731f, 0.000000f, 0.850651f}, {-0.442863f, 0.238856f, 0.864188f}, -{-0.295242f, 0.000000f, 0.955423f}, {-0.309017f, 0.500000f, 0.809017f}, -{-0.162460f, 0.262866f, 0.951056f}, {0.000000f, 0.000000f, 1.000000f}, -{0.000000f, 0.850651f, 0.525731f}, {-0.147621f, 0.716567f, 0.681718f}, -{0.147621f, 0.716567f, 0.681718f}, {0.000000f, 0.525731f, 0.850651f}, -{0.309017f, 0.500000f, 0.809017f}, {0.525731f, 0.000000f, 0.850651f}, -{0.295242f, 0.000000f, 0.955423f}, {0.442863f, 0.238856f, 0.864188f}, -{0.162460f, 0.262866f, 0.951056f}, {-0.681718f, 0.147621f, 0.716567f}, -{-0.809017f, 0.309017f, 0.500000f},{-0.587785f, 0.425325f, 0.688191f}, -{-0.850651f, 0.525731f, 0.000000f},{-0.864188f, 0.442863f, 0.238856f}, -{-0.716567f, 0.681718f, 0.147621f},{-0.688191f, 0.587785f, 0.425325f}, -{-0.500000f, 0.809017f, 0.309017f}, {-0.238856f, 0.864188f, 0.442863f}, -{-0.425325f, 0.688191f, 0.587785f}, {-0.716567f, 0.681718f, -0.147621f}, -{-0.500000f, 0.809017f, -0.309017f}, {-0.525731f, 0.850651f, 0.000000f}, -{0.000000f, 0.850651f, -0.525731f}, {-0.238856f, 0.864188f, -0.442863f}, -{0.000000f, 0.955423f, -0.295242f}, {-0.262866f, 0.951056f, -0.162460f}, -{0.000000f, 1.000000f, 0.000000f}, {0.000000f, 0.955423f, 0.295242f}, -{-0.262866f, 0.951056f, 0.162460f}, {0.238856f, 0.864188f, 0.442863f}, -{0.262866f, 0.951056f, 0.162460f}, {0.500000f, 0.809017f, 0.309017f}, -{0.238856f, 0.864188f, -0.442863f},{0.262866f, 0.951056f, -0.162460f}, -{0.500000f, 0.809017f, -0.309017f},{0.850651f, 0.525731f, 0.000000f}, -{0.716567f, 0.681718f, 0.147621f}, {0.716567f, 0.681718f, -0.147621f}, -{0.525731f, 0.850651f, 0.000000f}, {0.425325f, 0.688191f, 0.587785f}, -{0.864188f, 0.442863f, 0.238856f}, {0.688191f, 0.587785f, 0.425325f}, -{0.809017f, 0.309017f, 0.500000f}, {0.681718f, 0.147621f, 0.716567f}, -{0.587785f, 0.425325f, 0.688191f}, {0.955423f, 0.295242f, 0.000000f}, -{1.000000f, 0.000000f, 0.000000f}, {0.951056f, 0.162460f, 0.262866f}, -{0.850651f, -0.525731f, 0.000000f},{0.955423f, -0.295242f, 0.000000f}, -{0.864188f, -0.442863f, 0.238856f}, {0.951056f, -0.162460f, 0.262866f}, -{0.809017f, -0.309017f, 0.500000f}, {0.681718f, -0.147621f, 0.716567f}, -{0.850651f, 0.000000f, 0.525731f}, {0.864188f, 0.442863f, -0.238856f}, -{0.809017f, 0.309017f, -0.500000f}, {0.951056f, 0.162460f, -0.262866f}, +{-0.525731f, 0.000000f, 0.850651f}, {-0.442863f, 0.238856f, 0.864188f}, +{-0.295242f, 0.000000f, 0.955423f}, {-0.309017f, 0.500000f, 0.809017f}, +{-0.162460f, 0.262866f, 0.951056f}, {0.000000f, 0.000000f, 1.000000f}, +{0.000000f, 0.850651f, 0.525731f}, {-0.147621f, 0.716567f, 0.681718f}, +{0.147621f, 0.716567f, 0.681718f}, {0.000000f, 0.525731f, 0.850651f}, +{0.309017f, 0.500000f, 0.809017f}, {0.525731f, 0.000000f, 0.850651f}, +{0.295242f, 0.000000f, 0.955423f}, {0.442863f, 0.238856f, 0.864188f}, +{0.162460f, 0.262866f, 0.951056f}, {-0.681718f, 0.147621f, 0.716567f}, +{-0.809017f, 0.309017f, 0.500000f},{-0.587785f, 0.425325f, 0.688191f}, +{-0.850651f, 0.525731f, 0.000000f},{-0.864188f, 0.442863f, 0.238856f}, +{-0.716567f, 0.681718f, 0.147621f},{-0.688191f, 0.587785f, 0.425325f}, +{-0.500000f, 0.809017f, 0.309017f}, {-0.238856f, 0.864188f, 0.442863f}, +{-0.425325f, 0.688191f, 0.587785f}, {-0.716567f, 0.681718f, -0.147621f}, +{-0.500000f, 0.809017f, -0.309017f}, {-0.525731f, 0.850651f, 0.000000f}, +{0.000000f, 0.850651f, -0.525731f}, {-0.238856f, 0.864188f, -0.442863f}, +{0.000000f, 0.955423f, -0.295242f}, {-0.262866f, 0.951056f, -0.162460f}, +{0.000000f, 1.000000f, 0.000000f}, {0.000000f, 0.955423f, 0.295242f}, +{-0.262866f, 0.951056f, 0.162460f}, {0.238856f, 0.864188f, 0.442863f}, +{0.262866f, 0.951056f, 0.162460f}, {0.500000f, 0.809017f, 0.309017f}, +{0.238856f, 0.864188f, -0.442863f},{0.262866f, 0.951056f, -0.162460f}, +{0.500000f, 0.809017f, -0.309017f},{0.850651f, 0.525731f, 0.000000f}, +{0.716567f, 0.681718f, 0.147621f}, {0.716567f, 0.681718f, -0.147621f}, +{0.525731f, 0.850651f, 0.000000f}, {0.425325f, 0.688191f, 0.587785f}, +{0.864188f, 0.442863f, 0.238856f}, {0.688191f, 0.587785f, 0.425325f}, +{0.809017f, 0.309017f, 0.500000f}, {0.681718f, 0.147621f, 0.716567f}, +{0.587785f, 0.425325f, 0.688191f}, {0.955423f, 0.295242f, 0.000000f}, +{1.000000f, 0.000000f, 0.000000f}, {0.951056f, 0.162460f, 0.262866f}, +{0.850651f, -0.525731f, 0.000000f},{0.955423f, -0.295242f, 0.000000f}, +{0.864188f, -0.442863f, 0.238856f}, {0.951056f, -0.162460f, 0.262866f}, +{0.809017f, -0.309017f, 0.500000f}, {0.681718f, -0.147621f, 0.716567f}, +{0.850651f, 0.000000f, 0.525731f}, {0.864188f, 0.442863f, -0.238856f}, +{0.809017f, 0.309017f, -0.500000f}, {0.951056f, 0.162460f, -0.262866f}, {0.525731f, 0.000000f, -0.850651f}, {0.681718f, 0.147621f, -0.716567f}, -{0.681718f, -0.147621f, -0.716567f},{0.850651f, 0.000000f, -0.525731f}, -{0.809017f, -0.309017f, -0.500000f}, {0.864188f, -0.442863f, -0.238856f}, -{0.951056f, -0.162460f, -0.262866f}, {0.147621f, 0.716567f, -0.681718f}, -{0.309017f, 0.500000f, -0.809017f}, {0.425325f, 0.688191f, -0.587785f}, -{0.442863f, 0.238856f, -0.864188f}, {0.587785f, 0.425325f, -0.688191f}, -{0.688191f, 0.587785f, -0.425325f}, {-0.147621f, 0.716567f, -0.681718f}, -{-0.309017f, 0.500000f, -0.809017f}, {0.000000f, 0.525731f, -0.850651f}, -{-0.525731f, 0.000000f, -0.850651f}, {-0.442863f, 0.238856f, -0.864188f}, -{-0.295242f, 0.000000f, -0.955423f}, {-0.162460f, 0.262866f, -0.951056f}, -{0.000000f, 0.000000f, -1.000000f}, {0.295242f, 0.000000f, -0.955423f}, -{0.162460f, 0.262866f, -0.951056f}, {-0.442863f, -0.238856f, -0.864188f}, -{-0.309017f, -0.500000f, -0.809017f}, {-0.162460f, -0.262866f, -0.951056f}, -{0.000000f, -0.850651f, -0.525731f}, {-0.147621f, -0.716567f, -0.681718f}, -{0.147621f, -0.716567f, -0.681718f}, {0.000000f, -0.525731f, -0.850651f}, -{0.309017f, -0.500000f, -0.809017f}, {0.442863f, -0.238856f, -0.864188f}, -{0.162460f, -0.262866f, -0.951056f}, {0.238856f, -0.864188f, -0.442863f}, -{0.500000f, -0.809017f, -0.309017f}, {0.425325f, -0.688191f, -0.587785f}, -{0.716567f, -0.681718f, -0.147621f}, {0.688191f, -0.587785f, -0.425325f}, -{0.587785f, -0.425325f, -0.688191f}, {0.000000f, -0.955423f, -0.295242f}, -{0.000000f, -1.000000f, 0.000000f}, {0.262866f, -0.951056f, -0.162460f}, -{0.000000f, -0.850651f, 0.525731f}, {0.000000f, -0.955423f, 0.295242f}, -{0.238856f, -0.864188f, 0.442863f}, {0.262866f, -0.951056f, 0.162460f}, -{0.500000f, -0.809017f, 0.309017f}, {0.716567f, -0.681718f, 0.147621f}, -{0.525731f, -0.850651f, 0.000000f}, {-0.238856f, -0.864188f, -0.442863f}, -{-0.500000f, -0.809017f, -0.309017f}, {-0.262866f, -0.951056f, -0.162460f}, -{-0.850651f, -0.525731f, 0.000000f}, {-0.716567f, -0.681718f, -0.147621f}, -{-0.716567f, -0.681718f, 0.147621f}, {-0.525731f, -0.850651f, 0.000000f}, -{-0.500000f, -0.809017f, 0.309017f}, {-0.238856f, -0.864188f, 0.442863f}, -{-0.262866f, -0.951056f, 0.162460f}, {-0.864188f, -0.442863f, 0.238856f}, -{-0.809017f, -0.309017f, 0.500000f}, {-0.688191f, -0.587785f, 0.425325f}, -{-0.681718f, -0.147621f, 0.716567f}, {-0.442863f, -0.238856f, 0.864188f}, -{-0.587785f, -0.425325f, 0.688191f}, {-0.309017f, -0.500000f, 0.809017f}, -{-0.147621f, -0.716567f, 0.681718f}, {-0.425325f, -0.688191f, 0.587785f}, -{-0.162460f, -0.262866f, 0.951056f}, {0.442863f, -0.238856f, 0.864188f}, -{0.162460f, -0.262866f, 0.951056f}, {0.309017f, -0.500000f, 0.809017f}, -{0.147621f, -0.716567f, 0.681718f}, {0.000000f, -0.525731f, 0.850651f}, -{0.425325f, -0.688191f, 0.587785f}, {0.587785f, -0.425325f, 0.688191f}, -{0.688191f, -0.587785f, 0.425325f}, {-0.955423f, 0.295242f, 0.000000f}, -{-0.951056f, 0.162460f, 0.262866f}, {-1.000000f, 0.000000f, 0.000000f}, -{-0.850651f, 0.000000f, 0.525731f}, {-0.955423f, -0.295242f, 0.000000f}, -{-0.951056f, -0.162460f, 0.262866f}, {-0.864188f, 0.442863f, -0.238856f}, -{-0.951056f, 0.162460f, -0.262866f}, {-0.809017f, 0.309017f, -0.500000f}, -{-0.864188f, -0.442863f, -0.238856f}, {-0.951056f, -0.162460f, -0.262866f}, -{-0.809017f, -0.309017f, -0.500000f}, {-0.681718f, 0.147621f, -0.716567f}, -{-0.681718f, -0.147621f, -0.716567f}, {-0.850651f, 0.000000f, -0.525731f}, -{-0.688191f, 0.587785f, -0.425325f}, {-0.587785f, 0.425325f, -0.688191f}, -{-0.425325f, 0.688191f, -0.587785f}, {-0.425325f, -0.688191f, -0.587785f}, +{0.681718f, -0.147621f, -0.716567f},{0.850651f, 0.000000f, -0.525731f}, +{0.809017f, -0.309017f, -0.500000f}, {0.864188f, -0.442863f, -0.238856f}, +{0.951056f, -0.162460f, -0.262866f}, {0.147621f, 0.716567f, -0.681718f}, +{0.309017f, 0.500000f, -0.809017f}, {0.425325f, 0.688191f, -0.587785f}, +{0.442863f, 0.238856f, -0.864188f}, {0.587785f, 0.425325f, -0.688191f}, +{0.688191f, 0.587785f, -0.425325f}, {-0.147621f, 0.716567f, -0.681718f}, +{-0.309017f, 0.500000f, -0.809017f}, {0.000000f, 0.525731f, -0.850651f}, +{-0.525731f, 0.000000f, -0.850651f}, {-0.442863f, 0.238856f, -0.864188f}, +{-0.295242f, 0.000000f, -0.955423f}, {-0.162460f, 0.262866f, -0.951056f}, +{0.000000f, 0.000000f, -1.000000f}, {0.295242f, 0.000000f, -0.955423f}, +{0.162460f, 0.262866f, -0.951056f}, {-0.442863f, -0.238856f, -0.864188f}, +{-0.309017f, -0.500000f, -0.809017f}, {-0.162460f, -0.262866f, -0.951056f}, +{0.000000f, -0.850651f, -0.525731f}, {-0.147621f, -0.716567f, -0.681718f}, +{0.147621f, -0.716567f, -0.681718f}, {0.000000f, -0.525731f, -0.850651f}, +{0.309017f, -0.500000f, -0.809017f}, {0.442863f, -0.238856f, -0.864188f}, +{0.162460f, -0.262866f, -0.951056f}, {0.238856f, -0.864188f, -0.442863f}, +{0.500000f, -0.809017f, -0.309017f}, {0.425325f, -0.688191f, -0.587785f}, +{0.716567f, -0.681718f, -0.147621f}, {0.688191f, -0.587785f, -0.425325f}, +{0.587785f, -0.425325f, -0.688191f}, {0.000000f, -0.955423f, -0.295242f}, +{0.000000f, -1.000000f, 0.000000f}, {0.262866f, -0.951056f, -0.162460f}, +{0.000000f, -0.850651f, 0.525731f}, {0.000000f, -0.955423f, 0.295242f}, +{0.238856f, -0.864188f, 0.442863f}, {0.262866f, -0.951056f, 0.162460f}, +{0.500000f, -0.809017f, 0.309017f}, {0.716567f, -0.681718f, 0.147621f}, +{0.525731f, -0.850651f, 0.000000f}, {-0.238856f, -0.864188f, -0.442863f}, +{-0.500000f, -0.809017f, -0.309017f}, {-0.262866f, -0.951056f, -0.162460f}, +{-0.850651f, -0.525731f, 0.000000f}, {-0.716567f, -0.681718f, -0.147621f}, +{-0.716567f, -0.681718f, 0.147621f}, {-0.525731f, -0.850651f, 0.000000f}, +{-0.500000f, -0.809017f, 0.309017f}, {-0.238856f, -0.864188f, 0.442863f}, +{-0.262866f, -0.951056f, 0.162460f}, {-0.864188f, -0.442863f, 0.238856f}, +{-0.809017f, -0.309017f, 0.500000f}, {-0.688191f, -0.587785f, 0.425325f}, +{-0.681718f, -0.147621f, 0.716567f}, {-0.442863f, -0.238856f, 0.864188f}, +{-0.587785f, -0.425325f, 0.688191f}, {-0.309017f, -0.500000f, 0.809017f}, +{-0.147621f, -0.716567f, 0.681718f}, {-0.425325f, -0.688191f, 0.587785f}, +{-0.162460f, -0.262866f, 0.951056f}, {0.442863f, -0.238856f, 0.864188f}, +{0.162460f, -0.262866f, 0.951056f}, {0.309017f, -0.500000f, 0.809017f}, +{0.147621f, -0.716567f, 0.681718f}, {0.000000f, -0.525731f, 0.850651f}, +{0.425325f, -0.688191f, 0.587785f}, {0.587785f, -0.425325f, 0.688191f}, +{0.688191f, -0.587785f, 0.425325f}, {-0.955423f, 0.295242f, 0.000000f}, +{-0.951056f, 0.162460f, 0.262866f}, {-1.000000f, 0.000000f, 0.000000f}, +{-0.850651f, 0.000000f, 0.525731f}, {-0.955423f, -0.295242f, 0.000000f}, +{-0.951056f, -0.162460f, 0.262866f}, {-0.864188f, 0.442863f, -0.238856f}, +{-0.951056f, 0.162460f, -0.262866f}, {-0.809017f, 0.309017f, -0.500000f}, +{-0.864188f, -0.442863f, -0.238856f}, {-0.951056f, -0.162460f, -0.262866f}, +{-0.809017f, -0.309017f, -0.500000f}, {-0.681718f, 0.147621f, -0.716567f}, +{-0.681718f, -0.147621f, -0.716567f}, {-0.850651f, 0.000000f, -0.525731f}, +{-0.688191f, 0.587785f, -0.425325f}, {-0.587785f, 0.425325f, -0.688191f}, +{-0.425325f, 0.688191f, -0.587785f}, {-0.425325f, -0.688191f, -0.587785f}, {-0.587785f, -0.425325f, -0.688191f}, {-0.688191f, -0.587785f, -0.425325f} }; @@ -150,58 +150,58 @@ float Q_crandom( int *seed ) { #ifdef __LCC__ int VectorCompare( const vec3_t v1, const vec3_t v2 ) { - if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) { - return 0; - } - return 1; + if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) { + return 0; + } + return 1; } vec_t VectorLength( const vec3_t v ) { - return (vec_t)sqrt( v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ] + v[ 2 ] * v[ 2 ] ); + return (vec_t)sqrt( v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ] + v[ 2 ] * v[ 2 ] ); } vec_t VectorLengthSquared( const vec3_t v ) { - return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); + return (v[0]*v[0] + v[1]*v[1] + v[2]*v[2]); } vec_t Distance( const vec3_t p1, const vec3_t p2 ) { - vec3_t v; + vec3_t v; - VectorSubtract (p2, p1, v); - return VectorLength( v ); + VectorSubtract (p2, p1, v); + return VectorLength( v ); } vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ) { - vec3_t v; + vec3_t v; - VectorSubtract (p2, p1, v); - return v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; + VectorSubtract (p2, p1, v); + return v[0]*v[0] + v[1]*v[1] + v[2]*v[2]; } // fast vector normalize routine that does not check to make sure // that length != 0, nor does it return length, uses rsqrt approximation void VectorNormalizeFast( vec3_t v ) { - float ilength; + float ilength; - ilength = Q_rsqrt( DotProduct( v, v ) ); + ilength = Q_rsqrt( DotProduct( v, v ) ); - v[0] *= ilength; - v[1] *= ilength; - v[2] *= ilength; + v[0] *= ilength; + v[1] *= ilength; + v[2] *= ilength; } void VectorInverse( vec3_t v ){ - v[0] = -v[0]; - v[1] = -v[1]; - v[2] = -v[2]; + v[0] = -v[0]; + v[1] = -v[1]; + v[2] = -v[2]; } void CrossProduct( const vec3_t v1, const vec3_t v2, vec3_t cross ) { - cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; - cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; - cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; + cross[0] = v1[1]*v2[2] - v1[2]*v2[1]; + cross[1] = v1[2]*v2[0] - v1[0]*v2[2]; + cross[2] = v1[0]*v2[1] - v1[1]*v2[0]; } #endif @@ -239,11 +239,11 @@ int DirToByte( vec3_t dir ) bestd = 0; best = 0; - + for( i = 0; i < NUMVERTEXNORMALS; i++ ) { d = DotProduct( dir, bytedirs[ i ] ); - + if( d > bestd ) { bestd = d; @@ -261,7 +261,7 @@ void ByteToDir( int b, vec3_t dir ) VectorCopy( vec3_origin, dir ); return; } - + VectorCopy( bytedirs[ b ], dir); } @@ -401,7 +401,7 @@ void RotateAroundDirection( vec3_t axis[ 3 ], vec_t angle ) angle = DEG2RAD( angle ); - // create an arbitrary axis[1] + // create an arbitrary axis[1] PerpendicularVector( axis[ 1 ], axis[ 0 ] ); // cross to get axis[2] @@ -551,7 +551,7 @@ void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal ) assert( Q_fabs(inv_denom) != 0.0f ); // bk010122 - zero vectors get here #endif inv_denom = 1.0f / inv_denom; - + d = DotProduct( normal, p ) * inv_denom; n[0] = normal[0] * inv_denom; @@ -619,7 +619,7 @@ float Q_rsqrt( float number ) assert( !isnan(y) ); // bk010122 - FPE? #endif #endif - + return y; } #endif @@ -1302,14 +1302,14 @@ void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up) forward[ 1 ] = cp * sy; forward[ 2 ] = -sp; } - + if( right ) { right[ 0 ] = ( -1 * sr * sp * cy + -1 * cr * -sy ); right[ 1 ] = ( -1 * sr * sp * sy + -1 * cr * cy ); right[ 2 ] = -1 * sr * cp; } - + if( up ) { up[ 0 ] = ( cr * sp * cy + -sr * -sy ); @@ -1367,7 +1367,7 @@ float pointToLineDistance( const vec3_t p0, const vec3_t p1, const vec3_t p2 ) VectorSubtract( p2, p1, v ); VectorSubtract( p1, p0, w ); - + CrossProduct( w, v, y ); c1 = VectorLength( y ); c2 = VectorLength( v ); @@ -1389,16 +1389,16 @@ Used to find an "up" vector for drawing a sprite so that it always faces the vie */ void GetPerpendicularViewVector( const vec3_t point, const vec3_t p1, const vec3_t p2, vec3_t up ) { - vec3_t v1, v2; + vec3_t v1, v2; - VectorSubtract( point, p1, v1 ); - VectorNormalize( v1 ); + VectorSubtract( point, p1, v1 ); + VectorNormalize( v1 ); - VectorSubtract( point, p2, v2 ); - VectorNormalize( v2 ); + VectorSubtract( point, p2, v2 ); + VectorNormalize( v2 ); - CrossProduct( v1, v2, up ); - VectorNormalize( up ); + CrossProduct( v1, v2, up ); + VectorNormalize( up ); } /* @@ -1408,21 +1408,21 @@ ProjectPointOntoVector */ void ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vProj ) { - vec3_t pVec, vec; + vec3_t pVec, vec; - VectorSubtract( point, vStart, pVec ); - VectorSubtract( vEnd, vStart, vec ); - VectorNormalize( vec ); - // project onto the directional vector for this segment - VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj ); + VectorSubtract( point, vStart, pVec ); + VectorSubtract( vEnd, vStart, vec ); + VectorNormalize( vec ); + // project onto the directional vector for this segment + VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj ); } float VectorDistance(vec3_t v1, vec3_t v2) { - vec3_t dir; + vec3_t dir; - VectorSubtract(v2, v1, dir); - return VectorLength(dir); + VectorSubtract(v2, v1, dir); + return VectorLength(dir); } // done. diff --git a/src/game/q_shared.c b/src/game/q_shared.c index bd133ab9..6133c89a 100644 --- a/src/game/q_shared.c +++ b/src/game/q_shared.c @@ -327,10 +327,10 @@ int COM_Compress( char *data_p ) } else if( c == '/' && in[ 1 ] == '*' ) { - while( *in && ( *in != '*' || in[ 1 ] != '/' ) ) + while( *in && ( *in != '*' || in[ 1 ] != '/' ) ) in++; - - if( *in ) + + if( *in ) in += 2; // record when we hit a newline } @@ -355,23 +355,23 @@ int COM_Compress( char *data_p ) newline = qfalse; whitespace = qfalse; } - + if( whitespace ) { *out++ = ' '; whitespace = qfalse; } - + // copy quoted strings unmolested if( c == '"' ) { *out++ = c; in++; - + while( 1 ) { c = *in; - + if( c && c != '"' ) { *out++ = c; @@ -380,7 +380,7 @@ int COM_Compress( char *data_p ) else break; } - + if( c == '"' ) { *out++ = c; @@ -899,10 +899,10 @@ void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) va_start( argptr, fmt ); len = vsprintf( bigbuffer, fmt, argptr ); va_end( argptr ); - + if( len >= sizeof( bigbuffer ) ) Com_Error( ERR_FATAL, "Com_sprintf: overflowed bigbuffer" ); - + if( len >= size ) Com_Printf( "Com_sprintf: overflow of %i in %i\n", len, size ); @@ -973,10 +973,10 @@ char *Info_ValueForKey( const char *s, const char *key ) Com_Error( ERR_DROP, "Info_ValueForKey: oversize infostring" ); valueindex ^= 1; - + if( *s == '\\' ) s++; - + while( 1 ) { o = pkey; @@ -984,10 +984,10 @@ char *Info_ValueForKey( const char *s, const char *key ) { if( !*s ) return ""; - + *o++ = *s++; } - + *o = 0; s++; @@ -995,7 +995,7 @@ char *Info_ValueForKey( const char *s, const char *key ) while( *s != '\\' && *s ) *o++ = *s++; - + *o = 0; if( !Q_stricmp( key, pkey ) ) @@ -1176,7 +1176,7 @@ qboolean Info_Validate( const char *s ) { if( strchr( s, '\"' ) ) return qfalse; - + if( strchr( s, ';' ) ) return qfalse; diff --git a/src/game/q_shared.h b/src/game/q_shared.h index 69496267..e9c09c48 100644 --- a/src/game/q_shared.h +++ b/src/game/q_shared.h @@ -136,7 +136,7 @@ float FloatSwap (const float *f); #endif #endif -#define ID_INLINE __inline +#define ID_INLINE __inline static ID_INLINE short BigShort( short l) { return ShortSwap(l); } #define LittleShort @@ -157,7 +157,7 @@ static ID_INLINE float BigFloat(const float *l) { FloatSwap(l); } #define __cdecl #define __declspec(x) #define stricmp strcasecmp -#define ID_INLINE inline +#define ID_INLINE inline #ifdef __ppc__ #define CPUSTRING "MacOSX-ppc" @@ -174,21 +174,21 @@ static ID_INLINE float BigFloat(const float *l) { FloatSwap(l); } static inline unsigned int __lwbrx(register void *addr, register int offset) { register unsigned int word; - + asm("lwbrx %0,%2,%1" : "=r" (word) : "r" (addr), "b" (offset)); return word; } static inline unsigned short __lhbrx(register void *addr, register int offset) { register unsigned short halfword; - + asm("lhbrx %0,%2,%1" : "=r" (halfword) : "r" (addr), "b" (offset)); return halfword; } static inline float __fctiw(register float f) { register float fi; - + asm("fctiw %0,%1" : "=f" (fi) : "f" (f)); return fi; @@ -209,7 +209,7 @@ static inline float LittleFloat (const float l) { return FloatSwap(&l); } #include <MacTypes.h> #define MAC_STATIC -#define ID_INLINE inline +#define ID_INLINE inline #define CPUSTRING "MacOS-PPC" @@ -236,7 +236,7 @@ static inline float LittleFloat (const float l) { return FloatSwap(&l); } #define stricmp strcasecmp #define MAC_STATIC // bk: FIXME -#define ID_INLINE inline +#define ID_INLINE inline #ifdef __i386__ #define CPUSTRING "linux-i386" @@ -280,7 +280,7 @@ inline static float LittleFloat (const float *l) { return FloatSwap(l); } #define stricmp strcasecmp #define MAC_STATIC -#define ID_INLINE inline +#define ID_INLINE inline #ifdef __i386__ #define CPUSTRING "freebsd-i386" @@ -565,7 +565,7 @@ extern vec3_t axisDefault[3]; static inline float Q_rsqrt( float number ) { float x = 0.5f * number; float y; -#ifdef __GNUC__ +#ifdef __GNUC__ asm("frsqrte %0,%1" : "=f" (y) : "f" (number)); #else y = __frsqrte( number ); @@ -573,10 +573,10 @@ static inline float Q_rsqrt( float number ) { return y * (1.5f - (x * y * y)); } -#ifdef __GNUC__ +#ifdef __GNUC__ static inline float Q_fabs(float x) { float abs_x; - + asm("fabs %0,%1" : "=f" (abs_x) : "f" (x)); return abs_x; } @@ -658,7 +658,7 @@ void AddPointToBounds( const vec3_t v, vec3_t mins, vec3_t maxs ); static ID_INLINE int VectorCompare( const vec3_t v1, const vec3_t v2 ) { if (v1[0] != v2[0] || v1[1] != v2[1] || v1[2] != v2[2]) { return 0; - } + } return 1; } @@ -719,7 +719,7 @@ vec_t VectorLengthSquared( const vec3_t v ); vec_t Distance( const vec3_t p1, const vec3_t p2 ); vec_t DistanceSquared( const vec3_t p1, const vec3_t p2 ); - + void VectorNormalizeFast( vec3_t v ); void VectorInverse( vec3_t v ); @@ -1125,7 +1125,7 @@ typedef struct { #define MAX_STATS 16 #define MAX_PERSISTANT 16 #define MAX_POWERUPS 16 -#define MAX_WEAPONS 16 +#define MAX_WEAPONS 16 #define MAX_PS_EVENTS 2 @@ -1245,7 +1245,7 @@ typedef struct usercmd_s { int serverTime; int angles[3]; int buttons; - byte weapon; // weapon + byte weapon; // weapon signed char forwardmove, rightmove, upmove; } usercmd_t; @@ -1326,7 +1326,7 @@ typedef struct entityState_s { typedef enum { CA_UNINITIALIZED, CA_DISCONNECTED, // not talking to a server - CA_AUTHORIZING, // not used any more, was checking cd key + CA_AUTHORIZING, // not used any more, was checking cd key CA_CONNECTING, // sending request packets to the server CA_CHALLENGING, // sending challenge packets to the server CA_CONNECTED, // netchan_t established, getting gamestate @@ -1336,7 +1336,7 @@ typedef enum { CA_CINEMATIC // playing a cinematic or a static pic, not connected to a server } connstate_t; -// font support +// font support #define GLYPH_START 0 #define GLYPH_END 255 diff --git a/src/game/tremulous.h b/src/game/tremulous.h index e1f30ed9..ddee71de 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -10,7 +10,7 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. */ - + /* * ALIEN weapons @@ -19,7 +19,7 @@ * _DMG - amount of damage the weapon does * * ALIEN_WDMG_MODIFIER - overall damage modifier for coarse tuning - * + * */ #define ALIEN_WDMG_MODIFIER 1.0f @@ -108,7 +108,7 @@ * _REGEN - health per second regained * * ALIEN_HLTH_MODIFIER - overall health modifier for coarse tuning - * + * */ #define ALIEN_HLTH_MODIFIER 1.0f @@ -190,13 +190,13 @@ * * CREEP_BASESIZE - the maximum distance a buildable can be from an egg/overmind * ALIEN_BHLTH_MODIFIER - overall health modifier for coarse tuning - * + * */ #define ALIEN_BHLTH_MODIFIER 1.0f #define ABHM(h) ((int)((float)h*ALIEN_BHLTH_MODIFIER)) -#define CREEP_BASESIZE 700 +#define CREEP_BASESIZE 700 #define CREEP_TIMEOUT 1000 #define CREEP_MODIFIER 0.5f #define CREEP_ARMOUR_MODIFIER 0.75f @@ -289,7 +289,7 @@ * ALIEN misc * * ALIENSENSE_RANGE - the distance alien sense is useful for - * + * */ #define ALIENSENSE_RANGE 1000.0f @@ -310,7 +310,7 @@ * _PRICE - amount in credits weapon costs * * HUMAN_WDMG_MODIFIER - overall damage modifier for coarse tuning - * + * */ #define HUMAN_WDMG_MODIFIER 1.0f @@ -448,12 +448,12 @@ * _BP - build points required for this buildable * _BT - build time required for this buildable * _SPLASHDAMGE - the amount of damage caused by this buildable when it blows up - * _SPLASHRADIUS - the radius around which it does this damage + * _SPLASHRADIUS - the radius around which it does this damage * * REACTOR_BASESIZE - the maximum distance a buildable can be from an reactor * REPEATER_BASESIZE - the maximum distance a buildable can be from a repeater * HUMAN_BHLTH_MODIFIER - overall health modifier for coarse tuning - * + * */ #define HUMAN_BHLTH_MODIFIER 1.0f @@ -567,5 +567,5 @@ #define DEFAULT_ALIEN_BUILDPOINTS "100" #define DEFAULT_HUMAN_BUILDPOINTS "100" -#define DAMAGE_FRACTION_FOR_KILL 0.5f //how much damage players (versus structures) need to +#define DAMAGE_FRACTION_FOR_KILL 0.5f //how much damage players (versus structures) need to //do to increment the stage kill counters diff --git a/src/ui/keycodes.h b/src/ui/keycodes.h index b0830de2..cfa82223 100644 --- a/src/ui/keycodes.h +++ b/src/ui/keycodes.h @@ -24,134 +24,134 @@ // normal keys should be passed as lowercased ascii typedef enum { - K_TAB = 9, - K_ENTER = 13, - K_ESCAPE = 27, - K_SPACE = 32, - - K_BACKSPACE = 127, - - K_COMMAND = 128, - K_CAPSLOCK, - K_POWER, - K_PAUSE, - - K_UPARROW, - K_DOWNARROW, - K_LEFTARROW, - K_RIGHTARROW, - - K_ALT, - K_CTRL, - K_SHIFT, - K_INS, - K_DEL, - K_PGDN, - K_PGUP, - K_HOME, - K_END, - - K_F1, - K_F2, - K_F3, - K_F4, - K_F5, - K_F6, - K_F7, - K_F8, - K_F9, - K_F10, - K_F11, - K_F12, - K_F13, - K_F14, - K_F15, - - K_KP_HOME, - K_KP_UPARROW, - K_KP_PGUP, - K_KP_LEFTARROW, - K_KP_5, - K_KP_RIGHTARROW, - K_KP_END, - K_KP_DOWNARROW, - K_KP_PGDN, - K_KP_ENTER, - K_KP_INS, - K_KP_DEL, - K_KP_SLASH, - K_KP_MINUS, - K_KP_PLUS, - K_KP_NUMLOCK, - K_KP_STAR, - K_KP_EQUALS, - - K_MOUSE1, - K_MOUSE2, - K_MOUSE3, - K_MOUSE4, - K_MOUSE5, - - K_MWHEELDOWN, - K_MWHEELUP, - - K_JOY1, - K_JOY2, - K_JOY3, - K_JOY4, - K_JOY5, - K_JOY6, - K_JOY7, - K_JOY8, - K_JOY9, - K_JOY10, - K_JOY11, - K_JOY12, - K_JOY13, - K_JOY14, - K_JOY15, - K_JOY16, - K_JOY17, - K_JOY18, - K_JOY19, - K_JOY20, - K_JOY21, - K_JOY22, - K_JOY23, - K_JOY24, - K_JOY25, - K_JOY26, - K_JOY27, - K_JOY28, - K_JOY29, - K_JOY30, - K_JOY31, - K_JOY32, - - K_AUX1, - K_AUX2, - K_AUX3, - K_AUX4, - K_AUX5, - K_AUX6, - K_AUX7, - K_AUX8, - K_AUX9, - K_AUX10, - K_AUX11, - K_AUX12, - K_AUX13, - K_AUX14, - K_AUX15, - K_AUX16, - - K_LAST_KEY // this had better be <256! + K_TAB = 9, + K_ENTER = 13, + K_ESCAPE = 27, + K_SPACE = 32, + + K_BACKSPACE = 127, + + K_COMMAND = 128, + K_CAPSLOCK, + K_POWER, + K_PAUSE, + + K_UPARROW, + K_DOWNARROW, + K_LEFTARROW, + K_RIGHTARROW, + + K_ALT, + K_CTRL, + K_SHIFT, + K_INS, + K_DEL, + K_PGDN, + K_PGUP, + K_HOME, + K_END, + + K_F1, + K_F2, + K_F3, + K_F4, + K_F5, + K_F6, + K_F7, + K_F8, + K_F9, + K_F10, + K_F11, + K_F12, + K_F13, + K_F14, + K_F15, + + K_KP_HOME, + K_KP_UPARROW, + K_KP_PGUP, + K_KP_LEFTARROW, + K_KP_5, + K_KP_RIGHTARROW, + K_KP_END, + K_KP_DOWNARROW, + K_KP_PGDN, + K_KP_ENTER, + K_KP_INS, + K_KP_DEL, + K_KP_SLASH, + K_KP_MINUS, + K_KP_PLUS, + K_KP_NUMLOCK, + K_KP_STAR, + K_KP_EQUALS, + + K_MOUSE1, + K_MOUSE2, + K_MOUSE3, + K_MOUSE4, + K_MOUSE5, + + K_MWHEELDOWN, + K_MWHEELUP, + + K_JOY1, + K_JOY2, + K_JOY3, + K_JOY4, + K_JOY5, + K_JOY6, + K_JOY7, + K_JOY8, + K_JOY9, + K_JOY10, + K_JOY11, + K_JOY12, + K_JOY13, + K_JOY14, + K_JOY15, + K_JOY16, + K_JOY17, + K_JOY18, + K_JOY19, + K_JOY20, + K_JOY21, + K_JOY22, + K_JOY23, + K_JOY24, + K_JOY25, + K_JOY26, + K_JOY27, + K_JOY28, + K_JOY29, + K_JOY30, + K_JOY31, + K_JOY32, + + K_AUX1, + K_AUX2, + K_AUX3, + K_AUX4, + K_AUX5, + K_AUX6, + K_AUX7, + K_AUX8, + K_AUX9, + K_AUX10, + K_AUX11, + K_AUX12, + K_AUX13, + K_AUX14, + K_AUX15, + K_AUX16, + + K_LAST_KEY // this had better be <256! } keyNum_t; // The menu code needs to get both key and char events, but // to avoid duplicating the paths, the char events are just // distinguished by or'ing in K_CHAR_FLAG (ugly) -#define K_CHAR_FLAG 1024 +#define K_CHAR_FLAG 1024 #endif diff --git a/src/ui/ui_atoms.c b/src/ui/ui_atoms.c index 5abf7c31..8139be91 100644 --- a/src/ui/ui_atoms.c +++ b/src/ui/ui_atoms.c @@ -15,37 +15,37 @@ */ /********************************************************************** - UI_ATOMS.C + UI_ATOMS.C - User interface building blocks and support functions. + User interface building blocks and support functions. **********************************************************************/ #include "ui_local.h" -qboolean m_entersound; // after a frame, so caching won't disrupt the sound +qboolean m_entersound; // after a frame, so caching won't disrupt the sound // these are here so the functions in q_shared.c can link #ifndef UI_HARD_LINKED void QDECL Com_Error( int level, const char *error, ... ) { - va_list argptr; - char text[1024]; + va_list argptr; + char text[1024]; - va_start (argptr, error); - vsprintf (text, error, argptr); - va_end (argptr); + va_start (argptr, error); + vsprintf (text, error, argptr); + va_end (argptr); - trap_Error( va("%s", text) ); + trap_Error( va("%s", text) ); } void QDECL Com_Printf( const char *msg, ... ) { - va_list argptr; - char text[1024]; + va_list argptr; + char text[1024]; - va_start (argptr, msg); - vsprintf (text, msg, argptr); - va_end (argptr); + va_start (argptr, msg); + vsprintf (text, msg, argptr); + va_end (argptr); - trap_Print( va("%s", text) ); + trap_Print( va("%s", text) ); } #endif @@ -60,9 +60,9 @@ UI_ClampCvar */ float UI_ClampCvar( float min, float max, float value ) { - if ( value < min ) return min; - if ( value > max ) return max; - return value; + if ( value < min ) return min; + if ( value > max ) return max; + return value; } /* @@ -71,85 +71,85 @@ UI_StartDemoLoop ================= */ void UI_StartDemoLoop( void ) { - trap_Cmd_ExecuteText( EXEC_APPEND, "d1\n" ); + trap_Cmd_ExecuteText( EXEC_APPEND, "d1\n" ); } char *UI_Argv( int arg ) { - static char buffer[MAX_STRING_CHARS]; + static char buffer[MAX_STRING_CHARS]; - trap_Argv( arg, buffer, sizeof( buffer ) ); + trap_Argv( arg, buffer, sizeof( buffer ) ); - return buffer; + return buffer; } char *UI_Cvar_VariableString( const char *var_name ) { - static char buffer[MAX_STRING_CHARS]; + static char buffer[MAX_STRING_CHARS]; - trap_Cvar_VariableStringBuffer( var_name, buffer, sizeof( buffer ) ); + trap_Cvar_VariableStringBuffer( var_name, buffer, sizeof( buffer ) ); - return buffer; + return buffer; } void UI_SetBestScores(postGameInfo_t *newInfo, qboolean postGame) { - trap_Cvar_Set("ui_scoreAccuracy", va("%i%%", newInfo->accuracy)); - trap_Cvar_Set("ui_scoreImpressives", va("%i", newInfo->impressives)); - trap_Cvar_Set("ui_scoreExcellents", va("%i", newInfo->excellents)); - trap_Cvar_Set("ui_scoreDefends", va("%i", newInfo->defends)); - trap_Cvar_Set("ui_scoreAssists", va("%i", newInfo->assists)); - trap_Cvar_Set("ui_scoreGauntlets", va("%i", newInfo->gauntlets)); - trap_Cvar_Set("ui_scoreScore", va("%i", newInfo->score)); - trap_Cvar_Set("ui_scorePerfect", va("%i", newInfo->perfects)); - trap_Cvar_Set("ui_scoreTeam", va("%i to %i", newInfo->redScore, newInfo->blueScore)); - trap_Cvar_Set("ui_scoreBase", va("%i", newInfo->baseScore)); - trap_Cvar_Set("ui_scoreTimeBonus", va("%i", newInfo->timeBonus)); - trap_Cvar_Set("ui_scoreSkillBonus", va("%i", newInfo->skillBonus)); - trap_Cvar_Set("ui_scoreShutoutBonus", va("%i", newInfo->shutoutBonus)); - trap_Cvar_Set("ui_scoreTime", va("%02i:%02i", newInfo->time / 60, newInfo->time % 60)); - trap_Cvar_Set("ui_scoreCaptures", va("%i", newInfo->captures)); + trap_Cvar_Set("ui_scoreAccuracy", va("%i%%", newInfo->accuracy)); + trap_Cvar_Set("ui_scoreImpressives", va("%i", newInfo->impressives)); + trap_Cvar_Set("ui_scoreExcellents", va("%i", newInfo->excellents)); + trap_Cvar_Set("ui_scoreDefends", va("%i", newInfo->defends)); + trap_Cvar_Set("ui_scoreAssists", va("%i", newInfo->assists)); + trap_Cvar_Set("ui_scoreGauntlets", va("%i", newInfo->gauntlets)); + trap_Cvar_Set("ui_scoreScore", va("%i", newInfo->score)); + trap_Cvar_Set("ui_scorePerfect", va("%i", newInfo->perfects)); + trap_Cvar_Set("ui_scoreTeam", va("%i to %i", newInfo->redScore, newInfo->blueScore)); + trap_Cvar_Set("ui_scoreBase", va("%i", newInfo->baseScore)); + trap_Cvar_Set("ui_scoreTimeBonus", va("%i", newInfo->timeBonus)); + trap_Cvar_Set("ui_scoreSkillBonus", va("%i", newInfo->skillBonus)); + trap_Cvar_Set("ui_scoreShutoutBonus", va("%i", newInfo->shutoutBonus)); + trap_Cvar_Set("ui_scoreTime", va("%02i:%02i", newInfo->time / 60, newInfo->time % 60)); + trap_Cvar_Set("ui_scoreCaptures", va("%i", newInfo->captures)); if (postGame) { - trap_Cvar_Set("ui_scoreAccuracy2", va("%i%%", newInfo->accuracy)); - trap_Cvar_Set("ui_scoreImpressives2", va("%i", newInfo->impressives)); - trap_Cvar_Set("ui_scoreExcellents2", va("%i", newInfo->excellents)); - trap_Cvar_Set("ui_scoreDefends2", va("%i", newInfo->defends)); - trap_Cvar_Set("ui_scoreAssists2", va("%i", newInfo->assists)); - trap_Cvar_Set("ui_scoreGauntlets2", va("%i", newInfo->gauntlets)); - trap_Cvar_Set("ui_scoreScore2", va("%i", newInfo->score)); - trap_Cvar_Set("ui_scorePerfect2", va("%i", newInfo->perfects)); - trap_Cvar_Set("ui_scoreTeam2", va("%i to %i", newInfo->redScore, newInfo->blueScore)); - trap_Cvar_Set("ui_scoreBase2", va("%i", newInfo->baseScore)); - trap_Cvar_Set("ui_scoreTimeBonus2", va("%i", newInfo->timeBonus)); - trap_Cvar_Set("ui_scoreSkillBonus2", va("%i", newInfo->skillBonus)); - trap_Cvar_Set("ui_scoreShutoutBonus2", va("%i", newInfo->shutoutBonus)); - trap_Cvar_Set("ui_scoreTime2", va("%02i:%02i", newInfo->time / 60, newInfo->time % 60)); - trap_Cvar_Set("ui_scoreCaptures2", va("%i", newInfo->captures)); - } + trap_Cvar_Set("ui_scoreAccuracy2", va("%i%%", newInfo->accuracy)); + trap_Cvar_Set("ui_scoreImpressives2", va("%i", newInfo->impressives)); + trap_Cvar_Set("ui_scoreExcellents2", va("%i", newInfo->excellents)); + trap_Cvar_Set("ui_scoreDefends2", va("%i", newInfo->defends)); + trap_Cvar_Set("ui_scoreAssists2", va("%i", newInfo->assists)); + trap_Cvar_Set("ui_scoreGauntlets2", va("%i", newInfo->gauntlets)); + trap_Cvar_Set("ui_scoreScore2", va("%i", newInfo->score)); + trap_Cvar_Set("ui_scorePerfect2", va("%i", newInfo->perfects)); + trap_Cvar_Set("ui_scoreTeam2", va("%i to %i", newInfo->redScore, newInfo->blueScore)); + trap_Cvar_Set("ui_scoreBase2", va("%i", newInfo->baseScore)); + trap_Cvar_Set("ui_scoreTimeBonus2", va("%i", newInfo->timeBonus)); + trap_Cvar_Set("ui_scoreSkillBonus2", va("%i", newInfo->skillBonus)); + trap_Cvar_Set("ui_scoreShutoutBonus2", va("%i", newInfo->shutoutBonus)); + trap_Cvar_Set("ui_scoreTime2", va("%02i:%02i", newInfo->time / 60, newInfo->time % 60)); + trap_Cvar_Set("ui_scoreCaptures2", va("%i", newInfo->captures)); + } } void UI_LoadBestScores(const char *map, int game) { - char fileName[MAX_QPATH]; - fileHandle_t f; - postGameInfo_t newInfo; - memset(&newInfo, 0, sizeof(postGameInfo_t)); - Com_sprintf(fileName, MAX_QPATH, "games/%s_%i.game", map, game); - if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) { - int size = 0; - trap_FS_Read(&size, sizeof(int), f); - if (size == sizeof(postGameInfo_t)) { - trap_FS_Read(&newInfo, sizeof(postGameInfo_t), f); - } - trap_FS_FCloseFile(f); - } - UI_SetBestScores(&newInfo, qfalse); - - Com_sprintf(fileName, MAX_QPATH, "demos/%s_%d.dm_%d", map, game, (int)trap_Cvar_VariableValue("protocol")); - uiInfo.demoAvailable = qfalse; - if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) { - uiInfo.demoAvailable = qtrue; - trap_FS_FCloseFile(f); - } + char fileName[MAX_QPATH]; + fileHandle_t f; + postGameInfo_t newInfo; + memset(&newInfo, 0, sizeof(postGameInfo_t)); + Com_sprintf(fileName, MAX_QPATH, "games/%s_%i.game", map, game); + if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) { + int size = 0; + trap_FS_Read(&size, sizeof(int), f); + if (size == sizeof(postGameInfo_t)) { + trap_FS_Read(&newInfo, sizeof(postGameInfo_t), f); + } + trap_FS_FCloseFile(f); + } + UI_SetBestScores(&newInfo, qfalse); + + Com_sprintf(fileName, MAX_QPATH, "demos/%s_%d.dm_%d", map, game, (int)trap_Cvar_VariableValue("protocol")); + uiInfo.demoAvailable = qfalse; + if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) { + uiInfo.demoAvailable = qtrue; + trap_FS_FCloseFile(f); + } } /* @@ -158,38 +158,38 @@ UI_ClearScores =============== */ void UI_ClearScores() { - char gameList[4096]; - char *gameFile; - int i, len, count, size; - fileHandle_t f; - postGameInfo_t newInfo; - - count = trap_FS_GetFileList( "games", "game", gameList, sizeof(gameList) ); - - size = sizeof(postGameInfo_t); - memset(&newInfo, 0, size); - - if (count > 0) { - gameFile = gameList; - for ( i = 0; i < count; i++ ) { - len = strlen(gameFile); - if (trap_FS_FOpenFile(va("games/%s",gameFile), &f, FS_WRITE) >= 0) { - trap_FS_Write(&size, sizeof(int), f); - trap_FS_Write(&newInfo, size, f); - trap_FS_FCloseFile(f); - } - gameFile += len + 1; - } - } - - UI_SetBestScores(&newInfo, qfalse); + char gameList[4096]; + char *gameFile; + int i, len, count, size; + fileHandle_t f; + postGameInfo_t newInfo; + + count = trap_FS_GetFileList( "games", "game", gameList, sizeof(gameList) ); + + size = sizeof(postGameInfo_t); + memset(&newInfo, 0, size); + + if (count > 0) { + gameFile = gameList; + for ( i = 0; i < count; i++ ) { + len = strlen(gameFile); + if (trap_FS_FOpenFile(va("games/%s",gameFile), &f, FS_WRITE) >= 0) { + trap_FS_Write(&size, sizeof(int), f); + trap_FS_Write(&newInfo, size, f); + trap_FS_FCloseFile(f); + } + gameFile += len + 1; + } + } + + UI_SetBestScores(&newInfo, qfalse); } -static void UI_Cache_f() { - Display_CacheAll(); +static void UI_Cache_f() { + Display_CacheAll(); } /* @@ -198,96 +198,96 @@ UI_CalcPostGameStats ======================= */ static void UI_CalcPostGameStats() { - char map[MAX_QPATH]; - char fileName[MAX_QPATH]; - char info[MAX_INFO_STRING]; - fileHandle_t f; - int size, game, time, adjustedTime; - postGameInfo_t oldInfo; - postGameInfo_t newInfo; - qboolean newHigh = qfalse; - - trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ); - Q_strncpyz( map, Info_ValueForKey( info, "mapname" ), sizeof(map) ); - game = atoi(Info_ValueForKey(info, "g_gametype")); - - // compose file name - Com_sprintf(fileName, MAX_QPATH, "games/%s_%i.game", map, game); - // see if we have one already - memset(&oldInfo, 0, sizeof(postGameInfo_t)); - if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) { - // if so load it - size = 0; - trap_FS_Read(&size, sizeof(int), f); - if (size == sizeof(postGameInfo_t)) { - trap_FS_Read(&oldInfo, sizeof(postGameInfo_t), f); - } - trap_FS_FCloseFile(f); - } - - newInfo.accuracy = atoi(UI_Argv(3)); - newInfo.impressives = atoi(UI_Argv(4)); - newInfo.excellents = atoi(UI_Argv(5)); - newInfo.defends = atoi(UI_Argv(6)); - newInfo.assists = atoi(UI_Argv(7)); - newInfo.gauntlets = atoi(UI_Argv(8)); - newInfo.baseScore = atoi(UI_Argv(9)); - newInfo.perfects = atoi(UI_Argv(10)); - newInfo.redScore = atoi(UI_Argv(11)); - newInfo.blueScore = atoi(UI_Argv(12)); - time = atoi(UI_Argv(13)); - newInfo.captures = atoi(UI_Argv(14)); - - newInfo.time = (time - trap_Cvar_VariableValue("ui_matchStartTime")) / 1000; - adjustedTime = uiInfo.mapList[ui_currentMap.integer].timeToBeat[game]; - if (newInfo.time < adjustedTime) { - newInfo.timeBonus = (adjustedTime - newInfo.time) * 10; - } else { - newInfo.timeBonus = 0; - } - - if (newInfo.redScore > newInfo.blueScore && newInfo.blueScore <= 0) { - newInfo.shutoutBonus = 100; - } else { - newInfo.shutoutBonus = 0; - } - - newInfo.skillBonus = trap_Cvar_VariableValue("g_spSkill"); - if (newInfo.skillBonus <= 0) { - newInfo.skillBonus = 1; - } - newInfo.score = newInfo.baseScore + newInfo.shutoutBonus + newInfo.timeBonus; - newInfo.score *= newInfo.skillBonus; - - // see if the score is higher for this one - newHigh = (newInfo.redScore > newInfo.blueScore && newInfo.score > oldInfo.score); - - if (newHigh) { - // if so write out the new one - uiInfo.newHighScoreTime = uiInfo.uiDC.realTime + 20000; - if (trap_FS_FOpenFile(fileName, &f, FS_WRITE) >= 0) { - size = sizeof(postGameInfo_t); - trap_FS_Write(&size, sizeof(int), f); - trap_FS_Write(&newInfo, sizeof(postGameInfo_t), f); - trap_FS_FCloseFile(f); - } - } - - if (newInfo.time < oldInfo.time) { - uiInfo.newBestTime = uiInfo.uiDC.realTime + 20000; - } - - // put back all the ui overrides - trap_Cvar_Set("capturelimit", UI_Cvar_VariableString("ui_saveCaptureLimit")); - trap_Cvar_Set("fraglimit", UI_Cvar_VariableString("ui_saveFragLimit")); - trap_Cvar_Set("cg_drawTimer", UI_Cvar_VariableString("ui_drawTimer")); - trap_Cvar_Set("g_doWarmup", UI_Cvar_VariableString("ui_doWarmup")); - trap_Cvar_Set("g_Warmup", UI_Cvar_VariableString("ui_Warmup")); - trap_Cvar_Set("sv_pure", UI_Cvar_VariableString("ui_pure")); - trap_Cvar_Set("g_friendlyFire", UI_Cvar_VariableString("ui_friendlyFire")); - - UI_SetBestScores(&newInfo, qtrue); - UI_ShowPostGame(newHigh); + char map[MAX_QPATH]; + char fileName[MAX_QPATH]; + char info[MAX_INFO_STRING]; + fileHandle_t f; + int size, game, time, adjustedTime; + postGameInfo_t oldInfo; + postGameInfo_t newInfo; + qboolean newHigh = qfalse; + + trap_GetConfigString( CS_SERVERINFO, info, sizeof(info) ); + Q_strncpyz( map, Info_ValueForKey( info, "mapname" ), sizeof(map) ); + game = atoi(Info_ValueForKey(info, "g_gametype")); + + // compose file name + Com_sprintf(fileName, MAX_QPATH, "games/%s_%i.game", map, game); + // see if we have one already + memset(&oldInfo, 0, sizeof(postGameInfo_t)); + if (trap_FS_FOpenFile(fileName, &f, FS_READ) >= 0) { + // if so load it + size = 0; + trap_FS_Read(&size, sizeof(int), f); + if (size == sizeof(postGameInfo_t)) { + trap_FS_Read(&oldInfo, sizeof(postGameInfo_t), f); + } + trap_FS_FCloseFile(f); + } + + newInfo.accuracy = atoi(UI_Argv(3)); + newInfo.impressives = atoi(UI_Argv(4)); + newInfo.excellents = atoi(UI_Argv(5)); + newInfo.defends = atoi(UI_Argv(6)); + newInfo.assists = atoi(UI_Argv(7)); + newInfo.gauntlets = atoi(UI_Argv(8)); + newInfo.baseScore = atoi(UI_Argv(9)); + newInfo.perfects = atoi(UI_Argv(10)); + newInfo.redScore = atoi(UI_Argv(11)); + newInfo.blueScore = atoi(UI_Argv(12)); + time = atoi(UI_Argv(13)); + newInfo.captures = atoi(UI_Argv(14)); + + newInfo.time = (time - trap_Cvar_VariableValue("ui_matchStartTime")) / 1000; + adjustedTime = uiInfo.mapList[ui_currentMap.integer].timeToBeat[game]; + if (newInfo.time < adjustedTime) { + newInfo.timeBonus = (adjustedTime - newInfo.time) * 10; + } else { + newInfo.timeBonus = 0; + } + + if (newInfo.redScore > newInfo.blueScore && newInfo.blueScore <= 0) { + newInfo.shutoutBonus = 100; + } else { + newInfo.shutoutBonus = 0; + } + + newInfo.skillBonus = trap_Cvar_VariableValue("g_spSkill"); + if (newInfo.skillBonus <= 0) { + newInfo.skillBonus = 1; + } + newInfo.score = newInfo.baseScore + newInfo.shutoutBonus + newInfo.timeBonus; + newInfo.score *= newInfo.skillBonus; + + // see if the score is higher for this one + newHigh = (newInfo.redScore > newInfo.blueScore && newInfo.score > oldInfo.score); + + if (newHigh) { + // if so write out the new one + uiInfo.newHighScoreTime = uiInfo.uiDC.realTime + 20000; + if (trap_FS_FOpenFile(fileName, &f, FS_WRITE) >= 0) { + size = sizeof(postGameInfo_t); + trap_FS_Write(&size, sizeof(int), f); + trap_FS_Write(&newInfo, sizeof(postGameInfo_t), f); + trap_FS_FCloseFile(f); + } + } + + if (newInfo.time < oldInfo.time) { + uiInfo.newBestTime = uiInfo.uiDC.realTime + 20000; + } + + // put back all the ui overrides + trap_Cvar_Set("capturelimit", UI_Cvar_VariableString("ui_saveCaptureLimit")); + trap_Cvar_Set("fraglimit", UI_Cvar_VariableString("ui_saveFragLimit")); + trap_Cvar_Set("cg_drawTimer", UI_Cvar_VariableString("ui_drawTimer")); + trap_Cvar_Set("g_doWarmup", UI_Cvar_VariableString("ui_doWarmup")); + trap_Cvar_Set("g_Warmup", UI_Cvar_VariableString("ui_Warmup")); + trap_Cvar_Set("sv_pure", UI_Cvar_VariableString("ui_pure")); + trap_Cvar_Set("g_friendlyFire", UI_Cvar_VariableString("ui_friendlyFire")); + + UI_SetBestScores(&newInfo, qtrue); + UI_ShowPostGame(newHigh); } @@ -300,56 +300,56 @@ UI_ConsoleCommand */ qboolean UI_ConsoleCommand( int realTime ) { - char *cmd; + char *cmd; char *arg1; - uiInfo.uiDC.frameTime = realTime - uiInfo.uiDC.realTime; - uiInfo.uiDC.realTime = realTime; - - cmd = UI_Argv( 0 ); - - // ensure minimum menu data is available - //Menu_Cache(); - - if ( Q_stricmp (cmd, "ui_test") == 0 ) { - UI_ShowPostGame(qtrue); - } - - if ( Q_stricmp (cmd, "ui_report") == 0 ) { - UI_Report(); - return qtrue; - } - - if ( Q_stricmp (cmd, "ui_load") == 0 ) { - UI_Load(); - return qtrue; - } - - if ( Q_stricmp (cmd, "remapShader") == 0 ) { - if (trap_Argc() == 4) { - char shader1[MAX_QPATH]; - char shader2[MAX_QPATH]; - Q_strncpyz(shader1, UI_Argv(1), sizeof(shader1)); - Q_strncpyz(shader2, UI_Argv(2), sizeof(shader2)); - trap_R_RemapShader(shader1, shader2, UI_Argv(3)); - return qtrue; - } - } - - if ( Q_stricmp (cmd, "postgame") == 0 ) { - UI_CalcPostGameStats(); - return qtrue; - } - - if ( Q_stricmp (cmd, "ui_cache") == 0 ) { - UI_Cache_f(); - return qtrue; - } - - if ( Q_stricmp (cmd, "ui_teamOrders") == 0 ) { - //UI_TeamOrdersMenu_f(); - return qtrue; - } + uiInfo.uiDC.frameTime = realTime - uiInfo.uiDC.realTime; + uiInfo.uiDC.realTime = realTime; + + cmd = UI_Argv( 0 ); + + // ensure minimum menu data is available + //Menu_Cache(); + + if ( Q_stricmp (cmd, "ui_test") == 0 ) { + UI_ShowPostGame(qtrue); + } + + if ( Q_stricmp (cmd, "ui_report") == 0 ) { + UI_Report(); + return qtrue; + } + + if ( Q_stricmp (cmd, "ui_load") == 0 ) { + UI_Load(); + return qtrue; + } + + if ( Q_stricmp (cmd, "remapShader") == 0 ) { + if (trap_Argc() == 4) { + char shader1[MAX_QPATH]; + char shader2[MAX_QPATH]; + Q_strncpyz(shader1, UI_Argv(1), sizeof(shader1)); + Q_strncpyz(shader2, UI_Argv(2), sizeof(shader2)); + trap_R_RemapShader(shader1, shader2, UI_Argv(3)); + return qtrue; + } + } + + if ( Q_stricmp (cmd, "postgame") == 0 ) { + UI_CalcPostGameStats(); + return qtrue; + } + + if ( Q_stricmp (cmd, "ui_cache") == 0 ) { + UI_Cache_f(); + return qtrue; + } + + if ( Q_stricmp (cmd, "ui_teamOrders") == 0 ) { + //UI_TeamOrdersMenu_f(); + return qtrue; + } if( Q_stricmp ( cmd, "menu" ) == 0 ) { @@ -358,11 +358,11 @@ qboolean UI_ConsoleCommand( int realTime ) if( Menu_Count( ) > 0 ) { trap_Key_SetCatcher( KEYCATCH_UI ); - Menus_ActivateByName( arg1 ); + Menus_ActivateByName( arg1 ); return qtrue; } } - + if( Q_stricmp ( cmd, "closemenus" ) == 0 ) { if( Menu_Count( ) > 0 ) @@ -374,13 +374,13 @@ qboolean UI_ConsoleCommand( int realTime ) return qtrue; } } - - if ( Q_stricmp (cmd, "ui_cdkey") == 0 ) { - //UI_CDKeyMenu_f(); - return qtrue; - } - return qfalse; + if ( Q_stricmp (cmd, "ui_cdkey") == 0 ) { + //UI_CDKeyMenu_f(); + return qtrue; + } + + return qfalse; } /* @@ -399,57 +399,57 @@ Adjusted for resolution and screen aspect ratio ================ */ void UI_AdjustFrom640( float *x, float *y, float *w, float *h ) { - // expect valid pointers + // expect valid pointers #if 0 - *x = *x * uiInfo.uiDC.scale + uiInfo.uiDC.bias; - *y *= uiInfo.uiDC.scale; - *w *= uiInfo.uiDC.scale; - *h *= uiInfo.uiDC.scale; + *x = *x * uiInfo.uiDC.scale + uiInfo.uiDC.bias; + *y *= uiInfo.uiDC.scale; + *w *= uiInfo.uiDC.scale; + *h *= uiInfo.uiDC.scale; #endif - *x *= uiInfo.uiDC.xscale; - *y *= uiInfo.uiDC.yscale; - *w *= uiInfo.uiDC.xscale; - *h *= uiInfo.uiDC.yscale; + *x *= uiInfo.uiDC.xscale; + *y *= uiInfo.uiDC.yscale; + *w *= uiInfo.uiDC.xscale; + *h *= uiInfo.uiDC.yscale; } void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ) { - qhandle_t hShader; + qhandle_t hShader; - hShader = trap_R_RegisterShaderNoMip( picname ); - UI_AdjustFrom640( &x, &y, &width, &height ); - trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader ); + hShader = trap_R_RegisterShaderNoMip( picname ); + UI_AdjustFrom640( &x, &y, &width, &height ); + trap_R_DrawStretchPic( x, y, width, height, 0, 0, 1, 1, hShader ); } void UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader ) { - float s0; - float s1; - float t0; - float t1; - - if( w < 0 ) { // flip about vertical - w = -w; - s0 = 1; - s1 = 0; - } - else { - s0 = 0; - s1 = 1; - } - - if( h < 0 ) { // flip about horizontal - h = -h; - t0 = 1; - t1 = 0; - } - else { - t0 = 0; - t1 = 1; - } - - UI_AdjustFrom640( &x, &y, &w, &h ); - trap_R_DrawStretchPic( x, y, w, h, s0, t0, s1, t1, hShader ); + float s0; + float s1; + float t0; + float t1; + + if( w < 0 ) { // flip about vertical + w = -w; + s0 = 1; + s1 = 0; + } + else { + s0 = 0; + s1 = 1; + } + + if( h < 0 ) { // flip about horizontal + h = -h; + t0 = 1; + t1 = 0; + } + else { + t0 = 0; + t1 = 1; + } + + UI_AdjustFrom640( &x, &y, &w, &h ); + trap_R_DrawStretchPic( x, y, w, h, s0, t0, s1, t1, hShader ); } /* @@ -460,24 +460,24 @@ Coordinates are 640*480 virtual values ================= */ void UI_FillRect( float x, float y, float width, float height, const float *color ) { - trap_R_SetColor( color ); + trap_R_SetColor( color ); - UI_AdjustFrom640( &x, &y, &width, &height ); - trap_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); + UI_AdjustFrom640( &x, &y, &width, &height ); + trap_R_DrawStretchPic( x, y, width, height, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); - trap_R_SetColor( NULL ); + trap_R_SetColor( NULL ); } void UI_DrawSides(float x, float y, float w, float h) { - UI_AdjustFrom640( &x, &y, &w, &h ); - trap_R_DrawStretchPic( x, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); - trap_R_DrawStretchPic( x + w - 1, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); + UI_AdjustFrom640( &x, &y, &w, &h ); + trap_R_DrawStretchPic( x, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); + trap_R_DrawStretchPic( x + w - 1, y, 1, h, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); } void UI_DrawTopBottom(float x, float y, float w, float h) { - UI_AdjustFrom640( &x, &y, &w, &h ); - trap_R_DrawStretchPic( x, y, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); - trap_R_DrawStretchPic( x, y + h - 1, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); + UI_AdjustFrom640( &x, &y, &w, &h ); + trap_R_DrawStretchPic( x, y, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); + trap_R_DrawStretchPic( x, y + h - 1, w, 1, 0, 0, 0, 0, uiInfo.uiDC.whiteShader ); } /* ================ @@ -487,36 +487,36 @@ Coordinates are 640*480 virtual values ================= */ void UI_DrawRect( float x, float y, float width, float height, const float *color ) { - trap_R_SetColor( color ); + trap_R_SetColor( color ); UI_DrawTopBottom(x, y, width, height); UI_DrawSides(x, y, width, height); - trap_R_SetColor( NULL ); + trap_R_SetColor( NULL ); } void UI_SetColor( const float *rgba ) { - trap_R_SetColor( rgba ); + trap_R_SetColor( rgba ); } void UI_UpdateScreen( void ) { - trap_UpdateScreen(); + trap_UpdateScreen(); } void UI_DrawTextBox (int x, int y, int width, int lines) { - UI_FillRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorBlack ); - UI_DrawRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorWhite ); + UI_FillRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorBlack ); + UI_DrawRect( x + BIGCHAR_WIDTH/2, y + BIGCHAR_HEIGHT/2, ( width + 1 ) * BIGCHAR_WIDTH, ( lines + 1 ) * BIGCHAR_HEIGHT, colorWhite ); } qboolean UI_CursorInRect (int x, int y, int width, int height) { - if (uiInfo.uiDC.cursorx < x || - uiInfo.uiDC.cursory < y || - uiInfo.uiDC.cursorx > x+width || - uiInfo.uiDC.cursory > y+height) - return qfalse; + if (uiInfo.uiDC.cursorx < x || + uiInfo.uiDC.cursory < y || + uiInfo.uiDC.cursorx > x+width || + uiInfo.uiDC.cursory > y+height) + return qfalse; - return qtrue; + return qtrue; } diff --git a/src/ui/ui_gameinfo.c b/src/ui/ui_gameinfo.c index 5a04db53..49d0cdb0 100644 --- a/src/ui/ui_gameinfo.c +++ b/src/ui/ui_gameinfo.c @@ -160,7 +160,7 @@ void UI_LoadArenas( void ) { // determine type type = Info_ValueForKey( ui_arenaInfos[ n ], "type" ); // if no type specified, it will be treated as "ffa" - + if( *type && strstr( type, "tremulous" ) ) uiInfo.mapList[ uiInfo.mapCount ].typeBits |= ( 1 << 0 ); else diff --git a/src/ui/ui_local.h b/src/ui/ui_local.h index aa8d7aa7..8809eafc 100644 --- a/src/ui/ui_local.h +++ b/src/ui/ui_local.h @@ -26,324 +26,324 @@ // global display context -extern vmCvar_t ui_ffa_fraglimit; -extern vmCvar_t ui_ffa_timelimit; - -extern vmCvar_t ui_tourney_fraglimit; -extern vmCvar_t ui_tourney_timelimit; - -extern vmCvar_t ui_team_fraglimit; -extern vmCvar_t ui_team_timelimit; -extern vmCvar_t ui_team_friendly; - -extern vmCvar_t ui_ctf_capturelimit; -extern vmCvar_t ui_ctf_timelimit; -extern vmCvar_t ui_ctf_friendly; - -extern vmCvar_t ui_arenasFile; -extern vmCvar_t ui_botsFile; -extern vmCvar_t ui_spScores1; -extern vmCvar_t ui_spScores2; -extern vmCvar_t ui_spScores3; -extern vmCvar_t ui_spScores4; -extern vmCvar_t ui_spScores5; -extern vmCvar_t ui_spAwards; -extern vmCvar_t ui_spVideos; -extern vmCvar_t ui_spSkill; - -extern vmCvar_t ui_spSelection; - -extern vmCvar_t ui_browserMaster; -extern vmCvar_t ui_browserGameType; -extern vmCvar_t ui_browserSortKey; -extern vmCvar_t ui_browserShowFull; -extern vmCvar_t ui_browserShowEmpty; - -extern vmCvar_t ui_brassTime; -extern vmCvar_t ui_drawCrosshair; -extern vmCvar_t ui_drawCrosshairNames; -extern vmCvar_t ui_marks; - -extern vmCvar_t ui_server1; -extern vmCvar_t ui_server2; -extern vmCvar_t ui_server3; -extern vmCvar_t ui_server4; -extern vmCvar_t ui_server5; -extern vmCvar_t ui_server6; -extern vmCvar_t ui_server7; -extern vmCvar_t ui_server8; -extern vmCvar_t ui_server9; -extern vmCvar_t ui_server10; -extern vmCvar_t ui_server11; -extern vmCvar_t ui_server12; -extern vmCvar_t ui_server13; -extern vmCvar_t ui_server14; -extern vmCvar_t ui_server15; -extern vmCvar_t ui_server16; - -extern vmCvar_t ui_cdkey; -extern vmCvar_t ui_cdkeychecked; - -extern vmCvar_t ui_captureLimit; -extern vmCvar_t ui_fragLimit; -extern vmCvar_t ui_gameType; -extern vmCvar_t ui_netGameType; -extern vmCvar_t ui_actualNetGameType; -extern vmCvar_t ui_joinGameType; -extern vmCvar_t ui_netSource; -extern vmCvar_t ui_serverFilterType; -extern vmCvar_t ui_dedicated; -extern vmCvar_t ui_opponentName; -extern vmCvar_t ui_menuFiles; -extern vmCvar_t ui_currentTier; -extern vmCvar_t ui_currentMap; -extern vmCvar_t ui_currentNetMap; -extern vmCvar_t ui_mapIndex; -extern vmCvar_t ui_currentOpponent; -extern vmCvar_t ui_selectedPlayer; -extern vmCvar_t ui_selectedPlayerName; -extern vmCvar_t ui_lastServerRefresh_0; -extern vmCvar_t ui_lastServerRefresh_1; -extern vmCvar_t ui_lastServerRefresh_2; -extern vmCvar_t ui_lastServerRefresh_3; -extern vmCvar_t ui_singlePlayerActive; -extern vmCvar_t ui_scoreAccuracy; -extern vmCvar_t ui_scoreImpressives; -extern vmCvar_t ui_scoreExcellents; -extern vmCvar_t ui_scoreDefends; -extern vmCvar_t ui_scoreAssists; -extern vmCvar_t ui_scoreGauntlets; -extern vmCvar_t ui_scoreScore; -extern vmCvar_t ui_scorePerfect; -extern vmCvar_t ui_scoreTeam; -extern vmCvar_t ui_scoreBase; -extern vmCvar_t ui_scoreTimeBonus; -extern vmCvar_t ui_scoreSkillBonus; -extern vmCvar_t ui_scoreShutoutBonus; -extern vmCvar_t ui_scoreTime; -extern vmCvar_t ui_smallFont; -extern vmCvar_t ui_bigFont; +extern vmCvar_t ui_ffa_fraglimit; +extern vmCvar_t ui_ffa_timelimit; + +extern vmCvar_t ui_tourney_fraglimit; +extern vmCvar_t ui_tourney_timelimit; + +extern vmCvar_t ui_team_fraglimit; +extern vmCvar_t ui_team_timelimit; +extern vmCvar_t ui_team_friendly; + +extern vmCvar_t ui_ctf_capturelimit; +extern vmCvar_t ui_ctf_timelimit; +extern vmCvar_t ui_ctf_friendly; + +extern vmCvar_t ui_arenasFile; +extern vmCvar_t ui_botsFile; +extern vmCvar_t ui_spScores1; +extern vmCvar_t ui_spScores2; +extern vmCvar_t ui_spScores3; +extern vmCvar_t ui_spScores4; +extern vmCvar_t ui_spScores5; +extern vmCvar_t ui_spAwards; +extern vmCvar_t ui_spVideos; +extern vmCvar_t ui_spSkill; + +extern vmCvar_t ui_spSelection; + +extern vmCvar_t ui_browserMaster; +extern vmCvar_t ui_browserGameType; +extern vmCvar_t ui_browserSortKey; +extern vmCvar_t ui_browserShowFull; +extern vmCvar_t ui_browserShowEmpty; + +extern vmCvar_t ui_brassTime; +extern vmCvar_t ui_drawCrosshair; +extern vmCvar_t ui_drawCrosshairNames; +extern vmCvar_t ui_marks; + +extern vmCvar_t ui_server1; +extern vmCvar_t ui_server2; +extern vmCvar_t ui_server3; +extern vmCvar_t ui_server4; +extern vmCvar_t ui_server5; +extern vmCvar_t ui_server6; +extern vmCvar_t ui_server7; +extern vmCvar_t ui_server8; +extern vmCvar_t ui_server9; +extern vmCvar_t ui_server10; +extern vmCvar_t ui_server11; +extern vmCvar_t ui_server12; +extern vmCvar_t ui_server13; +extern vmCvar_t ui_server14; +extern vmCvar_t ui_server15; +extern vmCvar_t ui_server16; + +extern vmCvar_t ui_cdkey; +extern vmCvar_t ui_cdkeychecked; + +extern vmCvar_t ui_captureLimit; +extern vmCvar_t ui_fragLimit; +extern vmCvar_t ui_gameType; +extern vmCvar_t ui_netGameType; +extern vmCvar_t ui_actualNetGameType; +extern vmCvar_t ui_joinGameType; +extern vmCvar_t ui_netSource; +extern vmCvar_t ui_serverFilterType; +extern vmCvar_t ui_dedicated; +extern vmCvar_t ui_opponentName; +extern vmCvar_t ui_menuFiles; +extern vmCvar_t ui_currentTier; +extern vmCvar_t ui_currentMap; +extern vmCvar_t ui_currentNetMap; +extern vmCvar_t ui_mapIndex; +extern vmCvar_t ui_currentOpponent; +extern vmCvar_t ui_selectedPlayer; +extern vmCvar_t ui_selectedPlayerName; +extern vmCvar_t ui_lastServerRefresh_0; +extern vmCvar_t ui_lastServerRefresh_1; +extern vmCvar_t ui_lastServerRefresh_2; +extern vmCvar_t ui_lastServerRefresh_3; +extern vmCvar_t ui_singlePlayerActive; +extern vmCvar_t ui_scoreAccuracy; +extern vmCvar_t ui_scoreImpressives; +extern vmCvar_t ui_scoreExcellents; +extern vmCvar_t ui_scoreDefends; +extern vmCvar_t ui_scoreAssists; +extern vmCvar_t ui_scoreGauntlets; +extern vmCvar_t ui_scoreScore; +extern vmCvar_t ui_scorePerfect; +extern vmCvar_t ui_scoreTeam; +extern vmCvar_t ui_scoreBase; +extern vmCvar_t ui_scoreTimeBonus; +extern vmCvar_t ui_scoreSkillBonus; +extern vmCvar_t ui_scoreShutoutBonus; +extern vmCvar_t ui_scoreTime; +extern vmCvar_t ui_smallFont; +extern vmCvar_t ui_bigFont; extern vmCvar_t ui_serverStatusTimeOut; //TA: bank values -extern vmCvar_t ui_bank; +extern vmCvar_t ui_bank; // // ui_qmenu.c // -#define RCOLUMN_OFFSET ( BIGCHAR_WIDTH ) -#define LCOLUMN_OFFSET (-BIGCHAR_WIDTH ) - -#define SLIDER_RANGE 10 -#define MAX_EDIT_LINE 256 - -#define MAX_MENUDEPTH 8 -#define MAX_MENUITEMS 96 - -#define MTYPE_NULL 0 -#define MTYPE_SLIDER 1 -#define MTYPE_ACTION 2 -#define MTYPE_SPINCONTROL 3 -#define MTYPE_FIELD 4 -#define MTYPE_RADIOBUTTON 5 -#define MTYPE_BITMAP 6 -#define MTYPE_TEXT 7 -#define MTYPE_SCROLLLIST 8 -#define MTYPE_PTEXT 9 -#define MTYPE_BTEXT 10 - -#define QMF_BLINK 0x00000001 -#define QMF_SMALLFONT 0x00000002 -#define QMF_LEFT_JUSTIFY 0x00000004 -#define QMF_CENTER_JUSTIFY 0x00000008 -#define QMF_RIGHT_JUSTIFY 0x00000010 -#define QMF_NUMBERSONLY 0x00000020 // edit field is only numbers -#define QMF_HIGHLIGHT 0x00000040 -#define QMF_HIGHLIGHT_IF_FOCUS 0x00000080 // steady focus -#define QMF_PULSEIFFOCUS 0x00000100 // pulse if focus -#define QMF_HASMOUSEFOCUS 0x00000200 -#define QMF_NOONOFFTEXT 0x00000400 -#define QMF_MOUSEONLY 0x00000800 // only mouse input allowed -#define QMF_HIDDEN 0x00001000 // skips drawing -#define QMF_GRAYED 0x00002000 // grays and disables -#define QMF_INACTIVE 0x00004000 // disables any input -#define QMF_NODEFAULTINIT 0x00008000 // skip default initialization -#define QMF_OWNERDRAW 0x00010000 -#define QMF_PULSE 0x00020000 -#define QMF_LOWERCASE 0x00040000 // edit field is all lower case -#define QMF_UPPERCASE 0x00080000 // edit field is all upper case -#define QMF_SILENT 0x00100000 +#define RCOLUMN_OFFSET ( BIGCHAR_WIDTH ) +#define LCOLUMN_OFFSET (-BIGCHAR_WIDTH ) + +#define SLIDER_RANGE 10 +#define MAX_EDIT_LINE 256 + +#define MAX_MENUDEPTH 8 +#define MAX_MENUITEMS 96 + +#define MTYPE_NULL 0 +#define MTYPE_SLIDER 1 +#define MTYPE_ACTION 2 +#define MTYPE_SPINCONTROL 3 +#define MTYPE_FIELD 4 +#define MTYPE_RADIOBUTTON 5 +#define MTYPE_BITMAP 6 +#define MTYPE_TEXT 7 +#define MTYPE_SCROLLLIST 8 +#define MTYPE_PTEXT 9 +#define MTYPE_BTEXT 10 + +#define QMF_BLINK 0x00000001 +#define QMF_SMALLFONT 0x00000002 +#define QMF_LEFT_JUSTIFY 0x00000004 +#define QMF_CENTER_JUSTIFY 0x00000008 +#define QMF_RIGHT_JUSTIFY 0x00000010 +#define QMF_NUMBERSONLY 0x00000020 // edit field is only numbers +#define QMF_HIGHLIGHT 0x00000040 +#define QMF_HIGHLIGHT_IF_FOCUS 0x00000080 // steady focus +#define QMF_PULSEIFFOCUS 0x00000100 // pulse if focus +#define QMF_HASMOUSEFOCUS 0x00000200 +#define QMF_NOONOFFTEXT 0x00000400 +#define QMF_MOUSEONLY 0x00000800 // only mouse input allowed +#define QMF_HIDDEN 0x00001000 // skips drawing +#define QMF_GRAYED 0x00002000 // grays and disables +#define QMF_INACTIVE 0x00004000 // disables any input +#define QMF_NODEFAULTINIT 0x00008000 // skip default initialization +#define QMF_OWNERDRAW 0x00010000 +#define QMF_PULSE 0x00020000 +#define QMF_LOWERCASE 0x00040000 // edit field is all lower case +#define QMF_UPPERCASE 0x00080000 // edit field is all upper case +#define QMF_SILENT 0x00100000 // callback notifications -#define QM_GOTFOCUS 1 -#define QM_LOSTFOCUS 2 -#define QM_ACTIVATED 3 +#define QM_GOTFOCUS 1 +#define QM_LOSTFOCUS 2 +#define QM_ACTIVATED 3 typedef struct _tag_menuframework { - int cursor; - int cursor_prev; + int cursor; + int cursor_prev; - int nitems; - void *items[MAX_MENUITEMS]; + int nitems; + void *items[MAX_MENUITEMS]; - void (*draw) (void); - sfxHandle_t (*key) (int key); + void (*draw) (void); + sfxHandle_t (*key) (int key); - qboolean wrapAround; - qboolean fullscreen; - qboolean showlogo; + qboolean wrapAround; + qboolean fullscreen; + qboolean showlogo; } menuframework_s; typedef struct { - int type; - const char *name; - int id; - int x, y; - int left; - int top; - int right; - int bottom; - menuframework_s *parent; - int menuPosition; - unsigned flags; - - void (*callback)( void *self, int event ); - void (*statusbar)( void *self ); - void (*ownerdraw)( void *self ); + int type; + const char *name; + int id; + int x, y; + int left; + int top; + int right; + int bottom; + menuframework_s *parent; + int menuPosition; + unsigned flags; + + void (*callback)( void *self, int event ); + void (*statusbar)( void *self ); + void (*ownerdraw)( void *self ); } menucommon_s; typedef struct { - int cursor; - int scroll; - int widthInChars; - char buffer[MAX_EDIT_LINE]; - int maxchars; + int cursor; + int scroll; + int widthInChars; + char buffer[MAX_EDIT_LINE]; + int maxchars; } mfield_t; typedef struct { - menucommon_s generic; - mfield_t field; + menucommon_s generic; + mfield_t field; } menufield_s; -typedef struct +typedef struct { - menucommon_s generic; + menucommon_s generic; - float minvalue; - float maxvalue; - float curvalue; + float minvalue; + float maxvalue; + float curvalue; - float range; + float range; } menuslider_s; typedef struct { - menucommon_s generic; - - int oldvalue; - int curvalue; - int numitems; - int top; - - const char **itemnames; - - int width; - int height; - int columns; - int seperation; + menucommon_s generic; + + int oldvalue; + int curvalue; + int numitems; + int top; + + const char **itemnames; + + int width; + int height; + int columns; + int seperation; } menulist_s; typedef struct { - menucommon_s generic; + menucommon_s generic; } menuaction_s; typedef struct { - menucommon_s generic; - int curvalue; + menucommon_s generic; + int curvalue; } menuradiobutton_s; typedef struct { - menucommon_s generic; - char* focuspic; - char* errorpic; - qhandle_t shader; - qhandle_t focusshader; - int width; - int height; - float* focuscolor; + menucommon_s generic; + char* focuspic; + char* errorpic; + qhandle_t shader; + qhandle_t focusshader; + int width; + int height; + float* focuscolor; } menubitmap_s; typedef struct { - menucommon_s generic; - char* string; - int style; - float* color; + menucommon_s generic; + char* string; + int style; + float* color; } menutext_s; -extern void Menu_Cache( void ); -extern void Menu_Focus( menucommon_s *m ); -extern void Menu_AddItem( menuframework_s *menu, void *item ); -extern void Menu_AdjustCursor( menuframework_s *menu, int dir ); -extern void Menu_Draw( menuframework_s *menu ); -extern void *Menu_ItemAtCursor( menuframework_s *m ); -extern sfxHandle_t Menu_ActivateItem( menuframework_s *s, menucommon_s* item ); -extern void Menu_SetCursor( menuframework_s *s, int cursor ); -extern void Menu_SetCursorToItem( menuframework_s *m, void* ptr ); -extern sfxHandle_t Menu_DefaultKey( menuframework_s *s, int key ); -extern void Bitmap_Init( menubitmap_s *b ); -extern void Bitmap_Draw( menubitmap_s *b ); -extern void ScrollList_Draw( menulist_s *l ); -extern sfxHandle_t ScrollList_Key( menulist_s *l, int key ); -extern sfxHandle_t menu_in_sound; -extern sfxHandle_t menu_move_sound; -extern sfxHandle_t menu_out_sound; -extern sfxHandle_t menu_buzz_sound; -extern sfxHandle_t menu_null_sound; -extern sfxHandle_t weaponChangeSound; -extern vec4_t menu_text_color; -extern vec4_t menu_grayed_color; -extern vec4_t menu_dark_color; -extern vec4_t menu_highlight_color; -extern vec4_t menu_red_color; -extern vec4_t menu_black_color; -extern vec4_t menu_dim_color; -extern vec4_t color_black; -extern vec4_t color_white; -extern vec4_t color_yellow; -extern vec4_t color_blue; -extern vec4_t color_orange; -extern vec4_t color_red; -extern vec4_t color_dim; -extern vec4_t name_color; -extern vec4_t list_color; -extern vec4_t listbar_color; -extern vec4_t text_color_disabled; -extern vec4_t text_color_normal; -extern vec4_t text_color_highlight; - -extern char *ui_medalNames[]; -extern char *ui_medalPicNames[]; -extern char *ui_medalSounds[]; +extern void Menu_Cache( void ); +extern void Menu_Focus( menucommon_s *m ); +extern void Menu_AddItem( menuframework_s *menu, void *item ); +extern void Menu_AdjustCursor( menuframework_s *menu, int dir ); +extern void Menu_Draw( menuframework_s *menu ); +extern void *Menu_ItemAtCursor( menuframework_s *m ); +extern sfxHandle_t Menu_ActivateItem( menuframework_s *s, menucommon_s* item ); +extern void Menu_SetCursor( menuframework_s *s, int cursor ); +extern void Menu_SetCursorToItem( menuframework_s *m, void* ptr ); +extern sfxHandle_t Menu_DefaultKey( menuframework_s *s, int key ); +extern void Bitmap_Init( menubitmap_s *b ); +extern void Bitmap_Draw( menubitmap_s *b ); +extern void ScrollList_Draw( menulist_s *l ); +extern sfxHandle_t ScrollList_Key( menulist_s *l, int key ); +extern sfxHandle_t menu_in_sound; +extern sfxHandle_t menu_move_sound; +extern sfxHandle_t menu_out_sound; +extern sfxHandle_t menu_buzz_sound; +extern sfxHandle_t menu_null_sound; +extern sfxHandle_t weaponChangeSound; +extern vec4_t menu_text_color; +extern vec4_t menu_grayed_color; +extern vec4_t menu_dark_color; +extern vec4_t menu_highlight_color; +extern vec4_t menu_red_color; +extern vec4_t menu_black_color; +extern vec4_t menu_dim_color; +extern vec4_t color_black; +extern vec4_t color_white; +extern vec4_t color_yellow; +extern vec4_t color_blue; +extern vec4_t color_orange; +extern vec4_t color_red; +extern vec4_t color_dim; +extern vec4_t name_color; +extern vec4_t list_color; +extern vec4_t listbar_color; +extern vec4_t text_color_disabled; +extern vec4_t text_color_normal; +extern vec4_t text_color_highlight; + +extern char *ui_medalNames[]; +extern char *ui_medalPicNames[]; +extern char *ui_medalSounds[]; // // ui_mfield.c // -extern void MField_Clear( mfield_t *edit ); -extern void MField_KeyDownEvent( mfield_t *edit, int key ); -extern void MField_CharEvent( mfield_t *edit, int ch ); -extern void MField_Draw( mfield_t *edit, int x, int y, int style, vec4_t color ); -extern void MenuField_Init( menufield_s* m ); -extern void MenuField_Draw( menufield_s *f ); -extern sfxHandle_t MenuField_Key( menufield_s* m, int* key ); +extern void MField_Clear( mfield_t *edit ); +extern void MField_KeyDownEvent( mfield_t *edit, int key ); +extern void MField_CharEvent( mfield_t *edit, int ch ); +extern void MField_Draw( mfield_t *edit, int x, int y, int style, vec4_t color ); +extern void MenuField_Init( menufield_s* m ); +extern void MenuField_Draw( menufield_s *f ); +extern sfxHandle_t MenuField_Key( menufield_s* m, int* key ); // // ui_main.c @@ -497,71 +497,71 @@ extern void DriverInfo_Cache( void ); //FIXME ripped from cg_local.h typedef struct { - int oldFrame; - int oldFrameTime; // time when ->oldFrame was exactly on + int oldFrame; + int oldFrameTime; // time when ->oldFrame was exactly on - int frame; - int frameTime; // time when ->frame will be exactly on + int frame; + int frameTime; // time when ->frame will be exactly on - float backlerp; + float backlerp; - float yawAngle; - qboolean yawing; - float pitchAngle; - qboolean pitching; + float yawAngle; + qboolean yawing; + float pitchAngle; + qboolean pitching; - int animationNumber; // may include ANIM_TOGGLEBIT - animation_t *animation; - int animationTime; // time when the first frame of the animation will be exact + int animationNumber; // may include ANIM_TOGGLEBIT + animation_t *animation; + int animationTime; // time when the first frame of the animation will be exact } lerpFrame_t; typedef struct { - // model info - qhandle_t legsModel; - qhandle_t legsSkin; - lerpFrame_t legs; - - qhandle_t torsoModel; - qhandle_t torsoSkin; - lerpFrame_t torso; - - qhandle_t headModel; - qhandle_t headSkin; - - animation_t animations[MAX_PLAYER_TOTALANIMATIONS]; - - qhandle_t weaponModel; - qhandle_t barrelModel; - qhandle_t flashModel; - vec3_t flashDlightColor; - int muzzleFlashTime; - - // currently in use drawing parms - vec3_t viewAngles; - vec3_t moveAngles; - weapon_t currentWeapon; - int legsAnim; - int torsoAnim; - - // animation vars - weapon_t weapon; - weapon_t lastWeapon; - weapon_t pendingWeapon; - int weaponTimer; - int pendingLegsAnim; - int torsoAnimationTimer; - - int pendingTorsoAnim; - int legsAnimationTimer; - - qboolean chat; - qboolean newModel; - - qboolean barrelSpinning; - float barrelAngle; - int barrelTime; - - int realWeapon; + // model info + qhandle_t legsModel; + qhandle_t legsSkin; + lerpFrame_t legs; + + qhandle_t torsoModel; + qhandle_t torsoSkin; + lerpFrame_t torso; + + qhandle_t headModel; + qhandle_t headSkin; + + animation_t animations[MAX_PLAYER_TOTALANIMATIONS]; + + qhandle_t weaponModel; + qhandle_t barrelModel; + qhandle_t flashModel; + vec3_t flashDlightColor; + int muzzleFlashTime; + + // currently in use drawing parms + vec3_t viewAngles; + vec3_t moveAngles; + weapon_t currentWeapon; + int legsAnim; + int torsoAnim; + + // animation vars + weapon_t weapon; + weapon_t lastWeapon; + weapon_t pendingWeapon; + int weaponTimer; + int pendingLegsAnim; + int torsoAnimationTimer; + + int pendingTorsoAnim; + int legsAnimationTimer; + + qboolean chat; + qboolean newModel; + + qboolean barrelSpinning; + float barrelAngle; + int barrelTime; + + int realWeapon; } playerInfo_t; void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time ); @@ -574,27 +574,27 @@ qboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName // // this is only used in the old ui, the new ui has it's own version typedef struct { - int frametime; - int realtime; - int cursorx; - int cursory; - glconfig_t glconfig; - qboolean debug; - qhandle_t whiteShader; - qhandle_t menuBackShader; - qhandle_t menuBackShader2; - qhandle_t menuBackNoLogoShader; - qhandle_t charset; - qhandle_t charsetProp; - qhandle_t charsetPropGlow; - qhandle_t charsetPropB; - qhandle_t cursor; - qhandle_t rb_on; - qhandle_t rb_off; - float scale; - float bias; - qboolean demoversion; - qboolean firstdraw; + int frametime; + int realtime; + int cursorx; + int cursory; + glconfig_t glconfig; + qboolean debug; + qhandle_t whiteShader; + qhandle_t menuBackShader; + qhandle_t menuBackShader2; + qhandle_t menuBackNoLogoShader; + qhandle_t charset; + qhandle_t charsetProp; + qhandle_t charsetPropGlow; + qhandle_t charsetPropB; + qhandle_t cursor; + qhandle_t rb_on; + qhandle_t rb_off; + float scale; + float bias; + qboolean demoversion; + qboolean firstdraw; } uiStatic_t; @@ -608,23 +608,23 @@ typedef struct { #define MAX_MAPS 128 #define MAX_SPMAPS 16 #define PLAYERS_PER_TEAM 5 -#define MAX_PINGREQUESTS 32 -#define MAX_ADDRESSLENGTH 64 -#define MAX_HOSTNAMELENGTH 22 -#define MAX_MAPNAMELENGTH 16 -#define MAX_STATUSLENGTH 64 -#define MAX_LISTBOXWIDTH 59 -#define UI_FONT_THRESHOLD 0.1 -#define MAX_DISPLAY_SERVERS 2048 -#define MAX_SERVERSTATUS_LINES 128 -#define MAX_SERVERSTATUS_TEXT 1024 -#define MAX_FOUNDPLAYER_SERVERS 16 +#define MAX_PINGREQUESTS 32 +#define MAX_ADDRESSLENGTH 64 +#define MAX_HOSTNAMELENGTH 22 +#define MAX_MAPNAMELENGTH 16 +#define MAX_STATUSLENGTH 64 +#define MAX_LISTBOXWIDTH 59 +#define UI_FONT_THRESHOLD 0.1 +#define MAX_DISPLAY_SERVERS 2048 +#define MAX_SERVERSTATUS_LINES 128 +#define MAX_SERVERSTATUS_TEXT 1024 +#define MAX_FOUNDPLAYER_SERVERS 16 #define TEAM_MEMBERS 5 -#define GAMES_ALL 0 -#define GAMES_FFA 1 -#define GAMES_TEAMPLAY 2 -#define GAMES_TOURNEY 3 -#define GAMES_CTF 4 +#define GAMES_ALL 0 +#define GAMES_FFA 1 +#define GAMES_TEAMPLAY 2 +#define GAMES_TOURNEY 3 +#define GAMES_CTF 4 #define MAPS_PER_TIER 3 #define MAX_TIERS 16 #define MAX_MODS 64 @@ -635,27 +635,27 @@ typedef struct { typedef struct { const char *name; - const char *imageName; + const char *imageName; qhandle_t headImage; - const char *base; - qboolean active; - int reference; + const char *base; + qboolean active; + int reference; } characterInfo; typedef struct { - const char *name; - const char *ai; - const char *action; + const char *name; + const char *ai; + const char *action; } aliasInfo; typedef struct { const char *teamName; - const char *imageName; - const char *teamMembers[TEAM_MEMBERS]; + const char *imageName; + const char *teamMembers[TEAM_MEMBERS]; qhandle_t teamIcon; qhandle_t teamIcon_Metal; qhandle_t teamIcon_Name; - int cinematic; + int cinematic; } teamInfo; typedef struct { @@ -666,88 +666,88 @@ typedef struct { typedef struct { const char *mapName; const char *mapLoadName; - const char *imageName; - const char *opponentName; - int teamMembers; + const char *imageName; + const char *opponentName; + int teamMembers; int typeBits; - int cinematic; - int timeToBeat[MAX_GAMETYPES]; - qhandle_t levelShot; - qboolean active; + int cinematic; + int timeToBeat[MAX_GAMETYPES]; + qhandle_t levelShot; + qboolean active; } mapInfo; typedef struct { - const char *tierName; - const char *maps[MAPS_PER_TIER]; - int gameTypes[MAPS_PER_TIER]; - qhandle_t mapHandles[MAPS_PER_TIER]; + const char *tierName; + const char *maps[MAPS_PER_TIER]; + int gameTypes[MAPS_PER_TIER]; + qhandle_t mapHandles[MAPS_PER_TIER]; } tierInfo; typedef struct serverFilter_s { - const char *description; - const char *basedir; + const char *description; + const char *basedir; } serverFilter_t; typedef struct { - char adrstr[MAX_ADDRESSLENGTH]; - int start; + char adrstr[MAX_ADDRESSLENGTH]; + int start; } pinglist_t; typedef struct serverStatus_s { - pinglist_t pingList[MAX_PINGREQUESTS]; - int numqueriedservers; - int currentping; - int nextpingtime; - int maxservers; - int refreshtime; - int numServers; - int sortKey; - int sortDir; - int lastCount; - qboolean refreshActive; - int currentServer; - int displayServers[MAX_DISPLAY_SERVERS]; - int numDisplayServers; - int numPlayersOnServers; - int nextDisplayRefresh; - int nextSortTime; - qhandle_t currentServerPreview; - int currentServerCinematic; - int motdLen; - int motdWidth; - int motdPaintX; - int motdPaintX2; - int motdOffset; - int motdTime; - char motd[MAX_STRING_CHARS]; + pinglist_t pingList[MAX_PINGREQUESTS]; + int numqueriedservers; + int currentping; + int nextpingtime; + int maxservers; + int refreshtime; + int numServers; + int sortKey; + int sortDir; + int lastCount; + qboolean refreshActive; + int currentServer; + int displayServers[MAX_DISPLAY_SERVERS]; + int numDisplayServers; + int numPlayersOnServers; + int nextDisplayRefresh; + int nextSortTime; + qhandle_t currentServerPreview; + int currentServerCinematic; + int motdLen; + int motdWidth; + int motdPaintX; + int motdPaintX2; + int motdOffset; + int motdTime; + char motd[MAX_STRING_CHARS]; } serverStatus_t; typedef struct { - char adrstr[MAX_ADDRESSLENGTH]; - char name[MAX_ADDRESSLENGTH]; - int startTime; - int serverNum; - qboolean valid; + char adrstr[MAX_ADDRESSLENGTH]; + char name[MAX_ADDRESSLENGTH]; + int startTime; + int serverNum; + qboolean valid; } pendingServer_t; typedef struct { - int num; - pendingServer_t server[MAX_SERVERSTATUSREQUESTS]; + int num; + pendingServer_t server[MAX_SERVERSTATUSREQUESTS]; } pendingServerStatus_t; typedef struct { - char address[MAX_ADDRESSLENGTH]; - char *lines[MAX_SERVERSTATUS_LINES][4]; - char text[MAX_SERVERSTATUS_TEXT]; - char pings[MAX_CLIENTS * 3]; - int numLines; + char address[MAX_ADDRESSLENGTH]; + char *lines[MAX_SERVERSTATUS_LINES][4]; + char text[MAX_SERVERSTATUS_TEXT]; + char pings[MAX_CLIENTS * 3]; + int numLines; } serverStatusInfo_t; typedef struct { - const char *modName; - const char *modDescr; + const char *modName; + const char *modDescr; } modInfo_t; //TA: tremulous menus @@ -778,186 +778,186 @@ typedef struct const char *name; char text[ MAX_INFOPANE_TEXT ]; int align; - + tremIPGraphic_t graphics[ MAX_INFOPANE_GRAPHICS ]; int numGraphics; } tremInfoPane_t; typedef struct { - const char *text; - const char *cmd; - tremInfoPane_t *infopane; + const char *text; + const char *cmd; + tremInfoPane_t *infopane; } tremMenuItem_t; //TA: tremulous menus typedef struct { - displayContextDef_t uiDC; - int newHighScoreTime; - int newBestTime; - int showPostGameTime; - qboolean newHighScore; - qboolean demoAvailable; - qboolean soundHighScore; - - int characterCount; - int botIndex; - characterInfo characterList[MAX_HEADS]; - - int aliasCount; - aliasInfo aliasList[MAX_ALIASES]; - - int teamCount; - teamInfo teamList[MAX_TEAMS]; - - int numGameTypes; - gameTypeInfo gameTypes[MAX_GAMETYPES]; - - int numJoinGameTypes; - gameTypeInfo joinGameTypes[MAX_GAMETYPES]; - - int redBlue; - int playerCount; - int myTeamCount; - int teamIndex; - int playerRefresh; - int playerIndex; - int playerNumber; - qboolean teamLeader; - char playerNames[MAX_CLIENTS][MAX_NAME_LENGTH]; - char teamNames[MAX_CLIENTS][MAX_NAME_LENGTH]; - int teamClientNums[MAX_CLIENTS]; - - int mapCount; - mapInfo mapList[MAX_MAPS]; - - - int tierCount; - tierInfo tierList[MAX_TIERS]; - - int skillIndex; - - modInfo_t modList[MAX_MODS]; - int modCount; - int modIndex; - - const char *demoList[MAX_DEMOS]; - int demoCount; - int demoIndex; - - const char *movieList[MAX_MOVIES]; - int movieCount; - int movieIndex; - int previewMovie; + displayContextDef_t uiDC; + int newHighScoreTime; + int newBestTime; + int showPostGameTime; + qboolean newHighScore; + qboolean demoAvailable; + qboolean soundHighScore; + + int characterCount; + int botIndex; + characterInfo characterList[MAX_HEADS]; + + int aliasCount; + aliasInfo aliasList[MAX_ALIASES]; + + int teamCount; + teamInfo teamList[MAX_TEAMS]; + + int numGameTypes; + gameTypeInfo gameTypes[MAX_GAMETYPES]; + + int numJoinGameTypes; + gameTypeInfo joinGameTypes[MAX_GAMETYPES]; + + int redBlue; + int playerCount; + int myTeamCount; + int teamIndex; + int playerRefresh; + int playerIndex; + int playerNumber; + qboolean teamLeader; + char playerNames[MAX_CLIENTS][MAX_NAME_LENGTH]; + char teamNames[MAX_CLIENTS][MAX_NAME_LENGTH]; + int teamClientNums[MAX_CLIENTS]; + + int mapCount; + mapInfo mapList[MAX_MAPS]; + + + int tierCount; + tierInfo tierList[MAX_TIERS]; + + int skillIndex; + + modInfo_t modList[MAX_MODS]; + int modCount; + int modIndex; + + const char *demoList[MAX_DEMOS]; + int demoCount; + int demoIndex; + + const char *movieList[MAX_MOVIES]; + int movieCount; + int movieIndex; + int previewMovie; tremInfoPane_t tremInfoPanes[ MAX_INFOPANES ]; int tremInfoPaneCount; //TA: tremulous menus - tremMenuItem_t tremTeamList[ 4 ]; - int tremTeamCount; - int tremTeamIndex; - - tremMenuItem_t tremAlienClassList[ 3 ]; - int tremAlienClassCount; - int tremAlienClassIndex; - - tremMenuItem_t tremHumanItemList[ 3 ]; - int tremHumanItemCount; - int tremHumanItemIndex; - - tremMenuItem_t tremHumanArmouryBuyList[ 32 ]; - int tremHumanArmouryBuyCount; - int tremHumanArmouryBuyIndex; - - tremMenuItem_t tremHumanArmourySellList[ 32 ]; - int tremHumanArmourySellCount; - int tremHumanArmourySellIndex; - - tremMenuItem_t tremAlienUpgradeList[ 16 ]; - int tremAlienUpgradeCount; - int tremAlienUpgradeIndex; - - tremMenuItem_t tremAlienBuildList[ 32 ]; - int tremAlienBuildCount; - int tremAlienBuildIndex; - - tremMenuItem_t tremHumanBuildList[ 32 ]; - int tremHumanBuildCount; - int tremHumanBuildIndex; + tremMenuItem_t tremTeamList[ 4 ]; + int tremTeamCount; + int tremTeamIndex; + + tremMenuItem_t tremAlienClassList[ 3 ]; + int tremAlienClassCount; + int tremAlienClassIndex; + + tremMenuItem_t tremHumanItemList[ 3 ]; + int tremHumanItemCount; + int tremHumanItemIndex; + + tremMenuItem_t tremHumanArmouryBuyList[ 32 ]; + int tremHumanArmouryBuyCount; + int tremHumanArmouryBuyIndex; + + tremMenuItem_t tremHumanArmourySellList[ 32 ]; + int tremHumanArmourySellCount; + int tremHumanArmourySellIndex; + + tremMenuItem_t tremAlienUpgradeList[ 16 ]; + int tremAlienUpgradeCount; + int tremAlienUpgradeIndex; + + tremMenuItem_t tremAlienBuildList[ 32 ]; + int tremAlienBuildCount; + int tremAlienBuildIndex; + + tremMenuItem_t tremHumanBuildList[ 32 ]; + int tremHumanBuildCount; + int tremHumanBuildIndex; //TA: tremulous menus - - serverStatus_t serverStatus; - // for the showing the status of a server - char serverStatusAddress[MAX_ADDRESSLENGTH]; - serverStatusInfo_t serverStatusInfo; - int nextServerStatusRefresh; + serverStatus_t serverStatus; + + // for the showing the status of a server + char serverStatusAddress[MAX_ADDRESSLENGTH]; + serverStatusInfo_t serverStatusInfo; + int nextServerStatusRefresh; - // to retrieve the status of server to find a player - pendingServerStatus_t pendingServerStatus; - char findPlayerName[MAX_STRING_CHARS]; - char foundPlayerServerAddresses[MAX_FOUNDPLAYER_SERVERS][MAX_ADDRESSLENGTH]; - char foundPlayerServerNames[MAX_FOUNDPLAYER_SERVERS][MAX_ADDRESSLENGTH]; - int currentFoundPlayerServer; - int numFoundPlayerServers; - int nextFindPlayerRefresh; + // to retrieve the status of server to find a player + pendingServerStatus_t pendingServerStatus; + char findPlayerName[MAX_STRING_CHARS]; + char foundPlayerServerAddresses[MAX_FOUNDPLAYER_SERVERS][MAX_ADDRESSLENGTH]; + char foundPlayerServerNames[MAX_FOUNDPLAYER_SERVERS][MAX_ADDRESSLENGTH]; + int currentFoundPlayerServer; + int numFoundPlayerServers; + int nextFindPlayerRefresh; - int currentCrosshair; - int startPostGameTime; - sfxHandle_t newHighScoreSound; + int currentCrosshair; + int startPostGameTime; + sfxHandle_t newHighScoreSound; - int q3HeadCount; - char q3HeadNames[MAX_PLAYERMODELS][64]; - qhandle_t q3HeadIcons[MAX_PLAYERMODELS]; - int q3SelectedHead; + int q3HeadCount; + char q3HeadNames[MAX_PLAYERMODELS][64]; + qhandle_t q3HeadIcons[MAX_PLAYERMODELS]; + int q3SelectedHead; - int effectsColor; + int effectsColor; - qboolean inGameLoad; -} uiInfo_t; + qboolean inGameLoad; +} uiInfo_t; extern uiInfo_t uiInfo; -extern void UI_Init( void ); -extern void UI_Shutdown( void ); -extern void UI_KeyEvent( int key ); -extern void UI_MouseEvent( int dx, int dy ); -extern void UI_Refresh( int realtime ); -extern qboolean UI_ConsoleCommand( int realTime ); -extern float UI_ClampCvar( float min, float max, float value ); -extern void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ); -extern void UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader ); -extern void UI_FillRect( float x, float y, float width, float height, const float *color ); -extern void UI_DrawRect( float x, float y, float width, float height, const float *color ); +extern void UI_Init( void ); +extern void UI_Shutdown( void ); +extern void UI_KeyEvent( int key ); +extern void UI_MouseEvent( int dx, int dy ); +extern void UI_Refresh( int realtime ); +extern qboolean UI_ConsoleCommand( int realTime ); +extern float UI_ClampCvar( float min, float max, float value ); +extern void UI_DrawNamedPic( float x, float y, float width, float height, const char *picname ); +extern void UI_DrawHandlePic( float x, float y, float w, float h, qhandle_t hShader ); +extern void UI_FillRect( float x, float y, float width, float height, const float *color ); +extern void UI_DrawRect( float x, float y, float width, float height, const float *color ); extern void UI_DrawTopBottom(float x, float y, float w, float h); extern void UI_DrawSides(float x, float y, float w, float h); -extern void UI_UpdateScreen( void ); -extern void UI_SetColor( const float *rgba ); -extern void UI_LerpColor(vec4_t a, vec4_t b, vec4_t c, float t); -extern void UI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color ); -extern float UI_ProportionalSizeScale( int style ); -extern void UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ); -extern int UI_ProportionalStringWidth( const char* str ); -extern void UI_DrawString( int x, int y, const char* str, int style, vec4_t color ); -extern void UI_DrawChar( int x, int y, int ch, int style, vec4_t color ); -extern qboolean UI_CursorInRect (int x, int y, int width, int height); -extern void UI_AdjustFrom640( float *x, float *y, float *w, float *h ); -extern void UI_DrawTextBox (int x, int y, int width, int lines); -extern qboolean UI_IsFullscreen( void ); -extern void UI_SetActiveMenu( uiMenuCommand_t menu ); -extern void UI_PushMenu ( menuframework_s *menu ); -extern void UI_PopMenu (void); -extern void UI_ForceMenuOff (void); -extern char *UI_Argv( int arg ); -extern char *UI_Cvar_VariableString( const char *var_name ); -extern void UI_Refresh( int time ); -extern void UI_KeyEvent( int key ); -extern void UI_StartDemoLoop( void ); -extern qboolean m_entersound; +extern void UI_UpdateScreen( void ); +extern void UI_SetColor( const float *rgba ); +extern void UI_LerpColor(vec4_t a, vec4_t b, vec4_t c, float t); +extern void UI_DrawBannerString( int x, int y, const char* str, int style, vec4_t color ); +extern float UI_ProportionalSizeScale( int style ); +extern void UI_DrawProportionalString( int x, int y, const char* str, int style, vec4_t color ); +extern int UI_ProportionalStringWidth( const char* str ); +extern void UI_DrawString( int x, int y, const char* str, int style, vec4_t color ); +extern void UI_DrawChar( int x, int y, int ch, int style, vec4_t color ); +extern qboolean UI_CursorInRect (int x, int y, int width, int height); +extern void UI_AdjustFrom640( float *x, float *y, float *w, float *h ); +extern void UI_DrawTextBox (int x, int y, int width, int lines); +extern qboolean UI_IsFullscreen( void ); +extern void UI_SetActiveMenu( uiMenuCommand_t menu ); +extern void UI_PushMenu ( menuframework_s *menu ); +extern void UI_PopMenu (void); +extern void UI_ForceMenuOff (void); +extern char *UI_Argv( int arg ); +extern char *UI_Cvar_VariableString( const char *var_name ); +extern void UI_Refresh( int time ); +extern void UI_KeyEvent( int key ); +extern void UI_StartDemoLoop( void ); +extern qboolean m_entersound; void UI_LoadBestScores(const char *map, int game); -extern uiStatic_t uis; +extern uiStatic_t uis; // // ui_spLevel.c @@ -987,87 +987,87 @@ void UI_SPSkillMenu_Cache( void ); // // ui_syscalls.c // -void trap_Print( const char *string ); -void trap_Error( const char *string ); -int trap_Milliseconds( void ); -void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ); -void trap_Cvar_Update( vmCvar_t *vmCvar ); -void trap_Cvar_Set( const char *var_name, const char *value ); -float trap_Cvar_VariableValue( const char *var_name ); -void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ); -void trap_Cvar_SetValue( const char *var_name, float value ); -void trap_Cvar_Reset( const char *name ); -void trap_Cvar_Create( const char *var_name, const char *var_value, int flags ); -void trap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize ); -int trap_Argc( void ); -void trap_Argv( int n, char *buffer, int bufferLength ); -void trap_Cmd_ExecuteText( int exec_when, const char *text ); // don't use EXEC_NOW! -int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ); -void trap_FS_Read( void *buffer, int len, fileHandle_t f ); -void trap_FS_Write( const void *buffer, int len, fileHandle_t f ); -void trap_FS_FCloseFile( fileHandle_t f ); -int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ); +void trap_Print( const char *string ); +void trap_Error( const char *string ); +int trap_Milliseconds( void ); +void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags ); +void trap_Cvar_Update( vmCvar_t *vmCvar ); +void trap_Cvar_Set( const char *var_name, const char *value ); +float trap_Cvar_VariableValue( const char *var_name ); +void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ); +void trap_Cvar_SetValue( const char *var_name, float value ); +void trap_Cvar_Reset( const char *name ); +void trap_Cvar_Create( const char *var_name, const char *var_value, int flags ); +void trap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize ); +int trap_Argc( void ); +void trap_Argv( int n, char *buffer, int bufferLength ); +void trap_Cmd_ExecuteText( int exec_when, const char *text ); // don't use EXEC_NOW! +int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ); +void trap_FS_Read( void *buffer, int len, fileHandle_t f ); +void trap_FS_Write( const void *buffer, int len, fileHandle_t f ); +void trap_FS_FCloseFile( fileHandle_t f ); +int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ); int trap_FS_Seek( fileHandle_t f, long offset, int origin ); // fsOrigin_t -qhandle_t trap_R_RegisterModel( const char *name ); -qhandle_t trap_R_RegisterSkin( const char *name ); -qhandle_t trap_R_RegisterShaderNoMip( const char *name ); -void trap_R_ClearScene( void ); -void trap_R_AddRefEntityToScene( const refEntity_t *re ); -void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ); -void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); -void trap_R_RenderScene( const refdef_t *fd ); -void trap_R_SetColor( const float *rgba ); -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 ); -void trap_UpdateScreen( void ); -int trap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ); -void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ); -sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ); -void trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen ); -void trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ); -void trap_Key_SetBinding( int keynum, const char *binding ); -qboolean trap_Key_IsDown( int keynum ); -qboolean trap_Key_GetOverstrikeMode( void ); -void trap_Key_SetOverstrikeMode( qboolean state ); -void trap_Key_ClearStates( void ); -int trap_Key_GetCatcher( void ); -void trap_Key_SetCatcher( int catcher ); -void trap_GetClipboardData( char *buf, int bufsize ); -void trap_GetClientState( uiClientState_t *state ); -void trap_GetGlconfig( glconfig_t *glconfig ); -int trap_GetConfigString( int index, char* buff, int buffsize ); -int trap_LAN_GetServerCount( int source ); -void trap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen ); -void trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen ); -int trap_LAN_GetServerPing( int source, int n ); -int trap_LAN_GetPingQueueCount( void ); -void trap_LAN_ClearPing( int n ); -void trap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime ); -void trap_LAN_GetPingInfo( int n, char *buf, int buflen ); -void trap_LAN_LoadCachedServers(); -void trap_LAN_SaveCachedServers(); -void trap_LAN_MarkServerVisible(int source, int n, qboolean visible); -int trap_LAN_ServerIsVisible( int source, int n); -qboolean trap_LAN_UpdateVisiblePings( int source ); -int trap_LAN_AddServer(int source, const char *name, const char *addr); -void trap_LAN_RemoveServer(int source, const char *addr); -void trap_LAN_ResetPings(int n); -int trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen ); -int trap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ); -int trap_MemoryRemaining( void ); -void trap_GetCDKey( char *buf, int buflen ); -void trap_SetCDKey( char *buf ); -void trap_R_RegisterFont(const char *pFontname, int pointSize, fontInfo_t *font); -void trap_S_StopBackgroundTrack( void ); -void trap_S_StartBackgroundTrack( const char *intro, const char *loop); -int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits); -e_status trap_CIN_StopCinematic(int handle); -e_status trap_CIN_RunCinematic (int handle); -void trap_CIN_DrawCinematic (int handle); -void trap_CIN_SetExtents (int handle, int x, int y, int w, int h); -int trap_RealTime(qtime_t *qtime); -void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ); -qboolean trap_VerifyCDKey( const char *key, const char *chksum); +qhandle_t trap_R_RegisterModel( const char *name ); +qhandle_t trap_R_RegisterSkin( const char *name ); +qhandle_t trap_R_RegisterShaderNoMip( const char *name ); +void trap_R_ClearScene( void ); +void trap_R_AddRefEntityToScene( const refEntity_t *re ); +void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ); +void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ); +void trap_R_RenderScene( const refdef_t *fd ); +void trap_R_SetColor( const float *rgba ); +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 ); +void trap_UpdateScreen( void ); +int trap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ); +void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ); +sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ); +void trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen ); +void trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ); +void trap_Key_SetBinding( int keynum, const char *binding ); +qboolean trap_Key_IsDown( int keynum ); +qboolean trap_Key_GetOverstrikeMode( void ); +void trap_Key_SetOverstrikeMode( qboolean state ); +void trap_Key_ClearStates( void ); +int trap_Key_GetCatcher( void ); +void trap_Key_SetCatcher( int catcher ); +void trap_GetClipboardData( char *buf, int bufsize ); +void trap_GetClientState( uiClientState_t *state ); +void trap_GetGlconfig( glconfig_t *glconfig ); +int trap_GetConfigString( int index, char* buff, int buffsize ); +int trap_LAN_GetServerCount( int source ); +void trap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen ); +void trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen ); +int trap_LAN_GetServerPing( int source, int n ); +int trap_LAN_GetPingQueueCount( void ); +void trap_LAN_ClearPing( int n ); +void trap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime ); +void trap_LAN_GetPingInfo( int n, char *buf, int buflen ); +void trap_LAN_LoadCachedServers(); +void trap_LAN_SaveCachedServers(); +void trap_LAN_MarkServerVisible(int source, int n, qboolean visible); +int trap_LAN_ServerIsVisible( int source, int n); +qboolean trap_LAN_UpdateVisiblePings( int source ); +int trap_LAN_AddServer(int source, const char *name, const char *addr); +void trap_LAN_RemoveServer(int source, const char *addr); +void trap_LAN_ResetPings(int n); +int trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen ); +int trap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ); +int trap_MemoryRemaining( void ); +void trap_GetCDKey( char *buf, int buflen ); +void trap_SetCDKey( char *buf ); +void trap_R_RegisterFont(const char *pFontname, int pointSize, fontInfo_t *font); +void trap_S_StopBackgroundTrack( void ); +void trap_S_StartBackgroundTrack( const char *intro, const char *loop); +int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits); +e_status trap_CIN_StopCinematic(int handle); +e_status trap_CIN_RunCinematic (int handle); +void trap_CIN_DrawCinematic (int handle); +void trap_CIN_SetExtents (int handle, int x, int y, int w, int h); +int trap_RealTime(qtime_t *qtime); +void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ); +qboolean trap_VerifyCDKey( const char *key, const char *chksum); void trap_SetPbClStatus( int status ); @@ -1124,12 +1124,12 @@ void UI_NetworkOptionsMenu( void ); // ui_gameinfo.c // typedef enum { - AWARD_ACCURACY, - AWARD_IMPRESSIVE, - AWARD_EXCELLENT, - AWARD_GAUNTLET, - AWARD_FRAGS, - AWARD_PERFECT + AWARD_ACCURACY, + AWARD_IMPRESSIVE, + AWARD_EXCELLENT, + AWARD_GAUNTLET, + AWARD_FRAGS, + AWARD_PERFECT } awardType_t; const char *UI_GetArenaInfoByNumber( int num ); @@ -1179,28 +1179,28 @@ void RankStatus_Cache( void ); void UI_RankStatusMenu( void ); -// new ui +// new ui #define ASSET_BACKGROUND "uiBackground" // for tracking sp game info in Team Arena typedef struct postGameInfo_s { - int score; - int redScore; - int blueScore; - int perfects; - int accuracy; - int impressives; - int excellents; - int defends; - int assists; - int gauntlets; - int captures; - int time; - int timeBonus; - int shutoutBonus; - int skillBonus; - int baseScore; + int score; + int redScore; + int blueScore; + int perfects; + int accuracy; + int impressives; + int excellents; + int defends; + int assists; + int gauntlets; + int captures; + int time; + int timeBonus; + int shutoutBonus; + int skillBonus; + int baseScore; } postGameInfo_t; diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index 34f77c91..60e801cf 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -202,20 +202,7 @@ int vmMain( int command, int arg0, int arg1, int arg2, int arg3, int arg4, int a void AssetCache() { - int n; - //if (Assets.textFont == NULL) { - //} - //Assets.background = trap_R_RegisterShaderNoMip( ASSET_BACKGROUND ); - //Com_Printf("Menu Size: %i bytes\n", sizeof(Menus)); uiInfo.uiDC.Assets.gradientBar = trap_R_RegisterShaderNoMip( ASSET_GRADIENTBAR ); - uiInfo.uiDC.Assets.fxBasePic = trap_R_RegisterShaderNoMip( ART_FX_BASE ); - uiInfo.uiDC.Assets.fxPic[0] = trap_R_RegisterShaderNoMip( ART_FX_RED ); - uiInfo.uiDC.Assets.fxPic[1] = trap_R_RegisterShaderNoMip( ART_FX_YELLOW ); - uiInfo.uiDC.Assets.fxPic[2] = trap_R_RegisterShaderNoMip( ART_FX_GREEN ); - uiInfo.uiDC.Assets.fxPic[3] = trap_R_RegisterShaderNoMip( ART_FX_TEAL ); - uiInfo.uiDC.Assets.fxPic[4] = trap_R_RegisterShaderNoMip( ART_FX_BLUE ); - uiInfo.uiDC.Assets.fxPic[5] = trap_R_RegisterShaderNoMip( ART_FX_CYAN ); - uiInfo.uiDC.Assets.fxPic[6] = trap_R_RegisterShaderNoMip( ART_FX_WHITE ); uiInfo.uiDC.Assets.scrollBar = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR ); uiInfo.uiDC.Assets.scrollBarArrowDown = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWDOWN ); uiInfo.uiDC.Assets.scrollBarArrowUp = trap_R_RegisterShaderNoMip( ASSET_SCROLLBAR_ARROWUP ); @@ -224,12 +211,6 @@ void AssetCache() { uiInfo.uiDC.Assets.scrollBarThumb = trap_R_RegisterShaderNoMip( ASSET_SCROLL_THUMB ); uiInfo.uiDC.Assets.sliderBar = trap_R_RegisterShaderNoMip( ASSET_SLIDER_BAR ); uiInfo.uiDC.Assets.sliderThumb = trap_R_RegisterShaderNoMip( ASSET_SLIDER_THUMB ); - - for( n = 0; n < NUM_CROSSHAIRS; n++ ) { - uiInfo.uiDC.Assets.crosshairShader[n] = trap_R_RegisterShaderNoMip( va("gfx/2d/crosshair%c", 'a' + n ) ); - } - - /*uiInfo.newHighScoreSound = trap_S_RegisterSound("sound/feedback/voc_newhighscore.wav", qfalse);*/ } void _UI_DrawSides(float x, float y, float w, float h, float size) { @@ -381,10 +362,10 @@ void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, f int ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2; colorBlack[3] = newColor[3]; trap_R_SetColor( colorBlack ); - Text_PaintChar(x + ofs, y - yadj + ofs, + Text_PaintChar(x + ofs, y - yadj + ofs, glyph->imageWidth, glyph->imageHeight, - useScale, + useScale, glyph->s, glyph->t, glyph->s2, @@ -401,19 +382,19 @@ void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, f 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 ); Text_PaintChar( x - 1.5, y - yadj - 1.5, glyph->imageWidth + 3, @@ -424,7 +405,7 @@ void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, f glyph->s2, glyph->t2, glyph->glyph ); - + trap_R_SetColor( outer ); Text_PaintChar( x - 1, y - yadj - 1, glyph->imageWidth + 2, @@ -435,7 +416,7 @@ void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, f glyph->s2, glyph->t2, glyph->glyph ); - + trap_R_SetColor( inner ); Text_PaintChar( x - 0.5, y - yadj - 0.5, glyph->imageWidth + 1, @@ -446,14 +427,14 @@ void Text_Paint(float x, float y, float scale, vec4_t color, const char *text, f glyph->s2, glyph->t2, glyph->glyph ); - + trap_R_SetColor( white ); } - - Text_PaintChar(x, y - yadj, + + Text_PaintChar(x, y - yadj, glyph->imageWidth, glyph->imageHeight, - useScale, + useScale, glyph->s, glyph->t, glyph->s2, @@ -506,10 +487,10 @@ void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const cha int ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2; colorBlack[3] = newColor[3]; trap_R_SetColor( colorBlack ); - Text_PaintChar(x + ofs, y - yadj + ofs, + Text_PaintChar(x + ofs, y - yadj + ofs, glyph->imageWidth, glyph->imageHeight, - useScale, + useScale, glyph->s, glyph->t, glyph->s2, @@ -526,19 +507,19 @@ void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const cha 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 ); Text_PaintChar( x - 1.5, y - yadj - 1.5, glyph->imageWidth + 3, @@ -549,7 +530,7 @@ void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const cha glyph->s2, glyph->t2, glyph->glyph ); - + trap_R_SetColor( outer ); Text_PaintChar( x - 1, y - yadj - 1, glyph->imageWidth + 2, @@ -560,7 +541,7 @@ void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const cha glyph->s2, glyph->t2, glyph->glyph ); - + trap_R_SetColor( inner ); Text_PaintChar( x - 0.5, y - yadj - 0.5, glyph->imageWidth + 1, @@ -571,14 +552,14 @@ void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const cha glyph->s2, glyph->t2, glyph->glyph ); - + trap_R_SetColor( white ); } - - Text_PaintChar(x, y - yadj, + + Text_PaintChar(x, y - yadj, glyph->imageWidth, glyph->imageHeight, - useScale, + useScale, glyph->s, glyph->t, glyph->s2, @@ -588,10 +569,10 @@ void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const cha // CG_DrawPic(x, y - yadj, scale * uiDC.Assets.textFont.glyphs[text[i]].imageWidth, scale * uiDC.Assets.textFont.glyphs[text[i]].imageHeight, uiDC.Assets.textFont.glyphs[text[i]].glyph); yadj = useScale * glyph2->top; if (count == cursorPos && !((uiInfo.uiDC.realTime/BLINK_DIVISOR) & 1)) { - Text_PaintChar(x, y - yadj, + Text_PaintChar(x, y - yadj, glyph2->imageWidth, glyph2->imageHeight, - useScale, + useScale, glyph2->s, glyph2->t, glyph2->s2, @@ -607,10 +588,10 @@ void Text_PaintWithCursor(float x, float y, float scale, vec4_t color, const cha // need to paint cursor at end of text if (cursorPos == len && !((uiInfo.uiDC.realTime/BLINK_DIVISOR) & 1)) { yadj = useScale * glyph2->top; - Text_PaintChar(x, y - yadj, + Text_PaintChar(x, y - yadj, glyph2->imageWidth, glyph2->imageHeight, - useScale, + useScale, glyph2->s, glyph2->t, glyph2->s2, @@ -641,7 +622,7 @@ static void Text_Paint_Limit(float *maxX, float x, float y, float scale, vec4_t } useScale = scale * font->glyphScale; trap_R_SetColor( color ); - len = strlen(text); + len = strlen(text); if (limit > 0 && len > limit) { len = limit; } @@ -660,10 +641,10 @@ static void Text_Paint_Limit(float *maxX, float x, float y, float scale, vec4_t *maxX = 0; break; } - Text_PaintChar(x, y - yadj, + Text_PaintChar(x, y - yadj, glyph->imageWidth, glyph->imageHeight, - useScale, + useScale, glyph->s, glyph->t, glyph->s2, @@ -745,8 +726,8 @@ void _UI_Refresh( int realtime ) UI_BuildServerStatus(qfalse); // refresh find player list UI_BuildFindPlayerList(qfalse); - } - + } + // draw cursor UI_SetColor( NULL ); @@ -809,7 +790,7 @@ qboolean Asset_Parse(int handle) { if (Q_stricmp(token.string, "{") != 0) { return qfalse; } - + while ( 1 ) { memset(&token, 0, sizeof(pc_token_t)); @@ -1032,7 +1013,7 @@ tremInfoPane_t *UI_FindInfoPaneByName( const char *name ) uiInfo.tremInfoPanes[ i ].name = String_Alloc( name ); strncpy( uiInfo.tremInfoPanes[ i ].text, "Not implemented.\n\nui/infopanes.def\n", MAX_INFOPANE_TEXT ); Q_strcat( uiInfo.tremInfoPanes[ i ].text, MAX_INFOPANE_TEXT, String_Alloc( name ) ); - + uiInfo.tremInfoPaneCount++; return &uiInfo.tremInfoPanes[ i ]; @@ -1047,18 +1028,18 @@ qboolean UI_LoadInfoPane( int handle ) { pc_token_t token; qboolean valid = qfalse; - + while( 1 ) { memset( &token, 0, sizeof( pc_token_t ) ); - + if( !trap_PC_ReadToken( handle, &token ) ) break; if( !Q_stricmp( token.string, "name" ) ) { memset( &token, 0, sizeof( pc_token_t ) ); - + if( !trap_PC_ReadToken( handle, &token ) ) break; @@ -1068,14 +1049,14 @@ qboolean UI_LoadInfoPane( int handle ) else if( !Q_stricmp( token.string, "graphic" ) ) { int *graphic; - + memset( &token, 0, sizeof( pc_token_t ) ); - + if( !trap_PC_ReadToken( handle, &token ) ) break; graphic = &uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].numGraphics; - + if( !Q_stricmp( token.string, "top" ) ) uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].graphics[ *graphic ].side = INFOPANE_TOP; else if( !Q_stricmp( token.string, "bottom" ) ) @@ -1088,7 +1069,7 @@ qboolean UI_LoadInfoPane( int handle ) break; memset( &token, 0, sizeof( pc_token_t ) ); - + if( !trap_PC_ReadToken( handle, &token ) ) break; @@ -1096,39 +1077,39 @@ qboolean UI_LoadInfoPane( int handle ) uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].graphics[ *graphic ].offset = -1; else uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].graphics[ *graphic ].offset = token.intvalue; - + memset( &token, 0, sizeof( pc_token_t ) ); - + if( !trap_PC_ReadToken( handle, &token ) ) break; - + uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].graphics[ *graphic ].graphic = trap_R_RegisterShaderNoMip( token.string ); memset( &token, 0, sizeof( pc_token_t ) ); - + if( !trap_PC_ReadToken( handle, &token ) ) break; - + uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].graphics[ *graphic ].width = token.intvalue; - + memset( &token, 0, sizeof( pc_token_t ) ); - + if( !trap_PC_ReadToken( handle, &token ) ) break; - + uiInfo.tremInfoPanes[ uiInfo.tremInfoPaneCount ].graphics[ *graphic ].height = token.intvalue; - + //increment graphics (*graphic)++; - + if( *graphic == MAX_INFOPANE_GRAPHICS ) break; } else if( !Q_stricmp( token.string, "text" ) ) { memset( &token, 0, sizeof( pc_token_t ) ); - + if( !trap_PC_ReadToken( handle, &token ) ) break; @@ -1137,7 +1118,7 @@ qboolean UI_LoadInfoPane( int handle ) else if( !Q_stricmp( token.string, "align" ) ) { memset( &token, 0, sizeof( pc_token_t ) ); - + if( !trap_PC_ReadToken( handle, &token ) ) break; @@ -1182,21 +1163,21 @@ void UI_LoadInfoPanes( const char *file ) uiInfo.tremInfoPaneCount = count = 0; handle = trap_PC_LoadSource( file ); - + if( !handle ) { trap_Error( va( S_COLOR_YELLOW "infopane file not found: %s\n", file ) ); return; } - + while( 1 ) { if( !trap_PC_ReadToken( handle, &token ) ) break; - + if( token.string[ 0 ] == 0 ) break; - + if( token.string[ 0 ] == '{' ) { if( UI_LoadInfoPane( handle ) ) @@ -1223,7 +1204,7 @@ qboolean Load_Menu(int handle) { if (!trap_PC_ReadToken(handle, &token)) return qfalse; - + if ( token.string[0] == 0 ) { return qfalse; } @@ -1232,7 +1213,7 @@ qboolean Load_Menu(int handle) { return qtrue; } - UI_ParseMenu(token.string); + UI_ParseMenu(token.string); } return qfalse; } @@ -1364,7 +1345,7 @@ static int UI_TeamIndexFromName(const char *name) { return i; } } - } + } return 0; @@ -1425,7 +1406,7 @@ static void UI_DrawPreviewCinematic(rectDef_t *rect, float scale, vec4_t color) } else { uiInfo.previewMovie = -2; } - } + } } @@ -1453,7 +1434,7 @@ static void UI_DrawInfoPane( tremInfoPane_t *pane, rectDef_t *rect, float text_x float width = pane->graphics[ i ].width; float height = pane->graphics[ i ].height; qhandle_t graphic = pane->graphics[ i ].graphic; - + if( pane->graphics[ i ].side == INFOPANE_TOP || pane->graphics[ i ].side == INFOPANE_BOTTOM ) { //set horizontal offset of graphic @@ -1476,14 +1457,14 @@ static void UI_DrawInfoPane( tremInfoPane_t *pane, rectDef_t *rect, float text_x //set the horizontal offset of the text if( pane->graphics[ i ].width > maxLeft ) maxLeft = pane->graphics[ i ].width + GRAPHIC_BWIDTH; - + xoffset = GRAPHIC_BWIDTH; } else if( pane->graphics[ i ].side == INFOPANE_RIGHT ) { if( pane->graphics[ i ].width > maxRight ) maxRight = pane->graphics[ i ].width + GRAPHIC_BWIDTH; - + xoffset = rect->w - width - GRAPHIC_BWIDTH; } else if( pane->graphics[ i ].side == INFOPANE_TOP ) @@ -1491,21 +1472,21 @@ static void UI_DrawInfoPane( tremInfoPane_t *pane, rectDef_t *rect, float text_x //set the vertical offset of the text if( pane->graphics[ i ].height > maxTop ) maxTop = pane->graphics[ i ].height + GRAPHIC_BWIDTH; - + yoffset = GRAPHIC_BWIDTH; } else if( pane->graphics[ i ].side == INFOPANE_BOTTOM ) { if( pane->graphics[ i ].height > maxBottom ) maxBottom = pane->graphics[ i ].height + GRAPHIC_BWIDTH; - + yoffset = rect->h - height - GRAPHIC_BWIDTH; } //draw the graphic UI_DrawHandlePic( x + xoffset, y + yoffset, width, height, graphic ); } - + //offset the text x = rect->x + maxLeft; y = rect->y + maxTop; @@ -1513,7 +1494,7 @@ static void UI_DrawInfoPane( tremInfoPane_t *pane, rectDef_t *rect, float text_x h = rect->h - ( maxTop + maxBottom ); textItem.text = pane->text; - + textItem.parent = &dummyParent; memcpy( textItem.window.foreColor, color, sizeof( vec4_t ) ); textItem.window.flags = 0; @@ -1536,7 +1517,7 @@ static void UI_DrawInfoPane( tremInfoPane_t *pane, rectDef_t *rect, float text_x textItem.window.rect.x = x; break; } - + textItem.window.rect.y = y; textItem.window.rect.w = w; textItem.window.rect.h = h; @@ -1598,11 +1579,6 @@ static void UI_DrawTeamMember(rectDef_t *rect, float scale, vec4_t color, qboole Text_Paint(rect->x, rect->y, scale, color, text, 0, 0, textStyle); } -static void UI_DrawEffects(rectDef_t *rect, float scale, vec4_t color) { - UI_DrawHandlePic( rect->x, rect->y - 14, 128, 8, uiInfo.uiDC.Assets.fxBasePic ); - UI_DrawHandlePic( rect->x + uiInfo.effectsColor * 16 + 8, rect->y - 16, 16, 12, uiInfo.uiDC.Assets.fxPic[uiInfo.effectsColor] ); -} - static void UI_DrawMapPreview(rectDef_t *rect, float scale, vec4_t color, qboolean net) { int map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer; if (map < 0 || map > uiInfo.mapCount) { @@ -1625,7 +1601,7 @@ static void UI_DrawMapPreview(rectDef_t *rect, float scale, vec4_t color, qboole } else { UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, trap_R_RegisterShaderNoMip("gfx/2d/load_screen")); } -} +} static void UI_DrawMapTimeToBeat(rectDef_t *rect, float scale, vec4_t color, int textStyle) { @@ -1647,7 +1623,7 @@ static void UI_DrawMapTimeToBeat(rectDef_t *rect, float scale, vec4_t color, int static void UI_DrawMapCinematic(rectDef_t *rect, float scale, vec4_t color, qboolean net) { - int map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer; + int map = (net) ? ui_currentNetMap.integer : ui_currentMap.integer; if (map < 0 || map > uiInfo.mapCount) { if (net) { ui_currentNetMap.integer = 0; @@ -1782,7 +1758,7 @@ static void UI_DrawTierMap(rectDef_t *rect, int index) { if (uiInfo.tierList[i].mapHandles[index] == -1) { uiInfo.tierList[i].mapHandles[index] = trap_R_RegisterShaderNoMip(va("levelshots/%s", uiInfo.tierList[i].maps[index])); } - + UI_DrawHandlePic( rect->x, rect->y, rect->w, rect->h, uiInfo.tierList[i].mapHandles[index]); } @@ -1843,9 +1819,9 @@ static void UI_DrawOpponent(rectDef_t *rect) { char team[256]; vec3_t viewangles; vec3_t moveangles; - + if (updateOpponentModel) { - + strcpy(model, UI_Cvar_VariableString("ui_opponentModel")); strcpy(headmodel, UI_Cvar_VariableString("ui_opponentModel")); team[0] = '\0'; @@ -2108,7 +2084,7 @@ static int UI_OwnerDrawWidth(int ownerDraw, float scale) { static void UI_DrawBotName(rectDef_t *rect, float scale, vec4_t color, int textStyle) { int value = uiInfo.botIndex; const char *text = ""; - + if( value >= UI_GetNumBots( ) ) value = 0; @@ -2127,15 +2103,6 @@ static void UI_DrawRedBlue(rectDef_t *rect, float scale, vec4_t color, int textS Text_Paint(rect->x, rect->y, scale, color, (uiInfo.redBlue == 0) ? "Red" : "Blue", 0, 0, textStyle); } -static void UI_DrawCrosshair(rectDef_t *rect, float scale, vec4_t color) { - trap_R_SetColor( color ); - if (uiInfo.currentCrosshair < 0 || uiInfo.currentCrosshair >= NUM_CROSSHAIRS) { - uiInfo.currentCrosshair = 0; - } - UI_DrawHandlePic( rect->x, rect->y - rect->h, rect->w, rect->h, uiInfo.uiDC.Assets.crosshairShader[uiInfo.currentCrosshair]); - trap_R_SetColor( NULL ); -} - /* =============== UI_BuildPlayerList @@ -2201,10 +2168,10 @@ static void UI_DrawSelectedPlayer(rectDef_t *rect, float scale, vec4_t color, in static void UI_DrawServerRefreshDate(rectDef_t *rect, float scale, vec4_t color, int textStyle) { if (uiInfo.serverStatus.refreshActive) { vec4_t lowLight, newColor; - lowLight[0] = 0.8 * color[0]; - lowLight[1] = 0.8 * color[1]; - lowLight[2] = 0.8 * color[2]; - lowLight[3] = 0.8 * color[3]; + lowLight[0] = 0.8 * color[0]; + lowLight[1] = 0.8 * color[1]; + lowLight[2] = 0.8 * color[2]; + lowLight[3] = 0.8 * color[3]; LerpColor(color,lowLight,newColor,0.5+0.5*sin(uiInfo.uiDC.realTime / PULSE_DIVISOR)); Text_Paint(rect->x, rect->y, scale, newColor, va("Getting info for %d servers (ESC to cancel)", trap_LAN_GetServerCount(ui_netSource.integer)), 0, 0, textStyle); } else { @@ -2217,7 +2184,7 @@ static void UI_DrawServerRefreshDate(rectDef_t *rect, float scale, vec4_t color, static void UI_DrawServerMOTD(rectDef_t *rect, float scale, vec4_t color) { if (uiInfo.serverStatus.motdLen) { float maxX; - + if (uiInfo.serverStatus.motdWidth == -1) { uiInfo.serverStatus.motdWidth = 0; uiInfo.serverStatus.motdPaintX = rect->x + 1; @@ -2256,10 +2223,10 @@ static void UI_DrawServerMOTD(rectDef_t *rect, float scale, vec4_t color) { } maxX = rect->x + rect->w - 2; - Text_Paint_Limit(&maxX, uiInfo.serverStatus.motdPaintX, rect->y + rect->h - 3, scale, color, &uiInfo.serverStatus.motd[uiInfo.serverStatus.motdOffset], 0, 0); + Text_Paint_Limit(&maxX, uiInfo.serverStatus.motdPaintX, rect->y + rect->h - 3, scale, color, &uiInfo.serverStatus.motd[uiInfo.serverStatus.motdOffset], 0, 0); if (uiInfo.serverStatus.motdPaintX2 >= 0) { float maxX2 = rect->x + rect->w - 2; - Text_Paint_Limit(&maxX2, uiInfo.serverStatus.motdPaintX2, rect->y + rect->h - 3, scale, color, uiInfo.serverStatus.motd, 0, uiInfo.serverStatus.motdOffset); + Text_Paint_Limit(&maxX2, uiInfo.serverStatus.motdPaintX2, rect->y + rect->h - 3, scale, color, uiInfo.serverStatus.motd, 0, uiInfo.serverStatus.motdOffset); } if (uiInfo.serverStatus.motdOffset && maxX > 0) { // if we have an offset ( we are skipping the first part of the string ) and we fit the string @@ -2350,48 +2317,45 @@ static void UI_OwnerDraw( float x, float y, float w, float h, if( ( pane = uiInfo.tremTeamList[ uiInfo.tremTeamIndex ].infopane ) ) UI_DrawInfoPane( pane, &rect, text_x, text_y, scale, color, textStyle ); break; - + case UI_ACLASSINFOPANE: if( ( pane = uiInfo.tremAlienClassList[ uiInfo.tremAlienClassIndex ].infopane ) ) UI_DrawInfoPane( pane, &rect, text_x, text_y, scale, color, textStyle ); break; - + case UI_AUPGRADEINFOPANE: if( ( pane = uiInfo.tremAlienUpgradeList[ uiInfo.tremAlienUpgradeIndex ].infopane ) ) UI_DrawInfoPane( pane, &rect, text_x, text_y, scale, color, textStyle ); break; - + case UI_HITEMINFOPANE: if( ( pane = uiInfo.tremHumanItemList[ uiInfo.tremHumanItemIndex ].infopane ) ) UI_DrawInfoPane( pane, &rect, text_x, text_y, scale, color, textStyle ); break; - + case UI_HBUYINFOPANE: if( ( pane = uiInfo.tremHumanArmouryBuyList[ uiInfo.tremHumanArmouryBuyIndex ].infopane ) ) UI_DrawInfoPane( pane, &rect, text_x, text_y, scale, color, textStyle ); break; - + case UI_HSELLINFOPANE: if( ( pane = uiInfo.tremHumanArmourySellList[ uiInfo.tremHumanArmourySellIndex ].infopane ) ) UI_DrawInfoPane( pane, &rect, text_x, text_y, scale, color, textStyle ); break; - + case UI_ABUILDINFOPANE: if( ( pane = uiInfo.tremAlienBuildList[ uiInfo.tremAlienBuildIndex ].infopane ) ) UI_DrawInfoPane( pane, &rect, text_x, text_y, scale, color, textStyle ); break; - + case UI_HBUILDINFOPANE: if( ( pane = uiInfo.tremHumanBuildList[ uiInfo.tremHumanBuildIndex ].infopane ) ) UI_DrawInfoPane( pane, &rect, text_x, text_y, scale, color, textStyle ); break; - + case UI_HANDICAP: UI_DrawHandicap(&rect, scale, color, textStyle); break; - case UI_EFFECTS: - UI_DrawEffects(&rect, scale, color); - break; case UI_PLAYERMODEL: UI_DrawPlayerModel(&rect); break; @@ -2520,9 +2484,6 @@ static void UI_OwnerDraw( float x, float y, float w, float h, case UI_REDBLUE: UI_DrawRedBlue(&rect, scale, color, textStyle); break; - case UI_CROSSHAIR: - UI_DrawCrosshair(&rect, scale, color); - break; case UI_SELECTEDPLAYER: UI_DrawSelectedPlayer(&rect, scale, color, textStyle); break; @@ -2553,34 +2514,34 @@ static qboolean UI_OwnerDrawVisible(int flags) { trap_GetClientState( &cs ); trap_GetConfigString( CS_PLAYERS + cs.clientNum, info, MAX_INFO_STRING ); team = atoi( Info_ValueForKey( info, "t" ) ); - + while (flags) { - + if( flags & UI_SHOW_NOTSPECTATING ) { if( team == PTE_NONE ) vis = qfalse; - + flags &= ~UI_SHOW_NOTSPECTATING; - } - + } + if( flags & UI_SHOW_VOTEACTIVE ) { if( !trap_Cvar_VariableValue( "ui_voteActive" ) ) vis = qfalse; - + flags &= ~UI_SHOW_VOTEACTIVE; - } - + } + if( flags & UI_SHOW_CANVOTE ) { if( trap_Cvar_VariableValue( "ui_voteActive" ) ) vis = qfalse; - + flags &= ~UI_SHOW_CANVOTE; - } - + } + if( flags & UI_SHOW_TEAMVOTEACTIVE ) { if( team == PTE_ALIENS ) @@ -2593,10 +2554,10 @@ static qboolean UI_OwnerDrawVisible(int flags) { if( !trap_Cvar_VariableValue( "ui_humanTeamVoteActive" ) ) vis = qfalse; } - + flags &= ~UI_SHOW_TEAMVOTEACTIVE; - } - + } + if( flags & UI_SHOW_CANTEAMVOTE ) { if( team == PTE_ALIENS ) @@ -2609,47 +2570,47 @@ static qboolean UI_OwnerDrawVisible(int flags) { if( trap_Cvar_VariableValue( "ui_humanTeamVoteActive" ) ) vis = qfalse; } - + flags &= ~UI_SHOW_CANTEAMVOTE; - } - + } + if (flags & UI_SHOW_LEADER) { // these need to show when this client can give orders to a player or a group if (!uiInfo.teamLeader) { vis = qfalse; } else { // if showing yourself - if (ui_selectedPlayer.integer < uiInfo.myTeamCount && uiInfo.teamClientNums[ui_selectedPlayer.integer] == uiInfo.playerNumber) { + if (ui_selectedPlayer.integer < uiInfo.myTeamCount && uiInfo.teamClientNums[ui_selectedPlayer.integer] == uiInfo.playerNumber) { vis = qfalse; } } flags &= ~UI_SHOW_LEADER; - } + } if (flags & UI_SHOW_NOTLEADER) { // these need to show when this client is assigning their own status or they are NOT the leader if (uiInfo.teamLeader) { // if not showing yourself - if (!(ui_selectedPlayer.integer < uiInfo.myTeamCount && uiInfo.teamClientNums[ui_selectedPlayer.integer] == uiInfo.playerNumber)) { + if (!(ui_selectedPlayer.integer < uiInfo.myTeamCount && uiInfo.teamClientNums[ui_selectedPlayer.integer] == uiInfo.playerNumber)) { vis = qfalse; } // these need to show when this client can give orders to a player or a group } flags &= ~UI_SHOW_NOTLEADER; - } + } if (flags & UI_SHOW_FAVORITESERVERS) { // this assumes you only put this type of display flag on something showing in the proper context if (ui_netSource.integer != AS_FAVORITES) { vis = qfalse; } flags &= ~UI_SHOW_FAVORITESERVERS; - } + } if (flags & UI_SHOW_NOTFAVORITESERVERS) { // this assumes you only put this type of display flag on something showing in the proper context if (ui_netSource.integer == AS_FAVORITES) { vis = qfalse; } flags &= ~UI_SHOW_NOTFAVORITESERVERS; - } + } if (flags & UI_SHOW_NEWHIGHSCORE) { if (uiInfo.newHighScoreTime < uiInfo.uiDC.realTime) { vis = qfalse; @@ -2663,13 +2624,13 @@ static qboolean UI_OwnerDrawVisible(int flags) { } } flags &= ~UI_SHOW_NEWHIGHSCORE; - } + } if (flags & UI_SHOW_NEWBESTTIME) { if (uiInfo.newBestTime < uiInfo.uiDC.realTime) { vis = qfalse; } flags &= ~UI_SHOW_NEWBESTTIME; - } + } if (flags & UI_SHOW_DEMOAVAILABLE) { if (!uiInfo.demoAvailable) { vis = qfalse; @@ -2770,7 +2731,7 @@ static qboolean UI_GameType_HandleKey(int flags, float *special, int key, qboole ui_gameType.integer = 3; } } - + trap_Cvar_Set("ui_Q3Model", "0"); trap_Cvar_Set("ui_gameType", va("%d", ui_gameType.integer)); @@ -2798,7 +2759,7 @@ static qboolean UI_NetGameType_HandleKey(int flags, float *special, int key) { ui_netGameType.integer = uiInfo.numGameTypes - 1; } else if (ui_netGameType.integer >= uiInfo.numGameTypes) { ui_netGameType.integer = 0; - } + } trap_Cvar_Set( "ui_netGameType", va("%d", ui_netGameType.integer)); trap_Cvar_Set( "ui_actualnetGameType", va("%d", uiInfo.gameTypes[ui_netGameType.integer].gtEnum)); @@ -2907,7 +2868,7 @@ static qboolean UI_TeamMember_HandleKey(int flags, float *special, int key, qboo static qboolean UI_NetSource_HandleKey(int flags, float *special, int key) { if (key == K_MOUSE1 || key == K_MOUSE2 || key == K_ENTER || key == K_KP_ENTER) { - + if (key == K_MOUSE2) { ui_netSource.integer--; if (ui_netSource.integer == AS_MPLAYER) @@ -2981,7 +2942,7 @@ static qboolean UI_BotName_HandleKey(int flags, float *special, int key) { value = 0; else if( value < 0 ) value = UI_GetNumBots( ) + 2 - 1; - + uiInfo.botIndex = value; return qtrue; } @@ -3026,7 +2987,7 @@ static qboolean UI_Crosshair_HandleKey(int flags, float *special, int key) { } else if (uiInfo.currentCrosshair < 0) { uiInfo.currentCrosshair = NUM_CROSSHAIRS - 1; } - trap_Cvar_Set("cg_drawCrosshair", va("%d", uiInfo.currentCrosshair)); + trap_Cvar_Set("cg_drawCrosshair", va("%d", uiInfo.currentCrosshair)); return qtrue; } return qfalse; @@ -3043,7 +3004,7 @@ static qboolean UI_SelectedPlayer_HandleKey(int flags, float *special, int key) return qfalse; } selected = trap_Cvar_VariableValue("cg_selectedPlayer"); - + if (key == K_MOUSE2) { selected--; } else { @@ -3072,9 +3033,6 @@ static qboolean UI_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, case UI_HANDICAP: return UI_Handicap_HandleKey(flags, special, key); break; - case UI_EFFECTS: - return UI_Effects_HandleKey(flags, special, key); - break; case UI_CLANNAME: return UI_ClanName_HandleKey(flags, special, key); break; @@ -3128,9 +3086,6 @@ static qboolean UI_OwnerDrawHandleKey(int ownerDraw, int flags, float *special, case UI_REDBLUE: UI_RedBlue_HandleKey(flags, special, key); break; - case UI_CROSSHAIR: - UI_Crosshair_HandleKey(flags, special, key); - break; case UI_SELECTEDPLAYER: UI_SelectedPlayer_HandleKey(flags, special, key); break; @@ -3208,7 +3163,7 @@ static void UI_StartSinglePlayer() { } trap_Cmd_ExecuteText( EXEC_APPEND, "wait 5; team Red\n" ); } - + } */ @@ -3222,7 +3177,7 @@ static stage_t UI_GetCurrentAlienStage( void ) { char buffer[ MAX_TOKEN_CHARS ]; stage_t stage, dummy; - + trap_Cvar_VariableStringBuffer( "ui_stages", buffer, sizeof( buffer ) ); sscanf( buffer, "%d %d", (int *)&stage , (int *)&dummy ); @@ -3238,7 +3193,7 @@ static stage_t UI_GetCurrentHumanStage( void ) { char buffer[ MAX_TOKEN_CHARS ]; stage_t stage, dummy; - + trap_Cvar_VariableStringBuffer( "ui_stages", buffer, sizeof( buffer ) ); sscanf( buffer, "%d %d", (int *)&dummy, (int *)&stage ); @@ -3253,19 +3208,19 @@ UI_LoadTremTeams static void UI_LoadTremTeams( void ) { uiInfo.tremTeamCount = 4; - + uiInfo.tremTeamList[ 0 ].text = String_Alloc( "Aliens" ); uiInfo.tremTeamList[ 0 ].cmd = String_Alloc( "cmd team aliens\n" ); uiInfo.tremTeamList[ 0 ].infopane = UI_FindInfoPaneByName( "alienteam" ); - + uiInfo.tremTeamList[ 1 ].text = String_Alloc( "Humans" ); uiInfo.tremTeamList[ 1 ].cmd = String_Alloc( "cmd team humans\n" ); uiInfo.tremTeamList[ 1 ].infopane = UI_FindInfoPaneByName( "humanteam" ); - + uiInfo.tremTeamList[ 2 ].text = String_Alloc( "Spectate" ); uiInfo.tremTeamList[ 2 ].cmd = String_Alloc( "cmd team spectate\n" ); uiInfo.tremTeamList[ 2 ].infopane = UI_FindInfoPaneByName( "spectateteam" ); - + uiInfo.tremTeamList[ 3 ].text = String_Alloc( "Auto select" ); uiInfo.tremTeamList[ 3 ].cmd = String_Alloc( "cmd team auto\n" ); uiInfo.tremTeamList[ 3 ].infopane = UI_FindInfoPaneByName( "autoteam" ); @@ -3279,21 +3234,21 @@ UI_LoadTremAlienClasses static void UI_LoadTremAlienClasses( void ) { pClass_t bClass; - + uiInfo.tremAlienClassCount = 2; - + uiInfo.tremAlienClassList[ 0 ].text = String_Alloc( BG_FindHumanNameForClassNum( PCL_ALIEN_LEVEL0 ) ); uiInfo.tremAlienClassList[ 0 ].cmd = String_Alloc( va( "cmd class %s\n", BG_FindNameForClassNum( PCL_ALIEN_LEVEL0 ) ) ); uiInfo.tremAlienClassList[ 0 ].infopane = UI_FindInfoPaneByName( va( "%sclass", BG_FindNameForClassNum( PCL_ALIEN_LEVEL0 ) ) ); - + if( BG_FindStagesForClass( PCL_ALIEN_BUILDER0_UPG, UI_GetCurrentAlienStage( ) ) ) bClass = PCL_ALIEN_BUILDER0_UPG; else bClass = PCL_ALIEN_BUILDER0; - + uiInfo.tremAlienClassList[ 1 ].text = String_Alloc( BG_FindHumanNameForClassNum( bClass ) ); uiInfo.tremAlienClassList[ 1 ].cmd = @@ -3319,12 +3274,12 @@ static void UI_LoadTremHumanItems( void ) String_Alloc( va( "cmd class %s\n", BG_FindNameForWeapon( WP_MACHINEGUN ) ) ); uiInfo.tremHumanItemList[ 0 ].infopane = UI_FindInfoPaneByName( va( "%sitem", BG_FindNameForWeapon( WP_MACHINEGUN ) ) ); - + if( BG_FindStagesForWeapon( WP_HBUILD2, UI_GetCurrentHumanStage( ) ) ) bWeapon = WP_HBUILD2; else bWeapon = WP_HBUILD; - + uiInfo.tremHumanItemList[ 1 ].text = String_Alloc( BG_FindHumanNameForWeapon( bWeapon ) ); uiInfo.tremHumanItemList[ 1 ].cmd = @@ -3345,7 +3300,7 @@ static void UI_ParseCarriageList( int *weapons, int *upgrades ) char *iterator; char buffer[ MAX_TOKEN_CHARS ]; char *bufPointer; - + trap_Cvar_VariableStringBuffer( "ui_carriage", carriageCvar, sizeof( carriageCvar ) ); iterator = carriageCvar; @@ -3359,7 +3314,7 @@ static void UI_ParseCarriageList( int *weapons, int *upgrades ) while( iterator && iterator[ 0 ] != '$' ) { bufPointer = buffer; - + if( iterator[ 0 ] == 'W' ) { iterator++; @@ -3384,7 +3339,7 @@ static void UI_ParseCarriageList( int *weapons, int *upgrades ) *bufPointer++ = '\n'; i = atoi( buffer ); - + if( upgrades ) *upgrades |= ( 1 << i ); } @@ -3404,7 +3359,7 @@ static void UI_LoadTremHumanArmouryBuys( ) stage_t stage = UI_GetCurrentHumanStage( ); int weapons, upgrades; int slots = 0; - + UI_ParseCarriageList( &weapons, &upgrades ); for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) @@ -3412,15 +3367,15 @@ static void UI_LoadTremHumanArmouryBuys( ) if( weapons & ( 1 << i ) ) slots |= BG_FindSlotsForWeapon( i ); } - + for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ ) { if( upgrades & ( 1 << i ) ) slots |= BG_FindSlotsForUpgrade( i ); } - + uiInfo.tremHumanArmouryBuyCount = 0; - + for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) { if( BG_FindTeamForWeapon( i ) == WUT_HUMANS && @@ -3435,13 +3390,13 @@ static void UI_LoadTremHumanArmouryBuys( ) String_Alloc( va( "cmd buy %s retrigger\n", BG_FindNameForWeapon( i ) ) ); uiInfo.tremHumanArmouryBuyList[ j ].infopane = UI_FindInfoPaneByName( va( "%sitem", BG_FindNameForWeapon( i ) ) ); - + j++; uiInfo.tremHumanArmouryBuyCount++; } } - + for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ ) { if( BG_FindTeamForUpgrade( i ) == WUT_HUMANS && @@ -3458,7 +3413,7 @@ static void UI_LoadTremHumanArmouryBuys( ) UI_FindInfoPaneByName( va( "%sitem", BG_FindNameForUpgrade( i ) ) ); j++; - + uiInfo.tremHumanArmouryBuyCount++; } } @@ -3473,10 +3428,10 @@ static void UI_LoadTremHumanArmourySells( ) { int weapons, upgrades; int i, j = 0; - + uiInfo.tremHumanArmourySellCount = 0; UI_ParseCarriageList( &weapons, &upgrades ); - + for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) { if( weapons & ( 1 << i ) ) @@ -3488,11 +3443,11 @@ static void UI_LoadTremHumanArmourySells( ) UI_FindInfoPaneByName( va( "%sitem", BG_FindNameForWeapon( i ) ) ); j++; - + uiInfo.tremHumanArmourySellCount++; } } - + for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ ) { if( upgrades & ( 1 << i ) ) @@ -3504,7 +3459,7 @@ static void UI_LoadTremHumanArmourySells( ) UI_FindInfoPaneByName( va( "%sitem", BG_FindNameForUpgrade( i ) ) ); j++; - + uiInfo.tremHumanArmourySellCount++; } } @@ -3521,12 +3476,12 @@ static void UI_LoadTremAlienUpgrades( ) int class, credits; char ui_currentClass[ MAX_STRING_CHARS ]; stage_t stage = UI_GetCurrentAlienStage( ); - + trap_Cvar_VariableStringBuffer( "ui_currentClass", ui_currentClass, MAX_STRING_CHARS ); sscanf( ui_currentClass, "%d %d", &class, &credits ); uiInfo.tremAlienUpgradeCount = 0; - + for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { if( BG_ClassCanEvolveFromTo( class, i, credits, 0 ) >= 0 && @@ -3555,12 +3510,12 @@ static void UI_LoadTremAlienBuilds( ) int weapons; int i, j = 0; stage_t stage; - + UI_ParseCarriageList( &weapons, NULL ); stage = UI_GetCurrentAlienStage( ); - + uiInfo.tremAlienBuildCount = 0; - + for( i = BA_NONE +1; i < BA_NUM_BUILDABLES; i++ ) { if( BG_FindTeamForBuildable( i ) == BIT_ALIENS && @@ -3575,7 +3530,7 @@ static void UI_LoadTremAlienBuilds( ) UI_FindInfoPaneByName( va( "%sbuild", BG_FindNameForBuildable( i ) ) ); j++; - + uiInfo.tremAlienBuildCount++; } } @@ -3591,12 +3546,12 @@ static void UI_LoadTremHumanBuilds( ) int weapons; int i, j = 0; stage_t stage; - + UI_ParseCarriageList( &weapons, NULL ); stage = UI_GetCurrentHumanStage( ); uiInfo.tremHumanBuildCount = 0; - + for( i = BA_NONE +1; i < BA_NUM_BUILDABLES; i++ ) { if( BG_FindTeamForBuildable( i ) == BIT_HUMANS && @@ -3611,7 +3566,7 @@ static void UI_LoadTremHumanBuilds( ) UI_FindInfoPaneByName( va( "%sbuild", BG_FindNameForBuildable( i ) ) ); j++; - + uiInfo.tremHumanBuildCount++; } } @@ -3874,7 +3829,7 @@ static void UI_Update(const char *name) { trap_Cvar_SetValue( "cg_brassTime", 2500 ); trap_Cvar_Set( "r_texturemode", "GL_LINEAR_MIPMAP_LINEAR" ); break; - case 1: // normal + case 1: // normal trap_Cvar_SetValue( "r_fullScreen", 1 ); trap_Cvar_SetValue( "r_subdivisions", 12 ); trap_Cvar_SetValue( "r_vertexlight", 0 ); @@ -3966,7 +3921,7 @@ static void UI_RunMenuScript(char **args) { if (clients == 0) { clients = 8; } - + if (oldclients > clients) { clients = oldclients; } @@ -4019,10 +3974,10 @@ static void UI_RunMenuScript(char **args) { } else if (Q_stricmp(name, "verifyCDKey") == 0) { buff[0] = '\0'; - Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey1")); - Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey2")); - Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey3")); - Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey4")); + Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey1")); + Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey2")); + Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey3")); + Q_strcat(buff, 1024, UI_Cvar_VariableString("cdkey4")); trap_Cvar_Set("cdkey", buff); if (trap_VerifyCDKey(buff, UI_Cvar_VariableString("cdkeychecksum"))) { trap_Cvar_Set("ui_cdkeyvalid", "CD Key Appears to be valid."); @@ -4062,7 +4017,7 @@ static void UI_RunMenuScript(char **args) { } else if (Q_stricmp(name, "LoadMods") == 0) { UI_LoadMods(); } - + //TA: tremulous menus else if( Q_stricmp( name, "LoadTeams" ) == 0 ) UI_LoadTremTeams( ); @@ -4135,20 +4090,20 @@ static void UI_RunMenuScript(char **args) { // load the file len = trap_FS_FOpenFile( "ptrc.cfg", &f, FS_READ ); - + if( len > 0 && ( len < sizeof( text ) - 1 ) ) { trap_FS_Read( text, len, f ); text[ len ] = 0; trap_FS_FCloseFile( f ); - + Com_sprintf( command, 32, "ptrcrestore %s", text ); - + trap_Cmd_ExecuteText( EXEC_APPEND, command ); } } //TA: tremulous menus - + else if (Q_stricmp(name, "playMovie") == 0) { if (uiInfo.previewMovie >= 0) { trap_CIN_StopCinematic(uiInfo.previewMovie); @@ -4426,7 +4381,7 @@ static int UI_MapCountByGameType(qboolean singlePlayer) { qboolean UI_hasSkinForBase(const char *base, const char *team) { char test[1024]; - + Com_sprintf( test, sizeof( test ), "models/players/%s/%s/lower_default.skin", base, team ); if (trap_FS_FOpenFile(test, 0, FS_READ)) { @@ -4448,7 +4403,7 @@ UI_MapCountByTeam static int UI_HeadCountByTeam() { static int init = 0; int i, j, k, c, tIndex; - + c = 0; if (!init) { for (i = 0; i < uiInfo.characterCount; i++) { @@ -4601,11 +4556,11 @@ static void UI_BuildServerDisplayList(qboolean force) { if (len == 0) { strcpy(uiInfo.serverStatus.motd, "Welcome to Tremulous!"); len = strlen(uiInfo.serverStatus.motd); - } + } if (len != uiInfo.serverStatus.motdLen) { uiInfo.serverStatus.motdLen = len; uiInfo.serverStatus.motdWidth = -1; - } + } if (force) { numinvisible = 0; @@ -4666,14 +4621,14 @@ static void UI_BuildServerDisplayList(qboolean force) { continue; } } - + //TA: only show tremulous servers if( Q_stricmp( Info_ValueForKey( info, "game" ), "tremulous" ) != 0 ) { trap_LAN_MarkServerVisible( ui_netSource.integer, i, qfalse ); continue; } - + // make sure we never add a favorite server twice if (ui_netSource.integer == AS_FAVORITES) { UI_RemoveServerFromDisplayList(i); @@ -5092,7 +5047,7 @@ static int UI_FeederCount(float feederID) { else if( feederID == FEEDER_TREMHUMANBUILD ) return uiInfo.tremHumanBuildCount; //TA: tremulous menus - + return 0; } @@ -5144,7 +5099,7 @@ static int UI_GetIndexFromSelection(int actual) { return 0; } -static void UI_UpdatePendingPings() { +static void UI_UpdatePendingPings() { trap_LAN_ResetPings(ui_netSource.integer); uiInfo.serverStatus.refreshActive = qtrue; uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000; @@ -5183,7 +5138,7 @@ static const char *UI_FeederItemText(float feederID, int index, int column, qhan // UI_UpdatePendingPings(); } switch (column) { - case SORT_HOST : + case SORT_HOST : if (ping <= 0) { return Info_ValueForKey(info, "addr"); } else { @@ -5201,10 +5156,10 @@ static const char *UI_FeederItemText(float feederID, int index, int column, qhan } case SORT_MAP : return Info_ValueForKey(info, "mapname"); - case SORT_CLIENTS : + case SORT_CLIENTS : Com_sprintf( clientBuff, sizeof(clientBuff), "%s (%s)", Info_ValueForKey(info, "clients"), Info_ValueForKey(info, "sv_maxclients")); return clientBuff; - case SORT_PING : + case SORT_PING : if (ping <= 0) { return "..."; } else { @@ -5298,7 +5253,7 @@ static const char *UI_FeederItemText(float feederID, int index, int column, qhan return uiInfo.tremHumanBuildList[ index ].text; } //TA: tremulous menus - + return ""; } @@ -5340,7 +5295,7 @@ static void UI_FeederSelection(float feederID, int index) { index = actual; if (index >= 0 && index < uiInfo.characterCount) { trap_Cvar_Set( "team_model", va("%s", uiInfo.characterList[index].base)); - trap_Cvar_Set( "team_headmodel", va("*%s", uiInfo.characterList[index].name)); + trap_Cvar_Set( "team_headmodel", va("*%s", uiInfo.characterList[index].name)); updateModel = qtrue; } } else if (feederID == FEEDER_Q3HEADS) { @@ -5516,12 +5471,12 @@ static void UI_BuildQ3Model_List( void ) for (i=0; i<numdirs && uiInfo.q3HeadCount < MAX_PLAYERMODELS; i++,dirptr+=dirlen+1) { dirlen = strlen(dirptr); - + if (dirlen && dirptr[dirlen-1]=='/') dirptr[dirlen-1]='\0'; if (!strcmp(dirptr,".") || !strcmp(dirptr,"..")) continue; - + // iterate all skin files in directory numfiles = trap_FS_GetFileList( va("models/players/%s",dirptr), "tga", filelist, 2048 ); fileptr = filelist; @@ -5553,7 +5508,7 @@ static void UI_BuildQ3Model_List( void ) } } - } + } } @@ -5569,7 +5524,7 @@ void _UI_Init( qboolean inGameLoad ) { int start; BG_InitClassOverrides( ); - + //uiInfo.inGameLoad = inGameLoad; UI_RegisterCvars(); @@ -5631,8 +5586,8 @@ void _UI_Init( qboolean inGameLoad ) { uiInfo.uiDC.getBindingBuf = &trap_Key_GetBindingBuf; uiInfo.uiDC.keynumToStringBuf = &trap_Key_KeynumToStringBuf; uiInfo.uiDC.executeText = &trap_Cmd_ExecuteText; - uiInfo.uiDC.Error = &Com_Error; - uiInfo.uiDC.Print = &Com_Printf; + uiInfo.uiDC.Error = &Com_Error; + uiInfo.uiDC.Print = &Com_Printf; uiInfo.uiDC.Pause = &UI_Pause; uiInfo.uiDC.ownerDrawWidth = &UI_OwnerDrawWidth; uiInfo.uiDC.registerSound = &trap_S_RegisterSound; @@ -5646,8 +5601,7 @@ void _UI_Init( qboolean inGameLoad ) { Init_Display(&uiInfo.uiDC); String_Init(); - - uiInfo.uiDC.cursor = trap_R_RegisterShaderNoMip( "menu/art/3_cursor2" ); + uiInfo.uiDC.whiteShader = trap_R_RegisterShaderNoMip( "white" ); AssetCache(); @@ -5672,7 +5626,7 @@ void _UI_Init( qboolean inGameLoad ) { UI_LoadMenus("ui/ingame.txt", qtrue); } else { // bk010222: left this: UI_LoadMenus(menuSet, qtrue); } -#else +#else UI_LoadMenus(menuSet, qtrue); UI_LoadMenus("ui/ingame.txt", qfalse); UI_LoadMenus("ui/tremulous.txt", qfalse); @@ -5688,7 +5642,7 @@ void _UI_Init( qboolean inGameLoad ) { Com_Printf( "name: %s\n", uiInfo.tremInfoPanes[ i ].name ); Com_Printf( "text: %s\n", uiInfo.tremInfoPanes[ i ].text ); - + for( j = 0; j < uiInfo.tremInfoPanes[ i ].numGraphics; j++ ) Com_Printf( "graphic %d: %d %d %d %d\n", j, uiInfo.tremInfoPanes[ i ].graphics[ j ].side, uiInfo.tremInfoPanes[ i ].graphics[ j ].offset, @@ -5697,7 +5651,7 @@ void _UI_Init( qboolean inGameLoad ) { } } #endif - + Menus_CloseAll(); trap_LAN_LoadCachedServers(); @@ -5887,11 +5841,11 @@ static void UI_ReadableSize ( char *buf, int bufsize, int value ) { if (value > 1024*1024*1024 ) { // gigs Com_sprintf( buf, bufsize, "%d", value / (1024*1024*1024) ); - Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d GB", + Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d GB", (value % (1024*1024*1024))*100 / (1024*1024*1024) ); } else if (value > 1024*1024 ) { // megs Com_sprintf( buf, bufsize, "%d", value / (1024*1024) ); - Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d MB", + Com_sprintf( buf+strlen(buf), bufsize-strlen(buf), ".%02d MB", (value % (1024*1024))*100 / (1024*1024) ); } else if (value > 1024 ) { // kilos Com_sprintf( buf, bufsize, "%d KB", value / 1024 ); @@ -5919,37 +5873,37 @@ void Text_PaintCenter(float x, float y, float scale, vec4_t color, const char *t } void Text_PaintCenter_AutoWrapped(float x, float y, float xmax, float ystep, float scale, vec4_t color, const char *str, float adjust) { - int width; - char *s1,*s2,*s3; - char c_bcp; - char buf[1024]; - - if (!str || str[0]=='\0') - return; - - Q_strncpyz(buf, str, sizeof(buf)); - s1 = s2 = s3 = buf; - - while (1) { - do { - s3++; - } while (*s3!=' ' && *s3!='\0'); - c_bcp = *s3; - *s3 = '\0'; - width = Text_Width(s1, scale, 0); - *s3 = c_bcp; - if (width > xmax) { - if (s1==s2) - { - // fuck, don't have a clean cut, we'll overflow - s2 = s3; - } - *s2 = '\0'; - Text_PaintCenter(x, y, scale, color, s1, adjust); - y += ystep; - if (c_bcp == '\0') + int width; + char *s1,*s2,*s3; + char c_bcp; + char buf[1024]; + + if (!str || str[0]=='\0') + return; + + Q_strncpyz(buf, str, sizeof(buf)); + s1 = s2 = s3 = buf; + + while (1) { + do { + s3++; + } while (*s3!=' ' && *s3!='\0'); + c_bcp = *s3; + *s3 = '\0'; + width = Text_Width(s1, scale, 0); + *s3 = c_bcp; + if (width > xmax) { + if (s1==s2) { - // that was the last word + // fuck, don't have a clean cut, we'll overflow + s2 = s3; + } + *s2 = '\0'; + Text_PaintCenter(x, y, scale, color, s1, adjust); + y += ystep; + if (c_bcp == '\0') + { + // that was the last word // we could start a new loop, but that wouldn't be much use // even if the word is too long, we would overflow it (see above) // so just print it now if needed @@ -5958,20 +5912,20 @@ void Text_PaintCenter_AutoWrapped(float x, float y, float xmax, float ystep, flo Text_PaintCenter(x, y, scale, color, s2, adjust); break; } - s2++; - s1 = s2; - s3 = s2; - } - else - { - s2 = s3; - if (c_bcp == '\0') // we reached the end - { - Text_PaintCenter(x, y, scale, color, s1, adjust); - break; - } - } - } + s2++; + s1 = s2; + s3 = s2; + } + else + { + s2 = s3; + if (c_bcp == '\0') // we reached the end + { + Text_PaintCenter(x, y, scale, color, s1, adjust); + break; + } + } + } } @@ -6024,7 +5978,7 @@ static void UI_DisplayDownloadInfo( const char *downloadName, float centerPoint, int n = downloadSize / xferRate; // estimated time for entire d/l in secs // We do it in K (/1024) because we'd overflow around 4MB - UI_PrintTime ( dlTimeBuf, sizeof dlTimeBuf, + UI_PrintTime ( dlTimeBuf, sizeof dlTimeBuf, (n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000); Text_PaintCenter(leftWidth, yStart+216, scale, colorWhite, dlTimeBuf, 0); @@ -6058,7 +6012,7 @@ void UI_DrawConnectScreen( qboolean overlay ) { char info[MAX_INFO_VALUE]; char text[256]; float centerPoint, yStart, scale; - + menuDef_t *menu = Menus_FindByName("Connect"); @@ -6272,7 +6226,7 @@ vmCvar_t ui_realWarmUp; vmCvar_t ui_serverStatusTimeOut; //TA: bank values -vmCvar_t ui_bank; +vmCvar_t ui_bank; // bk001129 - made static to avoid aliasing @@ -6395,7 +6349,7 @@ static cvarTable_t cvarTable[] = { { &ui_realWarmUp, "g_warmup", "20", CVAR_ARCHIVE}, { &ui_realCaptureLimit, "capturelimit", "8", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_NORESTART}, { &ui_serverStatusTimeOut, "ui_serverStatusTimeOut", "7000", CVAR_ARCHIVE}, - + { &ui_bank, "ui_bank", "0", 0 }, }; diff --git a/src/ui/ui_players.c b/src/ui/ui_players.c index ee2c5126..4560cbd2 100644 --- a/src/ui/ui_players.c +++ b/src/ui/ui_players.c @@ -19,24 +19,24 @@ #include "ui_local.h" -#define UI_TIMER_GESTURE 2300 -#define UI_TIMER_JUMP 1000 -#define UI_TIMER_LAND 130 -#define UI_TIMER_WEAPON_SWITCH 300 -#define UI_TIMER_ATTACK 500 -#define UI_TIMER_MUZZLE_FLASH 20 -#define UI_TIMER_WEAPON_DELAY 250 +#define UI_TIMER_GESTURE 2300 +#define UI_TIMER_JUMP 1000 +#define UI_TIMER_LAND 130 +#define UI_TIMER_WEAPON_SWITCH 300 +#define UI_TIMER_ATTACK 500 +#define UI_TIMER_MUZZLE_FLASH 20 +#define UI_TIMER_WEAPON_DELAY 250 -#define JUMP_HEIGHT 56 +#define JUMP_HEIGHT 56 -#define SWINGSPEED 0.3f +#define SWINGSPEED 0.3f -#define SPIN_SPEED 0.9f -#define COAST_TIME 1000 +#define SPIN_SPEED 0.9f +#define COAST_TIME 1000 -static int dp_realtime; -static float jumpHeight; +static int dp_realtime; +static float jumpHeight; sfxHandle_t weaponChangeSound; @@ -48,86 +48,86 @@ UI_PlayerInfo_SetWeapon static void UI_PlayerInfo_SetWeapon( playerInfo_t *pi, weapon_t weaponNum ) { //TA: FIXME: this is probably useless for trem -/* gitem_t * item; - char path[MAX_QPATH]; +/* gitem_t * item; + char path[MAX_QPATH]; - pi->currentWeapon = weaponNum; + pi->currentWeapon = weaponNum; tryagain: - pi->realWeapon = weaponNum; - pi->weaponModel = 0; - pi->barrelModel = 0; - pi->flashModel = 0; - - if ( weaponNum == WP_NONE ) { - return; - } - - if ( item->classname ) { - pi->weaponModel = trap_R_RegisterModel( item->world_model[0] ); - } - - if( pi->weaponModel == 0 ) { - if( weaponNum == WP_MACHINEGUN ) { - weaponNum = WP_NONE; - goto tryagain; - } - weaponNum = WP_MACHINEGUN; - goto tryagain; - } - - if ( weaponNum == WP_MACHINEGUN ) { - strcpy( path, item->world_model[0] ); - COM_StripExtension( path, path ); - strcat( path, "_barrel.md3" ); - pi->barrelModel = trap_R_RegisterModel( path ); - } - - strcpy( path, item->world_model[0] ); - COM_StripExtension( path, path ); - strcat( path, "_flash.md3" ); - pi->flashModel = trap_R_RegisterModel( path ); - - switch( weaponNum ) { - case WP_GAUNTLET: - MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 ); - break; - - case WP_MACHINEGUN: - MAKERGB( pi->flashDlightColor, 1, 1, 0 ); - break; - - case WP_SHOTGUN: - MAKERGB( pi->flashDlightColor, 1, 1, 0 ); - break; - - case WP_GRENADE_LAUNCHER: - MAKERGB( pi->flashDlightColor, 1, 0.7f, 0.5f ); - break; - - case WP_ROCKET_LAUNCHER: - MAKERGB( pi->flashDlightColor, 1, 0.75f, 0 ); - break; - - case WP_TESLAGEN: - MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 ); - break; - - case WP_RAILGUN: - MAKERGB( pi->flashDlightColor, 1, 0.5f, 0 ); - break; - - case WP_BFG: - MAKERGB( pi->flashDlightColor, 1, 0.7f, 1 ); - break; - - case WP_GRAPPLING_HOOK: - MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 ); - break; - - default: - MAKERGB( pi->flashDlightColor, 1, 1, 1 ); - break; - }*/ + pi->realWeapon = weaponNum; + pi->weaponModel = 0; + pi->barrelModel = 0; + pi->flashModel = 0; + + if ( weaponNum == WP_NONE ) { + return; + } + + if ( item->classname ) { + pi->weaponModel = trap_R_RegisterModel( item->world_model[0] ); + } + + if( pi->weaponModel == 0 ) { + if( weaponNum == WP_MACHINEGUN ) { + weaponNum = WP_NONE; + goto tryagain; + } + weaponNum = WP_MACHINEGUN; + goto tryagain; + } + + if ( weaponNum == WP_MACHINEGUN ) { + strcpy( path, item->world_model[0] ); + COM_StripExtension( path, path ); + strcat( path, "_barrel.md3" ); + pi->barrelModel = trap_R_RegisterModel( path ); + } + + strcpy( path, item->world_model[0] ); + COM_StripExtension( path, path ); + strcat( path, "_flash.md3" ); + pi->flashModel = trap_R_RegisterModel( path ); + + switch( weaponNum ) { + case WP_GAUNTLET: + MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 ); + break; + + case WP_MACHINEGUN: + MAKERGB( pi->flashDlightColor, 1, 1, 0 ); + break; + + case WP_SHOTGUN: + MAKERGB( pi->flashDlightColor, 1, 1, 0 ); + break; + + case WP_GRENADE_LAUNCHER: + MAKERGB( pi->flashDlightColor, 1, 0.7f, 0.5f ); + break; + + case WP_ROCKET_LAUNCHER: + MAKERGB( pi->flashDlightColor, 1, 0.75f, 0 ); + break; + + case WP_TESLAGEN: + MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 ); + break; + + case WP_RAILGUN: + MAKERGB( pi->flashDlightColor, 1, 0.5f, 0 ); + break; + + case WP_BFG: + MAKERGB( pi->flashDlightColor, 1, 0.7f, 1 ); + break; + + case WP_GRAPPLING_HOOK: + MAKERGB( pi->flashDlightColor, 0.6f, 0.6f, 1 ); + break; + + default: + MAKERGB( pi->flashDlightColor, 1, 1, 1 ); + break; + }*/ } @@ -137,11 +137,11 @@ UI_ForceLegsAnim =============== */ static void UI_ForceLegsAnim( playerInfo_t *pi, int anim ) { - pi->legsAnim = ( ( pi->legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; + pi->legsAnim = ( ( pi->legsAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; - if ( anim == LEGS_JUMP ) { - pi->legsAnimationTimer = UI_TIMER_JUMP; - } + if ( anim == LEGS_JUMP ) { + pi->legsAnimationTimer = UI_TIMER_JUMP; + } } @@ -151,11 +151,11 @@ UI_SetLegsAnim =============== */ static void UI_SetLegsAnim( playerInfo_t *pi, int anim ) { - if ( pi->pendingLegsAnim ) { - anim = pi->pendingLegsAnim; - pi->pendingLegsAnim = 0; - } - UI_ForceLegsAnim( pi, anim ); + if ( pi->pendingLegsAnim ) { + anim = pi->pendingLegsAnim; + pi->pendingLegsAnim = 0; + } + UI_ForceLegsAnim( pi, anim ); } @@ -165,15 +165,15 @@ UI_ForceTorsoAnim =============== */ static void UI_ForceTorsoAnim( playerInfo_t *pi, int anim ) { - pi->torsoAnim = ( ( pi->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; + pi->torsoAnim = ( ( pi->torsoAnim & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; - if ( anim == TORSO_GESTURE ) { - pi->torsoAnimationTimer = UI_TIMER_GESTURE; - } + if ( anim == TORSO_GESTURE ) { + pi->torsoAnimationTimer = UI_TIMER_GESTURE; + } - if ( anim == TORSO_ATTACK || anim == TORSO_ATTACK2 ) { - pi->torsoAnimationTimer = UI_TIMER_ATTACK; - } + if ( anim == TORSO_ATTACK || anim == TORSO_ATTACK2 ) { + pi->torsoAnimationTimer = UI_TIMER_ATTACK; + } } @@ -183,12 +183,12 @@ UI_SetTorsoAnim =============== */ static void UI_SetTorsoAnim( playerInfo_t *pi, int anim ) { - if ( pi->pendingTorsoAnim ) { - anim = pi->pendingTorsoAnim; - pi->pendingTorsoAnim = 0; - } + if ( pi->pendingTorsoAnim ) { + anim = pi->pendingTorsoAnim; + pi->pendingTorsoAnim = 0; + } - UI_ForceTorsoAnim( pi, anim ); + UI_ForceTorsoAnim( pi, anim ); } @@ -198,42 +198,42 @@ UI_TorsoSequencing =============== */ static void UI_TorsoSequencing( playerInfo_t *pi ) { - int currentAnim; - - currentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT; - - if ( pi->weapon != pi->currentWeapon ) { - if ( currentAnim != TORSO_DROP ) { - pi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH; - UI_ForceTorsoAnim( pi, TORSO_DROP ); - } - } - - if ( pi->torsoAnimationTimer > 0 ) { - return; - } - - if( currentAnim == TORSO_GESTURE ) { - UI_SetTorsoAnim( pi, TORSO_STAND ); - return; - } - - if( currentAnim == TORSO_ATTACK || currentAnim == TORSO_ATTACK2 ) { - UI_SetTorsoAnim( pi, TORSO_STAND ); - return; - } - - if ( currentAnim == TORSO_DROP ) { - UI_PlayerInfo_SetWeapon( pi, pi->weapon ); - pi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH; - UI_ForceTorsoAnim( pi, TORSO_RAISE ); - return; - } - - if ( currentAnim == TORSO_RAISE ) { - UI_SetTorsoAnim( pi, TORSO_STAND ); - return; - } + int currentAnim; + + currentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT; + + if ( pi->weapon != pi->currentWeapon ) { + if ( currentAnim != TORSO_DROP ) { + pi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH; + UI_ForceTorsoAnim( pi, TORSO_DROP ); + } + } + + if ( pi->torsoAnimationTimer > 0 ) { + return; + } + + if( currentAnim == TORSO_GESTURE ) { + UI_SetTorsoAnim( pi, TORSO_STAND ); + return; + } + + if( currentAnim == TORSO_ATTACK || currentAnim == TORSO_ATTACK2 ) { + UI_SetTorsoAnim( pi, TORSO_STAND ); + return; + } + + if ( currentAnim == TORSO_DROP ) { + UI_PlayerInfo_SetWeapon( pi, pi->weapon ); + pi->torsoAnimationTimer = UI_TIMER_WEAPON_SWITCH; + UI_ForceTorsoAnim( pi, TORSO_RAISE ); + return; + } + + if ( currentAnim == TORSO_RAISE ) { + UI_SetTorsoAnim( pi, TORSO_STAND ); + return; + } } @@ -243,28 +243,28 @@ UI_LegsSequencing =============== */ static void UI_LegsSequencing( playerInfo_t *pi ) { - int currentAnim; - - currentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT; - - if ( pi->legsAnimationTimer > 0 ) { - if ( currentAnim == LEGS_JUMP ) { - jumpHeight = JUMP_HEIGHT * sin( M_PI * ( UI_TIMER_JUMP - pi->legsAnimationTimer ) / UI_TIMER_JUMP ); - } - return; - } - - if ( currentAnim == LEGS_JUMP ) { - UI_ForceLegsAnim( pi, LEGS_LAND ); - pi->legsAnimationTimer = UI_TIMER_LAND; - jumpHeight = 0; - return; - } - - if ( currentAnim == LEGS_LAND ) { - UI_SetLegsAnim( pi, LEGS_IDLE ); - return; - } + int currentAnim; + + currentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT; + + if ( pi->legsAnimationTimer > 0 ) { + if ( currentAnim == LEGS_JUMP ) { + jumpHeight = JUMP_HEIGHT * sin( M_PI * ( UI_TIMER_JUMP - pi->legsAnimationTimer ) / UI_TIMER_JUMP ); + } + return; + } + + if ( currentAnim == LEGS_JUMP ) { + UI_ForceLegsAnim( pi, LEGS_LAND ); + pi->legsAnimationTimer = UI_TIMER_LAND; + jumpHeight = 0; + return; + } + + if ( currentAnim == LEGS_LAND ) { + UI_SetLegsAnim( pi, LEGS_IDLE ); + return; + } } @@ -273,24 +273,24 @@ static void UI_LegsSequencing( playerInfo_t *pi ) { UI_PositionEntityOnTag ====================== */ -static void UI_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, - clipHandle_t parentModel, char *tagName ) { - int i; - orientation_t lerped; - - // lerp the tag - trap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame, - 1.0 - parent->backlerp, tagName ); - - // FIXME: allow origin offsets along tag? - VectorCopy( parent->origin, entity->origin ); - for ( i = 0 ; i < 3 ; i++ ) { - VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin ); - } - - // cast away const because of compiler problems - MatrixMultiply( lerped.axis, ((refEntity_t*)parent)->axis, entity->axis ); - entity->backlerp = parent->backlerp; +static void UI_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, + clipHandle_t parentModel, char *tagName ) { + int i; + orientation_t lerped; + + // lerp the tag + trap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame, + 1.0 - parent->backlerp, tagName ); + + // FIXME: allow origin offsets along tag? + VectorCopy( parent->origin, entity->origin ); + for ( i = 0 ; i < 3 ; i++ ) { + VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin ); + } + + // cast away const because of compiler problems + MatrixMultiply( lerped.axis, ((refEntity_t*)parent)->axis, entity->axis ); + entity->backlerp = parent->backlerp; } @@ -299,25 +299,25 @@ static void UI_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *pare UI_PositionRotatedEntityOnTag ====================== */ -static void UI_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, - clipHandle_t parentModel, char *tagName ) { - int i; - orientation_t lerped; - vec3_t tempAxis[3]; - - // lerp the tag - trap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame, - 1.0 - parent->backlerp, tagName ); - - // FIXME: allow origin offsets along tag? - VectorCopy( parent->origin, entity->origin ); - for ( i = 0 ; i < 3 ; i++ ) { - VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin ); - } - - // cast away const because of compiler problems - MatrixMultiply( entity->axis, ((refEntity_t *)parent)->axis, tempAxis ); - MatrixMultiply( lerped.axis, tempAxis, entity->axis ); +static void UI_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, + clipHandle_t parentModel, char *tagName ) { + int i; + orientation_t lerped; + vec3_t tempAxis[3]; + + // lerp the tag + trap_CM_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame, + 1.0 - parent->backlerp, tagName ); + + // FIXME: allow origin offsets along tag? + VectorCopy( parent->origin, entity->origin ); + for ( i = 0 ; i < 3 ; i++ ) { + VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin ); + } + + // cast away const because of compiler problems + MatrixMultiply( entity->axis, ((refEntity_t *)parent)->axis, tempAxis ); + MatrixMultiply( lerped.axis, tempAxis, entity->axis ); } @@ -327,19 +327,19 @@ UI_SetLerpFrameAnimation =============== */ static void UI_SetLerpFrameAnimation( playerInfo_t *ci, lerpFrame_t *lf, int newAnimation ) { - animation_t *anim; + animation_t *anim; - lf->animationNumber = newAnimation; - newAnimation &= ~ANIM_TOGGLEBIT; + lf->animationNumber = newAnimation; + newAnimation &= ~ANIM_TOGGLEBIT; - if ( newAnimation < 0 || newAnimation >= MAX_PLAYER_ANIMATIONS ) { - trap_Error( va("Bad animation number: %i", newAnimation) ); - } + if ( newAnimation < 0 || newAnimation >= MAX_PLAYER_ANIMATIONS ) { + trap_Error( va("Bad animation number: %i", newAnimation) ); + } - anim = &ci->animations[ newAnimation ]; + anim = &ci->animations[ newAnimation ]; - lf->animation = anim; - lf->animationTime = lf->frameTime + anim->initialLerp; + lf->animation = anim; + lf->animationTime = lf->frameTime + anim->initialLerp; } @@ -349,59 +349,59 @@ UI_RunLerpFrame =============== */ static void UI_RunLerpFrame( playerInfo_t *ci, lerpFrame_t *lf, int newAnimation ) { - int f; - animation_t *anim; - - // see if the animation sequence is switching - if ( newAnimation != lf->animationNumber || !lf->animation ) { - UI_SetLerpFrameAnimation( ci, lf, newAnimation ); - } - - // if we have passed the current frame, move it to - // oldFrame and calculate a new frame - if ( dp_realtime >= lf->frameTime ) { - lf->oldFrame = lf->frame; - lf->oldFrameTime = lf->frameTime; - - // get the next frame based on the animation - anim = lf->animation; - if ( dp_realtime < lf->animationTime ) { - lf->frameTime = lf->animationTime; // initial lerp - } else { - lf->frameTime = lf->oldFrameTime + anim->frameLerp; - } - f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp; - if ( f >= anim->numFrames ) { - f -= anim->numFrames; - if ( anim->loopFrames ) { - f %= anim->loopFrames; - f += anim->numFrames - anim->loopFrames; - } else { - f = anim->numFrames - 1; - // the animation is stuck at the end, so it - // can immediately transition to another sequence - lf->frameTime = dp_realtime; - } - } - lf->frame = anim->firstFrame + f; - if ( dp_realtime > lf->frameTime ) { - lf->frameTime = dp_realtime; - } - } - - if ( lf->frameTime > dp_realtime + 200 ) { - lf->frameTime = dp_realtime; - } - - if ( lf->oldFrameTime > dp_realtime ) { - lf->oldFrameTime = dp_realtime; - } - // calculate current lerp value - if ( lf->frameTime == lf->oldFrameTime ) { - lf->backlerp = 0; - } else { - lf->backlerp = 1.0 - (float)( dp_realtime - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime ); - } + int f; + animation_t *anim; + + // see if the animation sequence is switching + if ( newAnimation != lf->animationNumber || !lf->animation ) { + UI_SetLerpFrameAnimation( ci, lf, newAnimation ); + } + + // if we have passed the current frame, move it to + // oldFrame and calculate a new frame + if ( dp_realtime >= lf->frameTime ) { + lf->oldFrame = lf->frame; + lf->oldFrameTime = lf->frameTime; + + // get the next frame based on the animation + anim = lf->animation; + if ( dp_realtime < lf->animationTime ) { + lf->frameTime = lf->animationTime; // initial lerp + } else { + lf->frameTime = lf->oldFrameTime + anim->frameLerp; + } + f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp; + if ( f >= anim->numFrames ) { + f -= anim->numFrames; + if ( anim->loopFrames ) { + f %= anim->loopFrames; + f += anim->numFrames - anim->loopFrames; + } else { + f = anim->numFrames - 1; + // the animation is stuck at the end, so it + // can immediately transition to another sequence + lf->frameTime = dp_realtime; + } + } + lf->frame = anim->firstFrame + f; + if ( dp_realtime > lf->frameTime ) { + lf->frameTime = dp_realtime; + } + } + + if ( lf->frameTime > dp_realtime + 200 ) { + lf->frameTime = dp_realtime; + } + + if ( lf->oldFrameTime > dp_realtime ) { + lf->oldFrameTime = dp_realtime; + } + // calculate current lerp value + if ( lf->frameTime == lf->oldFrameTime ) { + lf->backlerp = 0; + } else { + lf->backlerp = 1.0 - (float)( dp_realtime - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime ); + } } @@ -411,37 +411,37 @@ UI_PlayerAnimation =============== */ static void UI_PlayerAnimation( playerInfo_t *pi, int *legsOld, int *legs, float *legsBackLerp, - int *torsoOld, int *torso, float *torsoBackLerp ) { - - // legs animation - pi->legsAnimationTimer -= uiInfo.uiDC.frameTime; - if ( pi->legsAnimationTimer < 0 ) { - pi->legsAnimationTimer = 0; - } - - UI_LegsSequencing( pi ); - - if ( pi->legs.yawing && ( pi->legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) { - UI_RunLerpFrame( pi, &pi->legs, LEGS_TURN ); - } else { - UI_RunLerpFrame( pi, &pi->legs, pi->legsAnim ); - } - *legsOld = pi->legs.oldFrame; - *legs = pi->legs.frame; - *legsBackLerp = pi->legs.backlerp; - - // torso animation - pi->torsoAnimationTimer -= uiInfo.uiDC.frameTime; - if ( pi->torsoAnimationTimer < 0 ) { - pi->torsoAnimationTimer = 0; - } - - UI_TorsoSequencing( pi ); - - UI_RunLerpFrame( pi, &pi->torso, pi->torsoAnim ); - *torsoOld = pi->torso.oldFrame; - *torso = pi->torso.frame; - *torsoBackLerp = pi->torso.backlerp; + int *torsoOld, int *torso, float *torsoBackLerp ) { + + // legs animation + pi->legsAnimationTimer -= uiInfo.uiDC.frameTime; + if ( pi->legsAnimationTimer < 0 ) { + pi->legsAnimationTimer = 0; + } + + UI_LegsSequencing( pi ); + + if ( pi->legs.yawing && ( pi->legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) { + UI_RunLerpFrame( pi, &pi->legs, LEGS_TURN ); + } else { + UI_RunLerpFrame( pi, &pi->legs, pi->legsAnim ); + } + *legsOld = pi->legs.oldFrame; + *legs = pi->legs.frame; + *legsBackLerp = pi->legs.backlerp; + + // torso animation + pi->torsoAnimationTimer -= uiInfo.uiDC.frameTime; + if ( pi->torsoAnimationTimer < 0 ) { + pi->torsoAnimationTimer = 0; + } + + UI_TorsoSequencing( pi ); + + UI_RunLerpFrame( pi, &pi->torso, pi->torsoAnim ); + *torsoOld = pi->torso.oldFrame; + *torso = pi->torso.frame; + *torsoBackLerp = pi->torso.backlerp; } @@ -451,59 +451,59 @@ UI_SwingAngles ================== */ static void UI_SwingAngles( float destination, float swingTolerance, float clampTolerance, - float speed, float *angle, qboolean *swinging ) { - float swing; - float move; - float scale; - - if ( !*swinging ) { - // see if a swing should be started - swing = AngleSubtract( *angle, destination ); - if ( swing > swingTolerance || swing < -swingTolerance ) { - *swinging = qtrue; - } - } - - if ( !*swinging ) { - return; - } - - // modify the speed depending on the delta - // 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 ) { - scale = 1.0; - } else { - scale = 2.0; - } - - // swing towards the destination angle - if ( swing >= 0 ) { - move = uiInfo.uiDC.frameTime * scale * speed; - if ( move >= swing ) { - move = swing; - *swinging = qfalse; - } - *angle = AngleMod( *angle + move ); - } else if ( swing < 0 ) { - move = uiInfo.uiDC.frameTime * scale * -speed; - if ( move <= swing ) { - move = swing; - *swinging = qfalse; - } - *angle = AngleMod( *angle + move ); - } - - // clamp to no more than tolerance - swing = AngleSubtract( destination, *angle ); - if ( swing > clampTolerance ) { - *angle = AngleMod( destination - (clampTolerance - 1) ); - } else if ( swing < -clampTolerance ) { - *angle = AngleMod( destination + (clampTolerance - 1) ); - } + float speed, float *angle, qboolean *swinging ) { + float swing; + float move; + float scale; + + if ( !*swinging ) { + // see if a swing should be started + swing = AngleSubtract( *angle, destination ); + if ( swing > swingTolerance || swing < -swingTolerance ) { + *swinging = qtrue; + } + } + + if ( !*swinging ) { + return; + } + + // modify the speed depending on the delta + // 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 ) { + scale = 1.0; + } else { + scale = 2.0; + } + + // swing towards the destination angle + if ( swing >= 0 ) { + move = uiInfo.uiDC.frameTime * scale * speed; + if ( move >= swing ) { + move = swing; + *swinging = qfalse; + } + *angle = AngleMod( *angle + move ); + } else if ( swing < 0 ) { + move = uiInfo.uiDC.frameTime * scale * -speed; + if ( move <= swing ) { + move = swing; + *swinging = qfalse; + } + *angle = AngleMod( *angle + move ); + } + + // clamp to no more than tolerance + swing = AngleSubtract( destination, *angle ); + if ( swing > clampTolerance ) { + *angle = AngleMod( destination - (clampTolerance - 1) ); + } else if ( swing < -clampTolerance ) { + *angle = AngleMod( destination + (clampTolerance - 1) ); + } } @@ -513,41 +513,41 @@ UI_MovedirAdjustment ====================== */ static float UI_MovedirAdjustment( playerInfo_t *pi ) { - vec3_t relativeAngles; - vec3_t moveVector; - - VectorSubtract( pi->viewAngles, pi->moveAngles, relativeAngles ); - AngleVectors( relativeAngles, moveVector, NULL, NULL ); - if ( Q_fabs( moveVector[0] ) < 0.01 ) { - moveVector[0] = 0.0; - } - if ( Q_fabs( moveVector[1] ) < 0.01 ) { - moveVector[1] = 0.0; - } - - if ( moveVector[1] == 0 && moveVector[0] > 0 ) { - return 0; - } - if ( moveVector[1] < 0 && moveVector[0] > 0 ) { - return 22; - } - if ( moveVector[1] < 0 && moveVector[0] == 0 ) { - return 45; - } - if ( moveVector[1] < 0 && moveVector[0] < 0 ) { - return -22; - } - if ( moveVector[1] == 0 && moveVector[0] < 0 ) { - return 0; - } - if ( moveVector[1] > 0 && moveVector[0] < 0 ) { - return 22; - } - if ( moveVector[1] > 0 && moveVector[0] == 0 ) { - return -45; - } - - return -22; + vec3_t relativeAngles; + vec3_t moveVector; + + VectorSubtract( pi->viewAngles, pi->moveAngles, relativeAngles ); + AngleVectors( relativeAngles, moveVector, NULL, NULL ); + if ( Q_fabs( moveVector[0] ) < 0.01 ) { + moveVector[0] = 0.0; + } + if ( Q_fabs( moveVector[1] ) < 0.01 ) { + moveVector[1] = 0.0; + } + + if ( moveVector[1] == 0 && moveVector[0] > 0 ) { + return 0; + } + if ( moveVector[1] < 0 && moveVector[0] > 0 ) { + return 22; + } + if ( moveVector[1] < 0 && moveVector[0] == 0 ) { + return 45; + } + if ( moveVector[1] < 0 && moveVector[0] < 0 ) { + return -22; + } + if ( moveVector[1] == 0 && moveVector[0] < 0 ) { + return 0; + } + if ( moveVector[1] > 0 && moveVector[0] < 0 ) { + return 22; + } + if ( moveVector[1] > 0 && moveVector[0] == 0 ) { + return -45; + } + + return -22; } @@ -557,56 +557,56 @@ UI_PlayerAngles =============== */ static void UI_PlayerAngles( playerInfo_t *pi, vec3_t legs[3], vec3_t torso[3], vec3_t head[3] ) { - vec3_t legsAngles, torsoAngles, headAngles; - float dest; - float adjust; - - VectorCopy( pi->viewAngles, headAngles ); - headAngles[YAW] = AngleMod( headAngles[YAW] ); - VectorClear( legsAngles ); - VectorClear( torsoAngles ); - - // --------- yaw ------------- - - // allow yaw to drift a bit - if ( ( pi->legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_IDLE - || ( pi->torsoAnim & ~ANIM_TOGGLEBIT ) != TORSO_STAND ) { - // if not standing still, always point all in the same direction - pi->torso.yawing = qtrue; // always center - pi->torso.pitching = qtrue; // always center - pi->legs.yawing = qtrue; // always center - } - - // adjust legs for movement dir - adjust = UI_MovedirAdjustment( pi ); - legsAngles[YAW] = headAngles[YAW] + adjust; - torsoAngles[YAW] = headAngles[YAW] + 0.25 * adjust; - - - // torso - UI_SwingAngles( torsoAngles[YAW], 25, 90, SWINGSPEED, &pi->torso.yawAngle, &pi->torso.yawing ); - UI_SwingAngles( legsAngles[YAW], 40, 90, SWINGSPEED, &pi->legs.yawAngle, &pi->legs.yawing ); - - torsoAngles[YAW] = pi->torso.yawAngle; - legsAngles[YAW] = pi->legs.yawAngle; - - // --------- pitch ------------- - - // only show a fraction of the pitch angle in the torso - if ( headAngles[PITCH] > 180 ) { - dest = (-360 + headAngles[PITCH]) * 0.75; - } else { - dest = headAngles[PITCH] * 0.75; - } - UI_SwingAngles( dest, 15, 30, 0.1f, &pi->torso.pitchAngle, &pi->torso.pitching ); - torsoAngles[PITCH] = pi->torso.pitchAngle; - - // pull the angles back out of the hierarchial chain - AnglesSubtract( headAngles, torsoAngles, headAngles ); - AnglesSubtract( torsoAngles, legsAngles, torsoAngles ); - AnglesToAxis( legsAngles, legs ); - AnglesToAxis( torsoAngles, torso ); - AnglesToAxis( headAngles, head ); + vec3_t legsAngles, torsoAngles, headAngles; + float dest; + float adjust; + + VectorCopy( pi->viewAngles, headAngles ); + headAngles[YAW] = AngleMod( headAngles[YAW] ); + VectorClear( legsAngles ); + VectorClear( torsoAngles ); + + // --------- yaw ------------- + + // allow yaw to drift a bit + if ( ( pi->legsAnim & ~ANIM_TOGGLEBIT ) != LEGS_IDLE + || ( pi->torsoAnim & ~ANIM_TOGGLEBIT ) != TORSO_STAND ) { + // if not standing still, always point all in the same direction + pi->torso.yawing = qtrue; // always center + pi->torso.pitching = qtrue; // always center + pi->legs.yawing = qtrue; // always center + } + + // adjust legs for movement dir + adjust = UI_MovedirAdjustment( pi ); + legsAngles[YAW] = headAngles[YAW] + adjust; + torsoAngles[YAW] = headAngles[YAW] + 0.25 * adjust; + + + // torso + UI_SwingAngles( torsoAngles[YAW], 25, 90, SWINGSPEED, &pi->torso.yawAngle, &pi->torso.yawing ); + UI_SwingAngles( legsAngles[YAW], 40, 90, SWINGSPEED, &pi->legs.yawAngle, &pi->legs.yawing ); + + torsoAngles[YAW] = pi->torso.yawAngle; + legsAngles[YAW] = pi->legs.yawAngle; + + // --------- pitch ------------- + + // only show a fraction of the pitch angle in the torso + if ( headAngles[PITCH] > 180 ) { + dest = (-360 + headAngles[PITCH]) * 0.75; + } else { + dest = headAngles[PITCH] * 0.75; + } + UI_SwingAngles( dest, 15, 30, 0.1f, &pi->torso.pitchAngle, &pi->torso.pitching ); + torsoAngles[PITCH] = pi->torso.pitchAngle; + + // pull the angles back out of the hierarchial chain + AnglesSubtract( headAngles, torsoAngles, headAngles ); + AnglesSubtract( torsoAngles, legsAngles, torsoAngles ); + AnglesToAxis( legsAngles, legs ); + AnglesToAxis( torsoAngles, torso ); + AnglesToAxis( headAngles, head ); } @@ -616,16 +616,16 @@ UI_PlayerFloatSprite =============== */ static void UI_PlayerFloatSprite( playerInfo_t *pi, vec3_t origin, qhandle_t shader ) { - refEntity_t ent; - - memset( &ent, 0, sizeof( ent ) ); - VectorCopy( origin, ent.origin ); - ent.origin[2] += 48; - ent.reType = RT_SPRITE; - ent.customShader = shader; - ent.radius = 10; - ent.renderfx = 0; - trap_R_AddRefEntityToScene( &ent ); + refEntity_t ent; + + memset( &ent, 0, sizeof( ent ) ); + VectorCopy( origin, ent.origin ); + ent.origin[2] += 48; + ent.reType = RT_SPRITE; + ent.customShader = shader; + ent.radius = 10; + ent.renderfx = 0; + trap_R_AddRefEntityToScene( &ent ); } @@ -634,35 +634,35 @@ static void UI_PlayerFloatSprite( playerInfo_t *pi, vec3_t origin, qhandle_t sha UI_MachinegunSpinAngle ====================== */ -float UI_MachinegunSpinAngle( playerInfo_t *pi ) { - int delta; - float angle; - float speed; - int torsoAnim; - - delta = dp_realtime - pi->barrelTime; - if ( pi->barrelSpinning ) { - angle = pi->barrelAngle + delta * SPIN_SPEED; - } else { - if ( delta > COAST_TIME ) { - delta = COAST_TIME; - } - - speed = 0.5 * ( SPIN_SPEED + (float)( COAST_TIME - delta ) / COAST_TIME ); - angle = pi->barrelAngle + delta * speed; - } - - torsoAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT; - if( torsoAnim == TORSO_ATTACK2 ) { - torsoAnim = TORSO_ATTACK; - } - if ( pi->barrelSpinning == !(torsoAnim == TORSO_ATTACK) ) { - pi->barrelTime = dp_realtime; - pi->barrelAngle = AngleMod( angle ); - pi->barrelSpinning = !!(torsoAnim == TORSO_ATTACK); - } - - return angle; +float UI_MachinegunSpinAngle( playerInfo_t *pi ) { + int delta; + float angle; + float speed; + int torsoAnim; + + delta = dp_realtime - pi->barrelTime; + if ( pi->barrelSpinning ) { + angle = pi->barrelAngle + delta * SPIN_SPEED; + } else { + if ( delta > COAST_TIME ) { + delta = COAST_TIME; + } + + speed = 0.5 * ( SPIN_SPEED + (float)( COAST_TIME - delta ) / COAST_TIME ); + angle = pi->barrelAngle + delta * speed; + } + + torsoAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT; + if( torsoAnim == TORSO_ATTACK2 ) { + torsoAnim = TORSO_ATTACK; + } + if ( pi->barrelSpinning == !(torsoAnim == TORSO_ATTACK) ) { + pi->barrelTime = dp_realtime; + pi->barrelAngle = AngleMod( angle ); + pi->barrelSpinning = !!(torsoAnim == TORSO_ATTACK); + } + + return angle; } @@ -672,214 +672,214 @@ UI_DrawPlayer =============== */ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int time ) { - refdef_t refdef; - refEntity_t legs; - refEntity_t torso; - refEntity_t head; - refEntity_t gun; - refEntity_t barrel; - refEntity_t flash; - vec3_t origin; - int renderfx; - vec3_t mins = {-16, -16, -24}; - vec3_t maxs = {16, 16, 32}; - float len; - float xx; + refdef_t refdef; + refEntity_t legs; + refEntity_t torso; + refEntity_t head; + refEntity_t gun; + refEntity_t barrel; + refEntity_t flash; + vec3_t origin; + int renderfx; + vec3_t mins = {-16, -16, -24}; + vec3_t maxs = {16, 16, 32}; + float len; + float xx; - if ( !pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames ) { - return; - } - - // this allows the ui to cache the player model on the main menu - if (w == 0 || h == 0) { - return; - } - - dp_realtime = time; - - if ( pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer ) { - pi->weapon = pi->pendingWeapon; - pi->lastWeapon = pi->pendingWeapon; - pi->pendingWeapon = -1; - pi->weaponTimer = 0; - if( pi->currentWeapon != pi->weapon ) { - trap_S_StartLocalSound( weaponChangeSound, CHAN_LOCAL ); - } - } + if ( !pi->legsModel || !pi->torsoModel || !pi->headModel || !pi->animations[0].numFrames ) { + return; + } - UI_AdjustFrom640( &x, &y, &w, &h ); - - y -= jumpHeight; - - memset( &refdef, 0, sizeof( refdef ) ); - memset( &legs, 0, sizeof(legs) ); - memset( &torso, 0, sizeof(torso) ); - memset( &head, 0, sizeof(head) ); - - refdef.rdflags = RDF_NOWORLDMODEL; - - AxisClear( refdef.viewaxis ); - - refdef.x = x; - refdef.y = y; - refdef.width = w; - refdef.height = h; - - refdef.fov_x = (int)((float)refdef.width / 640.0f * 90.0f); - xx = refdef.width / tan( refdef.fov_x / 360 * M_PI ); - refdef.fov_y = atan2( refdef.height, xx ); - refdef.fov_y *= ( 360 / (float)M_PI ); - - // calculate distance so the player nearly fills the box - len = 0.7 * ( maxs[2] - mins[2] ); - origin[0] = len / tan( DEG2RAD(refdef.fov_x) * 0.5 ); - origin[1] = 0.5 * ( mins[1] + maxs[1] ); - origin[2] = -0.5 * ( mins[2] + maxs[2] ); - - refdef.time = dp_realtime; - - trap_R_ClearScene(); - - // get the rotation information - UI_PlayerAngles( pi, legs.axis, torso.axis, head.axis ); - - // get the animation state (after rotation, to allow feet shuffle) - UI_PlayerAnimation( pi, &legs.oldframe, &legs.frame, &legs.backlerp, - &torso.oldframe, &torso.frame, &torso.backlerp ); - - renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; - - // - // add the legs - // - legs.hModel = pi->legsModel; - legs.customSkin = pi->legsSkin; - - VectorCopy( origin, legs.origin ); - - VectorCopy( origin, legs.lightingOrigin ); - legs.renderfx = renderfx; - VectorCopy (legs.origin, legs.oldorigin); - - trap_R_AddRefEntityToScene( &legs ); - - if (!legs.hModel) { - return; - } - - // - // add the torso - // - torso.hModel = pi->torsoModel; - if (!torso.hModel) { - return; - } - - torso.customSkin = pi->torsoSkin; - - VectorCopy( origin, torso.lightingOrigin ); - - UI_PositionRotatedEntityOnTag( &torso, &legs, pi->legsModel, "tag_torso"); - - torso.renderfx = renderfx; - - trap_R_AddRefEntityToScene( &torso ); - - // - // add the head - // - head.hModel = pi->headModel; - if (!head.hModel) { - return; - } - head.customSkin = pi->headSkin; - - VectorCopy( origin, head.lightingOrigin ); - - UI_PositionRotatedEntityOnTag( &head, &torso, pi->torsoModel, "tag_head"); - - head.renderfx = renderfx; - - trap_R_AddRefEntityToScene( &head ); - - // - // add the gun - // - if ( pi->currentWeapon != WP_NONE ) { - memset( &gun, 0, sizeof(gun) ); - gun.hModel = pi->weaponModel; - VectorCopy( origin, gun.lightingOrigin ); - UI_PositionEntityOnTag( &gun, &torso, pi->torsoModel, "tag_weapon"); - gun.renderfx = renderfx; - trap_R_AddRefEntityToScene( &gun ); - } - - // - // add the spinning barrel - // - if ( pi->realWeapon == WP_MACHINEGUN ) { - vec3_t angles; - - memset( &barrel, 0, sizeof(barrel) ); - VectorCopy( origin, barrel.lightingOrigin ); - barrel.renderfx = renderfx; - - barrel.hModel = pi->barrelModel; - angles[YAW] = 0; - angles[PITCH] = 0; - angles[ROLL] = UI_MachinegunSpinAngle( pi ); -/* if( pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG ) { - angles[PITCH] = angles[ROLL]; - angles[ROLL] = 0; - }*/ - AnglesToAxis( angles, barrel.axis ); - - UI_PositionRotatedEntityOnTag( &barrel, &gun, pi->weaponModel, "tag_barrel"); - - trap_R_AddRefEntityToScene( &barrel ); - } - - // - // add muzzle flash - // - if ( dp_realtime <= pi->muzzleFlashTime ) { - if ( pi->flashModel ) { - memset( &flash, 0, sizeof(flash) ); - flash.hModel = pi->flashModel; - VectorCopy( origin, flash.lightingOrigin ); - UI_PositionEntityOnTag( &flash, &gun, pi->weaponModel, "tag_flash"); - flash.renderfx = renderfx; - trap_R_AddRefEntityToScene( &flash ); - } - - // make a dlight for the flash - if ( pi->flashDlightColor[0] || pi->flashDlightColor[1] || pi->flashDlightColor[2] ) { - trap_R_AddLightToScene( flash.origin, 200 + (rand()&31), pi->flashDlightColor[0], - pi->flashDlightColor[1], pi->flashDlightColor[2] ); - } - } - - // - // add the chat icon - // - if ( pi->chat ) { - UI_PlayerFloatSprite( pi, origin, trap_R_RegisterShaderNoMip( "sprites/balloon3" ) ); - } - - // - // add an accent light - // - origin[0] -= 100; // + = behind, - = in front - origin[1] += 100; // + = left, - = right - origin[2] += 100; // + = above, - = below - trap_R_AddLightToScene( origin, 500, 1.0, 1.0, 1.0 ); - - origin[0] -= 100; - origin[1] -= 100; - origin[2] -= 100; - trap_R_AddLightToScene( origin, 500, 1.0, 0.0, 0.0 ); - - trap_R_RenderScene( &refdef ); + // this allows the ui to cache the player model on the main menu + if (w == 0 || h == 0) { + return; + } + + dp_realtime = time; + + if ( pi->pendingWeapon != -1 && dp_realtime > pi->weaponTimer ) { + pi->weapon = pi->pendingWeapon; + pi->lastWeapon = pi->pendingWeapon; + pi->pendingWeapon = -1; + pi->weaponTimer = 0; + if( pi->currentWeapon != pi->weapon ) { + trap_S_StartLocalSound( weaponChangeSound, CHAN_LOCAL ); + } + } + + UI_AdjustFrom640( &x, &y, &w, &h ); + + y -= jumpHeight; + + memset( &refdef, 0, sizeof( refdef ) ); + memset( &legs, 0, sizeof(legs) ); + memset( &torso, 0, sizeof(torso) ); + memset( &head, 0, sizeof(head) ); + + refdef.rdflags = RDF_NOWORLDMODEL; + + AxisClear( refdef.viewaxis ); + + refdef.x = x; + refdef.y = y; + refdef.width = w; + refdef.height = h; + + refdef.fov_x = (int)((float)refdef.width / 640.0f * 90.0f); + xx = refdef.width / tan( refdef.fov_x / 360 * M_PI ); + refdef.fov_y = atan2( refdef.height, xx ); + refdef.fov_y *= ( 360 / (float)M_PI ); + + // calculate distance so the player nearly fills the box + len = 0.7 * ( maxs[2] - mins[2] ); + origin[0] = len / tan( DEG2RAD(refdef.fov_x) * 0.5 ); + origin[1] = 0.5 * ( mins[1] + maxs[1] ); + origin[2] = -0.5 * ( mins[2] + maxs[2] ); + + refdef.time = dp_realtime; + + trap_R_ClearScene(); + + // get the rotation information + UI_PlayerAngles( pi, legs.axis, torso.axis, head.axis ); + + // get the animation state (after rotation, to allow feet shuffle) + UI_PlayerAnimation( pi, &legs.oldframe, &legs.frame, &legs.backlerp, + &torso.oldframe, &torso.frame, &torso.backlerp ); + + renderfx = RF_LIGHTING_ORIGIN | RF_NOSHADOW; + + // + // add the legs + // + legs.hModel = pi->legsModel; + legs.customSkin = pi->legsSkin; + + VectorCopy( origin, legs.origin ); + + VectorCopy( origin, legs.lightingOrigin ); + legs.renderfx = renderfx; + VectorCopy (legs.origin, legs.oldorigin); + + trap_R_AddRefEntityToScene( &legs ); + + if (!legs.hModel) { + return; + } + + // + // add the torso + // + torso.hModel = pi->torsoModel; + if (!torso.hModel) { + return; + } + + torso.customSkin = pi->torsoSkin; + + VectorCopy( origin, torso.lightingOrigin ); + + UI_PositionRotatedEntityOnTag( &torso, &legs, pi->legsModel, "tag_torso"); + + torso.renderfx = renderfx; + + trap_R_AddRefEntityToScene( &torso ); + + // + // add the head + // + head.hModel = pi->headModel; + if (!head.hModel) { + return; + } + head.customSkin = pi->headSkin; + + VectorCopy( origin, head.lightingOrigin ); + + UI_PositionRotatedEntityOnTag( &head, &torso, pi->torsoModel, "tag_head"); + + head.renderfx = renderfx; + + trap_R_AddRefEntityToScene( &head ); + + // + // add the gun + // + if ( pi->currentWeapon != WP_NONE ) { + memset( &gun, 0, sizeof(gun) ); + gun.hModel = pi->weaponModel; + VectorCopy( origin, gun.lightingOrigin ); + UI_PositionEntityOnTag( &gun, &torso, pi->torsoModel, "tag_weapon"); + gun.renderfx = renderfx; + trap_R_AddRefEntityToScene( &gun ); + } + + // + // add the spinning barrel + // + if ( pi->realWeapon == WP_MACHINEGUN ) { + vec3_t angles; + + memset( &barrel, 0, sizeof(barrel) ); + VectorCopy( origin, barrel.lightingOrigin ); + barrel.renderfx = renderfx; + + barrel.hModel = pi->barrelModel; + angles[YAW] = 0; + angles[PITCH] = 0; + angles[ROLL] = UI_MachinegunSpinAngle( pi ); +/* if( pi->realWeapon == WP_GAUNTLET || pi->realWeapon == WP_BFG ) { + angles[PITCH] = angles[ROLL]; + angles[ROLL] = 0; + }*/ + AnglesToAxis( angles, barrel.axis ); + + UI_PositionRotatedEntityOnTag( &barrel, &gun, pi->weaponModel, "tag_barrel"); + + trap_R_AddRefEntityToScene( &barrel ); + } + + // + // add muzzle flash + // + if ( dp_realtime <= pi->muzzleFlashTime ) { + if ( pi->flashModel ) { + memset( &flash, 0, sizeof(flash) ); + flash.hModel = pi->flashModel; + VectorCopy( origin, flash.lightingOrigin ); + UI_PositionEntityOnTag( &flash, &gun, pi->weaponModel, "tag_flash"); + flash.renderfx = renderfx; + trap_R_AddRefEntityToScene( &flash ); + } + + // make a dlight for the flash + if ( pi->flashDlightColor[0] || pi->flashDlightColor[1] || pi->flashDlightColor[2] ) { + trap_R_AddLightToScene( flash.origin, 200 + (rand()&31), pi->flashDlightColor[0], + pi->flashDlightColor[1], pi->flashDlightColor[2] ); + } + } + + // + // add the chat icon + // + if ( pi->chat ) { + UI_PlayerFloatSprite( pi, origin, trap_R_RegisterShaderNoMip( "sprites/balloon3" ) ); + } + + // + // add an accent light + // + origin[0] -= 100; // + = behind, - = in front + origin[1] += 100; // + = left, - = right + origin[2] += 100; // + = above, - = below + trap_R_AddLightToScene( origin, 500, 1.0, 1.0, 1.0 ); + + origin[0] -= 100; + origin[1] -= 100; + origin[2] -= 100; + trap_R_AddLightToScene( origin, 500, 1.0, 0.0, 0.0 ); + + trap_R_RenderScene( &refdef ); } /* @@ -887,14 +887,14 @@ void UI_DrawPlayer( float x, float y, float w, float h, playerInfo_t *pi, int ti UI_FileExists ========================== */ -static qboolean UI_FileExists(const char *filename) { - int len; - - len = trap_FS_FOpenFile( filename, 0, FS_READ ); - if (len>0) { - return qtrue; - } - return qfalse; +static qboolean UI_FileExists(const char *filename) { + int len; + + len = trap_FS_FOpenFile( filename, 0, FS_READ ); + if (len>0) { + return qtrue; + } + return qfalse; } /* @@ -902,51 +902,51 @@ static qboolean UI_FileExists(const char *filename) { UI_FindClientHeadFile ========================== */ -static qboolean UI_FindClientHeadFile( char *filename, int length, const char *teamName, const char *headModelName, const char *headSkinName, const char *base, const char *ext ) { - char *team, *headsFolder; - int i; - - team = "default"; - - if ( headModelName[0] == '*' ) { - headsFolder = "heads/"; - headModelName++; - } - else { - headsFolder = ""; - } - while(1) { - for ( i = 0; i < 2; i++ ) { - if ( i == 0 && teamName && *teamName ) { - Com_sprintf( filename, length, "models/players/%s%s/%s/%s%s_%s.%s", headsFolder, headModelName, headSkinName, teamName, base, team, ext ); - } - else { - Com_sprintf( filename, length, "models/players/%s%s/%s/%s_%s.%s", headsFolder, headModelName, headSkinName, base, team, ext ); - } - if ( UI_FileExists( filename ) ) { - return qtrue; - } - if ( i == 0 && teamName && *teamName ) { - Com_sprintf( filename, length, "models/players/%s%s/%s%s_%s.%s", headsFolder, headModelName, teamName, base, headSkinName, ext ); - } - else { - Com_sprintf( filename, length, "models/players/%s%s/%s_%s.%s", headsFolder, headModelName, base, headSkinName, ext ); - } - if ( UI_FileExists( filename ) ) { - return qtrue; - } - if ( !teamName || !*teamName ) { - break; - } - } - // if tried the heads folder first - if ( headsFolder[0] ) { - break; - } - headsFolder = "heads/"; - } - - return qfalse; +static qboolean UI_FindClientHeadFile( char *filename, int length, const char *teamName, const char *headModelName, const char *headSkinName, const char *base, const char *ext ) { + char *team, *headsFolder; + int i; + + team = "default"; + + if ( headModelName[0] == '*' ) { + headsFolder = "heads/"; + headModelName++; + } + else { + headsFolder = ""; + } + while(1) { + for ( i = 0; i < 2; i++ ) { + if ( i == 0 && teamName && *teamName ) { + Com_sprintf( filename, length, "models/players/%s%s/%s/%s%s_%s.%s", headsFolder, headModelName, headSkinName, teamName, base, team, ext ); + } + else { + Com_sprintf( filename, length, "models/players/%s%s/%s/%s_%s.%s", headsFolder, headModelName, headSkinName, base, team, ext ); + } + if ( UI_FileExists( filename ) ) { + return qtrue; + } + if ( i == 0 && teamName && *teamName ) { + Com_sprintf( filename, length, "models/players/%s%s/%s%s_%s.%s", headsFolder, headModelName, teamName, base, headSkinName, ext ); + } + else { + Com_sprintf( filename, length, "models/players/%s%s/%s_%s.%s", headsFolder, headModelName, base, headSkinName, ext ); + } + if ( UI_FileExists( filename ) ) { + return qtrue; + } + if ( !teamName || !*teamName ) { + break; + } + } + // if tried the heads folder first + if ( headsFolder[0] ) { + break; + } + headsFolder = "heads/"; + } + + return qfalse; } /* @@ -954,48 +954,48 @@ static qboolean UI_FindClientHeadFile( char *filename, int length, const char *t UI_RegisterClientSkin ========================== */ -static qboolean UI_RegisterClientSkin( playerInfo_t *pi, const char *modelName, const char *skinName, const char *headModelName, const char *headSkinName , const char *teamName) { - char filename[MAX_QPATH*2]; - - if (teamName && *teamName) { - Com_sprintf( filename, sizeof( filename ), "models/players/%s/%s/lower_%s.skin", modelName, teamName, skinName ); - } else { - Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower_%s.skin", modelName, skinName ); - } - pi->legsSkin = trap_R_RegisterSkin( filename ); - if (!pi->legsSkin) { - if (teamName && *teamName) { - Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/%s/lower_%s.skin", modelName, teamName, skinName ); - } else { - Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/lower_%s.skin", modelName, skinName ); - } - pi->legsSkin = trap_R_RegisterSkin( filename ); - } - - if (teamName && *teamName) { - Com_sprintf( filename, sizeof( filename ), "models/players/%s/%s/upper_%s.skin", modelName, teamName, skinName ); - } else { - Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper_%s.skin", modelName, skinName ); - } - pi->torsoSkin = trap_R_RegisterSkin( filename ); - if (!pi->torsoSkin) { - if (teamName && *teamName) { - Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/%s/upper_%s.skin", modelName, teamName, skinName ); - } else { - Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/upper_%s.skin", modelName, skinName ); - } - pi->torsoSkin = trap_R_RegisterSkin( filename ); - } - - if ( UI_FindClientHeadFile( filename, sizeof(filename), teamName, headModelName, headSkinName, "head", "skin" ) ) { - pi->headSkin = trap_R_RegisterSkin( filename ); - } - - if ( !pi->legsSkin || !pi->torsoSkin || !pi->headSkin ) { - return qfalse; - } - - return qtrue; +static qboolean UI_RegisterClientSkin( playerInfo_t *pi, const char *modelName, const char *skinName, const char *headModelName, const char *headSkinName , const char *teamName) { + char filename[MAX_QPATH*2]; + + if (teamName && *teamName) { + Com_sprintf( filename, sizeof( filename ), "models/players/%s/%s/lower_%s.skin", modelName, teamName, skinName ); + } else { + Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower_%s.skin", modelName, skinName ); + } + pi->legsSkin = trap_R_RegisterSkin( filename ); + if (!pi->legsSkin) { + if (teamName && *teamName) { + Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/%s/lower_%s.skin", modelName, teamName, skinName ); + } else { + Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/lower_%s.skin", modelName, skinName ); + } + pi->legsSkin = trap_R_RegisterSkin( filename ); + } + + if (teamName && *teamName) { + Com_sprintf( filename, sizeof( filename ), "models/players/%s/%s/upper_%s.skin", modelName, teamName, skinName ); + } else { + Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper_%s.skin", modelName, skinName ); + } + pi->torsoSkin = trap_R_RegisterSkin( filename ); + if (!pi->torsoSkin) { + if (teamName && *teamName) { + Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/%s/upper_%s.skin", modelName, teamName, skinName ); + } else { + Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/upper_%s.skin", modelName, skinName ); + } + pi->torsoSkin = trap_R_RegisterSkin( filename ); + } + + if ( UI_FindClientHeadFile( filename, sizeof(filename), teamName, headModelName, headSkinName, "head", "skin" ) ) { + pi->headSkin = trap_R_RegisterSkin( filename ); + } + + if ( !pi->legsSkin || !pi->torsoSkin || !pi->headSkin ) { + return qfalse; + } + + return qtrue; } @@ -1005,120 +1005,120 @@ UI_ParseAnimationFile ====================== */ static qboolean UI_ParseAnimationFile( const char *filename, animation_t *animations ) { - char *text_p, *prev; - int len; - int i; - char *token; - float fps; - int skip; - char text[20000]; - fileHandle_t f; - - memset( animations, 0, sizeof( animation_t ) * MAX_PLAYER_ANIMATIONS ); - - // load the file - len = trap_FS_FOpenFile( filename, &f, FS_READ ); - if ( len <= 0 ) { - return qfalse; - } - if ( len >= ( sizeof( text ) - 1 ) ) { - Com_Printf( "File %s too long\n", filename ); - return qfalse; - } - trap_FS_Read( text, len, f ); - text[len] = 0; - trap_FS_FCloseFile( f ); - - COM_Compress(text); - - // parse the text - text_p = text; - skip = 0; // quite the compiler warning - - // read optional parameters - while ( 1 ) { - prev = text_p; // so we can unget - token = COM_Parse( &text_p ); - if ( !token ) { - break; - } - if ( !Q_stricmp( token, "footsteps" ) ) { - token = COM_Parse( &text_p ); - if ( !token ) { - break; - } - continue; - } else if ( !Q_stricmp( token, "headoffset" ) ) { - for ( i = 0 ; i < 3 ; i++ ) { - token = COM_Parse( &text_p ); - if ( !token ) { - break; - } - } - continue; - } else if ( !Q_stricmp( token, "sex" ) ) { - token = COM_Parse( &text_p ); - if ( !token ) { - break; - } - continue; - } - - // if it is a number, start parsing animations - if ( token[0] >= '0' && token[0] <= '9' ) { - text_p = prev; // unget the token - break; - } - - Com_Printf( "unknown token '%s' is %s\n", token, filename ); - } - - // read information for each frame - for ( i = 0 ; i < MAX_PLAYER_ANIMATIONS ; i++ ) { - - token = COM_Parse( &text_p ); - if ( !token ) { - 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; - } - if ( i >= LEGS_WALKCR ) { - animations[i].firstFrame -= skip; - } - - token = COM_Parse( &text_p ); - if ( !token ) { - break; - } - animations[i].numFrames = atoi( token ); - - 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; - } - - if ( i != MAX_PLAYER_ANIMATIONS ) { - Com_Printf( "Error parsing animation file: %s", filename ); - return qfalse; - } - - return qtrue; + char *text_p, *prev; + int len; + int i; + char *token; + float fps; + int skip; + char text[20000]; + fileHandle_t f; + + memset( animations, 0, sizeof( animation_t ) * MAX_PLAYER_ANIMATIONS ); + + // load the file + len = trap_FS_FOpenFile( filename, &f, FS_READ ); + if ( len <= 0 ) { + return qfalse; + } + if ( len >= ( sizeof( text ) - 1 ) ) { + Com_Printf( "File %s too long\n", filename ); + return qfalse; + } + trap_FS_Read( text, len, f ); + text[len] = 0; + trap_FS_FCloseFile( f ); + + COM_Compress(text); + + // parse the text + text_p = text; + skip = 0; // quite the compiler warning + + // read optional parameters + while ( 1 ) { + prev = text_p; // so we can unget + token = COM_Parse( &text_p ); + if ( !token ) { + break; + } + if ( !Q_stricmp( token, "footsteps" ) ) { + token = COM_Parse( &text_p ); + if ( !token ) { + break; + } + continue; + } else if ( !Q_stricmp( token, "headoffset" ) ) { + for ( i = 0 ; i < 3 ; i++ ) { + token = COM_Parse( &text_p ); + if ( !token ) { + break; + } + } + continue; + } else if ( !Q_stricmp( token, "sex" ) ) { + token = COM_Parse( &text_p ); + if ( !token ) { + break; + } + continue; + } + + // if it is a number, start parsing animations + if ( token[0] >= '0' && token[0] <= '9' ) { + text_p = prev; // unget the token + break; + } + + Com_Printf( "unknown token '%s' is %s\n", token, filename ); + } + + // read information for each frame + for ( i = 0 ; i < MAX_PLAYER_ANIMATIONS ; i++ ) { + + token = COM_Parse( &text_p ); + if ( !token ) { + 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; + } + if ( i >= LEGS_WALKCR ) { + animations[i].firstFrame -= skip; + } + + token = COM_Parse( &text_p ); + if ( !token ) { + break; + } + animations[i].numFrames = atoi( token ); + + 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; + } + + if ( i != MAX_PLAYER_ANIMATIONS ) { + Com_Printf( "Error parsing animation file: %s", filename ); + return qfalse; + } + + return qtrue; } /* @@ -1127,101 +1127,101 @@ UI_RegisterClientModelname ========================== */ qboolean UI_RegisterClientModelname( playerInfo_t *pi, const char *modelSkinName, const char *headModelSkinName, const char *teamName ) { - char modelName[MAX_QPATH]; - char skinName[MAX_QPATH]; - char headModelName[MAX_QPATH]; - char headSkinName[MAX_QPATH]; - char filename[MAX_QPATH]; - char *slash; - - pi->torsoModel = 0; - pi->headModel = 0; - - if ( !modelSkinName[0] ) { - return qfalse; - } - - Q_strncpyz( modelName, modelSkinName, sizeof( modelName ) ); - - slash = strchr( modelName, '/' ); - if ( !slash ) { - // modelName did not include a skin name - Q_strncpyz( skinName, "default", sizeof( skinName ) ); - } else { - Q_strncpyz( skinName, slash + 1, sizeof( skinName ) ); - *slash = '\0'; - } - - Q_strncpyz( headModelName, headModelSkinName, sizeof( headModelName ) ); - slash = strchr( headModelName, '/' ); - if ( !slash ) { - // modelName did not include a skin name - Q_strncpyz( headSkinName, "default", sizeof( skinName ) ); - } else { - Q_strncpyz( headSkinName, slash + 1, sizeof( skinName ) ); - *slash = '\0'; - } - - // load cmodels before models so filecache works - - Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", modelName ); - pi->legsModel = trap_R_RegisterModel( filename ); - if ( !pi->legsModel ) { - Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/lower.md3", modelName ); - pi->legsModel = trap_R_RegisterModel( filename ); - if ( !pi->legsModel ) { - Com_Printf( "Failed to load model file %s\n", filename ); - return qfalse; - } - } - - Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", modelName ); - pi->torsoModel = trap_R_RegisterModel( filename ); - if ( !pi->torsoModel ) { - Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/upper.md3", modelName ); - pi->torsoModel = trap_R_RegisterModel( filename ); - if ( !pi->torsoModel ) { - Com_Printf( "Failed to load model file %s\n", filename ); - return qfalse; - } - } - - if (headModelName && headModelName[0] == '*' ) { - Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", &headModelName[1], &headModelName[1] ); - } - else { - Com_sprintf( filename, sizeof( filename ), "models/players/%s/head.md3", headModelName ); - } - pi->headModel = trap_R_RegisterModel( filename ); - if ( !pi->headModel && headModelName[0] != '*') { - Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", headModelName, headModelName ); - pi->headModel = trap_R_RegisterModel( filename ); - } - - if (!pi->headModel) { - Com_Printf( "Failed to load model file %s\n", filename ); - return qfalse; - } - - // if any skins failed to load, fall back to default - if ( !UI_RegisterClientSkin( pi, modelName, skinName, headModelName, headSkinName, teamName) ) { - if ( !UI_RegisterClientSkin( pi, modelName, "default", headModelName, "default", teamName ) ) { - Com_Printf( "Failed to load skin file: %s : %s\n", modelName, skinName ); - return qfalse; - } - } - - // load the animations - Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg", modelName ); - if ( !UI_ParseAnimationFile( filename, pi->animations ) ) { - Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/animation.cfg", modelName ); - if ( !UI_ParseAnimationFile( filename, pi->animations ) ) { - Com_Printf( "Failed to load animation file %s\n", filename ); - return qfalse; - } - } - - return qtrue; + char modelName[MAX_QPATH]; + char skinName[MAX_QPATH]; + char headModelName[MAX_QPATH]; + char headSkinName[MAX_QPATH]; + char filename[MAX_QPATH]; + char *slash; + + pi->torsoModel = 0; + pi->headModel = 0; + + if ( !modelSkinName[0] ) { + return qfalse; + } + + Q_strncpyz( modelName, modelSkinName, sizeof( modelName ) ); + + slash = strchr( modelName, '/' ); + if ( !slash ) { + // modelName did not include a skin name + Q_strncpyz( skinName, "default", sizeof( skinName ) ); + } else { + Q_strncpyz( skinName, slash + 1, sizeof( skinName ) ); + *slash = '\0'; + } + + Q_strncpyz( headModelName, headModelSkinName, sizeof( headModelName ) ); + slash = strchr( headModelName, '/' ); + if ( !slash ) { + // modelName did not include a skin name + Q_strncpyz( headSkinName, "default", sizeof( skinName ) ); + } else { + Q_strncpyz( headSkinName, slash + 1, sizeof( skinName ) ); + *slash = '\0'; + } + + // load cmodels before models so filecache works + + Com_sprintf( filename, sizeof( filename ), "models/players/%s/lower.md3", modelName ); + pi->legsModel = trap_R_RegisterModel( filename ); + if ( !pi->legsModel ) { + Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/lower.md3", modelName ); + pi->legsModel = trap_R_RegisterModel( filename ); + if ( !pi->legsModel ) { + Com_Printf( "Failed to load model file %s\n", filename ); + return qfalse; + } + } + + Com_sprintf( filename, sizeof( filename ), "models/players/%s/upper.md3", modelName ); + pi->torsoModel = trap_R_RegisterModel( filename ); + if ( !pi->torsoModel ) { + Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/upper.md3", modelName ); + pi->torsoModel = trap_R_RegisterModel( filename ); + if ( !pi->torsoModel ) { + Com_Printf( "Failed to load model file %s\n", filename ); + return qfalse; + } + } + + if (headModelName && headModelName[0] == '*' ) { + Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", &headModelName[1], &headModelName[1] ); + } + else { + Com_sprintf( filename, sizeof( filename ), "models/players/%s/head.md3", headModelName ); + } + pi->headModel = trap_R_RegisterModel( filename ); + if ( !pi->headModel && headModelName[0] != '*') { + Com_sprintf( filename, sizeof( filename ), "models/players/heads/%s/%s.md3", headModelName, headModelName ); + pi->headModel = trap_R_RegisterModel( filename ); + } + + if (!pi->headModel) { + Com_Printf( "Failed to load model file %s\n", filename ); + return qfalse; + } + + // if any skins failed to load, fall back to default + if ( !UI_RegisterClientSkin( pi, modelName, skinName, headModelName, headSkinName, teamName) ) { + if ( !UI_RegisterClientSkin( pi, modelName, "default", headModelName, "default", teamName ) ) { + Com_Printf( "Failed to load skin file: %s : %s\n", modelName, skinName ); + return qfalse; + } + } + + // load the animations + Com_sprintf( filename, sizeof( filename ), "models/players/%s/animation.cfg", modelName ); + if ( !UI_ParseAnimationFile( filename, pi->animations ) ) { + Com_sprintf( filename, sizeof( filename ), "models/players/characters/%s/animation.cfg", modelName ); + if ( !UI_ParseAnimationFile( filename, pi->animations ) ) { + Com_Printf( "Failed to load animation file %s\n", filename ); + return qfalse; + } + } + + return qtrue; } @@ -1231,16 +1231,16 @@ UI_PlayerInfo_SetModel =============== */ void UI_PlayerInfo_SetModel( playerInfo_t *pi, const char *model, const char *headmodel, char *teamName ) { - memset( pi, 0, sizeof(*pi) ); - UI_RegisterClientModelname( pi, model, headmodel, teamName ); - pi->weapon = WP_MACHINEGUN; - pi->currentWeapon = pi->weapon; - pi->lastWeapon = pi->weapon; - pi->pendingWeapon = -1; - pi->weaponTimer = 0; - pi->chat = qfalse; - pi->newModel = qtrue; - UI_PlayerInfo_SetWeapon( pi, pi->weapon ); + memset( pi, 0, sizeof(*pi) ); + UI_RegisterClientModelname( pi, model, headmodel, teamName ); + pi->weapon = WP_MACHINEGUN; + pi->currentWeapon = pi->weapon; + pi->lastWeapon = pi->weapon; + pi->pendingWeapon = -1; + pi->weaponTimer = 0; + pi->chat = qfalse; + pi->newModel = qtrue; + UI_PlayerInfo_SetWeapon( pi, pi->weapon ); } @@ -1250,112 +1250,112 @@ UI_PlayerInfo_SetInfo =============== */ void UI_PlayerInfo_SetInfo( playerInfo_t *pi, int legsAnim, int torsoAnim, vec3_t viewAngles, vec3_t moveAngles, weapon_t weaponNumber, qboolean chat ) { - int currentAnim; - weapon_t weaponNum; - - pi->chat = chat; - - // view angles - VectorCopy( viewAngles, pi->viewAngles ); - - // move angles - VectorCopy( moveAngles, pi->moveAngles ); - - if ( pi->newModel ) { - pi->newModel = qfalse; - - jumpHeight = 0; - pi->pendingLegsAnim = 0; - UI_ForceLegsAnim( pi, legsAnim ); - pi->legs.yawAngle = viewAngles[YAW]; - pi->legs.yawing = qfalse; - - pi->pendingTorsoAnim = 0; - UI_ForceTorsoAnim( pi, torsoAnim ); - pi->torso.yawAngle = viewAngles[YAW]; - pi->torso.yawing = qfalse; - - if ( weaponNumber != -1 ) { - pi->weapon = weaponNumber; - pi->currentWeapon = weaponNumber; - pi->lastWeapon = weaponNumber; - pi->pendingWeapon = -1; - pi->weaponTimer = 0; - UI_PlayerInfo_SetWeapon( pi, pi->weapon ); - } - - return; - } - - // weapon - if ( weaponNumber == -1 ) { - pi->pendingWeapon = -1; - pi->weaponTimer = 0; - } - else if ( weaponNumber != WP_NONE ) { - pi->pendingWeapon = weaponNumber; - pi->weaponTimer = dp_realtime + UI_TIMER_WEAPON_DELAY; - } - weaponNum = pi->lastWeapon; - pi->weapon = weaponNum; - - if ( torsoAnim == BOTH_DEATH1 || legsAnim == BOTH_DEATH1 ) { - torsoAnim = legsAnim = BOTH_DEATH1; - pi->weapon = pi->currentWeapon = WP_NONE; - UI_PlayerInfo_SetWeapon( pi, pi->weapon ); - - jumpHeight = 0; - pi->pendingLegsAnim = 0; - UI_ForceLegsAnim( pi, legsAnim ); - - pi->pendingTorsoAnim = 0; - UI_ForceTorsoAnim( pi, torsoAnim ); - - return; - } - - // leg animation - currentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT; - if ( legsAnim != LEGS_JUMP && ( currentAnim == LEGS_JUMP || currentAnim == LEGS_LAND ) ) { - pi->pendingLegsAnim = legsAnim; - } - else if ( legsAnim != currentAnim ) { - jumpHeight = 0; - pi->pendingLegsAnim = 0; - UI_ForceLegsAnim( pi, legsAnim ); - } - - // torso animation - if ( torsoAnim == TORSO_STAND || torsoAnim == TORSO_STAND2 ) { - if ( weaponNum == WP_NONE ) { - torsoAnim = TORSO_STAND2; - } - else { - torsoAnim = TORSO_STAND; - } - } - - if ( torsoAnim == TORSO_ATTACK || torsoAnim == TORSO_ATTACK2 ) { - if ( weaponNum == WP_NONE ) { - torsoAnim = TORSO_ATTACK2; - } - else { - torsoAnim = TORSO_ATTACK; - } - pi->muzzleFlashTime = dp_realtime + UI_TIMER_MUZZLE_FLASH; - //FIXME play firing sound here - } - - currentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT; - - if ( weaponNum != pi->currentWeapon || currentAnim == TORSO_RAISE || currentAnim == TORSO_DROP ) { - pi->pendingTorsoAnim = torsoAnim; - } - else if ( ( currentAnim == TORSO_GESTURE || currentAnim == TORSO_ATTACK ) && ( torsoAnim != currentAnim ) ) { - pi->pendingTorsoAnim = torsoAnim; - } - else if ( torsoAnim != currentAnim ) { - pi->pendingTorsoAnim = 0; - UI_ForceTorsoAnim( pi, torsoAnim ); - } + int currentAnim; + weapon_t weaponNum; + + pi->chat = chat; + + // view angles + VectorCopy( viewAngles, pi->viewAngles ); + + // move angles + VectorCopy( moveAngles, pi->moveAngles ); + + if ( pi->newModel ) { + pi->newModel = qfalse; + + jumpHeight = 0; + pi->pendingLegsAnim = 0; + UI_ForceLegsAnim( pi, legsAnim ); + pi->legs.yawAngle = viewAngles[YAW]; + pi->legs.yawing = qfalse; + + pi->pendingTorsoAnim = 0; + UI_ForceTorsoAnim( pi, torsoAnim ); + pi->torso.yawAngle = viewAngles[YAW]; + pi->torso.yawing = qfalse; + + if ( weaponNumber != -1 ) { + pi->weapon = weaponNumber; + pi->currentWeapon = weaponNumber; + pi->lastWeapon = weaponNumber; + pi->pendingWeapon = -1; + pi->weaponTimer = 0; + UI_PlayerInfo_SetWeapon( pi, pi->weapon ); + } + + return; + } + + // weapon + if ( weaponNumber == -1 ) { + pi->pendingWeapon = -1; + pi->weaponTimer = 0; + } + else if ( weaponNumber != WP_NONE ) { + pi->pendingWeapon = weaponNumber; + pi->weaponTimer = dp_realtime + UI_TIMER_WEAPON_DELAY; + } + weaponNum = pi->lastWeapon; + pi->weapon = weaponNum; + + if ( torsoAnim == BOTH_DEATH1 || legsAnim == BOTH_DEATH1 ) { + torsoAnim = legsAnim = BOTH_DEATH1; + pi->weapon = pi->currentWeapon = WP_NONE; + UI_PlayerInfo_SetWeapon( pi, pi->weapon ); + + jumpHeight = 0; + pi->pendingLegsAnim = 0; + UI_ForceLegsAnim( pi, legsAnim ); + + pi->pendingTorsoAnim = 0; + UI_ForceTorsoAnim( pi, torsoAnim ); + + return; + } + + // leg animation + currentAnim = pi->legsAnim & ~ANIM_TOGGLEBIT; + if ( legsAnim != LEGS_JUMP && ( currentAnim == LEGS_JUMP || currentAnim == LEGS_LAND ) ) { + pi->pendingLegsAnim = legsAnim; + } + else if ( legsAnim != currentAnim ) { + jumpHeight = 0; + pi->pendingLegsAnim = 0; + UI_ForceLegsAnim( pi, legsAnim ); + } + + // torso animation + if ( torsoAnim == TORSO_STAND || torsoAnim == TORSO_STAND2 ) { + if ( weaponNum == WP_NONE ) { + torsoAnim = TORSO_STAND2; + } + else { + torsoAnim = TORSO_STAND; + } + } + + if ( torsoAnim == TORSO_ATTACK || torsoAnim == TORSO_ATTACK2 ) { + if ( weaponNum == WP_NONE ) { + torsoAnim = TORSO_ATTACK2; + } + else { + torsoAnim = TORSO_ATTACK; + } + pi->muzzleFlashTime = dp_realtime + UI_TIMER_MUZZLE_FLASH; + //FIXME play firing sound here + } + + currentAnim = pi->torsoAnim & ~ANIM_TOGGLEBIT; + + if ( weaponNum != pi->currentWeapon || currentAnim == TORSO_RAISE || currentAnim == TORSO_DROP ) { + pi->pendingTorsoAnim = torsoAnim; + } + else if ( ( currentAnim == TORSO_GESTURE || currentAnim == TORSO_ATTACK ) && ( torsoAnim != currentAnim ) ) { + pi->pendingTorsoAnim = torsoAnim; + } + else if ( torsoAnim != currentAnim ) { + pi->pendingTorsoAnim = 0; + UI_ForceTorsoAnim( pi, torsoAnim ); + } } diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c index 8d019150..38dbfe50 100644 --- a/src/ui/ui_shared.c +++ b/src/ui/ui_shared.c @@ -1,4 +1,4 @@ -// +// // string allocation/managment /* @@ -84,15 +84,15 @@ static int allocPoint, outOfMemory; =============== UI_Alloc =============== -*/ +*/ void *UI_Alloc( int size ) { - char *p; + char *p; if( allocPoint + size > MEM_POOL_SIZE ) { outOfMemory = qtrue; - + if( DC->Print ) DC->Print( "UI_Alloc: Failure. Out of memory!\n" ); //DC->trap_Print(S_COLOR_YELLOW"WARNING: UI Out of Memory!\n"); @@ -242,7 +242,7 @@ void String_Init( ) UI_InitMemory( ); Item_SetupKeywordHash( ); Menu_SetupKeywordHash( ); - + if( DC && DC->getBindingBuf ) Controls_GetConfig( ); } @@ -495,7 +495,7 @@ qboolean PC_String_Parse(int handle, const char **out) { if (!trap_PC_ReadToken(handle, &token)) return qfalse; - + *(out) = String_Alloc(token.string); return qtrue; } @@ -510,9 +510,9 @@ qboolean PC_Script_Parse(int handle, const char **out) { pc_token_t token; memset(script, 0, sizeof(script)); - // scripts start with { and have ; separated command lists.. commands are command, arg.. + // scripts start with { and have ; separated command lists.. commands are command, arg.. // basically we want everything between the { } as it will be interpreted at run time - + if (!trap_PC_ReadToken(handle, &token)) return qfalse; if (Q_stricmp(token.string, "{") != 0) { @@ -539,7 +539,7 @@ qboolean PC_Script_Parse(int handle, const char **out) { } // display, window, menu, item code -// +// /* ================== @@ -555,7 +555,7 @@ void Init_Display( displayContextDef_t *dc ) -// type and style painting +// type and style painting void GradientBar_Paint( rectDef_t *rect, vec4_t color ) { @@ -571,7 +571,7 @@ void GradientBar_Paint( rectDef_t *rect, vec4_t color ) Window_Init Initializes a window structure ( windowDef_t ) with defaults - + ================== */ void Window_Init(Window *w) { @@ -657,7 +657,7 @@ void Window_Paint(Window *w, float fadeAmount, float fadeClamp, float fadeCycle) if (w->cinematic == -1) { w->cinematic = -2; } - } + } if (w->cinematic >= 0) { DC->runCinematicFrame(w->cinematic); DC->drawCinematic(w->cinematic, fillRect.x, fillRect.y, fillRect.w, fillRect.h); @@ -668,7 +668,7 @@ void Window_Paint(Window *w, float fadeAmount, float fadeClamp, float fadeCycle) // full // HACK HACK HACK if (w->style == WINDOW_STYLE_TEAMCOLOR) { - if (color[0] > 0) { + if (color[0] > 0) { // red color[0] = 1; color[1] = color[2] = .5; @@ -705,7 +705,7 @@ void Window_Paint(Window *w, float fadeAmount, float fadeClamp, float fadeCycle) void Item_SetScreenCoords(itemDef_t *item, float x, float y) { - + if (item == NULL) { return; } @@ -729,7 +729,7 @@ void Item_SetScreenCoords(itemDef_t *item, float x, float y) { void Item_UpdatePosition(itemDef_t *item) { float x, y; menuDef_t *menu; - + if (item == NULL || item->parent == NULL) { return; } @@ -738,7 +738,7 @@ void Item_UpdatePosition(itemDef_t *item) { x = menu->window.rect.x; y = menu->window.rect.y; - + if (menu->window.border != 0) { x += menu->window.borderSize; y += menu->window.borderSize; @@ -756,7 +756,7 @@ void Menu_UpdatePosition(menuDef_t *menu) { if (menu == NULL) { return; } - + x = menu->window.rect.x; y = menu->window.rect.y; if (menu->window.border != 0) { @@ -793,13 +793,13 @@ itemDef_t *Menu_ClearFocus(menuDef_t *menu) { for (i = 0; i < menu->itemCount; i++) { if (menu->items[i]->window.flags & WINDOW_HASFOCUS) { ret = menu->items[i]; - } + } menu->items[i]->window.flags &= ~WINDOW_HASFOCUS; if (menu->items[i]->leaveFocus) { Item_RunScript(menu->items[i], menu->items[i]->leaveFocus); } } - + return ret; } @@ -822,7 +822,7 @@ int Menu_ItemsMatchingGroup(menuDef_t *menu, const char *name) { for (i = 0; i < menu->itemCount; i++) { if (Q_stricmp(menu->items[i]->window.name, name) == 0 || (menu->items[i]->window.group && Q_stricmp(menu->items[i]->window.group, name) == 0)) { count++; - } + } } return count; } @@ -836,7 +836,7 @@ itemDef_t *Menu_GetMatchingItemByNumber(menuDef_t *menu, int index, const char * return menu->items[i]; } count++; - } + } } return NULL; } @@ -876,7 +876,7 @@ void Script_SetAsset(itemDef_t *item, char **args) { const char *name; // expecting name to set asset to if (String_Parse(args, &name)) { - // check for a model + // check for a model if (item->type == ITEM_TYPE_MODEL) { } } @@ -1003,7 +1003,7 @@ menuDef_t *Menus_FindByName(const char *p) { for (i = 0; i < menuCount; i++) { if (Q_stricmp(Menus[i].window.name, p) == 0) { return &Menus[i]; - } + } } return NULL; } @@ -1082,19 +1082,19 @@ void Script_Open(itemDef_t *item, char **args) { } void Script_ConditionalOpen(itemDef_t *item, char **args) { - const char *cvar; - const char *name1; - const char *name2; - float val; - - if ( String_Parse(args, &cvar) && String_Parse(args, &name1) && String_Parse(args, &name2) ) { - val = DC->getCVarValue( cvar ); - if ( val == 0.f ) { - Menus_OpenByName(name2); - } else { - Menus_OpenByName(name1); - } - } + const char *cvar; + const char *name1; + const char *name2; + float val; + + if ( String_Parse(args, &cvar) && String_Parse(args, &name1) && String_Parse(args, &name2) ) { + val = DC->getCVarValue( cvar ); + if ( val == 0.f ) { + Menus_OpenByName(name2); + } else { + Menus_OpenByName(name1); + } + } } void Script_Close(itemDef_t *item, char **args) { @@ -1210,7 +1210,7 @@ void Script_SetCvar(itemDef_t *item, char **args) { if (String_Parse(args, &cvar) && String_Parse(args, &val)) { DC->setCVar(cvar, val); } - + } void Script_Exec(itemDef_t *item, char **args) { @@ -1339,7 +1339,7 @@ qboolean Item_EnableShowViaCvar(itemDef_t *item, int flag) { } -// will optionaly set focus to this item +// will optionaly set focus to this item qboolean Item_SetFocus(itemDef_t *item, float x, float y) { int i; itemDef_t *oldFocus; @@ -1352,8 +1352,8 @@ qboolean Item_SetFocus(itemDef_t *item, float x, float y) { } // bk001206 - this can be NULL. - parent = (menuDef_t*)item->parent; - + parent = (menuDef_t*)item->parent; + // items can be enabled and disabled based on cvars if (item->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(item, CVAR_ENABLE)) { return qfalse; @@ -1597,11 +1597,11 @@ int Item_ListBox_OverLB(itemDef_t *item, float x, float y) { } -void Item_ListBox_MouseEnter(itemDef_t *item, float x, float y) +void Item_ListBox_MouseEnter(itemDef_t *item, float x, float y) { rectDef_t r; listBoxDef_t *listPtr = (listBoxDef_t*)item->typeData; - + item->window.flags &= ~(WINDOW_LB_LEFTARROW | WINDOW_LB_RIGHTARROW | WINDOW_LB_THUMB | WINDOW_LB_PGUP | WINDOW_LB_PGDN); item->window.flags |= Item_ListBox_OverLB(item, x, y); @@ -1620,7 +1620,7 @@ void Item_ListBox_MouseEnter(itemDef_t *item, float x, float y) } } } else { - // text hit.. + // text hit.. } } } else if (!(item->window.flags & (WINDOW_LB_LEFTARROW | WINDOW_LB_RIGHTARROW | WINDOW_LB_THUMB | WINDOW_LB_PGUP | WINDOW_LB_PGDN))) { @@ -1730,7 +1730,7 @@ qboolean Item_ListBox_HandleKey(itemDef_t *item, int key, qboolean down, qboolea max = Item_ListBox_MaxScroll(item); if (item->window.flags & WINDOW_HORIZONTAL) { viewmax = (item->window.rect.w / listPtr->elementWidth); - if ( key == K_LEFTARROW || key == K_KP_LEFTARROW ) + if ( key == K_LEFTARROW || key == K_KP_LEFTARROW ) { if (!listPtr->notselectable) { listPtr->cursorPos--; @@ -1753,7 +1753,7 @@ qboolean Item_ListBox_HandleKey(itemDef_t *item, int key, qboolean down, qboolea } return qtrue; } - if ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW ) + if ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW ) { if (!listPtr->notselectable) { listPtr->cursorPos++; @@ -1779,7 +1779,7 @@ qboolean Item_ListBox_HandleKey(itemDef_t *item, int key, qboolean down, qboolea } else { viewmax = (item->window.rect.h / listPtr->elementHeight); - if ( key == K_UPARROW || key == K_KP_UPARROW ) + if ( key == K_UPARROW || key == K_KP_UPARROW ) { if (!listPtr->notselectable) { listPtr->cursorPos--; @@ -1802,7 +1802,7 @@ qboolean Item_ListBox_HandleKey(itemDef_t *item, int key, qboolean down, qboolea } return qtrue; } - if ( key == K_DOWNARROW || key == K_KP_DOWNARROW ) + if ( key == K_DOWNARROW || key == K_KP_DOWNARROW ) { if (!listPtr->notselectable) { listPtr->cursorPos++; @@ -1875,7 +1875,7 @@ qboolean Item_ListBox_HandleKey(itemDef_t *item, int key, qboolean down, qboolea return qtrue; } - + if ( key == K_HOME || key == K_KP_HOME) { // home listPtr->startPos = 0; @@ -2115,7 +2115,7 @@ qboolean Item_TextField_HandleKey(itemDef_t *item, int key) { return qtrue; } - if ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW ) + if ( key == K_RIGHTARROW || key == K_KP_RIGHTARROW ) { if (editPtr->maxPaintChars && item->cursorPos >= editPtr->maxPaintChars && item->cursorPos < len) { item->cursorPos++; @@ -2124,11 +2124,11 @@ qboolean Item_TextField_HandleKey(itemDef_t *item, int key) { } if (item->cursorPos < len) { item->cursorPos++; - } + } return qtrue; } - if ( key == K_LEFTARROW || key == K_KP_LEFTARROW ) + if ( key == K_LEFTARROW || key == K_KP_LEFTARROW ) { if ( item->cursorPos > 0 ) { item->cursorPos--; @@ -2185,12 +2185,12 @@ qboolean Item_TextField_HandleKey(itemDef_t *item, int key) { static void Scroll_ListBox_AutoFunc(void *p) { scrollInfo_t *si = (scrollInfo_t*)p; - if (DC->realTime > si->nextScrollTime) { + if (DC->realTime > si->nextScrollTime) { // need to scroll which is done by simulating a click to the item // this is done a bit sideways as the autoscroll "knows" that the item is a listbox // so it calls it directly Item_ListBox_HandleKey(si->item, si->scrollKey, qtrue, qfalse); - si->nextScrollTime = DC->realTime + si->adjustValue; + si->nextScrollTime = DC->realTime + si->adjustValue; } if (DC->realTime > si->nextAdjustTime) { @@ -2246,12 +2246,12 @@ static void Scroll_ListBox_ThumbFunc(void *p) { si->yStart = DC->cursory; } - if (DC->realTime > si->nextScrollTime) { + if (DC->realTime > si->nextScrollTime) { // need to scroll which is done by simulating a click to the item // this is done a bit sideways as the autoscroll "knows" that the item is a listbox // so it calls it directly Item_ListBox_HandleKey(si->item, si->scrollKey, qtrue, qfalse); - si->nextScrollTime = DC->realTime + si->adjustValue; + si->nextScrollTime = DC->realTime + si->adjustValue; } if (DC->realTime > si->nextAdjustTime) { @@ -2453,14 +2453,14 @@ void Item_Action(itemDef_t *item) { itemDef_t *Menu_SetPrevCursorItem(menuDef_t *menu) { qboolean wrapped = qfalse; int oldCursor = menu->cursorItem; - + if (menu->cursorItem < 0) { menu->cursorItem = menu->itemCount-1; wrapped = qtrue; - } + } while (menu->cursorItem > -1) { - + menu->cursorItem--; if (menu->cursorItem < 0 && !wrapped) { wrapped = qtrue; @@ -2499,7 +2499,7 @@ itemDef_t *Menu_SetNextCursorItem(menuDef_t *menu) { Menu_HandleMouseMove(menu, menu->items[menu->cursorItem]->window.rect.x + 1, menu->items[menu->cursorItem]->window.rect.y + 1); return menu->items[menu->cursorItem]; } - + } menu->cursorItem = oldCursor; @@ -2564,9 +2564,9 @@ int Display_VisibleMenuCount() { void Menus_HandleOOBClick(menuDef_t *menu, int key, qboolean down) { if (menu) { int i; - // basically the behaviour we are looking for is if there are windows in the stack.. see if - // the cursor is within any of them.. if not close them otherwise activate them and pass the - // key on.. force a mouse move to activate focus and script stuff + // basically the behaviour we are looking for is if there are windows in the stack.. see if + // the cursor is within any of them.. if not close them otherwise activate them and pass the + // key on.. force a mouse move to activate focus and script stuff if (down && menu->window.flags & WINDOW_OOB_CLICK) { Menu_RunCloseScript(menu); menu->window.flags &= ~(WINDOW_HASFOCUS | WINDOW_VISIBLE); @@ -2768,7 +2768,7 @@ void ToWindowCoords(float *x, float *y, windowDef_t *window) { if (window->border != 0) { *x += window->borderSize; *y += window->borderSize; - } + } *x += window->rect.x; *y += window->rect.y; } @@ -2822,18 +2822,18 @@ void Item_TextColor(itemDef_t *item, vec4_t *newColor) { Fade(&item->window.flags, &item->window.foreColor[3], parent->fadeClamp, &item->window.nextTime, parent->fadeCycle, qtrue, parent->fadeAmount); if (item->window.flags & WINDOW_HASFOCUS) { -/* lowLight[0] = 0.8 * parent->focusColor[0]; - lowLight[1] = 0.8 * parent->focusColor[1]; - lowLight[2] = 0.8 * parent->focusColor[2]; - lowLight[3] = 0.8 * parent->focusColor[3]; +/* lowLight[0] = 0.8 * parent->focusColor[0]; + lowLight[1] = 0.8 * parent->focusColor[1]; + lowLight[2] = 0.8 * parent->focusColor[2]; + lowLight[3] = 0.8 * parent->focusColor[3]; LerpColor(parent->focusColor,lowLight,*newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));*/ //TA: memcpy(newColor, &parent->focusColor, sizeof(vec4_t)); } else if (item->textStyle == ITEM_TEXTSTYLE_BLINK && !((DC->realTime/BLINK_DIVISOR) & 1)) { - lowLight[0] = 0.8 * item->window.foreColor[0]; - lowLight[1] = 0.8 * item->window.foreColor[1]; - lowLight[2] = 0.8 * item->window.foreColor[2]; - lowLight[3] = 0.8 * item->window.foreColor[3]; + lowLight[0] = 0.8 * item->window.foreColor[0]; + lowLight[1] = 0.8 * item->window.foreColor[1]; + lowLight[2] = 0.8 * item->window.foreColor[2]; + lowLight[3] = 0.8 * item->window.foreColor[3]; LerpColor(item->window.foreColor,lowLight,*newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR)); } else { memcpy(newColor, &item->window.foreColor, sizeof(vec4_t)); @@ -2878,11 +2878,11 @@ int Item_Text_AutoWrapped_Lines( itemDef_t *item ) buff[ 0 ] = '\0'; newLine = 0; p = textPtr; - + while( p ) { textWidth = DC->textWidth( buff, item->textscale, 0 ); - + if( *p == ' ' || *p == '\t' || *p == '\n' || *p == '\0' ) { newLine = len; @@ -2900,10 +2900,10 @@ int Item_Text_AutoWrapped_Lines( itemDef_t *item ) { if( len ) buff[ newLine ] = '\0'; - + if( !( *p == '\n' && !*( p + 1 ) ) ) lines++; - + if( *p == '\0' ) break; @@ -2911,10 +2911,10 @@ int Item_Text_AutoWrapped_Lines( itemDef_t *item ) p = newLinePtr; len = 0; newLine = 0; - + continue; } - + buff[ len++ ] = *p++; buff[ len ] = '\0'; } @@ -2957,7 +2957,7 @@ static int checkCache( const char *text, rectDef_t *rect, int width, int height if( awc[ i ].textWidth != width || awc[ i ].textHeight != height ) continue; - + //this is a match return i; } @@ -2997,7 +2997,7 @@ void Item_Text_AutoWrapped_Paint( itemDef_t *item ) if( *textPtr == '\0' ) return; - + Item_TextColor( item, &color ); Item_SetTextExtents( item, &width, &height, textPtr ); @@ -3011,7 +3011,7 @@ void Item_Text_AutoWrapped_Paint( itemDef_t *item ) { item->textRect.x = awc[ cache ].lineOffsets[ i ][ 0 ]; item->textRect.y = awc[ cache ].lineOffsets[ i ][ 1 ]; - + DC->drawText( item->textRect.x, item->textRect.y, item->textscale, color, awc[ cache ].lines[ i ], 0, 0, item->textStyle ); } @@ -3024,9 +3024,9 @@ void Item_Text_AutoWrapped_Paint( itemDef_t *item ) newLine = 0; newLineWidth = 0; p = textPtr; - + totalLines = Item_Text_AutoWrapped_Lines( item ); - + totalY = totalLines * ( height + 5 ); diffY = totalY - item->window.rect.h; @@ -3043,23 +3043,23 @@ void Item_Text_AutoWrapped_Paint( itemDef_t *item ) awc[ cacheIndex ].rect.h = item->window.rect.h; awc[ cacheIndex ].textWidth = width; awc[ cacheIndex ].textHeight = height; - + while( p ) { textWidth = DC->textWidth( buff, item->textscale, 0 ); - + if( *p == '^' ) { lastCMod[ 0 ] = p[ 0 ]; lastCMod[ 1 ] = p[ 1 ]; } - + if( *p == ' ' || *p == '\t' || *p == '\n' || *p == '\0' ) { newLine = len; newLinePtr = p+1; newLineWidth = textWidth; - + if( *p == '\n' ) //don't forward colours past deilberate \n's lastCMod[ 0 ] = lastCMod[ 1 ] = 0; else @@ -3072,7 +3072,7 @@ void Item_Text_AutoWrapped_Paint( itemDef_t *item ) newLine = len; newLinePtr = p; newLineWidth = textWidth; - + forwardColor = qtrue; } @@ -3109,7 +3109,7 @@ void Item_Text_AutoWrapped_Paint( itemDef_t *item ) // if( !skipLines ) y += height + 5; - + if( skipLines ) skipLines--; @@ -3126,10 +3126,10 @@ void Item_Text_AutoWrapped_Paint( itemDef_t *item ) forwardColor = qfalse; } - + continue; } - + buff[ len++ ] = *p++; buff[ len ] = '\0'; } @@ -3275,15 +3275,15 @@ void Item_TextField_Paint(itemDef_t *item) { if (item->cvar) { DC->getCVarString(item->cvar, buff, sizeof(buff)); - } + } parent = (menuDef_t*)item->parent; if (item->window.flags & WINDOW_HASFOCUS) { -/* lowLight[0] = 0.8 * parent->focusColor[0]; - lowLight[1] = 0.8 * parent->focusColor[1]; - lowLight[2] = 0.8 * parent->focusColor[2]; - lowLight[3] = 0.8 * parent->focusColor[3]; +/* lowLight[0] = 0.8 * parent->focusColor[0]; + lowLight[1] = 0.8 * parent->focusColor[1]; + lowLight[2] = 0.8 * parent->focusColor[2]; + lowLight[3] = 0.8 * parent->focusColor[3]; LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));*/ //TA: memcpy(newColor, &parent->focusColor, sizeof(vec4_t)); @@ -3309,10 +3309,10 @@ void Item_YesNo_Paint(itemDef_t *item) { value = (item->cvar) ? DC->getCVarValue(item->cvar) : 0; if (item->window.flags & WINDOW_HASFOCUS) { -/* lowLight[0] = 0.8 * parent->focusColor[0]; - lowLight[1] = 0.8 * parent->focusColor[1]; - lowLight[2] = 0.8 * parent->focusColor[2]; - lowLight[3] = 0.8 * parent->focusColor[3]; +/* lowLight[0] = 0.8 * parent->focusColor[0]; + lowLight[1] = 0.8 * parent->focusColor[1]; + lowLight[2] = 0.8 * parent->focusColor[2]; + lowLight[3] = 0.8 * parent->focusColor[3]; LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));*/ //TA: memcpy(newColor, &parent->focusColor, sizeof(vec4_t)); @@ -3334,10 +3334,10 @@ void Item_Multi_Paint(itemDef_t *item) { menuDef_t *parent = (menuDef_t*)item->parent; if (item->window.flags & WINDOW_HASFOCUS) { -/* lowLight[0] = 0.8 * parent->focusColor[0]; - lowLight[1] = 0.8 * parent->focusColor[1]; - lowLight[2] = 0.8 * parent->focusColor[2]; - lowLight[3] = 0.8 * parent->focusColor[3]; +/* lowLight[0] = 0.8 * parent->focusColor[0]; + lowLight[1] = 0.8 * parent->focusColor[1]; + lowLight[2] = 0.8 * parent->focusColor[2]; + lowLight[3] = 0.8 * parent->focusColor[3]; LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));*/ //TA: memcpy(newColor, &parent->focusColor, sizeof(vec4_t)); @@ -3369,11 +3369,11 @@ typedef struct { char* name; float defaultvalue; - float value; + float value; } configcvar_t; -static bind_t g_bindings[] = +static bind_t g_bindings[] = { { "+scores", K_TAB, -1, -1, -1 }, { "+button2", K_ENTER, -1, -1, -1 }, @@ -3438,7 +3438,7 @@ static bind_t g_bindings[] = { "tauntGauntlet", K_F5, -1, -1, -1 }, { "scoresUp", K_KP_PGUP, -1, -1, -1 }, { "scoresDown", K_KP_PGDN, -1, -1, -1 }, - // bk001205 - this one below was: '-1' + // bk001205 - this one below was: '-1' { "messagemode", -1, -1, -1, -1 }, { "messagemode2", -1, -1, -1, -1 }, { "messagemode3", -1, -1, -1, -1 }, @@ -3521,7 +3521,7 @@ void Controls_SetConfig(qboolean restart) { if (g_bindings[i].bind1 != -1) - { + { DC->setBinding( g_bindings[i].bind1, g_bindings[i].command ); if (g_bindings[i].bind2 != -1) @@ -3621,10 +3621,10 @@ void Item_Slider_Paint(itemDef_t *item) { value = (item->cvar) ? DC->getCVarValue(item->cvar) : 0; if (item->window.flags & WINDOW_HASFOCUS) { -/* lowLight[0] = 0.8 * parent->focusColor[0]; - lowLight[1] = 0.8 * parent->focusColor[1]; - lowLight[2] = 0.8 * parent->focusColor[2]; - lowLight[3] = 0.8 * parent->focusColor[3]; +/* lowLight[0] = 0.8 * parent->focusColor[0]; + lowLight[1] = 0.8 * parent->focusColor[1]; + lowLight[2] = 0.8 * parent->focusColor[2]; + lowLight[3] = 0.8 * parent->focusColor[3]; LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));*/ //TA: memcpy(newColor, &parent->focusColor, sizeof(vec4_t)); @@ -3666,10 +3666,10 @@ void Item_Bind_Paint(itemDef_t *item) { lowLight[2] = 0.8f * 0.0f; lowLight[3] = 0.8f * 1.0f; } else { - lowLight[0] = 0.8f * parent->focusColor[0]; - lowLight[1] = 0.8f * parent->focusColor[1]; - lowLight[2] = 0.8f * parent->focusColor[2]; - lowLight[3] = 0.8f * parent->focusColor[3]; + lowLight[0] = 0.8f * parent->focusColor[0]; + lowLight[1] = 0.8f * parent->focusColor[1]; + lowLight[2] = 0.8f * parent->focusColor[2]; + lowLight[3] = 0.8f * parent->focusColor[3]; } /*LerpColor(parent->focusColor,lowLight,newColor,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));*/ //TA: @@ -3718,7 +3718,7 @@ qboolean Item_Bind_HandleKey(itemDef_t *item, int key, qboolean down) { case K_ESCAPE: g_waitingForKey = qfalse; return qtrue; - + case K_BACKSPACE: id = BindingIDFromName(item->cvar); if (id != -1) { @@ -3778,10 +3778,10 @@ qboolean Item_Bind_HandleKey(itemDef_t *item, int key, qboolean down) { DC->setBinding( g_bindings[id].bind2, "" ); g_bindings[id].bind1 = key; g_bindings[id].bind2 = -1; - } + } } - Controls_SetConfig(qtrue); + Controls_SetConfig(qtrue); g_waitingForKey = qfalse; return qtrue; @@ -3832,7 +3832,7 @@ void Item_Model_Paint(itemDef_t *item) { // calculate distance so the model nearly fills the box if (qtrue) { - float len = 0.5 * ( maxs[2] - mins[2] ); + float len = 0.5 * ( maxs[2] - mins[2] ); origin[0] = len / 0.268; // len / tan( fov/2 ) //origin[0] = len / tan(w/2); } else { @@ -4095,25 +4095,25 @@ void Item_OwnerDraw_Paint(itemDef_t *item) { } if (item->window.flags & WINDOW_HASFOCUS) { -/* lowLight[0] = 0.8 * parent->focusColor[0]; - lowLight[1] = 0.8 * parent->focusColor[1]; - lowLight[2] = 0.8 * parent->focusColor[2]; - lowLight[3] = 0.8 * parent->focusColor[3]; +/* lowLight[0] = 0.8 * parent->focusColor[0]; + lowLight[1] = 0.8 * parent->focusColor[1]; + lowLight[2] = 0.8 * parent->focusColor[2]; + lowLight[3] = 0.8 * parent->focusColor[3]; LerpColor(parent->focusColor,lowLight,color,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR));*/ //TA: memcpy(color, &parent->focusColor, sizeof(vec4_t)); } else if (item->textStyle == ITEM_TEXTSTYLE_BLINK && !((DC->realTime/BLINK_DIVISOR) & 1)) { - lowLight[0] = 0.8 * item->window.foreColor[0]; - lowLight[1] = 0.8 * item->window.foreColor[1]; - lowLight[2] = 0.8 * item->window.foreColor[2]; - lowLight[3] = 0.8 * item->window.foreColor[3]; + lowLight[0] = 0.8 * item->window.foreColor[0]; + lowLight[1] = 0.8 * item->window.foreColor[1]; + lowLight[2] = 0.8 * item->window.foreColor[2]; + lowLight[3] = 0.8 * item->window.foreColor[3]; LerpColor(item->window.foreColor,lowLight,color,0.5+0.5*sin(DC->realTime / PULSE_DIVISOR)); } if (item->cvarFlags & (CVAR_ENABLE | CVAR_DISABLE) && !Item_EnableShowViaCvar(item, CVAR_ENABLE)) { memcpy(color, parent->disableColor, sizeof(vec4_t)); // bk001207 - FIXME: Com_Memcpy } - + if (item->text) { Item_Text_Paint(item); if (item->text[0]) { @@ -4142,7 +4142,7 @@ void Item_Paint(itemDef_t *item) { if (item->window.flags & WINDOW_ORBITING) { if (DC->realTime > item->window.nextTime) { float rx, ry, a, c, s, w, h; - + item->window.nextTime = DC->realTime + item->window.offsetTime; // translate w = item->window.rectClient.w / 2; @@ -4265,7 +4265,7 @@ void Item_Paint(itemDef_t *item) { return; } - // paint the rect first.. + // paint the rect first.. Window_Paint(&item->window, parent->fadeAmount , parent->fadeClamp, parent->fadeCycle); if (debugMode) { @@ -4425,7 +4425,7 @@ menuDef_t *Menus_ActivateByName(const char *p) { DC->feederSelection( m->items[ j ]->special, 0 ); } } - + if (openMenuCount < MAX_OPEN_MENUS && focus != NULL) { menuStack[openMenuCount++] = focus; } @@ -4466,7 +4466,7 @@ void Menu_HandleMouseMove(menuDef_t *menu, float x, float y) { return; } - // FIXME: this is the whole issue of focus vs. mouse over.. + // FIXME: this is the whole issue of focus vs. mouse over.. // need a better overall solution as i don't like going through everything twice for (pass = 0; pass < 2; pass++) { for (i = 0; i < menu->itemCount; i++) { @@ -4531,7 +4531,7 @@ void Menu_Paint(menuDef_t *menu, qboolean forcePaint) { if (menu->window.ownerDrawFlags && DC->ownerDrawVisible && !DC->ownerDrawVisible(menu->window.ownerDrawFlags)) { return; } - + if (forcePaint) { menu->window.flags |= WINDOW_FORCED; } @@ -4885,7 +4885,7 @@ qboolean ItemParse_elementtype( itemDef_t *item, int handle ) { return qtrue; } -// columns sets a number of columns and an x pos and width per.. +// columns sets a number of columns and an x pos and width per.. qboolean ItemParse_columns( itemDef_t *item, int handle ) { int num, i; listBoxDef_t *listPtr; @@ -5210,7 +5210,7 @@ qboolean ItemParse_cvarStrList( itemDef_t *item, int handle ) { pc_token_t token; multiDef_t *multiPtr; int pass; - + Item_ValidateTypeData(item); if (!item->typeData) return qfalse; @@ -5258,7 +5258,7 @@ qboolean ItemParse_cvarStrList( itemDef_t *item, int handle ) { qboolean ItemParse_cvarFloatList( itemDef_t *item, int handle ) { pc_token_t token; multiDef_t *multiPtr; - + Item_ValidateTypeData(item); if (!item->typeData) return qfalse; @@ -5437,7 +5437,7 @@ void Item_SetupKeywordHash( void ) int i; memset( itemParseKeywordHash, 0, sizeof( itemParseKeywordHash ) ); - + for( i = 0; itemParseKeywords[ i ].keyword; i++ ) KeywordHash_Add( itemParseKeywordHash, &itemParseKeywords[ i ] ); } @@ -5839,7 +5839,7 @@ void Menu_SetupKeywordHash( void ) int i; memset( menuParseKeywordHash, 0, sizeof( menuParseKeywordHash ) ); - + for(i = 0; menuParseKeywords[ i ].keyword; i++ ) KeywordHash_Add( menuParseKeywordHash, &menuParseKeywords[ i ] ); } @@ -5858,7 +5858,7 @@ qboolean Menu_Parse(int handle, menuDef_t *menu) { if (*token.string != '{') { return qfalse; } - + while ( 1 ) { memset(&token, 0, sizeof(pc_token_t)); @@ -5929,7 +5929,7 @@ void Menu_Reset( void ) displayContextDef_t *Display_GetContext() { return DC; } - + void *Display_CaptureItem(int x, int y) { int i; @@ -5944,7 +5944,7 @@ void *Display_CaptureItem(int x, int y) { } -// FIXME: +// FIXME: qboolean Display_MouseMove(void *p, int x, int y) { int i; menuDef_t *menu = p; @@ -5986,7 +5986,7 @@ int Display_CursorType(int x, int y) { void Display_HandleKey(int key, qboolean down, int x, int y) { menuDef_t *menu = Display_CaptureItem(x, y); - if (menu == NULL) { + if (menu == NULL) { menu = Menu_GetFocused(); } if (menu) { diff --git a/src/ui/ui_shared.h b/src/ui/ui_shared.h index d0864c02..fd0ed967 100644 --- a/src/ui/ui_shared.h +++ b/src/ui/ui_shared.h @@ -31,36 +31,36 @@ #define MAX_COLOR_RANGES 10 #define MAX_OPEN_MENUS 16 -#define WINDOW_MOUSEOVER 0x00000001 // mouse is over it, non exclusive -#define WINDOW_HASFOCUS 0x00000002 // has cursor focus, exclusive -#define WINDOW_VISIBLE 0x00000004 // is visible -#define WINDOW_GREY 0x00000008 // is visible but grey ( non-active ) -#define WINDOW_DECORATION 0x00000010 // for decoration only, no mouse, keyboard, etc.. -#define WINDOW_FADINGOUT 0x00000020 // fading out, non-active -#define WINDOW_FADINGIN 0x00000040 // fading in -#define WINDOW_MOUSEOVERTEXT 0x00000080 // mouse is over it, non exclusive -#define WINDOW_INTRANSITION 0x00000100 // window is in transition -#define WINDOW_FORECOLORSET 0x00000200 // forecolor was explicitly set ( used to color alpha images or not ) -#define WINDOW_HORIZONTAL 0x00000400 // for list boxes and sliders, vertical is default this is set of horizontal -#define WINDOW_LB_LEFTARROW 0x00000800 // mouse is over left/up arrow -#define WINDOW_LB_RIGHTARROW 0x00001000 // mouse is over right/down arrow -#define WINDOW_LB_THUMB 0x00002000 // mouse is over thumb -#define WINDOW_LB_PGUP 0x00004000 // mouse is over page up -#define WINDOW_LB_PGDN 0x00008000 // mouse is over page down -#define WINDOW_ORBITING 0x00010000 // item is in orbit -#define WINDOW_OOB_CLICK 0x00020000 // close on out of bounds click -#define WINDOW_WRAPPED 0x00040000 // manually wrap text -#define WINDOW_AUTOWRAPPED 0x00080000 // auto wrap text -#define WINDOW_FORCED 0x00100000 // forced open -#define WINDOW_POPUP 0x00200000 // popup -#define WINDOW_BACKCOLORSET 0x00400000 // backcolor was explicitly set -#define WINDOW_TIMEDVISIBLE 0x00800000 // visibility timing ( NOT implemented ) +#define WINDOW_MOUSEOVER 0x00000001 // mouse is over it, non exclusive +#define WINDOW_HASFOCUS 0x00000002 // has cursor focus, exclusive +#define WINDOW_VISIBLE 0x00000004 // is visible +#define WINDOW_GREY 0x00000008 // is visible but grey ( non-active ) +#define WINDOW_DECORATION 0x00000010 // for decoration only, no mouse, keyboard, etc.. +#define WINDOW_FADINGOUT 0x00000020 // fading out, non-active +#define WINDOW_FADINGIN 0x00000040 // fading in +#define WINDOW_MOUSEOVERTEXT 0x00000080 // mouse is over it, non exclusive +#define WINDOW_INTRANSITION 0x00000100 // window is in transition +#define WINDOW_FORECOLORSET 0x00000200 // forecolor was explicitly set ( used to color alpha images or not ) +#define WINDOW_HORIZONTAL 0x00000400 // for list boxes and sliders, vertical is default this is set of horizontal +#define WINDOW_LB_LEFTARROW 0x00000800 // mouse is over left/up arrow +#define WINDOW_LB_RIGHTARROW 0x00001000 // mouse is over right/down arrow +#define WINDOW_LB_THUMB 0x00002000 // mouse is over thumb +#define WINDOW_LB_PGUP 0x00004000 // mouse is over page up +#define WINDOW_LB_PGDN 0x00008000 // mouse is over page down +#define WINDOW_ORBITING 0x00010000 // item is in orbit +#define WINDOW_OOB_CLICK 0x00020000 // close on out of bounds click +#define WINDOW_WRAPPED 0x00040000 // manually wrap text +#define WINDOW_AUTOWRAPPED 0x00080000 // auto wrap text +#define WINDOW_FORCED 0x00100000 // forced open +#define WINDOW_POPUP 0x00200000 // popup +#define WINDOW_BACKCOLORSET 0x00400000 // backcolor was explicitly set +#define WINDOW_TIMEDVISIBLE 0x00800000 // visibility timing ( NOT implemented ) // CGAME cursor type bits -#define CURSOR_NONE 0x00000001 -#define CURSOR_ARROW 0x00000002 -#define CURSOR_SIZER 0x00000004 +#define CURSOR_NONE 0x00000001 +#define CURSOR_ARROW 0x00000002 +#define CURSOR_SIZER 0x00000004 #ifdef CGAME #define STRING_POOL_SIZE 128*1024 @@ -72,14 +72,14 @@ #define MAX_SCRIPT_ARGS 12 #define MAX_EDITFIELD 256 -#define ART_FX_BASE "menu/art/fx_base" -#define ART_FX_BLUE "menu/art/fx_blue" -#define ART_FX_CYAN "menu/art/fx_cyan" -#define ART_FX_GREEN "menu/art/fx_grn" -#define ART_FX_RED "menu/art/fx_red" -#define ART_FX_TEAL "menu/art/fx_teal" -#define ART_FX_WHITE "menu/art/fx_white" -#define ART_FX_YELLOW "menu/art/fx_yel" +#define ART_FX_BASE "menu/art/fx_base" +#define ART_FX_BLUE "menu/art/fx_blue" +#define ART_FX_CYAN "menu/art/fx_cyan" +#define ART_FX_GREEN "menu/art/fx_grn" +#define ART_FX_RED "menu/art/fx_red" +#define ART_FX_TEAL "menu/art/fx_teal" +#define ART_FX_WHITE "menu/art/fx_white" +#define ART_FX_YELLOW "menu/art/fx_yel" #define ASSET_GRADIENTBAR "ui/assets/gradientbar2.tga" #define ASSET_SCROLLBAR "ui/assets/scrollbar.tga" @@ -88,14 +88,14 @@ #define ASSET_SCROLLBAR_ARROWLEFT "ui/assets/scrollbar_arrow_left.tga" #define ASSET_SCROLLBAR_ARROWRIGHT "ui/assets/scrollbar_arrow_right.tga" #define ASSET_SCROLL_THUMB "ui/assets/scrollbar_thumb.tga" -#define ASSET_SLIDER_BAR "ui/assets/slider2.tga" -#define ASSET_SLIDER_THUMB "ui/assets/sliderbutt_1.tga" +#define ASSET_SLIDER_BAR "ui/assets/slider2.tga" +#define ASSET_SLIDER_THUMB "ui/assets/sliderbutt_1.tga" #define SCROLLBAR_SIZE 16.0 #define SLIDER_WIDTH 96.0 #define SLIDER_HEIGHT 16.0 #define SLIDER_THUMB_WIDTH 12.0 #define SLIDER_THUMB_HEIGHT 20.0 -#define NUM_CROSSHAIRS 10 +#define NUM_CROSSHAIRS 10 typedef struct { const char *command; @@ -118,13 +118,13 @@ typedef struct { Rectangle rectClient; // screen coord rectangle const char *name; // const char *group; // if it belongs to a group - const char *cinematicName; // cinematic name - int cinematic; // cinematic handle + const char *cinematicName; // cinematic name + int cinematic; // cinematic handle int style; // int border; // - int ownerDraw; // ownerDraw style - int ownerDrawFlags; // show flags for ownerdraw items - float borderSize; // + int ownerDraw; // ownerDraw style + int ownerDrawFlags; // show flags for ownerdraw items + float borderSize; // int flags; // visible, focus, mouseover, cursor Rectangle rectEffects; // for various effects Rectangle rectEffects2; // for various effects @@ -134,86 +134,86 @@ typedef struct { vec4_t backColor; // border color vec4_t borderColor; // border color vec4_t outlineColor; // border color - qhandle_t background; // background asset + qhandle_t background; // background asset } windowDef_t; typedef windowDef_t Window; typedef struct { - vec4_t color; - float low; - float high; + vec4_t color; + float low; + float high; } colorRangeDef_t; // FIXME: combine flags into bitfields to save space // FIXME: consolidate all of the common stuff in one structure for menus and items // THINKABOUTME: is there any compelling reason not to have items contain items -// and do away with a menu per say.. major issue is not being able to dynamically allocate -// and destroy stuff.. Another point to consider is adding an alloc free call for vm's and have +// and do away with a menu per say.. major issue is not being able to dynamically allocate +// and destroy stuff.. Another point to consider is adding an alloc free call for vm's and have // the engine just allocate the pool for it based on a cvar // many of the vars are re-used for different item types, as such they are not always named appropriately // the benefits of c++ in DOOM will greatly help crap like this // FIXME: need to put a type ptr that points to specific type info per type -// +// #define MAX_LB_COLUMNS 16 typedef struct columnInfo_s { - int pos; - int width; - int maxChars; + int pos; + int width; + int maxChars; int align; } columnInfo_t; typedef struct listBoxDef_s { - int startPos; - int endPos; - int drawPadding; - int cursorPos; - float elementWidth; - float elementHeight; - int elementStyle; - int numColumns; - columnInfo_t columnInfo[MAX_LB_COLUMNS]; - const char *doubleClick; - qboolean notselectable; + int startPos; + int endPos; + int drawPadding; + int cursorPos; + float elementWidth; + float elementHeight; + int elementStyle; + int numColumns; + columnInfo_t columnInfo[MAX_LB_COLUMNS]; + const char *doubleClick; + qboolean notselectable; } listBoxDef_t; typedef struct editFieldDef_s { - float minVal; // edit field limits + float minVal; // edit field limits float maxVal; // float defVal; // - float range; // + float range; // int maxChars; // for edit fields int maxPaintChars; // for edit fields - int paintOffset; // + int paintOffset; // } editFieldDef_t; #define MAX_MULTI_CVARS 32 typedef struct multiDef_s { - const char *cvarList[MAX_MULTI_CVARS]; - const char *cvarStr[MAX_MULTI_CVARS]; - float cvarValue[MAX_MULTI_CVARS]; - int count; - qboolean strDef; + const char *cvarList[MAX_MULTI_CVARS]; + const char *cvarStr[MAX_MULTI_CVARS]; + float cvarValue[MAX_MULTI_CVARS]; + int count; + qboolean strDef; } multiDef_t; typedef struct modelDef_s { - int angle; - vec3_t origin; - float fov_x; - float fov_y; - int rotationSpeed; + int angle; + vec3_t origin; + float fov_x; + float fov_y; + int rotationSpeed; } modelDef_t; -#define CVAR_ENABLE 0x00000001 -#define CVAR_DISABLE 0x00000002 -#define CVAR_SHOW 0x00000004 -#define CVAR_HIDE 0x00000008 +#define CVAR_ENABLE 0x00000001 +#define CVAR_DISABLE 0x00000002 +#define CVAR_SHOW 0x00000004 +#define CVAR_HIDE 0x00000008 typedef struct itemDef_s { Window window; // common positional, border, style, layout info - Rectangle textRect; // rectangle the text ( if any ) consumes + Rectangle textRect; // rectangle the text ( if any ) consumes int type; // text, button, radiobutton, checkbox, textfield, listbox, combo int alignment; // left center right int textalignment; // ( optional ) alignment for text within rect based on text width @@ -227,40 +227,40 @@ typedef struct itemDef_s { const char *mouseEnterText; // mouse enter script const char *mouseExitText; // mouse exit script const char *mouseEnter; // mouse enter script - const char *mouseExit; // mouse exit script + const char *mouseExit; // mouse exit script const char *action; // select script const char *onFocus; // select script const char *leaveFocus; // select script - const char *cvar; // associated cvar + const char *cvar; // associated cvar const char *cvarTest; // associated cvar for enable actions - const char *enableCvar; // enable, disable, show, or hide based on value, this can contain a list - int cvarFlags; // what type of action to take on cvarenables + const char *enableCvar; // enable, disable, show, or hide based on value, this can contain a list + int cvarFlags; // what type of action to take on cvarenables sfxHandle_t focusSound; - int numColors; // number of color ranges - colorRangeDef_t colorRanges[MAX_COLOR_RANGES]; - float special; // used for feeder id's etc.. diff per type + int numColors; // number of color ranges + colorRangeDef_t colorRanges[MAX_COLOR_RANGES]; + float special; // used for feeder id's etc.. diff per type int cursorPos; // cursor position in characters - void *typeData; // type specific data ptr's + void *typeData; // type specific data ptr's } itemDef_t; typedef struct { Window window; - const char *font; // font - qboolean fullScreen; // covers entire screen - int itemCount; // number of items; - int fontIndex; // - int cursorItem; // which item as the cursor - int fadeCycle; // - float fadeClamp; // - float fadeAmount; // - const char *onOpen; // run when the menu is first opened - const char *onClose; // run when the menu is closed - const char *onESC; // run when the menu is closed - const char *soundName; // background loop sound for menu - - vec4_t focusColor; // focus color for items - vec4_t disableColor; // focus color for items - itemDef_t *items[MAX_MENUITEMS]; // items this menu contains + const char *font; // font + qboolean fullScreen; // covers entire screen + int itemCount; // number of items; + int fontIndex; // + int cursorItem; // which item as the cursor + int fadeCycle; // + float fadeClamp; // + float fadeAmount; // + const char *onOpen; // run when the menu is first opened + const char *onClose; // run when the menu is closed + const char *onESC; // run when the menu is closed + const char *soundName; // background loop sound for menu + + vec4_t focusColor; // focus color for items + vec4_t disableColor; // focus color for items + itemDef_t *items[MAX_MENUITEMS]; // items this menu contains } menuDef_t; typedef struct { @@ -296,11 +296,6 @@ typedef struct { float shadowFadeClamp; qboolean fontRegistered; - // player settings - qhandle_t fxBasePic; - qhandle_t fxPic[7]; - qhandle_t crosshairShader[NUM_CROSSHAIRS]; - } cachedAssets_t; typedef struct { @@ -327,8 +322,8 @@ typedef struct { void (*renderScene) ( const refdef_t *fd ); void (*registerFont) (const char *pFontname, int pointSize, fontInfo_t *font); void (*ownerDrawItem) (float x, float y, float w, float h, float text_x, float text_y, int ownerDraw, int ownerDrawFlags, int align, float special, float scale, vec4_t color, qhandle_t shader, int textStyle); - float (*getValue) (int ownerDraw); - qboolean (*ownerDrawVisible) (int flags); + float (*getValue) (int ownerDraw); + qboolean (*ownerDrawVisible) (int flags); void (*runScript)(char **p); void (*getTeamColor)(vec4_t *color); void (*getCVarString)(const char *cvar, char *buffer, int bufsize); @@ -343,38 +338,38 @@ typedef struct { const char *(*feederItemText)(float feederID, int index, int column, qhandle_t *handle); qhandle_t (*feederItemImage)(float feederID, int index); void (*feederSelection)(float feederID, int index); - void (*keynumToStringBuf)( int keynum, char *buf, int buflen ); - void (*getBindingBuf)( int keynum, char *buf, int buflen ); - void (*setBinding)( int keynum, const char *binding ); - void (*executeText)(int exec_when, const char *text ); - void (*Error)(int level, const char *error, ...); - void (*Print)(const char *msg, ...); - void (*Pause)(qboolean b); - int (*ownerDrawWidth)(int ownerDraw, float scale); - sfxHandle_t (*registerSound)(const char *name, qboolean compressed); - void (*startBackgroundTrack)( const char *intro, const char *loop); - void (*stopBackgroundTrack)(); - int (*playCinematic)(const char *name, float x, float y, float w, float h); - void (*stopCinematic)(int handle); - void (*drawCinematic)(int handle, float x, float y, float w, float h); - void (*runCinematicFrame)(int handle); - - float yscale; - float xscale; - float bias; - int realTime; - int frameTime; - int cursorx; - int cursory; - qboolean debug; + void (*keynumToStringBuf)( int keynum, char *buf, int buflen ); + void (*getBindingBuf)( int keynum, char *buf, int buflen ); + void (*setBinding)( int keynum, const char *binding ); + void (*executeText)(int exec_when, const char *text ); + void (*Error)(int level, const char *error, ...); + void (*Print)(const char *msg, ...); + void (*Pause)(qboolean b); + int (*ownerDrawWidth)(int ownerDraw, float scale); + sfxHandle_t (*registerSound)(const char *name, qboolean compressed); + void (*startBackgroundTrack)( const char *intro, const char *loop); + void (*stopBackgroundTrack)(); + int (*playCinematic)(const char *name, float x, float y, float w, float h); + void (*stopCinematic)(int handle); + void (*drawCinematic)(int handle, float x, float y, float w, float h); + void (*runCinematicFrame)(int handle); + + float yscale; + float xscale; + float bias; + int realTime; + int frameTime; + int cursorx; + int cursory; + qboolean debug; cachedAssets_t Assets; - glconfig_t glconfig; - qhandle_t whiteShader; + glconfig_t glconfig; + qhandle_t whiteShader; qhandle_t gradientImage; qhandle_t cursor; - float FPS; + float FPS; } displayContextDef_t; @@ -437,11 +432,11 @@ void Controls_SetDefaults( void ); //for cg_draw.c void Item_Text_AutoWrapped_Paint( itemDef_t *item ); -int trap_PC_AddGlobalDefine( char *define ); -int trap_PC_LoadSource( const char *filename ); -int trap_PC_FreeSource( int handle ); -int trap_PC_ReadToken( int handle, pc_token_t *pc_token ); -int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ); +int trap_PC_AddGlobalDefine( char *define ); +int trap_PC_LoadSource( const char *filename ); +int trap_PC_FreeSource( int handle ); +int trap_PC_ReadToken( int handle, pc_token_t *pc_token ); +int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ); void BindingFromName( const char *cvar ); extern char g_nameBind1[ 32 ]; diff --git a/src/ui/ui_syscalls.c b/src/ui/ui_syscalls.c index 294d30f0..9a560a15 100644 --- a/src/ui/ui_syscalls.c +++ b/src/ui/ui_syscalls.c @@ -22,95 +22,95 @@ static int (QDECL *syscall)( int arg, ... ) = (int (QDECL *)( int, ...))-1; void dllEntry( int (QDECL *syscallptr)( int arg,... ) ) { - syscall = syscallptr; + syscall = syscallptr; } int PASSFLOAT( float x ) { - float floatTemp; - floatTemp = x; - return *(int *)&floatTemp; + float floatTemp; + floatTemp = x; + return *(int *)&floatTemp; } void trap_Print( const char *string ) { - syscall( UI_PRINT, string ); + syscall( UI_PRINT, string ); } void trap_Error( const char *string ) { - syscall( UI_ERROR, string ); + syscall( UI_ERROR, string ); } int trap_Milliseconds( void ) { - return syscall( UI_MILLISECONDS ); + return syscall( UI_MILLISECONDS ); } void trap_Cvar_Register( vmCvar_t *cvar, const char *var_name, const char *value, int flags ) { - syscall( UI_CVAR_REGISTER, cvar, var_name, value, flags ); + syscall( UI_CVAR_REGISTER, cvar, var_name, value, flags ); } void trap_Cvar_Update( vmCvar_t *cvar ) { - syscall( UI_CVAR_UPDATE, cvar ); + syscall( UI_CVAR_UPDATE, cvar ); } void trap_Cvar_Set( const char *var_name, const char *value ) { - syscall( UI_CVAR_SET, var_name, value ); + syscall( UI_CVAR_SET, var_name, value ); } float trap_Cvar_VariableValue( const char *var_name ) { - int temp; - temp = syscall( UI_CVAR_VARIABLEVALUE, var_name ); - return (*(float*)&temp); + int temp; + temp = syscall( UI_CVAR_VARIABLEVALUE, var_name ); + return (*(float*)&temp); } void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) { - syscall( UI_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize ); + syscall( UI_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize ); } void trap_Cvar_SetValue( const char *var_name, float value ) { - syscall( UI_CVAR_SETVALUE, var_name, PASSFLOAT( value ) ); + syscall( UI_CVAR_SETVALUE, var_name, PASSFLOAT( value ) ); } void trap_Cvar_Reset( const char *name ) { - syscall( UI_CVAR_RESET, name ); + syscall( UI_CVAR_RESET, name ); } void trap_Cvar_Create( const char *var_name, const char *var_value, int flags ) { - syscall( UI_CVAR_CREATE, var_name, var_value, flags ); + syscall( UI_CVAR_CREATE, var_name, var_value, flags ); } void trap_Cvar_InfoStringBuffer( int bit, char *buffer, int bufsize ) { - syscall( UI_CVAR_INFOSTRINGBUFFER, bit, buffer, bufsize ); + syscall( UI_CVAR_INFOSTRINGBUFFER, bit, buffer, bufsize ); } int trap_Argc( void ) { - return syscall( UI_ARGC ); + return syscall( UI_ARGC ); } void trap_Argv( int n, char *buffer, int bufferLength ) { - syscall( UI_ARGV, n, buffer, bufferLength ); + syscall( UI_ARGV, n, buffer, bufferLength ); } void trap_Cmd_ExecuteText( int exec_when, const char *text ) { - syscall( UI_CMD_EXECUTETEXT, exec_when, text ); + syscall( UI_CMD_EXECUTETEXT, exec_when, text ); } int trap_FS_FOpenFile( const char *qpath, fileHandle_t *f, fsMode_t mode ) { - return syscall( UI_FS_FOPENFILE, qpath, f, mode ); + return syscall( UI_FS_FOPENFILE, qpath, f, mode ); } void trap_FS_Read( void *buffer, int len, fileHandle_t f ) { - syscall( UI_FS_READ, buffer, len, f ); + syscall( UI_FS_READ, buffer, len, f ); } void trap_FS_Write( const void *buffer, int len, fileHandle_t f ) { - syscall( UI_FS_WRITE, buffer, len, f ); + syscall( UI_FS_WRITE, buffer, len, f ); } void trap_FS_FCloseFile( fileHandle_t f ) { - syscall( UI_FS_FCLOSEFILE, f ); + syscall( UI_FS_FCLOSEFILE, f ); } int trap_FS_GetFileList( const char *path, const char *extension, char *listbuf, int bufsize ) { - return syscall( UI_FS_GETFILELIST, path, extension, listbuf, bufsize ); + return syscall( UI_FS_GETFILELIST, path, extension, listbuf, bufsize ); } int trap_FS_Seek( fileHandle_t f, long offset, int origin ) { @@ -118,242 +118,242 @@ int trap_FS_Seek( fileHandle_t f, long offset, int origin ) { } qhandle_t trap_R_RegisterModel( const char *name ) { - return syscall( UI_R_REGISTERMODEL, name ); + return syscall( UI_R_REGISTERMODEL, name ); } qhandle_t trap_R_RegisterSkin( const char *name ) { - return syscall( UI_R_REGISTERSKIN, name ); + return syscall( UI_R_REGISTERSKIN, name ); } void trap_R_RegisterFont(const char *fontName, int pointSize, fontInfo_t *font) { - syscall( UI_R_REGISTERFONT, fontName, pointSize, font ); + syscall( UI_R_REGISTERFONT, fontName, pointSize, font ); } qhandle_t trap_R_RegisterShaderNoMip( const char *name ) { - return syscall( UI_R_REGISTERSHADERNOMIP, name ); + return syscall( UI_R_REGISTERSHADERNOMIP, name ); } void trap_R_ClearScene( void ) { - syscall( UI_R_CLEARSCENE ); + syscall( UI_R_CLEARSCENE ); } void trap_R_AddRefEntityToScene( const refEntity_t *re ) { - syscall( UI_R_ADDREFENTITYTOSCENE, re ); + syscall( UI_R_ADDREFENTITYTOSCENE, re ); } void trap_R_AddPolyToScene( qhandle_t hShader , int numVerts, const polyVert_t *verts ) { - syscall( UI_R_ADDPOLYTOSCENE, hShader, numVerts, verts ); + syscall( UI_R_ADDPOLYTOSCENE, hShader, numVerts, verts ); } void trap_R_AddLightToScene( const vec3_t org, float intensity, float r, float g, float b ) { - syscall( UI_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) ); + syscall( UI_R_ADDLIGHTTOSCENE, org, PASSFLOAT(intensity), PASSFLOAT(r), PASSFLOAT(g), PASSFLOAT(b) ); } void trap_R_RenderScene( const refdef_t *fd ) { - syscall( UI_R_RENDERSCENE, fd ); + syscall( UI_R_RENDERSCENE, fd ); } void trap_R_SetColor( const float *rgba ) { - syscall( UI_R_SETCOLOR, rgba ); + syscall( UI_R_SETCOLOR, rgba ); } void trap_R_DrawStretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) { - syscall( UI_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader ); + syscall( UI_R_DRAWSTRETCHPIC, PASSFLOAT(x), PASSFLOAT(y), PASSFLOAT(w), PASSFLOAT(h), PASSFLOAT(s1), PASSFLOAT(t1), PASSFLOAT(s2), PASSFLOAT(t2), hShader ); } -void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) { - syscall( UI_R_MODELBOUNDS, model, mins, maxs ); +void trap_R_ModelBounds( clipHandle_t model, vec3_t mins, vec3_t maxs ) { + syscall( UI_R_MODELBOUNDS, model, mins, maxs ); } void trap_UpdateScreen( void ) { - syscall( UI_UPDATESCREEN ); + syscall( UI_UPDATESCREEN ); } int trap_CM_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int endFrame, float frac, const char *tagName ) { - return syscall( UI_CM_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName ); + return syscall( UI_CM_LERPTAG, tag, mod, startFrame, endFrame, PASSFLOAT(frac), tagName ); } void trap_S_StartLocalSound( sfxHandle_t sfx, int channelNum ) { - syscall( UI_S_STARTLOCALSOUND, sfx, channelNum ); + syscall( UI_S_STARTLOCALSOUND, sfx, channelNum ); } -sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ) { - return syscall( UI_S_REGISTERSOUND, sample, compressed ); +sfxHandle_t trap_S_RegisterSound( const char *sample, qboolean compressed ) { + return syscall( UI_S_REGISTERSOUND, sample, compressed ); } void trap_Key_KeynumToStringBuf( int keynum, char *buf, int buflen ) { - syscall( UI_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen ); + syscall( UI_KEY_KEYNUMTOSTRINGBUF, keynum, buf, buflen ); } void trap_Key_GetBindingBuf( int keynum, char *buf, int buflen ) { - syscall( UI_KEY_GETBINDINGBUF, keynum, buf, buflen ); + syscall( UI_KEY_GETBINDINGBUF, keynum, buf, buflen ); } void trap_Key_SetBinding( int keynum, const char *binding ) { - syscall( UI_KEY_SETBINDING, keynum, binding ); + syscall( UI_KEY_SETBINDING, keynum, binding ); } qboolean trap_Key_IsDown( int keynum ) { - return syscall( UI_KEY_ISDOWN, keynum ); + return syscall( UI_KEY_ISDOWN, keynum ); } qboolean trap_Key_GetOverstrikeMode( void ) { - return syscall( UI_KEY_GETOVERSTRIKEMODE ); + return syscall( UI_KEY_GETOVERSTRIKEMODE ); } void trap_Key_SetOverstrikeMode( qboolean state ) { - syscall( UI_KEY_SETOVERSTRIKEMODE, state ); + syscall( UI_KEY_SETOVERSTRIKEMODE, state ); } void trap_Key_ClearStates( void ) { - syscall( UI_KEY_CLEARSTATES ); + syscall( UI_KEY_CLEARSTATES ); } int trap_Key_GetCatcher( void ) { - return syscall( UI_KEY_GETCATCHER ); + return syscall( UI_KEY_GETCATCHER ); } void trap_Key_SetCatcher( int catcher ) { - syscall( UI_KEY_SETCATCHER, catcher ); + syscall( UI_KEY_SETCATCHER, catcher ); } void trap_GetClipboardData( char *buf, int bufsize ) { - syscall( UI_GETCLIPBOARDDATA, buf, bufsize ); + syscall( UI_GETCLIPBOARDDATA, buf, bufsize ); } void trap_GetClientState( uiClientState_t *state ) { - syscall( UI_GETCLIENTSTATE, state ); + syscall( UI_GETCLIENTSTATE, state ); } void trap_GetGlconfig( glconfig_t *glconfig ) { - syscall( UI_GETGLCONFIG, glconfig ); + syscall( UI_GETGLCONFIG, glconfig ); } int trap_GetConfigString( int index, char* buff, int buffsize ) { - return syscall( UI_GETCONFIGSTRING, index, buff, buffsize ); + return syscall( UI_GETCONFIGSTRING, index, buff, buffsize ); } -int trap_LAN_GetServerCount( int source ) { - return syscall( UI_LAN_GETSERVERCOUNT, source ); +int trap_LAN_GetServerCount( int source ) { + return syscall( UI_LAN_GETSERVERCOUNT, source ); } void trap_LAN_GetServerAddressString( int source, int n, char *buf, int buflen ) { - syscall( UI_LAN_GETSERVERADDRESSSTRING, source, n, buf, buflen ); + syscall( UI_LAN_GETSERVERADDRESSSTRING, source, n, buf, buflen ); } void trap_LAN_GetServerInfo( int source, int n, char *buf, int buflen ) { - syscall( UI_LAN_GETSERVERINFO, source, n, buf, buflen ); + syscall( UI_LAN_GETSERVERINFO, source, n, buf, buflen ); } int trap_LAN_GetServerPing( int source, int n ) { - return syscall( UI_LAN_GETSERVERPING, source, n ); + return syscall( UI_LAN_GETSERVERPING, source, n ); } int trap_LAN_GetPingQueueCount( void ) { - return syscall( UI_LAN_GETPINGQUEUECOUNT ); + return syscall( UI_LAN_GETPINGQUEUECOUNT ); } int trap_LAN_ServerStatus( const char *serverAddress, char *serverStatus, int maxLen ) { - return syscall( UI_LAN_SERVERSTATUS, serverAddress, serverStatus, maxLen ); + return syscall( UI_LAN_SERVERSTATUS, serverAddress, serverStatus, maxLen ); } void trap_LAN_SaveCachedServers() { - syscall( UI_LAN_SAVECACHEDSERVERS ); + syscall( UI_LAN_SAVECACHEDSERVERS ); } void trap_LAN_LoadCachedServers() { - syscall( UI_LAN_LOADCACHEDSERVERS ); + syscall( UI_LAN_LOADCACHEDSERVERS ); } void trap_LAN_ResetPings(int n) { - syscall( UI_LAN_RESETPINGS, n ); + syscall( UI_LAN_RESETPINGS, n ); } void trap_LAN_ClearPing( int n ) { - syscall( UI_LAN_CLEARPING, n ); + syscall( UI_LAN_CLEARPING, n ); } void trap_LAN_GetPing( int n, char *buf, int buflen, int *pingtime ) { - syscall( UI_LAN_GETPING, n, buf, buflen, pingtime ); + syscall( UI_LAN_GETPING, n, buf, buflen, pingtime ); } void trap_LAN_GetPingInfo( int n, char *buf, int buflen ) { - syscall( UI_LAN_GETPINGINFO, n, buf, buflen ); + syscall( UI_LAN_GETPINGINFO, n, buf, buflen ); } void trap_LAN_MarkServerVisible( int source, int n, qboolean visible ) { - syscall( UI_LAN_MARKSERVERVISIBLE, source, n, visible ); + syscall( UI_LAN_MARKSERVERVISIBLE, source, n, visible ); } int trap_LAN_ServerIsVisible( int source, int n) { - return syscall( UI_LAN_SERVERISVISIBLE, source, n ); + return syscall( UI_LAN_SERVERISVISIBLE, source, n ); } qboolean trap_LAN_UpdateVisiblePings( int source ) { - return syscall( UI_LAN_UPDATEVISIBLEPINGS, source ); + return syscall( UI_LAN_UPDATEVISIBLEPINGS, source ); } int trap_LAN_AddServer(int source, const char *name, const char *addr) { - return syscall( UI_LAN_ADDSERVER, source, name, addr ); + return syscall( UI_LAN_ADDSERVER, source, name, addr ); } void trap_LAN_RemoveServer(int source, const char *addr) { - syscall( UI_LAN_REMOVESERVER, source, addr ); + syscall( UI_LAN_REMOVESERVER, source, addr ); } int trap_LAN_CompareServers( int source, int sortKey, int sortDir, int s1, int s2 ) { - return syscall( UI_LAN_COMPARESERVERS, source, sortKey, sortDir, s1, s2 ); + return syscall( UI_LAN_COMPARESERVERS, source, sortKey, sortDir, s1, s2 ); } int trap_MemoryRemaining( void ) { - return syscall( UI_MEMORY_REMAINING ); + return syscall( UI_MEMORY_REMAINING ); } void trap_GetCDKey( char *buf, int buflen ) { - syscall( UI_GET_CDKEY, buf, buflen ); + syscall( UI_GET_CDKEY, buf, buflen ); } void trap_SetCDKey( char *buf ) { - syscall( UI_SET_CDKEY, buf ); + syscall( UI_SET_CDKEY, buf ); } int trap_PC_AddGlobalDefine( char *define ) { - return syscall( UI_PC_ADD_GLOBAL_DEFINE, define ); + return syscall( UI_PC_ADD_GLOBAL_DEFINE, define ); } int trap_PC_LoadSource( const char *filename ) { - return syscall( UI_PC_LOAD_SOURCE, filename ); + return syscall( UI_PC_LOAD_SOURCE, filename ); } int trap_PC_FreeSource( int handle ) { - return syscall( UI_PC_FREE_SOURCE, handle ); + return syscall( UI_PC_FREE_SOURCE, handle ); } int trap_PC_ReadToken( int handle, pc_token_t *pc_token ) { - return syscall( UI_PC_READ_TOKEN, handle, pc_token ); + return syscall( UI_PC_READ_TOKEN, handle, pc_token ); } int trap_PC_SourceFileAndLine( int handle, char *filename, int *line ) { - return syscall( UI_PC_SOURCE_FILE_AND_LINE, handle, filename, line ); + return syscall( UI_PC_SOURCE_FILE_AND_LINE, handle, filename, line ); } void trap_S_StopBackgroundTrack( void ) { - syscall( UI_S_STOPBACKGROUNDTRACK ); + syscall( UI_S_STOPBACKGROUNDTRACK ); } void trap_S_StartBackgroundTrack( const char *intro, const char *loop) { - syscall( UI_S_STARTBACKGROUNDTRACK, intro, loop ); + syscall( UI_S_STARTBACKGROUNDTRACK, intro, loop ); } int trap_RealTime(qtime_t *qtime) { - return syscall( UI_REAL_TIME, qtime ); + return syscall( UI_REAL_TIME, qtime ); } // this returns a handle. arg0 is the name in the format "idlogo.roq", set arg1 to NULL, alteredstates to qfalse (do not alter gamestate) int trap_CIN_PlayCinematic( const char *arg0, int xpos, int ypos, int width, int height, int bits) { return syscall(UI_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) { @@ -365,13 +365,13 @@ e_status trap_CIN_StopCinematic(int handle) { e_status trap_CIN_RunCinematic (int handle) { return syscall(UI_CIN_RUNCINEMATIC, handle); } - + // draws the current frame void trap_CIN_DrawCinematic (int handle) { syscall(UI_CIN_DRAWCINEMATIC, handle); } - + // allows you to resize the animation dynamically void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) { @@ -379,12 +379,12 @@ void trap_CIN_SetExtents (int handle, int x, int y, int w, int h) { } -void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) { - syscall( UI_R_REMAP_SHADER, oldShader, newShader, timeOffset ); +void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset ) { + syscall( UI_R_REMAP_SHADER, oldShader, newShader, timeOffset ); } qboolean trap_VerifyCDKey( const char *key, const char *chksum) { - return syscall( UI_VERIFY_CDKEY, key, chksum); + return syscall( UI_VERIFY_CDKEY, key, chksum); } void trap_SetPbClStatus( int status ) { diff --git a/ui/menudef.h b/ui/menudef.h index 57514a53..6c6a34bf 100644 --- a/ui/menudef.h +++ b/ui/menudef.h @@ -260,7 +260,6 @@ #define UI_OWNERDRAW_BASE 200 #define UI_HANDICAP 200 -#define UI_EFFECTS 201 #define UI_PLAYERMODEL 202 #define UI_CLANNAME 203 #define UI_CLANLOGO 204 @@ -301,7 +300,6 @@ #define UI_BOTNAME 239 #define UI_BOTSKILL 240 #define UI_REDBLUE 241 -#define UI_CROSSHAIR 242 #define UI_SELECTEDPLAYER 243 #define UI_MAPCINEMATIC 244 #define UI_NETGAMETYPE 245 |