2011-12-25 13:33:05 +00:00
|
|
|
/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
|
2010-08-30 12:13:43 +00:00
|
|
|
#include "teamscore.h"
|
2020-07-02 20:11:43 +00:00
|
|
|
#include <engine/shared/config.h>
|
2010-08-30 12:13:43 +00:00
|
|
|
|
2011-01-06 05:30:19 +00:00
|
|
|
CTeamsCore::CTeamsCore()
|
|
|
|
{
|
2010-09-24 07:12:26 +00:00
|
|
|
Reset();
|
2010-08-30 12:13:43 +00:00
|
|
|
}
|
|
|
|
|
2020-06-24 07:23:07 +00:00
|
|
|
bool CTeamsCore::SameTeam(int ClientID1, int ClientID2) const
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
return m_aTeam[ClientID1] == TEAM_SUPER || m_aTeam[ClientID2] == TEAM_SUPER || m_aTeam[ClientID1] == m_aTeam[ClientID2];
|
2010-08-30 12:13:43 +00:00
|
|
|
}
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2020-06-24 07:23:07 +00:00
|
|
|
int CTeamsCore::Team(int ClientID) const
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
return m_aTeam[ClientID];
|
2010-08-30 12:13:43 +00:00
|
|
|
}
|
|
|
|
|
2011-02-13 05:35:13 +00:00
|
|
|
void CTeamsCore::Team(int ClientID, int Team)
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2022-01-31 12:29:11 +00:00
|
|
|
dbg_assert(Team >= TEAM_FLOCK && Team <= TEAM_SUPER, "invalid team");
|
2022-06-30 22:36:32 +00:00
|
|
|
m_aTeam[ClientID] = Team;
|
2010-09-21 19:09:11 +00:00
|
|
|
}
|
|
|
|
|
2020-06-24 07:23:07 +00:00
|
|
|
bool CTeamsCore::CanKeepHook(int ClientID1, int ClientID2) const
|
2015-02-28 00:18:35 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
if(m_aTeam[ClientID1] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || m_aTeam[ClientID2] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || ClientID1 == ClientID2)
|
2015-02-28 00:18:35 +00:00
|
|
|
return true;
|
2022-06-30 22:36:32 +00:00
|
|
|
return m_aTeam[ClientID1] == m_aTeam[ClientID2];
|
2015-02-28 00:18:35 +00:00
|
|
|
}
|
|
|
|
|
2020-06-24 07:23:07 +00:00
|
|
|
bool CTeamsCore::CanCollide(int ClientID1, int ClientID2) const
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2022-06-30 22:36:32 +00:00
|
|
|
if(m_aTeam[ClientID1] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || m_aTeam[ClientID2] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || ClientID1 == ClientID2)
|
2011-04-20 16:47:25 +00:00
|
|
|
return true;
|
2022-06-30 22:36:32 +00:00
|
|
|
if(m_aIsSolo[ClientID1] || m_aIsSolo[ClientID2])
|
2011-09-02 18:04:18 +00:00
|
|
|
return false;
|
2022-06-30 22:36:32 +00:00
|
|
|
return m_aTeam[ClientID1] == m_aTeam[ClientID2];
|
2010-09-24 07:12:26 +00:00
|
|
|
}
|
|
|
|
|
2011-01-06 05:30:19 +00:00
|
|
|
void CTeamsCore::Reset()
|
|
|
|
{
|
2014-01-21 17:21:01 +00:00
|
|
|
m_IsDDRace16 = false;
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
for(int i = 0; i < MAX_CLIENTS; ++i)
|
2011-09-02 18:04:18 +00:00
|
|
|
{
|
2022-02-19 14:20:32 +00:00
|
|
|
if(g_Config.m_SvTeam == SV_TEAM_FORCED_SOLO)
|
2022-06-30 22:36:32 +00:00
|
|
|
m_aTeam[i] = i;
|
2020-06-30 18:22:17 +00:00
|
|
|
else
|
2022-06-30 22:36:32 +00:00
|
|
|
m_aTeam[i] = TEAM_FLOCK;
|
|
|
|
m_aIsSolo[i] = false;
|
2011-09-02 18:04:18 +00:00
|
|
|
}
|
2010-11-13 13:22:19 +00:00
|
|
|
}
|
2023-01-03 12:17:59 +00:00
|
|
|
|
|
|
|
void CTeamsCore::SetSolo(int ClientID, bool Value)
|
|
|
|
{
|
|
|
|
dbg_assert(ClientID >= 0 && ClientID < MAX_CLIENTS, "Invalid client id");
|
|
|
|
m_aIsSolo[ClientID] = Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CTeamsCore::GetSolo(int ClientID) const
|
|
|
|
{
|
|
|
|
if(ClientID < 0 || ClientID >= MAX_CLIENTS)
|
|
|
|
return false;
|
|
|
|
return m_aIsSolo[ClientID];
|
|
|
|
}
|