mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Clamp Spectator ID
This commit is contained in:
parent
7944c9ca75
commit
fabd559746
|
@ -4,6 +4,7 @@
|
|||
#define ENGINE_SERVER_H
|
||||
|
||||
#include <base/hash.h>
|
||||
#include <base/math.h>
|
||||
|
||||
#include "kernel.h"
|
||||
#include "message.h"
|
||||
|
@ -131,6 +132,7 @@ public:
|
|||
GetClientInfo(Client, &Info);
|
||||
if (Info.m_ClientVersion >= VERSION_DDNET_OLD)
|
||||
return true;
|
||||
Target = clamp(Target, 0, VANILLA_MAX_CLIENTS-1);
|
||||
int *pMap = GetIdMap(Client);
|
||||
if (pMap[Target] == -1)
|
||||
return false;
|
||||
|
|
|
@ -1794,7 +1794,9 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
{
|
||||
CNetMsg_Cl_SetSpectatorMode *pMsg = (CNetMsg_Cl_SetSpectatorMode *)pRawMsg;
|
||||
|
||||
if(pMsg->m_SpectatorID != SPEC_FREEVIEW)
|
||||
pMsg->m_SpectatorID = clamp(pMsg->m_SpectatorID, (int)SPEC_FOLLOW, MAX_CLIENTS-1);
|
||||
|
||||
if(pMsg->m_SpectatorID >= 0)
|
||||
if (!Server()->ReverseTranslate(pMsg->m_SpectatorID, ClientID))
|
||||
return;
|
||||
|
||||
|
@ -1802,7 +1804,7 @@ void CGameContext::OnMessage(int MsgID, CUnpacker *pUnpacker, int ClientID)
|
|||
return;
|
||||
|
||||
pPlayer->m_LastSetSpectatorMode = Server()->Tick();
|
||||
if(pMsg->m_SpectatorID != SPEC_FREEVIEW && (!m_apPlayers[pMsg->m_SpectatorID] || m_apPlayers[pMsg->m_SpectatorID]->GetTeam() == TEAM_SPECTATORS))
|
||||
if(pMsg->m_SpectatorID >= 0 && (!m_apPlayers[pMsg->m_SpectatorID] || m_apPlayers[pMsg->m_SpectatorID]->GetTeam() == TEAM_SPECTATORS))
|
||||
SendChatTarget(ClientID, "Invalid spectator id used");
|
||||
else
|
||||
pPlayer->m_SpectatorID = pMsg->m_SpectatorID;
|
||||
|
|
|
@ -509,7 +509,6 @@ CCharacter* CPlayer::ForceSpawn(vec2 Pos)
|
|||
|
||||
void CPlayer::SetTeam(int Team, bool DoChatMsg)
|
||||
{
|
||||
// clamp the team
|
||||
Team = GameServer()->m_pController->ClampTeam(Team);
|
||||
if(m_Team == Team)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue