diff --git a/cl_dll/StudioModelRenderer.cpp b/cl_dll/StudioModelRenderer.cpp index d4644408..b7c3c1c6 100644 --- a/cl_dll/StudioModelRenderer.cpp +++ b/cl_dll/StudioModelRenderer.cpp @@ -39,14 +39,14 @@ engine_studio_api_t IEngineStudio; // enumerate all the bones that used for gait animation const char *legs_bones[] = { - "Bip01" , - "Bip01 Pelvis" , - "Bip01 L Leg" , - "Bip01 L Leg1" , - "Bip01 L Foot" , - "Bip01 R Leg" , - "Bip01 R Leg1" , - "Bip01 R Foot" + "Bip01", + "Bip01 Pelvis", + "Bip01 L Leg", + "Bip01 L Leg1", + "Bip01 L Foot", + "Bip01 R Leg", + "Bip01 R Leg1", + "Bip01 R Foot" }; /* @@ -81,7 +81,7 @@ CStudioModelRenderer */ CStudioModelRenderer::CStudioModelRenderer( void ) { - m_fDoInterp = 1; + m_fDoInterp = 1; m_fGaitEstimation = 1; m_pCurrentEntity = NULL; m_pCvarHiModels = NULL; @@ -95,8 +95,8 @@ CStudioModelRenderer::CStudioModelRenderer( void ) m_pbonetransform = NULL; m_plighttransform = NULL; m_pStudioHeader = NULL; - m_pBodyPart = NULL; - m_pSubModel = NULL; + m_pBodyPart = NULL; + m_pSubModel = NULL; m_pPlayerInfo = NULL; m_pRenderModel = NULL; } @@ -119,54 +119,54 @@ StudioCalcBoneAdj */ void CStudioModelRenderer::StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen ) { - int i, j; - float value; + int i, j; + float value; mstudiobonecontroller_t *pbonecontroller; - - pbonecontroller = (mstudiobonecontroller_t *)((byte *)m_pStudioHeader + m_pStudioHeader->bonecontrollerindex); - for (j = 0; j < m_pStudioHeader->numbonecontrollers; j++) + pbonecontroller = (mstudiobonecontroller_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->bonecontrollerindex ); + + for( j = 0; j < m_pStudioHeader->numbonecontrollers; j++ ) { i = pbonecontroller[j].index; - if (i <= 3) + if( i <= 3 ) { // check for 360% wrapping - if (pbonecontroller[j].type & STUDIO_RLOOP) + if( pbonecontroller[j].type & STUDIO_RLOOP ) { - if (abs(pcontroller1[i] - pcontroller2[i]) > 128) + if( abs( pcontroller1[i] - pcontroller2[i] ) > 128) { int a, b; - a = (pcontroller1[j] + 128) % 256; - b = (pcontroller2[j] + 128) % 256; - value = ((a * dadt) + (b * (1 - dadt)) - 128) * (360.0/256.0) + pbonecontroller[j].start; + a = ( pcontroller1[j] + 128 ) % 256; + b = ( pcontroller2[j] + 128 ) % 256; + value = ( ( a * dadt ) + ( b * ( 1 - dadt ) ) - 128 ) * ( 360.0 / 256.0 ) + pbonecontroller[j].start; } - else + else { - value = ((pcontroller1[i] * dadt + (pcontroller2[i]) * (1.0 - dadt))) * (360.0/256.0) + pbonecontroller[j].start; + value = ( ( pcontroller1[i] * dadt + ( pcontroller2[i] ) * ( 1.0 - dadt ) ) ) * ( 360.0 / 256.0 ) + pbonecontroller[j].start; } } - else + else { - value = (pcontroller1[i] * dadt + pcontroller2[i] * (1.0 - dadt)) / 255.0; - if (value < 0) value = 0; - if (value > 1.0) value = 1.0; - value = (1.0 - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; + value = ( pcontroller1[i] * dadt + pcontroller2[i] * ( 1.0 - dadt ) ) / 255.0; + if( value < 0 ) value = 0; + if( value > 1.0 ) value = 1.0; + value = ( 1.0 - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end; } // Con_DPrintf( "%d %d %f : %f\n", m_pCurrentEntity->curstate.controller[j], m_pCurrentEntity->latched.prevcontroller[j], value, dadt ); } else { value = mouthopen / 64.0; - if (value > 1.0) value = 1.0; - value = (1.0 - value) * pbonecontroller[j].start + value * pbonecontroller[j].end; - // Con_DPrintf("%d %f\n", mouthopen, value ); + if( value > 1.0 ) value = 1.0; + value = ( 1.0 - value ) * pbonecontroller[j].start + value * pbonecontroller[j].end; + // Con_DPrintf( "%d %f\n", mouthopen, value ); } - switch(pbonecontroller[j].type & STUDIO_TYPES) + switch( pbonecontroller[j].type & STUDIO_TYPES ) { case STUDIO_XR: case STUDIO_YR: case STUDIO_ZR: - adj[j] = value * (M_PI / 180.0); + adj[j] = value * ( M_PI / 180.0 ); break; case STUDIO_X: case STUDIO_Y: @@ -186,53 +186,53 @@ StudioCalcBoneQuaterion */ void CStudioModelRenderer::StudioCalcBoneQuaterion( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q ) { - int j, k; - vec4_t q1, q2; - vec3_t angle1, angle2; - mstudioanimvalue_t *panimvalue; + int j, k; + vec4_t q1, q2; + vec3_t angle1, angle2; + mstudioanimvalue_t *panimvalue; - for (j = 0; j < 3; j++) + for( j = 0; j < 3; j++ ) { - if (panim->offset[j+3] == 0) + if( panim->offset[j + 3] == 0 ) { - angle2[j] = angle1[j] = pbone->value[j+3]; // default; + angle2[j] = angle1[j] = pbone->value[ j + 3]; // default; } else { - panimvalue = (mstudioanimvalue_t *)((byte *)panim + panim->offset[j+3]); + panimvalue = (mstudioanimvalue_t *)( (byte *)panim + panim->offset[j + 3] ); k = frame; // DEBUG - if (panimvalue->num.total < panimvalue->num.valid) + if( panimvalue->num.total < panimvalue->num.valid ) k = 0; - while (panimvalue->num.total <= k) + while( panimvalue->num.total <= k ) { k -= panimvalue->num.total; panimvalue += panimvalue->num.valid + 1; // DEBUG - if (panimvalue->num.total < panimvalue->num.valid) + if( panimvalue->num.total < panimvalue->num.valid ) k = 0; } // Bah, missing blend! - if (panimvalue->num.valid > k) + if( panimvalue->num.valid > k ) { - angle1[j] = panimvalue[k+1].value; + angle1[j] = panimvalue[k + 1].value; - if (panimvalue->num.valid > k + 1) + if( panimvalue->num.valid > k + 1 ) { - angle2[j] = panimvalue[k+2].value; + angle2[j] = panimvalue[k + 2].value; } else { - if (panimvalue->num.total > k + 1) + if( panimvalue->num.total > k + 1 ) angle2[j] = angle1[j]; else - angle2[j] = panimvalue[panimvalue->num.valid+2].value; + angle2[j] = panimvalue[panimvalue->num.valid + 2].value; } } else { angle1[j] = panimvalue[panimvalue->num.valid].value; - if (panimvalue->num.total > k + 1) + if( panimvalue->num.total > k + 1 ) { angle2[j] = angle1[j]; } @@ -241,18 +241,18 @@ void CStudioModelRenderer::StudioCalcBoneQuaterion( int frame, float s, mstudiob angle2[j] = panimvalue[panimvalue->num.valid + 2].value; } } - angle1[j] = pbone->value[j+3] + angle1[j] * pbone->scale[j+3]; - angle2[j] = pbone->value[j+3] + angle2[j] * pbone->scale[j+3]; + angle1[j] = pbone->value[j+3] + angle1[j] * pbone->scale[j + 3]; + angle2[j] = pbone->value[j+3] + angle2[j] * pbone->scale[j + 3]; } - if (pbone->bonecontroller[j+3] != -1) + if( pbone->bonecontroller[j + 3] != -1 ) { - angle1[j] += adj[pbone->bonecontroller[j+3]]; - angle2[j] += adj[pbone->bonecontroller[j+3]]; + angle1[j] += adj[pbone->bonecontroller[j + 3]]; + angle2[j] += adj[pbone->bonecontroller[j + 3]]; } } - if (!VectorCompare( angle1, angle2 )) + if( !VectorCompare( angle1, angle2 ) ) { AngleQuaternion( angle1, q1 ); AngleQuaternion( angle2, q2 ); @@ -272,52 +272,52 @@ StudioCalcBonePosition */ void CStudioModelRenderer::StudioCalcBonePosition( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos ) { - int j, k; - mstudioanimvalue_t *panimvalue; + int j, k; + mstudioanimvalue_t *panimvalue; - for (j = 0; j < 3; j++) + for( j = 0; j < 3; j++ ) { pos[j] = pbone->value[j]; // default; - if (panim->offset[j] != 0) + if( panim->offset[j] != 0 ) { - panimvalue = (mstudioanimvalue_t *)((byte *)panim + panim->offset[j]); + panimvalue = (mstudioanimvalue_t *)( (byte *)panim + panim->offset[j] ); /* - if (i == 0 && j == 0) - Con_DPrintf("%d %d:%d %f\n", frame, panimvalue->num.valid, panimvalue->num.total, s ); + if( i == 0 && j == 0 ) + Con_DPrintf( "%d %d:%d %f\n", frame, panimvalue->num.valid, panimvalue->num.total, s ); */ k = frame; // DEBUG - if (panimvalue->num.total < panimvalue->num.valid) + if( panimvalue->num.total < panimvalue->num.valid ) k = 0; // find span of values that includes the frame we want - while (panimvalue->num.total <= k) + while( panimvalue->num.total <= k ) { k -= panimvalue->num.total; panimvalue += panimvalue->num.valid + 1; // DEBUG - if (panimvalue->num.total < panimvalue->num.valid) + if( panimvalue->num.total < panimvalue->num.valid ) k = 0; } // if we're inside the span - if (panimvalue->num.valid > k) + if( panimvalue->num.valid > k ) { // and there's more data in the span - if (panimvalue->num.valid > k + 1) + if( panimvalue->num.valid > k + 1 ) { - pos[j] += (panimvalue[k+1].value * (1.0 - s) + s * panimvalue[k+2].value) * pbone->scale[j]; + pos[j] += ( panimvalue[k + 1].value * ( 1.0 - s ) + s * panimvalue[k + 2].value ) * pbone->scale[j]; } else { - pos[j] += panimvalue[k+1].value * pbone->scale[j]; + pos[j] += panimvalue[k + 1].value * pbone->scale[j]; } } else { // are we at the end of the repeating values section and there's another section with data? - if (panimvalue->num.total <= k + 1) + if( panimvalue->num.total <= k + 1 ) { - pos[j] += (panimvalue[panimvalue->num.valid].value * (1.0 - s) + s * panimvalue[panimvalue->num.valid + 2].value) * pbone->scale[j]; + pos[j] += ( panimvalue[panimvalue->num.valid].value * ( 1.0 - s ) + s * panimvalue[panimvalue->num.valid + 2].value ) * pbone->scale[j]; } else { @@ -325,7 +325,7 @@ void CStudioModelRenderer::StudioCalcBonePosition( int frame, float s, mstudiobo } } } - if ( pbone->bonecontroller[j] != -1 && adj ) + if( pbone->bonecontroller[j] != -1 && adj ) { pos[j] += adj[pbone->bonecontroller[j]]; } @@ -340,16 +340,18 @@ StudioSlerpBones */ void CStudioModelRenderer::StudioSlerpBones( vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s ) { - int i; - vec4_t q3; - float s1; + int i; + vec4_t q3; + float s1; - if (s < 0) s = 0; - else if (s > 1.0) s = 1.0; + if( s < 0 ) + s = 0; + else if( s > 1.0 ) + s = 1.0; s1 = 1.0 - s; - for (i = 0; i < m_pStudioHeader->numbones; i++) + for( i = 0; i < m_pStudioHeader->numbones; i++ ) { QuaternionSlerp( q1[i], q2[i], s, q3 ); q1[i][0] = q3[0]; @@ -370,30 +372,30 @@ StudioGetAnim */ mstudioanim_t *CStudioModelRenderer::StudioGetAnim( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc ) { - mstudioseqgroup_t *pseqgroup; + mstudioseqgroup_t *pseqgroup; cache_user_t *paSequences; - pseqgroup = (mstudioseqgroup_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqgroupindex) + pseqdesc->seqgroup; + pseqgroup = (mstudioseqgroup_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->seqgroupindex ) + pseqdesc->seqgroup; - if (pseqdesc->seqgroup == 0) + if( pseqdesc->seqgroup == 0 ) { - return (mstudioanim_t *)((byte *)m_pStudioHeader + pseqdesc->animindex); + return (mstudioanim_t *)( (byte *)m_pStudioHeader + pseqdesc->animindex ); } paSequences = (cache_user_t *)m_pSubModel->submodels; - if (paSequences == NULL) + if( paSequences == NULL ) { - paSequences = (cache_user_t *)IEngineStudio.Mem_Calloc( 16, sizeof( cache_user_t ) ); // UNDONE: leak! + paSequences = (cache_user_t *)IEngineStudio.Mem_Calloc( 16, sizeof(cache_user_t) ); // UNDONE: leak! m_pSubModel->submodels = (dmodel_t *)paSequences; } - if (!IEngineStudio.Cache_Check( (struct cache_user_s *)&(paSequences[pseqdesc->seqgroup]))) + if( !IEngineStudio.Cache_Check( (struct cache_user_s *)&( paSequences[pseqdesc->seqgroup] ) ) ) { gEngfuncs.Con_DPrintf("loading %s\n", pseqgroup->name ); IEngineStudio.LoadCacheFile( pseqgroup->name, (struct cache_user_s *)&paSequences[pseqdesc->seqgroup] ); } - return (mstudioanim_t *)((byte *)paSequences[pseqdesc->seqgroup].data + pseqdesc->animindex); + return (mstudioanim_t *)( (byte *)paSequences[pseqdesc->seqgroup].data + pseqdesc->animindex ); } /* @@ -405,23 +407,23 @@ StudioPlayerBlend void CStudioModelRenderer::StudioPlayerBlend( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch ) { // calc up/down pointing - *pBlend = (*pPitch * 3); - if (*pBlend < pseqdesc->blendstart[0]) + *pBlend = ( *pPitch * 3 ); + if( *pBlend < pseqdesc->blendstart[0] ) { *pPitch -= pseqdesc->blendstart[0] / 3.0; *pBlend = 0; } - else if (*pBlend > pseqdesc->blendend[0]) + else if( *pBlend > pseqdesc->blendend[0] ) { *pPitch -= pseqdesc->blendend[0] / 3.0; *pBlend = 255; } else { - if (pseqdesc->blendend[0] - pseqdesc->blendstart[0] < 0.1) // catch qc error + if( pseqdesc->blendend[0] - pseqdesc->blendstart[0] < 0.1 ) // catch qc error *pBlend = 127; else - *pBlend = 255 * (*pBlend - pseqdesc->blendstart[0]) / (pseqdesc->blendend[0] - pseqdesc->blendstart[0]); + *pBlend = 255 * ( *pBlend - pseqdesc->blendstart[0] ) / ( pseqdesc->blendend[0] - pseqdesc->blendstart[0] ); *pPitch = 0; } } @@ -432,14 +434,14 @@ StudioSetUpTransform ==================== */ -void CStudioModelRenderer::StudioSetUpTransform (int trivial_accept) +void CStudioModelRenderer::StudioSetUpTransform( int trivial_accept ) { - int i; - vec3_t angles; - vec3_t modelpos; + int i; + vec3_t angles; + vec3_t modelpos; -// tweek model origin - //for (i = 0; i < 3; i++) + // tweek model origin + //for( i = 0; i < 3; i++ ) // modelpos[i] = m_pCurrentEntity->origin[i]; VectorCopy( m_pCurrentEntity->origin, modelpos ); @@ -451,26 +453,26 @@ void CStudioModelRenderer::StudioSetUpTransform (int trivial_accept) angles[PITCH] = m_pCurrentEntity->curstate.angles[PITCH]; angles[YAW] = m_pCurrentEntity->curstate.angles[YAW]; - //Con_DPrintf("Angles %4.2f prev %4.2f for %i\n", angles[PITCH], m_pCurrentEntity->index); - //Con_DPrintf("movetype %d %d\n", m_pCurrentEntity->movetype, m_pCurrentEntity->aiment ); - if (m_pCurrentEntity->curstate.movetype == MOVETYPE_STEP) + //Con_DPrintf( "Angles %4.2f prev %4.2f for %i\n", angles[PITCH], m_pCurrentEntity->index ); + //Con_DPrintf( "movetype %d %d\n", m_pCurrentEntity->movetype, m_pCurrentEntity->aiment ); + if( m_pCurrentEntity->curstate.movetype == MOVETYPE_STEP ) { - float f = 0; - float d; + float f = 0; + float d; // don't do it if the goalstarttime hasn't updated in a while. // NOTE: Because we need to interpolate multiplayer characters, the interpolation time limit // was increased to 1.0 s., which is 2x the max lag we are accounting for. - if ( ( m_clTime < m_pCurrentEntity->curstate.animtime + 1.0f ) && - ( m_pCurrentEntity->curstate.animtime != m_pCurrentEntity->latched.prevanimtime ) ) + if( ( m_clTime < m_pCurrentEntity->curstate.animtime + 1.0f ) && + ( m_pCurrentEntity->curstate.animtime != m_pCurrentEntity->latched.prevanimtime ) ) { - f = (m_clTime - m_pCurrentEntity->curstate.animtime) / (m_pCurrentEntity->curstate.animtime - m_pCurrentEntity->latched.prevanimtime); - //Con_DPrintf("%4.2f %.2f %.2f\n", f, m_pCurrentEntity->curstate.animtime, m_clTime); + f = ( m_clTime - m_pCurrentEntity->curstate.animtime ) / ( m_pCurrentEntity->curstate.animtime - m_pCurrentEntity->latched.prevanimtime ); + //Con_DPrintf( "%4.2f %.2f %.2f\n", f, m_pCurrentEntity->curstate.animtime, m_clTime ); } - if (m_fDoInterp) + if( m_fDoInterp ) { // ugly hack to interpolate angle, position. current is reached 0.1 seconds after being set f = f - 1.0; @@ -480,17 +482,16 @@ void CStudioModelRenderer::StudioSetUpTransform (int trivial_accept) f = 0; } - for (i = 0; i < 3; i++) + for( i = 0; i < 3; i++ ) { - modelpos[i] += (m_pCurrentEntity->origin[i] - m_pCurrentEntity->latched.prevorigin[i]) * f; + modelpos[i] += ( m_pCurrentEntity->origin[i] - m_pCurrentEntity->latched.prevorigin[i] ) * f; } // NOTE: Because multiplayer lag can be relatively large, we don't want to cap // f at 1.5 anymore. - //if (f > -1.0 && f < 1.5) {} - -// Con_DPrintf("%.0f %.0f\n",m_pCurrentEntity->msg_angles[0][YAW], m_pCurrentEntity->msg_angles[1][YAW] ); - for (i = 0; i < 3; i++) + //if( f > -1.0 && f < 1.5 ) {} + //Con_DPrintf( "%.0f %.0f\n",m_pCurrentEntity->msg_angles[0][YAW], m_pCurrentEntity->msg_angles[1][YAW] ); + for( i = 0; i < 3; i++ ) { float ang1, ang2; @@ -498,60 +499,57 @@ void CStudioModelRenderer::StudioSetUpTransform (int trivial_accept) ang2 = m_pCurrentEntity->latched.prevangles[i]; d = ang1 - ang2; - if (d > 180) + if( d > 180 ) { d -= 360; } - else if (d < -180) - { + else if( d < -180 ) + { d += 360; } angles[i] += d * f; } - //Con_DPrintf("%.3f \n", f ); + //Con_DPrintf( "%.3f \n", f ); } - else if ( m_pCurrentEntity->curstate.movetype != MOVETYPE_NONE ) + else if( m_pCurrentEntity->curstate.movetype != MOVETYPE_NONE ) { VectorCopy( m_pCurrentEntity->angles, angles ); } - //Con_DPrintf("%.0f %0.f %0.f\n", modelpos[0], modelpos[1], modelpos[2] ); - //Con_DPrintf("%.0f %0.f %0.f\n", angles[0], angles[1], angles[2] ); + //Con_DPrintf( "%.0f %0.f %0.f\n", modelpos[0], modelpos[1], modelpos[2] ); + //Con_DPrintf( "%.0f %0.f %0.f\n", angles[0], angles[1], angles[2] ); angles[PITCH] = -angles[PITCH]; - AngleMatrix (angles, (*m_protationmatrix)); + AngleMatrix( angles, ( *m_protationmatrix ) ); - if ( !IEngineStudio.IsHardware() ) + if( !IEngineStudio.IsHardware() ) { static float viewmatrix[3][4]; - VectorCopy (m_vRight, viewmatrix[0]); - VectorCopy (m_vUp, viewmatrix[1]); - VectorInverse (viewmatrix[1]); - VectorCopy (m_vNormal, viewmatrix[2]); + VectorCopy( m_vRight, viewmatrix[0] ); + VectorCopy( m_vUp, viewmatrix[1] ); + VectorInverse( viewmatrix[1] ); + VectorCopy( m_vNormal, viewmatrix[2] ); (*m_protationmatrix)[0][3] = modelpos[0] - m_vRenderOrigin[0]; (*m_protationmatrix)[1][3] = modelpos[1] - m_vRenderOrigin[1]; (*m_protationmatrix)[2][3] = modelpos[2] - m_vRenderOrigin[2]; - ConcatTransforms (viewmatrix, (*m_protationmatrix), (*m_paliastransform)); + ConcatTransforms( viewmatrix, (*m_protationmatrix), (*m_paliastransform) ); // do the scaling up of x and y to screen coordinates as part of the transform // for the unclipped case (it would mess up clipping in the clipped case). // Also scale down z, so 1/z is scaled 31 bits for free, and scale down x and y // correspondingly so the projected x and y come out right // FIXME: make this work for clipped case too? - if (trivial_accept) + if( trivial_accept ) { - for (i=0 ; i<4 ; i++) + for( i = 0; i < 4; i++ ) { - (*m_paliastransform)[0][i] *= m_fSoftwareXScale * - (1.0 / (ZISCALE * 0x10000)); - (*m_paliastransform)[1][i] *= m_fSoftwareYScale * - (1.0 / (ZISCALE * 0x10000)); - (*m_paliastransform)[2][i] *= 1.0 / (ZISCALE * 0x10000); - + (*m_paliastransform)[0][i] *= m_fSoftwareXScale * ( 1.0 / ( ZISCALE * 0x10000 ) ); + (*m_paliastransform)[1][i] *= m_fSoftwareYScale * ( 1.0 / ( ZISCALE * 0x10000 ) ); + (*m_paliastransform)[2][i] *= 1.0 / ( ZISCALE * 0x10000 ); } } } @@ -561,7 +559,6 @@ void CStudioModelRenderer::StudioSetUpTransform (int trivial_accept) (*m_protationmatrix)[2][3] = modelpos[2]; } - /* ==================== StudioEstimateInterpolant @@ -572,10 +569,10 @@ float CStudioModelRenderer::StudioEstimateInterpolant( void ) { float dadt = 1.0; - if ( m_fDoInterp && ( m_pCurrentEntity->curstate.animtime >= m_pCurrentEntity->latched.prevanimtime + 0.01 ) ) + if( m_fDoInterp && ( m_pCurrentEntity->curstate.animtime >= m_pCurrentEntity->latched.prevanimtime + 0.01 ) ) { - dadt = (m_clTime - m_pCurrentEntity->curstate.animtime) / 0.1; - if (dadt > 2.0) + dadt = ( m_clTime - m_pCurrentEntity->curstate.animtime ) / 0.1; + if( dadt > 2.0 ) { dadt = 2.0; } @@ -589,78 +586,77 @@ StudioCalcRotations ==================== */ -void CStudioModelRenderer::StudioCalcRotations ( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f ) +void CStudioModelRenderer::StudioCalcRotations( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f ) { - int i; - int frame; - mstudiobone_t *pbone; + int i; + int frame; + mstudiobone_t *pbone; - float s; - float adj[MAXSTUDIOCONTROLLERS]; - float dadt; + float s; + float adj[MAXSTUDIOCONTROLLERS]; + float dadt; - if (f > pseqdesc->numframes - 1) + if( f > pseqdesc->numframes - 1 ) { f = 0; // bah, fix this bug with changing sequences too fast } // BUG ( somewhere else ) but this code should validate this data. // This could cause a crash if the frame # is negative, so we'll go ahead // and clamp it here - else if ( f < -0.01 ) + else if( f < -0.01 ) { f = -0.01; } frame = (int)f; - // Con_DPrintf("%d %.4f %.4f %.4f %.4f %d\n", m_pCurrentEntity->curstate.sequence, m_clTime, m_pCurrentEntity->animtime, m_pCurrentEntity->frame, f, frame ); + // Con_DPrintf( "%d %.4f %.4f %.4f %.4f %d\n", m_pCurrentEntity->curstate.sequence, m_clTime, m_pCurrentEntity->animtime, m_pCurrentEntity->frame, f, frame ); // Con_DPrintf( "%f %f %f\n", m_pCurrentEntity->angles[ROLL], m_pCurrentEntity->angles[PITCH], m_pCurrentEntity->angles[YAW] ); - // Con_DPrintf("frame %d %d\n", frame1, frame2 ); - + // Con_DPrintf( "frame %d %d\n", frame1, frame2 ); - dadt = StudioEstimateInterpolant( ); - s = (f - frame); + dadt = StudioEstimateInterpolant(); + s = ( f - frame ); // add in programtic controllers - pbone = (mstudiobone_t *)((byte *)m_pStudioHeader + m_pStudioHeader->boneindex); + pbone = (mstudiobone_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->boneindex ); StudioCalcBoneAdj( dadt, adj, m_pCurrentEntity->curstate.controller, m_pCurrentEntity->latched.prevcontroller, m_pCurrentEntity->mouth.mouthopen ); - for (i = 0; i < m_pStudioHeader->numbones; i++, pbone++, panim++) + for( i = 0; i < m_pStudioHeader->numbones; i++, pbone++, panim++ ) { StudioCalcBoneQuaterion( frame, s, pbone, panim, adj, q[i] ); StudioCalcBonePosition( frame, s, pbone, panim, adj, pos[i] ); - // if (0 && i == 0) - // Con_DPrintf("%d %d %d %d\n", m_pCurrentEntity->curstate.sequence, frame, j, k ); + // if( 0 && i == 0 ) + // Con_DPrintf( "%d %d %d %d\n", m_pCurrentEntity->curstate.sequence, frame, j, k ); } - if (pseqdesc->motiontype & STUDIO_X) + if( pseqdesc->motiontype & STUDIO_X ) { pos[pseqdesc->motionbone][0] = 0.0; } - if (pseqdesc->motiontype & STUDIO_Y) + if( pseqdesc->motiontype & STUDIO_Y ) { pos[pseqdesc->motionbone][1] = 0.0; } - if (pseqdesc->motiontype & STUDIO_Z) + if( pseqdesc->motiontype & STUDIO_Z ) { pos[pseqdesc->motionbone][2] = 0.0; } - s = 0 * ((1.0 - (f - (int)(f))) / (pseqdesc->numframes)) * m_pCurrentEntity->curstate.framerate; + s = 0 * ( ( 1.0 - ( f - (int)( f ) ) ) / ( pseqdesc->numframes ) ) * m_pCurrentEntity->curstate.framerate; - if (pseqdesc->motiontype & STUDIO_LX) + if( pseqdesc->motiontype & STUDIO_LX ) { pos[pseqdesc->motionbone][0] += s * pseqdesc->linearmovement[0]; } - if (pseqdesc->motiontype & STUDIO_LY) + if( pseqdesc->motiontype & STUDIO_LY ) { pos[pseqdesc->motionbone][1] += s * pseqdesc->linearmovement[1]; } - if (pseqdesc->motiontype & STUDIO_LZ) + if( pseqdesc->motiontype & STUDIO_LZ ) { pos[pseqdesc->motionbone][2] += s * pseqdesc->linearmovement[2]; } @@ -678,36 +674,35 @@ void CStudioModelRenderer::StudioFxTransform( cl_entity_t *ent, float transform[ { case kRenderFxDistort: case kRenderFxHologram: - if ( gEngfuncs.pfnRandomLong(0,49) == 0 ) + if( gEngfuncs.pfnRandomLong( 0, 49 ) == 0 ) { - int axis = gEngfuncs.pfnRandomLong(0,1); - if ( axis == 1 ) // Choose between x & z + int axis = gEngfuncs.pfnRandomLong( 0, 1 ); + if( axis == 1 ) // Choose between x & z axis = 2; - VectorScale( transform[axis], gEngfuncs.pfnRandomFloat(1,1.484), transform[axis] ); + VectorScale( transform[axis], gEngfuncs.pfnRandomFloat( 1, 1.484 ), transform[axis] ); } - else if ( gEngfuncs.pfnRandomLong(0,49) == 0 ) + else if( gEngfuncs.pfnRandomLong( 0, 49 ) == 0 ) { float offset; int axis = gEngfuncs.pfnRandomLong(0,1); - if ( axis == 1 ) // Choose between x & z + if( axis == 1 ) // Choose between x & z axis = 2; - offset = gEngfuncs.pfnRandomFloat(-10,10); - transform[gEngfuncs.pfnRandomLong(0,2)][3] += offset; + offset = gEngfuncs.pfnRandomFloat( -10, 10 ); + transform[gEngfuncs.pfnRandomLong( 0, 2 )][3] += offset; } break; case kRenderFxExplode: { float scale; - scale = 1.0 + ( m_clTime - ent->curstate.animtime) * 10.0; - if ( scale > 2 ) // Don't blow up more than 200% + scale = 1.0 + ( m_clTime - ent->curstate.animtime ) * 10.0; + if( scale > 2 ) // Don't blow up more than 200% scale = 2; transform[0][1] *= scale; transform[1][1] *= scale; transform[2][1] *= scale; } break; - } } @@ -719,18 +714,17 @@ StudioEstimateFrame */ float CStudioModelRenderer::StudioEstimateFrame( mstudioseqdesc_t *pseqdesc ) { - double dfdt, f; + double dfdt, f; - if ( m_fDoInterp ) + if( m_fDoInterp ) { - if ( m_clTime < m_pCurrentEntity->curstate.animtime ) + if( m_clTime < m_pCurrentEntity->curstate.animtime ) { dfdt = 0; } else { - dfdt = (m_clTime - m_pCurrentEntity->curstate.animtime) * m_pCurrentEntity->curstate.framerate * pseqdesc->fps; - + dfdt = ( m_clTime - m_pCurrentEntity->curstate.animtime ) * m_pCurrentEntity->curstate.framerate * pseqdesc->fps; } } else @@ -738,35 +732,35 @@ float CStudioModelRenderer::StudioEstimateFrame( mstudioseqdesc_t *pseqdesc ) dfdt = 0; } - if (pseqdesc->numframes <= 1) + if( pseqdesc->numframes <= 1 ) { f = 0; } else { - f = (m_pCurrentEntity->curstate.frame * (pseqdesc->numframes - 1)) / 256.0; + f = ( m_pCurrentEntity->curstate.frame * ( pseqdesc->numframes - 1 ) ) / 256.0; } - + f += dfdt; - if (pseqdesc->flags & STUDIO_LOOPING) + if( pseqdesc->flags & STUDIO_LOOPING ) { - if (pseqdesc->numframes > 1) + if( pseqdesc->numframes > 1 ) { - f -= (int)(f / (pseqdesc->numframes - 1)) * (pseqdesc->numframes - 1); + f -= (int)( f / ( pseqdesc->numframes - 1 ) ) * ( pseqdesc->numframes - 1 ); } - if (f < 0) + if( f < 0 ) { - f += (pseqdesc->numframes - 1); + f += ( pseqdesc->numframes - 1 ); } } else { - if (f >= pseqdesc->numframes - 1.001) + if( f >= pseqdesc->numframes - 1.001 ) { f = pseqdesc->numframes - 1.001; } - if (f < 0.0) + if( f < 0.0 ) { f = 0.0; } @@ -780,57 +774,57 @@ StudioSetupBones ==================== */ -void CStudioModelRenderer::StudioSetupBones ( void ) +void CStudioModelRenderer::StudioSetupBones( void ) { - int i, j; - double f; + int i, j; + double f; - mstudiobone_t *pbones; - mstudioseqdesc_t *pseqdesc; - mstudioanim_t *panim; + mstudiobone_t *pbones; + mstudioseqdesc_t *pseqdesc; + mstudioanim_t *panim; - static float pos[MAXSTUDIOBONES][3]; - static vec4_t q[MAXSTUDIOBONES]; - float bonematrix[3][4]; + static float pos[MAXSTUDIOBONES][3]; + static vec4_t q[MAXSTUDIOBONES]; + float bonematrix[3][4]; - static float pos2[MAXSTUDIOBONES][3]; - static vec4_t q2[MAXSTUDIOBONES]; - static float pos3[MAXSTUDIOBONES][3]; - static vec4_t q3[MAXSTUDIOBONES]; - static float pos4[MAXSTUDIOBONES][3]; - static vec4_t q4[MAXSTUDIOBONES]; + static float pos2[MAXSTUDIOBONES][3]; + static vec4_t q2[MAXSTUDIOBONES]; + static float pos3[MAXSTUDIOBONES][3]; + static vec4_t q3[MAXSTUDIOBONES]; + static float pos4[MAXSTUDIOBONES][3]; + static vec4_t q4[MAXSTUDIOBONES]; - if (m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq) + if( m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq ) { m_pCurrentEntity->curstate.sequence = 0; } - pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence; + pseqdesc = (mstudioseqdesc_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->seqindex ) + m_pCurrentEntity->curstate.sequence; f = StudioEstimateFrame( pseqdesc ); - if (m_pCurrentEntity->latched.prevframe > f) + if( m_pCurrentEntity->latched.prevframe > f ) { - //Con_DPrintf("%f %f\n", m_pCurrentEntity->prevframe, f ); + //Con_DPrintf( "%f %f\n", m_pCurrentEntity->prevframe, f ); } panim = StudioGetAnim( m_pRenderModel, pseqdesc ); StudioCalcRotations( pos, q, pseqdesc, panim, f ); - if (pseqdesc->numblends > 1) + if( pseqdesc->numblends > 1 ) { - float s; - float dadt; + float s; + float dadt; panim += m_pStudioHeader->numbones; StudioCalcRotations( pos2, q2, pseqdesc, panim, f ); dadt = StudioEstimateInterpolant(); - s = (m_pCurrentEntity->curstate.blending[0] * dadt + m_pCurrentEntity->latched.prevblending[0] * (1.0 - dadt)) / 255.0; + s = ( m_pCurrentEntity->curstate.blending[0] * dadt + m_pCurrentEntity->latched.prevblending[0] * ( 1.0 - dadt ) ) / 255.0; StudioSlerpBones( q, pos, q2, pos2, s ); - if (pseqdesc->numblends == 4) + if( pseqdesc->numblends == 4 ) { panim += m_pStudioHeader->numbones; StudioCalcRotations( pos3, q3, pseqdesc, panim, f ); @@ -838,30 +832,29 @@ void CStudioModelRenderer::StudioSetupBones ( void ) panim += m_pStudioHeader->numbones; StudioCalcRotations( pos4, q4, pseqdesc, panim, f ); - s = (m_pCurrentEntity->curstate.blending[0] * dadt + m_pCurrentEntity->latched.prevblending[0] * (1.0 - dadt)) / 255.0; + s = ( m_pCurrentEntity->curstate.blending[0] * dadt + m_pCurrentEntity->latched.prevblending[0] * ( 1.0 - dadt ) ) / 255.0; StudioSlerpBones( q3, pos3, q4, pos4, s ); - s = (m_pCurrentEntity->curstate.blending[1] * dadt + m_pCurrentEntity->latched.prevblending[1] * (1.0 - dadt)) / 255.0; + s = ( m_pCurrentEntity->curstate.blending[1] * dadt + m_pCurrentEntity->latched.prevblending[1] * ( 1.0 - dadt ) ) / 255.0; StudioSlerpBones( q, pos, q3, pos3, s ); } } - if (m_fDoInterp && - m_pCurrentEntity->latched.sequencetime && + if( m_fDoInterp && m_pCurrentEntity->latched.sequencetime && ( m_pCurrentEntity->latched.sequencetime + 0.2 > m_clTime ) && - ( m_pCurrentEntity->latched.prevsequence < m_pStudioHeader->numseq )) + ( m_pCurrentEntity->latched.prevsequence < m_pStudioHeader->numseq ) ) { // blend from last sequence - static float pos1b[MAXSTUDIOBONES][3]; - static vec4_t q1b[MAXSTUDIOBONES]; - float s; + static float pos1b[MAXSTUDIOBONES][3]; + static vec4_t q1b[MAXSTUDIOBONES]; + float s; - pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->latched.prevsequence; + pseqdesc = (mstudioseqdesc_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->seqindex ) + m_pCurrentEntity->latched.prevsequence; panim = StudioGetAnim( m_pRenderModel, pseqdesc ); // clip prevframe StudioCalcRotations( pos1b, q1b, pseqdesc, panim, m_pCurrentEntity->latched.prevframe ); - if (pseqdesc->numblends > 1) + if( pseqdesc->numblends > 1 ) { panim += m_pStudioHeader->numbones; StudioCalcRotations( pos2, q2, pseqdesc, panim, m_pCurrentEntity->latched.prevframe ); @@ -869,7 +862,7 @@ void CStudioModelRenderer::StudioSetupBones ( void ) s = (m_pCurrentEntity->latched.prevseqblending[0]) / 255.0; StudioSlerpBones( q1b, pos1b, q2, pos2, s ); - if (pseqdesc->numblends == 4) + if( pseqdesc->numblends == 4 ) { panim += m_pStudioHeader->numbones; StudioCalcRotations( pos3, q3, pseqdesc, panim, m_pCurrentEntity->latched.prevframe ); @@ -877,15 +870,15 @@ void CStudioModelRenderer::StudioSetupBones ( void ) panim += m_pStudioHeader->numbones; StudioCalcRotations( pos4, q4, pseqdesc, panim, m_pCurrentEntity->latched.prevframe ); - s = (m_pCurrentEntity->latched.prevseqblending[0]) / 255.0; + s = ( m_pCurrentEntity->latched.prevseqblending[0] ) / 255.0; StudioSlerpBones( q3, pos3, q4, pos4, s ); - s = (m_pCurrentEntity->latched.prevseqblending[1]) / 255.0; + s = ( m_pCurrentEntity->latched.prevseqblending[1] ) / 255.0; StudioSlerpBones( q1b, pos1b, q3, pos3, s ); } } - s = 1.0 - (m_clTime - m_pCurrentEntity->latched.sequencetime) / 0.2; + s = 1.0 - ( m_clTime - m_pCurrentEntity->latched.sequencetime ) / 0.2; StudioSlerpBones( q, pos, q1b, pos1b, s ); } else @@ -894,39 +887,39 @@ void CStudioModelRenderer::StudioSetupBones ( void ) m_pCurrentEntity->latched.prevframe = f; } - pbones = (mstudiobone_t *)((byte *)m_pStudioHeader + m_pStudioHeader->boneindex); + pbones = (mstudiobone_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->boneindex ); // calc gait animation - if (m_pPlayerInfo && m_pPlayerInfo->gaitsequence != 0) + if( m_pPlayerInfo && m_pPlayerInfo->gaitsequence != 0 ) { - if (m_pPlayerInfo->gaitsequence >= m_pStudioHeader->numseq) + if( m_pPlayerInfo->gaitsequence >= m_pStudioHeader->numseq ) { m_pPlayerInfo->gaitsequence = 0; } - pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pPlayerInfo->gaitsequence; + pseqdesc = (mstudioseqdesc_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->seqindex ) + m_pPlayerInfo->gaitsequence; panim = StudioGetAnim( m_pRenderModel, pseqdesc ); StudioCalcRotations( pos2, q2, pseqdesc, panim, m_pPlayerInfo->gaitframe ); - for (i = 0; i < m_pStudioHeader->numbones; i++) + for( i = 0; i < m_pStudioHeader->numbones; i++ ) { for( j = 0; j < LEGS_BONES_COUNT; j++ ) { - if( !strcmp( pbones[i].name, legs_bones[j] )) + if( !strcmp( pbones[i].name, legs_bones[j] ) ) break; } if( j == LEGS_BONES_COUNT ) continue; // not used for legs - memcpy( pos[i], pos2[i], sizeof( pos[i] )); - memcpy( q[i], q2[i], sizeof( q[i] )); + memcpy( pos[i], pos2[i], sizeof(pos[i]) ); + memcpy( q[i], q2[i], sizeof(q[i]) ); } } - for (i = 0; i < m_pStudioHeader->numbones; i++) + for( i = 0; i < m_pStudioHeader->numbones; i++ ) { QuaternionMatrix( q[i], bonematrix ); @@ -934,20 +927,20 @@ void CStudioModelRenderer::StudioSetupBones ( void ) bonematrix[1][3] = pos[i][1]; bonematrix[2][3] = pos[i][2]; - if (pbones[i].parent == -1) + if( pbones[i].parent == -1 ) { - if ( IEngineStudio.IsHardware() ) + if( IEngineStudio.IsHardware() ) { - ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_pbonetransform)[i]); + ConcatTransforms( (*m_protationmatrix), bonematrix, (*m_pbonetransform)[i] ); // MatrixCopy should be faster... - //ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]); + //ConcatTransforms( (*m_protationmatrix), bonematrix, (*m_plighttransform)[i] ); MatrixCopy( (*m_pbonetransform)[i], (*m_plighttransform)[i] ); } else { - ConcatTransforms ((*m_paliastransform), bonematrix, (*m_pbonetransform)[i]); - ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]); + ConcatTransforms( (*m_paliastransform), bonematrix, (*m_pbonetransform)[i] ); + ConcatTransforms( (*m_protationmatrix), bonematrix, (*m_plighttransform)[i] ); } // Apply client-side effects to the transformation matrix @@ -955,13 +948,12 @@ void CStudioModelRenderer::StudioSetupBones ( void ) } else { - ConcatTransforms ((*m_pbonetransform)[pbones[i].parent], bonematrix, (*m_pbonetransform)[i]); - ConcatTransforms ((*m_plighttransform)[pbones[i].parent], bonematrix, (*m_plighttransform)[i]); + ConcatTransforms( (*m_pbonetransform)[pbones[i].parent], bonematrix, (*m_pbonetransform)[i] ); + ConcatTransforms( (*m_plighttransform)[pbones[i].parent], bonematrix, (*m_plighttransform)[i] ); } } } - /* ==================== StudioSaveBones @@ -970,14 +962,14 @@ StudioSaveBones */ void CStudioModelRenderer::StudioSaveBones( void ) { - int i; + int i; - mstudiobone_t *pbones; - pbones = (mstudiobone_t *)((byte *)m_pStudioHeader + m_pStudioHeader->boneindex); + mstudiobone_t *pbones; + pbones = (mstudiobone_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->boneindex ); m_nCachedBones = m_pStudioHeader->numbones; - for (i = 0; i < m_pStudioHeader->numbones; i++) + for( i = 0; i < m_pStudioHeader->numbones; i++ ) { strcpy( m_nCachedBoneNames[i], pbones[i].name ); MatrixCopy( (*m_pbonetransform)[i], m_rgCachedBoneTransform[i] ); @@ -985,59 +977,57 @@ void CStudioModelRenderer::StudioSaveBones( void ) } } - /* ==================== StudioMergeBones ==================== */ -void CStudioModelRenderer::StudioMergeBones ( model_t *m_pSubModel ) +void CStudioModelRenderer::StudioMergeBones( model_t *m_pSubModel ) { - int i, j; - double f; - int do_hunt = true; + int i, j; + double f; + int do_hunt = true; - mstudiobone_t *pbones; - mstudioseqdesc_t *pseqdesc; - mstudioanim_t *panim; + mstudiobone_t *pbones; + mstudioseqdesc_t *pseqdesc; + mstudioanim_t *panim; - static float pos[MAXSTUDIOBONES][3]; - float bonematrix[3][4]; - static vec4_t q[MAXSTUDIOBONES]; + static float pos[MAXSTUDIOBONES][3]; + float bonematrix[3][4]; + static vec4_t q[MAXSTUDIOBONES]; - if (m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq) + if( m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq ) { m_pCurrentEntity->curstate.sequence = 0; } - pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence; + pseqdesc = (mstudioseqdesc_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->seqindex ) + m_pCurrentEntity->curstate.sequence; f = StudioEstimateFrame( pseqdesc ); - if (m_pCurrentEntity->latched.prevframe > f) + if( m_pCurrentEntity->latched.prevframe > f ) { - //Con_DPrintf("%f %f\n", m_pCurrentEntity->prevframe, f ); + //Con_DPrintf( "%f %f\n", m_pCurrentEntity->prevframe, f ); } panim = StudioGetAnim( m_pSubModel, pseqdesc ); StudioCalcRotations( pos, q, pseqdesc, panim, f ); - pbones = (mstudiobone_t *)((byte *)m_pStudioHeader + m_pStudioHeader->boneindex); + pbones = (mstudiobone_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->boneindex ); - - for (i = 0; i < m_pStudioHeader->numbones; i++) + for( i = 0; i < m_pStudioHeader->numbones; i++ ) { - for (j = 0; j < m_nCachedBones; j++) + for( j = 0; j < m_nCachedBones; j++ ) { - if (stricmp(pbones[i].name, m_nCachedBoneNames[j]) == 0) + if( stricmp( pbones[i].name, m_nCachedBoneNames[j] ) == 0 ) { MatrixCopy( m_rgCachedBoneTransform[j], (*m_pbonetransform)[i] ); MatrixCopy( m_rgCachedLightTransform[j], (*m_plighttransform)[i] ); break; } } - if (j >= m_nCachedBones) + if( j >= m_nCachedBones ) { QuaternionMatrix( q[i], bonematrix ); @@ -1045,20 +1035,20 @@ void CStudioModelRenderer::StudioMergeBones ( model_t *m_pSubModel ) bonematrix[1][3] = pos[i][1]; bonematrix[2][3] = pos[i][2]; - if (pbones[i].parent == -1) + if( pbones[i].parent == -1 ) { - if ( IEngineStudio.IsHardware() ) + if( IEngineStudio.IsHardware() ) { - ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_pbonetransform)[i]); + ConcatTransforms( (*m_protationmatrix), bonematrix, (*m_pbonetransform)[i] ); // MatrixCopy should be faster... - //ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]); + //ConcatTransforms( (*m_protationmatrix), bonematrix, (*m_plighttransform)[i] ); MatrixCopy( (*m_pbonetransform)[i], (*m_plighttransform)[i] ); } else { - ConcatTransforms ((*m_paliastransform), bonematrix, (*m_pbonetransform)[i]); - ConcatTransforms ((*m_protationmatrix), bonematrix, (*m_plighttransform)[i]); + ConcatTransforms( (*m_paliastransform), bonematrix, (*m_pbonetransform)[i] ); + ConcatTransforms( (*m_protationmatrix), bonematrix, (*m_plighttransform)[i] ); } // Apply client-side effects to the transformation matrix @@ -1066,8 +1056,8 @@ void CStudioModelRenderer::StudioMergeBones ( model_t *m_pSubModel ) } else { - ConcatTransforms ((*m_pbonetransform)[pbones[i].parent], bonematrix, (*m_pbonetransform)[i]); - ConcatTransforms ((*m_plighttransform)[pbones[i].parent], bonematrix, (*m_plighttransform)[i]); + ConcatTransforms( (*m_pbonetransform)[pbones[i].parent], bonematrix, (*m_pbonetransform)[i] ); + ConcatTransforms( (*m_plighttransform)[pbones[i].parent], bonematrix, (*m_plighttransform)[i] ); } } } @@ -1089,18 +1079,18 @@ int CStudioModelRenderer::StudioDrawModel( int flags ) IEngineStudio.GetViewInfo( m_vRenderOrigin, m_vUp, m_vRight, m_vNormal ); IEngineStudio.GetAliasScale( &m_fSoftwareXScale, &m_fSoftwareYScale ); - if (m_pCurrentEntity->curstate.renderfx == kRenderFxDeadPlayer) + if( m_pCurrentEntity->curstate.renderfx == kRenderFxDeadPlayer ) { entity_state_t deadplayer; int result; int save_interp; - if (m_pCurrentEntity->curstate.renderamt <= 0 || m_pCurrentEntity->curstate.renderamt > gEngfuncs.GetMaxClients() ) + if( m_pCurrentEntity->curstate.renderamt <= 0 || m_pCurrentEntity->curstate.renderamt > gEngfuncs.GetMaxClients() ) return 0; // get copy of player - deadplayer = *(IEngineStudio.GetPlayerState( m_pCurrentEntity->curstate.renderamt - 1 )); //cl.frames[cl.parsecount & CL_UPDATE_MASK].playerstate[m_pCurrentEntity->curstate.renderamt-1]; + deadplayer = *( IEngineStudio.GetPlayerState( m_pCurrentEntity->curstate.renderamt - 1 ) ); //cl.frames[cl.parsecount & CL_UPDATE_MASK].playerstate[m_pCurrentEntity->curstate.renderamt - 1]; // clear weapon, movement state deadplayer.number = m_pCurrentEntity->curstate.renderamt; @@ -1122,65 +1112,65 @@ int CStudioModelRenderer::StudioDrawModel( int flags ) } m_pRenderModel = m_pCurrentEntity->model; - m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata (m_pRenderModel); + m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata( m_pRenderModel ); IEngineStudio.StudioSetHeader( m_pStudioHeader ); IEngineStudio.SetRenderModel( m_pRenderModel ); StudioSetUpTransform( 0 ); - if (flags & STUDIO_RENDER) + if( flags & STUDIO_RENDER ) { // see if the bounding box lets us trivially reject, also sets - if (!IEngineStudio.StudioCheckBBox ()) + if( !IEngineStudio.StudioCheckBBox() ) return 0; - (*m_pModelsDrawn)++; - (*m_pStudioModelCount)++; // render data cache cookie + ( *m_pModelsDrawn )++; + ( *m_pStudioModelCount )++; // render data cache cookie - if (m_pStudioHeader->numbodyparts == 0) + if( m_pStudioHeader->numbodyparts == 0 ) return 1; } - if (m_pCurrentEntity->curstate.movetype == MOVETYPE_FOLLOW) + if( m_pCurrentEntity->curstate.movetype == MOVETYPE_FOLLOW ) { StudioMergeBones( m_pRenderModel ); } else { - StudioSetupBones( ); + StudioSetupBones(); } - StudioSaveBones( ); + StudioSaveBones(); - if (flags & STUDIO_EVENTS) + if( flags & STUDIO_EVENTS ) { - StudioCalcAttachments( ); - IEngineStudio.StudioClientEvents( ); + StudioCalcAttachments(); + IEngineStudio.StudioClientEvents(); // copy attachments into global entity array - if ( m_pCurrentEntity->index > 0 ) + if( m_pCurrentEntity->index > 0 ) { cl_entity_t *ent = gEngfuncs.GetEntityByIndex( m_pCurrentEntity->index ); - memcpy( ent->attachment, m_pCurrentEntity->attachment, sizeof( vec3_t ) * 4 ); + memcpy( ent->attachment, m_pCurrentEntity->attachment, sizeof(vec3_t) * 4 ); } } - if (flags & STUDIO_RENDER) + if( flags & STUDIO_RENDER ) { lighting.plightvec = dir; - IEngineStudio.StudioDynamicLight(m_pCurrentEntity, &lighting ); + IEngineStudio.StudioDynamicLight( m_pCurrentEntity, &lighting ); IEngineStudio.StudioEntityLight( &lighting ); // model and frame independant - IEngineStudio.StudioSetupLighting (&lighting); + IEngineStudio.StudioSetupLighting( &lighting ); // get remap colors m_nTopColor = m_pCurrentEntity->curstate.colormap & 0xFF; - m_nBottomColor = (m_pCurrentEntity->curstate.colormap & 0xFF00) >> 8; + m_nBottomColor = ( m_pCurrentEntity->curstate.colormap & 0xFF00 ) >> 8; IEngineStudio.StudioSetRemapColors( m_nTopColor, m_nBottomColor ); - StudioRenderModel( ); + StudioRenderModel(); } return 1; @@ -1197,25 +1187,25 @@ void CStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer ) float dt; vec3_t est_velocity; - dt = (m_clTime - m_clOldTime); - if (dt < 0) + dt = ( m_clTime - m_clOldTime ); + if( dt < 0 ) dt = 0; - else if (dt > 1.0) + else if( dt > 1.0 ) dt = 1; - if (dt == 0 || m_pPlayerInfo->renderframe == m_nFrameCount) + if( dt == 0 || m_pPlayerInfo->renderframe == m_nFrameCount ) { m_flGaitMovement = 0; return; } // VectorAdd( pplayer->velocity, pplayer->prediction_error, est_velocity ); - if ( m_fGaitEstimation ) + if( m_fGaitEstimation ) { VectorSubtract( m_pCurrentEntity->origin, m_pPlayerInfo->prevgaitorigin, est_velocity ); VectorCopy( m_pCurrentEntity->origin, m_pPlayerInfo->prevgaitorigin ); m_flGaitMovement = Length( est_velocity ); - if (dt <= 0 || m_flGaitMovement / dt < 5) + if( dt <= 0 || m_flGaitMovement / dt < 5 ) { m_flGaitMovement = 0; est_velocity[0] = 0; @@ -1228,34 +1218,33 @@ void CStudioModelRenderer::StudioEstimateGait( entity_state_t *pplayer ) m_flGaitMovement = Length( est_velocity ) * dt; } - if (est_velocity[1] == 0 && est_velocity[0] == 0) + if( est_velocity[1] == 0 && est_velocity[0] == 0 ) { float flYawDiff = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw; - flYawDiff = flYawDiff - (int)(flYawDiff / 360) * 360; - if (flYawDiff > 180) + flYawDiff = flYawDiff - (int)( flYawDiff / 360 ) * 360; + if( flYawDiff > 180 ) flYawDiff -= 360; - if (flYawDiff < -180) + if( flYawDiff < -180 ) flYawDiff += 360; - if (dt < 0.25) + if( dt < 0.25 ) flYawDiff *= dt * 4; else flYawDiff *= dt; m_pPlayerInfo->gaityaw += flYawDiff; - m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)(m_pPlayerInfo->gaityaw / 360) * 360; + m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - (int)( m_pPlayerInfo->gaityaw / 360 ) * 360; m_flGaitMovement = 0; } else { - m_pPlayerInfo->gaityaw = (atan2(est_velocity[1], est_velocity[0]) * 180 / M_PI); - if (m_pPlayerInfo->gaityaw > 180) + m_pPlayerInfo->gaityaw = ( atan2( est_velocity[1], est_velocity[0] ) * 180 / M_PI ); + if( m_pPlayerInfo->gaityaw > 180 ) m_pPlayerInfo->gaityaw = 180; - if (m_pPlayerInfo->gaityaw < -180) + if( m_pPlayerInfo->gaityaw < -180 ) m_pPlayerInfo->gaityaw = -180; } - } /* @@ -1266,17 +1255,17 @@ StudioProcessGait */ void CStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer ) { - mstudioseqdesc_t *pseqdesc; + mstudioseqdesc_t *pseqdesc; float dt; int iBlend; float flYaw; // view direction relative to movement - if (m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq) + if( m_pCurrentEntity->curstate.sequence >= m_pStudioHeader->numseq ) { m_pCurrentEntity->curstate.sequence = 0; } - pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + m_pCurrentEntity->curstate.sequence; + pseqdesc = (mstudioseqdesc_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->seqindex ) + m_pCurrentEntity->curstate.sequence; StudioPlayerBlend( pseqdesc, &iBlend, &m_pCurrentEntity->angles[PITCH] ); @@ -1285,33 +1274,33 @@ void CStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer ) m_pCurrentEntity->latched.prevblending[0] = m_pCurrentEntity->curstate.blending[0]; m_pCurrentEntity->latched.prevseqblending[0] = m_pCurrentEntity->curstate.blending[0]; - // Con_DPrintf("%f %d\n", m_pCurrentEntity->angles[PITCH], m_pCurrentEntity->blending[0] ); + // Con_DPrintf( "%f %d\n", m_pCurrentEntity->angles[PITCH], m_pCurrentEntity->blending[0] ); - dt = (m_clTime - m_clOldTime); - if (dt < 0) + dt = ( m_clTime - m_clOldTime ); + if( dt < 0 ) dt = 0; - else if (dt > 1.0) + else if( dt > 1.0 ) dt = 1; StudioEstimateGait( pplayer ); - // Con_DPrintf("%f %f\n", m_pCurrentEntity->angles[YAW], m_pPlayerInfo->gaityaw ); + // Con_DPrintf( "%f %f\n", m_pCurrentEntity->angles[YAW], m_pPlayerInfo->gaityaw ); // calc side to side turning flYaw = m_pCurrentEntity->angles[YAW] - m_pPlayerInfo->gaityaw; - flYaw = flYaw - (int)(flYaw / 360) * 360; - if (flYaw < -180) + flYaw = flYaw - (int)( flYaw / 360 ) * 360; + if( flYaw < -180 ) flYaw = flYaw + 360; - if (flYaw > 180) + if( flYaw > 180 ) flYaw = flYaw - 360; - if (flYaw > 120) + if( flYaw > 120 ) { m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw - 180; m_flGaitMovement = -m_flGaitMovement; flYaw = flYaw - 180; } - else if (flYaw < -120) + else if( flYaw < -120 ) { m_pPlayerInfo->gaityaw = m_pPlayerInfo->gaityaw + 180; m_flGaitMovement = -m_flGaitMovement; @@ -1319,31 +1308,31 @@ void CStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer ) } // adjust torso - m_pCurrentEntity->curstate.controller[0] = ((flYaw / 4.0) + 30) / (60.0 / 255.0); - m_pCurrentEntity->curstate.controller[1] = ((flYaw / 4.0) + 30) / (60.0 / 255.0); - m_pCurrentEntity->curstate.controller[2] = ((flYaw / 4.0) + 30) / (60.0 / 255.0); - m_pCurrentEntity->curstate.controller[3] = ((flYaw / 4.0) + 30) / (60.0 / 255.0); + m_pCurrentEntity->curstate.controller[0] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 ); + m_pCurrentEntity->curstate.controller[1] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 ); + m_pCurrentEntity->curstate.controller[2] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 ); + m_pCurrentEntity->curstate.controller[3] = ( ( flYaw / 4.0 ) + 30 ) / ( 60.0 / 255.0 ); m_pCurrentEntity->latched.prevcontroller[0] = m_pCurrentEntity->curstate.controller[0]; m_pCurrentEntity->latched.prevcontroller[1] = m_pCurrentEntity->curstate.controller[1]; m_pCurrentEntity->latched.prevcontroller[2] = m_pCurrentEntity->curstate.controller[2]; m_pCurrentEntity->latched.prevcontroller[3] = m_pCurrentEntity->curstate.controller[3]; m_pCurrentEntity->angles[YAW] = m_pPlayerInfo->gaityaw; - if (m_pCurrentEntity->angles[YAW] < -0) + if( m_pCurrentEntity->angles[YAW] < -0 ) m_pCurrentEntity->angles[YAW] += 360; m_pCurrentEntity->latched.prevangles[YAW] = m_pCurrentEntity->angles[YAW]; - if (pplayer->gaitsequence >= m_pStudioHeader->numseq) + if( pplayer->gaitsequence >= m_pStudioHeader->numseq ) { pplayer->gaitsequence = 0; } - pseqdesc = (mstudioseqdesc_t *)((byte *)m_pStudioHeader + m_pStudioHeader->seqindex) + pplayer->gaitsequence; + pseqdesc = (mstudioseqdesc_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->seqindex ) + pplayer->gaitsequence; // calc gait frame - if (pseqdesc->linearmovement[0] > 0) + if( pseqdesc->linearmovement[0] > 0 ) { - m_pPlayerInfo->gaitframe += (m_flGaitMovement / pseqdesc->linearmovement[0]) * pseqdesc->numframes; + m_pPlayerInfo->gaitframe += ( m_flGaitMovement / pseqdesc->linearmovement[0] ) * pseqdesc->numframes; } else { @@ -1352,7 +1341,7 @@ void CStudioModelRenderer::StudioProcessGait( entity_state_t *pplayer ) // do modulo m_pPlayerInfo->gaitframe = m_pPlayerInfo->gaitframe - (int)(m_pPlayerInfo->gaitframe / pseqdesc->numframes) * pseqdesc->numframes; - if (m_pPlayerInfo->gaitframe < 0) + if( m_pPlayerInfo->gaitframe < 0 ) m_pPlayerInfo->gaitframe += pseqdesc->numframes; } @@ -1372,32 +1361,32 @@ int CStudioModelRenderer::StudioDrawPlayer( int flags, entity_state_t *pplayer ) IEngineStudio.GetViewInfo( m_vRenderOrigin, m_vUp, m_vRight, m_vNormal ); IEngineStudio.GetAliasScale( &m_fSoftwareXScale, &m_fSoftwareYScale ); - // Con_DPrintf("DrawPlayer %d\n", m_pCurrentEntity->blending[0] ); + // Con_DPrintf( "DrawPlayer %d\n", m_pCurrentEntity->blending[0] ); - // Con_DPrintf("DrawPlayer %d %d (%d)\n", m_nFrameCount, pplayer->player_index, m_pCurrentEntity->curstate.sequence ); + // Con_DPrintf( "DrawPlayer %d %d (%d)\n", m_nFrameCount, pplayer->player_index, m_pCurrentEntity->curstate.sequence ); // Con_DPrintf("Player %.2f %.2f %.2f\n", pplayer->velocity[0], pplayer->velocity[1], pplayer->velocity[2] ); m_nPlayerIndex = pplayer->number - 1; - if (m_nPlayerIndex < 0 || m_nPlayerIndex >= gEngfuncs.GetMaxClients()) + if( m_nPlayerIndex < 0 || m_nPlayerIndex >= gEngfuncs.GetMaxClients() ) return 0; m_pRenderModel = IEngineStudio.SetupPlayerModel( m_nPlayerIndex ); - if (m_pRenderModel == NULL) + if( m_pRenderModel == NULL ) return 0; - m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata (m_pRenderModel); + m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata( m_pRenderModel ); IEngineStudio.StudioSetHeader( m_pStudioHeader ); IEngineStudio.SetRenderModel( m_pRenderModel ); - if (pplayer->gaitsequence) + if( pplayer->gaitsequence ) { vec3_t orig_angles; m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex ); VectorCopy( m_pCurrentEntity->angles, orig_angles ); - + StudioProcessGait( pplayer ); m_pPlayerInfo->gaitsequence = pplayer->gaitsequence; @@ -1416,102 +1405,102 @@ int CStudioModelRenderer::StudioDrawPlayer( int flags, entity_state_t *pplayer ) m_pCurrentEntity->latched.prevcontroller[1] = m_pCurrentEntity->curstate.controller[1]; m_pCurrentEntity->latched.prevcontroller[2] = m_pCurrentEntity->curstate.controller[2]; m_pCurrentEntity->latched.prevcontroller[3] = m_pCurrentEntity->curstate.controller[3]; - + m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex ); m_pPlayerInfo->gaitsequence = 0; StudioSetUpTransform( 0 ); } - if (flags & STUDIO_RENDER) + if( flags & STUDIO_RENDER ) { // see if the bounding box lets us trivially reject, also sets - if (!IEngineStudio.StudioCheckBBox ()) + if( !IEngineStudio.StudioCheckBBox () ) return 0; - (*m_pModelsDrawn)++; - (*m_pStudioModelCount)++; // render data cache cookie + ( *m_pModelsDrawn )++; + ( *m_pStudioModelCount )++; // render data cache cookie - if (m_pStudioHeader->numbodyparts == 0) + if( m_pStudioHeader->numbodyparts == 0 ) return 1; } m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex ); - StudioSetupBones( ); - StudioSaveBones( ); + StudioSetupBones(); + StudioSaveBones(); m_pPlayerInfo->renderframe = m_nFrameCount; m_pPlayerInfo = NULL; - if (flags & STUDIO_EVENTS) + if( flags & STUDIO_EVENTS ) { - StudioCalcAttachments( ); - IEngineStudio.StudioClientEvents( ); + StudioCalcAttachments(); + IEngineStudio.StudioClientEvents(); // copy attachments into global entity array - if ( m_pCurrentEntity->index > 0 ) + if( m_pCurrentEntity->index > 0 ) { cl_entity_t *ent = gEngfuncs.GetEntityByIndex( m_pCurrentEntity->index ); - memcpy( ent->attachment, m_pCurrentEntity->attachment, sizeof( vec3_t ) * 4 ); + memcpy( ent->attachment, m_pCurrentEntity->attachment, sizeof(vec3_t) * 4 ); } } - if (flags & STUDIO_RENDER) + if( flags & STUDIO_RENDER ) { - if (m_pCvarHiModels->value && m_pRenderModel != m_pCurrentEntity->model ) + if( m_pCvarHiModels->value && m_pRenderModel != m_pCurrentEntity->model ) { // show highest resolution multiplayer model m_pCurrentEntity->curstate.body = 255; } - if (!(m_pCvarDeveloper->value == 0 && gEngfuncs.GetMaxClients() == 1 ) && ( m_pRenderModel == m_pCurrentEntity->model ) ) + if( !( m_pCvarDeveloper->value == 0 && gEngfuncs.GetMaxClients() == 1 ) && ( m_pRenderModel == m_pCurrentEntity->model ) ) { m_pCurrentEntity->curstate.body = 1; // force helmet } lighting.plightvec = dir; - IEngineStudio.StudioDynamicLight(m_pCurrentEntity, &lighting ); + IEngineStudio.StudioDynamicLight( m_pCurrentEntity, &lighting ); IEngineStudio.StudioEntityLight( &lighting ); // model and frame independant - IEngineStudio.StudioSetupLighting (&lighting); + IEngineStudio.StudioSetupLighting( &lighting ); m_pPlayerInfo = IEngineStudio.PlayerInfo( m_nPlayerIndex ); // get remap colors m_nTopColor = m_pPlayerInfo->topcolor; m_nBottomColor = m_pPlayerInfo->bottomcolor; - if (m_nTopColor < 0) + if( m_nTopColor < 0 ) m_nTopColor = 0; - if (m_nTopColor > 360) + if( m_nTopColor > 360 ) m_nTopColor = 360; - if (m_nBottomColor < 0) + if( m_nBottomColor < 0 ) m_nBottomColor = 0; - if (m_nBottomColor > 360) + if( m_nBottomColor > 360 ) m_nBottomColor = 360; IEngineStudio.StudioSetRemapColors( m_nTopColor, m_nBottomColor ); - StudioRenderModel( ); + StudioRenderModel(); m_pPlayerInfo = NULL; - if (pplayer->weaponmodel) + if( pplayer->weaponmodel ) { cl_entity_t saveent = *m_pCurrentEntity; model_t *pweaponmodel = IEngineStudio.GetModelByIndex( pplayer->weaponmodel ); - m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata (pweaponmodel); + m_pStudioHeader = (studiohdr_t *)IEngineStudio.Mod_Extradata( pweaponmodel ); IEngineStudio.StudioSetHeader( m_pStudioHeader ); - StudioMergeBones( pweaponmodel); + StudioMergeBones( pweaponmodel ); - IEngineStudio.StudioSetupLighting (&lighting); + IEngineStudio.StudioSetupLighting( &lighting ); - StudioRenderModel( ); + StudioRenderModel(); - StudioCalcAttachments( ); + StudioCalcAttachments(); *m_pCurrentEntity = saveent; } @@ -1531,17 +1520,17 @@ void CStudioModelRenderer::StudioCalcAttachments( void ) int i; mstudioattachment_t *pattachment; - if ( m_pStudioHeader->numattachments > 4 ) + if( m_pStudioHeader->numattachments > 4 ) { gEngfuncs.Con_DPrintf( "Too many attachments on %s\n", m_pCurrentEntity->model->name ); exit( -1 ); } // calculate attachment points - pattachment = (mstudioattachment_t *)((byte *)m_pStudioHeader + m_pStudioHeader->attachmentindex); - for (i = 0; i < m_pStudioHeader->numattachments; i++) + pattachment = (mstudioattachment_t *)( (byte *)m_pStudioHeader + m_pStudioHeader->attachmentindex ); + for( i = 0; i < m_pStudioHeader->numattachments; i++ ) { - VectorTransform( pattachment[i].org, (*m_plighttransform)[pattachment[i].bone], m_pCurrentEntity->attachment[i] ); + VectorTransform( pattachment[i].org, (*m_plighttransform)[pattachment[i].bone], m_pCurrentEntity->attachment[i] ); } } @@ -1556,12 +1545,12 @@ void CStudioModelRenderer::StudioRenderModel( void ) IEngineStudio.SetChromeOrigin(); IEngineStudio.SetForceFaceFlags( 0 ); - if ( m_pCurrentEntity->curstate.renderfx == kRenderFxGlowShell ) + if( m_pCurrentEntity->curstate.renderfx == kRenderFxGlowShell ) { m_pCurrentEntity->curstate.renderfx = kRenderFxNone; - StudioRenderFinal( ); - - if ( !IEngineStudio.IsHardware() ) + StudioRenderFinal(); + + if( !IEngineStudio.IsHardware() ) { gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); } @@ -1571,15 +1560,15 @@ void CStudioModelRenderer::StudioRenderModel( void ) gEngfuncs.pTriAPI->SpriteTexture( m_pChromeSprite, 0 ); m_pCurrentEntity->curstate.renderfx = kRenderFxGlowShell; - StudioRenderFinal( ); - if ( !IEngineStudio.IsHardware() ) + StudioRenderFinal(); + if( !IEngineStudio.IsHardware() ) { gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); } } else { - StudioRenderFinal( ); + StudioRenderFinal(); } } @@ -1596,35 +1585,35 @@ void CStudioModelRenderer::StudioRenderFinal_Software( void ) // Note, rendermode set here has effect in SW IEngineStudio.SetupRenderer( 0 ); - if (m_pCvarDrawEntities->value == 2) + if( m_pCvarDrawEntities->value == 2 ) { - IEngineStudio.StudioDrawBones( ); + IEngineStudio.StudioDrawBones(); } - else if (m_pCvarDrawEntities->value == 3) + else if( m_pCvarDrawEntities->value == 3 ) { - IEngineStudio.StudioDrawHulls( ); + IEngineStudio.StudioDrawHulls(); } else { - for (i=0 ; i < m_pStudioHeader->numbodyparts ; i++) + for( i = 0; i < m_pStudioHeader->numbodyparts; i++ ) { IEngineStudio.StudioSetupModel( i, (void **)&m_pBodyPart, (void **)&m_pSubModel ); - IEngineStudio.StudioDrawPoints( ); + IEngineStudio.StudioDrawPoints(); } } - if (m_pCvarDrawEntities->value == 4) + if( m_pCvarDrawEntities->value == 4 ) { gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); - IEngineStudio.StudioDrawHulls( ); + IEngineStudio.StudioDrawHulls(); gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); } - if (m_pCvarDrawEntities->value == 5) + if( m_pCvarDrawEntities->value == 5 ) { - IEngineStudio.StudioDrawAbsBBox( ); + IEngineStudio.StudioDrawAbsBBox(); } - + IEngineStudio.RestoreRenderer(); } @@ -1641,22 +1630,22 @@ void CStudioModelRenderer::StudioRenderFinal_Hardware( void ) rendermode = IEngineStudio.GetForceFaceFlags() ? kRenderTransAdd : m_pCurrentEntity->curstate.rendermode; IEngineStudio.SetupRenderer( rendermode ); - - if (m_pCvarDrawEntities->value == 2) + + if( m_pCvarDrawEntities->value == 2 ) { IEngineStudio.StudioDrawBones(); } - else if (m_pCvarDrawEntities->value == 3) + else if( m_pCvarDrawEntities->value == 3 ) { IEngineStudio.StudioDrawHulls(); } else { - for (i=0 ; i < m_pStudioHeader->numbodyparts ; i++) + for( i = 0; i < m_pStudioHeader->numbodyparts; i++ ) { IEngineStudio.StudioSetupModel( i, (void **)&m_pBodyPart, (void **)&m_pSubModel ); - if (m_fDoInterp) + if( m_fDoInterp ) { // interpolation messes up bounding boxes. m_pCurrentEntity->trivial_accept = 0; @@ -1668,16 +1657,16 @@ void CStudioModelRenderer::StudioRenderFinal_Hardware( void ) } } - if ( m_pCvarDrawEntities->value == 4 ) + if( m_pCvarDrawEntities->value == 4 ) { gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd ); - IEngineStudio.StudioDrawHulls( ); + IEngineStudio.StudioDrawHulls(); gEngfuncs.pTriAPI->RenderMode( kRenderNormal ); } - if (m_pCvarDrawEntities->value == 5) + if( m_pCvarDrawEntities->value == 5 ) { - IEngineStudio.StudioDrawAbsBBox( ); + IEngineStudio.StudioDrawAbsBBox(); } IEngineStudio.RestoreRenderer(); @@ -1689,9 +1678,9 @@ StudioRenderFinal ==================== */ -void CStudioModelRenderer::StudioRenderFinal(void) +void CStudioModelRenderer::StudioRenderFinal( void ) { - if ( IEngineStudio.IsHardware() ) + if( IEngineStudio.IsHardware() ) { StudioRenderFinal_Hardware(); } @@ -1700,4 +1689,3 @@ void CStudioModelRenderer::StudioRenderFinal(void) StudioRenderFinal_Software(); } } - diff --git a/cl_dll/StudioModelRenderer.h b/cl_dll/StudioModelRenderer.h index 8f1427ff..0a56b731 100644 --- a/cl_dll/StudioModelRenderer.h +++ b/cl_dll/StudioModelRenderer.h @@ -27,76 +27,76 @@ public: // Initialization virtual void Init( void ); -public: +public: // Public Interfaces - virtual int StudioDrawModel ( int flags ); - virtual int StudioDrawPlayer ( int flags, struct entity_state_s *pplayer ); + virtual int StudioDrawModel( int flags ); + virtual int StudioDrawPlayer( int flags, struct entity_state_s *pplayer ); public: // Local interfaces // // Look up animation data for sequence - virtual mstudioanim_t *StudioGetAnim ( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc ); + virtual mstudioanim_t *StudioGetAnim( model_t *m_pSubModel, mstudioseqdesc_t *pseqdesc ); // Interpolate model position and angles and set up matrices - virtual void StudioSetUpTransform (int trivial_accept); + virtual void StudioSetUpTransform( int trivial_accept ); // Set up model bone positions - virtual void StudioSetupBones ( void ); + virtual void StudioSetupBones( void ); // Find final attachment points - virtual void StudioCalcAttachments ( void ); + virtual void StudioCalcAttachments( void ); // Save bone matrices and names virtual void StudioSaveBones( void ); // Merge cached bones with current bones for model - virtual void StudioMergeBones ( model_t *m_pSubModel ); + virtual void StudioMergeBones( model_t *m_pSubModel ); // Determine interpolation fraction virtual float StudioEstimateInterpolant( void ); // Determine current frame for rendering - virtual float StudioEstimateFrame ( mstudioseqdesc_t *pseqdesc ); + virtual float StudioEstimateFrame( mstudioseqdesc_t *pseqdesc ); // Apply special effects to transform matrix virtual void StudioFxTransform( cl_entity_t *ent, float transform[3][4] ); // Spherical interpolation of bones - virtual void StudioSlerpBones ( vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s ); + virtual void StudioSlerpBones( vec4_t q1[], float pos1[][3], vec4_t q2[], float pos2[][3], float s ); - // Compute bone adjustments ( bone controllers ) - virtual void StudioCalcBoneAdj ( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen ); + // Compute bone adjustments( bone controllers ) + virtual void StudioCalcBoneAdj( float dadt, float *adj, const byte *pcontroller1, const byte *pcontroller2, byte mouthopen ); // Get bone quaternions - virtual void StudioCalcBoneQuaterion ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q ); + virtual void StudioCalcBoneQuaterion( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *q ); // Get bone positions - virtual void StudioCalcBonePosition ( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos ); + virtual void StudioCalcBonePosition( int frame, float s, mstudiobone_t *pbone, mstudioanim_t *panim, float *adj, float *pos ); // Compute rotations - virtual void StudioCalcRotations ( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f ); + virtual void StudioCalcRotations( float pos[][3], vec4_t *q, mstudioseqdesc_t *pseqdesc, mstudioanim_t *panim, float f ); // Send bones and verts to renderer - virtual void StudioRenderModel ( void ); + virtual void StudioRenderModel( void ); // Finalize rendering - virtual void StudioRenderFinal (void); + virtual void StudioRenderFinal( void ); // GL&D3D vs. Software renderer finishing functions - virtual void StudioRenderFinal_Software ( void ); - virtual void StudioRenderFinal_Hardware ( void ); + virtual void StudioRenderFinal_Software( void ); + virtual void StudioRenderFinal_Hardware( void ); // Player specific data // Determine pitch and blending amounts for players - virtual void StudioPlayerBlend ( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch ); + virtual void StudioPlayerBlend( mstudioseqdesc_t *pseqdesc, int *pBlend, float *pPitch ); // Estimate gait frame for player - virtual void StudioEstimateGait ( entity_state_t *pplayer ); + virtual void StudioEstimateGait( entity_state_t *pplayer ); // Process movement of player - virtual void StudioProcessGait ( entity_state_t *pplayer ); + virtual void StudioProcessGait( entity_state_t *pplayer ); public: @@ -145,7 +145,7 @@ public: mstudiomodel_t *m_pSubModel; // Palette substition for top and bottom of model - int m_nTopColor; + int m_nTopColor; int m_nBottomColor; // @@ -156,34 +156,34 @@ public: // Number of bones in bone cache int m_nCachedBones; // Names of cached bones - char m_nCachedBoneNames[ MAXSTUDIOBONES ][ 32 ]; + char m_nCachedBoneNames[MAXSTUDIOBONES][32]; // Cached bone & light transformation matrices - float m_rgCachedBoneTransform [ MAXSTUDIOBONES ][ 3 ][ 4 ]; - float m_rgCachedLightTransform[ MAXSTUDIOBONES ][ 3 ][ 4 ]; + float m_rgCachedBoneTransform[MAXSTUDIOBONES][3][4]; + float m_rgCachedLightTransform[MAXSTUDIOBONES][3][4]; // Software renderer scale factors float m_fSoftwareXScale, m_fSoftwareYScale; // Current view vectors and render origin - float m_vUp[ 3 ]; - float m_vRight[ 3 ]; - float m_vNormal[ 3 ]; + float m_vUp[3]; + float m_vRight[3]; + float m_vNormal[3]; + + float m_vRenderOrigin[3]; - float m_vRenderOrigin[ 3 ]; - // Model render counters ( from engine ) int *m_pStudioModelCount; int *m_pModelsDrawn; // Matrices // Model to world transformation - float (*m_protationmatrix)[ 3 ][ 4 ]; + float (*m_protationmatrix)[3][4]; // Model to view transformation - float (*m_paliastransform)[ 3 ][ 4 ]; + float (*m_paliastransform)[3][4]; // Concatenated bone and light transforms - float (*m_pbonetransform) [ MAXSTUDIOBONES ][ 3 ][ 4 ]; - float (*m_plighttransform)[ MAXSTUDIOBONES ][ 3 ][ 4 ]; + float (*m_pbonetransform)[MAXSTUDIOBONES][3][4]; + float (*m_plighttransform)[MAXSTUDIOBONES][3][4]; }; -#endif // STUDIOMODELRENDERER_H \ No newline at end of file +#endif // STUDIOMODELRENDERER_H diff --git a/dlls/decals.h b/dlls/decals.h index dd13fafe..ce5a2b53 100644 --- a/dlls/decals.h +++ b/dlls/decals.h @@ -66,8 +66,8 @@ enum decal_e typedef struct { - char *name; - int index; + char *name; + int index; } DLL_DECALLIST; extern DLL_DECALLIST gDecals[]; diff --git a/dlls/extdll.h b/dlls/extdll.h index 659f9a0a..be2df7e8 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -15,7 +15,6 @@ #ifndef EXTDLL_H #define EXTDLL_H - // // Global header file for extension DLLs // @@ -57,15 +56,14 @@ typedef int BOOL; #define max(a,b) (((a) > (b)) ? (a) : (b)) #endif - // Misc C-runtime library headers #include "stdio.h" #include "stdlib.h" #include "math.h" // Header file containing definition of globalvars_t and entvars_t -typedef unsigned int func_t; // -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef unsigned int func_t; +typedef unsigned int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h // Vector class @@ -84,5 +82,4 @@ typedef float vec_t; // needed before including progdefs.h // Shared header between the client DLL and the game DLLs #include "cdll_dll.h" - #endif //EXTDLL_H diff --git a/dlls/leech.cpp b/dlls/leech.cpp index 8bb9b0c5..ea524aaa 100644 --- a/dlls/leech.cpp +++ b/dlls/leech.cpp @@ -46,14 +46,14 @@ // Movement constants -#define LEECH_ACCELERATE 10 -#define LEECH_CHECK_DIST 45 -#define LEECH_SWIM_SPEED 50 -#define LEECH_SWIM_ACCEL 80 -#define LEECH_SWIM_DECEL 10 -#define LEECH_TURN_RATE 90 -#define LEECH_SIZEX 10 -#define LEECH_FRAMETIME 0.1 +#define LEECH_ACCELERATE 10 +#define LEECH_CHECK_DIST 45 +#define LEECH_SWIM_SPEED 50 +#define LEECH_SWIM_ACCEL 80 +#define LEECH_SWIM_DECEL 10 +#define LEECH_TURN_RATE 90 +#define LEECH_SIZEX 10 +#define LEECH_FRAMETIME 0.1 #define DEBUG_BEAMS 0 @@ -71,10 +71,10 @@ public: void EXPORT DeadThink( void ); void Touch( CBaseEntity *pOther ) { - if ( pOther->IsPlayer() ) + if( pOther->IsPlayer() ) { // If the client is pushing me, give me some base velocity - if ( gpGlobals->trace_ent && gpGlobals->trace_ent == edict() ) + if( gpGlobals->trace_ent && gpGlobals->trace_ent == edict() ) { pev->basevelocity = pOther->pev->velocity; pev->flags |= FL_BASEVELOCITY; @@ -84,8 +84,8 @@ public: void SetObjectCollisionBox( void ) { - pev->absmin = pev->origin + Vector(-8,-8,0); - pev->absmax = pev->origin + Vector(8,8,2); + pev->absmin = pev->origin + Vector( -8, -8, 0 ); + pev->absmax = pev->origin + Vector( 8, 8, 2 ); } void AttackSound( void ); @@ -98,38 +98,38 @@ public: // Base entity functions void HandleAnimEvent( MonsterEvent_t *pEvent ); - int BloodColor( void ) { return DONT_BLEED; } + int BloodColor( void ) { return DONT_BLEED; } void Killed( entvars_t *pevAttacker, int iGib ); void Activate( void ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - int Classify( void ) { return CLASS_INSECT; } + int Classify( void ) { return CLASS_INSECT; } int IRelationship( CBaseEntity *pTarget ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; static const char *pAttackSounds[]; static const char *pAlertSounds[]; private: // UNDONE: Remove unused boid vars, do group behavior - float m_flTurning;// is this boid turning? - BOOL m_fPathBlocked;// TRUE if there is an obstacle ahead - float m_flAccelerate; - float m_obstacle; - float m_top; - float m_bottom; - float m_height; - float m_waterTime; - float m_sideTime; // Timer to randomly check clearance on sides - float m_zTime; - float m_stateTime; - float m_attackSoundTime; + float m_flTurning;// is this boid turning? + BOOL m_fPathBlocked;// TRUE if there is an obstacle ahead + float m_flAccelerate; + float m_obstacle; + float m_top; + float m_bottom; + float m_height; + float m_waterTime; + float m_sideTime; // Timer to randomly check clearance on sides + float m_zTime; + float m_stateTime; + float m_attackSoundTime; #if DEBUG_BEAMS - CBeam *m_pb; - CBeam *m_pt; + CBeam *m_pb; + CBeam *m_pt; #endif }; @@ -169,20 +169,20 @@ const char *CLeech::pAlertSounds[] = void CLeech::Spawn( void ) { Precache(); - SET_MODEL(ENT(pev), "models/leech.mdl"); + SET_MODEL( ENT( pev ), "models/leech.mdl" ); // Just for fun - // SET_MODEL(ENT(pev), "models/icky.mdl"); + // SET_MODEL( ENT( pev ), "models/icky.mdl" ); //UTIL_SetSize( pev, g_vecZero, g_vecZero ); - UTIL_SetSize( pev, Vector(-1,-1,0), Vector(1,1,2)); + UTIL_SetSize( pev, Vector( -1, -1, 0 ), Vector( 1, 1, 2 ) ); // Don't push the minz down too much or the water check will fail because this entity is really point-sized - pev->solid = SOLID_SLIDEBOX; - pev->movetype = MOVETYPE_FLY; - SetBits(pev->flags, FL_SWIM); - pev->health = gSkillData.leechHealth; + pev->solid = SOLID_SLIDEBOX; + pev->movetype = MOVETYPE_FLY; + SetBits( pev->flags, FL_SWIM ); + pev->health = gSkillData.leechHealth; - m_flFieldOfView = -0.5; // 180 degree FOV - m_flDistLook = 750; + m_flFieldOfView = -0.5; // 180 degree FOV + m_flDistLook = 750; MonsterInit(); SetThink( &CLeech::SwimThink ); SetUse( NULL ); @@ -204,12 +204,12 @@ void CLeech::Activate( void ) void CLeech::RecalculateWaterlevel( void ) { // Calculate boundaries - Vector vecTest = pev->origin - Vector(0,0,400); + Vector vecTest = pev->origin - Vector( 0, 0, 400 ); TraceResult tr; - UTIL_TraceLine(pev->origin, vecTest, missile, edict(), &tr); - if ( tr.flFraction != 1.0 ) + UTIL_TraceLine( pev->origin, vecTest, missile, edict(), &tr ); + if( tr.flFraction != 1.0 ) m_bottom = tr.vecEndPos.z + 1; else m_bottom = vecTest.z; @@ -227,7 +227,7 @@ void CLeech::RecalculateWaterlevel( void ) void CLeech::SwitchLeechState( void ) { m_stateTime = gpGlobals->time + RANDOM_FLOAT( 3, 6 ); - if ( m_MonsterState == MONSTERSTATE_COMBAT ) + if( m_MonsterState == MONSTERSTATE_COMBAT ) { m_hEnemy = NULL; SetState( MONSTERSTATE_IDLE ); @@ -238,7 +238,7 @@ void CLeech::SwitchLeechState( void ) { Look( m_flDistLook ); CBaseEntity *pEnemy = BestVisibleEnemy(); - if ( pEnemy && pEnemy->pev->waterlevel != 0 ) + if( pEnemy && pEnemy->pev->waterlevel != 0 ) { m_hEnemy = pEnemy; SetState( MONSTERSTATE_COMBAT ); @@ -250,36 +250,36 @@ void CLeech::SwitchLeechState( void ) int CLeech::IRelationship( CBaseEntity *pTarget ) { - if ( pTarget->IsPlayer() ) + if( pTarget->IsPlayer() ) return R_DL; return CBaseMonster::IRelationship( pTarget ); } void CLeech::AttackSound( void ) { - if ( gpGlobals->time > m_attackSoundTime ) + if( gpGlobals->time > m_attackSoundTime ) { - EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAttackSounds[ RANDOM_LONG(0,ARRAYSIZE(pAttackSounds)-1) ], 1.0, ATTN_NORM, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, PITCH_NORM ); m_attackSoundTime = gpGlobals->time + 0.5; } } void CLeech::AlertSound( void ) { - EMIT_SOUND_DYN ( ENT(pev), CHAN_VOICE, pAlertSounds[ RANDOM_LONG(0,ARRAYSIZE(pAlertSounds)-1) ], 1.0, ATTN_NORM * 0.5, 0, PITCH_NORM ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAlertSounds[RANDOM_LONG( 0, ARRAYSIZE( pAlertSounds ) - 1 )], 1.0, ATTN_NORM * 0.5, 0, PITCH_NORM ); } void CLeech::Precache( void ) { int i; - //PRECACHE_MODEL("models/icky.mdl"); - PRECACHE_MODEL("models/leech.mdl"); + //PRECACHE_MODEL( "models/icky.mdl" ); + PRECACHE_MODEL( "models/leech.mdl" ); - for ( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND((char *)pAttackSounds[i]); - for ( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND((char *)pAlertSounds[i]); + for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) + PRECACHE_SOUND( (char *)pAttackSounds[i] ); + for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) + PRECACHE_SOUND( (char *)pAlertSounds[i] ); } int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) @@ -287,9 +287,9 @@ int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float f pev->velocity = g_vecZero; // Nudge the leech away from the damage - if ( pevInflictor ) + if( pevInflictor ) { - pev->velocity = (pev->origin - pevInflictor->origin).Normalize() * 25; + pev->velocity = ( pev->origin - pevInflictor->origin ).Normalize() * 25; } return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); @@ -304,7 +304,7 @@ void CLeech::HandleAnimEvent( MonsterEvent_t *pEvent ) CBaseEntity *pEnemy; pEnemy = m_hEnemy; - if ( pEnemy != NULL ) + if( pEnemy != NULL ) { Vector dir, face; @@ -315,7 +315,7 @@ void CLeech::HandleAnimEvent( MonsterEvent_t *pEvent ) dir = dir.Normalize(); face = face.Normalize(); - if ( DotProduct(dir, face) > 0.9 ) // Only take damage if the leech is facing the prey + if( DotProduct( dir, face ) > 0.9 ) // Only take damage if the leech is facing the prey pEnemy->TakeDamage( pev, pev, gSkillData.leechDmgBite, DMG_SLASH ); } m_stateTime -= 2; @@ -333,7 +333,7 @@ void CLeech::MakeVectors( void ) { Vector tmp = pev->angles; tmp.x = -tmp.x; - UTIL_MakeVectors ( tmp ); + UTIL_MakeVectors( tmp ); } // @@ -341,8 +341,8 @@ void CLeech::MakeVectors( void ) // float CLeech::ObstacleDistance( CBaseEntity *pTarget ) { - TraceResult tr; - Vector vecTest; + TraceResult tr; + Vector vecTest; // use VELOCITY, not angles, not all boids point the direction they are flying //Vector vecDir = UTIL_VecToAngles( pev->velocity ); @@ -350,58 +350,58 @@ float CLeech::ObstacleDistance( CBaseEntity *pTarget ) // check for obstacle ahead vecTest = pev->origin + gpGlobals->v_forward * LEECH_CHECK_DIST; - UTIL_TraceLine(pev->origin, vecTest, missile, edict(), &tr); + UTIL_TraceLine( pev->origin, vecTest, missile, edict(), &tr ); - if ( tr.fStartSolid ) + if( tr.fStartSolid ) { pev->speed = -LEECH_SWIM_SPEED * 0.5; -// ALERT( at_console, "Stuck from (%f %f %f) to (%f %f %f)\n", pev->oldorigin.x, pev->oldorigin.y, pev->oldorigin.z, pev->origin.x, pev->origin.y, pev->origin.z ); -// UTIL_SetOrigin( pev, pev->oldorigin ); + //ALERT( at_console, "Stuck from (%f %f %f) to (%f %f %f)\n", pev->oldorigin.x, pev->oldorigin.y, pev->oldorigin.z, pev->origin.x, pev->origin.y, pev->origin.z ); + //UTIL_SetOrigin( pev, pev->oldorigin ); } - if ( tr.flFraction != 1.0 ) + if( tr.flFraction != 1.0 ) { - if ( (pTarget == NULL || tr.pHit != pTarget->edict()) ) + if( ( pTarget == NULL || tr.pHit != pTarget->edict() ) ) { return tr.flFraction; } else { - if ( fabs(m_height - pev->origin.z) > 10 ) + if( fabs( m_height - pev->origin.z ) > 10 ) return tr.flFraction; } } - if ( m_sideTime < gpGlobals->time ) + if( m_sideTime < gpGlobals->time ) { // extra wide checks vecTest = pev->origin + gpGlobals->v_right * LEECH_SIZEX * 2 + gpGlobals->v_forward * LEECH_CHECK_DIST; - UTIL_TraceLine(pev->origin, vecTest, missile, edict(), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( pev->origin, vecTest, missile, edict(), &tr ); + if( tr.flFraction != 1.0 ) return tr.flFraction; vecTest = pev->origin - gpGlobals->v_right * LEECH_SIZEX * 2 + gpGlobals->v_forward * LEECH_CHECK_DIST; - UTIL_TraceLine(pev->origin, vecTest, missile, edict(), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( pev->origin, vecTest, missile, edict(), &tr ); + if( tr.flFraction != 1.0 ) return tr.flFraction; // Didn't hit either side, so stop testing for another 0.5 - 1 seconds - m_sideTime = gpGlobals->time + RANDOM_FLOAT(0.5,1); + m_sideTime = gpGlobals->time + RANDOM_FLOAT( 0.5, 1 ); } return 1.0; } void CLeech::DeadThink( void ) { - if ( m_fSequenceFinished ) + if( m_fSequenceFinished ) { - if ( m_Activity == ACT_DIEFORWARD ) + if( m_Activity == ACT_DIEFORWARD ) { SetThink( NULL ); StopAnimation(); return; } - else if ( pev->flags & FL_ONGROUND ) + else if( pev->flags & FL_ONGROUND ) { pev->solid = SOLID_NOT; SetActivity(ACT_DIEFORWARD); @@ -411,13 +411,13 @@ void CLeech::DeadThink( void ) pev->nextthink = gpGlobals->time + 0.1; // Apply damage velocity, but keep out of the walls - if ( pev->velocity.x != 0 || pev->velocity.y != 0 ) + if( pev->velocity.x != 0 || pev->velocity.y != 0 ) { TraceResult tr; // Look 0.5 seconds ahead - UTIL_TraceLine(pev->origin, pev->origin + pev->velocity * 0.5, missile, edict(), &tr); - if (tr.flFraction != 1.0) + UTIL_TraceLine( pev->origin, pev->origin + pev->velocity * 0.5, missile, edict(), &tr ); + if( tr.flFraction != 1.0 ) { pev->velocity.x = 0; pev->velocity.y = 0; @@ -427,27 +427,27 @@ void CLeech::DeadThink( void ) void CLeech::UpdateMotion( void ) { - float flapspeed = (pev->speed - m_flAccelerate) / LEECH_ACCELERATE; + float flapspeed = ( pev->speed - m_flAccelerate ) / LEECH_ACCELERATE; m_flAccelerate = m_flAccelerate * 0.8 + pev->speed * 0.2; - if (flapspeed < 0) + if( flapspeed < 0 ) flapspeed = -flapspeed; flapspeed += 1.0; - if (flapspeed < 0.5) + if( flapspeed < 0.5 ) flapspeed = 0.5; - if (flapspeed > 1.9) + if( flapspeed > 1.9 ) flapspeed = 1.9; pev->framerate = flapspeed; - if ( !m_fPathBlocked ) + if( !m_fPathBlocked ) pev->avelocity.y = pev->ideal_yaw; else pev->avelocity.y = pev->ideal_yaw * m_obstacle; - if ( pev->avelocity.y > 150 ) + if( pev->avelocity.y > 150 ) m_IdealActivity = ACT_TURN_LEFT; - else if ( pev->avelocity.y < -150 ) + else if( pev->avelocity.y < -150 ) m_IdealActivity = ACT_TURN_RIGHT; else m_IdealActivity = ACT_SWIM; @@ -456,9 +456,9 @@ void CLeech::UpdateMotion( void ) float targetPitch, delta; delta = m_height - pev->origin.z; - if ( delta < -10 ) + if( delta < -10 ) targetPitch = -30; - else if ( delta > 10 ) + else if( delta > 10 ) targetPitch = 30; else targetPitch = 0; @@ -466,13 +466,13 @@ void CLeech::UpdateMotion( void ) pev->angles.x = UTIL_Approach( targetPitch, pev->angles.x, 60 * LEECH_FRAMETIME ); // bank - pev->avelocity.z = - (pev->angles.z + (pev->avelocity.y * 0.25)); + pev->avelocity.z = -( pev->angles.z + ( pev->avelocity.y * 0.25 ) ); - if ( m_MonsterState == MONSTERSTATE_COMBAT && HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) + if( m_MonsterState == MONSTERSTATE_COMBAT && HasConditions( bits_COND_CAN_MELEE_ATTACK1 ) ) m_IdealActivity = ACT_MELEE_ATTACK1; // Out of water check - if ( !pev->waterlevel ) + if( !pev->waterlevel ) { pev->movetype = MOVETYPE_TOSS; m_IdealActivity = ACT_TWITCH; @@ -482,10 +482,10 @@ void CLeech::UpdateMotion( void ) pev->angles.z = 0; pev->angles.x = 0; - if ( pev->framerate < 1.0 ) + if( pev->framerate < 1.0 ) pev->framerate = 1.0; } - else if ( pev->movetype == MOVETYPE_TOSS ) + else if( pev->movetype == MOVETYPE_TOSS ) { pev->movetype = MOVETYPE_FLY; pev->flags &= ~FL_ONGROUND; @@ -493,25 +493,25 @@ void CLeech::UpdateMotion( void ) m_waterTime = gpGlobals->time + 2; // Recalc again soon, water may be rising } - if ( m_Activity != m_IdealActivity ) + if( m_Activity != m_IdealActivity ) { - SetActivity ( m_IdealActivity ); + SetActivity( m_IdealActivity ); } float flInterval = StudioFrameAdvance(); - DispatchAnimEvents ( flInterval ); + DispatchAnimEvents( flInterval ); #if DEBUG_BEAMS - if ( !m_pb ) + if( !m_pb ) m_pb = CBeam::BeamCreate( "sprites/laserbeam.spr", 5 ); - if ( !m_pt ) + if( !m_pt ) m_pt = CBeam::BeamCreate( "sprites/laserbeam.spr", 5 ); m_pb->PointsInit( pev->origin, pev->origin + gpGlobals->v_forward * LEECH_CHECK_DIST ); - m_pt->PointsInit( pev->origin, pev->origin - gpGlobals->v_right * (pev->avelocity.y*0.25) ); - if ( m_fPathBlocked ) + m_pt->PointsInit( pev->origin, pev->origin - gpGlobals->v_right * ( pev->avelocity.y * 0.25 ) ); + if( m_fPathBlocked ) { float color = m_obstacle * 30; - if ( m_obstacle == 1.0 ) + if( m_obstacle == 1.0 ) color = 0; - if ( color > 255 ) + if( color > 255 ) color = 255; m_pb->SetColor( 255, (int)color, (int)color ); } @@ -523,16 +523,16 @@ void CLeech::UpdateMotion( void ) void CLeech::SwimThink( void ) { - TraceResult tr; - float flLeftSide; - float flRightSide; - float targetSpeed; - float targetYaw = 0; - CBaseEntity *pTarget; - - if ( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) + TraceResult tr; + float flLeftSide; + float flRightSide; + float targetSpeed; + float targetYaw = 0; + CBaseEntity *pTarget; + + if( FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) ) { - pev->nextthink = gpGlobals->time + RANDOM_FLOAT(1,1.5); + pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 1, 1.5 ); pev->velocity = g_vecZero; return; } @@ -541,10 +541,10 @@ void CLeech::SwimThink( void ) targetSpeed = LEECH_SWIM_SPEED; - if ( m_waterTime < gpGlobals->time ) + if( m_waterTime < gpGlobals->time ) RecalculateWaterlevel(); - if ( m_stateTime < gpGlobals->time ) + if( m_stateTime < gpGlobals->time ) SwitchLeechState(); ClearConditions( bits_COND_CAN_MELEE_ATTACK1 ); @@ -552,47 +552,47 @@ void CLeech::SwimThink( void ) { case MONSTERSTATE_COMBAT: pTarget = m_hEnemy; - if ( !pTarget ) + if( !pTarget ) SwitchLeechState(); else { // Chase the enemy's eyes m_height = pTarget->pev->origin.z + pTarget->pev->view_ofs.z - 5; // Clip to viable water area - if ( m_height < m_bottom ) + if( m_height < m_bottom ) m_height = m_bottom; - else if ( m_height > m_top ) + else if( m_height > m_top ) m_height = m_top; Vector location = pTarget->pev->origin - pev->origin; location.z += (pTarget->pev->view_ofs.z); - if ( location.Length() < 40 ) + if( location.Length() < 40 ) SetConditions( bits_COND_CAN_MELEE_ATTACK1 ); // Turn towards target ent targetYaw = UTIL_VecToYaw( location ); targetYaw = UTIL_AngleDiff( targetYaw, UTIL_AngleMod( pev->angles.y ) ); - if ( targetYaw < (-LEECH_TURN_RATE*0.75) ) - targetYaw = (-LEECH_TURN_RATE*0.75); - else if ( targetYaw > (LEECH_TURN_RATE*0.75) ) - targetYaw = (LEECH_TURN_RATE*0.75); + if( targetYaw < ( -LEECH_TURN_RATE * 0.75 ) ) + targetYaw = ( -LEECH_TURN_RATE * 0.75 ); + else if( targetYaw > ( LEECH_TURN_RATE * 0.75 ) ) + targetYaw = ( LEECH_TURN_RATE * 0.75 ); else targetSpeed *= 2; } break; default: - if ( m_zTime < gpGlobals->time ) + if( m_zTime < gpGlobals->time ) { float newHeight = RANDOM_FLOAT( m_bottom, m_top ); m_height = 0.5 * m_height + 0.5 * newHeight; m_zTime = gpGlobals->time + RANDOM_FLOAT( 1, 4 ); } - if ( RANDOM_LONG( 0, 100 ) < 10 ) + if( RANDOM_LONG( 0, 100 ) < 10 ) targetYaw = RANDOM_LONG( -30, 30 ); pTarget = NULL; // oldorigin test - if ( (pev->origin - pev->oldorigin).Length() < 1 ) + if( ( pev->origin - pev->oldorigin ).Length() < 1 ) { // If leech didn't move, there must be something blocking it, so try to turn m_sideTime = 0; @@ -602,14 +602,14 @@ void CLeech::SwimThink( void ) m_obstacle = ObstacleDistance( pTarget ); pev->oldorigin = pev->origin; - if ( m_obstacle < 0.1 ) + if( m_obstacle < 0.1 ) m_obstacle = 0.1; // is the way ahead clear? - if ( m_obstacle == 1.0 ) + if( m_obstacle == 1.0 ) { // if the leech is turning, stop the trend. - if ( m_flTurning != 0 ) + if( m_flTurning != 0 ) { m_flTurning = 0; } @@ -625,55 +625,55 @@ void CLeech::SwimThink( void ) // IF we get this far in the function, the leader's path is blocked! m_fPathBlocked = TRUE; - if ( m_flTurning == 0 )// something in the way and leech is not already turning to avoid + if( m_flTurning == 0 )// something in the way and leech is not already turning to avoid { Vector vecTest; // measure clearance on left and right to pick the best dir to turn - vecTest = pev->origin + (gpGlobals->v_right * LEECH_SIZEX) + (gpGlobals->v_forward * LEECH_CHECK_DIST); - UTIL_TraceLine(pev->origin, vecTest, missile, edict(), &tr); + vecTest = pev->origin + ( gpGlobals->v_right * LEECH_SIZEX ) + ( gpGlobals->v_forward * LEECH_CHECK_DIST ); + UTIL_TraceLine( pev->origin, vecTest, missile, edict(), &tr ); flRightSide = tr.flFraction; - vecTest = pev->origin + (gpGlobals->v_right * -LEECH_SIZEX) + (gpGlobals->v_forward * LEECH_CHECK_DIST); - UTIL_TraceLine(pev->origin, vecTest, missile, edict(), &tr); + vecTest = pev->origin + ( gpGlobals->v_right * -LEECH_SIZEX ) + ( gpGlobals->v_forward * LEECH_CHECK_DIST ); + UTIL_TraceLine( pev->origin, vecTest, missile, edict(), &tr ); flLeftSide = tr.flFraction; // turn left, right or random depending on clearance ratio - float delta = (flRightSide - flLeftSide); - if ( delta > 0.1 || (delta > -0.1 && RANDOM_LONG(0,100)<50) ) + float delta = ( flRightSide - flLeftSide ); + if( delta > 0.1 || ( delta > -0.1 && RANDOM_LONG( 0, 100 ) < 50 ) ) m_flTurning = -LEECH_TURN_RATE; else m_flTurning = LEECH_TURN_RATE; } - pev->speed = UTIL_Approach( -(LEECH_SWIM_SPEED*0.5), pev->speed, LEECH_SWIM_DECEL * LEECH_FRAMETIME * m_obstacle ); + pev->speed = UTIL_Approach( -( LEECH_SWIM_SPEED * 0.5 ), pev->speed, LEECH_SWIM_DECEL * LEECH_FRAMETIME * m_obstacle ); pev->velocity = gpGlobals->v_forward * pev->speed; } pev->ideal_yaw = m_flTurning + targetYaw; UpdateMotion(); } -void CLeech::Killed(entvars_t *pevAttacker, int iGib) +void CLeech::Killed( entvars_t *pevAttacker, int iGib ) { - Vector vecSplatDir; - TraceResult tr; + Vector vecSplatDir; + TraceResult tr; //ALERT(at_aiconsole, "Leech: killed\n"); // tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality. - CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner); - if (pOwner) - pOwner->DeathNotice(pev); + CBaseEntity *pOwner = CBaseEntity::Instance( pev->owner ); + if( pOwner ) + pOwner->DeathNotice( pev ); // When we hit the ground, play the "death_end" activity - if ( pev->waterlevel ) + if( pev->waterlevel ) { pev->angles.z = 0; pev->angles.x = 0; pev->origin.z += 1; pev->avelocity = g_vecZero; - if ( RANDOM_LONG( 0, 99 ) < 70 ) + if( RANDOM_LONG( 0, 99 ) < 70 ) pev->avelocity.y = RANDOM_LONG( -720, 720 ); pev->gravity = 0.02; - ClearBits(pev->flags, FL_ONGROUND); + ClearBits( pev->flags, FL_ONGROUND ); SetActivity( ACT_DIESIMPLE ); } else diff --git a/dlls/monsterevent.h b/dlls/monsterevent.h index 5d144750..ab54b687 100644 --- a/dlls/monsterevent.h +++ b/dlls/monsterevent.h @@ -18,9 +18,9 @@ typedef struct { - int event; - char *options; -} MonsterEvent_t; + int event; + char *options; +}MonsterEvent_t; #define EVENT_SPECIFIC 0 #define EVENT_SCRIPTED 1000 @@ -30,6 +30,5 @@ typedef struct #define MONSTER_EVENT_BODYDROP_LIGHT 2001 #define MONSTER_EVENT_BODYDROP_HEAVY 2002 -#define MONSTER_EVENT_SWISHSOUND 2010 - +#define MONSTER_EVENT_SWISHSOUND 2010 #endif //MONSTEREVENT_H diff --git a/dlls/monsters.h b/dlls/monsters.h index bf30ffcc..6f2df294 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -41,10 +41,10 @@ // Monster Spawnflags #define SF_MONSTER_WAIT_TILL_SEEN 1// spawnflag that makes monsters wait until player can see them before attacking. -#define SF_MONSTER_GAG 2 // no idle noises from this monster +#define SF_MONSTER_GAG 2 // no idle noises from this monster #define SF_MONSTER_HITMONSTERCLIP 4 // 8 -#define SF_MONSTER_PRISONER 16 // monster won't attack anyone, no one will attacke him. +#define SF_MONSTER_PRISONER 16 // monster won't attack anyone, no one will attacke him. // 32 // 64 #define SF_MONSTER_WAIT_FOR_SCRIPT 128 //spawnflag that makes monsters wait to check for attacking until the script is done or they've been attacked @@ -58,27 +58,27 @@ #define SF_MONSTER_WAIT_UNTIL_PROVOKED 64 // don't attack the player unless provoked // MoveToOrigin stuff -#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal -#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. +#define MOVE_START_TURN_DIST 64 // when this far away from moveGoal, start turning to face next goal +#define MOVE_STUCK_DIST 32 // if a monster can't step this far, it is stuck. // MoveToOrigin stuff -#define MOVE_NORMAL 0// normal move in the direction monster is facing -#define MOVE_STRAFE 1// moves in direction specified, no matter which way monster is facing +#define MOVE_NORMAL 0// normal move in the direction monster is facing +#define MOVE_STRAFE 1// moves in direction specified, no matter which way monster is facing // spawn flags 256 and above are already taken by the engine extern void UTIL_MoveToOrigin( edict_t* pent, const Vector &vecGoal, float flDist, int iMoveType ); -Vector VecCheckToss ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj = 1.0 ); -Vector VecCheckThrow ( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1.0 ); -extern DLL_GLOBAL Vector g_vecAttackDir; +Vector VecCheckToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj = 1.0 ); +Vector VecCheckThrow( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1.0 ); +extern DLL_GLOBAL Vector g_vecAttackDir; extern DLL_GLOBAL CONSTANT float g_flMeleeRange; extern DLL_GLOBAL CONSTANT float g_flMediumRange; extern DLL_GLOBAL CONSTANT float g_flLongRange; -extern void EjectBrass (const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ); +extern void EjectBrass(const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ); extern void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ); -BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget ); -BOOL FBoxVisible ( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize = 0.0 ); +BOOL FBoxVisible( entvars_t *pevLooker, entvars_t *pevTarget ); +BOOL FBoxVisible( entvars_t *pevLooker, entvars_t *pevTarget, Vector &vecTargetOrigin, float flSize = 0.0 ); // monster to monster relationship types #define R_AL -2 // (ALLY) pals. Good alternative to R_NO when applicable. @@ -140,20 +140,20 @@ class CGib : public CBaseEntity { public: void Spawn( const char *szGibModel ); - void EXPORT BounceGibTouch ( CBaseEntity *pOther ); - void EXPORT StickyGibTouch ( CBaseEntity *pOther ); + void EXPORT BounceGibTouch( CBaseEntity *pOther ); + void EXPORT StickyGibTouch( CBaseEntity *pOther ); void EXPORT WaitTillLand( void ); - void LimitVelocity( void ); + void LimitVelocity( void ); - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } - static void SpawnHeadGib( entvars_t *pevVictim ); - static void SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ); - static void SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs ); + virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | FCAP_DONT_SAVE; } + static void SpawnHeadGib( entvars_t *pevVictim ); + static void SpawnRandomGibs( entvars_t *pevVictim, int cGibs, int human ); + static void SpawnStickyGibs( entvars_t *pevVictim, Vector vecOrigin, int cGibs ); - int m_bloodColor; - int m_cBloodDecals; - int m_material; - float m_lifeTime; + int m_bloodColor; + int m_cBloodDecals; + int m_material; + float m_lifeTime; }; #define CUSTOM_SCHEDULES\ @@ -166,10 +166,9 @@ public: #define IMPLEMENT_CUSTOM_SCHEDULES(derivedClass, baseClass)\ Schedule_t *derivedClass::ScheduleFromName( const char *pName )\ {\ - Schedule_t *pSchedule = ScheduleInList( pName, m_scheduleList, ARRAYSIZE(m_scheduleList) );\ - if ( !pSchedule )\ - return baseClass::ScheduleFromName(pName);\ + Schedule_t *pSchedule = ScheduleInList( pName, m_scheduleList, ARRAYSIZE( m_scheduleList ) );\ + if( !pSchedule )\ + return baseClass::ScheduleFromName( pName );\ return pSchedule;\ } - #endif //MONSTERS_H diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 850bf549..7d05d5e1 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -45,11 +45,11 @@ int CMP5::SecondaryAmmoIndex( void ) return m_iSecondaryAmmoType; } -void CMP5::Spawn( ) +void CMP5::Spawn() { - pev->classname = MAKE_STRING("weapon_9mmAR"); // hack to allow for old names - Precache( ); - SET_MODEL(ENT(pev), "models/w_9mmAR.mdl"); + pev->classname = MAKE_STRING( "weapon_9mmAR" ); // hack to allow for old names + Precache(); + SET_MODEL( ENT( pev ), "models/w_9mmAR.mdl" ); m_iId = WEAPON_MP5; m_iDefaultAmmo = MP5_DEFAULT_GIVE; @@ -59,36 +59,36 @@ void CMP5::Spawn( ) void CMP5::Precache( void ) { - PRECACHE_MODEL("models/v_9mmAR.mdl"); - PRECACHE_MODEL("models/w_9mmAR.mdl"); - PRECACHE_MODEL("models/p_9mmAR.mdl"); + PRECACHE_MODEL( "models/v_9mmAR.mdl" ); + PRECACHE_MODEL( "models/w_9mmAR.mdl" ); + PRECACHE_MODEL( "models/p_9mmAR.mdl" ); - m_iShell = PRECACHE_MODEL ("models/shell.mdl");// brass shellTE_MODEL + m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shellTE_MODEL - PRECACHE_MODEL("models/grenade.mdl"); // grenade + PRECACHE_MODEL( "models/grenade.mdl" ); // grenade - PRECACHE_MODEL("models/w_9mmARclip.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_9mmARclip.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); - PRECACHE_SOUND("items/clipinsert1.wav"); - PRECACHE_SOUND("items/cliprelease1.wav"); + PRECACHE_SOUND( "items/clipinsert1.wav" ); + PRECACHE_SOUND( "items/cliprelease1.wav" ); - PRECACHE_SOUND ("weapons/hks1.wav");// H to the K - PRECACHE_SOUND ("weapons/hks2.wav");// H to the K - PRECACHE_SOUND ("weapons/hks3.wav");// H to the K + PRECACHE_SOUND( "weapons/hks1.wav" );// H to the K + PRECACHE_SOUND( "weapons/hks2.wav" );// H to the K + PRECACHE_SOUND( "weapons/hks3.wav" );// H to the K PRECACHE_SOUND( "weapons/glauncher.wav" ); PRECACHE_SOUND( "weapons/glauncher2.wav" ); - PRECACHE_SOUND ("weapons/357_cock1.wav"); + PRECACHE_SOUND( "weapons/357_cock1.wav" ); m_usMP5 = PRECACHE_EVENT( 1, "events/mp5.sc" ); m_usMP52 = PRECACHE_EVENT( 1, "events/mp52.sc" ); } -int CMP5::GetItemInfo(ItemInfo *p) +int CMP5::GetItemInfo( ItemInfo *p ) { - p->pszName = STRING(pev->classname); + p->pszName = STRING( pev->classname ); p->pszAmmo1 = "9mm"; p->iMaxAmmo1 = _9MM_MAX_CARRY; p->pszAmmo2 = "ARgrenades"; @@ -105,7 +105,7 @@ int CMP5::GetItemInfo(ItemInfo *p) int CMP5::AddToPlayer( CBasePlayer *pPlayer ) { - if ( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); WRITE_BYTE( m_iId ); @@ -115,7 +115,7 @@ int CMP5::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -BOOL CMP5::Deploy( ) +BOOL CMP5::Deploy() { return DefaultDeploy( "models/v_9mmAR.mdl", "models/p_9mmAR.mdl", MP5_DEPLOY, "mp5" ); } @@ -123,14 +123,14 @@ BOOL CMP5::Deploy( ) void CMP5::PrimaryAttack() { // don't fire underwater - if (m_pPlayer->pev->waterlevel == 3) + if( m_pPlayer->pev->waterlevel == 3 ) { - PlayEmptySound( ); + PlayEmptySound(); m_flNextPrimaryAttack = 0.15; return; } - if (m_iClip <= 0) + if( m_iClip <= 0 ) { PlayEmptySound(); m_flNextPrimaryAttack = 0.15; @@ -142,18 +142,18 @@ void CMP5::PrimaryAttack() m_iClip--; - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; + m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - Vector vecSrc = m_pPlayer->GetGunPosition( ); + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); Vector vecDir; #ifdef CLIENT_DLL - if ( !bIsMultiplayer() ) + if( !bIsMultiplayer() ) #else - if ( !g_pGameRules->IsMultiplayer() ) + if( !g_pGameRules->IsMultiplayer() ) #endif { // optimized multiplayer. Widened to make it easier to hit a moving player @@ -173,13 +173,13 @@ void CMP5::PrimaryAttack() #endif PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); - if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; - if ( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) + if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); @@ -188,16 +188,16 @@ void CMP5::PrimaryAttack() void CMP5::SecondaryAttack( void ) { // don't fire underwater - if (m_pPlayer->pev->waterlevel == 3) + if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound( ); m_flNextPrimaryAttack = 0.15; return; } - if (m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] == 0) + if( m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] == 0 ) { - PlayEmptySound( ); + PlayEmptySound(); return; } @@ -206,7 +206,7 @@ void CMP5::SecondaryAttack( void ) m_pPlayer->m_iExtraSoundTypes = bits_SOUND_DANGER; m_pPlayer->m_flStopExtraSoundTime = UTIL_WeaponTimeBase() + 0.2; - + m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType]--; // player "shoot" animation @@ -215,9 +215,9 @@ void CMP5::SecondaryAttack( void ) UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); // we don't add in player velocity anymore. - CGrenade::ShootContact( m_pPlayer->pev, - m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16, - gpGlobals->v_forward * 800 ); + CGrenade::ShootContact( m_pPlayer->pev, + m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16, + gpGlobals->v_forward * 800 ); int flags; #if defined( CLIENT_WEAPONS ) @@ -226,19 +226,19 @@ void CMP5::SecondaryAttack( void ) flags = 0; #endif PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usMP52 ); - + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1; m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5;// idle pretty soon after shooting. - if (!m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType]) + if( !m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] ) // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0); + m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); } void CMP5::Reload( void ) { - if ( m_pPlayer->ammo_9mm <= 0 ) + if( m_pPlayer->ammo_9mm <= 0 ) return; DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5 ); @@ -246,20 +246,19 @@ void CMP5::Reload( void ) void CMP5::WeaponIdle( void ) { - ResetEmptySound( ); + ResetEmptySound(); m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); - if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) + if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; int iAnim; - switch ( RANDOM_LONG( 0, 1 ) ) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: iAnim = MP5_LONGIDLE; break; - default: case 1: iAnim = MP5_IDLE1; @@ -274,22 +273,22 @@ void CMP5::WeaponIdle( void ) class CMP5AmmoClip : public CBasePlayerAmmo { void Spawn( void ) - { - Precache( ); - SET_MODEL(ENT(pev), "models/w_9mmARclip.mdl"); - CBasePlayerAmmo::Spawn( ); + { + Precache(); + SET_MODEL( ENT( pev ), "models/w_9mmARclip.mdl" ); + CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_9mmARclip.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_9mmARclip.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) { - int bResult = (pOther->GiveAmmo( AMMO_MP5CLIP_GIVE, "9mm", _9MM_MAX_CARRY) != -1); - if (bResult) + int bResult = ( pOther->GiveAmmo( AMMO_MP5CLIP_GIVE, "9mm", _9MM_MAX_CARRY ) != -1 ); + if( bResult ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); } return bResult; } @@ -302,21 +301,21 @@ class CMP5Chainammo : public CBasePlayerAmmo { void Spawn( void ) { - Precache( ); - SET_MODEL(ENT(pev), "models/w_chainammo.mdl"); - CBasePlayerAmmo::Spawn( ); + Precache(); + SET_MODEL( ENT( pev ), "models/w_chainammo.mdl" ); + CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_chainammo.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_chainammo.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) { - int bResult = (pOther->GiveAmmo( AMMO_CHAINBOX_GIVE, "9mm", _9MM_MAX_CARRY) != -1); - if (bResult) + int bResult = ( pOther->GiveAmmo( AMMO_CHAINBOX_GIVE, "9mm", _9MM_MAX_CARRY ) != -1 ); + if( bResult ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); } return bResult; } @@ -327,23 +326,23 @@ LINK_ENTITY_TO_CLASS( ammo_9mmbox, CMP5Chainammo ) class CMP5AmmoGrenade : public CBasePlayerAmmo { void Spawn( void ) - { - Precache( ); - SET_MODEL(ENT(pev), "models/w_ARgrenade.mdl"); - CBasePlayerAmmo::Spawn( ); + { + Precache(); + SET_MODEL( ENT( pev ), "models/w_ARgrenade.mdl" ); + CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL ("models/w_ARgrenade.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); + PRECACHE_MODEL( "models/w_ARgrenade.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) { - int bResult = (pOther->GiveAmmo( AMMO_M203BOX_GIVE, "ARgrenades", M203_GRENADE_MAX_CARRY ) != -1); + int bResult = ( pOther->GiveAmmo( AMMO_M203BOX_GIVE, "ARgrenades", M203_GRENADE_MAX_CARRY ) != -1 ); - if (bResult) + if( bResult ) { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); } return bResult; } diff --git a/dlls/plats.cpp b/dlls/plats.cpp index e4e30ef1..93fb22fe 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -33,20 +33,20 @@ static void PlatSpawnInsideTrigger(entvars_t* pevPlatform); class CBasePlatTrain : public CBaseToggle { public: - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } void KeyValue( KeyValueData* pkvd); void Precache( void ); // This is done to fix spawn flag collisions between this class and a derived class - virtual BOOL IsTogglePlat( void ) { return (pev->spawnflags & SF_PLAT_TOGGLE) ? TRUE : FALSE; } + virtual BOOL IsTogglePlat( void ) { return ( pev->spawnflags & SF_PLAT_TOGGLE ) ? TRUE : FALSE; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - BYTE m_bMoveSnd; // sound a plat makes while moving - BYTE m_bStopSnd; // sound a plat makes when it stops - float m_volume; // Sound volume + BYTE m_bMoveSnd; // sound a plat makes while moving + BYTE m_bStopSnd; // sound a plat makes when it stops + float m_volume; // Sound volume }; TYPEDESCRIPTION CBasePlatTrain::m_SaveData[] = @@ -58,41 +58,41 @@ TYPEDESCRIPTION CBasePlatTrain::m_SaveData[] = IMPLEMENT_SAVERESTORE( CBasePlatTrain, CBaseToggle ) -void CBasePlatTrain :: KeyValue( KeyValueData *pkvd ) +void CBasePlatTrain::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "lip")) + if( FStrEq( pkvd->szKeyName, "lip" ) ) { - m_flLip = atof(pkvd->szValue); + m_flLip = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "wait")) + else if( FStrEq( pkvd->szKeyName, "wait" ) ) { - m_flWait = atof(pkvd->szValue); + m_flWait = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "height")) + else if( FStrEq( pkvd->szKeyName, "height" ) ) { - m_flHeight = atof(pkvd->szValue); + m_flHeight = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "rotation")) + else if( FStrEq( pkvd->szKeyName, "rotation" ) ) { - m_vecFinalAngle.x = atof(pkvd->szValue); + m_vecFinalAngle.x = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "movesnd")) + else if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof(pkvd->szValue); + m_bMoveSnd = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "stopsnd")) + else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) { - m_bStopSnd = atof(pkvd->szValue); + m_bStopSnd = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "volume")) + else if( FStrEq( pkvd->szKeyName, "volume" ) ) { - m_volume = atof(pkvd->szValue); + m_volume = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -105,109 +105,108 @@ void CBasePlatTrain :: KeyValue( KeyValueData *pkvd ) void CBasePlatTrain::Precache( void ) { // set the plat's "in-motion" sound - switch (m_bMoveSnd) + switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = MAKE_STRING("common/null.wav"); + case 0: + pev->noiseMoving = MAKE_STRING( "common/null.wav" ); break; - case 1: - PRECACHE_SOUND ("plats/bigmove1.wav"); - pev->noiseMoving = MAKE_STRING("plats/bigmove1.wav"); + case 1: + PRECACHE_SOUND( "plats/bigmove1.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/bigmove1.wav" ); break; - case 2: - PRECACHE_SOUND ("plats/bigmove2.wav"); - pev->noiseMoving = MAKE_STRING("plats/bigmove2.wav"); + case 2: + PRECACHE_SOUND( "plats/bigmove2.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/bigmove2.wav" ); break; - case 3: - PRECACHE_SOUND ("plats/elevmove1.wav"); - pev->noiseMoving = MAKE_STRING("plats/elevmove1.wav"); + case 3: + PRECACHE_SOUND( "plats/elevmove1.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/elevmove1.wav" ); break; - case 4: - PRECACHE_SOUND ("plats/elevmove2.wav"); - pev->noiseMoving = MAKE_STRING("plats/elevmove2.wav"); + case 4: + PRECACHE_SOUND( "plats/elevmove2.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/elevmove2.wav" ); break; - case 5: - PRECACHE_SOUND ("plats/elevmove3.wav"); - pev->noiseMoving = MAKE_STRING("plats/elevmove3.wav"); + case 5: + PRECACHE_SOUND( "plats/elevmove3.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/elevmove3.wav" ); break; - case 6: - PRECACHE_SOUND ("plats/freightmove1.wav"); - pev->noiseMoving = MAKE_STRING("plats/freightmove1.wav"); + case 6: + PRECACHE_SOUND( "plats/freightmove1.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/freightmove1.wav" ); break; - case 7: - PRECACHE_SOUND ("plats/freightmove2.wav"); - pev->noiseMoving = MAKE_STRING("plats/freightmove2.wav"); + case 7: + PRECACHE_SOUND( "plats/freightmove2.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/freightmove2.wav" ); break; - case 8: - PRECACHE_SOUND ("plats/heavymove1.wav"); - pev->noiseMoving = MAKE_STRING("plats/heavymove1.wav"); + case 8: + PRECACHE_SOUND( "plats/heavymove1.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/heavymove1.wav" ); break; - case 9: - PRECACHE_SOUND ("plats/rackmove1.wav"); - pev->noiseMoving = MAKE_STRING("plats/rackmove1.wav"); + case 9: + PRECACHE_SOUND( "plats/rackmove1.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/rackmove1.wav" ); break; - case 10: - PRECACHE_SOUND ("plats/railmove1.wav"); - pev->noiseMoving = MAKE_STRING("plats/railmove1.wav"); + case 10: + PRECACHE_SOUND( "plats/railmove1.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/railmove1.wav" ); break; - case 11: - PRECACHE_SOUND ("plats/squeekmove1.wav"); - pev->noiseMoving = MAKE_STRING("plats/squeekmove1.wav"); + case 11: + PRECACHE_SOUND( "plats/squeekmove1.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/squeekmove1.wav" ); break; - case 12: - PRECACHE_SOUND ("plats/talkmove1.wav"); - pev->noiseMoving = MAKE_STRING("plats/talkmove1.wav"); + case 12: + PRECACHE_SOUND( "plats/talkmove1.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/talkmove1.wav" ); break; - case 13: - PRECACHE_SOUND ("plats/talkmove2.wav"); - pev->noiseMoving = MAKE_STRING("plats/talkmove2.wav"); + case 13: + PRECACHE_SOUND( "plats/talkmove2.wav" ); + pev->noiseMoving = MAKE_STRING( "plats/talkmove2.wav" ); break; default: - pev->noiseMoving = MAKE_STRING("common/null.wav"); + pev->noiseMoving = MAKE_STRING( "common/null.wav" ); break; } // set the plat's 'reached destination' stop sound - switch (m_bStopSnd) + switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = MAKE_STRING("common/null.wav"); + case 0: + pev->noiseArrived = MAKE_STRING( "common/null.wav" ); break; - case 1: - PRECACHE_SOUND ("plats/bigstop1.wav"); - pev->noiseArrived = MAKE_STRING("plats/bigstop1.wav"); + case 1: + PRECACHE_SOUND( "plats/bigstop1.wav" ); + pev->noiseArrived = MAKE_STRING( "plats/bigstop1.wav" ); break; - case 2: - PRECACHE_SOUND ("plats/bigstop2.wav"); - pev->noiseArrived = MAKE_STRING("plats/bigstop2.wav"); + case 2: + PRECACHE_SOUND( "plats/bigstop2.wav" ); + pev->noiseArrived = MAKE_STRING( "plats/bigstop2.wav" ); break; - case 3: - PRECACHE_SOUND ("plats/freightstop1.wav"); - pev->noiseArrived = MAKE_STRING("plats/freightstop1.wav"); + case 3: + PRECACHE_SOUND( "plats/freightstop1.wav" ); + pev->noiseArrived = MAKE_STRING( "plats/freightstop1.wav" ); break; - case 4: - PRECACHE_SOUND ("plats/heavystop2.wav"); - pev->noiseArrived = MAKE_STRING("plats/heavystop2.wav"); + case 4: + PRECACHE_SOUND( "plats/heavystop2.wav" ); + pev->noiseArrived = MAKE_STRING( "plats/heavystop2.wav" ); break; - case 5: - PRECACHE_SOUND ("plats/rackstop1.wav"); - pev->noiseArrived = MAKE_STRING("plats/rackstop1.wav"); + case 5: + PRECACHE_SOUND( "plats/rackstop1.wav" ); + pev->noiseArrived = MAKE_STRING( "plats/rackstop1.wav" ); break; - case 6: - PRECACHE_SOUND ("plats/railstop1.wav"); - pev->noiseArrived = MAKE_STRING("plats/railstop1.wav"); + case 6: + PRECACHE_SOUND( "plats/railstop1.wav" ); + pev->noiseArrived = MAKE_STRING( "plats/railstop1.wav" ); break; - case 7: - PRECACHE_SOUND ("plats/squeekstop1.wav"); - pev->noiseArrived = MAKE_STRING("plats/squeekstop1.wav"); + case 7: + PRECACHE_SOUND( "plats/squeekstop1.wav" ); + pev->noiseArrived = MAKE_STRING( "plats/squeekstop1.wav" ); break; - case 8: - PRECACHE_SOUND ("plats/talkstop1.wav"); - pev->noiseArrived = MAKE_STRING("plats/talkstop1.wav"); + case 8: + PRECACHE_SOUND( "plats/talkstop1.wav" ); + pev->noiseArrived = MAKE_STRING( "plats/talkstop1.wav" ); break; - default: - pev->noiseArrived = MAKE_STRING("common/null.wav"); + pev->noiseArrived = MAKE_STRING( "common/null.wav" ); break; } } @@ -230,9 +229,9 @@ public: void EXPORT PlatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT CallGoDown( void ) { GoDown(); } - void EXPORT CallHitTop( void ) { HitTop(); } - void EXPORT CallHitBottom( void ) { HitBottom(); } + void EXPORT CallGoDown( void ) { GoDown(); } + void EXPORT CallHitTop( void ) { HitTop(); } + void EXPORT CallHitBottom( void ) { HitBottom(); } virtual void GoUp( void ); virtual void GoDown( void ); @@ -246,7 +245,7 @@ LINK_ENTITY_TO_CLASS( func_plat, CFuncPlat ) class CPlatTrigger : public CBaseEntity { public: - virtual int ObjectCaps( void ) { return (CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } + virtual int ObjectCaps( void ) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } void SpawnInsideTrigger( CFuncPlat *pPlatform ); void Touch( CBaseEntity *pOther ); CFuncPlat *m_pPlatform; @@ -268,49 +267,49 @@ Set "sounds" to one of the following: 2) chain slow */ -void CFuncPlat :: Setup( void ) +void CFuncPlat::Setup( void ) { - //pev->noiseMovement = MAKE_STRING("plats/platmove1.wav"); - //pev->noiseStopMoving = MAKE_STRING("plats/platstop1.wav"); + //pev->noiseMovement = MAKE_STRING( "plats/platmove1.wav" ); + //pev->noiseStopMoving = MAKE_STRING( "plats/platstop1.wav" ); - if (m_flTLength == 0) + if( m_flTLength == 0 ) m_flTLength = 80; - if (m_flTWidth == 0) + if( m_flTWidth == 0 ) m_flTWidth = 10; - pev->angles = g_vecZero; + pev->angles = g_vecZero; - pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); // set size and link into world - UTIL_SetSize(pev, pev->mins, pev->maxs); - SET_MODEL(ENT(pev), STRING(pev->model) ); + UTIL_SetOrigin( pev, pev->origin ); // set size and link into world + UTIL_SetSize( pev, pev->mins, pev->maxs ); + SET_MODEL( ENT( pev), STRING( pev->model ) ); // vecPosition1 is the top position, vecPosition2 is the bottom m_vecPosition1 = pev->origin; m_vecPosition2 = pev->origin; - if (m_flHeight != 0) + if( m_flHeight != 0 ) m_vecPosition2.z = pev->origin.z - m_flHeight; else m_vecPosition2.z = pev->origin.z - pev->size.z + 8; - if (pev->speed == 0) + if( pev->speed == 0 ) pev->speed = 150; - if ( m_volume == 0 ) + if( m_volume == 0 ) m_volume = 0.85; } -void CFuncPlat :: Precache( ) +void CFuncPlat::Precache() { CBasePlatTrain::Precache(); - //PRECACHE_SOUND("plats/platmove1.wav"); - //PRECACHE_SOUND("plats/platstop1.wav"); - if ( !IsTogglePlat() ) + //PRECACHE_SOUND( "plats/platmove1.wav" ); + //PRECACHE_SOUND( "plats/platstop1.wav" ); + if( !IsTogglePlat() ) PlatSpawnInsideTrigger( pev ); // the "start moving" trigger } -void CFuncPlat :: Spawn( ) +void CFuncPlat::Spawn() { Setup(); @@ -318,70 +317,70 @@ void CFuncPlat :: Spawn( ) // If this platform is the target of some button, it starts at the TOP position, // and is brought down by that button. Otherwise, it starts at BOTTOM. - if ( !FStringNull(pev->targetname) ) + if( !FStringNull( pev->targetname ) ) { - UTIL_SetOrigin (pev, m_vecPosition1); + UTIL_SetOrigin( pev, m_vecPosition1 ); m_toggle_state = TS_AT_TOP; SetUse( &CFuncPlat::PlatUse ); } else { - UTIL_SetOrigin (pev, m_vecPosition2); + UTIL_SetOrigin( pev, m_vecPosition2 ); m_toggle_state = TS_AT_BOTTOM; } } -static void PlatSpawnInsideTrigger(entvars_t* pevPlatform) +static void PlatSpawnInsideTrigger( entvars_t *pevPlatform ) { - GetClassPtr( (CPlatTrigger *)NULL)->SpawnInsideTrigger( GetClassPtr( (CFuncPlat *)pevPlatform ) ); + GetClassPtr( (CPlatTrigger *)NULL )->SpawnInsideTrigger( GetClassPtr( (CFuncPlat *)pevPlatform ) ); } // // Create a trigger entity for a platform. // -void CPlatTrigger :: SpawnInsideTrigger( CFuncPlat *pPlatform ) +void CPlatTrigger::SpawnInsideTrigger( CFuncPlat *pPlatform ) { m_pPlatform = pPlatform; // Create trigger entity, "point" it at the owning platform, give it a touch method - pev->solid = SOLID_TRIGGER; - pev->movetype = MOVETYPE_NONE; + pev->solid = SOLID_TRIGGER; + pev->movetype = MOVETYPE_NONE; pev->origin = pPlatform->pev->origin; // Establish the trigger field's size - Vector vecTMin = m_pPlatform->pev->mins + Vector ( 25 , 25 , 0 ); - Vector vecTMax = m_pPlatform->pev->maxs + Vector ( 25 , 25 , 8 ); + Vector vecTMin = m_pPlatform->pev->mins + Vector( 25, 25, 0 ); + Vector vecTMax = m_pPlatform->pev->maxs + Vector( 25, 25, 8 ); vecTMin.z = vecTMax.z - ( m_pPlatform->m_vecPosition1.z - m_pPlatform->m_vecPosition2.z + 8 ); - if (m_pPlatform->pev->size.x <= 50) + if( m_pPlatform->pev->size.x <= 50 ) { - vecTMin.x = (m_pPlatform->pev->mins.x + m_pPlatform->pev->maxs.x) / 2; + vecTMin.x = ( m_pPlatform->pev->mins.x + m_pPlatform->pev->maxs.x ) / 2; vecTMax.x = vecTMin.x + 1; } - if (m_pPlatform->pev->size.y <= 50) + if( m_pPlatform->pev->size.y <= 50 ) { - vecTMin.y = (m_pPlatform->pev->mins.y + m_pPlatform->pev->maxs.y) / 2; + vecTMin.y = ( m_pPlatform->pev->mins.y + m_pPlatform->pev->maxs.y ) / 2; vecTMax.y = vecTMin.y + 1; } - UTIL_SetSize ( pev, vecTMin, vecTMax ); + UTIL_SetSize( pev, vecTMin, vecTMax ); } // // When the platform's trigger field is touched, the platform ??? // -void CPlatTrigger :: Touch( CBaseEntity *pOther ) +void CPlatTrigger::Touch( CBaseEntity *pOther ) { // Ignore touches by non-players - entvars_t* pevToucher = pOther->pev; - if ( !FClassnameIs (pevToucher, "player") ) + entvars_t *pevToucher = pOther->pev; + if( !FClassnameIs( pevToucher, "player" ) ) return; // Ignore touches by corpses - if (!pOther->IsAlive()) + if( !pOther->IsAlive() ) return; - + // Make linked platform go up/down. - if (m_pPlatform->m_toggle_state == TS_AT_BOTTOM) + if( m_pPlatform->m_toggle_state == TS_AT_BOTTOM ) m_pPlatform->GoUp(); - else if (m_pPlatform->m_toggle_state == TS_AT_TOP) + else if( m_pPlatform->m_toggle_state == TS_AT_TOP ) m_pPlatform->pev->nextthink = m_pPlatform->pev->ltime + 1;// delay going down } @@ -389,26 +388,26 @@ void CPlatTrigger :: Touch( CBaseEntity *pOther ) // Used by SUB_UseTargets, when a platform is the target of a button. // Start bringing platform down. // -void CFuncPlat :: PlatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncPlat::PlatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( IsTogglePlat() ) + if( IsTogglePlat() ) { // Top is off, bottom is on - BOOL on = (m_toggle_state == TS_AT_BOTTOM) ? TRUE : FALSE; + BOOL on = ( m_toggle_state == TS_AT_BOTTOM ) ? TRUE : FALSE; - if ( !ShouldToggle( useType, on ) ) + if( !ShouldToggle( useType, on ) ) return; - if (m_toggle_state == TS_AT_TOP) + if( m_toggle_state == TS_AT_TOP ) GoDown(); - else if ( m_toggle_state == TS_AT_BOTTOM ) + else if( m_toggle_state == TS_AT_BOTTOM ) GoUp(); } else { SetUse( NULL ); - if (m_toggle_state == TS_AT_TOP) + if( m_toggle_state == TS_AT_TOP ) GoDown(); } } @@ -416,61 +415,61 @@ void CFuncPlat :: PlatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY // // Platform is at top, now starts moving down. // -void CFuncPlat :: GoDown( void ) +void CFuncPlat::GoDown( void ) { - if(pev->noiseMovement) - EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMovement), m_volume, ATTN_NORM); + if( pev->noiseMovement ) + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); - ASSERT(m_toggle_state == TS_AT_TOP || m_toggle_state == TS_GOING_UP); + ASSERT( m_toggle_state == TS_AT_TOP || m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_GOING_DOWN; - SetMoveDone( &CFuncPlat::CallHitBottom); - LinearMove(m_vecPosition2, pev->speed); + SetMoveDone( &CFuncPlat::CallHitBottom ); + LinearMove( m_vecPosition2, pev->speed ); } // // Platform has hit bottom. Stops and waits forever. // -void CFuncPlat :: HitBottom( void ) +void CFuncPlat::HitBottom( void ) { - if(pev->noiseMovement) - STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMovement)); + if( pev->noiseMovement ) + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); - if (pev->noiseStopMoving) - EMIT_SOUND(ENT(pev), CHAN_WEAPON, (char*)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + if( pev->noiseStopMoving ) + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); - ASSERT(m_toggle_state == TS_GOING_DOWN); + ASSERT( m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_AT_BOTTOM; } // // Platform is at bottom, now starts moving up // -void CFuncPlat :: GoUp( void ) +void CFuncPlat::GoUp( void ) { - if (pev->noiseMovement) - EMIT_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMovement), m_volume, ATTN_NORM); - - ASSERT(m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN); + if( pev->noiseMovement ) + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + + ASSERT( m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_GOING_UP; - SetMoveDone( &CFuncPlat::CallHitTop); + SetMoveDone( &CFuncPlat::CallHitTop ); LinearMove(m_vecPosition1, pev->speed); } // // Platform has hit top. Pauses, then starts back down again. // -void CFuncPlat :: HitTop( void ) +void CFuncPlat::HitTop( void ) { - if(pev->noiseMovement) - STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMovement)); + if( pev->noiseMovement ) + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); - if (pev->noiseStopMoving) - EMIT_SOUND(ENT(pev), CHAN_WEAPON, (char*)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); - - ASSERT(m_toggle_state == TS_GOING_UP); + if( pev->noiseStopMoving ) + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + + ASSERT( m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_AT_TOP; - if ( !IsTogglePlat() ) + if( !IsTogglePlat() ) { // After a delay, the platform will automatically start going down again. SetThink( &CFuncPlat::CallGoDown ); @@ -478,20 +477,20 @@ void CFuncPlat :: HitTop( void ) } } -void CFuncPlat :: Blocked( CBaseEntity *pOther ) +void CFuncPlat::Blocked( CBaseEntity *pOther ) { - ALERT( at_aiconsole, "%s Blocked by %s\n", STRING(pev->classname), STRING(pOther->pev->classname) ); + ALERT( at_aiconsole, "%s Blocked by %s\n", STRING( pev->classname ), STRING( pOther->pev->classname ) ); // Hurt the blocker a little - pOther->TakeDamage(pev, pev, 1, DMG_CRUSH); + pOther->TakeDamage( pev, pev, 1, DMG_CRUSH ); + + if( pev->noiseMovement ) + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); - if(pev->noiseMovement) - STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMovement)); - // Send the platform back where it came from - ASSERT(m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN); - if (m_toggle_state == TS_GOING_UP) + ASSERT( m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN ); + if( m_toggle_state == TS_GOING_UP ) GoDown(); - else if (m_toggle_state == TS_GOING_DOWN) + else if( m_toggle_state == TS_GOING_DOWN ) GoUp (); } @@ -501,17 +500,17 @@ public: void Spawn( void ); void SetupRotation( void ); - virtual void GoUp( void ); - virtual void GoDown( void ); - virtual void HitTop( void ); - virtual void HitBottom( void ); - - void RotMove( Vector &destAngle, float time ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual void GoUp( void ); + virtual void GoDown( void ); + virtual void HitTop( void ); + virtual void HitBottom( void ); - Vector m_end, m_start; + void RotMove( Vector &destAngle, float time ); + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; + + Vector m_end, m_start; }; LINK_ENTITY_TO_CLASS( func_platrot, CFuncPlatRot ) @@ -523,11 +522,11 @@ TYPEDESCRIPTION CFuncPlatRot::m_SaveData[] = IMPLEMENT_SAVERESTORE( CFuncPlatRot, CFuncPlat ) -void CFuncPlatRot :: SetupRotation( void ) +void CFuncPlatRot::SetupRotation( void ) { - if ( m_vecFinalAngle.x != 0 ) // This plat rotates too! + if( m_vecFinalAngle.x != 0 ) // This plat rotates too! { - CBaseToggle :: AxisDir( pev ); + CBaseToggle::AxisDir( pev ); m_start = pev->angles; m_end = pev->angles + pev->movedir * m_vecFinalAngle.x; } @@ -536,30 +535,30 @@ void CFuncPlatRot :: SetupRotation( void ) m_start = g_vecZero; m_end = g_vecZero; } - if ( !FStringNull(pev->targetname) ) // Start at top + if( !FStringNull( pev->targetname ) ) // Start at top { pev->angles = m_end; } } -void CFuncPlatRot :: Spawn( void ) +void CFuncPlatRot::Spawn( void ) { - CFuncPlat :: Spawn(); + CFuncPlat::Spawn(); SetupRotation(); } -void CFuncPlatRot :: GoDown( void ) +void CFuncPlatRot::GoDown( void ) { - CFuncPlat :: GoDown(); + CFuncPlat::GoDown(); RotMove( m_start, pev->nextthink - pev->ltime ); } // // Platform has hit bottom. Stops and waits forever. // -void CFuncPlatRot :: HitBottom( void ) +void CFuncPlatRot::HitBottom( void ) { - CFuncPlat :: HitBottom(); + CFuncPlat::HitBottom(); pev->avelocity = g_vecZero; pev->angles = m_start; } @@ -567,29 +566,29 @@ void CFuncPlatRot :: HitBottom( void ) // // Platform is at bottom, now starts moving up // -void CFuncPlatRot :: GoUp( void ) +void CFuncPlatRot::GoUp( void ) { - CFuncPlat :: GoUp(); + CFuncPlat::GoUp(); RotMove( m_end, pev->nextthink - pev->ltime ); } // // Platform has hit top. Pauses, then starts back down again. // -void CFuncPlatRot :: HitTop( void ) +void CFuncPlatRot::HitTop( void ) { - CFuncPlat :: HitTop(); + CFuncPlat::HitTop(); pev->avelocity = g_vecZero; pev->angles = m_end; } -void CFuncPlatRot :: RotMove( Vector &destAngle, float time ) +void CFuncPlatRot::RotMove( Vector &destAngle, float time ) { // set destdelta to the vector needed to move Vector vecDestDelta = destAngle - pev->angles; // Travel time is so short, we're practically there already; so make it so. - if ( time >= 0.1) + if( time >= 0.1 ) pev->avelocity = vecDestDelta / time; else { @@ -601,7 +600,6 @@ void CFuncPlatRot :: RotMove( Vector &destAngle, float time ) // //====================== TRAIN code ================================================== // - class CFuncTrain : public CBasePlatTrain { public: @@ -614,16 +612,15 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void KeyValue( KeyValueData *pkvd ); - void EXPORT Wait( void ); void EXPORT Next( void ); - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - entvars_t *m_pevCurrentTarget; - int m_sounds; - BOOL m_activated; + entvars_t *m_pevCurrentTarget; + int m_sounds; + BOOL m_activated; }; LINK_ENTITY_TO_CLASS( func_train, CFuncTrain ) @@ -637,30 +634,30 @@ TYPEDESCRIPTION CFuncTrain::m_SaveData[] = IMPLEMENT_SAVERESTORE( CFuncTrain, CBasePlatTrain ) -void CFuncTrain :: KeyValue( KeyValueData *pkvd ) +void CFuncTrain::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "sounds")) + if( FStrEq( pkvd->szKeyName, "sounds" ) ) { - m_sounds = atoi(pkvd->szValue); + m_sounds = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBasePlatTrain::KeyValue( pkvd ); } -void CFuncTrain :: Blocked( CBaseEntity *pOther ) +void CFuncTrain::Blocked( CBaseEntity *pOther ) { - if ( gpGlobals->time < m_flActivateFinished) + if( gpGlobals->time < m_flActivateFinished ) return; m_flActivateFinished = gpGlobals->time + 0.5; - - pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); + + pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); } -void CFuncTrain :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncTrain::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( pev->spawnflags & SF_TRAIN_WAIT_RETRIGGER ) + if( pev->spawnflags & SF_TRAIN_WAIT_RETRIGGER ) { // Move toward my target pev->spawnflags &= ~SF_TRAIN_WAIT_RETRIGGER; @@ -670,49 +667,48 @@ void CFuncTrain :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE { pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER; // Pop back to last target if it's available - if ( pev->enemy ) + if( pev->enemy ) pev->target = pev->enemy->v.targetname; pev->nextthink = 0; pev->velocity = g_vecZero; - if ( pev->noiseStopMoving ) - EMIT_SOUND (ENT(pev), CHAN_VOICE, (char*)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + if( pev->noiseStopMoving ) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); } } -void CFuncTrain :: Wait( void ) +void CFuncTrain::Wait( void ) { // Fire the pass target if there is one - if ( m_pevCurrentTarget->message ) + if( m_pevCurrentTarget->message ) { - FireTargets( STRING(m_pevCurrentTarget->message), this, this, USE_TOGGLE, 0 ); - if ( FBitSet( m_pevCurrentTarget->spawnflags, SF_CORNER_FIREONCE ) ) + FireTargets( STRING( m_pevCurrentTarget->message ), this, this, USE_TOGGLE, 0 ); + if( FBitSet( m_pevCurrentTarget->spawnflags, SF_CORNER_FIREONCE ) ) m_pevCurrentTarget->message = 0; } - + // need pointer to LAST target. - if ( FBitSet (m_pevCurrentTarget->spawnflags , SF_TRAIN_WAIT_RETRIGGER ) || ( pev->spawnflags & SF_TRAIN_WAIT_RETRIGGER ) ) + if( FBitSet( m_pevCurrentTarget->spawnflags, SF_TRAIN_WAIT_RETRIGGER ) || ( pev->spawnflags & SF_TRAIN_WAIT_RETRIGGER ) ) { pev->spawnflags |= SF_TRAIN_WAIT_RETRIGGER; // clear the sound channel. - if ( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) ); - if ( pev->noiseStopMoving ) - EMIT_SOUND (ENT(pev), CHAN_VOICE, (char*)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + if( pev->noiseMovement ) + STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + if( pev->noiseStopMoving ) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); pev->nextthink = 0; return; } - // ALERT ( at_console, "%f\n", m_flWait ); - - if (m_flWait != 0) + // ALERT( at_console, "%f\n", m_flWait ); + if( m_flWait != 0 ) { // -1 wait will wait forever! pev->nextthink = pev->ltime + m_flWait; - if ( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) ); - if ( pev->noiseStopMoving ) - EMIT_SOUND (ENT(pev), CHAN_VOICE, (char*)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + if( pev->noiseMovement ) + STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + if( pev->noiseStopMoving ) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); SetThink( &CFuncTrain::Next ); } else @@ -724,21 +720,20 @@ void CFuncTrain :: Wait( void ) // // Train next - path corner needs to change to next target // -void CFuncTrain :: Next( void ) +void CFuncTrain::Next( void ) { - CBaseEntity *pTarg; + CBaseEntity *pTarg; - // now find our next target pTarg = GetNextTarget(); if( !pTarg ) { - if ( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) ); + if( pev->noiseMovement ) + STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); // Play stop sound - if ( pev->noiseStopMoving ) - EMIT_SOUND (ENT(pev), CHAN_VOICE, (char*)STRING(pev->noiseStopMoving), m_volume, ATTN_NORM); + if( pev->noiseStopMoving ) + EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); return; } @@ -782,20 +777,20 @@ void CFuncTrain :: Next( void ) } } -void CFuncTrain :: Activate( void ) +void CFuncTrain::Activate( void ) { // Not yet active, so teleport to first target - if ( !m_activated ) + if( !m_activated ) { m_activated = TRUE; - entvars_t *pevTarg = VARS( FIND_ENTITY_BY_TARGETNAME (NULL, STRING(pev->target) ) ); - + entvars_t *pevTarg = VARS( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); + pev->target = pevTarg->target; m_pevCurrentTarget = pevTarg;// keep track of this since path corners change our target for us. - UTIL_SetOrigin (pev, pevTarg->origin - (pev->mins + pev->maxs) * 0.5 ); - - if ( FStringNull(pev->targetname) ) + UTIL_SetOrigin( pev, pevTarg->origin - ( pev->mins + pev->maxs ) * 0.5 ); + + if( FStringNull( pev->targetname ) ) { // not triggered, so start immediately pev->nextthink = pev->ltime + 0.1; SetThink( &CFuncTrain::Next ); @@ -815,58 +810,57 @@ dmg default 2 sounds 1) ratchet metal */ - -void CFuncTrain :: Spawn( void ) +void CFuncTrain::Spawn( void ) { Precache(); - if (pev->speed == 0) + if( pev->speed == 0 ) pev->speed = 100; - if ( FStringNull(pev->target) ) - ALERT(at_console, "FuncTrain with no target"); + if( FStringNull(pev->target) ) + ALERT( at_console, "FuncTrain with no target" ); - if (pev->dmg == 0) + if( pev->dmg == 0 ) pev->dmg = 2; pev->movetype = MOVETYPE_PUSH; - if ( FBitSet (pev->spawnflags, SF_TRACKTRAIN_PASSABLE) ) - pev->solid = SOLID_NOT; + if( FBitSet( pev->spawnflags, SF_TRACKTRAIN_PASSABLE ) ) + pev->solid = SOLID_NOT; else - pev->solid = SOLID_BSP; + pev->solid = SOLID_BSP; - SET_MODEL( ENT(pev), STRING(pev->model) ); - UTIL_SetSize (pev, pev->mins, pev->maxs); - UTIL_SetOrigin(pev, pev->origin); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); + UTIL_SetSize( pev, pev->mins, pev->maxs ); + UTIL_SetOrigin( pev, pev->origin ); m_activated = FALSE; - if ( m_volume == 0 ) + if( m_volume == 0 ) m_volume = 0.85; } void CFuncTrain::Precache( void ) { CBasePlatTrain::Precache(); -#if 0 // obsolete +#if 0 // obsolete // otherwise use preset sound - switch (m_sounds) + switch( m_sounds ) { case 0: pev->noise = 0; pev->noise1 = 0; break; case 1: - PRECACHE_SOUND ("plats/train2.wav"); - PRECACHE_SOUND ("plats/train1.wav"); - pev->noise = MAKE_STRING("plats/train2.wav"); - pev->noise1 = MAKE_STRING("plats/train1.wav"); + PRECACHE_SOUND( "plats/train2.wav" ); + PRECACHE_SOUND( "plats/train1.wav" ); + pev->noise = MAKE_STRING("plats/train2.wav" ); + pev->noise1 = MAKE_STRING("plats/train1.wav" ); break; case 2: - PRECACHE_SOUND ("plats/platmove1.wav"); - PRECACHE_SOUND ("plats/platstop1.wav"); - pev->noise = MAKE_STRING("plats/platstop1.wav"); - pev->noise1 = MAKE_STRING("plats/platmove1.wav"); + PRECACHE_SOUND( "plats/platmove1.wav" ); + PRECACHE_SOUND( "plats/platstop1.wav" ); + pev->noise = MAKE_STRING( "plats/platstop1.wav" ); + pev->noise1 = MAKE_STRING( "plats/platmove1.wav" ); break; } #endif @@ -874,15 +868,15 @@ void CFuncTrain::Precache( void ) void CFuncTrain::OverrideReset( void ) { - CBaseEntity *pTarg; + CBaseEntity *pTarg; // Are we moving? - if ( pev->velocity != g_vecZero && pev->nextthink != 0 ) + if( pev->velocity != g_vecZero && pev->nextthink != 0 ) { pev->target = pev->message; // now find our next target pTarg = GetNextTarget(); - if ( !pTarg ) + if( !pTarg ) { pev->nextthink = 0; pev->velocity = g_vecZero; @@ -920,46 +914,46 @@ TYPEDESCRIPTION CFuncTrackTrain::m_SaveData[] = IMPLEMENT_SAVERESTORE( CFuncTrackTrain, CBaseEntity ) LINK_ENTITY_TO_CLASS( func_tracktrain, CFuncTrackTrain ) -void CFuncTrackTrain :: KeyValue( KeyValueData *pkvd ) +void CFuncTrackTrain::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "wheels")) + if( FStrEq( pkvd->szKeyName, "wheels" ) ) { - m_length = atof(pkvd->szValue); + m_length = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "height")) + else if( FStrEq( pkvd->szKeyName, "height" ) ) { m_height = atof(pkvd->szValue); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "startspeed")) + else if( FStrEq( pkvd->szKeyName, "startspeed" ) ) { m_startSpeed = atof(pkvd->szValue); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "sounds")) + else if( FStrEq( pkvd->szKeyName, "sounds" ) ) { m_sounds = atoi(pkvd->szValue); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "volume")) + else if( FStrEq( pkvd->szKeyName, "volume" ) ) { - m_flVolume = (float) (atoi(pkvd->szValue)); + m_flVolume = (float)atoi( pkvd->szValue ); m_flVolume *= 0.1; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "bank")) + else if( FStrEq( pkvd->szKeyName, "bank" ) ) { - m_flBank = atof(pkvd->szValue); + m_flBank = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseEntity::KeyValue( pkvd ); } -void CFuncTrackTrain :: NextThink( float thinkTime, BOOL alwaysThink ) +void CFuncTrackTrain::NextThink( float thinkTime, BOOL alwaysThink ) { - if ( alwaysThink ) + if( alwaysThink ) pev->flags |= FL_ALWAYSTHINK; else pev->flags &= ~FL_ALWAYSTHINK; @@ -967,38 +961,38 @@ void CFuncTrackTrain :: NextThink( float thinkTime, BOOL alwaysThink ) pev->nextthink = thinkTime; } -void CFuncTrackTrain :: Blocked( CBaseEntity *pOther ) +void CFuncTrackTrain::Blocked( CBaseEntity *pOther ) { - entvars_t *pevOther = pOther->pev; + entvars_t *pevOther = pOther->pev; // Blocker is on-ground on the train - if ( FBitSet( pevOther->flags, FL_ONGROUND ) && VARS(pevOther->groundentity) == pev ) + if( FBitSet( pevOther->flags, FL_ONGROUND ) && VARS( pevOther->groundentity ) == pev ) { - float deltaSpeed = fabs(pev->speed); - if ( deltaSpeed > 50 ) + float deltaSpeed = fabs( pev->speed ); + if( deltaSpeed > 50 ) deltaSpeed = 50; - if ( !pevOther->velocity.z ) + if( !pevOther->velocity.z ) pevOther->velocity.z += deltaSpeed; return; } else - pevOther->velocity = (pevOther->origin - pev->origin ).Normalize() * pev->dmg; + pevOther->velocity = ( pevOther->origin - pev->origin ).Normalize() * pev->dmg; - ALERT( at_aiconsole, "TRAIN(%s): Blocked by %s (dmg:%.2f)\n", STRING(pev->targetname), STRING(pOther->pev->classname), pev->dmg ); - if ( pev->dmg <= 0 ) + ALERT( at_aiconsole, "TRAIN(%s): Blocked by %s (dmg:%.2f)\n", STRING( pev->targetname ), STRING( pOther->pev->classname ), pev->dmg ); + if( pev->dmg <= 0 ) return; // we can't hurt this thing, so we're not concerned with it - pOther->TakeDamage(pev, pev, pev->dmg, DMG_CRUSH); + pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); } -void CFuncTrackTrain :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncTrackTrain::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( useType != USE_SET ) + if( useType != USE_SET ) { - if ( !ShouldToggle( useType, (pev->speed != 0) ) ) + if( !ShouldToggle( useType, ( pev->speed != 0 ) ) ) return; - if ( pev->speed == 0 ) + if( pev->speed == 0 ) { pev->speed = m_speed * m_dir; @@ -1017,27 +1011,27 @@ void CFuncTrackTrain :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ { float delta = value; - delta = ((int)(pev->speed * 4) / (int)m_speed)*0.25 + 0.25 * delta; - if ( delta > 1 ) + delta = ( (int)( pev->speed * 4 ) / (int)m_speed )*0.25 + 0.25 * delta; + if( delta > 1 ) delta = 1; else if ( delta < -1 ) delta = -1; - if ( pev->spawnflags & SF_TRACKTRAIN_FORWARDONLY ) + if( pev->spawnflags & SF_TRACKTRAIN_FORWARDONLY ) { - if ( delta < 0 ) + if( delta < 0 ) delta = 0; } pev->speed = m_speed * delta; Next(); - ALERT( at_aiconsole, "TRAIN(%s), speed to %.2f\n", STRING(pev->targetname), pev->speed ); + ALERT( at_aiconsole, "TRAIN(%s), speed to %.2f\n", STRING( pev->targetname ), pev->speed ); } } static float Fix( float angle ) { - while ( angle < 0 ) + while( angle < 0 ) angle += 360; - while ( angle > 360 ) + while( angle > 360 ) angle -= 360; return angle; @@ -1054,23 +1048,22 @@ static void FixupAngles( Vector &v ) #define TRAIN_MAXPITCH 200 #define TRAIN_MAXSPEED 1000 // approx max speed for sound pitch calculation -void CFuncTrackTrain :: StopSound( void ) +void CFuncTrackTrain::StopSound( void ) { // if sound playing, stop it - if (m_soundPlaying && pev->noise) + if( m_soundPlaying && pev->noise ) { unsigned short us_encode; - unsigned short us_sound = ( ( unsigned short )( m_sounds ) & 0x0007 ) << 12; + unsigned short us_sound = ( (unsigned short)( m_sounds ) & 0x0007 ) << 12; us_encode = us_sound; PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, us_encode, 0, 1, 0 ); - /* - STOP_SOUND(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noise)); + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ) ); */ - EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "plats/ttrain_brake1.wav", m_flVolume, ATTN_NORM, 0, 100); + EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "plats/ttrain_brake1.wav", m_flVolume, ATTN_NORM, 0, 100 ); } m_soundPlaying = 0; @@ -1079,28 +1072,27 @@ void CFuncTrackTrain :: StopSound( void ) // update pitch based on speed, start sound if not playing // NOTE: when train goes through transition, m_soundPlaying should go to 0, // which will cause the looped sound to restart. - -void CFuncTrackTrain :: UpdateSound( void ) +void CFuncTrackTrain::UpdateSound( void ) { float flpitch; - if (!pev->noise) + if( !pev->noise ) return; - flpitch = TRAIN_STARTPITCH + (fabs(pev->speed) * (TRAIN_MAXPITCH - TRAIN_STARTPITCH) / TRAIN_MAXSPEED); + flpitch = TRAIN_STARTPITCH + ( fabs( pev->speed ) * ( TRAIN_MAXPITCH - TRAIN_STARTPITCH ) / TRAIN_MAXSPEED ); - if (!m_soundPlaying) + if( !m_soundPlaying ) { // play startup sound for train - EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "plats/ttrain_start1.wav", m_flVolume, ATTN_NORM, 0, 100); - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noise), m_flVolume, ATTN_NORM, 0, (int) flpitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "plats/ttrain_start1.wav", m_flVolume, ATTN_NORM, 0, 100 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ), m_flVolume, ATTN_NORM, 0, (int)flpitch ); m_soundPlaying = 1; } else { /* // update pitch - EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, (char*)STRING(pev->noise), m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, (int) flpitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ), m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, (int)flpitch ); */ // volume 0.0 - 1.0 - 6 bits // m_sounds 3 bits @@ -1114,27 +1106,27 @@ void CFuncTrackTrain :: UpdateSound( void ) us_encode = us_sound | us_pitch | us_volume; - PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, + PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, us_encode, 0, 0, 0 ); } } -void CFuncTrackTrain :: Next( void ) +void CFuncTrackTrain::Next( void ) { float time = 0.5; - if ( !pev->speed ) + if( !pev->speed ) { - ALERT( at_aiconsole, "TRAIN(%s): Speed is 0\n", STRING(pev->targetname) ); + ALERT( at_aiconsole, "TRAIN(%s): Speed is 0\n", STRING( pev->targetname ) ); StopSound(); return; } -// if ( !m_ppath ) -// m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME( NULL, STRING(pev->target) )); - if ( !m_ppath ) + //if( !m_ppath ) + // m_ppath = CPathTrack::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); + if( !m_ppath ) { - ALERT( at_aiconsole, "TRAIN(%s): Lost path\n", STRING(pev->targetname) ); + ALERT( at_aiconsole, "TRAIN(%s): Lost path\n", STRING( pev->targetname ) ); StopSound(); return; } @@ -1147,11 +1139,11 @@ void CFuncTrackTrain :: Next( void ) CPathTrack *pnext = m_ppath->LookAhead( &nextPos, pev->speed * 0.1, 1 ); nextPos.z += m_height; - pev->velocity = (nextPos - pev->origin) * 10; + pev->velocity = ( nextPos - pev->origin ) * 10; Vector nextFront = pev->origin; nextFront.z -= m_height; - if ( m_length > 0 ) + if( m_length > 0 ) m_ppath->LookAhead( &nextFront, m_length, 0 ); else m_ppath->LookAhead( &nextFront, 100, 0 ); @@ -1166,11 +1158,11 @@ void CFuncTrackTrain :: Next( void ) FixupAngles( angles ); FixupAngles( pev->angles ); - if ( !pnext || (delta.x == 0 && delta.y == 0) ) + if( !pnext || ( delta.x == 0 && delta.y == 0 ) ) angles = pev->angles; float vy, vx; - if ( !(pev->spawnflags & SF_TRACKTRAIN_NOPITCH) ) + if( !( pev->spawnflags & SF_TRACKTRAIN_NOPITCH ) ) vx = UTIL_AngleDistance( angles.x, pev->angles.x ); else vx = 0; @@ -1179,46 +1171,46 @@ void CFuncTrackTrain :: Next( void ) pev->avelocity.y = vy * 10; pev->avelocity.x = vx * 10; - if ( m_flBank != 0 ) + if( m_flBank != 0 ) { - if ( pev->avelocity.y < -5 ) - pev->avelocity.z = UTIL_AngleDistance( UTIL_ApproachAngle( -m_flBank, pev->angles.z, m_flBank*2 ), pev->angles.z); - else if ( pev->avelocity.y > 5 ) - pev->avelocity.z = UTIL_AngleDistance( UTIL_ApproachAngle( m_flBank, pev->angles.z, m_flBank*2 ), pev->angles.z); + if( pev->avelocity.y < -5 ) + pev->avelocity.z = UTIL_AngleDistance( UTIL_ApproachAngle( -m_flBank, pev->angles.z, m_flBank * 2 ), pev->angles.z ); + else if( pev->avelocity.y > 5 ) + pev->avelocity.z = UTIL_AngleDistance( UTIL_ApproachAngle( m_flBank, pev->angles.z, m_flBank * 2 ), pev->angles.z ); else - pev->avelocity.z = UTIL_AngleDistance( UTIL_ApproachAngle( 0, pev->angles.z, m_flBank*4 ), pev->angles.z) * 4; + pev->avelocity.z = UTIL_AngleDistance( UTIL_ApproachAngle( 0, pev->angles.z, m_flBank * 4 ), pev->angles.z ) * 4; } - - if ( pnext ) + + if( pnext ) { - if ( pnext != m_ppath ) + if( pnext != m_ppath ) { CPathTrack *pFire; - if ( pev->speed >= 0 ) + if( pev->speed >= 0 ) pFire = pnext; else pFire = m_ppath; m_ppath = pnext; // Fire the pass target if there is one - if ( pFire->pev->message ) + if( pFire->pev->message ) { - FireTargets( STRING(pFire->pev->message), this, this, USE_TOGGLE, 0 ); - if ( FBitSet( pFire->pev->spawnflags, SF_PATH_FIREONCE ) ) + FireTargets( STRING( pFire->pev->message ), this, this, USE_TOGGLE, 0 ); + if( FBitSet( pFire->pev->spawnflags, SF_PATH_FIREONCE ) ) pFire->pev->message = 0; } - if ( pFire->pev->spawnflags & SF_PATH_DISABLE_TRAIN ) + if( pFire->pev->spawnflags & SF_PATH_DISABLE_TRAIN ) pev->spawnflags |= SF_TRACKTRAIN_NOCONTROL; // Don't override speed if under user control - if ( pev->spawnflags & SF_TRACKTRAIN_NOCONTROL ) + if( pev->spawnflags & SF_TRACKTRAIN_NOCONTROL ) { - if ( pFire->pev->speed != 0 ) + if( pFire->pev->speed != 0 ) { // don't copy speed from target if it is 0 (uninitialized) pev->speed = pFire->pev->speed; - ALERT( at_aiconsole, "TrackTrain %s speed to %4.2f\n", STRING(pev->targetname), pev->speed ); + ALERT( at_aiconsole, "TrackTrain %s speed to %4.2f\n", STRING( pev->targetname ), pev->speed ); } } @@ -1229,7 +1221,7 @@ void CFuncTrackTrain :: Next( void ) else // end of path, stop { StopSound(); - pev->velocity = (nextPos - pev->origin); + pev->velocity = nextPos - pev->origin; pev->avelocity = g_vecZero; float distance = pev->velocity.Length(); m_oldSpeed = pev->speed; @@ -1239,11 +1231,11 @@ void CFuncTrackTrain :: Next( void ) // Move to the dead end // Are we there yet? - if ( distance > 0 ) + if( distance > 0 ) { // no, how long to get there? time = distance / m_oldSpeed; - pev->velocity = pev->velocity * (m_oldSpeed / distance); + pev->velocity = pev->velocity * ( m_oldSpeed / distance ); SetThink( &CFuncTrackTrain::DeadEnd ); NextThink( pev->ltime + time, FALSE ); } @@ -1261,45 +1253,45 @@ void CFuncTrackTrain::DeadEnd( void ) pTrack = m_ppath; - ALERT( at_aiconsole, "TRAIN(%s): Dead end ", STRING(pev->targetname) ); + ALERT( at_aiconsole, "TRAIN(%s): Dead end ", STRING( pev->targetname ) ); // Find the dead end path node // HACKHACK -- This is bugly, but the train can actually stop moving at a different node depending on it's speed // so we have to traverse the list to it's end. - if ( pTrack ) + if( pTrack ) { - if ( m_oldSpeed < 0 ) + if( m_oldSpeed < 0 ) { do { pNext = pTrack->ValidPath( pTrack->GetPrevious(), TRUE ); - if ( pNext ) + if( pNext ) pTrack = pNext; - } while ( pNext ); + } while( pNext ); } else { do { pNext = pTrack->ValidPath( pTrack->GetNext(), TRUE ); - if ( pNext ) + if( pNext ) pTrack = pNext; - } while ( pNext ); + } while( pNext ); } } pev->velocity = g_vecZero; pev->avelocity = g_vecZero; - if ( pTrack ) + if( pTrack ) { - ALERT( at_aiconsole, "at %s\n", STRING(pTrack->pev->targetname) ); - if ( pTrack->pev->netname ) - FireTargets( STRING(pTrack->pev->netname), this, this, USE_TOGGLE, 0 ); + ALERT( at_aiconsole, "at %s\n", STRING( pTrack->pev->targetname ) ); + if( pTrack->pev->netname ) + FireTargets( STRING( pTrack->pev->netname ), this, this, USE_TOGGLE, 0 ); } else ALERT( at_aiconsole, "\n" ); } -void CFuncTrackTrain :: SetControls( entvars_t *pevControls ) +void CFuncTrackTrain::SetControls( entvars_t *pevControls ) { Vector offset = pevControls->origin - pev->oldorigin; @@ -1307,11 +1299,11 @@ void CFuncTrackTrain :: SetControls( entvars_t *pevControls ) m_controlMaxs = pevControls->maxs + offset; } -BOOL CFuncTrackTrain :: OnControls( entvars_t *pevTest ) +BOOL CFuncTrackTrain::OnControls( entvars_t *pevTest ) { Vector offset = pevTest->origin - pev->origin; - if ( pev->spawnflags & SF_TRACKTRAIN_NOCONTROL ) + if( pev->spawnflags & SF_TRACKTRAIN_NOCONTROL ) return FALSE; // Transform offset into local coordinates @@ -1321,21 +1313,21 @@ BOOL CFuncTrackTrain :: OnControls( entvars_t *pevTest ) local.y = -DotProduct( offset, gpGlobals->v_right ); local.z = DotProduct( offset, gpGlobals->v_up ); - if ( local.x >= m_controlMins.x && local.y >= m_controlMins.y && local.z >= m_controlMins.z && + if( local.x >= m_controlMins.x && local.y >= m_controlMins.y && local.z >= m_controlMins.z && local.x <= m_controlMaxs.x && local.y <= m_controlMaxs.y && local.z <= m_controlMaxs.z ) return TRUE; return FALSE; } -void CFuncTrackTrain :: Find( void ) +void CFuncTrackTrain::Find( void ) { - m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME( NULL, STRING(pev->target) )); - if ( !m_ppath ) + m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); + if( !m_ppath ) return; entvars_t *pevTarget = m_ppath->pev; - if ( !FClassnameIs( pevTarget, "path_track" ) ) + if( !FClassnameIs( pevTarget, "path_track" ) ) { ALERT( at_error, "func_track_train must be on a path of path_track\n" ); m_ppath = NULL; @@ -1354,7 +1346,7 @@ void CFuncTrackTrain :: Find( void ) // The train actually points west pev->angles.y += 180; - if ( pev->spawnflags & SF_TRACKTRAIN_NOPITCH ) + if( pev->spawnflags & SF_TRACKTRAIN_NOPITCH ) pev->angles.x = 0; UTIL_SetOrigin( pev, nextPos ); NextThink( pev->ltime + 0.1, FALSE ); @@ -1364,7 +1356,7 @@ void CFuncTrackTrain :: Find( void ) UpdateSound(); } -void CFuncTrackTrain :: NearestPath( void ) +void CFuncTrackTrain::NearestPath( void ) { CBaseEntity *pTrack = NULL; CBaseEntity *pNearest = NULL; @@ -1372,13 +1364,13 @@ void CFuncTrackTrain :: NearestPath( void ) closest = 1024; - while ((pTrack = UTIL_FindEntityInSphere( pTrack, pev->origin, 1024 )) != NULL) + while( ( pTrack = UTIL_FindEntityInSphere( pTrack, pev->origin, 1024 ) ) != NULL ) { // filter out non-tracks - if ( !(pTrack->pev->flags & (FL_CLIENT|FL_MONSTER)) && FClassnameIs( pTrack->pev, "path_track" ) ) + if( !( pTrack->pev->flags & ( FL_CLIENT | FL_MONSTER ) ) && FClassnameIs( pTrack->pev, "path_track" ) ) { - dist = (pev->origin - pTrack->pev->origin).Length(); - if ( dist < closest ) + dist = ( pev->origin - pTrack->pev->origin ).Length(); + if( dist < closest ) { closest = dist; pNearest = pTrack; @@ -1386,25 +1378,25 @@ void CFuncTrackTrain :: NearestPath( void ) } } - if ( !pNearest ) + if( !pNearest ) { ALERT( at_console, "Can't find a nearby track !!!\n" ); SetThink( NULL ); return; } - ALERT( at_aiconsole, "TRAIN: %s, Nearest track is %s\n", STRING(pev->targetname), STRING(pNearest->pev->targetname) ); + ALERT( at_aiconsole, "TRAIN: %s, Nearest track is %s\n", STRING( pev->targetname ), STRING( pNearest->pev->targetname ) ); // If I'm closer to the next path_track on this path, then it's my real path - pTrack = ((CPathTrack *)pNearest)->GetNext(); - if ( pTrack ) + pTrack = ( (CPathTrack *)pNearest )->GetNext(); + if( pTrack ) { - if ( (pev->origin - pTrack->pev->origin).Length() < (pev->origin - pNearest->pev->origin).Length() ) + if( ( pev->origin - pTrack->pev->origin ).Length() < ( pev->origin - pNearest->pev->origin ).Length() ) pNearest = pTrack; } m_ppath = (CPathTrack *)pNearest; - if ( pev->speed != 0 ) + if( pev->speed != 0 ) { NextThink( pev->ltime + 0.1, FALSE ); SetThink( &CFuncTrackTrain::Next ); @@ -1419,8 +1411,8 @@ void CFuncTrackTrain::OverrideReset( void ) CFuncTrackTrain *CFuncTrackTrain::Instance( edict_t *pent ) { - if ( FClassnameIs( pent, "func_tracktrain" ) ) - return (CFuncTrackTrain *)GET_PRIVATE(pent); + if( FClassnameIs( pent, "func_tracktrain" ) ) + return (CFuncTrackTrain *)GET_PRIVATE( pent ); return NULL; } @@ -1435,9 +1427,9 @@ sounds 1) ratchet metal */ -void CFuncTrackTrain :: Spawn( void ) +void CFuncTrackTrain::Spawn( void ) { - if ( pev->speed == 0 ) + if( pev->speed == 0 ) m_speed = 100; else m_speed = pev->speed; @@ -1449,16 +1441,16 @@ void CFuncTrackTrain :: Spawn( void ) m_dir = 1; - if ( FStringNull(pev->target) ) + if( FStringNull( pev->target ) ) ALERT( at_console, "FuncTrain with no target" ); - if ( pev->spawnflags & SF_TRACKTRAIN_PASSABLE ) + if( pev->spawnflags & SF_TRACKTRAIN_PASSABLE ) pev->solid = SOLID_NOT; else pev->solid = SOLID_BSP; pev->movetype = MOVETYPE_PUSH; - SET_MODEL( ENT(pev), STRING(pev->model) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); UTIL_SetSize( pev, pev->mins, pev->maxs ); UTIL_SetOrigin( pev, pev->origin ); @@ -1477,27 +1469,45 @@ void CFuncTrackTrain :: Spawn( void ) Precache(); } -void CFuncTrackTrain :: Precache( void ) +void CFuncTrackTrain::Precache( void ) { - if (m_flVolume == 0.0) + if( m_flVolume == 0.0 ) m_flVolume = 1.0; - switch (m_sounds) + switch( m_sounds ) { default: // no sound pev->noise = 0; break; - case 1: PRECACHE_SOUND("plats/ttrain1.wav"); pev->noise = MAKE_STRING("plats/ttrain1.wav");break; - case 2: PRECACHE_SOUND("plats/ttrain2.wav"); pev->noise = MAKE_STRING("plats/ttrain2.wav");break; - case 3: PRECACHE_SOUND("plats/ttrain3.wav"); pev->noise = MAKE_STRING("plats/ttrain3.wav");break; - case 4: PRECACHE_SOUND("plats/ttrain4.wav"); pev->noise = MAKE_STRING("plats/ttrain4.wav");break; - case 5: PRECACHE_SOUND("plats/ttrain6.wav"); pev->noise = MAKE_STRING("plats/ttrain6.wav");break; - case 6: PRECACHE_SOUND("plats/ttrain7.wav"); pev->noise = MAKE_STRING("plats/ttrain7.wav");break; + case 1: + PRECACHE_SOUND( "plats/ttrain1.wav" ); + pev->noise = MAKE_STRING("plats/ttrain1.wav" ); + break; + case 2: + PRECACHE_SOUND( "plats/ttrain2.wav" ); + pev->noise = MAKE_STRING( "plats/ttrain2.wav" ); + break; + case 3: + PRECACHE_SOUND( "plats/ttrain3.wav" ); + pev->noise = MAKE_STRING( "plats/ttrain3.wav" ); + break; + case 4: + PRECACHE_SOUND( "plats/ttrain4.wav" ); + pev->noise = MAKE_STRING( "plats/ttrain4.wav" ); + break; + case 5: + PRECACHE_SOUND( "plats/ttrain6.wav" ); + pev->noise = MAKE_STRING( "plats/ttrain6.wav" ); + break; + case 6: + PRECACHE_SOUND( "plats/ttrain7.wav" ); + pev->noise = MAKE_STRING( "plats/ttrain7.wav" ); + break; } - PRECACHE_SOUND("plats/ttrain_brake1.wav"); - PRECACHE_SOUND("plats/ttrain_start1.wav"); + PRECACHE_SOUND( "plats/ttrain_brake1.wav" ); + PRECACHE_SOUND( "plats/ttrain_start1.wav" ); m_usAdjustPitch = PRECACHE_EVENT( 1, "events/train.sc" ); } @@ -1506,38 +1516,38 @@ void CFuncTrackTrain :: Precache( void ) class CFuncTrainControls : public CBaseEntity { public: - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int ObjectCaps( void ) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } void Spawn( void ); void EXPORT Find( void ); }; LINK_ENTITY_TO_CLASS( func_traincontrols, CFuncTrainControls ) -void CFuncTrainControls :: Find( void ) +void CFuncTrainControls::Find( void ) { edict_t *pTarget = NULL; do { - pTarget = FIND_ENTITY_BY_TARGETNAME( pTarget, STRING(pev->target) ); - } while ( !FNullEnt(pTarget) && !FClassnameIs(pTarget, "func_tracktrain") ); + pTarget = FIND_ENTITY_BY_TARGETNAME( pTarget, STRING( pev->target ) ); + } while( !FNullEnt(pTarget) && !FClassnameIs( pTarget, "func_tracktrain" ) ); - if ( FNullEnt( pTarget ) ) + if( FNullEnt( pTarget ) ) { - ALERT( at_console, "No train %s\n", STRING(pev->target) ); + ALERT( at_console, "No train %s\n", STRING( pev->target ) ); return; } - CFuncTrackTrain *ptrain = CFuncTrackTrain::Instance(pTarget); + CFuncTrackTrain *ptrain = CFuncTrackTrain::Instance( pTarget ); ptrain->SetControls( pev ); UTIL_Remove( this ); } -void CFuncTrainControls :: Spawn( void ) +void CFuncTrainControls::Spawn( void ) { pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - SET_MODEL( ENT(pev), STRING(pev->model) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); UTIL_SetSize( pev, pev->mins, pev->maxs ); UTIL_SetOrigin( pev, pev->origin ); @@ -1551,11 +1561,10 @@ void CFuncTrainControls :: Spawn( void ) // Track changer / Train elevator // // ---------------------------------------------------------------------------- - -#define SF_TRACK_ACTIVATETRAIN 0x00000001 +#define SF_TRACK_ACTIVATETRAIN 0x00000001 #define SF_TRACK_RELINK 0x00000002 #define SF_TRACK_ROTMOVE 0x00000004 -#define SF_TRACK_STARTBOTTOM 0x00000008 +#define SF_TRACK_STARTBOTTOM 0x00000008 #define SF_TRACK_DONT_MOVE 0x00000010 // @@ -1563,8 +1572,12 @@ void CFuncTrainControls :: Spawn( void ) // It must be larger in X-Y planar area than the train, since it must contain the // train within these dimensions in order to operate when the train is near it. // - -typedef enum { TRAIN_SAFE, TRAIN_BLOCKING, TRAIN_FOLLOWING } TRAIN_CODE; +typedef enum +{ + TRAIN_SAFE, + TRAIN_BLOCKING, + TRAIN_FOLLOWING +}TRAIN_CODE; class CFuncTrackChange : public CFuncPlatRot { @@ -1572,42 +1585,42 @@ public: void Spawn( void ); void Precache( void ); - //virtual void Blocked( void ); - virtual void EXPORT GoUp( void ); - virtual void EXPORT GoDown( void ); - - void KeyValue( KeyValueData* pkvd ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - void EXPORT Find( void ); - TRAIN_CODE EvaluateTrain( CPathTrack *pcurrent ); - void UpdateTrain( Vector &dest ); - virtual void HitBottom( void ); - virtual void HitTop( void ); - void Touch( CBaseEntity *pOther ); - virtual void UpdateAutoTargets( int toggleState ); - virtual BOOL IsTogglePlat( void ) { return TRUE; } + //virtual void Blocked( void ); + virtual void EXPORT GoUp( void ); + virtual void EXPORT GoDown( void ); + + void KeyValue( KeyValueData* pkvd ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void EXPORT Find( void ); + TRAIN_CODE EvaluateTrain( CPathTrack *pcurrent ); + void UpdateTrain( Vector &dest ); + virtual void HitBottom( void ); + virtual void HitTop( void ); + void Touch( CBaseEntity *pOther ); + virtual void UpdateAutoTargets( int toggleState ); + virtual BOOL IsTogglePlat( void ) { return TRUE; } - void DisableUse( void ) { m_use = 0; } - void EnableUse( void ) { m_use = 1; } - int UseEnabled( void ) { return m_use; } + void DisableUse( void ) { m_use = 0; } + void EnableUse( void ) { m_use = 1; } + int UseEnabled( void ) { return m_use; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; - virtual void OverrideReset( void ); + virtual void OverrideReset( void ); - CPathTrack *m_trackTop; - CPathTrack *m_trackBottom; + CPathTrack *m_trackTop; + CPathTrack *m_trackBottom; CFuncTrackTrain *m_train; - int m_trackTopName; - int m_trackBottomName; - int m_trainName; - TRAIN_CODE m_code; - int m_targetState; - int m_use; + int m_trackTopName; + int m_trackBottomName; + int m_trainName; + TRAIN_CODE m_code; + int m_targetState; + int m_use; }; LINK_ENTITY_TO_CLASS( func_trackchange, CFuncTrackChange ) @@ -1627,24 +1640,24 @@ TYPEDESCRIPTION CFuncTrackChange::m_SaveData[] = IMPLEMENT_SAVERESTORE( CFuncTrackChange, CFuncPlatRot ) -void CFuncTrackChange :: Spawn( void ) +void CFuncTrackChange::Spawn( void ) { Setup(); - if ( FBitSet( pev->spawnflags, SF_TRACK_DONT_MOVE ) ) + if( FBitSet( pev->spawnflags, SF_TRACK_DONT_MOVE ) ) m_vecPosition2.z = pev->origin.z; SetupRotation(); - if ( FBitSet( pev->spawnflags, SF_TRACK_STARTBOTTOM ) ) + if( FBitSet( pev->spawnflags, SF_TRACK_STARTBOTTOM ) ) { - UTIL_SetOrigin (pev, m_vecPosition2); + UTIL_SetOrigin( pev, m_vecPosition2 ); m_toggle_state = TS_AT_BOTTOM; pev->angles = m_start; m_targetState = TS_AT_TOP; } else { - UTIL_SetOrigin (pev, m_vecPosition1); + UTIL_SetOrigin( pev, m_vecPosition1 ); m_toggle_state = TS_AT_TOP; pev->angles = m_end; m_targetState = TS_AT_BOTTOM; @@ -1656,7 +1669,7 @@ void CFuncTrackChange :: Spawn( void ) Precache(); } -void CFuncTrackChange :: Precache( void ) +void CFuncTrackChange::Precache( void ) { // Can't trigger sound PRECACHE_SOUND( "buttons/button11.wav" ); @@ -1665,7 +1678,7 @@ void CFuncTrackChange :: Precache( void ) } // UNDONE: Filter touches before re-evaluating the train. -void CFuncTrackChange :: Touch( CBaseEntity *pOther ) +void CFuncTrackChange::Touch( CBaseEntity *pOther ) { #if 0 TRAIN_CODE code; @@ -1673,19 +1686,19 @@ void CFuncTrackChange :: Touch( CBaseEntity *pOther ) #endif } -void CFuncTrackChange :: KeyValue( KeyValueData *pkvd ) +void CFuncTrackChange::KeyValue( KeyValueData *pkvd ) { - if ( FStrEq(pkvd->szKeyName, "train") ) + if( FStrEq( pkvd->szKeyName, "train" ) ) { m_trainName = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "toptrack") ) + else if( FStrEq( pkvd->szKeyName, "toptrack" ) ) { m_trackTopName = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if ( FStrEq(pkvd->szKeyName, "bottomtrack") ) + else if( FStrEq( pkvd->szKeyName, "bottomtrack" ) ) { m_trackBottomName = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -1702,29 +1715,29 @@ void CFuncTrackChange::OverrideReset( void ) SetThink( &CFuncTrackChange::Find ); } -void CFuncTrackChange :: Find( void ) +void CFuncTrackChange::Find( void ) { // Find track entities edict_t *target; - target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_trackTopName) ); - if ( !FNullEnt(target) ) + target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_trackTopName ) ); + if( !FNullEnt( target ) ) { m_trackTop = CPathTrack::Instance( target ); - target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_trackBottomName) ); - if ( !FNullEnt(target) ) + target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_trackBottomName ) ); + if( !FNullEnt( target ) ) { m_trackBottom = CPathTrack::Instance( target ); - target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_trainName) ); - if ( !FNullEnt(target) ) + target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_trainName ) ); + if( !FNullEnt( target ) ) { - m_train = CFuncTrackTrain::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_trainName) ) ); - if ( !m_train ) + m_train = CFuncTrackTrain::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_trainName ) ) ); + if( !m_train ) { - ALERT( at_error, "Can't find train for track change! %s\n", STRING(m_trainName) ); + ALERT( at_error, "Can't find train for track change! %s\n", STRING( m_trainName ) ); return; } - Vector center = (pev->absmin + pev->absmax) * 0.5; + Vector center = ( pev->absmin + pev->absmax ) * 0.5; m_trackBottom = m_trackBottom->Nearest( center ); m_trackTop = m_trackTop->Nearest( center ); UpdateAutoTargets( m_toggle_state ); @@ -1733,34 +1746,34 @@ void CFuncTrackChange :: Find( void ) } else { - ALERT( at_error, "Can't find train for track change! %s\n", STRING(m_trainName) ); - target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING(m_trainName) ); + ALERT( at_error, "Can't find train for track change! %s\n", STRING( m_trainName ) ); + target = FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_trainName ) ); } } else - ALERT( at_error, "Can't find bottom track for track change! %s\n", STRING(m_trackBottomName) ); + ALERT( at_error, "Can't find bottom track for track change! %s\n", STRING( m_trackBottomName ) ); } else - ALERT( at_error, "Can't find top track for track change! %s\n", STRING(m_trackTopName) ); + ALERT( at_error, "Can't find top track for track change! %s\n", STRING( m_trackTopName ) ); } -TRAIN_CODE CFuncTrackChange :: EvaluateTrain( CPathTrack *pcurrent ) +TRAIN_CODE CFuncTrackChange::EvaluateTrain( CPathTrack *pcurrent ) { // Go ahead and work, we don't have anything to switch, so just be an elevator - if ( !pcurrent || !m_train ) + if( !pcurrent || !m_train ) return TRAIN_SAFE; - if ( m_train->m_ppath == pcurrent || (pcurrent->m_pprevious && m_train->m_ppath == pcurrent->m_pprevious) || - (pcurrent->m_pnext && m_train->m_ppath == pcurrent->m_pnext) ) + if( m_train->m_ppath == pcurrent || ( pcurrent->m_pprevious && m_train->m_ppath == pcurrent->m_pprevious ) || + ( pcurrent->m_pnext && m_train->m_ppath == pcurrent->m_pnext ) ) { - if ( m_train->pev->speed != 0 ) + if( m_train->pev->speed != 0 ) return TRAIN_BLOCKING; Vector dist = pev->origin - m_train->pev->origin; float length = dist.Length2D(); - if ( length < m_train->m_length ) // Empirically determined close distance + if( length < m_train->m_length ) // Empirically determined close distance return TRAIN_FOLLOWING; - else if ( length > (150 + m_train->m_length) ) + else if( length > ( 150 + m_train->m_length ) ) return TRAIN_SAFE; return TRAIN_BLOCKING; @@ -1769,16 +1782,16 @@ TRAIN_CODE CFuncTrackChange :: EvaluateTrain( CPathTrack *pcurrent ) return TRAIN_SAFE; } -void CFuncTrackChange :: UpdateTrain( Vector &dest ) +void CFuncTrackChange::UpdateTrain( Vector &dest ) { - float time = (pev->nextthink - pev->ltime); + float time = ( pev->nextthink - pev->ltime ); m_train->pev->velocity = pev->velocity; m_train->pev->avelocity = pev->avelocity; m_train->NextThink( m_train->pev->ltime + time, FALSE ); // Attempt at getting the train to rotate properly around the origin of the trackchange - if ( time <= 0 ) + if( time <= 0 ) return; Vector offset = m_train->pev->origin - pev->origin; @@ -1791,12 +1804,12 @@ void CFuncTrackChange :: UpdateTrain( Vector &dest ) local.z = DotProduct( offset, gpGlobals->v_up ); local = local - offset; - m_train->pev->velocity = pev->velocity + (local * (1.0/time)); + m_train->pev->velocity = pev->velocity + ( local * ( 1.0 / time ) ); } -void CFuncTrackChange :: GoDown( void ) +void CFuncTrackChange::GoDown( void ) { - if ( m_code == TRAIN_BLOCKING ) + if( m_code == TRAIN_BLOCKING ) return; // HitBottom may get called during CFuncPlat::GoDown(), so set up for that @@ -1804,7 +1817,7 @@ void CFuncTrackChange :: GoDown( void ) UpdateAutoTargets( TS_GOING_DOWN ); // If ROTMOVE, move & rotate - if ( FBitSet( pev->spawnflags, SF_TRACK_DONT_MOVE ) ) + if( FBitSet( pev->spawnflags, SF_TRACK_DONT_MOVE ) ) { SetMoveDone( &CFuncPlat::CallHitBottom ); m_toggle_state = TS_GOING_DOWN; @@ -1812,14 +1825,14 @@ void CFuncTrackChange :: GoDown( void ) } else { - CFuncPlat :: GoDown(); + CFuncPlat::GoDown(); SetMoveDone( &CFuncPlat::CallHitBottom ); RotMove( m_start, pev->nextthink - pev->ltime ); } // Otherwise, rotate first, move second // If the train is moving with the platform, update it - if ( m_code == TRAIN_FOLLOWING ) + if( m_code == TRAIN_FOLLOWING ) { UpdateTrain( m_start ); m_train->m_ppath = NULL; @@ -1829,16 +1842,15 @@ void CFuncTrackChange :: GoDown( void ) // // Platform is at bottom, now starts moving up // -void CFuncTrackChange :: GoUp( void ) +void CFuncTrackChange::GoUp( void ) { - if ( m_code == TRAIN_BLOCKING ) + if( m_code == TRAIN_BLOCKING ) return; // HitTop may get called during CFuncPlat::GoUp(), so set up for that // before you call GoUp(); - UpdateAutoTargets( TS_GOING_UP ); - if ( FBitSet( pev->spawnflags, SF_TRACK_DONT_MOVE ) ) + if( FBitSet( pev->spawnflags, SF_TRACK_DONT_MOVE ) ) { m_toggle_state = TS_GOING_UP; SetMoveDone( &CFuncPlat::CallHitTop ); @@ -1847,7 +1859,7 @@ void CFuncTrackChange :: GoUp( void ) else { // If ROTMOVE, move & rotate - CFuncPlat :: GoUp(); + CFuncPlat::GoUp(); SetMoveDone( &CFuncPlat::CallHitTop ); RotMove( m_end, pev->nextthink - pev->ltime ); } @@ -1855,7 +1867,7 @@ void CFuncTrackChange :: GoUp( void ) // Otherwise, move first, rotate second // If the train is moving with the platform, update it - if ( m_code == TRAIN_FOLLOWING ) + if( m_code == TRAIN_FOLLOWING ) { UpdateTrain( m_end ); m_train->m_ppath = NULL; @@ -1863,47 +1875,46 @@ void CFuncTrackChange :: GoUp( void ) } // Normal track change -void CFuncTrackChange :: UpdateAutoTargets( int toggleState ) +void CFuncTrackChange::UpdateAutoTargets( int toggleState ) { - if ( !m_trackTop || !m_trackBottom ) + if( !m_trackTop || !m_trackBottom ) return; - if ( toggleState == TS_AT_TOP ) + if( toggleState == TS_AT_TOP ) ClearBits( m_trackTop->pev->spawnflags, SF_PATH_DISABLED ); else SetBits( m_trackTop->pev->spawnflags, SF_PATH_DISABLED ); - if ( toggleState == TS_AT_BOTTOM ) + if( toggleState == TS_AT_BOTTOM ) ClearBits( m_trackBottom->pev->spawnflags, SF_PATH_DISABLED ); else SetBits( m_trackBottom->pev->spawnflags, SF_PATH_DISABLED ); } -void CFuncTrackChange :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncTrackChange::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( m_toggle_state != TS_AT_TOP && m_toggle_state != TS_AT_BOTTOM ) + if( m_toggle_state != TS_AT_TOP && m_toggle_state != TS_AT_BOTTOM ) return; // If train is in "safe" area, but not on the elevator, play alarm sound - if ( m_toggle_state == TS_AT_TOP ) + if( m_toggle_state == TS_AT_TOP ) m_code = EvaluateTrain( m_trackTop ); - else if ( m_toggle_state == TS_AT_BOTTOM ) + else if( m_toggle_state == TS_AT_BOTTOM ) m_code = EvaluateTrain( m_trackBottom ); else m_code = TRAIN_BLOCKING; - if ( m_code == TRAIN_BLOCKING ) + if( m_code == TRAIN_BLOCKING ) { // Play alarm and return - EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/button11.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "buttons/button11.wav", 1, ATTN_NORM ); return; } // Otherwise, it's safe to move // If at top, go down // at bottom, go up - DisableUse(); - if (m_toggle_state == TS_AT_TOP) + if( m_toggle_state == TS_AT_TOP ) GoDown(); else GoUp(); @@ -1912,10 +1923,10 @@ void CFuncTrackChange :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE // // Platform has hit bottom. Stops and waits forever. // -void CFuncTrackChange :: HitBottom( void ) +void CFuncTrackChange::HitBottom( void ) { - CFuncPlatRot :: HitBottom(); - if ( m_code == TRAIN_FOLLOWING ) + CFuncPlatRot::HitBottom(); + if( m_code == TRAIN_FOLLOWING ) { //UpdateTrain(); m_train->SetTrack( m_trackBottom ); @@ -1931,10 +1942,10 @@ void CFuncTrackChange :: HitBottom( void ) // // Platform has hit bottom. Stops and waits forever. // -void CFuncTrackChange :: HitTop( void ) +void CFuncTrackChange::HitTop( void ) { - CFuncPlatRot :: HitTop(); - if ( m_code == TRAIN_FOLLOWING ) + CFuncPlatRot::HitTop(); + if( m_code == TRAIN_FOLLOWING ) { //UpdateTrain(); m_train->SetTrack( m_trackTop ); @@ -1957,14 +1968,14 @@ public: LINK_ENTITY_TO_CLASS( func_trackautochange, CFuncTrackAuto ) // Auto track change -void CFuncTrackAuto :: UpdateAutoTargets( int toggleState ) +void CFuncTrackAuto::UpdateAutoTargets( int toggleState ) { CPathTrack *pTarget, *pNextTarget; - if ( !m_trackTop || !m_trackBottom ) + if( !m_trackTop || !m_trackBottom ) return; - if ( m_targetState == TS_AT_TOP ) + if( m_targetState == TS_AT_TOP ) { pTarget = m_trackTop->GetNext(); pNextTarget = m_trackBottom->GetNext(); @@ -1974,40 +1985,40 @@ void CFuncTrackAuto :: UpdateAutoTargets( int toggleState ) pTarget = m_trackBottom->GetNext(); pNextTarget = m_trackTop->GetNext(); } - if ( pTarget ) + if( pTarget ) { ClearBits( pTarget->pev->spawnflags, SF_PATH_DISABLED ); - if ( m_code == TRAIN_FOLLOWING && m_train && m_train->pev->speed == 0 ) + if( m_code == TRAIN_FOLLOWING && m_train && m_train->pev->speed == 0 ) m_train->Use( this, this, USE_ON, 0 ); } - if ( pNextTarget ) + if( pNextTarget ) SetBits( pNextTarget->pev->spawnflags, SF_PATH_DISABLED ); } -void CFuncTrackAuto :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +void CFuncTrackAuto::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CPathTrack *pTarget; - if ( !UseEnabled() ) + if( !UseEnabled() ) return; - if ( m_toggle_state == TS_AT_TOP ) + if( m_toggle_state == TS_AT_TOP ) pTarget = m_trackTop; - else if ( m_toggle_state == TS_AT_BOTTOM ) + else if( m_toggle_state == TS_AT_BOTTOM ) pTarget = m_trackBottom; else pTarget = NULL; - if ( FClassnameIs( pActivator->pev, "func_tracktrain" ) ) + if( FClassnameIs( pActivator->pev, "func_tracktrain" ) ) { m_code = EvaluateTrain( pTarget ); // Safe to fire? - if ( m_code == TRAIN_FOLLOWING && m_toggle_state != m_targetState ) + if( m_code == TRAIN_FOLLOWING && m_toggle_state != m_targetState ) { DisableUse(); - if (m_toggle_state == TS_AT_TOP) + if( m_toggle_state == TS_AT_TOP ) GoDown(); else GoUp(); @@ -2015,11 +2026,11 @@ void CFuncTrackAuto :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T } else { - if ( pTarget ) + if( pTarget ) pTarget = pTarget->GetNext(); - if ( pTarget && m_train->m_ppath != pTarget && ShouldToggle( useType, m_targetState ) ) + if( pTarget && m_train->m_ppath != pTarget && ShouldToggle( useType, m_targetState ) ) { - if ( m_targetState == TS_AT_TOP ) + if( m_targetState == TS_AT_TOP ) m_targetState = TS_AT_BOTTOM; else m_targetState = TS_AT_TOP; @@ -2041,27 +2052,27 @@ void CFuncTrackAuto :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T class CGunTarget : public CBaseMonster { public: - void Spawn( void ); - void Activate( void ); - void EXPORT Next( void ); - void EXPORT Start( void ); - void EXPORT Wait( void ); - void Stop( void ); - - int BloodColor( void ) { return DONT_BLEED; } - int Classify( void ) { return CLASS_MACHINE; } - int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - Vector BodyTarget( const Vector &posSrc ) { return pev->origin; } + void Spawn( void ); + void Activate( void ); + void EXPORT Next( void ); + void EXPORT Start( void ); + void EXPORT Wait( void ); + void Stop( void ); + + int BloodColor( void ) { return DONT_BLEED; } + int Classify( void ) { return CLASS_MACHINE; } + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + Vector BodyTarget( const Vector &posSrc ) { return pev->origin; } - virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } - virtual int Save( CSave &save ); - virtual int Restore( CRestore &restore ); + virtual int ObjectCaps( void ) { return CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; } + virtual int Save( CSave &save ); + virtual int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; + static TYPEDESCRIPTION m_SaveData[]; private: - BOOL m_on; + BOOL m_on; }; LINK_ENTITY_TO_CLASS( func_guntarget, CGunTarget ) @@ -2075,13 +2086,13 @@ IMPLEMENT_SAVERESTORE( CGunTarget, CBaseMonster ) void CGunTarget::Spawn( void ) { - pev->solid = SOLID_BSP; - pev->movetype = MOVETYPE_PUSH; + pev->solid = SOLID_BSP; + pev->movetype = MOVETYPE_PUSH; - UTIL_SetOrigin(pev, pev->origin); - SET_MODEL(ENT(pev), STRING(pev->model) ); + UTIL_SetOrigin( pev, pev->origin ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); - if ( pev->speed == 0 ) + if( pev->speed == 0 ) pev->speed = 100; // Don't take damage until "on" @@ -2091,7 +2102,7 @@ void CGunTarget::Spawn( void ) m_on = FALSE; pev->max_health = pev->health; - if ( pev->spawnflags & FGUNTARGET_START_ON ) + if( pev->spawnflags & FGUNTARGET_START_ON ) { SetThink( &CGunTarget::Start ); pev->nextthink = pev->ltime + 0.3; @@ -2100,14 +2111,14 @@ void CGunTarget::Spawn( void ) void CGunTarget::Activate( void ) { - CBaseEntity *pTarg; + CBaseEntity *pTarg; // now find our next target pTarg = GetNextTarget(); - if ( pTarg ) + if( pTarg ) { m_hTargetEnt = pTarg; - UTIL_SetOrigin( pev, pTarg->pev->origin - (pev->mins + pev->maxs) * 0.5 ); + UTIL_SetOrigin( pev, pTarg->pev->origin - ( pev->mins + pev->maxs ) * 0.5 ); } } @@ -2123,38 +2134,38 @@ void CGunTarget::Next( void ) m_hTargetEnt = GetNextTarget(); CBaseEntity *pTarget = m_hTargetEnt; - if ( !pTarget ) + if( !pTarget ) { Stop(); return; } SetMoveDone( &CGunTarget::Wait ); - LinearMove( pTarget->pev->origin - (pev->mins + pev->maxs) * 0.5, pev->speed ); + LinearMove( pTarget->pev->origin - ( pev->mins + pev->maxs ) * 0.5, pev->speed ); } void CGunTarget::Wait( void ) { CBaseEntity *pTarget = m_hTargetEnt; - if ( !pTarget ) + if( !pTarget ) { Stop(); return; } // Fire the pass target if there is one - if ( pTarget->pev->message ) + if( pTarget->pev->message ) { FireTargets( STRING(pTarget->pev->message), this, this, USE_TOGGLE, 0 ); - if ( FBitSet( pTarget->pev->spawnflags, SF_CORNER_FIREONCE ) ) + if( FBitSet( pTarget->pev->spawnflags, SF_CORNER_FIREONCE ) ) pTarget->pev->message = 0; } - + m_flWait = pTarget->GetDelay(); pev->target = pTarget->pev->target; SetThink( &CGunTarget::Next ); - if (m_flWait != 0) + if( m_flWait != 0 ) { // -1 wait will wait forever! pev->nextthink = pev->ltime + m_flWait; @@ -2172,18 +2183,17 @@ void CGunTarget::Stop( void ) pev->takedamage = DAMAGE_NO; } - int CGunTarget::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - if ( pev->health > 0 ) + if( pev->health > 0 ) { pev->health -= flDamage; - if ( pev->health <= 0 ) + if( pev->health <= 0 ) { pev->health = 0; Stop(); - if ( pev->message ) - FireTargets( STRING(pev->message), this, this, USE_TOGGLE, 0 ); + if( pev->message ) + FireTargets( STRING( pev->message ), this, this, USE_TOGGLE, 0 ); } } return 0; @@ -2191,10 +2201,10 @@ int CGunTarget::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo void CGunTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !ShouldToggle( useType, m_on ) ) + if( !ShouldToggle( useType, m_on ) ) return; - if ( m_on ) + if( m_on ) { Stop(); } @@ -2202,7 +2212,7 @@ void CGunTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us { pev->takedamage = DAMAGE_AIM; m_hTargetEnt = GetNextTarget(); - if ( m_hTargetEnt == NULL ) + if( m_hTargetEnt == NULL ) return; pev->health = pev->max_health; Next(); diff --git a/dlls/prop.cpp b/dlls/prop.cpp index 0c3cbc8f..c6c4017e 100644 --- a/dlls/prop.cpp +++ b/dlls/prop.cpp @@ -31,35 +31,53 @@ #include "gamerules.h" #define SF_PROP_RESPAWN 8 // enable autorespawn -#define SF_PROP_BREAKABLE 16 // enable break/explode +#define SF_PROP_BREAKABLE 16 // enable break/explode #define SF_PROP_FIXED 32 // don't move untill touch -typedef enum { expRandom, expDirected} Explosions; -typedef enum { matGlass = 0, matWood, matMetal, matFlesh, matCinderBlock, matCeilingTile, matComputer, matUnbreakableGlass, matRocks, matNone, matLastMaterial } Materials; +typedef enum +{ + expRandom, + expDirected +}Explosions; -//extern "C" void AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); -Vector UTIL_AngleVectorsF(const Vector &angles) +typedef enum +{ + matGlass = 0, + matWood, + matMetal, + matFlesh, + matCinderBlock, + matCeilingTile, + matComputer, + matUnbreakableGlass, + matRocks, + matNone, + matLastMaterial +}Materials; + +//extern "C" void AngleVectors( const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up); +Vector UTIL_AngleVectorsF( const Vector &angles ) { float rgflVecOut[3]; float rgflVecIn[3]; - angles.CopyToArray(rgflVecIn); - g_engfuncs.pfnAngleVectors(rgflVecIn, rgflVecOut, NULL, NULL); - return Vector(rgflVecOut); + angles.CopyToArray( rgflVecIn ); + g_engfuncs.pfnAngleVectors( rgflVecIn, rgflVecOut, NULL, NULL ); + return Vector( rgflVecOut ); } -Vector UTIL_AngleVectorsR(const Vector &angles) +Vector UTIL_AngleVectorsR( const Vector &angles ) { float rgflVecOut[3]; float rgflVecIn[3]; - angles.CopyToArray(rgflVecIn); - g_engfuncs.pfnAngleVectors(rgflVecIn, NULL, rgflVecOut, NULL); - return Vector(rgflVecOut); + angles.CopyToArray( rgflVecIn ); + g_engfuncs.pfnAngleVectors( rgflVecIn, NULL, rgflVecOut, NULL ); + return Vector( rgflVecOut ); } -Vector UTIL_AngleVectorsU(const Vector &angles) +Vector UTIL_AngleVectorsU( const Vector &angles ) { float rgflVecOut[3]; float rgflVecIn[3]; - angles.CopyToArray(rgflVecIn); - g_engfuncs.pfnAngleVectors(rgflVecIn, NULL, rgflVecOut, NULL); - return Vector(rgflVecOut); + angles.CopyToArray( rgflVecIn ); + g_engfuncs.pfnAngleVectors( rgflVecIn, NULL, rgflVecOut, NULL ); + return Vector( rgflVecOut ); } //===================grenade @@ -76,18 +94,18 @@ enum PropShape class CProp : public CBaseEntity { public: - void Spawn(void); + void Spawn( void ); void Precache(); - void EXPORT BounceTouch(CBaseEntity *pOther); - //void EXPORT SlideTouch(CBaseEntity *pOther); - virtual void Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - virtual void Force(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value); - int TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType); - virtual int ObjectCaps(void) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE; } - virtual void BounceSound(void); - virtual int BloodColor(void) { return DONT_BLEED; } - virtual void Killed(entvars_t *pevAttacker, int iGib); + void EXPORT BounceTouch( CBaseEntity *pOther ); + //void EXPORT SlideTouch( CBaseEntity *pOther ); + virtual void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + virtual void Force( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + int TakeDamage( entvars_t *pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); + virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION ) | FCAP_IMPULSE_USE | FCAP_CONTINUOUS_USE; } + virtual void BounceSound( void ); + virtual int BloodColor( void ) { return DONT_BLEED; } + virtual void Killed( entvars_t *pevAttacker, int iGib ); void CheckRotate(); void EXPORT RespawnThink(); void EXPORT AngleThink(); @@ -95,7 +113,7 @@ public: void EXPORT DieThink(); void DamageSound( void ); void PropRespawn(); - void KeyValue( KeyValueData* pkvd); + void KeyValue( KeyValueData *pkvd ); static const char *pSoundsWood[]; static const char *pSoundsFlesh[]; @@ -104,15 +122,14 @@ public: static const char *pSoundsConcrete[]; static const char *pSpawnObjects[]; - inline BOOL Explodable( void ) { return ExplosionMagnitude() > 0; } - inline int ExplosionMagnitude( void ) { return pev->impulse; } - inline void ExplosionSetMagnitude( int magnitude ) { pev->impulse = magnitude; } - + inline BOOL Explodable( void ) { return ExplosionMagnitude() > 0; } + inline int ExplosionMagnitude( void ) { return pev->impulse; } + inline void ExplosionSetMagnitude( int magnitude ) { pev->impulse = magnitude; } static void MaterialSoundPrecache( Materials precacheMaterial ); static void MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, float volume ); static const char **MaterialSoundList( Materials precacheMaterial, int &soundCount ); - void EXPORT Die( void ); + void EXPORT Die( void ); BOOL m_bBarrel; float m_flFloorFriction; @@ -134,16 +151,16 @@ public: PropShape m_oldshape; CBasePlayer *m_pHolstered; float m_flSpawnHealth; - int m_idShard; - float m_angle; - int m_iszGibModel; - Materials m_Material; - Explosions m_Explosion; + int m_idShard; + float m_angle; + int m_iszGibModel; + Materials m_Material; + Explosions m_Explosion; int m_iaCustomAnglesX[10]; int m_iaCustomAnglesZ[10]; }; -LINK_ENTITY_TO_CLASS(prop, CProp) +LINK_ENTITY_TO_CLASS( prop, CProp ) const char *CProp::pSoundsWood[] = { @@ -185,33 +202,32 @@ const char *CProp::pSoundsGlass[] = const char **CProp::MaterialSoundList( Materials precacheMaterial, int &soundCount ) { - const char **pSoundList = NULL; + const char **pSoundList = NULL; - switch ( precacheMaterial ) + switch( precacheMaterial ) { case matWood: pSoundList = pSoundsWood; - soundCount = ARRAYSIZE(pSoundsWood); + soundCount = ARRAYSIZE( pSoundsWood ); break; case matFlesh: pSoundList = pSoundsFlesh; - soundCount = ARRAYSIZE(pSoundsFlesh); + soundCount = ARRAYSIZE( pSoundsFlesh ); break; case matComputer: case matUnbreakableGlass: case matGlass: pSoundList = pSoundsGlass; - soundCount = ARRAYSIZE(pSoundsGlass); + soundCount = ARRAYSIZE( pSoundsGlass ); break; - case matMetal: pSoundList = pSoundsMetal; - soundCount = ARRAYSIZE(pSoundsMetal); + soundCount = ARRAYSIZE( pSoundsMetal ); break; case matCinderBlock: case matRocks: pSoundList = pSoundsConcrete; - soundCount = ARRAYSIZE(pSoundsConcrete); + soundCount = ARRAYSIZE( pSoundsConcrete ); break; case matCeilingTile: case matNone: @@ -225,12 +241,12 @@ const char **CProp::MaterialSoundList( Materials precacheMaterial, int &soundCou void CProp::MaterialSoundPrecache( Materials precacheMaterial ) { - const char **pSoundList; - int i, soundCount = 0; + const char **pSoundList; + int i, soundCount = 0; pSoundList = MaterialSoundList( precacheMaterial, soundCount ); - for ( i = 0; i < soundCount; i++ ) + for( i = 0; i < soundCount; i++ ) { PRECACHE_SOUND( (char *)pSoundList[i] ); } @@ -238,13 +254,13 @@ void CProp::MaterialSoundPrecache( Materials precacheMaterial ) void CProp::MaterialSoundRandom( edict_t *pEdict, Materials soundMaterial, float volume ) { - const char **pSoundList; - int soundCount = 0; + const char **pSoundList; + int soundCount = 0; pSoundList = MaterialSoundList( soundMaterial, soundCount ); - if ( soundCount ) - EMIT_SOUND( pEdict, CHAN_BODY, pSoundList[ RANDOM_LONG(0,soundCount-1) ], volume, 1.0 ); + if( soundCount ) + EMIT_SOUND( pEdict, CHAN_BODY, pSoundList[RANDOM_LONG( 0, soundCount - 1 )], volume, 1.0 ); } void CProp::Precache( void ) @@ -254,65 +270,65 @@ void CProp::Precache( void ) if( !pev->model ) pev->model = MAKE_STRING( "models/xash/barrel_brown.mdl" ); - switch (m_Material) + switch( m_Material ) { case matWood: pGibName = "models/woodgibs.mdl"; - PRECACHE_SOUND("debris/bustcrate1.wav"); - PRECACHE_SOUND("debris/bustcrate2.wav"); + PRECACHE_SOUND( "debris/bustcrate1.wav" ); + PRECACHE_SOUND( "debris/bustcrate2.wav" ); break; case matFlesh: pGibName = "models/fleshgibs.mdl"; - PRECACHE_SOUND("debris/bustflesh1.wav"); - PRECACHE_SOUND("debris/bustflesh2.wav"); + PRECACHE_SOUND( "debris/bustflesh1.wav" ); + PRECACHE_SOUND( "debris/bustflesh2.wav" ); break; case matComputer: - PRECACHE_SOUND("buttons/spark5.wav"); - PRECACHE_SOUND("buttons/spark6.wav"); + PRECACHE_SOUND( "buttons/spark5.wav"); + PRECACHE_SOUND( "buttons/spark6.wav"); pGibName = "models/computergibs.mdl"; - PRECACHE_SOUND("debris/bustmetal1.wav"); - PRECACHE_SOUND("debris/bustmetal2.wav"); + PRECACHE_SOUND( "debris/bustmetal1.wav" ); + PRECACHE_SOUND( "debris/bustmetal2.wav" ); break; case matUnbreakableGlass: case matGlass: pGibName = "models/glassgibs.mdl"; - PRECACHE_SOUND("debris/bustglass1.wav"); - PRECACHE_SOUND("debris/bustglass2.wav"); + PRECACHE_SOUND( "debris/bustglass1.wav" ); + PRECACHE_SOUND( "debris/bustglass2.wav" ); break; case matMetal: pGibName = "models/metalplategibs.mdl"; - PRECACHE_SOUND("debris/bustmetal1.wav"); - PRECACHE_SOUND("debris/bustmetal2.wav"); + PRECACHE_SOUND( "debris/bustmetal1.wav" ); + PRECACHE_SOUND( "debris/bustmetal2.wav" ); break; case matCinderBlock: pGibName = "models/cindergibs.mdl"; - PRECACHE_SOUND("debris/bustconcrete1.wav"); - PRECACHE_SOUND("debris/bustconcrete2.wav"); + PRECACHE_SOUND( "debris/bustconcrete1.wav" ); + PRECACHE_SOUND( "debris/bustconcrete2.wav" ); break; case matRocks: pGibName = "models/rockgibs.mdl"; - PRECACHE_SOUND("debris/bustconcrete1.wav"); - PRECACHE_SOUND("debris/bustconcrete2.wav"); + PRECACHE_SOUND( "debris/bustconcrete1.wav" ); + PRECACHE_SOUND( "debris/bustconcrete2.wav" ); break; case matCeilingTile: pGibName = "models/ceilinggibs.mdl"; - PRECACHE_SOUND ("debris/bustceiling.wav"); + PRECACHE_SOUND( "debris/bustceiling.wav" ); break; } MaterialSoundPrecache( m_Material ); - if ( m_iszGibModel ) - pGibName = STRING(m_iszGibModel); + if( m_iszGibModel ) + pGibName = STRING( m_iszGibModel ); m_idShard = PRECACHE_MODEL( (char *)pGibName ); - PRECACHE_MODEL( (char *)STRING(pev->model) ); + PRECACHE_MODEL( (char *)STRING( pev->model ) ); } void CProp::DamageSound( void ) @@ -323,20 +339,20 @@ void CProp::DamageSound( void ) int i; int material = m_Material; - //if (RANDOM_LONG(0,1)) + //if( RANDOM_LONG( 0, 1 ) ) // return; - if (RANDOM_LONG(0,2)) + if( RANDOM_LONG( 0, 2 ) ) pitch = PITCH_NORM; else - pitch = 95 + RANDOM_LONG(0,34); + pitch = 95 + RANDOM_LONG( 0, 34 ); - fvol = RANDOM_FLOAT(0.75, 1.0); + fvol = RANDOM_FLOAT( 0.75, 1.0 ); - if (material == matComputer && RANDOM_LONG(0,1)) + if( material == matComputer && RANDOM_LONG( 0, 1 ) ) material = matMetal; - switch (material) + switch( material ) { case matComputer: case matGlass: @@ -380,8 +396,8 @@ void CProp::DamageSound( void ) break; } - if (i) - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, rgpsz[RANDOM_LONG(0,i-1)], fvol, ATTN_NORM, 0, pitch); + if( i ) + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, rgpsz[RANDOM_LONG( 0, i - 1 )], fvol, ATTN_NORM, 0, pitch ); } void CProp::Die( void ) @@ -392,79 +408,89 @@ void CProp::Die( void ) int pitch; float fvol; - pitch = 95 + RANDOM_LONG(0,29); + pitch = 95 + RANDOM_LONG( 0, 29 ); - if (pitch > 97 && pitch < 103) + if( pitch > 97 && pitch < 103 ) pitch = 100; // The more negative pev->health, the louder // the sound should be. - fvol = RANDOM_FLOAT(0.85, 1.0) + (fabs(pev->health) / 100.0); + fvol = RANDOM_FLOAT( 0.85, 1.0 ) + ( fabs( pev->health ) / 100.0 ); - if (fvol > 1.0) + if( fvol > 1.0 ) fvol = 1.0; - switch (m_Material) + switch( m_Material ) { case matGlass: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustglass1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustglass1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustglass2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustglass2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_GLASS; break; case matWood: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustcrate1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustcrate1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustcrate2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustcrate2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_WOOD; break; case matComputer: case matMetal: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustmetal1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustmetal1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustmetal2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustmetal2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_METAL; break; case matFlesh: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustflesh1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustflesh1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustflesh2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustflesh2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_FLESH; break; case matRocks: case matCinderBlock: - switch ( RANDOM_LONG(0,1) ) + switch( RANDOM_LONG( 0, 1 ) ) { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustconcrete1.wav", fvol, ATTN_NORM, 0, pitch); + case 0: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustconcrete1.wav", fvol, ATTN_NORM, 0, pitch ); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustconcrete2.wav", fvol, ATTN_NORM, 0, pitch); + case 1: + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustconcrete2.wav", fvol, ATTN_NORM, 0, pitch ); break; } cFlag = BREAK_CONCRETE; break; case matCeilingTile: - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "debris/bustceiling.wav", fvol, ATTN_NORM, 0, pitch); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "debris/bustceiling.wav", fvol, ATTN_NORM, 0, pitch ); break; } - if (m_Explosion == expDirected) + if( m_Explosion == expDirected ) vecVelocity = g_vecAttackDir * 200; else { @@ -509,9 +535,9 @@ void CProp::Die( void ) MESSAGE_END(); float size = pev->size.x; - if ( size < pev->size.y ) + if( size < pev->size.y ) size = pev->size.y; - if ( size < pev->size.z ) + if( size < pev->size.z ) size = pev->size.z; // !!! HACK This should work! @@ -524,9 +550,9 @@ void CProp::Die( void ) // BUGBUG -- can only find 256 entities on a breakable -- should be enough CBaseEntity *pList[256]; int count = UTIL_EntitiesInBox( pList, 256, mins, maxs, FL_ONGROUND ); - if ( count ) + if( count ) { - for ( int i = 0; i < count; i++ ) + for( int i = 0; i < count; i++ ) { ClearBits( pList[i]->pev->flags, FL_ONGROUND ); pList[i]->pev->groundentity = NULL; @@ -541,15 +567,15 @@ void CProp::Die( void ) // Fire targets on break SUB_UseTargets( NULL, USE_TOGGLE, 0 ); - if ( Explodable() && (m_attacker != NULL) ) + if( Explodable() && ( m_attacker != NULL ) ) { ExplosionCreate( pev->origin, pev->angles, m_attacker, ExplosionMagnitude(), FALSE ); - RadiusDamage ( pev->origin, pev, VARS(m_attacker), ExplosionMagnitude(), ExplosionMagnitude() * 2.5 , CLASS_NONE, DMG_BLAST ); + RadiusDamage( pev->origin, pev, VARS(m_attacker), ExplosionMagnitude(), ExplosionMagnitude() * 2.5 , CLASS_NONE, DMG_BLAST ); } - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0) ); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); } -void CProp::Killed(entvars_t *pevAttacker, int iGib) +void CProp::Killed( entvars_t *pevAttacker, int iGib ) { pev->takedamage = DAMAGE_NO; pev->deadflag = DEAD_DEAD; @@ -561,13 +587,13 @@ void CProp::Killed(entvars_t *pevAttacker, int iGib) SetUse( NULL ); } -void CProp::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CProp::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if( pev->health <= 0) + if( pev->health <= 0 ) return; - if (m_owner2 != pActivator->edict()) + if( m_owner2 != pActivator->edict() ) { - if (pev->velocity.Length() < 100 && pActivator->IsPlayer()) + if( pev->velocity.Length() < 100 && pActivator->IsPlayer() ) { m_owner2 = m_attacker = pActivator->edict(); } @@ -580,9 +606,9 @@ void CProp::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, if( m_pHolstered ) { - if ( m_pHolstered->m_pActiveItem ) + if( m_pHolstered->m_pActiveItem ) { - CBasePlayerWeapon *weapon = (CBasePlayerWeapon *) m_pHolstered->m_pActiveItem->GetWeaponPtr(); + CBasePlayerWeapon *weapon = (CBasePlayerWeapon *)m_pHolstered->m_pActiveItem->GetWeaponPtr(); //m_Holstered->m_pActiveItem->Holster(); // strange bug here. ValveWHY? @@ -600,64 +626,64 @@ void CProp::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, pev->nextthink = gpGlobals->time + 0.2; } } - Vector target = pActivator->pev->origin + UTIL_GetAimVector(m_owner2, 1000) * 50; + Vector target = pActivator->pev->origin + UTIL_GetAimVector( m_owner2, 1000 ) * 50; target.z = target.z + 32; - pev->velocity = (target - VecBModelOrigin(pev)) * 10; - Vector atarget = UTIL_VecToAngles(UTIL_GetAimVector(m_owner2, 1000)); - pev->angles.x = UTIL_AngleMod(pev->angles.x); - pev->angles.y = UTIL_AngleMod(pev->angles.y); - pev->angles.z = UTIL_AngleMod(pev->angles.z); - atarget.x = UTIL_AngleMod(atarget.x); - atarget.y = UTIL_AngleMod(atarget.y); - atarget.z = UTIL_AngleMod(atarget.z); - pev->avelocity.x = UTIL_AngleDiff(atarget.x, pev->angles.x) * 10; - pev->avelocity.y = UTIL_AngleDiff(atarget.y, pev->angles.y) * 10; - pev->avelocity.z = UTIL_AngleDiff(atarget.z, pev->angles.z) * 10; - //pev->angles.z += (0 - pev->angles.z) * 0.06; - if ((pActivator->pev->button & (IN_ATTACK))) + pev->velocity = ( target - VecBModelOrigin( pev ) ) * 10; + Vector atarget = UTIL_VecToAngles(UTIL_GetAimVector( m_owner2, 1000 ) ); + pev->angles.x = UTIL_AngleMod( pev->angles.x ); + pev->angles.y = UTIL_AngleMod( pev->angles.y ); + pev->angles.z = UTIL_AngleMod( pev->angles.z ); + atarget.x = UTIL_AngleMod( atarget.x ); + atarget.y = UTIL_AngleMod( atarget.y ); + atarget.z = UTIL_AngleMod( atarget.z ); + pev->avelocity.x = UTIL_AngleDiff( atarget.x, pev->angles.x ) * 10; + pev->avelocity.y = UTIL_AngleDiff( atarget.y, pev->angles.y ) * 10; + pev->avelocity.z = UTIL_AngleDiff( atarget.z, pev->angles.z ) * 10; + //pev->angles.z += ( 0 - pev->angles.z ) * 0.06; + if( ( pActivator->pev->button & ( IN_ATTACK ) ) ) { - pev->velocity = UTIL_GetAimVector(m_owner2, 1000) * 1000; - pev->avelocity.y = pev->avelocity.y*1.5 + RANDOM_FLOAT(100, -100); - pev->avelocity.x = pev->avelocity.x*1.5 + RANDOM_FLOAT(100, -100); - //pev->avelocity.z = pev->avelocity.z*0.5 + RANDOM_FLOAT ( 100, -100 ); + pev->velocity = UTIL_GetAimVector( m_owner2, 1000 ) * 1000; + pev->avelocity.y = pev->avelocity.y * 1.5 + RANDOM_FLOAT( 100, -100 ); + pev->avelocity.x = pev->avelocity.x * 1.5 + RANDOM_FLOAT( 100, -100 ); + //pev->avelocity.z = pev->avelocity.z * 0.5 + RANDOM_FLOAT( 100, -100 ); } - if ((pActivator->pev->button & (IN_ATTACK2))) + if ( ( pActivator->pev->button & ( IN_ATTACK2 ) ) ) { //m_Horizontal = false; //pev->angles.z = 0; } - // m_Horizontal = (fabs(UTIL_AngleDiff(pev->angles.z, 90)) < 20) || ( sin(pev->angles.x/180*M_PI) > 0.1); + // m_Horizontal = ( fabs( UTIL_AngleDiff( pev->angles.z, 90 ) ) < 20 ) || ( sin( pev->angles.x / 180 * M_PI ) > 0.1 ); // CheckRotate(); - //ALERT( at_console, "Prop use!\n"); + //ALERT( at_console, "Prop use!\n" ); } -void CProp::Force(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) +void CProp::Force( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if( pev->health <= 0 ) return; - if (m_owner2 != pActivator->edict()) + if( m_owner2 != pActivator->edict() ) { - if (pev->velocity.Length() < 100 && pActivator->IsPlayer()) + if( pev->velocity.Length() < 100 && pActivator->IsPlayer() ) m_attacker = pActivator->edict(); else return; } - if ((pActivator->pev->button & (IN_ATTACK))) + if( ( pActivator->pev->button & ( IN_ATTACK ) ) ) { - pev->velocity = UTIL_GetAimVector(m_owner2, 3000) * 1000; - pev->avelocity.y = pev->avelocity.y*1.5 + RANDOM_FLOAT(100, -100); - pev->avelocity.x = pev->avelocity.x*1.5 + RANDOM_FLOAT(100, -100); - //pev->avelocity.z = pev->avelocity.z*0.5 + RANDOM_FLOAT ( 100, -100 ); + pev->velocity = UTIL_GetAimVector( m_owner2, 3000 ) * 1000; + pev->avelocity.y = pev->avelocity.y * 1.5 + RANDOM_FLOAT( 100, -100 ); + pev->avelocity.x = pev->avelocity.x * 1.5 + RANDOM_FLOAT( 100, -100 ); + //pev->avelocity.z = pev->avelocity.z * 0.5 + RANDOM_FLOAT( 100, -100 ); } - if ((pActivator->pev->button & (IN_ATTACK2))) + if( ( pActivator->pev->button & ( IN_ATTACK2 ) ) ) { //m_Horizontal = false; //pev->angles.z = 0; } pev->nextthink = gpGlobals->time + m_flRespawnTime; - SetThink( &CProp::RespawnThink); + SetThink( &CProp::RespawnThink ); } void CProp::CheckRotate() @@ -667,47 +693,45 @@ void CProp::CheckRotate() UTIL_SetSize(pev, minsH, maxsH); return; } - if( (fabs(UTIL_AngleDiff(pev->angles.z, 90)) < 20) || - (fabs(sin(pev->angles.x / 180 * M_PI)) > 0.3) ) + if( ( fabs( UTIL_AngleDiff( pev->angles.z, 90 ) ) < 20 ) || ( fabs( sin( pev->angles.x / 180 * M_PI ) ) > 0.3 ) ) m_shape = SHAPE_CYL_H; else m_shape = SHAPE_CYL_V; - if (m_oldshape != m_shape) + if( m_oldshape != m_shape ) { - - if (m_shape == SHAPE_CYL_H) + if( m_shape == SHAPE_CYL_H ) { pev->angles.y += 90; - ALERT(at_console, "setH: %f %f %f\n", pev->angles.x, pev->angles.y, pev->angles.z); + ALERT( at_console, "setH: %f %f %f\n", pev->angles.x, pev->angles.y, pev->angles.z ); - UTIL_SetSize(pev, minsH, maxsH); + UTIL_SetSize( pev, minsH, maxsH ); } - else if (m_shape == SHAPE_CYL_V) + else if( m_shape == SHAPE_CYL_V ) { Vector mins = pev->absmin; Vector maxs = pev->absmax; mins.z = pev->absmax.z; maxs.z += 10; - ALERT(at_console, "setV: %f %f %f\n", pev->angles.x, pev->angles.y, pev->angles.z); + ALERT( at_console, "setV: %f %f %f\n", pev->angles.x, pev->angles.y, pev->angles.z ); // BUGBUG -- can only find 256 entities on a prop -- should be enough CBaseEntity *pList[256]; int count = UTIL_EntitiesInBox( pList, 256, mins, maxs, FL_ONGROUND ); - if ( count ) + if( count ) { - for ( int i = 0; i < count; i++ ) + for( int i = 0; i < count; i++ ) { pList[i]->pev->origin.z += 10; } } pev->origin.z += 10; //pev->angles.y -= 90; - UTIL_SetSize(pev, minsV, maxsV); + UTIL_SetSize( pev, minsV, maxsV ); } - //DROP_TO_FLOOR(edict()); + //DROP_TO_FLOOR( edict() ); //pev->origin.z += 0.5; m_oldshape = m_shape; } @@ -737,7 +761,7 @@ void CProp::DeployThink( void ) } } -void CProp::BounceTouch(CBaseEntity *pOther) +void CProp::BounceTouch( CBaseEntity *pOther ) { if( pev->health <= 0 ) return; @@ -745,50 +769,50 @@ void CProp::BounceTouch(CBaseEntity *pOther) // only do damage if we're moving fairly fast DeployThink(); - if ( m_flNextAttack < gpGlobals->time && pev->velocity.Length() > 300) + if( m_flNextAttack < gpGlobals->time && pev->velocity.Length() > 300 ) { - entvars_t *pevOwner = VARS(m_attacker); - if (pevOwner) + entvars_t *pevOwner = VARS( m_attacker ); + if( pevOwner ) { float dmg = 50 + pev->velocity.Length() / 40; - if (pOther->edict() == m_owner2) + if( pOther->edict() == m_owner2 ) { dmg = 5; - if (pOther->pev->button & (IN_USE)) + if( pOther->pev->button & ( IN_USE ) ) { dmg = 1; } } TraceResult tr = UTIL_GetGlobalTrace(); ClearMultiDamage(); - pOther->TraceAttack(pevOwner, dmg, gpGlobals->v_forward, &tr, DMG_CLUB); - ApplyMultiDamage(pev, pevOwner); + pOther->TraceAttack( pevOwner, dmg, gpGlobals->v_forward, &tr, DMG_CLUB ); + ApplyMultiDamage( pev, pevOwner ); } m_flNextAttack = gpGlobals->time + 1.0; // debounce } - if( (pOther->edict() != m_owner2) && (pev->spawnflags & SF_PROP_BREAKABLE) && (pev->velocity.Length() > 900) ) + if( ( pOther->edict() != m_owner2 ) && ( pev->spawnflags & SF_PROP_BREAKABLE ) && ( pev->velocity.Length() > 900 ) ) { pev->nextthink = gpGlobals->time + 0.1; SetThink( &CProp::DieThink ); } pev->velocity = pev->velocity + pOther->pev->velocity; - float dp = cos(M_PI / 180 * UTIL_AngleDiff(UTIL_VecToAngles(pev->velocity).y, pev->angles.y)); - if (pev->flags & FL_ONGROUND || fabs(pev->velocity.z) < 40) + float dp = cos( M_PI / 180 * UTIL_AngleDiff( UTIL_VecToAngles( pev->velocity ).y, pev->angles.y ) ); + if( pev->flags & FL_ONGROUND || fabs( pev->velocity.z ) < 40 ) { CheckRotate(); - if (m_shape == SHAPE_CYL_H) + if( m_shape == SHAPE_CYL_H ) { - pev->velocity.x *= fabs(dp) * 0.8 + 0.2; - pev->velocity.y *= fabs(dp) * 0.8 + 0.2; + pev->velocity.x *= fabs( dp ) * 0.8 + 0.2; + pev->velocity.y *= fabs( dp ) * 0.8 + 0.2; pev->velocity.z -= 20; pev->avelocity.x = -dp*pev->velocity.Length()* 1.5; pev->avelocity.y = 0; pev->avelocity.z = 0; - pev->angles.z += UTIL_AngleDiff(90, pev->angles.z) * 0.7; + pev->angles.z += UTIL_AngleDiff( 90, pev->angles.z ) * 0.7; //AngleThink(); } - else if (m_shape == SHAPE_CYL_V) + else if( m_shape == SHAPE_CYL_V ) { // pev->angles.z *= 0.3; //pev->angles.x *= 0.3; @@ -798,13 +822,13 @@ void CProp::BounceTouch(CBaseEntity *pOther) pev->velocity.x *= m_flFloorFriction; pev->velocity.y *= m_flFloorFriction; pev->velocity.z -= 10; - pev->avelocity.y = pev->avelocity.y*0.4 + RANDOM_FLOAT(30, -30); + pev->avelocity.y = pev->avelocity.y * 0.4 + RANDOM_FLOAT( 30, -30 ); } else if( m_shape == SHAPE_SPHERE ) { pev->velocity.z -= 20; - pev->avelocity.x = -cos(M_PI / 180 * UTIL_AngleDiff(UTIL_VecToAngles(pev->velocity).y, pev->angles.y))*pev->velocity.Length()* 1.5; - pev->avelocity.y = -sin(M_PI / 180 * UTIL_AngleDiff(UTIL_VecToAngles(pev->velocity).y, pev->angles.y))*pev->velocity.Length()* 1.5;; + pev->avelocity.x = -cos( M_PI / 180 * UTIL_AngleDiff( UTIL_VecToAngles( pev->velocity ).y, pev->angles.y ) ) * pev->velocity.Length() * 1.5; + pev->avelocity.y = -sin( M_PI / 180 * UTIL_AngleDiff( UTIL_VecToAngles( pev->velocity ).y, pev->angles.y ) ) * pev->velocity.Length() * 1.5;; pev->avelocity.z = 0; } else if( m_shape == SHAPE_BOX || m_shape == SHAPE_GENERIC ) @@ -823,48 +847,54 @@ void CProp::BounceTouch(CBaseEntity *pOther) pev->velocity.x *= m_flCollideFriction; if( m_shape != SHAPE_SPHERE ) { - pev->avelocity.y = pev->avelocity.y*0.4 + RANDOM_FLOAT(100, -100); - pev->avelocity.x = pev->avelocity.x*0.5 + RANDOM_FLOAT(100, -100); + pev->avelocity.y = pev->avelocity.y * 0.4 + RANDOM_FLOAT( 100, -100 ); + pev->avelocity.x = pev->avelocity.x * 0.5 + RANDOM_FLOAT( 100, -100 ); } } - //pev->avelocity.z = pev->avelocity.z*0.5 + RANDOM_FLOAT ( 1, -1 ); + //pev->avelocity.z = pev->avelocity.z*0.5 + RANDOM_FLOAT( 1, -1 ); BounceSound(); } pev->framerate = pev->velocity.Length() / 200.0; - if (pev->framerate > 1.0) + if( pev->framerate > 1.0 ) pev->framerate = 1; - else if (pev->framerate < 0.2) + else if( pev->framerate < 0.2 ) { CheckRotate(); AngleThink(); - if (pev->angles.z == 0 || pev->angles.z == 90) + if( pev->angles.z == 0 || pev->angles.z == 90 ) pev->framerate = 0; else pev->framerate = 0.2; } } -void CProp::BounceSound(void) +void CProp::BounceSound( void ) { - switch (RANDOM_LONG(0, 2)) + switch( RANDOM_LONG( 0, 2 ) ) { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit2.wav", 0.25, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/grenade_hit3.wav", 0.25, ATTN_NORM); break; + case 0: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM ); + break; + case 1: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/grenade_hit2.wav", 0.25, ATTN_NORM ); + break; + case 2: + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/grenade_hit3.wav", 0.25, ATTN_NORM ); + break; } } -void CProp::Spawn(void) +void CProp::Spawn( void ) { Precache(); if( minsH == g_vecZero ) { // default barrel parameters - minsV = Vector(-10, -10, -17); - maxsV = Vector(10, 10, 18); - minsH = Vector(-10, -10, -10); - maxsH = Vector(10, 10, 13); + minsV = Vector( -10, -10, -17 ); + maxsV = Vector( 10, 10, 18 ); + minsH = Vector( -10, -10, -10 ); + maxsH = Vector( 10, 10, 13 ); } m_flCollideFriction = 0.7; m_flFloorFriction = 0.5; @@ -881,7 +911,7 @@ void CProp::Spawn(void) void CProp::PropRespawn() { - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0) ); + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); pev->effects &= ~EF_NODRAW; pev->movetype = MOVETYPE_BOUNCE; pev->solid = SOLID_SLIDEBOX; @@ -890,8 +920,8 @@ void CProp::PropRespawn() pev->velocity = pev->avelocity = g_vecZero; pev->angles = spawnAngles; pev->deadflag = DEAD_NO; - SET_MODEL( ENT(pev), STRING(pev->model) ); - m_oldshape = (PropShape)-1; + SET_MODEL( ENT( pev ), STRING( pev->model ) ); + m_oldshape = ( PropShape ) - 1; CheckRotate(); SetTouch( &CProp::BounceTouch ); SetUse( &CProp::Use ); @@ -902,7 +932,7 @@ void CProp::PropRespawn() void CProp::RespawnThink() { - if( !(pev->spawnflags & SF_PROP_RESPAWN)) + if( !( pev->spawnflags & SF_PROP_RESPAWN ) ) { if( pev->health <= 0 ) { @@ -918,75 +948,75 @@ void CProp::AngleThink() { pev->nextthink = gpGlobals->time + m_flRespawnTime; SetThink( &CProp::RespawnThink); - if (!(pev->flags & FL_ONGROUND || fabs(pev->velocity.z) < 40)) + if(! ( pev->flags & FL_ONGROUND || fabs( pev->velocity.z ) < 40 ) ) { m_owner2 = m_attacker = 0; return; } - if (m_shape == SHAPE_CYL_H) + if( m_shape == SHAPE_CYL_H ) { - pev->angles.z += UTIL_AngleDiff(90, pev->angles.z) * 0.7; - if (fabs(UTIL_AngleDiff(90, pev->angles.z)) > 0.1) + pev->angles.z += UTIL_AngleDiff( 90, pev->angles.z ) * 0.7; + if( fabs( UTIL_AngleDiff( 90, pev->angles.z ) ) > 0.1 ) { - SetThink( &CProp::AngleThink); + SetThink( &CProp::AngleThink ); pev->nextthink = gpGlobals->time + 0.1; } //ALERT( at_console, "AngleThink: %f %f %f\n", pev->angles.x, pev->angles.y, pev->angles.z ); pev->avelocity.y = pev->avelocity.z = 0; } - else if (m_shape == SHAPE_CYL_V) + else if( m_shape == SHAPE_CYL_V ) { - if (fabs(UTIL_AngleDiff(90, pev->angles.z)) > 0.1) + if( fabs( UTIL_AngleDiff( 90, pev->angles.z ) ) > 0.1 ) { - SetThink( &CProp::AngleThink); + SetThink( &CProp::AngleThink ); pev->nextthink = gpGlobals->time + 0.1; } - pev->angles.z += UTIL_AngleDiff(0, pev->angles.z) * 0.7; + pev->angles.z += UTIL_AngleDiff( 0, pev->angles.z ) * 0.7; //pev->angles.x += UTIL_AngleDiff( 0, pev->angles.x ) * 0.3; pev->avelocity.x = pev->avelocity.y = pev->avelocity.z = 0; } - else if (m_shape == SHAPE_BOX) + else if( m_shape == SHAPE_BOX ) { Vector iangles; iangles.x = round( pev->angles.x / 90 ) * 90; iangles.y = round( pev->angles.y / 90 ) * 90; iangles.z = round( pev->angles.z / 90 ) * 90; - if (fabs(UTIL_AngleDiff(iangles.x, pev->angles.x)) > 0.1 || - //fabs(UTIL_AngleDiff(iangles.y, pev->angles.y)) > 0.1 || - fabs(UTIL_AngleDiff(iangles.z, pev->angles.z)) > 0.1) + if( fabs( UTIL_AngleDiff( iangles.x, pev->angles.x ) ) > 0.1 || + //fabs( UTIL_AngleDiff( iangles.y, pev->angles.y ) ) > 0.1 || + fabs( UTIL_AngleDiff( iangles.z, pev->angles.z ) ) > 0.1) { - SetThink( &CProp::AngleThink); + SetThink( &CProp::AngleThink ); pev->nextthink = gpGlobals->time + 0.1; } - pev->angles.x += UTIL_AngleDiff(iangles.x, pev->angles.x) * 0.6; - //pev->angles.y += UTIL_AngleDiff(iangles.y, pev->angles.y) * 0.6; - pev->angles.z += UTIL_AngleDiff(iangles.z, pev->angles.z) * 0.6; + pev->angles.x += UTIL_AngleDiff( iangles.x, pev->angles.x ) * 0.6; + //pev->angles.y += UTIL_AngleDiff( iangles.y, pev->angles.y ) * 0.6; + pev->angles.z += UTIL_AngleDiff( iangles.z, pev->angles.z ) * 0.6; pev->avelocity.x = pev->avelocity.y = pev->avelocity.z = 0; } - else if (m_shape == SHAPE_NOROTATE) + else if( m_shape == SHAPE_NOROTATE ) { pev->avelocity.x = pev->avelocity.y = pev->avelocity.z = 0; Vector iangles = spawnAngles; - if (fabs(UTIL_AngleDiff(iangles.x, pev->angles.x)) > 0.1 || - fabs(UTIL_AngleDiff(iangles.y, pev->angles.y)) > 0.1 || - fabs(UTIL_AngleDiff(iangles.z, pev->angles.z)) > 0.1) + if( fabs(UTIL_AngleDiff( iangles.x, pev->angles.x ) ) > 0.1 || + fabs( UTIL_AngleDiff( iangles.y, pev->angles.y ) ) > 0.1 || + fabs( UTIL_AngleDiff( iangles.z, pev->angles.z ) ) > 0.1 ) { - SetThink( &CProp::AngleThink); + SetThink( &CProp::AngleThink ); pev->nextthink = gpGlobals->time + 0.1; } - pev->angles.x += UTIL_AngleDiff(iangles.x, pev->angles.x) * 0.6; - pev->angles.y += UTIL_AngleDiff(iangles.y, pev->angles.y) * 0.6; - pev->angles.z += UTIL_AngleDiff(iangles.z, pev->angles.z) * 0.6; + pev->angles.x += UTIL_AngleDiff( iangles.x, pev->angles.x ) * 0.6; + pev->angles.y += UTIL_AngleDiff( iangles.y, pev->angles.y ) * 0.6; + pev->angles.z += UTIL_AngleDiff( iangles.z, pev->angles.z ) * 0.6; } - else if (m_shape == SHAPE_GENERIC) + else if( m_shape == SHAPE_GENERIC ) { float ianglex = 0, ianglez = 0, imaxanglediff=360.0f; // if first number is zero, it is angle // all other zeroes is array end - for( int i = 0; (i < 10) && ( (i == 0 ) || m_iaCustomAnglesX[i] ); i++) + for( int i = 0; ( i < 10 ) && ( ( i == 0 ) || m_iaCustomAnglesX[i] ); i++ ) { - float anglediff = fabs(UTIL_AngleDiff(pev->angles.x, m_iaCustomAnglesX[i])); + float anglediff = fabs( UTIL_AngleDiff( pev->angles.x, m_iaCustomAnglesX[i] ) ); if( imaxanglediff > anglediff ) { ianglex = m_iaCustomAnglesX[i]; @@ -994,66 +1024,65 @@ void CProp::AngleThink() } } imaxanglediff=360.0f; - for( int i = 0; (i < 10) && ( (i == 0 ) || m_iaCustomAnglesZ[i] ); i++) + for( int i = 0; ( i < 10 ) && ( ( i == 0 ) || m_iaCustomAnglesZ[i] ); i++ ) { - float anglediff = fabs(UTIL_AngleDiff(pev->angles.z, m_iaCustomAnglesZ[i])); + float anglediff = fabs( UTIL_AngleDiff( pev->angles.z, m_iaCustomAnglesZ[i] ) ); if( imaxanglediff > anglediff ) { ianglez = m_iaCustomAnglesZ[i]; imaxanglediff = anglediff; } } - if (fabs(UTIL_AngleDiff(ianglex, pev->angles.x)) > 0.1 || - fabs(UTIL_AngleDiff(ianglez, pev->angles.z)) > 0.1 ) + if( fabs( UTIL_AngleDiff( ianglex, pev->angles.x ) ) > 0.1 || + fabs( UTIL_AngleDiff( ianglez, pev->angles.z ) ) > 0.1 ) { - SetThink( &CProp::AngleThink); + SetThink( &CProp::AngleThink ); pev->nextthink = gpGlobals->time + 0.1; } - pev->angles.x += UTIL_AngleDiff(ianglex, pev->angles.x) * 0.6; - pev->angles.z += UTIL_AngleDiff(ianglez, pev->angles.z) * 0.6; + pev->angles.x += UTIL_AngleDiff( ianglex, pev->angles.x ) * 0.6; + pev->angles.z += UTIL_AngleDiff( ianglez, pev->angles.z ) * 0.6; pev->avelocity.x = pev->avelocity.y = pev->avelocity.z = 0; } - pev->angles.x = UTIL_AngleMod(pev->angles.x); - pev->angles.y = UTIL_AngleMod(pev->angles.y); - pev->angles.z = UTIL_AngleMod(pev->angles.z); + pev->angles.x = UTIL_AngleMod( pev->angles.x ); + pev->angles.y = UTIL_AngleMod( pev->angles.y ); + pev->angles.z = UTIL_AngleMod( pev->angles.z ); } void CProp::DieThink() { - Killed( VARS(m_attacker), GIB_NORMAL ); + Killed( VARS( m_attacker ), GIB_NORMAL ); Die(); } -int CProp::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType) +int CProp::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) { - Vector r = (pevInflictor->origin - pev->origin); - if ( (!m_attacker - || (pev->velocity.Length() < 700)) - && ((CBaseEntity*)GET_PRIVATE(ENT(pevAttacker)))->IsPlayer()) - m_attacker = ENT(pevAttacker); + Vector r = ( pevInflictor->origin - pev->origin ); + if( ( !m_attacker || ( pev->velocity.Length() < 700 ) ) + && ( (CBaseEntity*)GET_PRIVATE( ENT( pevAttacker ) ) )->IsPlayer() ) + m_attacker = ENT( pevAttacker ); DeployThink(); pev->velocity = r * flDamage / -7; - pev->avelocity.x = pev->avelocity.x*0.5 + RANDOM_FLOAT(100, -100); - ALERT(at_console, "Takedmg: %s %s %f %f\n", STRING(pevInflictor->classname), STRING(pevAttacker->classname), flDamage, pev->health ); + pev->avelocity.x = pev->avelocity.x*0.5 + RANDOM_FLOAT( 100, -100 ); + ALERT( at_console, "Takedmg: %s %s %f %f\n", STRING( pevInflictor->classname ), STRING( pevAttacker->classname ), flDamage, pev->health ); // now some func_breakable code - if ( !(pev->spawnflags & SF_PROP_BREAKABLE ) ) + if( !( pev->spawnflags & SF_PROP_BREAKABLE ) ) return 0; - if ( pev->health <= 0 ) + if( pev->health <= 0 ) return; // Breakables take double damage from the crowbar - if ( bitsDamageType & DMG_CLUB ) + if( bitsDamageType & DMG_CLUB ) flDamage *= 2; // Boxes / glass / etc. don't take much poison damage, just the impact of the dart - consider that 10% - if ( bitsDamageType & DMG_POISON ) + if( bitsDamageType & DMG_POISON ) flDamage *= 0.1; g_vecAttackDir = r.Normalize(); // do the damage pev->health -= flDamage; - if ( pev->health <= 0 ) + if( pev->health <= 0 ) { // delayed explode SetThink( &CProp::DieThink ); @@ -1069,84 +1098,84 @@ int CProp::TakeDamage(entvars_t* pevInflictor, entvars_t* pevAttacker, float flD void CProp::KeyValue( KeyValueData* pkvd ) { - ALERT( at_console, "%s %s\n", pkvd->szKeyName, pkvd->szValue); + ALERT( at_console, "%s %s\n", pkvd->szKeyName, pkvd->szValue ); // UNDONE_WC: explicitly ignoring these fields, but they shouldn't be in the map file! - if (FStrEq(pkvd->szKeyName, "explosion")) + if( FStrEq( pkvd->szKeyName, "explosion" ) ) { - if (!stricmp(pkvd->szValue, "directed")) + if( !stricmp( pkvd->szValue, "directed" ) ) m_Explosion = expDirected; - else if (!stricmp(pkvd->szValue, "random")) + else if( !stricmp(pkvd->szValue, "random" ) ) m_Explosion = expRandom; else m_Explosion = expRandom; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "material")) + else if( FStrEq( pkvd->szKeyName, "material" ) ) { - int i = atoi( pkvd->szValue); + int i = atoi( pkvd->szValue ); // 0:glass, 1:metal, 2:flesh, 3:wood - if ((i < 0) || (i >= matLastMaterial)) + if( ( i < 0 ) || ( i >= matLastMaterial ) ) m_Material = matWood; else m_Material = (Materials)i; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "shape")) + else if( FStrEq( pkvd->szKeyName, "shape" ) ) { - int i = atoi( pkvd->szValue); + int i = atoi( pkvd->szValue ); - if ((i < 0) || (i >= SHAPE_NOROTATE)) + if( ( i < 0 ) || ( i >= SHAPE_NOROTATE ) ) m_shape = SHAPE_NOROTATE; else m_shape = (PropShape)i; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "gibmodel") ) + else if( FStrEq( pkvd->szKeyName, "gibmodel" ) ) { - m_iszGibModel = ALLOC_STRING(pkvd->szValue); + m_iszGibModel = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "explodemagnitude") ) + else if( FStrEq( pkvd->szKeyName, "explodemagnitude" ) ) { ExplosionSetMagnitude( atoi( pkvd->szValue ) ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "respawntime") ) + else if( FStrEq( pkvd->szKeyName, "respawntime" ) ) { m_flRespawnTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "customanglesx")) + else if( FStrEq( pkvd->szKeyName, "customanglesx" ) ) { UTIL_StringToIntArray( m_iaCustomAnglesX, ARRAYSIZE( m_iaCustomAnglesX ), pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "customanglesz")) + else if( FStrEq( pkvd->szKeyName, "customanglesz" ) ) { UTIL_StringToIntArray( m_iaCustomAnglesZ, ARRAYSIZE( m_iaCustomAnglesZ ), pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "hmin")) + else if( FStrEq( pkvd->szKeyName, "hmin" ) ) { UTIL_StringToVector( minsH, pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "hmax")) + else if( FStrEq( pkvd->szKeyName, "hmax" ) ) { UTIL_StringToVector( maxsH, pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "vmin")) + else if( FStrEq( pkvd->szKeyName, "vmin" ) ) { UTIL_StringToVector( minsV, pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "vmax")) + else if( FStrEq( pkvd->szKeyName, "vmax" ) ) { UTIL_StringToVector( maxsV, pkvd->szValue ); pkvd->fHandled = TRUE; diff --git a/dlls/soundent.cpp b/dlls/soundent.cpp index b59511f4..08000f28 100644 --- a/dlls/soundent.cpp +++ b/dlls/soundent.cpp @@ -26,34 +26,34 @@ CSoundEnt *pSoundEnt; //========================================================= // CSound - Clear - zeros all fields for a sound //========================================================= -void CSound :: Clear ( void ) +void CSound::Clear( void ) { - m_vecOrigin = g_vecZero; - m_iType = 0; - m_iVolume = 0; - m_flExpireTime = 0; - m_iNext = SOUNDLIST_EMPTY; - m_iNextAudible = 0; + m_vecOrigin = g_vecZero; + m_iType = 0; + m_iVolume = 0; + m_flExpireTime = 0; + m_iNext = SOUNDLIST_EMPTY; + m_iNextAudible = 0; } //========================================================= // Reset - clears the volume, origin, and type for a sound, // but doesn't expire or unlink it. //========================================================= -void CSound :: Reset ( void ) +void CSound::Reset( void ) { - m_vecOrigin = g_vecZero; - m_iType = 0; - m_iVolume = 0; - m_iNext = SOUNDLIST_EMPTY; + m_vecOrigin = g_vecZero; + m_iType = 0; + m_iVolume = 0; + m_iNext = SOUNDLIST_EMPTY; } //========================================================= // FIsSound - returns TRUE if the sound is an Audible sound //========================================================= -BOOL CSound :: FIsSound ( void ) +BOOL CSound::FIsSound( void ) { - if ( m_iType & ( bits_SOUND_COMBAT | bits_SOUND_WORLD | bits_SOUND_PLAYER | bits_SOUND_DANGER ) ) + if( m_iType & ( bits_SOUND_COMBAT | bits_SOUND_WORLD | bits_SOUND_PLAYER | bits_SOUND_DANGER ) ) { return TRUE; } @@ -64,9 +64,9 @@ BOOL CSound :: FIsSound ( void ) //========================================================= // FIsScent - returns TRUE if the sound is actually a scent //========================================================= -BOOL CSound :: FIsScent ( void ) +BOOL CSound::FIsScent( void ) { - if ( m_iType & ( bits_SOUND_CARCASS | bits_SOUND_MEAT | bits_SOUND_GARBAGE ) ) + if( m_iType & ( bits_SOUND_CARCASS | bits_SOUND_MEAT | bits_SOUND_GARBAGE ) ) { return TRUE; } @@ -77,7 +77,7 @@ BOOL CSound :: FIsScent ( void ) //========================================================= // Spawn //========================================================= -void CSoundEnt :: Spawn( void ) +void CSoundEnt::Spawn( void ) { pev->solid = SOLID_NOT; Initialize(); @@ -90,7 +90,7 @@ void CSoundEnt :: Spawn( void ) // for sounds that have ExpireTimes less than or equal // to the current world time, and these sounds are deallocated. //========================================================= -void CSoundEnt :: Think ( void ) +void CSoundEnt::Think( void ) { int iSound; int iPreviousSound; @@ -100,9 +100,9 @@ void CSoundEnt :: Think ( void ) iPreviousSound = SOUNDLIST_EMPTY; iSound = m_iActiveSound; - while ( iSound != SOUNDLIST_EMPTY ) + while( iSound != SOUNDLIST_EMPTY ) { - if ( m_SoundPool[ iSound ].m_flExpireTime <= gpGlobals->time && m_SoundPool[ iSound ].m_flExpireTime != SOUND_NEVER_EXPIRE ) + if( m_SoundPool[ iSound ].m_flExpireTime <= gpGlobals->time && m_SoundPool[ iSound ].m_flExpireTime != SOUND_NEVER_EXPIRE ) { int iNext = m_SoundPool[ iSound ].m_iNext; @@ -118,17 +118,17 @@ void CSoundEnt :: Think ( void ) } } - if ( m_fShowReport ) + if( m_fShowReport ) { - ALERT ( at_aiconsole, "Soundlist: %d / %d (%d)\n", ISoundsInList( SOUNDLISTTYPE_ACTIVE ),ISoundsInList( SOUNDLISTTYPE_FREE ), ISoundsInList( SOUNDLISTTYPE_ACTIVE ) - m_cLastActiveSounds ); - m_cLastActiveSounds = ISoundsInList ( SOUNDLISTTYPE_ACTIVE ); + ALERT( at_aiconsole, "Soundlist: %d / %d (%d)\n", ISoundsInList( SOUNDLISTTYPE_ACTIVE ),ISoundsInList( SOUNDLISTTYPE_FREE ), ISoundsInList( SOUNDLISTTYPE_ACTIVE ) - m_cLastActiveSounds ); + m_cLastActiveSounds = ISoundsInList( SOUNDLISTTYPE_ACTIVE ); } } //========================================================= // Precache - dummy function //========================================================= -void CSoundEnt :: Precache ( void ) +void CSoundEnt::Precache( void ) { } @@ -137,29 +137,29 @@ void CSoundEnt :: Precache ( void ) // to the top of the free list. TAKE CARE to only call this // function for sounds in the Active list!! //========================================================= -void CSoundEnt :: FreeSound ( int iSound, int iPrevious ) +void CSoundEnt::FreeSound( int iSound, int iPrevious ) { - if ( !pSoundEnt ) + if( !pSoundEnt ) { // no sound ent! return; } - if ( iPrevious != SOUNDLIST_EMPTY ) + if( iPrevious != SOUNDLIST_EMPTY ) { // iSound is not the head of the active list, so // must fix the index for the Previous sound - //pSoundEnt->m_SoundPool[ iPrevious ].m_iNext = m_SoundPool[ iSound ].m_iNext; - pSoundEnt->m_SoundPool[ iPrevious ].m_iNext = pSoundEnt->m_SoundPool[ iSound ].m_iNext; + //pSoundEnt->m_SoundPool[iPrevious].m_iNext = m_SoundPool[iSound].m_iNext; + pSoundEnt->m_SoundPool[iPrevious].m_iNext = pSoundEnt->m_SoundPool[iSound].m_iNext; } else { // the sound we're freeing IS the head of the active list. - pSoundEnt->m_iActiveSound = pSoundEnt->m_SoundPool [ iSound ].m_iNext; + pSoundEnt->m_iActiveSound = pSoundEnt->m_SoundPool[iSound].m_iNext; } // make iSound the head of the Free list. - pSoundEnt->m_SoundPool[ iSound ].m_iNext = pSoundEnt->m_iFreeSound; + pSoundEnt->m_SoundPool[iSound].m_iNext = pSoundEnt->m_iFreeSound; pSoundEnt->m_iFreeSound = iSound; } @@ -167,25 +167,25 @@ void CSoundEnt :: FreeSound ( int iSound, int iPrevious ) // IAllocSound - moves a sound from the Free list to the // Active list returns the index of the alloc'd sound //========================================================= -int CSoundEnt :: IAllocSound( void ) +int CSoundEnt::IAllocSound( void ) { int iNewSound; - if ( m_iFreeSound == SOUNDLIST_EMPTY ) + if( m_iFreeSound == SOUNDLIST_EMPTY ) { // no free sound! - ALERT ( at_console, "Free Sound List is full!\n" ); + ALERT( at_console, "Free Sound List is full!\n" ); return SOUNDLIST_EMPTY; } // there is at least one sound available, so move it to the // Active sound list, and return its SoundPool index. - + iNewSound = m_iFreeSound;// copy the index of the next free sound - m_iFreeSound = m_SoundPool[ m_iFreeSound ].m_iNext;// move the index down into the free list. + m_iFreeSound = m_SoundPool[m_iFreeSound].m_iNext;// move the index down into the free list. - m_SoundPool[ iNewSound ].m_iNext = m_iActiveSound;// point the new sound at the top of the active list. + m_SoundPool[iNewSound].m_iNext = m_iActiveSound;// point the new sound at the top of the active list. m_iActiveSound = iNewSound;// now make the new sound the top of the active list. You're done. @@ -196,11 +196,11 @@ int CSoundEnt :: IAllocSound( void ) // InsertSound - Allocates a free sound and fills it with // sound info. //========================================================= -void CSoundEnt :: InsertSound ( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) +void CSoundEnt::InsertSound( int iType, const Vector &vecOrigin, int iVolume, float flDuration ) { - int iThisSound; + int iThisSound; - if ( !pSoundEnt ) + if( !pSoundEnt ) { // no sound ent! return; @@ -208,23 +208,23 @@ void CSoundEnt :: InsertSound ( int iType, const Vector &vecOrigin, int iVolume, iThisSound = pSoundEnt->IAllocSound(); - if ( iThisSound == SOUNDLIST_EMPTY ) + if( iThisSound == SOUNDLIST_EMPTY ) { - ALERT ( at_console, "Could not AllocSound() for InsertSound() (DLL)\n" ); + ALERT( at_console, "Could not AllocSound() for InsertSound() (DLL)\n" ); return; } - pSoundEnt->m_SoundPool[ iThisSound ].m_vecOrigin = vecOrigin; - pSoundEnt->m_SoundPool[ iThisSound ].m_iType = iType; - pSoundEnt->m_SoundPool[ iThisSound ].m_iVolume = iVolume; - pSoundEnt->m_SoundPool[ iThisSound ].m_flExpireTime = gpGlobals->time + flDuration; + pSoundEnt->m_SoundPool[iThisSound].m_vecOrigin = vecOrigin; + pSoundEnt->m_SoundPool[iThisSound].m_iType = iType; + pSoundEnt->m_SoundPool[iThisSound].m_iVolume = iVolume; + pSoundEnt->m_SoundPool[iThisSound].m_flExpireTime = gpGlobals->time + flDuration; } //========================================================= // Initialize - clears all sounds and moves them into the // free sound list. //========================================================= -void CSoundEnt :: Initialize ( void ) +void CSoundEnt::Initialize( void ) { int i; int iSound; @@ -233,30 +233,30 @@ void CSoundEnt :: Initialize ( void ) m_iFreeSound = 0; m_iActiveSound = SOUNDLIST_EMPTY; - for ( i = 0 ; i < MAX_WORLD_SOUNDS ; i++ ) + for( i = 0; i < MAX_WORLD_SOUNDS; i++ ) { // clear all sounds, and link them into the free sound list. - m_SoundPool[ i ].Clear(); - m_SoundPool[ i ].m_iNext = i + 1; + m_SoundPool[i].Clear(); + m_SoundPool[i].m_iNext = i + 1; } - m_SoundPool[ i - 1 ].m_iNext = SOUNDLIST_EMPTY;// terminate the list here. + m_SoundPool[i - 1].m_iNext = SOUNDLIST_EMPTY;// terminate the list here. // now reserve enough sounds for each client - for ( i = 0 ; i < gpGlobals->maxClients ; i++ ) + for( i = 0; i < gpGlobals->maxClients; i++ ) { iSound = pSoundEnt->IAllocSound(); - if ( iSound == SOUNDLIST_EMPTY ) + if( iSound == SOUNDLIST_EMPTY ) { - ALERT ( at_console, "Could not AllocSound() for Client Reserve! (DLL)\n" ); + ALERT( at_console, "Could not AllocSound() for Client Reserve! (DLL)\n" ); return; } - pSoundEnt->m_SoundPool[ iSound ].m_flExpireTime = SOUND_NEVER_EXPIRE; + pSoundEnt->m_SoundPool[iSound].m_flExpireTime = SOUND_NEVER_EXPIRE; } - if ( CVAR_GET_FLOAT("displaysoundlist") == 1 ) + if( CVAR_GET_FLOAT( "displaysoundlist" ) == 1 ) { m_fShowReport = TRUE; } @@ -270,36 +270,36 @@ void CSoundEnt :: Initialize ( void ) // ISoundsInList - returns the number of sounds in the desired // sound list. //========================================================= -int CSoundEnt :: ISoundsInList ( int iListType ) +int CSoundEnt::ISoundsInList( int iListType ) { int i; int iThisSound = 0; - if ( iListType == SOUNDLISTTYPE_FREE ) + if( iListType == SOUNDLISTTYPE_FREE ) { iThisSound = m_iFreeSound; } - else if ( iListType == SOUNDLISTTYPE_ACTIVE ) + else if( iListType == SOUNDLISTTYPE_ACTIVE ) { iThisSound = m_iActiveSound; } else { - ALERT ( at_console, "Unknown Sound List Type!\n" ); + ALERT( at_console, "Unknown Sound List Type!\n" ); } - if ( iThisSound == SOUNDLIST_EMPTY ) + if( iThisSound == SOUNDLIST_EMPTY ) { return 0; } i = 0; - while ( iThisSound != SOUNDLIST_EMPTY ) + while( iThisSound != SOUNDLIST_EMPTY ) { i++; - iThisSound = m_SoundPool[ iThisSound ].m_iNext; + iThisSound = m_SoundPool[iThisSound].m_iNext; } return i; @@ -308,9 +308,9 @@ int CSoundEnt :: ISoundsInList ( int iListType ) //========================================================= // ActiveList - returns the head of the active sound list //========================================================= -int CSoundEnt :: ActiveList ( void ) +int CSoundEnt::ActiveList( void ) { - if ( !pSoundEnt ) + if( !pSoundEnt ) { return SOUNDLIST_EMPTY; } @@ -321,9 +321,9 @@ int CSoundEnt :: ActiveList ( void ) //========================================================= // FreeList - returns the head of the free sound list //========================================================= -int CSoundEnt :: FreeList ( void ) +int CSoundEnt::FreeList( void ) { - if ( !pSoundEnt ) + if( !pSoundEnt ) { return SOUNDLIST_EMPTY; } @@ -335,26 +335,26 @@ int CSoundEnt :: FreeList ( void ) // SoundPointerForIndex - returns a pointer to the instance // of CSound at index's position in the sound pool. //========================================================= -CSound* CSoundEnt :: SoundPointerForIndex( int iIndex ) +CSound *CSoundEnt::SoundPointerForIndex( int iIndex ) { - if ( !pSoundEnt ) + if( !pSoundEnt ) { return NULL; } - if ( iIndex > ( MAX_WORLD_SOUNDS - 1 ) ) + if( iIndex > ( MAX_WORLD_SOUNDS - 1 ) ) { - ALERT ( at_console, "SoundPointerForIndex() - Index too large!\n" ); + ALERT( at_console, "SoundPointerForIndex() - Index too large!\n" ); return NULL; } - if ( iIndex < 0 ) + if( iIndex < 0 ) { - ALERT ( at_console, "SoundPointerForIndex() - Index < 0!\n" ); + ALERT( at_console, "SoundPointerForIndex() - Index < 0!\n" ); return NULL; } - return &pSoundEnt->m_SoundPool[ iIndex ]; + return &pSoundEnt->m_SoundPool[iIndex]; } //========================================================= @@ -363,14 +363,14 @@ CSound* CSoundEnt :: SoundPointerForIndex( int iIndex ) // so this function ensures that a client gets the proper index // to his reserved sound in the soundlist. //========================================================= -int CSoundEnt :: ClientSoundIndex ( edict_t *pClient ) +int CSoundEnt::ClientSoundIndex( edict_t *pClient ) { int iReturn = ENTINDEX( pClient ) - 1; #ifdef _DEBUG - if ( iReturn < 0 || iReturn > gpGlobals->maxClients ) + if( iReturn < 0 || iReturn > gpGlobals->maxClients ) { - ALERT ( at_console, "** ClientSoundIndex returning a bogus value! **\n" ); + ALERT( at_console, "** ClientSoundIndex returning a bogus value! **\n" ); } #endif // _DEBUG diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index f3d67ac6..b1ba1385 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -31,20 +31,20 @@ #include "decals.h" #include "gamerules.h" -extern CGraph WorldGraph; +extern CGraph WorldGraph; extern int gEvilImpulse101; #define NOT_USED 255 -DLL_GLOBAL short g_sModelIndexLaser;// holds the index for the laser beam -DLL_GLOBAL const char *g_pModelNameLaser = "sprites/laserbeam.spr"; -DLL_GLOBAL short g_sModelIndexLaserDot;// holds the index for the laser beam dot -DLL_GLOBAL short g_sModelIndexFireball;// holds the index for the fireball -DLL_GLOBAL short g_sModelIndexSmoke;// holds the index for the smoke cloud -DLL_GLOBAL short g_sModelIndexWExplosion;// holds the index for the underwater explosion -DLL_GLOBAL short g_sModelIndexBubbles;// holds the index for the bubbles model -DLL_GLOBAL short g_sModelIndexBloodDrop;// holds the sprite index for the initial blood -DLL_GLOBAL short g_sModelIndexBloodSpray;// holds the sprite index for splattered blood +DLL_GLOBAL short g_sModelIndexLaser;// holds the index for the laser beam +DLL_GLOBAL const char *g_pModelNameLaser = "sprites/laserbeam.spr"; +DLL_GLOBAL short g_sModelIndexLaserDot;// holds the index for the laser beam dot +DLL_GLOBAL short g_sModelIndexFireball;// holds the index for the fireball +DLL_GLOBAL short g_sModelIndexSmoke;// holds the index for the smoke cloud +DLL_GLOBAL short g_sModelIndexWExplosion;// holds the index for the underwater explosion +DLL_GLOBAL short g_sModelIndexBubbles;// holds the index for the bubbles model +DLL_GLOBAL short g_sModelIndexBloodDrop;// holds the sprite index for the initial blood +DLL_GLOBAL short g_sModelIndexBloodSpray;// holds the sprite index for splattered blood ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS]; AmmoInfo CBasePlayerItem::AmmoInfoArray[MAX_AMMO_SLOTS]; @@ -62,11 +62,11 @@ MULTIDAMAGE gMultiDamage; //========================================================= int MaxAmmoCarry( int iszName ) { - for ( int i = 0; i < MAX_WEAPONS; i++ ) + for( int i = 0; i < MAX_WEAPONS; i++ ) { - if ( CBasePlayerItem::ItemInfoArray[i].pszAmmo1 && !strcmp( STRING(iszName), CBasePlayerItem::ItemInfoArray[i].pszAmmo1 ) ) + if( CBasePlayerItem::ItemInfoArray[i].pszAmmo1 && !strcmp( STRING( iszName ), CBasePlayerItem::ItemInfoArray[i].pszAmmo1 ) ) return CBasePlayerItem::ItemInfoArray[i].iMaxAmmo1; - if ( CBasePlayerItem::ItemInfoArray[i].pszAmmo2 && !strcmp( STRING(iszName), CBasePlayerItem::ItemInfoArray[i].pszAmmo2 ) ) + if( CBasePlayerItem::ItemInfoArray[i].pszAmmo2 && !strcmp( STRING( iszName ), CBasePlayerItem::ItemInfoArray[i].pszAmmo2 ) ) return CBasePlayerItem::ItemInfoArray[i].iMaxAmmo2; } @@ -87,10 +87,10 @@ Collects multiple small damages into a single damage // // ClearMultiDamage - resets the global multi damage accumulator // -void ClearMultiDamage(void) +void ClearMultiDamage( void ) { gMultiDamage.pEntity = NULL; - gMultiDamage.amount = 0; + gMultiDamage.amount = 0; gMultiDamage.type = 0; } @@ -99,34 +99,32 @@ void ClearMultiDamage(void) // // GLOBALS USED: // gMultiDamage - -void ApplyMultiDamage(entvars_t *pevInflictor, entvars_t *pevAttacker ) +void ApplyMultiDamage( entvars_t *pevInflictor, entvars_t *pevAttacker ) { - Vector vecSpot1;//where blood comes from - Vector vecDir;//direction blood should go - TraceResult tr; + Vector vecSpot1;//where blood comes from + Vector vecDir;//direction blood should go + TraceResult tr; - if ( !gMultiDamage.pEntity ) + if( !gMultiDamage.pEntity ) return; - gMultiDamage.pEntity->TakeDamage(pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type ); + gMultiDamage.pEntity->TakeDamage( pevInflictor, pevAttacker, gMultiDamage.amount, gMultiDamage.type ); } // GLOBALS USED: // gMultiDamage - -void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) +void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType ) { - if ( !pEntity ) + if( !pEntity ) return; gMultiDamage.type |= bitsDamageType; - if ( pEntity != gMultiDamage.pEntity ) + if( pEntity != gMultiDamage.pEntity ) { - ApplyMultiDamage(pevInflictor,pevInflictor); // UNDONE: wrong attacker! - gMultiDamage.pEntity = pEntity; - gMultiDamage.amount = 0; + ApplyMultiDamage( pevInflictor,pevInflictor ); // UNDONE: wrong attacker! + gMultiDamage.pEntity = pEntity; + gMultiDamage.amount = 0; } gMultiDamage.amount += flDamage; @@ -137,15 +135,15 @@ void AddMultiDamage( entvars_t *pevInflictor, CBaseEntity *pEntity, float flDama SpawnBlood ================ */ -void SpawnBlood(Vector vecSpot, int bloodColor, float flDamage) +void SpawnBlood( Vector vecSpot, int bloodColor, float flDamage ) { UTIL_BloodDrips( vecSpot, g_vecAttackDir, bloodColor, (int)flDamage ); } int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) { - if ( !pEntity ) - return (DECAL_GUNSHOT1 + RANDOM_LONG(0,4)); + if( !pEntity ) + return ( DECAL_GUNSHOT1 + RANDOM_LONG( 0, 4 ) ); return pEntity->DamageDecal( bitsDamageType ); } @@ -153,15 +151,15 @@ int DamageDecal( CBaseEntity *pEntity, int bitsDamageType ) void DecalGunshot( TraceResult *pTrace, int iBulletType ) { // Is the entity valid - if ( !UTIL_IsValidEntity( pTrace->pHit ) ) + if( !UTIL_IsValidEntity( pTrace->pHit ) ) return; - if ( VARS(pTrace->pHit)->solid == SOLID_BSP || VARS(pTrace->pHit)->movetype == MOVETYPE_PUSHSTEP ) + if( VARS( pTrace->pHit )->solid == SOLID_BSP || VARS( pTrace->pHit )->movetype == MOVETYPE_PUSHSTEP ) { CBaseEntity *pEntity = NULL; // Decal the wall with a gunshot - if ( !FNullEnt(pTrace->pHit) ) - pEntity = CBaseEntity::Instance(pTrace->pHit); + if( !FNullEnt( pTrace->pHit ) ) + pEntity = CBaseEntity::Instance( pTrace->pHit ); switch( iBulletType ) { @@ -190,22 +188,21 @@ void DecalGunshot( TraceResult *pTrace, int iBulletType ) // // EjectBrass - tosses a brass shell from passed origin at passed velocity // -void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) +void EjectBrass( const Vector &vecOrigin, const Vector &vecVelocity, float rotation, int model, int soundtype ) { // FIX: when the player shoots, their gun isn't in the same position as it is on the model other players see. - MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin ); - WRITE_BYTE( TE_MODEL); - WRITE_COORD( vecOrigin.x); - WRITE_COORD( vecOrigin.y); - WRITE_COORD( vecOrigin.z); - WRITE_COORD( vecVelocity.x); - WRITE_COORD( vecVelocity.y); - WRITE_COORD( vecVelocity.z); + WRITE_BYTE( TE_MODEL ); + WRITE_COORD( vecOrigin.x ); + WRITE_COORD( vecOrigin.y ); + WRITE_COORD( vecOrigin.z ); + WRITE_COORD( vecVelocity.x ); + WRITE_COORD( vecVelocity.y ); + WRITE_COORD( vecVelocity.z ); WRITE_ANGLE( rotation ); WRITE_SHORT( model ); - WRITE_BYTE ( soundtype); - WRITE_BYTE ( 25 );// 2.5 seconds + WRITE_BYTE( soundtype ); + WRITE_BYTE( 25 );// 2.5 seconds MESSAGE_END(); } @@ -214,14 +211,14 @@ void EjectBrass ( const Vector &vecOrigin, const Vector &vecVelocity, float rota void ExplodeModel( const Vector &vecOrigin, float speed, int model, int count ) { MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, vecOrigin ); - WRITE_BYTE ( TE_EXPLODEMODEL ); + WRITE_BYTE( TE_EXPLODEMODEL ); WRITE_COORD( vecOrigin.x ); WRITE_COORD( vecOrigin.y ); WRITE_COORD( vecOrigin.z ); WRITE_COORD( speed ); WRITE_SHORT( model ); WRITE_SHORT( count ); - WRITE_BYTE ( 15 );// 1.5 seconds + WRITE_BYTE( 15 );// 1.5 seconds MESSAGE_END(); } #endif @@ -232,18 +229,18 @@ int giAmmoIndex = 0; void AddAmmoNameToAmmoRegistry( const char *szAmmoname ) { // make sure it's not already in the registry - for ( int i = 0; i < MAX_AMMO_SLOTS; i++ ) + for( int i = 0; i < MAX_AMMO_SLOTS; i++ ) { - if ( !CBasePlayerItem::AmmoInfoArray[i].pszName) + if( !CBasePlayerItem::AmmoInfoArray[i].pszName) continue; - if ( stricmp( CBasePlayerItem::AmmoInfoArray[i].pszName, szAmmoname ) == 0 ) + if( stricmp( CBasePlayerItem::AmmoInfoArray[i].pszName, szAmmoname ) == 0 ) return; // ammo already in registry, just quite } giAmmoIndex++; ASSERT( giAmmoIndex < MAX_AMMO_SLOTS ); - if ( giAmmoIndex >= MAX_AMMO_SLOTS ) + if( giAmmoIndex >= MAX_AMMO_SLOTS ) giAmmoIndex = 0; CBasePlayerItem::AmmoInfoArray[giAmmoIndex].pszName = szAmmoname; @@ -256,29 +253,29 @@ void UTIL_PrecacheOtherWeapon( const char *szClassname ) edict_t *pent; pent = CREATE_NAMED_ENTITY( MAKE_STRING( szClassname ) ); - if ( FNullEnt( pent ) ) + if( FNullEnt( pent ) ) { - ALERT ( at_console, "NULL Ent in UTIL_PrecacheOtherWeapon\n" ); + ALERT( at_console, "NULL Ent in UTIL_PrecacheOtherWeapon\n" ); return; } - CBaseEntity *pEntity = CBaseEntity::Instance (VARS( pent )); + CBaseEntity *pEntity = CBaseEntity::Instance( VARS( pent ) ); - if (pEntity) + if( pEntity ) { ItemInfo II; - pEntity->Precache( ); + pEntity->Precache(); memset( &II, 0, sizeof II ); - if ( ((CBasePlayerItem*)pEntity)->GetItemInfo( &II ) ) + if( ( (CBasePlayerItem*)pEntity )->GetItemInfo( &II ) ) { CBasePlayerItem::ItemInfoArray[II.iId] = II; - if ( II.pszAmmo1 && *II.pszAmmo1 ) + if( II.pszAmmo1 && *II.pszAmmo1 ) { AddAmmoNameToAmmoRegistry( II.pszAmmo1 ); } - if ( II.pszAmmo2 && *II.pszAmmo2 ) + if( II.pszAmmo2 && *II.pszAmmo2 ) { AddAmmoNameToAmmoRegistry( II.pszAmmo2 ); } @@ -287,11 +284,11 @@ void UTIL_PrecacheOtherWeapon( const char *szClassname ) } } - REMOVE_ENTITY(pent); + REMOVE_ENTITY( pent ); } // called by worldspawn -void W_Precache(void) +void W_Precache( void ) { memset( CBasePlayerItem::ItemInfoArray, 0, sizeof(CBasePlayerItem::ItemInfoArray) ); memset( CBasePlayerItem::AmmoInfoArray, 0, sizeof(CBasePlayerItem::AmmoInfoArray) ); @@ -326,9 +323,7 @@ void W_Precache(void) // python UTIL_PrecacheOtherWeapon( "weapon_357" ); UTIL_PrecacheOther( "ammo_357" ); -#endif -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // gauss UTIL_PrecacheOtherWeapon( "weapon_gauss" ); UTIL_PrecacheOther( "ammo_gaussclip" ); @@ -336,9 +331,7 @@ void W_Precache(void) // rpg UTIL_PrecacheOtherWeapon( "weapon_rpg" ); UTIL_PrecacheOther( "ammo_rpgclip" ); -#endif -#if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // crossbow UTIL_PrecacheOtherWeapon( "weapon_crossbow" ); UTIL_PrecacheOther( "ammo_crossbow" ); @@ -361,37 +354,37 @@ void W_Precache(void) // hornetgun UTIL_PrecacheOtherWeapon( "weapon_hornetgun" ); - if ( g_pGameRules->IsDeathmatch() ) + if( g_pGameRules->IsDeathmatch() ) { UTIL_PrecacheOther( "weaponbox" );// container for dropped deathmatch weapons } #endif - g_sModelIndexFireball = PRECACHE_MODEL ("sprites/zerogxplode.spr");// fireball - g_sModelIndexWExplosion = PRECACHE_MODEL ("sprites/WXplo1.spr");// underwater fireball - g_sModelIndexSmoke = PRECACHE_MODEL ("sprites/steam1.spr");// smoke - g_sModelIndexBubbles = PRECACHE_MODEL ("sprites/bubble.spr");//bubbles - g_sModelIndexBloodSpray = PRECACHE_MODEL ("sprites/bloodspray.spr"); // initial blood - g_sModelIndexBloodDrop = PRECACHE_MODEL ("sprites/blood.spr"); // splattered blood + g_sModelIndexFireball = PRECACHE_MODEL( "sprites/zerogxplode.spr" );// fireball + g_sModelIndexWExplosion = PRECACHE_MODEL( "sprites/WXplo1.spr" );// underwater fireball + g_sModelIndexSmoke = PRECACHE_MODEL( "sprites/steam1.spr" );// smoke + g_sModelIndexBubbles = PRECACHE_MODEL( "sprites/bubble.spr" );//bubbles + g_sModelIndexBloodSpray = PRECACHE_MODEL( "sprites/bloodspray.spr" ); // initial blood + g_sModelIndexBloodDrop = PRECACHE_MODEL( "sprites/blood.spr" ); // splattered blood g_sModelIndexLaser = PRECACHE_MODEL( (char *)g_pModelNameLaser ); - g_sModelIndexLaserDot = PRECACHE_MODEL("sprites/laserdot.spr"); + g_sModelIndexLaserDot = PRECACHE_MODEL( "sprites/laserdot.spr" ); // used by explosions - PRECACHE_MODEL ("models/grenade.mdl"); - PRECACHE_MODEL ("sprites/explode1.spr"); + PRECACHE_MODEL( "models/grenade.mdl" ); + PRECACHE_MODEL( "sprites/explode1.spr" ); - PRECACHE_SOUND ("weapons/debris1.wav");// explosion aftermaths - PRECACHE_SOUND ("weapons/debris2.wav");// explosion aftermaths - PRECACHE_SOUND ("weapons/debris3.wav");// explosion aftermaths + PRECACHE_SOUND( "weapons/debris1.wav" );// explosion aftermaths + PRECACHE_SOUND( "weapons/debris2.wav" );// explosion aftermaths + PRECACHE_SOUND( "weapons/debris3.wav" );// explosion aftermaths - PRECACHE_SOUND ("weapons/grenade_hit1.wav");//grenade - PRECACHE_SOUND ("weapons/grenade_hit2.wav");//grenade - PRECACHE_SOUND ("weapons/grenade_hit3.wav");//grenade + PRECACHE_SOUND( "weapons/grenade_hit1.wav" );//grenade + PRECACHE_SOUND( "weapons/grenade_hit2.wav" );//grenade + PRECACHE_SOUND( "weapons/grenade_hit3.wav" );//grenade - PRECACHE_SOUND ("weapons/bullet_hit1.wav"); // hit by bullet - PRECACHE_SOUND ("weapons/bullet_hit2.wav"); // hit by bullet - - PRECACHE_SOUND ("items/weapondrop1.wav");// weapon falls to the ground + PRECACHE_SOUND( "weapons/bullet_hit1.wav" ); // hit by bullet + PRECACHE_SOUND( "weapons/bullet_hit2.wav" ); // hit by bullet + + PRECACHE_SOUND( "items/weapondrop1.wav" );// weapon falls to the ground } TYPEDESCRIPTION CBasePlayerItem::m_SaveData[] = @@ -421,28 +414,28 @@ TYPEDESCRIPTION CBasePlayerWeapon::m_SaveData[] = DEFINE_FIELD( CBasePlayerWeapon, m_iSecondaryAmmoType, FIELD_INTEGER ), DEFINE_FIELD( CBasePlayerWeapon, m_iClip, FIELD_INTEGER ), DEFINE_FIELD( CBasePlayerWeapon, m_iDefaultAmmo, FIELD_INTEGER ), -// DEFINE_FIELD( CBasePlayerWeapon, m_iClientClip, FIELD_INTEGER ) , reset to zero on load so hud gets updated correctly -// DEFINE_FIELD( CBasePlayerWeapon, m_iClientWeaponState, FIELD_INTEGER ), reset to zero on load so hud gets updated correctly + //DEFINE_FIELD( CBasePlayerWeapon, m_iClientClip, FIELD_INTEGER ), reset to zero on load so hud gets updated correctly + //DEFINE_FIELD( CBasePlayerWeapon, m_iClientWeaponState, FIELD_INTEGER ), reset to zero on load so hud gets updated correctly }; IMPLEMENT_SAVERESTORE( CBasePlayerWeapon, CBasePlayerItem ) -void CBasePlayerItem :: SetObjectCollisionBox( void ) +void CBasePlayerItem::SetObjectCollisionBox( void ) { - pev->absmin = pev->origin + Vector(-24, -24, 0); - pev->absmax = pev->origin + Vector(24, 24, 16); + pev->absmin = pev->origin + Vector( -24, -24, 0 ); + pev->absmax = pev->origin + Vector( 24, 24, 16 ); } //========================================================= // Sets up movetype, size, solidtype for a new weapon. //========================================================= -void CBasePlayerItem :: FallInit( void ) +void CBasePlayerItem::FallInit( void ) { pev->movetype = MOVETYPE_TOSS; pev->solid = SOLID_BBOX; UTIL_SetOrigin( pev, pev->origin ); - UTIL_SetSize(pev, Vector( 0, 0, 0), Vector(0, 0, 0) );//pointsize until it lands on the ground. + UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) );//pointsize until it lands on the ground. SetTouch( &CBasePlayerItem::DefaultTouch ); SetThink( &CBasePlayerItem::FallThink ); @@ -457,18 +450,18 @@ void CBasePlayerItem :: FallInit( void ) // to trigger and set it in a large box that helps the // player get it. //========================================================= -void CBasePlayerItem::FallThink ( void ) +void CBasePlayerItem::FallThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - if ( pev->flags & FL_ONGROUND ) + if( pev->flags & FL_ONGROUND ) { // clatter if we have an owner (i.e., dropped by someone) // don't clatter if the gun is waiting to respawn (if it's waiting, it is invisible!) - if ( !FNullEnt( pev->owner ) ) + if( !FNullEnt( pev->owner ) ) { - int pitch = 95 + RANDOM_LONG(0,29); - EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "items/weapondrop1.wav", 1, ATTN_NORM, 0, pitch); + int pitch = 95 + RANDOM_LONG( 0, 29 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "items/weapondrop1.wav", 1, ATTN_NORM, 0, pitch ); } // lie flat @@ -484,10 +477,10 @@ void CBasePlayerItem::FallThink ( void ) //========================================================= void CBasePlayerItem::Materialize( void ) { - if ( pev->effects & EF_NODRAW ) + if( pev->effects & EF_NODRAW ) { // changing from invisible state to visible. - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 ); pev->effects &= ~EF_NODRAW; pev->effects |= EF_MUZZLEFLASH; } @@ -507,7 +500,7 @@ void CBasePlayerItem::AttemptToMaterialize( void ) { float time = g_pGameRules->FlWeaponTryRespawn( this ); - if ( time == 0 ) + if( time == 0 ) { Materialize(); return; @@ -520,9 +513,9 @@ void CBasePlayerItem::AttemptToMaterialize( void ) // CheckRespawn - a player is taking this weapon, should // it respawn? //========================================================= -void CBasePlayerItem :: CheckRespawn ( void ) +void CBasePlayerItem::CheckRespawn( void ) { - switch ( g_pGameRules->WeaponShouldRespawn( this ) ) + switch( g_pGameRules->WeaponShouldRespawn( this ) ) { case GR_WEAPON_RESPAWN_YES: Respawn(); @@ -543,13 +536,13 @@ CBaseEntity* CBasePlayerItem::Respawn( void ) // will decide when to make the weapon visible and touchable. CBaseEntity *pNewWeapon = CBaseEntity::Create( (char *)STRING( pev->classname ), g_pGameRules->VecWeaponRespawnSpot( this ), pev->angles, pev->owner ); - if ( pNewWeapon ) + if( pNewWeapon ) { pNewWeapon->pev->effects |= EF_NODRAW;// invisible for now pNewWeapon->SetTouch( NULL );// no touch pNewWeapon->SetThink( &CBasePlayerItem::AttemptToMaterialize ); - DROP_TO_FLOOR ( ENT(pev) ); + DROP_TO_FLOOR( ENT( pev ) ); // not a typo! We want to know when the weapon the player just picked up should respawn! This new entity we created is the replacement, // but when it should respawn is based on conditions belonging to the weapon that was taken. @@ -557,7 +550,7 @@ CBaseEntity* CBasePlayerItem::Respawn( void ) } else { - ALERT ( at_console, "Respawn failed to create %s!\n", STRING( pev->classname ) ); + ALERT( at_console, "Respawn failed to create %s!\n", STRING( pev->classname ) ); } return pNewWeapon; @@ -566,25 +559,25 @@ CBaseEntity* CBasePlayerItem::Respawn( void ) void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) { // if it's not a player, ignore - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) return; CBasePlayer *pPlayer = (CBasePlayer *)pOther; // can I have this? - if ( !g_pGameRules->CanHavePlayerItem( pPlayer, this ) ) + if( !g_pGameRules->CanHavePlayerItem( pPlayer, this ) ) { - if ( gEvilImpulse101 ) + if( gEvilImpulse101 ) { UTIL_Remove( this ); } return; } - if (pOther->AddPlayerItem( this )) + if( pOther->AddPlayerItem( this ) ) { AttachToPlayer( pPlayer ); - EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pPlayer->pev ), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM ); } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? @@ -593,9 +586,9 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) { #if defined( CLIENT_WEAPONS ) - if ( !isPredicted ) + if( !isPredicted ) #else - if ( 1 ) + if( 1 ) #endif { return ( attack_time <= curtime ) ? TRUE : FALSE; @@ -608,7 +601,7 @@ BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) void CBasePlayerWeapon::ItemPostFrame( void ) { - if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) + if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); @@ -622,9 +615,9 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fInReload = FALSE; } - if ((m_pPlayer->pev->button & IN_ATTACK2) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) ) + if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) ) { - if ( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) + if( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) { m_fFireOnEmpty = TRUE; } @@ -633,9 +626,9 @@ void CBasePlayerWeapon::ItemPostFrame( void ) SecondaryAttack(); m_pPlayer->pev->button &= ~IN_ATTACK2; } - else if ((m_pPlayer->pev->button & IN_ATTACK) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) ) + else if( ( m_pPlayer->pev->button & IN_ATTACK ) && CanAttack( m_flNextPrimaryAttack, gpGlobals->time, UseDecrement() ) ) { - if ( (m_iClip == 0 && pszAmmo1()) || (iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) ) + if( ( m_iClip == 0 && pszAmmo1() ) || ( iMaxClip() == -1 && !m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] ) ) { m_fFireOnEmpty = TRUE; } @@ -643,21 +636,20 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_pPlayer->TabulateAmmo(); PrimaryAttack(); } - else if ( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) + else if( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) { // reload when reload is pressed, or if no buttons are down and weapon is empty. Reload(); } - else if ( !(m_pPlayer->pev->button & (IN_ATTACK|IN_ATTACK2) ) ) + else if( !( m_pPlayer->pev->button & ( IN_ATTACK | IN_ATTACK2 ) ) ) { // no fire buttons down - m_fFireOnEmpty = FALSE; - if ( !IsUseable() && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) + if( !IsUseable() && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) { // weapon isn't useable, switch. - if ( !(iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY) && g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) ) + if( !( iFlags() & ITEM_FLAG_NOAUTOSWITCHEMPTY ) && g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) ) { m_flNextPrimaryAttack = ( UseDecrement() ? 0.0 : gpGlobals->time ) + 0.3; return; @@ -666,19 +658,19 @@ void CBasePlayerWeapon::ItemPostFrame( void ) else { // weapon is useable. Reload if empty and weapon has waited as long as it has to after firing - if ( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD) && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) + if( m_iClip == 0 && !(iFlags() & ITEM_FLAG_NOAUTORELOAD ) && m_flNextPrimaryAttack < ( UseDecrement() ? 0.0 : gpGlobals->time ) ) { Reload(); return; } } - WeaponIdle( ); + WeaponIdle(); return; } // catch all - if ( ShouldWeaponIdle() ) + if( ShouldWeaponIdle() ) { WeaponIdle(); } @@ -686,13 +678,13 @@ void CBasePlayerWeapon::ItemPostFrame( void ) void CBasePlayerItem::DestroyItem( void ) { - if ( m_pPlayer ) + if( m_pPlayer ) { // if attached to a player, remove. m_pPlayer->RemovePlayerItem( this ); } - Kill( ); + Kill(); } int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) @@ -705,14 +697,14 @@ int CBasePlayerItem::AddToPlayer( CBasePlayer *pPlayer ) void CBasePlayerItem::Drop( void ) { SetTouch( NULL ); - SetThink( &CBaseEntity::SUB_Remove); + SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + .1; } void CBasePlayerItem::Kill( void ) { SetTouch( NULL ); - SetThink( &CBaseEntity::SUB_Remove); + SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + .1; } @@ -722,7 +714,7 @@ void CBasePlayerItem::Holster( int skiplocal /* = 0 */ ) m_pPlayer->pev->weaponmodel = 0; } -void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) +void CBasePlayerItem::AttachToPlayer( CBasePlayer *pPlayer ) { pev->movetype = MOVETYPE_FOLLOW; pev->solid = SOLID_NOT; @@ -739,7 +731,7 @@ void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) // CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { - if ( m_iDefaultAmmo ) + if( m_iDefaultAmmo ) { return ExtractAmmo( (CBasePlayerWeapon *)pOriginal ); } @@ -754,16 +746,16 @@ int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { int bResult = CBasePlayerItem::AddToPlayer( pPlayer ); - pPlayer->pev->weapons |= (1<pev->weapons |= ( 1 << m_iId ); - if ( !m_iPrimaryAmmoType ) + if( !m_iPrimaryAmmoType ) { m_iPrimaryAmmoType = pPlayer->GetAmmoIndex( pszAmmo1() ); m_iSecondaryAmmoType = pPlayer->GetAmmoIndex( pszAmmo2() ); } - if (bResult) - return AddWeapon( ); + if( bResult ) + return AddWeapon(); return FALSE; } @@ -771,39 +763,36 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { BOOL bSend = FALSE; int state = 0; - if ( pPlayer->m_pActiveItem == this ) + if( pPlayer->m_pActiveItem == this ) { - if ( pPlayer->m_fOnTarget ) + if( pPlayer->m_fOnTarget ) state = WEAPON_IS_ONTARGET; else state = 1; } // Forcing send of all data! - if ( !pPlayer->m_fWeapon ) + if( !pPlayer->m_fWeapon ) { bSend = TRUE; } - + // This is the current or last weapon, so the state will need to be updated - if ( this == pPlayer->m_pActiveItem || - this == pPlayer->m_pClientActiveItem ) + if( this == pPlayer->m_pActiveItem || this == pPlayer->m_pClientActiveItem ) { - if ( pPlayer->m_pActiveItem != pPlayer->m_pClientActiveItem ) + if( pPlayer->m_pActiveItem != pPlayer->m_pClientActiveItem ) { bSend = TRUE; } } // If the ammo, state, or fov has changed, update the weapon - if ( m_iClip != m_iClientClip || - state != m_iClientWeaponState || - pPlayer->m_iFOV != pPlayer->m_iClientFOV ) + if( m_iClip != m_iClientClip || state != m_iClientWeaponState || pPlayer->m_iFOV != pPlayer->m_iClientFOV ) { bSend = TRUE; } - if ( bSend ) + if( bSend ) { MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pPlayer->pev ); WRITE_BYTE( state ); @@ -816,7 +805,7 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) pPlayer->m_fWeapon = TRUE; } - if ( m_pNext ) + if( m_pNext ) m_pNext->UpdateClientData( pPlayer ); return 1; @@ -824,7 +813,7 @@ int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body ) { - if ( UseDecrement() ) + if( UseDecrement() ) skiplocal = 1; else skiplocal = 0; @@ -832,25 +821,25 @@ void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal, int body ) m_pPlayer->pev->weaponanim = iAnim; #if defined( CLIENT_WEAPONS ) - if ( skiplocal && ENGINE_CANSKIP( m_pPlayer->edict() ) ) + if( skiplocal && ENGINE_CANSKIP( m_pPlayer->edict() ) ) return; #endif MESSAGE_BEGIN( MSG_ONE, SVC_WEAPONANIM, NULL, m_pPlayer->pev ); - WRITE_BYTE( iAnim ); // sequence number - WRITE_BYTE( pev->body ); // weaponmodel bodygroup. + WRITE_BYTE( iAnim ); // sequence number + WRITE_BYTE( pev->body ); // weaponmodel bodygroup. MESSAGE_END(); } -BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) +BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { int iIdAmmo; - if (iMaxClip < 1) + if( iMaxClip < 1 ) { m_iClip = -1; iIdAmmo = m_pPlayer->GiveAmmo( iCount, szName, iMaxCarry ); } - else if (m_iClip == 0) + else if( m_iClip == 0 ) { int i; i = min( m_iClip + iCount, iMaxClip ) - m_iClip; @@ -864,21 +853,21 @@ BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip // m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] = iMaxCarry; // hack for testing - if (iIdAmmo > 0) + if( iIdAmmo > 0 ) { m_iPrimaryAmmoType = iIdAmmo; - if (m_pPlayer->HasPlayerItem( this ) ) + if( m_pPlayer->HasPlayerItem( this ) ) { // play the "got ammo" sound only if we gave some ammo to a player that already had this gun. // if the player is just getting this gun for the first time, DefaultTouch will play the "picked up gun" sound for us. - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); } } return iIdAmmo > 0 ? TRUE : FALSE; } -BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) +BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax ) { int iIdAmmo; @@ -886,10 +875,10 @@ BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) //m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] = iMax; // hack for testing - if (iIdAmmo > 0) + if( iIdAmmo > 0 ) { m_iSecondaryAmmoType = iIdAmmo; - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); } return iIdAmmo > 0 ? TRUE : FALSE; } @@ -900,11 +889,11 @@ BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) // (does it have ammo loaded? do I have any ammo for the // weapon?, etc) //========================================================= -BOOL CBasePlayerWeapon :: IsUseable( void ) +BOOL CBasePlayerWeapon::IsUseable( void ) { - if ( m_iClip <= 0 ) + if( m_iClip <= 0 ) { - if ( m_pPlayer->m_rgAmmo[ PrimaryAmmoIndex() ] <= 0 && iMaxAmmo1() != -1 ) + if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] <= 0 && iMaxAmmo1() != -1 ) { // clip is empty (or nonexistant) and the player has no more ammo of this type. return FALSE; @@ -914,29 +903,29 @@ BOOL CBasePlayerWeapon :: IsUseable( void ) return TRUE; } -BOOL CBasePlayerWeapon :: CanDeploy( void ) +BOOL CBasePlayerWeapon::CanDeploy( void ) { BOOL bHasAmmo = 0; - if ( !pszAmmo1() ) + if( !pszAmmo1() ) { // this weapon doesn't use ammo, can always deploy. return TRUE; } - if ( pszAmmo1() ) + if( pszAmmo1() ) { - bHasAmmo |= (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] != 0); + bHasAmmo |= ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] != 0 ); } - if ( pszAmmo2() ) + if( pszAmmo2() ) { - bHasAmmo |= (m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] != 0); + bHasAmmo |= ( m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] != 0 ); } - if (m_iClip > 0) + if( m_iClip > 0 ) { bHasAmmo |= 1; } - if (!bHasAmmo) + if( !bHasAmmo ) { return FALSE; } @@ -944,14 +933,14 @@ BOOL CBasePlayerWeapon :: CanDeploy( void ) return TRUE; } -BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal /* = 0 */, int body ) +BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal /* = 0 */, int body ) { - if (!CanDeploy( )) + if( !CanDeploy() ) return FALSE; m_pPlayer->TabulateAmmo(); - m_pPlayer->pev->viewmodel = MAKE_STRING(szViewModel); - m_pPlayer->pev->weaponmodel = MAKE_STRING(szWeaponModel); + m_pPlayer->pev->viewmodel = MAKE_STRING( szViewModel ); + m_pPlayer->pev->weaponmodel = MAKE_STRING( szWeaponModel ); strcpy( m_pPlayer->m_szAnimExtention, szAnimExt ); SendWeaponAnim( iAnim, skiplocal, body ); @@ -961,14 +950,14 @@ BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, return TRUE; } -BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay, int body ) +BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, int body ) { - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; - int j = min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + int j = min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); - if (j == 0) + if( j == 0 ) return FALSE; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay; @@ -982,18 +971,18 @@ BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay, return TRUE; } -BOOL CBasePlayerWeapon :: PlayEmptySound( void ) +BOOL CBasePlayerWeapon::PlayEmptySound( void ) { - if (m_iPlayEmptySound) + if( m_iPlayEmptySound ) { - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM ); m_iPlayEmptySound = 0; return 0; } return 0; } -void CBasePlayerWeapon :: ResetEmptySound( void ) +void CBasePlayerWeapon::ResetEmptySound( void ) { m_iPlayEmptySound = 1; } @@ -1023,7 +1012,7 @@ void CBasePlayerAmmo::Spawn( void ) { pev->movetype = MOVETYPE_TOSS; pev->solid = SOLID_TRIGGER; - UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); + UTIL_SetSize( pev, Vector( -16, -16, 0 ), Vector( 16, 16, 16 ) ); UTIL_SetOrigin( pev, pev->origin ); SetTouch( &CBasePlayerAmmo::DefaultTouch ); @@ -1044,10 +1033,10 @@ CBaseEntity* CBasePlayerAmmo::Respawn( void ) void CBasePlayerAmmo::Materialize( void ) { - if ( pev->effects & EF_NODRAW ) + if( pev->effects & EF_NODRAW ) { // changing from invisible state to visible. - EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 ); pev->effects &= ~EF_NODRAW; pev->effects |= EF_MUZZLEFLASH; } @@ -1055,31 +1044,31 @@ void CBasePlayerAmmo::Materialize( void ) SetTouch( &CBasePlayerAmmo::DefaultTouch ); } -void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther ) +void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) { - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) { return; } - if (AddAmmo( pOther )) + if( AddAmmo( pOther ) ) { - if ( g_pGameRules->AmmoShouldRespawn( this ) == GR_AMMO_RESPAWN_YES ) + if( g_pGameRules->AmmoShouldRespawn( this ) == GR_AMMO_RESPAWN_YES ) { Respawn(); } else { SetTouch( NULL ); - SetThink( &CBaseEntity::SUB_Remove); + SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + .1; } } - else if (gEvilImpulse101) + else if( gEvilImpulse101 ) { // evil impulse 101 hack, kill always SetTouch( NULL ); - SetThink( &CBaseEntity::SUB_Remove); + SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time + .1; } } @@ -1094,9 +1083,9 @@ void CBasePlayerAmmo :: DefaultTouch( CBaseEntity *pOther ) //========================================================= int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { - int iReturn; + int iReturn; - if ( pszAmmo1() != NULL ) + if( pszAmmo1() != NULL ) { // blindly call with m_iDefaultAmmo. It's either going to be a value or zero. If it is zero, // we only get the ammo in the weapon's clip, which is what we want. @@ -1104,7 +1093,7 @@ int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) m_iDefaultAmmo = 0; } - if ( pszAmmo2() != NULL ) + if( pszAmmo2() != NULL ) { iReturn = pWeapon->AddSecondaryAmmo( 0, (char *)pszAmmo2(), iMaxAmmo2() ); } @@ -1117,9 +1106,9 @@ int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) //========================================================= int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { - int iAmmo; + int iAmmo; - if ( m_iClip == WEAPON_NOCLIP ) + if( m_iClip == WEAPON_NOCLIP ) { iAmmo = 0;// guns with no clips always come empty if they are second-hand } @@ -1127,7 +1116,7 @@ int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) { iAmmo = m_iClip; } - + return pWeapon->m_pPlayer->GiveAmmo( iAmmo, (char *)pszAmmo1(), iMaxAmmo1() ); // , &m_iPrimaryAmmoType } @@ -1165,23 +1154,23 @@ IMPLEMENT_SAVERESTORE( CWeaponBox, CBaseEntity ) //========================================================= void CWeaponBox::Precache( void ) { - PRECACHE_MODEL("models/w_weaponbox.mdl"); + PRECACHE_MODEL( "models/w_weaponbox.mdl" ); } //========================================================= //========================================================= -void CWeaponBox :: KeyValue( KeyValueData *pkvd ) +void CWeaponBox::KeyValue( KeyValueData *pkvd ) { - if ( m_cAmmoTypes < MAX_AMMO_SLOTS ) + if( m_cAmmoTypes < MAX_AMMO_SLOTS ) { - PackAmmo( ALLOC_STRING(pkvd->szKeyName), atoi(pkvd->szValue) ); + PackAmmo( ALLOC_STRING( pkvd->szKeyName ), atoi( pkvd->szValue ) ); m_cAmmoTypes++;// count this new ammo type. pkvd->fHandled = TRUE; } else { - ALERT ( at_console, "WeaponBox too full! only %d ammotypes allowed\n", MAX_AMMO_SLOTS ); + ALERT( at_console, "WeaponBox too full! only %d ammotypes allowed\n", MAX_AMMO_SLOTS ); } } @@ -1190,14 +1179,14 @@ void CWeaponBox :: KeyValue( KeyValueData *pkvd ) //========================================================= void CWeaponBox::Spawn( void ) { - Precache( ); + Precache(); pev->movetype = MOVETYPE_TOSS; pev->solid = SOLID_TRIGGER; UTIL_SetSize( pev, g_vecZero, g_vecZero ); - SET_MODEL( ENT(pev), "models/w_weaponbox.mdl"); + SET_MODEL( ENT( pev ), "models/w_weaponbox.mdl" ); } //========================================================= @@ -1210,13 +1199,13 @@ void CWeaponBox::Kill( void ) int i; // destroy the weapons - for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { - pWeapon = m_rgpPlayerItems[ i ]; + pWeapon = m_rgpPlayerItems[i]; - while ( pWeapon ) + while( pWeapon ) { - pWeapon->SetThink( &CBaseEntity::SUB_Remove); + pWeapon->SetThink( &CBaseEntity::SUB_Remove ); pWeapon->pev->nextthink = gpGlobals->time + 0.1; pWeapon = pWeapon->m_pNext; } @@ -1232,18 +1221,18 @@ void CWeaponBox::Kill( void ) //========================================================= void CWeaponBox::Touch( CBaseEntity *pOther ) { - if ( !(pev->flags & FL_ONGROUND ) ) + if( !( pev->flags & FL_ONGROUND ) ) { return; } - if ( !pOther->IsPlayer() ) + if( !pOther->IsPlayer() ) { // only players may touch a weaponbox. return; } - if ( !pOther->IsAlive() ) + if( !pOther->IsAlive() ) { // no dead guys. return; @@ -1253,39 +1242,39 @@ void CWeaponBox::Touch( CBaseEntity *pOther ) int i; // dole out ammo - for ( i = 0 ; i < MAX_AMMO_SLOTS ; i++ ) + for( i = 0; i < MAX_AMMO_SLOTS; i++ ) { - if ( !FStringNull( m_rgiszAmmo[ i ] ) ) + if( !FStringNull( m_rgiszAmmo[i] ) ) { // there's some ammo of this type. - pPlayer->GiveAmmo( m_rgAmmo[ i ], (char *)STRING( m_rgiszAmmo[ i ] ), MaxAmmoCarry( m_rgiszAmmo[ i ] ) ); + pPlayer->GiveAmmo( m_rgAmmo[i], (char *)STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); - //ALERT ( at_console, "Gave %d rounds of %s\n", m_rgAmmo[i], STRING(m_rgiszAmmo[i]) ); + //ALERT( at_console, "Gave %d rounds of %s\n", m_rgAmmo[i], STRING( m_rgiszAmmo[i] ) ); // now empty the ammo from the weaponbox since we just gave it to the player - m_rgiszAmmo[ i ] = iStringNull; - m_rgAmmo[ i ] = 0; + m_rgiszAmmo[i] = iStringNull; + m_rgAmmo[i] = 0; } } // go through my weapons and try to give the usable ones to the player. // it's important the the player be given ammo first, so the weapons code doesn't refuse // to deploy a better weapon that the player may pick up because he has no ammo for it. - for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { - if ( m_rgpPlayerItems[ i ] ) + if( m_rgpPlayerItems[i] ) { CBasePlayerItem *pItem; // have at least one weapon in this slot - while ( m_rgpPlayerItems[ i ] ) + while( m_rgpPlayerItems[i] ) { - //ALERT ( at_console, "trying to give %s\n", STRING( m_rgpPlayerItems[ i ]->pev->classname ) ); + //ALERT( at_console, "trying to give %s\n", STRING( m_rgpPlayerItems[i]->pev->classname ) ); - pItem = m_rgpPlayerItems[ i ]; - m_rgpPlayerItems[ i ] = m_rgpPlayerItems[ i ]->m_pNext;// unlink this weapon from the box + pItem = m_rgpPlayerItems[i]; + m_rgpPlayerItems[i] = m_rgpPlayerItems[i]->m_pNext;// unlink this weapon from the box - if ( pPlayer->AddPlayerItem( pItem ) ) + if( pPlayer->AddPlayerItem( pItem ) ) { pItem->AttachToPlayer( pPlayer ); } @@ -1304,14 +1293,14 @@ void CWeaponBox::Touch( CBaseEntity *pOther ) BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon ) { // is one of these weapons already packed in this box? - if ( HasWeapon( pWeapon ) ) + if( HasWeapon( pWeapon ) ) { return FALSE;// box can only hold one of each weapon type } - if ( pWeapon->m_pPlayer ) + if( pWeapon->m_pPlayer ) { - if ( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon ) ) + if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon ) ) { // failed to unhook the weapon from the player! return FALSE; @@ -1320,16 +1309,16 @@ BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon ) int iWeaponSlot = pWeapon->iItemSlot(); - if ( m_rgpPlayerItems[ iWeaponSlot ] ) + if( m_rgpPlayerItems[iWeaponSlot] ) { // there's already one weapon in this slot, so link this into the slot's column - pWeapon->m_pNext = m_rgpPlayerItems[ iWeaponSlot ]; - m_rgpPlayerItems[ iWeaponSlot ] = pWeapon; + pWeapon->m_pNext = m_rgpPlayerItems[iWeaponSlot]; + m_rgpPlayerItems[iWeaponSlot] = pWeapon; } else { // first weapon we have for this slot - m_rgpPlayerItems[ iWeaponSlot ] = pWeapon; + m_rgpPlayerItems[iWeaponSlot] = pWeapon; pWeapon->m_pNext = NULL; } @@ -1344,7 +1333,7 @@ BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon ) pWeapon->SetTouch( NULL ); pWeapon->m_pPlayer = NULL; - //ALERT ( at_console, "packed %s\n", STRING(pWeapon->pev->classname) ); + //ALERT( at_console, "packed %s\n", STRING( pWeapon->pev->classname ) ); return TRUE; } @@ -1356,18 +1345,18 @@ BOOL CWeaponBox::PackAmmo( int iszName, int iCount ) { int iMaxCarry; - if ( FStringNull( iszName ) ) + if( FStringNull( iszName ) ) { // error here - ALERT ( at_console, "NULL String in PackAmmo!\n" ); + ALERT( at_console, "NULL String in PackAmmo!\n" ); return FALSE; } iMaxCarry = MaxAmmoCarry( iszName ); - if ( iMaxCarry != -1 && iCount > 0 ) + if( iMaxCarry != -1 && iCount > 0 ) { - //ALERT ( at_console, "Packed %d rounds of %s\n", iCount, STRING(iszName) ); + //ALERT( at_console, "Packed %d rounds of %s\n", iCount, STRING( iszName ) ); GiveAmmo( iCount, (char *)STRING( iszName ), iMaxCarry ); return TRUE; } @@ -1382,15 +1371,15 @@ int CWeaponBox::GiveAmmo( int iCount, char *szName, int iMax, int *pIndex/* = NU { int i; - for (i = 1; i < MAX_AMMO_SLOTS && !FStringNull( m_rgiszAmmo[i] ); i++) + for( i = 1; i < MAX_AMMO_SLOTS && !FStringNull( m_rgiszAmmo[i] ); i++ ) { - if (stricmp( szName, STRING( m_rgiszAmmo[i])) == 0) + if( stricmp( szName, STRING( m_rgiszAmmo[i] ) ) == 0 ) { - if (pIndex) + if( pIndex ) *pIndex = i; - int iAdd = min( iCount, iMax - m_rgAmmo[i]); - if (iCount == 0 || iAdd > 0) + int iAdd = min( iCount, iMax - m_rgAmmo[i] ); + if( iCount == 0 || iAdd > 0 ) { m_rgAmmo[i] += iAdd; @@ -1399,9 +1388,9 @@ int CWeaponBox::GiveAmmo( int iCount, char *szName, int iMax, int *pIndex/* = NU return -1; } } - if (i < MAX_AMMO_SLOTS) + if( i < MAX_AMMO_SLOTS ) { - if (pIndex) + if( pIndex ) *pIndex = i; m_rgiszAmmo[i] = MAKE_STRING( szName ); @@ -1409,7 +1398,7 @@ int CWeaponBox::GiveAmmo( int iCount, char *szName, int iMax, int *pIndex/* = NU return i; } - ALERT( at_console, "out of named ammo slots\n"); + ALERT( at_console, "out of named ammo slots\n" ); return i; } @@ -1421,9 +1410,9 @@ BOOL CWeaponBox::HasWeapon( CBasePlayerItem *pCheckItem ) { CBasePlayerItem *pItem = m_rgpPlayerItems[pCheckItem->iItemSlot()]; - while (pItem) + while( pItem ) { - if (FClassnameIs( pItem->pev, STRING( pCheckItem->pev->classname) )) + if( FClassnameIs( pItem->pev, STRING( pCheckItem->pev->classname ) ) ) { return TRUE; } @@ -1440,17 +1429,17 @@ BOOL CWeaponBox::IsEmpty( void ) { int i; - for ( i = 0 ; i < MAX_ITEM_TYPES ; i++ ) + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { - if ( m_rgpPlayerItems[ i ] ) + if( m_rgpPlayerItems[i] ) { return FALSE; } } - for ( i = 0 ; i < MAX_AMMO_SLOTS ; i++ ) + for( i = 0; i < MAX_AMMO_SLOTS; i++ ) { - if ( !FStringNull( m_rgiszAmmo[ i ] ) ) + if( !FStringNull( m_rgiszAmmo[i] ) ) { // still have a bit of this type of ammo return FALSE; @@ -1464,11 +1453,10 @@ BOOL CWeaponBox::IsEmpty( void ) //========================================================= void CWeaponBox::SetObjectCollisionBox( void ) { - pev->absmin = pev->origin + Vector(-16, -16, 0); - pev->absmax = pev->origin + Vector(16, 16, 16); + pev->absmin = pev->origin + Vector( -16, -16, 0 ); + pev->absmax = pev->origin + Vector( 16, 16, 16 ); } - void CBasePlayerWeapon::PrintState( void ) { ALERT( at_console, "primary: %f\n", m_flNextPrimaryAttack ); @@ -1542,4 +1530,3 @@ TYPEDESCRIPTION CSatchel::m_SaveData[] = }; IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon ) -