2517: Fix sixup players not making sounds when hooking others r=Learath2 a=Fireball-Teeworlds

I've restructured the code to make it easier to read.

There are two differences in it's behavior:
1. Hook sounds coming from sixup players are now only muted for the player themselves (using a mask) instead of being muted for everyone. This fixes at least one cause for #2508.
2. Mask for `COREEVENT_GROUND_JUMP` is now using `Asker` parameter to `TeamMask()`. I believe it was originally an oversight that this mask was different from the others. But the difference is barely noticeable: one case is when spectating a Tee that is in a solo part. Previously such Tee wouldn't be making ground jumping sounds.

7e610f9944/src/game/server/teams.cpp (L405-L418)

I've tested this with DDNet and Vanilla (0.7) clients.

Co-authored-by: Fireball <fireball.teeworlds@gmail.com>
This commit is contained in:
bors[bot] 2020-07-20 13:26:24 +00:00 committed by GitHub
commit 34b761312e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 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)