mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Get /spec working
This commit is contained in:
parent
e81c718180
commit
9dc1a0357a
|
@ -3248,9 +3248,10 @@ void CServer::SnapFreeID(int ID)
|
|||
}
|
||||
|
||||
|
||||
|
||||
void *CServer::SnapNewItem(int Type, int ID, int Size)
|
||||
{
|
||||
if(!(Type >= 0 && Type <= 0xffff))
|
||||
if(Type > 0xffff)
|
||||
{
|
||||
g_UuidManager.GetUuid(Type);
|
||||
}
|
||||
|
|
|
@ -1377,6 +1377,18 @@ void *CGameContext::PreProcessMsg(int *MsgID, CUnpacker *pUnpacker, int ClientID
|
|||
|
||||
return 0;
|
||||
}
|
||||
else if(*MsgID == protocol7::NETMSGTYPE_CL_SETSPECTATORMODE)
|
||||
{
|
||||
protocol7::CNetMsg_Cl_SetSpectatorMode *pMsg7 = (protocol7::CNetMsg_Cl_SetSpectatorMode *)pRawMsg;
|
||||
::CNetMsg_Cl_SetSpectatorMode *pMsg = (::CNetMsg_Cl_SetSpectatorMode *)s_aRawMsg;
|
||||
|
||||
if(pMsg7->m_SpecMode == protocol7::SPEC_FREEVIEW)
|
||||
pMsg->m_SpectatorID = SPEC_FREEVIEW;
|
||||
else if(pMsg7->m_SpecMode == protocol7::SPEC_PLAYER)
|
||||
pMsg->m_SpectatorID = pMsg7->m_SpectatorID;
|
||||
else
|
||||
pMsg->m_SpectatorID = SPEC_FREEVIEW; // Probably not needed
|
||||
}
|
||||
|
||||
*MsgID = Msg_SevenToSix(*MsgID);
|
||||
|
||||
|
@ -3503,7 +3515,7 @@ void CGameContext::WhisperID(int ClientID, int VictimID, const char *pMessage)
|
|||
Msg.m_pMessage = pMessage;
|
||||
Msg.m_TargetID = VictimID;
|
||||
|
||||
Server()->SendPackMsgOne(&Msg, MSGFLAG_VITAL, ClientID);
|
||||
Server()->SendPackMsgOne(&Msg, MSGFLAG_VITAL|MSGFLAG_NORECORD, ClientID);
|
||||
}
|
||||
else if(GetClientVersion(ClientID) >= VERSION_DDNET_WHISPER)
|
||||
{
|
||||
|
@ -3530,7 +3542,7 @@ void CGameContext::WhisperID(int ClientID, int VictimID, const char *pMessage)
|
|||
Msg.m_pMessage = pMessage;
|
||||
Msg.m_TargetID = VictimID;
|
||||
|
||||
Server()->SendPackMsgOne(&Msg, MSGFLAG_VITAL, VictimID);
|
||||
Server()->SendPackMsgOne(&Msg, MSGFLAG_VITAL|MSGFLAG_NORECORD, VictimID);
|
||||
}
|
||||
else if(GetClientVersion(VictimID) >= VERSION_DDNET_WHISPER)
|
||||
{
|
||||
|
|
|
@ -354,6 +354,8 @@ void CPlayer::Snap(int SnappingClient)
|
|||
}
|
||||
|
||||
if(m_ClientID == SnappingClient && (m_Team == TEAM_SPECTATORS || m_Paused))
|
||||
{
|
||||
if(!Server()->IsSixup(SnappingClient))
|
||||
{
|
||||
CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(CNetObj_SpectatorInfo)));
|
||||
if(!pSpectatorInfo)
|
||||
|
@ -363,6 +365,18 @@ void CPlayer::Snap(int SnappingClient)
|
|||
pSpectatorInfo->m_X = m_ViewPos.x;
|
||||
pSpectatorInfo->m_Y = m_ViewPos.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
protocol7::CNetObj_SpectatorInfo *pSpectatorInfo = static_cast<protocol7::CNetObj_SpectatorInfo *>(Server()->SnapNewItem(NETOBJTYPE_SPECTATORINFO, m_ClientID, sizeof(protocol7::CNetObj_SpectatorInfo)));
|
||||
if(!pSpectatorInfo)
|
||||
return;
|
||||
|
||||
pSpectatorInfo->m_SpecMode = m_SpectatorID == SPEC_FREEVIEW ? protocol7::SPEC_FREEVIEW : protocol7::SPEC_PLAYER;
|
||||
pSpectatorInfo->m_SpectatorID = m_SpectatorID;
|
||||
pSpectatorInfo->m_X = m_ViewPos.x;
|
||||
pSpectatorInfo->m_Y = m_ViewPos.y;
|
||||
}
|
||||
}
|
||||
|
||||
CNetObj_DDNetPlayer *pDDNetPlayer = static_cast<CNetObj_DDNetPlayer *>(Server()->SnapNewItem(NETOBJTYPE_DDNETPLAYER, id, sizeof(CNetObj_DDNetPlayer)));
|
||||
if(!pDDNetPlayer)
|
||||
|
@ -383,6 +397,9 @@ void CPlayer::FakeSnap()
|
|||
if(GetClientVersion() >= VERSION_DDNET_OLD)
|
||||
return;
|
||||
|
||||
if(Server()->IsSixup(m_ClientID))
|
||||
return;
|
||||
|
||||
int FakeID = VANILLA_MAX_CLIENTS - 1;
|
||||
|
||||
CNetObj_ClientInfo *pClientInfo = static_cast<CNetObj_ClientInfo *>(Server()->SnapNewItem(NETOBJTYPE_CLIENTINFO, FakeID, sizeof(CNetObj_ClientInfo)));
|
||||
|
@ -593,6 +610,19 @@ void CPlayer::SetTeam(int Team, bool DoChatMsg)
|
|||
|
||||
//GameServer()->m_pController->OnPlayerInfoChange(GameServer()->m_apPlayers[m_ClientID]);
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; i++)
|
||||
{
|
||||
if(Server()->ClientIngame(i) && Server()->IsSixup(i))
|
||||
{
|
||||
protocol7::CNetMsg_Sv_Team Msg;
|
||||
Msg.m_ClientID = m_ClientID;
|
||||
Msg.m_Team = m_Team;
|
||||
Msg.m_Silent = !DoChatMsg;
|
||||
Msg.m_CooldownTick = m_LastSetTeam + Server()->TickSpeed() * g_Config.m_SvTeamChangeDelay;
|
||||
Server()->SendPackMsgOne(&Msg, MSGFLAG_VITAL|MSGFLAG_NORECORD, i);
|
||||
}
|
||||
}
|
||||
|
||||
if(Team == TEAM_SPECTATORS)
|
||||
{
|
||||
// update spectator modes
|
||||
|
|
Loading…
Reference in a new issue