GameContext::OnMessage: Move the check for World.Paused into OnSetTeam

1. Regardless of the pause the message is CL_SETTEAM and there is no
   reason to match it against other messages.
2. Another implementation can save the wanted team and apply it later.
This commit is contained in:
Alexander Akulich 2023-08-15 23:44:37 +03:00
parent ce5371b038
commit 9f668e20db

View file

@ -1936,7 +1936,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
OnCallVoteNetMessage(static_cast<CNetMsg_Cl_CallVote *>(pRawMsg), ClientID);
else if(MsgID == NETMSGTYPE_CL_VOTE)
OnVoteNetMessage(static_cast<CNetMsg_Cl_Vote *>(pRawMsg), ClientID);
else if(MsgID == NETMSGTYPE_CL_SETTEAM && !m_World.m_Paused)
else if(MsgID == NETMSGTYPE_CL_SETTEAM)
OnSetTeamNetMessage(static_cast<CNetMsg_Cl_SetTeam *>(pRawMsg), ClientID);
else if(MsgID == NETMSGTYPE_CL_ISDDNETLEGACY)
{
@ -2656,6 +2656,9 @@ void CGameContext::OnVoteNetMessage(const CNetMsg_Cl_Vote *pMsg, int ClientID)
void CGameContext::OnSetTeamNetMessage(const CNetMsg_Cl_SetTeam *pMsg, int ClientID)
{
if(m_World.m_Paused)
return;
CPlayer *pPlayer = m_apPlayers[ClientID];
if(pPlayer->GetTeam() == pMsg->m_Team || (g_Config.m_SvSpamprotection && pPlayer->m_LastSetTeam && pPlayer->m_LastSetTeam + Server()->TickSpeed() * g_Config.m_SvTeamChangeDelay > Server()->Tick()))