Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weapon sounds now work on dedicated servers #162

Merged
merged 4 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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