From 7c66c3aa9ce0cf03762225e4734b39ddea287e4a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 7 Apr 2018 04:01:09 +0500 Subject: [PATCH] A little optimizations. --- cl_dll/ammo.cpp | 4 +- cl_dll/cl_util.h | 16 +- cl_dll/ev_hldm.cpp | 905 ++++++++++++++++-------------- cl_dll/quake/quake_baseentity.cpp | 4 +- cl_dll/quake/quake_weapons.cpp | 22 +- common/r_efx.h | 2 +- dlls/aghl/agglobal.cpp | 12 - dlls/dmc/quake_gun.cpp | 2 +- dlls/dmc/quake_items.cpp | 4 +- dlls/dmc/quake_weapons_all.cpp | 2 +- dlls/doors.cpp | 2 +- dlls/multiplay_gamerules.cpp | 2 +- dlls/player.cpp | 4 +- dlls/player.h | 2 +- dlls/weapons.cpp | 12 +- dlls/weapons.h | 4 +- 16 files changed, 527 insertions(+), 472 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 86932755..434dc3f7 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -802,7 +802,7 @@ int CHudAmmo::Draw( float flTime ) int iCrossX; int iCrossY; int iCrossLength; - char *chCrossHair = "+"; // Heh + const char *chCrossHair = "+"; // Heh //if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) // return 1; @@ -845,7 +845,7 @@ int CHudAmmo::Draw( float flTime ) y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; /******************* DRAW CROSSHAIR *********************/ - iCrossLength = gHUD.m_scrinfo.charWidths[*chCrossHair]; + iCrossLength = gHUD.m_scrinfo.charWidths[(unsigned char)*chCrossHair]; iCrossY = ScreenHeight / 2 - gHUD.m_scrinfo.iCharHeight / 2; iCrossX = ScreenWidth / 2 - iCrossLength / 2; diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 23f12230..af41c795 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -40,9 +40,9 @@ gHUD.y.UserCmd_##x( ); \ } -inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( (char*)x ); } -inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( (char*)x ); } -inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( (char*)cv, (char*)val, flags ); } +inline float CVAR_GET_FLOAT( const char *x ) { return gEngfuncs.pfnGetCvarFloat( x ); } +inline char* CVAR_GET_STRING( const char *x ) { return gEngfuncs.pfnGetCvarString( x ); } +inline struct cvar_s *CVAR_CREATE( const char *cv, const char *val, const int flags ) { return gEngfuncs.pfnRegisterVariable( cv, val, flags ); } #define SPR_Load ( *gEngfuncs.pfnSPR_Load ) #define SPR_Set ( *gEngfuncs.pfnSPR_Set ) @@ -108,16 +108,16 @@ inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b ) inline int DrawConsoleString( int x, int y, const char *string ) { if( hud_textmode->value == 1 ) - return gHUD.DrawHudString( x, y, 9999, (char*)string, 255 * g_hud_text_color[0], 255 * g_hud_text_color[1], 255 * g_hud_text_color[2] ); - return gEngfuncs.pfnDrawConsoleString( x, y, (char*) string ); + return gHUD.DrawHudString( x, y, 9999, string, 255 * g_hud_text_color[0], 255 * g_hud_text_color[1], 255 * g_hud_text_color[2] ); + return gEngfuncs.pfnDrawConsoleString( x, y, string ); } inline void GetConsoleStringSize( const char *string, int *width, int *height ) { if( hud_textmode->value == 1 ) - *height = 13, *width = gHUD.DrawHudStringLen( (char*)string ); + *height = 13, *width = gHUD.DrawHudStringLen( string ); else - gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height ); + gEngfuncs.pfnDrawConsoleStringLen( string, width, height ); } int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ); @@ -126,7 +126,7 @@ inline int ConsoleStringLen( const char *string ) { int _width = 0, _height = 0; if( hud_textmode->value == 1 ) - return gHUD.DrawHudStringLen( (char*)string ); + return gHUD.DrawHudStringLen( string ); GetConsoleStringSize( string, &_width, &_height ); return _width; } diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 39d62bb7..e5863812 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -31,33 +31,34 @@ extern "C" char PM_FindTextureType( char *name ); -void V_PunchAxis( int axis, float punch ); +extern void EV_Quake_DecalTrace( pmtrace_t *pTrace, const char *decalName ); +extern void V_PunchAxis( int axis, float punch ); extern vec3_t v_origin; extern "C" { // HLDM -void EV_FireShotGunSingle( struct event_args_s *args ); -void EV_FireShotGunDouble( struct event_args_s *args ); -void EV_FireAxe( struct event_args_s *args ); -void EV_FireAxeSwing( struct event_args_s *args ); -void EV_FireRocket( struct event_args_s *args ); -void EV_FireLightning( struct event_args_s *args ); -void EV_FireSpike( struct event_args_s *args ); -void EV_FireSuperSpike( struct event_args_s *args ); -void EV_FireGrenade( struct event_args_s *args ); -void EV_Gibbed( event_args_t *args ); -void EV_Teleport( event_args_t *args ); -void EV_Trail( event_args_t *args ); -void EV_Explosion( event_args_t *args ); +void EV_FireShotGunSingle( struct event_args_s *args ); +void EV_FireShotGunDouble( struct event_args_s *args ); +void EV_FireAxe( struct event_args_s *args ); +void EV_FireAxeSwing( struct event_args_s *args ); +void EV_FireRocket( struct event_args_s *args ); +void EV_FireLightning( struct event_args_s *args ); +void EV_FireSpike( struct event_args_s *args ); +void EV_FireSuperSpike( struct event_args_s *args ); +void EV_FireGrenade( struct event_args_s *args ); +void EV_Gibbed( event_args_t *args ); +void EV_Teleport( event_args_t *args ); +void EV_Trail( event_args_t *args ); +void EV_Explosion( event_args_t *args ); -void EV_PlayerPowerup( struct event_args_s *args ); +void EV_PlayerPowerup( struct event_args_s *args ); -void EV_DMC_DoorGoUp( struct event_args_s *args ); -void EV_DMC_DoorGoDown( struct event_args_s *args ); -void EV_DMC_DoorHitTop( struct event_args_s *args ); -void EV_DMC_DoorHitBottom( struct event_args_s *args ); +void EV_DMC_DoorGoUp( struct event_args_s *args ); +void EV_DMC_DoorGoDown( struct event_args_s *args ); +void EV_DMC_DoorHitTop( struct event_args_s *args ); +void EV_DMC_DoorHitBottom( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); } @@ -88,9 +89,9 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v int cnt; float fattn = ATTN_NORM; int entity; - char *pTextureName; - char texname[ 64 ]; - char szbuffer[ 64 ]; + const char *pTextureName; + char texname[64]; + char szbuffer[64]; entity = gEngfuncs.pEventAPI->EV_IndexFromTrace( ptr ); @@ -100,85 +101,101 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v chTextureType = 0; // Player - if ( entity >= 1 && entity <= gEngfuncs.GetMaxClients() ) + if( entity >= 1 && entity <= gEngfuncs.GetMaxClients() ) { // hit body chTextureType = CHAR_TEX_FLESH; } - else if ( entity == 0 ) + else if( entity == 0 ) { // get texture from entity or world (world is ent(0)) - pTextureName = (char *)gEngfuncs.pEventAPI->EV_TraceTexture( ptr->ent, vecSrc, vecEnd ); + pTextureName = gEngfuncs.pEventAPI->EV_TraceTexture( ptr->ent, vecSrc, vecEnd ); - if ( pTextureName ) + if( pTextureName ) { strcpy( texname, pTextureName ); pTextureName = texname; // strip leading '-0' or '+0~' or '{' or '!' - if (*pTextureName == '-' || *pTextureName == '+') + if(*pTextureName == '-' || *pTextureName == '+') { pTextureName += 2; } - if (*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ') + if(*pTextureName == '{' || *pTextureName == '!' || *pTextureName == '~' || *pTextureName == ' ') { pTextureName++; } // '}}' strcpy( szbuffer, pTextureName ); - szbuffer[ CBTEXTURENAMEMAX - 1 ] = 0; + szbuffer[CBTEXTURENAMEMAX - 1] = 0; // get texture type chTextureType = PM_FindTextureType( szbuffer ); } } - switch (chTextureType) + switch( chTextureType ) { default: - case CHAR_TEX_CONCRETE: fvol = 0.9; fvolbar = 0.6; + case CHAR_TEX_CONCRETE: + fvol = 0.9; + fvolbar = 0.6; rgsz[0] = "player/pl_step1.wav"; rgsz[1] = "player/pl_step2.wav"; cnt = 2; break; - case CHAR_TEX_METAL: fvol = 0.9; fvolbar = 0.3; + case CHAR_TEX_METAL: + fvol = 0.9; + fvolbar = 0.3; rgsz[0] = "player/pl_metal1.wav"; rgsz[1] = "player/pl_metal2.wav"; cnt = 2; break; - case CHAR_TEX_DIRT: fvol = 0.9; fvolbar = 0.1; + case CHAR_TEX_DIRT: + fvol = 0.9; + fvolbar = 0.1; rgsz[0] = "player/pl_dirt1.wav"; rgsz[1] = "player/pl_dirt2.wav"; rgsz[2] = "player/pl_dirt3.wav"; cnt = 3; break; - case CHAR_TEX_VENT: fvol = 0.5; fvolbar = 0.3; + case CHAR_TEX_VENT: + fvol = 0.5; + fvolbar = 0.3; rgsz[0] = "player/pl_duct1.wav"; rgsz[1] = "player/pl_duct1.wav"; cnt = 2; break; - case CHAR_TEX_GRATE: fvol = 0.9; fvolbar = 0.5; + case CHAR_TEX_GRATE: + fvol = 0.9; + fvolbar = 0.5; rgsz[0] = "player/pl_grate1.wav"; rgsz[1] = "player/pl_grate4.wav"; cnt = 2; break; - case CHAR_TEX_TILE: fvol = 0.8; fvolbar = 0.2; + case CHAR_TEX_TILE: + fvol = 0.8; + fvolbar = 0.2; rgsz[0] = "player/pl_tile1.wav"; rgsz[1] = "player/pl_tile3.wav"; rgsz[2] = "player/pl_tile2.wav"; rgsz[3] = "player/pl_tile4.wav"; cnt = 4; break; - case CHAR_TEX_SLOSH: fvol = 0.9; fvolbar = 0.0; + case CHAR_TEX_SLOSH: + fvol = 0.9; + fvolbar = 0.0; rgsz[0] = "player/pl_slosh1.wav"; rgsz[1] = "player/pl_slosh3.wav"; rgsz[2] = "player/pl_slosh2.wav"; rgsz[3] = "player/pl_slosh4.wav"; cnt = 4; break; - case CHAR_TEX_WOOD: fvol = 0.9; fvolbar = 0.2; + case CHAR_TEX_WOOD: + fvol = 0.9; + fvolbar = 0.2; rgsz[0] = "debris/wood1.wav"; rgsz[1] = "debris/wood2.wav"; rgsz[2] = "debris/wood3.wav"; @@ -186,7 +203,8 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v break; case CHAR_TEX_GLASS: case CHAR_TEX_COMPUTER: - fvol = 0.8; fvolbar = 0.2; + fvol = 0.8; + fvolbar = 0.2; rgsz[0] = "debris/glass1.wav"; rgsz[1] = "debris/glass2.wav"; rgsz[2] = "debris/glass3.wav"; @@ -204,7 +222,7 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v } // play material hit sound - gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, rgsz[gEngfuncs.pfnRandomLong(0,cnt-1)], fvol, fattn, 0, 96 + gEngfuncs.pfnRandomLong(0,0xf) ); + gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, rgsz[gEngfuncs.pfnRandomLong( 0, cnt-1 )], fvol, fattn, 0, 96 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); return fvolbar; } @@ -213,14 +231,12 @@ bool CheckPVS( int playerIndex ) { //returns true if the player is in the same PVS cl_entity_t *localPlayer = gEngfuncs.GetLocalPlayer(); - cl_entity_t *player; - - player = gEngfuncs.GetEntityByIndex( playerIndex ); + cl_entity_t *player = gEngfuncs.GetEntityByIndex( playerIndex ); if( !player || !localPlayer ) return false; - if ( player == localPlayer ) + if( player == localPlayer ) return true; if( player->curstate.messagenum < localPlayer->curstate.messagenum ) @@ -229,95 +245,125 @@ bool CheckPVS( int playerIndex ) return true; } - -char *EV_HLDM_RocketDamageDecal( void ) +const char *EV_HLDM_RocketDamageDecal() { - static char decalname[ 32 ]; + const char *pszDecalName; int idx; - idx = gEngfuncs.pfnRandomLong( 1, 3 ); - sprintf( decalname, "{scorch%i", idx ); - return decalname; -} - -char *EV_HLDM_DamageDecal( void ) -{ - static char decalname[ 32 ]; - int idx; - - idx = gEngfuncs.pfnRandomLong( 0, 4 ); - sprintf( decalname, "{shot%i", idx + 1 ); - return decalname; -} - - -char *EV_Lightning_DamageDecal( void ) -{ - int idx; - static char decalname[ 32 ]; - //sprintf( decalname, "{smscorch1"); - idx = gEngfuncs.pfnRandomLong( 0, 2 ); - sprintf( decalname, "{smscorch%i", idx + 1 ); + switch( idx + 1 ) + { + case 1: + pszDecalName = "{scorch1"; + break; + case 2: + pszDecalName = "{scorch2"; + break; + case 3: + pszDecalName = "{scorch3"; + break; + } - return decalname; + return pszDecalName; } -char *EV_Quake_DamageDecalClub( void ) +const char *EV_HLDM_DamageDecal() { - static char decalname[ 32 ]; + const char *pszDecalName; + int idx = gEngfuncs.pfnRandomLong( 0, 4 ); + + switch( idx + 1 ) + { + case 1: + pszDecalName = "{shot1"; + break; + case 2: + pszDecalName = "{shot2"; + break; + case 3: + pszDecalName = "{shot3"; + break; + case 4: + pszDecalName = "{shot4"; + break; + case 5: + pszDecalName = "{shot5"; + break; + } + return pszDecalName; +} + + +const char *EV_Lightning_DamageDecal( void ) +{ + const char *pszDecalName; int idx; - idx = gEngfuncs.pfnRandomLong( 0, 4 ); - sprintf( decalname, "{shot%i", idx + 1 ); - return decalname; + idx = gEngfuncs.pfnRandomLong( 0, 2 ); + switch( idx + 1 ) + { + case 1: + pszDecalName = "{smscorch1"; + break; + case 2: + pszDecalName = "{smscorch2"; + break; + case 3: + pszDecalName = "{smscorch3"; + break; + } + + return pszDecalName; } -void EV_Quake_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName ) +const char *EV_Quake_DamageDecalClub() +{ + return EV_HLDM_DamageDecal(); +} + +void EV_Quake_GunshotDecalTrace( pmtrace_t *pTrace, const char *decalName ) { int iRand; - physent_t *pe; gEngfuncs.pEfxAPI->R_BulletImpactParticles( pTrace->endpos ); - iRand = gEngfuncs.pfnRandomLong(0,0x7FFF); - if ( iRand < (0x7fff/2) )// not every bullet makes a sound. + iRand = gEngfuncs.pfnRandomLong( 0, 0x7FFF ); + if( iRand < ( 0x7fff / 2 ) )// not every bullet makes a sound. { - switch( iRand % 5) + const char *pszSound; + + switch( iRand % 5 ) { - case 0: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 1: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 2: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 3: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 4: gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, "weapons/ric5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; + case 0: + pszSound = "weapons/ric1.wav"; + break; + case 1: + pszSound = "weapons/ric2.wav"; + break; + case 2: + pszSound = "weapons/ric3.wav"; + break; + case 3: + pszSound = "weapons/ric4.wav"; + break; + case 4: + pszSound = "weapons/ric5.wav"; + break; } + gEngfuncs.pEventAPI->EV_PlaySound( -1, pTrace->endpos, 0, pszSound, 1.0, ATTN_NORM, 0, PITCH_NORM ); } - pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent ); - - // Only decal brush models such as the world etc. - if ( decalName && decalName[0] && pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) ) - { - if ( CVAR_GET_FLOAT( "r_decals" ) ) - { - gEngfuncs.pEfxAPI->R_DecalShoot( - gEngfuncs.pEfxAPI->Draw_DecalIndex( gEngfuncs.pEfxAPI->Draw_DecalIndexFromName( decalName ) ), - gEngfuncs.pEventAPI->EV_IndexFromTrace( pTrace ), 0, pTrace->endpos, 0 ); - } - } + EV_Quake_DecalTrace( pTrace, decalName ); } - -void EV_Quake_DecalTrace( pmtrace_t *pTrace, char *decalName ) +void EV_Quake_DecalTrace( pmtrace_t *pTrace, const char *decalName ) { - physent_t *pe; - - pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent ); + physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent ); // Only decal brush models such as the world etc. - if ( decalName && decalName[0] && pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) ) + if( decalName && decalName[0] && pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) ) { - if ( CVAR_GET_FLOAT( "r_decals" ) ) + if( CVAR_GET_FLOAT( "r_decals" ) ) { gEngfuncs.pEfxAPI->R_DecalShoot( gEngfuncs.pEfxAPI->Draw_DecalIndex( gEngfuncs.pEfxAPI->Draw_DecalIndexFromName( decalName ) ), @@ -328,18 +374,15 @@ void EV_Quake_DecalTrace( pmtrace_t *pTrace, char *decalName ) void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType ) { - physent_t *pe; + // physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent ); - pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent ); - - if ( pe && pe->solid == SOLID_BSP ) + // if( pe && pe->solid == SOLID_BSP ) { switch( iBulletType ) { case BULLET_PLAYER_CROWBAR: EV_Quake_DecalTrace( pTrace, EV_Quake_DamageDecalClub() ); break; - case BULLET_PLAYER_9MM: case BULLET_MONSTER_9MM: case BULLET_PLAYER_MP5: @@ -356,7 +399,7 @@ void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType ) void EV_Quake_PlayQuadSound ( int idx, float *origin, int iFlag ) { - if ( iFlag == 1 ) + if( iFlag == 1 ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "items/damage3.wav", 1, ATTN_NORM, 0, PITCH_NORM); } @@ -377,22 +420,23 @@ void EV_Quake_FireBullets( int idx, float *forward, float *right, float *up, int VectorCopy( right, vecRight ); VectorCopy( up, vecUp ); - for ( iShot = 1; iShot <= cShots; iShot++ ) + for( iShot = 1; iShot <= cShots; iShot++ ) { vec3_t vecDir, vecEnd; // get circular gaussian spread vec3_t spread; - do { - spread[0] = gEngfuncs.pfnRandomFloat(-1.0,1.0) + gEngfuncs.pfnRandomFloat(-1.0,1.0); - spread[1] = gEngfuncs.pfnRandomFloat(-1.0,1.0) + gEngfuncs.pfnRandomFloat(-1.0,1.0); - spread[2] = spread[0] * spread[0] + spread[1] *spread[1]; - } while (spread[2] > 1); - - for ( i = 0 ; i < 3; i++ ) + do { - vecDir[i] = vecDirShooting[i] + spread[ 0 ] * vecSpread[ 0 ] * vecRight[ i ] + spread[ 1 ] * vecSpread[ 1 ] * up [ i ]; - vecEnd[i] = vecSrc[ i ] + 2048.0 * vecDir[ i ]; + spread[0] = gEngfuncs.pfnRandomFloat( -1.0, 1.0 ) + gEngfuncs.pfnRandomFloat( -1.0, 1.0 ); + spread[1] = gEngfuncs.pfnRandomFloat( -1.0, 1.0 ) + gEngfuncs.pfnRandomFloat( -1.0, 1.0 ); + spread[2] = spread[0] * spread[0] + spread[1] *spread[1]; + }while( spread[2] > 1 ); + + for( i = 0; i < 3; i++ ) + { + vecDir[i] = vecDirShooting[i] + spread[0] * vecSpread[0] * vecRight[i] + spread[1] * vecSpread[1] * up [i]; + vecEnd[i] = vecSrc[i] + 2048.0 * vecDir[i]; } gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); @@ -401,7 +445,7 @@ void EV_Quake_FireBullets( int idx, float *forward, float *right, float *up, int gEngfuncs.pEventAPI->EV_PushPMStates(); // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr ); @@ -409,15 +453,13 @@ void EV_Quake_FireBullets( int idx, float *forward, float *right, float *up, int int iBulletType = BULLET_PLAYER_BUCKSHOT; // do damage, paint decals - if ( tr.fraction != 1.0 ) + if( tr.fraction != 1.0 ) { - switch(iBulletType) + switch( iBulletType ) { default: case BULLET_PLAYER_9MM: - EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); - EV_HLDM_DecalGunshot( &tr, iBulletType ); - break; + case BULLET_PLAYER_357: case BULLET_PLAYER_MP5: EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); EV_HLDM_DecalGunshot( &tr, iBulletType ); @@ -425,10 +467,6 @@ void EV_Quake_FireBullets( int idx, float *forward, float *right, float *up, int case BULLET_PLAYER_BUCKSHOT: EV_HLDM_DecalGunshot( &tr, iBulletType ); break; - case BULLET_PLAYER_357: - EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); - EV_HLDM_DecalGunshot( &tr, iBulletType ); - break; } } @@ -463,16 +501,13 @@ void EV_FireShotGunDouble( event_args_t *args ) EV_GetGunPosition( args, vecSrc, origin ); VectorCopy( forward, vecAiming ); - for ( i = 0; i < 3; i++ ) - { - vecSpread[0] = 0.04; - vecSpread[1] = 0.04; - vecSpread[2] = 0.00; - } + vecSpread[0] = 0.04; + vecSpread[1] = 0.04; + vecSpread[2] = 0.00; EV_Quake_FireBullets( idx, forward, right, up, 14, vecSrc, vecAiming, vecSpread ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { V_PunchAxis( 0, Q_BIG_PUNCHANGLE_KICK ); } @@ -506,16 +541,13 @@ void EV_FireShotGunSingle( event_args_t *args ) EV_GetGunPosition( args, vecSrc, origin ); VectorCopy( forward, vecAiming ); - for ( i = 0; i < 3; i++ ) - { - vecSpread[0] = 0.04; - vecSpread[1] = 0.04; - vecSpread[2] = 0.00; - } + vecSpread[0] = 0.04; + vecSpread[1] = 0.04; + vecSpread[2] = 0.00; EV_Quake_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, vecSpread ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { V_PunchAxis( 0, Q_SMALL_PUNCHANGLE_KICK ); } @@ -525,27 +557,27 @@ enum soundtypes_e { SOUND_MISS, SOUND_HIT_BODY, - SOUND_HIT_WALL, + SOUND_HIT_WALL }; void EV_Quake_PlayAxeSound( int idx, float *origin, int iSoundType ) { - switch ( iSoundType ) + const char *pszSound; + + switch( iSoundType ) { case SOUND_HIT_BODY: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "player/axhitbod.wav", 1, ATTN_NORM, 0, PITCH_NORM); + pszSound = "player/axhitbod.wav"; break; - case SOUND_HIT_WALL: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "player/axhit2.wav", 1, ATTN_NORM, 0, PITCH_NORM); + pszSound = "player/axhit2.wav"; break; - default: - break; + return; } + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, pszSound, 1, ATTN_NORM, 0, PITCH_NORM ); } - void EV_FireAxe( event_args_t *args ) { int ent; @@ -579,16 +611,16 @@ void EV_FireAxe( event_args_t *args ) gEngfuncs.pEventAPI->EV_PushPMStates(); // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_NORMAL, -1, &tr ); - if ( tr.fraction < 1.0 ) + if( tr.fraction < 1.0 ) { ent = gEngfuncs.pEventAPI->EV_IndexFromTrace( &tr ); - if ( !EV_IsPlayer( ent ) ) + if( !EV_IsPlayer( ent ) ) { EV_Quake_PlayAxeSound( idx, origin, SOUND_HIT_WALL ); EV_HLDM_DecalGunshot( &tr, BULLET_PLAYER_CROWBAR ); @@ -598,10 +630,9 @@ void EV_FireAxe( event_args_t *args ) } gEngfuncs.pEventAPI->EV_PopPMStates(); - } -void EV_FireAxeSwing( event_args_t *args ) +void EV_FireAxeSwing( event_args_t *args ) { int idx; vec3_t origin; @@ -613,28 +644,28 @@ void EV_FireAxeSwing( event_args_t *args ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/ax1.wav", 1.0, ATTN_NORM, 0, 100 ); } -void EV_PowerupCallback ( struct tempent_s *ent, float frametime, float currenttime ) +void EV_PowerupCallback( struct tempent_s *ent, float frametime, float currenttime ) { //If the Player is not on our PVS, then go back - if ( !CheckPVS( ent->clientIndex ) ) + if( !CheckPVS( ent->clientIndex ) ) return; - dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight ( 0 ); + dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight( 0 ); cl_entity_t *player = gEngfuncs.GetEntityByIndex( ent->clientIndex ); - if ( !player ) + if( !player ) return; - VectorCopy ( player->origin, dl->origin ); + VectorCopy( player->origin, dl->origin ); dl->radius = 270; dl->dark = true; dl->die = gEngfuncs.GetClientTime() + 0.001; //Kill it right away - if ( ent->entity.baseline.iuser2 == 1 ) + if( ent->entity.baseline.iuser2 == 1 ) { - if ( ent->entity.baseline.iuser1 == 1 ) + if( ent->entity.baseline.iuser1 == 1 ) { dl->color.r = 255; dl->color.g = 128; @@ -647,15 +678,15 @@ void EV_PowerupCallback ( struct tempent_s *ent, float frametime, float currentt dl->color.b = 255; } } - else if ( ent->entity.baseline.iuser2 == 2 ) + else if( ent->entity.baseline.iuser2 == 2 ) { - if ( ent->entity.baseline.iuser1 == 1 ) + if( ent->entity.baseline.iuser1 == 1 ) { dl->color.r = 255; dl->color.g = 128; dl->color.b = 0; } - else if ( ent->entity.baseline.iuser1 == 2 ) + else if( ent->entity.baseline.iuser1 == 2 ) { dl->color.r = 0; dl->color.g = 128; @@ -668,7 +699,7 @@ void EV_PowerupCallback ( struct tempent_s *ent, float frametime, float currentt dl->color.b = 0; } } - else if ( ent->entity.baseline.iuser2 == 3 ) + else if( ent->entity.baseline.iuser2 == 3 ) { dl->color.r = 255; dl->color.g = 125; @@ -676,34 +707,34 @@ void EV_PowerupCallback ( struct tempent_s *ent, float frametime, float currentt } } -void EV_PlayerPowerup (event_args_t *args) +void EV_PlayerPowerup( event_args_t *args ) { int iEntIndex = args->iparam1; - int iTeam = args->iparam2; - int iPowerUp = (int)args->fparam1; + int iTeam = args->iparam2; + int iPowerUp = (int)args->fparam1; int modelIndex; - char *model = "sprites/smoke.spr"; + const char *model = "sprites/smoke.spr"; - modelIndex = gEngfuncs.pEventAPI->EV_FindModelIndex ( model ); + modelIndex = gEngfuncs.pEventAPI->EV_FindModelIndex( model ); - if ( args->bparam1 == 1) - gEngfuncs.pEfxAPI->R_KillAttachedTents ( iEntIndex ); + if( args->bparam1 == 1 ) + gEngfuncs.pEfxAPI->R_KillAttachedTents( iEntIndex ); - if ( iPowerUp ) + if( iPowerUp ) { TEMPENTITY *pTrailSpawner = NULL; - pTrailSpawner = gEngfuncs.pEfxAPI->R_TempModel ( args->origin, args->velocity, args->angles, 9999, modelIndex, TE_BOUNCE_NULL ); + pTrailSpawner = gEngfuncs.pEfxAPI->R_TempModel( args->origin, args->velocity, args->angles, 9999, modelIndex, TE_BOUNCE_NULL ); - if ( pTrailSpawner != NULL) + if( pTrailSpawner != NULL ) { - pTrailSpawner->flags |= ( FTENT_PLYRATTACHMENT | FTENT_PERSIST | FTENT_NOMODEL | FTENT_CLIENTCUSTOM ); - pTrailSpawner->clientIndex = iEntIndex; + pTrailSpawner->flags |= ( FTENT_PLYRATTACHMENT | FTENT_PERSIST | FTENT_NOMODEL | FTENT_CLIENTCUSTOM ); + pTrailSpawner->clientIndex = iEntIndex; - pTrailSpawner->entity.baseline.iuser1 = iTeam; - pTrailSpawner->entity.baseline.iuser2 = iPowerUp; + pTrailSpawner->entity.baseline.iuser1 = iTeam; + pTrailSpawner->entity.baseline.iuser2 = iPowerUp; - pTrailSpawner->callback = EV_PowerupCallback; + pTrailSpawner->callback = EV_PowerupCallback; } } } @@ -738,7 +769,7 @@ void EV_FireLightning( event_args_t *args ) AngleVectors( angles, forward, right, up ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { if ( g_flLightTime <= gEngfuncs.GetClientTime() ) { @@ -756,21 +787,20 @@ void EV_FireLightning( event_args_t *args ) origin = origin + Vector( 0, 0, 16 ); } - - if ( bSound ) + if( bSound ) { gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/lhit.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); EV_Quake_PlayQuadSound( idx, origin, args->iparam1 ); } - if ( iShutDown == 0 && EV_IsLocal( idx ) && pBeam == NULL ) + if( iShutDown == 0 && EV_IsLocal( idx ) && pBeam == NULL ) { vec3_t vecSrc, vecEnd; pmtrace_t tr; cl_entity_t *pl = gEngfuncs.GetEntityByIndex( idx ); - if ( pl ) + if( pl ) { VectorCopy( gHUD.m_vecAngles, angles ); @@ -796,11 +826,11 @@ void EV_FireLightning( event_args_t *args ) pBeam = gEngfuncs.pEfxAPI->R_BeamEntPoint ( idx | 0x1000, tr.endpos, modelIndex, 99999, 5.0, 0.15, 2.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 ); } } - else if ( iShutDown == 1 ) + else if( iShutDown == 1 ) { - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { - if ( pBeam ) + if( pBeam ) { pBeam->die = 0.0; pBeam = NULL; @@ -821,7 +851,7 @@ void EV_FireRocket( event_args_t *args ) EV_Quake_PlayQuadSound( idx, origin, args->iparam1 ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { V_PunchAxis( 0, Q_SMALL_PUNCHANGLE_KICK ); } @@ -839,7 +869,7 @@ void EV_FireGrenade( event_args_t *args ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/grenade.wav", 1.0, ATTN_NORM, 0, 100 ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { V_PunchAxis( 0, Q_SMALL_PUNCHANGLE_KICK ); } @@ -847,17 +877,11 @@ void EV_FireGrenade( event_args_t *args ) void EV_Quake_NailTouch( struct tempent_s *ent, pmtrace_t *ptr ) { - char decalname[ 32 ]; - int idx; - physent_t *pe; + //physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( ptr->ent ); - pe = gEngfuncs.pEventAPI->EV_GetPhysent( ptr->ent ); - if ( pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) ) + //if( pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) ) { - decalname[ 0 ] = '\0'; - idx = gEngfuncs.pfnRandomLong( 0, 4 ); - sprintf( decalname, "{shot%i", idx + 1 ); - EV_Quake_GunshotDecalTrace( ptr, decalname ); + EV_Quake_GunshotDecalTrace( ptr, EV_HLDM_DamageDecal() ); } } @@ -892,9 +916,9 @@ void EV_FireSpike( event_args_t *args ) // make nails VectorScale( forward, 1000, vecVelocity ); - EV_Quake_ClientProjectile( origin + Vector(0,0,10) + (right * offset), vecVelocity, (short)shell, idx, 6, EV_Quake_NailTouch ); + EV_Quake_ClientProjectile( origin + Vector( 0, 0, 10 ) + ( right * offset ), vecVelocity, (short)shell, idx, 6, EV_Quake_NailTouch ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { V_PunchAxis( 0, Q_SMALL_PUNCHANGLE_KICK ); } @@ -923,15 +947,15 @@ void EV_FireSuperSpike( event_args_t *args ) // make nails VectorScale( forward, 1000, vecVelocity ); - EV_Quake_ClientProjectile( origin + Vector(0,0,16), vecVelocity, (short)shell, idx, 6, EV_Quake_NailTouch ); + EV_Quake_ClientProjectile( origin + Vector( 0, 0, 16 ), vecVelocity, (short)shell, idx, 6, EV_Quake_NailTouch ); - if ( EV_IsLocal( idx ) ) + if( EV_IsLocal( idx ) ) { V_PunchAxis( 0, Q_SMALL_PUNCHANGLE_KICK ); } } -#define SND_CHANGE_PITCH (1<<7) +#define SND_CHANGE_PITCH ( 1 << 7 ) void EV_TrainPitchAdjust( event_args_t *args ) { @@ -944,7 +968,7 @@ void EV_TrainPitchAdjust( event_args_t *args ) int pitch; int stop; - char sz[ 256 ]; + const char *pszSound; idx = args->entindex; @@ -957,180 +981,225 @@ void EV_TrainPitchAdjust( event_args_t *args ) noise = (int)(((us_params) >> 12 ) & 0x0007); pitch = (int)( 10.0 * (float)( ( us_params >> 6 ) & 0x003f ) ); - switch ( noise ) + switch( noise ) { - case 1: strcpy( sz, "plats/ttrain1.wav"); break; - case 2: strcpy( sz, "plats/ttrain2.wav"); break; - case 3: strcpy( sz, "plats/ttrain3.wav"); break; - case 4: strcpy( sz, "plats/ttrain4.wav"); break; - case 5: strcpy( sz, "plats/ttrain6.wav"); break; - case 6: strcpy( sz, "plats/ttrain7.wav"); break; + case 1: + pszSound = "plats/ttrain1.wav"; + break; + case 2: + pszSound = "plats/ttrain2.wav"; + break; + case 3: + pszSound = "plats/ttrain3.wav"; + break; + case 4: + pszSound = "plats/ttrain4.wav"; + break; + case 5: + pszSound = "plats/ttrain6.wav"; + break; + case 6: + pszSound = "plats/ttrain7.wav"; + break; default: // no sound - strcpy( sz, "" ); return; } - if ( stop ) + if( stop ) { - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz ); + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, pszSound ); } else { - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, pszSound, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch ); } } -char *DMC_BloodDecal (void) +const char *DMC_BloodDecal() { - static char blooddecal[ 32 ]; - int idx; - - idx = gEngfuncs.pfnRandomLong( 0, 5 ); - - sprintf( blooddecal, "{blood%i", idx + 1 ); - - return blooddecal; -} - -void DMC_DecalTrace( pmtrace_t *pTrace, char *decalName ) -{ - physent_t *pe; - - pe = gEngfuncs.pEventAPI->EV_GetPhysent( pTrace->ent ); - - // Only decal brush models such as the world etc. - if ( decalName && decalName[0] && pe && ( pe->solid == SOLID_BSP || pe->movetype == MOVETYPE_PUSHSTEP ) ) + const char *pszDecalName; + int idx = gEngfuncs.pfnRandomLong( 0, 5 ); + + switch( idx + 1 ) { - if ( CVAR_GET_FLOAT( "r_decals" ) ) - { - gEngfuncs.pEfxAPI->R_DecalShoot( - gEngfuncs.pEfxAPI->Draw_DecalIndex( gEngfuncs.pEfxAPI->Draw_DecalIndexFromName( decalName ) ), - gEngfuncs.pEventAPI->EV_IndexFromTrace( pTrace ), 0, pTrace->endpos, 0 ); - } + case 1: + pszDecalName = "{blood1"; + break; + case 2: + pszDecalName = "{blood2"; + break; + case 3: + pszDecalName = "{blood3"; + break; + case 4: + pszDecalName = "{blood4"; + break; + case 5: + pszDecalName = "{blood5"; + break; + case 6: + pszDecalName = "{blood6"; + break; } + return pszDecalName; } -void EV_GibTouch ( struct tempent_s *ent, struct pmtrace_s *ptr ) +void DMC_DecalTrace( pmtrace_t *pTrace, const char *decalName ) { - DMC_DecalTrace (ptr, DMC_BloodDecal()); + EV_Quake_DecalTrace( pTrace, decalName ); +} - // 1 in 5 chance of squishy sound - if (gEngfuncs.pfnRandomLong(0, 4) > 0) - return; +void EV_GibTouch( struct tempent_s *ent, struct pmtrace_s *ptr ) +{ + const char *pszSound; - switch (gEngfuncs.pfnRandomLong(0, 5)) - { - case 0 : gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, "debris/flesh1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 1 : gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, "debris/flesh2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 2 : gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, "debris/flesh3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 3 : gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, "debris/flesh5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 4 : gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, "debris/flesh6.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 5 : gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, "debris/flesh7.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - } + DMC_DecalTrace( ptr, DMC_BloodDecal() ); + + // 1 in 5 chance of squishy sound + if( gEngfuncs.pfnRandomLong( 0, 4 ) > 0 ) + return; + + switch( gEngfuncs.pfnRandomLong( 0, 5 ) ) + { + case 0: + pszSound = "debris/flesh1.wav"; + break; + case 1: + pszSound = "debris/flesh2.wav"; + break; + case 2: + pszSound = "debris/flesh3.wav"; + break; + case 3: + pszSound = "debris/flesh5.wav"; + break; + case 4: + pszSound = "debris/flesh6.wav"; + break; + case 5: + pszSound = "debris/flesh7.wav"; + break; + } + gEngfuncs.pEventAPI->EV_PlaySound( 0, ptr->endpos, CHAN_STATIC, pszSound, 1.0, ATTN_NORM, 0, PITCH_NORM ); } void EV_GibParticleCallback( struct particle_s *particle, float frametime ) { - int i; - - for ( i = 0; i < 3; i++ ) + for( int i = 0; i < 3; i++ ) { - particle->org[ i ] += particle->vel[ i ] * frametime; + particle->org[i] += particle->vel[i] * frametime; } } -void EV_Gibbed (event_args_t *args) +void EV_Gibbed( event_args_t *args ) { + vec3_t origin, velocity, angles, rotate; + int modelindex, i; + TEMPENTITY *pGib = NULL; + int gibs = 5; - vec3_t origin, velocity, angles, rotate; - int modelindex, i; - TEMPENTITY *pGib = NULL; - int gibs = 5; - char *model1 = "models/gib_1.mdl"; - char *model2 = "models/gib_2.mdl"; - char *model3 = "models/gib_3.mdl"; + VectorCopy( args->origin, origin ); - VectorCopy( args->origin, origin ); + gEngfuncs.pEventAPI->EV_PlaySound( 0, origin, CHAN_STATIC, "player/gib.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); - gEngfuncs.pEventAPI->EV_PlaySound( 0, origin, CHAN_STATIC, "player/gib.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); + rotate[0] = gEngfuncs.pfnRandomLong( -100, 100 ); + rotate[1] = gEngfuncs.pfnRandomLong( -100, 100 ); + rotate[2] = gEngfuncs.pfnRandomLong( -100, 100 ); - rotate[0] = gEngfuncs.pfnRandomLong (-100, 100); - rotate[1] = gEngfuncs.pfnRandomLong (-100, 100); - rotate[2] = gEngfuncs.pfnRandomLong (-100, 100); - - for (i = 0; i < gibs; i++) + for( i = 0; i < gibs; i++ ) { - switch ( gEngfuncs.pfnRandomLong( 1, 3 ) ) - { - case 1: modelindex = gEngfuncs.pEventAPI->EV_FindModelIndex ( model1 ); break; - case 2: modelindex = gEngfuncs.pEventAPI->EV_FindModelIndex ( model2 ); break; - case 3: modelindex = gEngfuncs.pEventAPI->EV_FindModelIndex ( model3 ); break; - //Just in case - default: modelindex = gEngfuncs.pEventAPI->EV_FindModelIndex ( model1 ); break; - } + const char *pszModel; - if (!modelindex) - return; + switch( gEngfuncs.pfnRandomLong( 1, 3 ) ) + { + //Just in case + default: + case 1: + pszModel = "models/gib_1.mdl"; + break; + case 2: + pszModel = "models/gib_2.mdl"; + break; + case 3: + pszModel = "models/gib_3.mdl"; + break; + } + + modelindex = gEngfuncs.pEventAPI->EV_FindModelIndex( pszModel ); + + if( !modelindex ) + return; VectorCopy( args->angles, angles ); - VectorScale( angles, -1.0, angles ); + VectorScale( angles, -1.0, angles ); - angles[0] += gEngfuncs.pfnRandomFloat ( -0.30, 0.30 ); - angles[1] += gEngfuncs.pfnRandomFloat ( -0.30, 0.30 ); - angles[2] += gEngfuncs.pfnRandomFloat ( -0.30, 0.30 ); + angles[0] += gEngfuncs.pfnRandomFloat( -0.30, 0.30 ); + angles[1] += gEngfuncs.pfnRandomFloat( -0.30, 0.30 ); + angles[2] += gEngfuncs.pfnRandomFloat( -0.30, 0.30 ); - VectorScale ( angles, gEngfuncs.pfnRandomFloat( 500, 1200 ), velocity ); - velocity[2] += 600; + VectorScale( angles, gEngfuncs.pfnRandomFloat( 500, 1200 ), velocity ); + velocity[2] += 600; - pGib = gEngfuncs.pEfxAPI->R_TempModel (origin, velocity, rotate, 15, modelindex, TE_BOUNCE_NULL); + pGib = gEngfuncs.pEfxAPI->R_TempModel( origin, velocity, rotate, 15, modelindex, TE_BOUNCE_NULL ); - if (pGib != NULL) - { - pGib->flags |= (FTENT_COLLIDEWORLD | FTENT_ROTATE | FTENT_FADEOUT | FTENT_CLIENTCUSTOM | FTENT_SMOKETRAIL); - pGib->hitcallback = EV_GibTouch; - - } - } + if( pGib ) + { + pGib->flags |= ( FTENT_COLLIDEWORLD | FTENT_ROTATE | FTENT_FADEOUT | FTENT_CLIENTCUSTOM | FTENT_SMOKETRAIL ); + pGib->hitcallback = EV_GibTouch; + } + } } //Spawns the teleport effect. -void EV_Teleport ( event_args_t *args ) +void EV_Teleport( event_args_t *args ) { + const char *pszSound; vec3_t vecOrg; VectorCopy( args->origin, vecOrg ); - switch (gEngfuncs.pfnRandomLong(0, 4)) - { - case 0 : gEngfuncs.pEventAPI->EV_PlaySound( 0, vecOrg, CHAN_STATIC, "misc/r_tele1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 1 : gEngfuncs.pEventAPI->EV_PlaySound( 0, vecOrg, CHAN_STATIC, "misc/r_tele2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 2 : gEngfuncs.pEventAPI->EV_PlaySound( 0, vecOrg, CHAN_STATIC, "misc/r_tele3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 3 : gEngfuncs.pEventAPI->EV_PlaySound( 0, vecOrg, CHAN_STATIC, "misc/r_tele4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - case 4 : gEngfuncs.pEventAPI->EV_PlaySound( 0, vecOrg, CHAN_STATIC, "misc/r_tele5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM ); break; - } + switch( gEngfuncs.pfnRandomLong( 0, 4 ) ) + { + case 0: + pszSound = "misc/r_tele1.wav"; + break; + case 1: + pszSound = "misc/r_tele2.wav"; + break; + case 2: + pszSound = "misc/r_tele3.wav"; + break; + case 3: + pszSound = "misc/r_tele4.wav"; + break; + case 4: + pszSound = "misc/r_tele5.wav"; + break; + } + gEngfuncs.pEventAPI->EV_PlaySound( 0, vecOrg, CHAN_STATIC, pszSound, 1.0, ATTN_NORM, 0, PITCH_NORM ); gEngfuncs.pEfxAPI->R_TeleportSplash( vecOrg ); } -int ramp3[8] = {0x6d, 0x6b, 6, 5, 4, 3}; +int ramp3[8] = {0x6d, 0x6b, 6, 5, 4, 3}; -void EV_RocketTrailCallback ( struct tempent_s *ent, float frametime, float currenttime ) +void EV_RocketTrailCallback( struct tempent_s *ent, float frametime, float currenttime ) { - if ( currenttime < ent->entity.baseline.fuser1 ) + if( currenttime < ent->entity.baseline.fuser1 ) return; - if ( ent->entity.origin == ent->entity.attachment[0] ) + if( ent->entity.origin == ent->entity.attachment[0] ) ent->die = gEngfuncs.GetClientTime(); else - VectorCopy ( ent->entity.origin, ent->entity.attachment[0] ); + VectorCopy( ent->entity.origin, ent->entity.attachment[0] ); //Make the Rocket light up. ( And only rockets, no Grenades ). - if ( ent->entity.baseline.sequence == 70 ) + if( ent->entity.baseline.sequence == 70 ) { - dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight ( 0 ); - VectorCopy ( ent->entity.origin, dl->origin ); + dlight_t *dl = gEngfuncs.pEfxAPI->CL_AllocDlight( 0 ); + VectorCopy( ent->entity.origin, dl->origin ); dl->radius = 160; dl->dark = true; @@ -1145,37 +1214,37 @@ void EV_RocketTrailCallback ( struct tempent_s *ent, float frametime, float curr #define GRENADE_TRAIL 1 #define ROCKET_TRAIL 2 -void EV_Trail (event_args_t *args) +void EV_Trail( event_args_t *args ) { int iEntIndex = args->iparam1; TEMPENTITY *pTrailSpawner = NULL; - - pTrailSpawner = gEngfuncs.pEfxAPI->CL_TempEntAllocNoModel ( args->origin ); - if ( pTrailSpawner != NULL) + pTrailSpawner = gEngfuncs.pEfxAPI->CL_TempEntAllocNoModel( args->origin ); + + if( pTrailSpawner != NULL ) { - pTrailSpawner->flags |= ( FTENT_PLYRATTACHMENT | FTENT_COLLIDEKILL | FTENT_CLIENTCUSTOM | FTENT_SMOKETRAIL | FTENT_COLLIDEWORLD ); - pTrailSpawner->callback = EV_RocketTrailCallback; - pTrailSpawner->clientIndex = iEntIndex; + pTrailSpawner->flags |= ( FTENT_PLYRATTACHMENT | FTENT_COLLIDEKILL | FTENT_CLIENTCUSTOM | FTENT_SMOKETRAIL | FTENT_COLLIDEWORLD ); + pTrailSpawner->callback = EV_RocketTrailCallback; + pTrailSpawner->clientIndex = iEntIndex; - if ( args->iparam2 == GRENADE_TRAIL ) - pTrailSpawner->entity.baseline.sequence = 69; - else if ( args->iparam2 == ROCKET_TRAIL ) - pTrailSpawner->entity.baseline.sequence = 70; + if( args->iparam2 == GRENADE_TRAIL ) + pTrailSpawner->entity.baseline.sequence = 69; + else if ( args->iparam2 == ROCKET_TRAIL ) + pTrailSpawner->entity.baseline.sequence = 70; - pTrailSpawner->die = gEngfuncs.GetClientTime() + 10; // Just in case - pTrailSpawner->entity.baseline.fuser1 = gEngfuncs.GetClientTime() + 0.5; // Don't try to die till 500ms ahead + pTrailSpawner->die = gEngfuncs.GetClientTime() + 10; // Just in case + pTrailSpawner->entity.baseline.fuser1 = gEngfuncs.GetClientTime() + 0.5; // Don't try to die till 500ms ahead } } -void EV_Explosion (event_args_t *args) +void EV_Explosion( event_args_t *args ) { vec3_t origin, scorch_origin, velocity, forward, right, up; int modelIndex; - char *model = "sprites/zerogxplode.spr"; - modelIndex = gEngfuncs.pEventAPI->EV_FindModelIndex (model); + const char *model = "sprites/zerogxplode.spr"; + modelIndex = gEngfuncs.pEventAPI->EV_FindModelIndex( model ); pmtrace_t tr; - + //Make decals and Explosions //Might not work for grenades. VectorCopy( args->origin, origin ); @@ -1184,117 +1253,111 @@ void EV_Explosion (event_args_t *args) scorch_origin = origin - velocity.Normalize() * 32; gEngfuncs.pEfxAPI->R_Explosion( origin, modelIndex, 2.5, 15, TE_EXPLFLAG_NONE ); - gEngfuncs.pEfxAPI->R_ParticleExplosion2( origin , 111, 8 ); + gEngfuncs.pEfxAPI->R_ParticleExplosion2( origin, 111, 8 ); gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - - gEngfuncs.pEventAPI->EV_PushPMStates(); - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( -1 ); - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); + gEngfuncs.pEventAPI->EV_PushPMStates(); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 ); + + gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); gEngfuncs.pEventAPI->EV_PlayerTrace( scorch_origin, scorch_origin + velocity.Normalize() * 64, PM_STUDIO_BOX | PM_WORLD_ONLY , -1, &tr ); - - gEngfuncs.pEventAPI->EV_PopPMStates(); - + + gEngfuncs.pEventAPI->EV_PopPMStates(); DMC_DecalTrace( &tr, EV_HLDM_RocketDamageDecal() ); - } #define EV_DMC_MOVE_SOUND 0 #define EV_DMC_STOP_SOUND 1 -char *EV_DMC_LookupDoorSound( int type, int index ) +const char *EV_DMC_LookupDoorSound( int type, int index ) { - static char sound[ 128 ]; + const char *pszSound; int idx; // Assume the worst - strcpy( sound, "common/null.wav"); + pszSound = "common/null.wav"; - if ( type == EV_DMC_MOVE_SOUND ) + if( type == EV_DMC_MOVE_SOUND ) { idx = ( index >> 8 ) & 0xff; - switch (idx) + switch( idx ) { - case 0: - strcpy( sound, "common/null.wav"); - break; - case 1: - strcpy( sound, "doors/doormove1.wav"); - break; - case 2: - strcpy( sound, "doors/doormove2.wav"); - break; - case 3: - strcpy( sound, "doors/doormove3.wav"); - break; - case 4: - strcpy( sound, "doors/doormove4.wav"); - break; - case 5: - strcpy( sound, "doors/doormove5.wav"); - break; - case 6: - strcpy( sound, "doors/doormove6.wav"); - break; - case 7: - strcpy( sound, "doors/doormove7.wav"); - break; - case 8: - strcpy( sound, "doors/doormove8.wav"); - break; - case 9: - strcpy( sound, "doors/doormove9.wav"); - break; - case 10: - strcpy( sound, "doors/doormove10.wav"); - break; default: - strcpy( sound, "common/null.wav"); + case 0: + pszSound = "common/null.wav"; + break; + case 1: + pszSound = "doors/doormove1.wav"; + break; + case 2: + pszSound = "doors/doormove2.wav"; + break; + case 3: + pszSound = "doors/doormove3.wav"; + break; + case 4: + pszSound = "doors/doormove4.wav"; + break; + case 5: + pszSound = "doors/doormove5.wav"; + break; + case 6: + pszSound = "doors/doormove6.wav"; + break; + case 7: + pszSound = "doors/doormove7.wav"; + break; + case 8: + pszSound = "doors/doormove8.wav"; + break; + case 9: + pszSound = "doors/doormove9.wav"; + break; + case 10: + pszSound = "doors/doormove10.wav"; break; } } - else if ( type == EV_DMC_STOP_SOUND ) + else if( type == EV_DMC_STOP_SOUND ) { idx = ( index & 0xff ); // set the door's 'reached destination' stop sound - switch ( idx ) + switch( idx ) { - case 0: - strcpy( sound, "common/null.wav"); - break; - case 1: - strcpy( sound, "doors/doorstop1.wav"); - break; - case 2: - strcpy( sound, "doors/doorstop2.wav"); - break; - case 3: - strcpy( sound, "doors/doorstop3.wav"); - break; - case 4: - strcpy( sound, "doors/doorstop4.wav"); - break; - case 5: - strcpy( sound, "doors/doorstop5.wav"); - break; - case 6: - strcpy( sound, "doors/doorstop6.wav"); - break; - case 7: - strcpy( sound, "doors/doorstop7.wav"); - break; - case 8: - strcpy( sound, "doors/doorstop8.wav"); - break; default: - strcpy( sound, "common/null.wav"); + case 0: + pszSound = "common/null.wav"; + break; + case 1: + pszSound = "doors/doorstop1.wav"; + break; + case 2: + pszSound = "doors/doorstop2.wav"; + break; + case 3: + pszSound = "doors/doorstop3.wav"; + break; + case 4: + pszSound = "doors/doorstop4.wav"; + break; + case 5: + pszSound = "doors/doorstop5.wav"; + break; + case 6: + pszSound = "doors/doorstop6.wav"; + break; + case 7: + pszSound = "doors/doorstop7.wav"; + break; + case 8: + pszSound = "doors/doorstop8.wav"; break; } } - return sound; + return pszSound; } void EV_DMC_DoorGoUp( event_args_t *args ) @@ -1308,11 +1371,14 @@ void EV_DMC_DoorGoUp( event_args_t *args ) void EV_DMC_DoorGoDown( event_args_t *args ) { + EV_DMC_DoorGoUp( args ); +/* int idx = -1; int soundindex = args->iparam1; gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EV_DMC_LookupDoorSound( EV_DMC_MOVE_SOUND, soundindex )); gEngfuncs.pEventAPI->EV_PlaySound( idx, args->origin, CHAN_STATIC, EV_DMC_LookupDoorSound( EV_DMC_MOVE_SOUND, soundindex ), 1.0, ATTN_NORM, 0, PITCH_NORM ); +*/ } void EV_DMC_DoorHitTop( event_args_t *args ) @@ -1320,17 +1386,18 @@ void EV_DMC_DoorHitTop( event_args_t *args ) int idx = -1; int soundindex = args->iparam1; - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EV_DMC_LookupDoorSound( EV_DMC_MOVE_SOUND, soundindex )); + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EV_DMC_LookupDoorSound( EV_DMC_MOVE_SOUND, soundindex ) ); gEngfuncs.pEventAPI->EV_PlaySound( idx, args->origin, CHAN_STATIC, EV_DMC_LookupDoorSound( EV_DMC_STOP_SOUND, soundindex ), 1.0, ATTN_NORM, 0, PITCH_NORM ); } void EV_DMC_DoorHitBottom( event_args_t *args ) { + EV_DMC_DoorHitTop( args ); +/* int idx = -1; int soundindex = args->iparam1; - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EV_DMC_LookupDoorSound( EV_DMC_MOVE_SOUND, soundindex )); + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EV_DMC_LookupDoorSound( EV_DMC_MOVE_SOUND, soundindex ) ); gEngfuncs.pEventAPI->EV_PlaySound( idx, args->origin, CHAN_STATIC, EV_DMC_LookupDoorSound( EV_DMC_STOP_SOUND, soundindex ), 1.0, ATTN_NORM, 0, PITCH_NORM ); +*/ } - - diff --git a/cl_dll/quake/quake_baseentity.cpp b/cl_dll/quake/quake_baseentity.cpp index 1067449b..3038977d 100644 --- a/cl_dll/quake/quake_baseentity.cpp +++ b/cl_dll/quake/quake_baseentity.cpp @@ -317,8 +317,8 @@ void CBasePlayerItem::AttachToPlayer ( CBasePlayer *pPlayer ) { } int CBasePlayerWeapon::AddDuplicate( CBasePlayerItem *pOriginal ) { return 0; } int CBasePlayerWeapon::AddToPlayer( CBasePlayer *pPlayer ) { return FALSE; } int CBasePlayerWeapon::UpdateClientData( CBasePlayer *pPlayer ) { return 0; } -BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; } -BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, char *szName, int iMax ) { return TRUE; } +BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, const char *szName, int iMaxClip, int iMaxCarry ) { return TRUE; } +BOOL CBasePlayerWeapon :: AddSecondaryAmmo( int iCount, const char *szName, int iMax ) { return TRUE; } BOOL CBasePlayerWeapon :: IsUseable( void ) { return TRUE; } int CBasePlayerWeapon::PrimaryAmmoIndex( void ) { return -1; } int CBasePlayerWeapon::SecondaryAmmoIndex( void ) { return -1; } diff --git a/cl_dll/quake/quake_weapons.cpp b/cl_dll/quake/quake_weapons.cpp index d3a227a1..d898dc52 100644 --- a/cl_dll/quake/quake_weapons.cpp +++ b/cl_dll/quake/quake_weapons.cpp @@ -83,21 +83,21 @@ we set up the m_pPlayer field. */ void HUD_PrepEntity( CBaseEntity *pEntity, CBasePlayer *pWeaponOwner ) { - memset( &ev[ num_ents ], 0, sizeof( entvars_t ) ); - pEntity->pev = &ev[ num_ents++ ]; + memset( &ev[num_ents], 0, sizeof(entvars_t) ); + pEntity->pev = &ev[num_ents++]; pEntity->Precache(); pEntity->Spawn(); - if ( pWeaponOwner ) + if( pWeaponOwner ) { ItemInfo info; + CBasePlayerWeapon *pWeapon = (CBasePlayerWeapon *)pEntity; + pWeapon->m_pPlayer = pWeaponOwner; - ((CBasePlayerWeapon *)pEntity)->m_pPlayer = pWeaponOwner; - - ((CBasePlayerWeapon *)pEntity)->GetItemInfo( &info ); + pWeapon->GetItemInfo( &info ); - g_pWpns[ info.iId ] = (CBasePlayerWeapon *)pEntity; + g_pWpns[info.iId] = pWeapon; } } @@ -121,7 +121,7 @@ CQuakeNail *CQuakeNail::CreateNail( Vector vecOrigin, Vector vecAngles, CBaseEnt return NULL; } -void CBasePlayer :: Precache( void ) +void CBasePlayer::Precache( void ) { m_usShotgunSingle = PRECACHE_EVENT( 1, "events/shotgun1.sc" ); m_usShotgunDouble = PRECACHE_EVENT( 1, "events/shotgun2.sc" ); @@ -141,7 +141,7 @@ CBaseEntity :: Killed If weapons code "kills" an entity, just set its effects to EF_NODRAW ===================== */ -void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) +void CBaseEntity::Killed( entvars_t *pevAttacker, int iGib ) { pev->effects |= EF_NODRAW; } @@ -151,7 +151,7 @@ void CBaseEntity :: Killed( entvars_t *pevAttacker, int iGib ) CBasePlayerWeapon :: DefaultReload ===================== */ -BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay ) +BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + fDelay; @@ -444,7 +444,7 @@ void CBasePlayer::Spawn( void ) BOOL CQuakeGun::Deploy( ) { gEngfuncs.CL_LoadModel( "models/v_axe.mdl", &m_pPlayer->pev->viewmodel ); - strcpy( m_pPlayer->m_szAnimExtention, "onehanded" ); + m_pPlayer->m_pszAnimExtention = "onehanded"; return TRUE; } diff --git a/common/r_efx.h b/common/r_efx.h index 1a55aa0b..aad61150 100644 --- a/common/r_efx.h +++ b/common/r_efx.h @@ -168,7 +168,7 @@ struct efx_api_s TEMPENTITY *(*R_DefaultSprite)( float *pos, int spriteIndex, float framerate ); TEMPENTITY *(*R_TempSprite)( float *pos, float *dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags ); int (*Draw_DecalIndex)( int id ); - int (*Draw_DecalIndexFromName)( char *name ); + int (*Draw_DecalIndexFromName)( const char *name ); void (*R_DecalShoot)( int textureIndex, int entity, int modelIndex, float *position, int flags ); void (*R_AttachTentToPlayer)( int client, int modelIndex, float zoffset, float life ); void (*R_KillAttachedTents)( int client ); diff --git a/dlls/aghl/agglobal.cpp b/dlls/aghl/agglobal.cpp index 758a57fb..a57ebad3 100644 --- a/dlls/aghl/agglobal.cpp +++ b/dlls/aghl/agglobal.cpp @@ -142,18 +142,6 @@ void AgResetMap() while ((pEntity = UTIL_FindEntityByClassname( pEntity, "weaponbox" )) != NULL) UTIL_Remove(pEntity); - pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname( pEntity, "monster_satchel" )) != NULL) - UTIL_Remove(pEntity); - - pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname( pEntity, "monster_tripmine" )) != NULL) - UTIL_Remove(pEntity); - - pEntity = NULL; - while ((pEntity = UTIL_FindEntityByClassname( pEntity, "monster_snark" )) != NULL) - UTIL_Remove(pEntity); - pEntity = NULL; while ((pEntity = UTIL_FindEntityByClassname( pEntity, "beam" )) != NULL) UTIL_Remove(pEntity); diff --git a/dlls/dmc/quake_gun.cpp b/dlls/dmc/quake_gun.cpp index ff550ff8..a03ccd36 100644 --- a/dlls/dmc/quake_gun.cpp +++ b/dlls/dmc/quake_gun.cpp @@ -132,7 +132,7 @@ BOOL CQuakeGun::Deploy( ) { m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_crowbar.mdl"); m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_9mmhandgun.mdl"); - strcpy( m_pPlayer->m_szAnimExtention, "onehanded" ); + m_pPlayer->m_pszAnimExtention = "onehanded"; #ifdef CLIENT_DLL g_flLightTime = 0.0; diff --git a/dlls/dmc/quake_items.cpp b/dlls/dmc/quake_items.cpp index cce00fe0..e05a0eea 100644 --- a/dlls/dmc/quake_items.cpp +++ b/dlls/dmc/quake_items.cpp @@ -832,9 +832,9 @@ void CItemAmmo::Spawn( void ) void CItemAmmo::Precache( void ) { if (pev->spawnflags & BIG_AMMOBOX) - PRECACHE_MODEL( (char*)STRING(m_isLargeBox) ); + PRECACHE_MODEL( STRING(m_isLargeBox) ); else - PRECACHE_MODEL( (char*)STRING(m_isSmallBox) ); + PRECACHE_MODEL( STRING(m_isSmallBox) ); } BOOL CItemAmmo::MyTouch( CBasePlayer *pPlayer ) diff --git a/dlls/dmc/quake_weapons_all.cpp b/dlls/dmc/quake_weapons_all.cpp index d6d203e9..feb7116c 100644 --- a/dlls/dmc/quake_weapons_all.cpp +++ b/dlls/dmc/quake_weapons_all.cpp @@ -218,7 +218,7 @@ void CBasePlayer::W_SetCurrentAmmo( int sendanim /* = 1 */ ) pev->viewmodel = iszViewModel; pev->weaponmodel = iszWeaponModel; - strcpy( m_szAnimExtention, szAnimExt ); + m_pszAnimExtention = szAnimExt; #else { diff --git a/dlls/doors.cpp b/dlls/doors.cpp index e57cadf3..76549516 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -823,7 +823,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) if( m_fNextSoundPlay <= gpGlobals->time ) { m_fNextSoundPlay = gpGlobals->time + 0.3; - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); } // Block all door pieces with the same targetname here. diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 7e6ea6a5..55564e85 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -87,7 +87,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() #endif int length; - char *pFileList = (char*)LOAD_FILE_FOR_ME( "motd.txt", &length ); + const char *pFileList = (const char*)LOAD_FILE_FOR_ME( "motd.txt", &length ); if( pFileList ) g_bHaveMOTD = true; diff --git a/dlls/player.cpp b/dlls/player.cpp index 5c654d4a..3d4d667d 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -725,7 +725,7 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) strcpy( szAnim, "crouch_shoot_" ); else strcpy( szAnim, "ref_shoot_" ); - strcat( szAnim, m_szAnimExtention ); + strcat( szAnim, m_pszAnimExtention ); animDesired = LookupSequence( szAnim ); if( animDesired == -1 ) animDesired = 0; @@ -752,7 +752,7 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) strcpy( szAnim, "crouch_aim_" ); else strcpy( szAnim, "ref_aim_" ); - strcat( szAnim, m_szAnimExtention ); + strcat( szAnim, m_pszAnimExtention ); animDesired = LookupSequence( szAnim ); if( animDesired == -1 ) animDesired = 0; diff --git a/dlls/player.h b/dlls/player.h index 91cebf41..780779cc 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -251,7 +251,7 @@ public: int Classify ( void ); void SetAnimation( PLAYER_ANIM playerAnim ); void SetWeaponAnimType( const char *szExtention ); - char m_szAnimExtention[32]; + const char *m_pszAnimExtention; // custom player functions virtual void ImpulseCommands( void ); diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 254fd75e..136444b1 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -794,7 +794,7 @@ void CBasePlayerWeapon::SendWeaponAnim( int iAnim, int skiplocal ) MESSAGE_END(); } -BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ) +BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, const char *szName, int iMaxClip, int iMaxCarry ) { int iIdAmmo; @@ -831,7 +831,7 @@ BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, return iIdAmmo > 0 ? TRUE : FALSE; } -BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, char *szName, int iMax ) +BOOL CBasePlayerWeapon::AddSecondaryAmmo( int iCount, const char *szName, int iMax ) { int iIdAmmo; @@ -906,7 +906,7 @@ BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWe m_pPlayer->pev->viewmodel = MAKE_STRING( szViewModel ); m_pPlayer->pev->weaponmodel = MAKE_STRING( szWeaponModel ); - strcpy( m_pPlayer->m_szAnimExtention, szAnimExt ); + m_pPlayer->m_pszAnimExtention = szAnimExt; SendWeaponAnim( iAnim, skiplocal ); m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; @@ -1056,13 +1056,13 @@ int CBasePlayerWeapon::ExtractAmmo( CBasePlayerWeapon *pWeapon ) { // 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. - iReturn = pWeapon->AddPrimaryAmmo( m_iDefaultAmmo, (char *)pszAmmo1(), iMaxClip(), iMaxAmmo1() ); + iReturn = pWeapon->AddPrimaryAmmo( m_iDefaultAmmo, pszAmmo1(), iMaxClip(), iMaxAmmo1() ); m_iDefaultAmmo = 0; } if( pszAmmo2() != NULL ) { - iReturn = pWeapon->AddSecondaryAmmo( 0, (char *)pszAmmo2(), iMaxAmmo2() ); + iReturn = pWeapon->AddSecondaryAmmo( 0, pszAmmo2(), iMaxAmmo2() ); } return iReturn; @@ -1084,7 +1084,7 @@ int CBasePlayerWeapon::ExtractClipAmmo( CBasePlayerWeapon *pWeapon ) iAmmo = m_iClip; } - return pWeapon->m_pPlayer->GiveAmmo( iAmmo, (char *)pszAmmo1(), iMaxAmmo1() ); // , &m_iPrimaryAmmoType + return pWeapon->m_pPlayer->GiveAmmo( iAmmo, pszAmmo1(), iMaxAmmo1() ); // , &m_iPrimaryAmmoType } //========================================================= diff --git a/dlls/weapons.h b/dlls/weapons.h index a18ac530..1a88bacc 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -294,8 +294,8 @@ public: virtual int AddWeapon( void ) { ExtractAmmo( this ); return TRUE; }; // Return TRUE if you want to add yourself to the player // generic "shared" ammo handlers - BOOL AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, int iMaxCarry ); - BOOL AddSecondaryAmmo( int iCount, char *szName, int iMaxCarry ); + BOOL AddPrimaryAmmo( int iCount, const char *szName, int iMaxClip, int iMaxCarry ); + BOOL AddSecondaryAmmo( int iCount, const char *szName, int iMaxCarry ); virtual void UpdateItemInfo( void ) {}; // updates HUD state