1 | /* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */ |
---|---|
2 | #include "teamscore.h" |
3 | #include <base/system.h> |
4 | #include <engine/shared/config.h> |
5 | |
6 | CTeamsCore::CTeamsCore() |
7 | { |
8 | Reset(); |
9 | } |
10 | |
11 | bool CTeamsCore::SameTeam(int ClientId1, int ClientId2) const |
12 | { |
13 | return m_aTeam[ClientId1] == TEAM_SUPER || m_aTeam[ClientId2] == TEAM_SUPER || m_aTeam[ClientId1] == m_aTeam[ClientId2]; |
14 | } |
15 | |
16 | int CTeamsCore::Team(int ClientId) const |
17 | { |
18 | return m_aTeam[ClientId]; |
19 | } |
20 | |
21 | void CTeamsCore::Team(int ClientId, int Team) |
22 | { |
23 | dbg_assert(Team >= TEAM_FLOCK && Team <= TEAM_SUPER, "invalid team"); |
24 | m_aTeam[ClientId] = Team; |
25 | } |
26 | |
27 | bool CTeamsCore::CanKeepHook(int ClientId1, int ClientId2) const |
28 | { |
29 | if(m_aTeam[ClientId1] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || m_aTeam[ClientId2] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || ClientId1 == ClientId2) |
30 | return true; |
31 | return m_aTeam[ClientId1] == m_aTeam[ClientId2]; |
32 | } |
33 | |
34 | bool CTeamsCore::CanCollide(int ClientId1, int ClientId2) const |
35 | { |
36 | if(m_aTeam[ClientId1] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || m_aTeam[ClientId2] == (m_IsDDRace16 ? VANILLA_TEAM_SUPER : TEAM_SUPER) || ClientId1 == ClientId2) |
37 | return true; |
38 | if(m_aIsSolo[ClientId1] || m_aIsSolo[ClientId2]) |
39 | return false; |
40 | return m_aTeam[ClientId1] == m_aTeam[ClientId2]; |
41 | } |
42 | |
43 | void CTeamsCore::Reset() |
44 | { |
45 | m_IsDDRace16 = false; |
46 | |
47 | for(int i = 0; i < MAX_CLIENTS; ++i) |
48 | { |
49 | if(g_Config.m_SvTeam == SV_TEAM_FORCED_SOLO) |
50 | m_aTeam[i] = i; |
51 | else |
52 | m_aTeam[i] = TEAM_FLOCK; |
53 | m_aIsSolo[i] = false; |
54 | } |
55 | } |
56 | |
57 | void CTeamsCore::SetSolo(int ClientId, bool Value) |
58 | { |
59 | dbg_assert(ClientId >= 0 && ClientId < MAX_CLIENTS, "Invalid client id"); |
60 | m_aIsSolo[ClientId] = Value; |
61 | } |
62 | |
63 | bool CTeamsCore::GetSolo(int ClientId) const |
64 | { |
65 | if(ClientId < 0 || ClientId >= MAX_CLIENTS) |
66 | return false; |
67 | return m_aIsSolo[ClientId]; |
68 | } |
69 |