Skip to content

Commit

Permalink
Merge pull request #162 from voxelizedworld/develop
Browse files Browse the repository at this point in the history
Weapon sounds now work on dedicated servers
  • Loading branch information
TomyLobo authored Feb 15, 2021
2 parents 55dbd80 + b15cbac commit 89d9e6e
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
4 changes: 3 additions & 1 deletion mp/src/game/client/sdk/c_te_firebullets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ void C_TEFireBullets::PostDataUpdate( DataUpdateType_t updateType )
m_iWeaponID,
m_iMode,
m_iSeed,
m_flSpread );
m_flSpread,
false
);
}


Expand Down
24 changes: 19 additions & 5 deletions mp/src/game/shared/sdk/sdk_fx_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,21 @@
void FX_WeaponSound ( int iPlayerIndex,
WeaponSound_t sound_type,
const Vector &vOrigin,
CSDKWeaponInfo *pWeaponInfo ) {};
CSDKWeaponInfo *pWeaponInfo )
{
// make sure we got something
if (iPlayerIndex == -1)
return;

// If we have some sounds from the weapon classname.txt file, play a random one of them
const char *shootsound = pWeaponInfo->aShootSounds[sound_type];
if (!shootsound || !shootsound[0])
return;

CBroadcastRecipientFilter filter;
filter.RemoveRecipient(UTIL_PlayerByIndex(iPlayerIndex));
CBaseEntity::EmitSound(filter, iPlayerIndex, shootsound, &vOrigin);
}

#endif

Expand All @@ -116,7 +130,8 @@ void FX_FireBullets(
int iWeaponID,
int iMode,
int iSeed,
float flSpread
float flSpread,
bool bShouldPlaySound
)
{
Assert(vOrigin.IsValid());
Expand Down Expand Up @@ -157,8 +172,6 @@ void FX_FireBullets(
iSeed,
flSpread
);

bDoEffects = false; // no effects on server
#endif

iSeed++;
Expand All @@ -176,7 +189,8 @@ void FX_FireBullets(
//ProjectedLightEffectManager( iPlayerIndex ).TriggerMuzzleFlash();
#endif

FX_WeaponSound( iPlayerIndex, sound_type, vOrigin, pWeaponInfo );
if (bShouldPlaySound)
FX_WeaponSound(iPlayerIndex, sound_type, vOrigin, pWeaponInfo);
}


Expand Down
3 changes: 2 additions & 1 deletion mp/src/game/shared/sdk/sdk_fx_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ void FX_FireBullets(
int iWeaponID,
int iMode,
int iSeed,
float flSpread
float flSpread,
bool bShouldPlaySound
);


Expand Down
3 changes: 2 additions & 1 deletion mp/src/game/shared/sdk/weapon_sdkbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ void CWeaponSDKBase::FinishAttack (CSDKPlayer *pPlayer)
GetWeaponID(),
0, //Tony; fire mode - this is unused at the moment, left over from CSS when SDK* was created in the first place.
CBaseEntity::GetPredictionRandomSeed() & 255,
flSpread
flSpread,
true
);

//Add our view kick in
Expand Down

0 comments on commit 89d9e6e

Please sign in to comment.