about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authoroy <Tom_Adams@web.de>2012-10-06 13:47:37 +0200
committeroy <Tom_Adams@web.de>2013-02-24 18:02:57 +0100
commit7eddbe0dc9297e795ffdac65914f70ffcd43325a (patch)
tree94394eca372ad9fa0a7a6343f9a5c12b6edecb67 /src
parent2948d2392b509c5cc743d517687a8d941e4ef9d0 (diff)
downloadzcatch-7eddbe0dc9297e795ffdac65914f70ffcd43325a.tar.gz
zcatch-7eddbe0dc9297e795ffdac65914f70ffcd43325a.zip
play only one weapon no ammo sound per second. #993
Diffstat (limited to 'src')
-rw-r--r--src/game/server/entities/character.cpp7
-rw-r--r--src/game/server/entities/character.h1
2 files changed, 7 insertions, 1 deletions
diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp
index 1c76f655..6794429d 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 aa127979..d799d8a7 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;