mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Merge #4522
4522: Improve super prediction r=heinrich5991 a=def- As suggested by cheeser0613 ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [ ] Considered possible null pointers and out of bounds array indexing - [ ] Changed no physics that affect existing maps - [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: def <dennis@felsin9.de> Co-authored-by: Dennis Felsing <dennis@felsin9.de>
This commit is contained in:
commit
901b61756f
|
@ -758,9 +758,9 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, int Conn, bool Dumm
|
|||
if(pUnpacker->Error())
|
||||
WentWrong = true;
|
||||
|
||||
if(!WentWrong && Team >= 0 && Team < MAX_CLIENTS)
|
||||
if(!WentWrong && Team >= TEAM_FLOCK && Team <= TEAM_SUPER)
|
||||
m_Teams.Team(i, Team);
|
||||
else if(Team != MAX_CLIENTS)
|
||||
else
|
||||
WentWrong = true;
|
||||
|
||||
if(WentWrong)
|
||||
|
@ -1388,7 +1388,7 @@ void CGameClient::OnNewSnapshot()
|
|||
else if(Item.m_Type == NETOBJTYPE_SWITCHSTATE)
|
||||
{
|
||||
const CNetObj_SwitchState *pSwitchStateData = (const CNetObj_SwitchState *)pData;
|
||||
int Team = clamp(Item.m_ID, 0, MAX_CLIENTS - 1);
|
||||
int Team = clamp(Item.m_ID, (int)TEAM_FLOCK, (int)TEAM_SUPER - 1);
|
||||
|
||||
int NumSwitchers = clamp(pSwitchStateData->m_NumSwitchers, 0, 255);
|
||||
if(!Collision()->m_pSwitchers || NumSwitchers != Collision()->m_NumSwitchers)
|
||||
|
@ -1521,7 +1521,7 @@ void CGameClient::OnNewSnapshot()
|
|||
|
||||
// sort player infos by DDRace Team (and score between)
|
||||
int Index = 0;
|
||||
for(int Team = 0; Team <= MAX_CLIENTS; ++Team)
|
||||
for(int Team = TEAM_FLOCK; Team <= TEAM_SUPER; ++Team)
|
||||
{
|
||||
for(int i = 0; i < MAX_CLIENTS && Index < MAX_CLIENTS; ++i)
|
||||
{
|
||||
|
@ -1532,7 +1532,7 @@ void CGameClient::OnNewSnapshot()
|
|||
|
||||
// sort player infos by DDRace Team (and name between)
|
||||
Index = 0;
|
||||
for(int Team = 0; Team <= MAX_CLIENTS; ++Team)
|
||||
for(int Team = TEAM_FLOCK; Team <= TEAM_SUPER; ++Team)
|
||||
{
|
||||
for(int i = 0; i < MAX_CLIENTS && Index < MAX_CLIENTS; ++i)
|
||||
{
|
||||
|
@ -2575,10 +2575,17 @@ bool CGameClient::IsOtherTeam(int ClientID)
|
|||
else if((m_aClients[m_Snap.m_LocalClientID].m_Team == TEAM_SPECTATORS && m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW) || ClientID < 0)
|
||||
return false;
|
||||
else if(m_Snap.m_SpecInfo.m_Active && m_Snap.m_SpecInfo.m_SpectatorID != SPEC_FREEVIEW)
|
||||
{
|
||||
if(m_Teams.Team(ClientID) == TEAM_SUPER || m_Teams.Team(m_Snap.m_SpecInfo.m_SpectatorID) == TEAM_SUPER)
|
||||
return false;
|
||||
return m_Teams.Team(ClientID) != m_Teams.Team(m_Snap.m_SpecInfo.m_SpectatorID);
|
||||
}
|
||||
else if((m_aClients[m_Snap.m_LocalClientID].m_Solo || m_aClients[ClientID].m_Solo) && !Local)
|
||||
return true;
|
||||
|
||||
if(m_Teams.Team(ClientID) == TEAM_SUPER || m_Teams.Team(m_Snap.m_LocalClientID) == TEAM_SUPER)
|
||||
return false;
|
||||
|
||||
return m_Teams.Team(ClientID) != m_Teams.Team(m_Snap.m_LocalClientID);
|
||||
}
|
||||
|
||||
|
|
|
@ -483,6 +483,9 @@ int64_t CGameTeams::TeamMask(int Team, int ExceptID, int Asker)
|
|||
{
|
||||
int64_t Mask = 0;
|
||||
|
||||
if(Team == TEAM_SUPER)
|
||||
return 0xffffffffffffffff;
|
||||
|
||||
for(int i = 0; i < MAX_CLIENTS; ++i)
|
||||
{
|
||||
if(i == ExceptID)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
|
||||
#include "teamscore.h"
|
||||
#include <base/math.h>
|
||||
#include <engine/shared/config.h>
|
||||
|
||||
CTeamsCore::CTeamsCore()
|
||||
|
@ -9,7 +10,7 @@ CTeamsCore::CTeamsCore()
|
|||
|
||||
bool CTeamsCore::SameTeam(int ClientID1, int ClientID2) const
|
||||
{
|
||||
return m_Team[ClientID1] == m_Team[ClientID2];
|
||||
return m_Team[ClientID1] == TEAM_SUPER || m_Team[ClientID2] == TEAM_SUPER || m_Team[ClientID1] == m_Team[ClientID2];
|
||||
}
|
||||
|
||||
int CTeamsCore::Team(int ClientID) const
|
||||
|
@ -19,6 +20,7 @@ int CTeamsCore::Team(int ClientID) const
|
|||
|
||||
void CTeamsCore::Team(int ClientID, int Team)
|
||||
{
|
||||
dbg_assert(Team >= TEAM_FLOCK && Team <= TEAM_SUPER, "invalid team");
|
||||
m_Team[ClientID] = Team;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue