DDraceNetwork Documentation
Loading...
Searching...
No Matches
teams.h
Go to the documentation of this file.
1/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
2#ifndef GAME_SERVER_TEAMS_H
3#define GAME_SERVER_TEAMS_H
4
6#include <game/race_state.h>
8#include <game/team_state.h>
9#include <game/teamscore.h>
10
11class CCharacter;
12class CPlayer;
13struct CScoreSaveResult;
14
16{
17 // `m_TeeStarted` is used to keep track whether a given tee has hit the
18 // start of the map yet. If a tee that leaves hasn't hit the start line
19 // yet, the team will be marked as "not allowed to finish"
20 // (`ETeamState::STARTED_UNFINISHABLE`). If this were not the case, tees
21 // could go around the startline on a map, leave one tee behind at
22 // start, go to the finish line, let the tee start and kill, allowing
23 // the team to finish instantly.
27
33 std::shared_ptr<CScoreSaveResult> m_apSaveTeamResult[NUM_DDRACE_TEAMS];
34 uint64_t m_aLastSwap[MAX_CLIENTS]; // index is id of player who initiated swap
36 // `m_aTeamUnfinishableKillTick` is -1 by default and gets set when a
37 // team becomes unfinishable. If the team hasn't entered practice mode
38 // by that time, it'll get killed to prevent people not understanding
39 // the message from playing for a long time in an unfinishable team.
41
43
50 void KillTeam(int Team, int NewStrongId, int ExceptId = -1);
51 bool TeamFinished(int Team);
52 void OnTeamFinish(int Team, CPlayer **Players, unsigned int Size, int TimeTicks, const char *pTimestamp);
53 void OnFinish(CPlayer *Player, int TimeTicks, const char *pTimestamp);
54
55public:
57
59
60 // helper methods
61 CCharacter *Character(int ClientId);
62 CPlayer *GetPlayer(int ClientId);
63 class CGameContext *GameServer();
64 class IServer *Server();
65
66 void OnCharacterStart(int ClientId);
67 void OnCharacterFinish(int ClientId);
68 void OnCharacterSpawn(int ClientId);
69 void OnCharacterDeath(int ClientId, int Weapon);
70 void Tick();
71
72 // returns nullptr if successful, error string if failed
73 const char *SetCharacterTeam(int ClientId, int Team);
74 void CheckTeamFinished(int Team);
75
76 void ChangeTeamState(int Team, ETeamState State);
77
79
80 int Count(int Team) const;
81
82 // need to be very careful using this method. SERIOUSLY...
83 void SetForceCharacterTeam(int ClientId, int Team);
84
85 void Reset();
86 void ResetRoundState(int Team);
87 void ResetSwitchers(int Team);
88
89 void SendTeamsState(int ClientId);
90 void SetTeamLock(int Team, bool Lock);
91 void SetTeamFlock(int Team, bool Mode);
92 void ResetInvited(int Team);
93 void SetClientInvited(int Team, int ClientId, bool Invited);
94
95 ERaceState GetDDRaceState(const CPlayer *Player) const;
96 int GetStartTime(CPlayer *Player);
97 float *GetCurrentTimeCp(CPlayer *Player);
99 void SetStartTime(CPlayer *Player, int StartTime);
100 void SetLastTimeCp(CPlayer *Player, int LastTimeCp);
101 void KillCharacterOrTeam(int ClientId, int Team);
102 void ResetSavedTeam(int ClientId, int Team);
105 void CancelTeamSwap(CPlayer *pPlayer, int Team);
106 void ProcessSaveTeam();
107 int GetFirstEmptyTeam() const;
108 bool TeeStarted(int ClientId) const;
109 bool TeeFinished(int ClientId) const;
110 ETeamState GetTeamState(int Team) const;
111 bool TeamLocked(int Team) const;
112 bool TeamFlock(int Team) const;
113 bool IsInvited(int Team, int ClientId) const;
114 bool IsStarted(int Team) const;
115 void SetStarted(int ClientId, bool Started);
116 void SetFinished(int ClientId, bool Finished);
117 void SetSaving(int TeamId, std::shared_ptr<CScoreSaveResult> &SaveResult);
118 bool GetSaving(int TeamId) const;
119 void SetPractice(int Team, bool Enabled);
120 bool IsPractice(int Team);
121};
122
123#endif
Definition character.h:24
Definition gamecontext.h:106
@ FLAG_SIXUP
Definition gamecontext.h:291
@ FLAG_SIX
Definition gamecontext.h:290
Definition teams.h:16
bool TeamLocked(int Team) const
Definition teams.cpp:1269
bool GetSaving(int TeamId) const
Definition teams.cpp:1310
void OnCharacterSpawn(int ClientId)
Definition teams.cpp:1091
int Count(int Team) const
Definition teams.cpp:459
float * GetCurrentTimeCp(CPlayer *Player)
Definition teams.cpp:670
bool IsPractice(int Team)
Definition teams.cpp:1334
void SetFinished(int ClientId, bool Finished)
Definition teams.cpp:1300
class CGameContext * GameServer()
Definition teams.cpp:841
CTeamsCore m_Core
Definition teams.h:56
int GetStartTime(CPlayer *Player)
Definition teams.cpp:639
int GetFirstEmptyTeam() const
Definition teams.cpp:1246
void OnTeamFinish(int Team, CPlayer **Players, unsigned int Size, int TimeTicks, const char *pTimestamp)
Definition teams.cpp:681
bool m_aTeeFinished[MAX_CLIENTS]
Definition teams.h:25
void CheckTeamFinished(int Team)
Definition teams.cpp:317
uint64_t m_aLastSwap[MAX_CLIENTS]
Definition teams.h:34
void Reset()
Definition teams.cpp:20
bool m_aTeamLocked[NUM_DDRACE_TEAMS]
Definition teams.h:29
void KillTeam(int Team, int NewStrongId, int ExceptId=-1)
Definition teams.cpp:478
void OnFinish(CPlayer *Player, int TimeTicks, const char *pTimestamp)
Definition teams.cpp:703
const char * SetCharacterTeam(int ClientId, int Team)
Definition teams.cpp:380
void SwapTeamCharacters(CPlayer *pPrimaryPlayer, CPlayer *pTargetPlayer, int Team)
Definition teams.cpp:898
class CGameContext * m_pGameContext
Definition teams.h:42
void ResetRoundState(int Team)
Definition teams.cpp:44
void ResetInvited(int Team)
Definition teams.cpp:1199
void SetStarted(int ClientId, bool Started)
Definition teams.cpp:1295
bool TeeStarted(int ClientId) const
Definition teams.cpp:1254
bool m_aTeamFlock[NUM_DDRACE_TEAMS]
Definition teams.h:30
bool m_aTeamSentStartWarning[NUM_DDRACE_TEAMS]
Definition teams.h:35
void RequestTeamSwap(CPlayer *pPlayer, CPlayer *pTargetPlayer, int Team)
Definition teams.cpp:851
void CancelTeamSwap(CPlayer *pPlayer, int Team)
Definition teams.cpp:969
void ProcessSaveTeam()
Definition teams.cpp:1007
void SetDDRaceState(CPlayer *Player, ERaceState DDRaceState)
Definition teams.cpp:629
bool TeamFlock(int Team) const
Definition teams.cpp:1277
CClientMask m_aInvited[NUM_DDRACE_TEAMS]
Definition teams.h:31
void SetTeamFlock(int Team, bool Mode)
Definition teams.cpp:1193
void SetTeamLock(int Team, bool Lock)
Definition teams.cpp:1187
void ChangeTeamState(int Team, ETeamState State)
Definition teams.cpp:473
ETeamState GetTeamState(int Team) const
Definition teams.cpp:1264
int m_aLastChat[MAX_CLIENTS]
Definition teams.h:26
void OnCharacterStart(int ClientId)
Definition teams.cpp:74
bool TeeFinished(int ClientId) const
Definition teams.cpp:1259
CClientMask TeamMask(int Team, int ExceptId=-1, int Asker=-1, int VersionFlags=CGameContext::FLAG_SIX|CGameContext::FLAG_SIXUP)
Definition teams.cpp:515
void OnCharacterDeath(int ClientId, int Weapon)
Definition teams.cpp:1110
void SetLastTimeCp(CPlayer *Player, int LastTimeCp)
Definition teams.cpp:660
void SetStartTime(CPlayer *Player, int StartTime)
Definition teams.cpp:650
bool TeamFinished(int Team)
Definition teams.cpp:503
void SetClientInvited(int Team, int ClientId, bool Invited)
Definition teams.cpp:1204
void ResetSwitchers(int Team)
Definition teams.cpp:64
void Tick()
Definition teams.cpp:218
bool IsInvited(int Team, int ClientId) const
Definition teams.cpp:1285
void SetSaving(int TeamId, std::shared_ptr< CScoreSaveResult > &SaveResult)
Definition teams.cpp:1305
void OnCharacterFinish(int ClientId)
Definition teams.cpp:192
CPlayer * GetPlayer(int ClientId)
Definition teams.cpp:836
ERaceState GetDDRaceState(const CPlayer *Player) const
Definition teams.cpp:618
ETeamState m_aTeamState[NUM_DDRACE_TEAMS]
Definition teams.h:28
bool m_aTeeStarted[MAX_CLIENTS]
Definition teams.h:24
CCharacter * Character(int ClientId)
Definition teams.cpp:831
void ResetSavedTeam(int ClientId, int Team)
Definition teams.cpp:1227
class IServer * Server()
Definition teams.cpp:846
std::shared_ptr< CScoreSaveResult > m_apSaveTeamResult[NUM_DDRACE_TEAMS]
Definition teams.h:33
void KillCharacterOrTeam(int ClientId, int Team)
Definition teams.cpp:1215
void SetPractice(int Team, bool Enabled)
Definition teams.cpp:1320
bool IsStarted(int Team) const
Definition teams.cpp:1290
void SendTeamsState(int ClientId)
Definition teams.cpp:593
void SetForceCharacterTeam(int ClientId, int Team)
Definition teams.cpp:413
int m_aTeamUnfinishableKillTick[NUM_DDRACE_TEAMS]
Definition teams.h:40
bool m_aPractice[NUM_DDRACE_TEAMS]
Definition teams.h:32
Definition player.h:24
Definition teamscore.h:25
Definition server.h:31
Definition vmath.h:15
std::bitset< MAX_CLIENTS > CClientMask
Definition protocol.h:142
@ MAX_CLIENTS
Definition protocol.h:88
ERaceState
Definition race_state.h:5
Definition scoreworker.h:150
ETeamState
Definition team_state.h:5
@ NUM_DDRACE_TEAMS
Definition teamscore.h:11