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