Merge pull request #8782 from ChillerDragon/pr_fix_sixup_sounds

Fix sixup sounds
This commit is contained in:
Dennis Felsing 2024-08-21 15:07:33 +00:00 committed by GitHub
commit db9b5f5b61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 38 additions and 36 deletions

View file

@ -851,24 +851,23 @@ void CCharacter::TickDeferred()
int Events = m_Core.m_TriggeredEvents;
int CID = m_pPlayer->GetCid();
CClientMask TeamMask = Teams()->TeamMask(Team(), -1, CID);
// Some sounds are triggered client-side for the acting player
// Some sounds are triggered client-side for the acting player (or for all players on Sixup)
// so we need to avoid duplicating them
CClientMask TeamMaskExceptSelf = Teams()->TeamMask(Team(), CID, CID);
CClientMask TeamMaskExceptSelfAndSixup = Teams()->TeamMask(Team(), -1, CID, CGameContext::FLAG_SIX);
// Some are triggered client-side but only on Sixup
CClientMask TeamMaskExceptSelfIfSixup = Server()->IsSixup(CID) ? TeamMaskExceptSelf : TeamMask;
CClientMask TeamMaskExceptSixup = Teams()->TeamMask(Team(), -1, CID, CGameContext::FLAG_SIX);
if(Events & COREEVENT_GROUND_JUMP)
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, TeamMaskExceptSelf);
GameServer()->CreateSound(m_Pos, SOUND_PLAYER_JUMP, TeamMaskExceptSelfAndSixup);
if(Events & COREEVENT_HOOK_ATTACH_PLAYER)
GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, TeamMaskExceptSelfIfSixup);
GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_PLAYER, TeamMaskExceptSixup);
if(Events & COREEVENT_HOOK_ATTACH_GROUND)
GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, TeamMaskExceptSelf);
GameServer()->CreateSound(m_Pos, SOUND_HOOK_ATTACH_GROUND, TeamMaskExceptSelfAndSixup);
if(Events & COREEVENT_HOOK_HIT_NOHOOK)
GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, TeamMaskExceptSelf);
GameServer()->CreateSound(m_Pos, SOUND_HOOK_NOATTACH, TeamMaskExceptSelfAndSixup);
if(Events & COREEVENT_GROUND_JUMP)
m_TriggeredEvents7 |= protocol7::COREEVENTFLAG_GROUND_JUMP;

View file

