From 7e610f994428e5afeb77013ddbd725a4a8b3896b Mon Sep 17 00:00:00 2001 From: Fireball Date: Sat, 18 Jul 2020 18:39:24 +0100 Subject: [PATCH] Fix sixup players not making sounds when hooking others This also fixes some less noticeable edgecases with ground jump sound: for example, when spectating a tee who is in a solo part. --- src/game/server/entities/character.cpp | 29 ++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/game/server/entities/character.cpp b/src/game/server/entities/character.cpp index 201fff405..cd2d87d5a 100644 --- a/src/game/server/entities/character.cpp +++ b/src/game/server/entities/character.cpp @@ -847,14 +847,31 @@ void CCharacter::TickDefered() GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf); } - int Events = m_Core.m_TriggeredEvents; - //int Mask = CmaskAllExceptOne(m_pPlayer->GetCID()); + { + int Events = m_Core.m_TriggeredEvents; + int CID = m_pPlayer->GetCID(); - if(Events&COREEVENT_GROUND_JUMP) GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, Teams()->TeamMask(Team(), m_pPlayer->GetCID())); + int64 TeamMask = Teams()->TeamMask(Team(), -1, CID); + // Some sounds are triggered client-side for the acting player + // so we need to avoid duplicating them + int64 TeamMaskExceptSelf = Teams()->TeamMask(Team(), CID, CID); + // Some are triggered client-side but only on Sixup + int64 TeamMaskExceptSelfIfSixup = Server()->IsSixup(CID) + ? TeamMaskExceptSelf + : TeamMask; - if(Events&COREEVENT_HOOK_ATTACH_PLAYER && !Server()->IsSixup(m_pPlayer->GetCID())) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, Teams()->TeamMask(Team(), -1, m_pPlayer->GetCID())); - if(Events&COREEVENT_HOOK_ATTACH_GROUND) GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, Teams()->TeamMask(Team(), m_pPlayer->GetCID(), m_pPlayer->GetCID())); - if(Events&COREEVENT_HOOK_HIT_NOHOOK) GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, Teams()->TeamMask(Team(), m_pPlayer->GetCID(), m_pPlayer->GetCID())); + if(Events&COREEVENT_GROUND_JUMP) + GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, TeamMaskExceptSelf); + + if(Events&COREEVENT_HOOK_ATTACH_PLAYER) + GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, TeamMaskExceptSelfIfSixup); + + if(Events&COREEVENT_HOOK_ATTACH_GROUND) + GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, TeamMaskExceptSelf); + + if(Events&COREEVENT_HOOK_HIT_NOHOOK) + GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, TeamMaskExceptSelf); + } if(m_pPlayer->GetTeam() == TEAM_SPECTATORS)