ddnet/src/game/teamscore.cpp

55 lines
1.5 KiB
C++
Raw Normal View History

/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
#include "teamscore.h"
#include <engine/shared/config.h>
CTeamsCore::CTeamsCore()
{
2010-09-24 07:12:26 +00:00
Reset();
}
bool CTeamsCore::SameTeam(int ClientID1, int ClientID2) const
{
return m_Team[ClientID1] == TEAM_SUPER || m_Team[ClientID2] == TEAM_SUPER || m_Team[ClientID1] == m_Team[ClientID2];
}
int CTeamsCore::Team(int ClientID) const
{
return m_Team[ClientID];
}
void CTeamsCore::Team(int ClientID, int Team)
{
dbg_assert(Team >= TEAM_FLOCK && Team <= TEAM_SUPER, "invalid team");
m_Team[ClientID] = Team;
}
bool CTeamsCore::CanKeepHook(int ClientID1, int ClientID2) const
2015-02-28 00:18:35 +00:00
{
if(m_Team[ClientID1] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || m_Team[ClientID2] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || ClientID1 == ClientID2)
2015-02-28 00:18:35 +00:00
return true;
return m_Team[ClientID1] == m_Team[ClientID2];
}
bool CTeamsCore::CanCollide(int ClientID1, int ClientID2) const
{
if(m_Team[ClientID1] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || m_Team[ClientID2] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || ClientID1 == ClientID2)
2011-04-20 16:47:25 +00:00
return true;
if(m_IsSolo[ClientID1] || m_IsSolo[ClientID2])
return false;
return m_Team[ClientID1] == m_Team[ClientID2];
2010-09-24 07:12:26 +00:00
}
void CTeamsCore::Reset()
{
m_IsDDRace16 = false;
for(int i = 0; i < MAX_CLIENTS; ++i)
{
if(g_Config.m_SvTeam == SV_TEAM_FORCED_SOLO)
m_Team[i] = i;
else
m_Team[i] = TEAM_FLOCK;
m_IsSolo[i] = false;
}
}