@ -546,7 +546,7 @@ void CGameContext::CallVote(int ClientId, const char *pDesc, const char *pCmd, c
if(!pPlayer)
return;
SendChat(-1, TEAM_ALL, pChatmsg, -1, CHAT_SIX);
SendChat(-1, TEAM_ALL, pChatmsg, -1, FLAG_SIX);
if(!pSixupDesc)
pSixupDesc = pDesc;
@ -557,7 +557,7 @@ void CGameContext::CallVote(int ClientId, const char *pDesc, const char *pCmd, c
pPlayer->m_LastVoteCall = Now;
}
void CGameContext::SendChatTarget(int To, const char *pText, int Flags) const
void CGameContext::SendChatTarget(int To, const char *pText, int VersionFlags) const
{
CNetMsg_Sv_Chat Msg;
Msg.m_Team = 0;
@ -571,8 +571,8 @@ void CGameContext::SendChatTarget(int To, const char *pText, int Flags) const
{
for(int i = 0; i < Server()->MaxClients(); i++)
{
if(!((Server()->IsSixup(i) && (Flags & CHAT_SIXUP)) ||
(!Server()->IsSixup(i) && (Flags & CHAT_SIX))))
if(!((Server()->IsSixup(i) && (VersionFlags & FLAG_SIXUP)) ||
(!Server()->IsSixup(i) && (VersionFlags & FLAG_SIX))))
continue;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, i);
@ -580,8 +580,8 @@ void CGameContext::SendChatTarget(int To, const char *pText, int Flags) const
}
else
{
if(!((Server()->IsSixup(To) && (Flags & CHAT_SIXUP)) ||
(!Server()->IsSixup(To) && (Flags & CHAT_SIX))))
if(!((Server()->IsSixup(To) && (VersionFlags & FLAG_SIXUP)) ||
(!Server()->IsSixup(To) && (VersionFlags & FLAG_SIX))))
return;
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, To);
@ -595,7 +595,7 @@ void CGameContext::SendChatTeam(int Team, const char *pText) const
SendChatTarget(i, pText);
}
void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText, int SpamProtectionClientId, int Flags)
void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText, int SpamProtectionClientId, int VersionFlags)
{
if(SpamProtectionClientId >= 0 && SpamProtectionClientId < MAX_CLIENTS)
if(ProcessSpamProtection(SpamProtectionClientId))
@ -631,8 +631,8 @@ void CGameContext::SendChat(int ChatterClientId, int Team, const char *pText, in
{
if(!m_apPlayers[i])
continue;
bool Send = (Server()->IsSixup(i) && (Flags & CHAT_SIXUP)) ||
(!Server()->IsSixup(i) && (Flags & CHAT_SIX));
bool Send = (Server()->IsSixup(i) && (VersionFlags & FLAG_SIXUP)) ||
(!Server()->IsSixup(i) && (VersionFlags & FLAG_SIX));
if(!m_apPlayers[i]->m_DND && Send)
Server()->SendPackMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_NORECORD, i);
@ -1181,7 +1181,7 @@ void CGameContext::OnTick()
Console()->ExecuteLine(m_aVoteCommand);
Server()->SetRconCid(IServer::RCON_CID_SERV);
EndVote();
SendChat(-1, TEAM_ALL, "Vote passed", -1, CHAT_SIX);
SendChat(-1, TEAM_ALL, "Vote passed", -1, FLAG_SIX);
if(m_apPlayers[m_VoteCreator] && !IsKickVote() && !IsSpecVote())
m_apPlayers[m_VoteCreator]->m_LastVoteCall = 0;
@ -1189,22 +1189,22 @@ void CGameContext::OnTick()
else if(m_VoteEnforce == VOTE_ENFORCE_YES_ADMIN)
{
Console()->ExecuteLine(m_aVoteCommand, m_VoteEnforcer);
SendChat(-1, TEAM_ALL, "Vote passed enforced by authorized player", -1, CHAT_SIX);
SendChat(-1, TEAM_ALL, "Vote passed enforced by authorized player", -1, FLAG_SIX);
EndVote();
}
else if(m_VoteEnforce == VOTE_ENFORCE_NO_ADMIN)
{
EndVote();
SendChat(-1, TEAM_ALL, "Vote failed enforced by authorized player", -1, CHAT_SIX);
SendChat(-1, TEAM_ALL, "Vote failed enforced by authorized player", -1, FLAG_SIX);
}
//else if(m_VoteEnforce == VOTE_ENFORCE_NO || time_get() > m_VoteCloseTime)
else if(m_VoteEnforce == VOTE_ENFORCE_NO || (time_get() > m_VoteCloseTime && g_Config.m_SvVoteMajority))
{
EndVote();
if(VetoStop || (m_VoteWillPass && Veto))
SendChat(-1, TEAM_ALL, "Vote failed because of veto. Find an empty server instead", -1, CHAT_SIX);
SendChat(-1, TEAM_ALL, "Vote failed because of veto. Find an empty server instead", -1, FLAG_SIX);
else
SendChat(-1, TEAM_ALL, "Vote failed", -1, CHAT_SIX);
SendChat(-1, TEAM_ALL, "Vote failed", -1, FLAG_SIX);
}
else if(m_VoteUpdate)
{
@ -3345,7 +3345,7 @@ void CGameContext::ConForceVote(IConsole::IResult *pResult, void *pUserData)
if(str_comp_nocase(pValue, pOption->m_aDescription) == 0)
{
str_format(aBuf, sizeof(aBuf), "authorized player forced server option '%s' (%s)", pValue, pReason);
pSelf->SendChatTarget(-1, aBuf, CHAT_SIX);
pSelf->SendChatTarget(-1, aBuf, FLAG_SIX);
pSelf->Console()->ExecuteLine(pOption->m_aCommand);
break;
}

View file

@ -250,15 +250,15 @@ public:
enum
{
CHAT_SIX = 1 << 0,
CHAT_SIXUP = 1 << 1,
FLAG_SIX = 1 << 0,
FLAG_SIXUP = 1 << 1,
};
// network
void CallVote(int ClientId, const char *pDesc, const char *pCmd, const char *pReason, const char *pChatmsg, const char *pSixupDesc = 0);
void SendChatTarget(int To, const char *pText, int Flags = CHAT_SIX | CHAT_SIXUP) const;
void SendChatTarget(int To, const char *pText, int VersionFlags = FLAG_SIX | FLAG_SIXUP) const;
void SendChatTeam(int Team, const char *pText) const;
void SendChat(int ClientId, int Team, const char *pText, int SpamProtectionClientId = -1, int Flags = CHAT_SIX | CHAT_SIXUP);
void SendChat(int ClientId, int Team, const char *pText, int SpamProtectionClientId = -1, int VersionFlags = FLAG_SIX | FLAG_SIXUP);
void SendStartWarning(int ClientId, const char *pMessage);
void SendEmoticon(int ClientId, int Emoticon, int TargetClientId) const;
void SendWeaponPickup(int ClientId, int Weapon) const;

View file

@ -410,7 +410,7 @@ void IGameController::OnPlayerDisconnect(class CPlayer *pPlayer, const char *pRe
str_format(aBuf, sizeof(aBuf), "'%s' has left the game (%s)", Server()->ClientName(ClientId), pReason);
else
str_format(aBuf, sizeof(aBuf), "'%s' has left the game", Server()->ClientName(ClientId));
GameServer()->SendChat(-1, TEAM_ALL, aBuf, -1, CGameContext::CHAT_SIX);
GameServer()->SendChat(-1, TEAM_ALL, aBuf, -1, CGameContext::FLAG_SIX);
str_format(aBuf, sizeof(aBuf), "leave player='%d:%s'", ClientId, Server()->ClientName(ClientId));
GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "game", aBuf);

View file

@ -127,7 +127,7 @@ void CGameControllerDDRace::OnPlayerConnect(CPlayer *pPlayer)
{
char aBuf[512];
str_format(aBuf, sizeof(aBuf), "'%s' entered and joined the %s", Server()->ClientName(ClientId), GetTeamName(pPlayer->GetTeam()));
GameServer()->SendChat(-1, TEAM_ALL, aBuf, -1, CGameContext::CHAT_SIX);
GameServer()->SendChat(-1, TEAM_ALL, aBuf, -1, CGameContext::FLAG_SIX);
GameServer()->SendChatTarget(ClientId, "DDraceNetwork Mod. Version: " GAME_VERSION);
GameServer()->SendChatTarget(ClientId, "please visit DDNet.org or say /info and make sure to read our /rules");

View file

@ -507,7 +507,7 @@ bool CGameTeams::TeamFinished(int Team)
return true;
}
CClientMask CGameTeams::TeamMask(int Team, int ExceptId, int Asker)
CClientMask CGameTeams::TeamMask(int Team, int ExceptId, int Asker, int VersionFlags)
{
if(Team == TEAM_SUPER)
{
@ -523,6 +523,9 @@ CClientMask CGameTeams::TeamMask(int Team, int ExceptId, int Asker)
continue; // Explicitly excluded
if(!GetPlayer(i))
continue; // Player doesn't exist
if(!((Server()->IsSixup(i) && (VersionFlags & CGameContext::FLAG_SIXUP)) ||
(!Server()->IsSixup(i) && (VersionFlags & CGameContext::FLAG_SIX))))
continue;
if(!(GetPlayer(i)->GetTeam() == TEAM_SPECTATORS || GetPlayer(i)->IsPaused()))
{ // Not spectator
@ -711,9 +714,9 @@ void CGameTeams::OnFinish(CPlayer *Player, int TimeTicks, const char *pTimestamp
Server()->ClientName(ClientId), (int)Time / 60,
Time - ((int)Time / 60 * 60));
if(g_Config.m_SvHideScore || !g_Config.m_SvSaveWorseScores)
GameServer()->SendChatTarget(ClientId, aBuf, CGameContext::CHAT_SIX);
GameServer()->SendChatTarget(ClientId, aBuf, CGameContext::FLAG_SIX);
else
GameServer()->SendChat(-1, TEAM_ALL, aBuf, -1., CGameContext::CHAT_SIX);
GameServer()->SendChat(-1, TEAM_ALL, aBuf, -1., CGameContext::FLAG_SIX);
float Diff = absolute(Time - pData->m_BestTime);
@ -730,9 +733,9 @@ void CGameTeams::OnFinish(CPlayer *Player, int TimeTicks, const char *pTimestamp
str_format(aBuf, sizeof(aBuf), "New record: %5.2f second(s) better.",
Diff);
if(g_Config.m_SvHideScore || !g_Config.m_SvSaveWorseScores)
GameServer()->SendChatTarget(ClientId, aBuf, CGameContext::CHAT_SIX);
GameServer()->SendChatTarget(ClientId, aBuf, CGameContext::FLAG_SIX);
else
GameServer()->SendChat(-1, TEAM_ALL, aBuf, -1, CGameContext::CHAT_SIX);
GameServer()->SendChat(-1, TEAM_ALL, aBuf, -1, CGameContext::FLAG_SIX);
}
else if(pData->m_BestTime != 0) // tee has already finished?
{
@ -752,7 +755,7 @@ void CGameTeams::OnFinish(CPlayer *Player, int TimeTicks, const char *pTimestamp
str_format(aBuf, sizeof(aBuf),
"%5.2f second(s) worse, better luck next time.",
Diff);
GameServer()->SendChatTarget(ClientId, aBuf, CGameContext::CHAT_SIX); // this is private, sent only to the tee
GameServer()->SendChatTarget(ClientId, aBuf, CGameContext::FLAG_SIX); // this is private, sent only to the tee
}
}
else

View file

@ -97,7 +97,7 @@ public:
void ChangeTeamState(int Team, int State);
CClientMask TeamMask(int Team, int ExceptId = -1, int Asker = -1);
CClientMask TeamMask(int Team, int ExceptId = -1, int Asker = -1, int VersionFlags = CGameContext::FLAG_SIX | CGameContext::FLAG_SIXUP);
int Count(int Team) const;