From 7eddbe0dc9297e795ffdac65914f70ffcd43325a Mon Sep 17 00:00:00 2001 From: oy Date: Sat, 6 Oct 2012 13:47:37 +0200 Subject: [PATCH] play only one weapon no ammo sound per second. #993 --- src/game/server/entities/character.cpp | 7 ++++++- src/game/server/entities/character.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 1c76f6556..6794429da 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -56,6 +56,7 @@ bool CCharacter::Spawn(CPlayer *pPlayer, vec2 Pos) { m_EmoteStop = -1; m_LastAction = -1; + m_LastNoAmmoSound = -1; m_ActiveWeapon = WEAPON_GUN; m_LastWeapon = WEAPON_HAMMER; m_QueuedWeapon = -1; @@ -270,7 +271,11 @@ void CCharacter::FireWeapon() { // 125ms is a magical limit of how fast a human can click m_ReloadTimer = 125 * Server()->TickSpeed() / 1000; - GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO); + if(m_LastNoAmmoSound+Server()->TickSpeed() <= Server()->Tick()) + { + GameServer()->CreateSound(m_Pos, SOUND_WEAPON_NOAMMO); + m_LastNoAmmoSound = Server()->Tick(); + } return; } diff --git a/src/game/server/entities/character.h b/src/game/server/entities/character.h index aa127979b..d799d8a7d 100644 --- a/src/game/server/entities/character.h +++ b/src/game/server/entities/character.h @@ -97,6 +97,7 @@ private: // last tick that the player took any action ie some input int m_LastAction; + int m_LastNoAmmoSound; // these are non-heldback inputs CNetObj_PlayerInput m_LatestPrevInput;