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-28 13:47:52 +00:00
|
|
|
#ifndef GAME_SERVER_TEAMS_H
|
|
|
|
#define GAME_SERVER_TEAMS_H
|
|
|
|
|
2020-06-30 18:22:17 +00:00
|
|
|
#include <engine/shared/config.h>
|
2010-08-30 12:13:43 +00:00
|
|
|
#include <game/teamscore.h>
|
2010-08-28 13:47:52 +00:00
|
|
|
#include <game/server/gamecontext.h>
|
|
|
|
|
2011-01-06 05:30:19 +00:00
|
|
|
class CGameTeams
|
|
|
|
{
|
2013-12-28 15:09:03 +00:00
|
|
|
int m_TeamState[MAX_CLIENTS];
|
|
|
|
bool m_TeeFinished[MAX_CLIENTS];
|
|
|
|
bool m_TeamLocked[MAX_CLIENTS];
|
2017-04-23 20:50:07 +00:00
|
|
|
uint64_t m_Invited[MAX_CLIENTS];
|
2020-05-22 21:59:47 +00:00
|
|
|
bool m_Practice[MAX_CLIENTS];
|
2020-06-24 21:14:09 +00:00
|
|
|
std::shared_ptr<CScoreSaveResult> m_pSaveTeamResult[MAX_CLIENTS];
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2010-08-28 20:53:42 +00:00
|
|
|
class CGameContext * m_pGameContext;
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2019-01-10 08:32:23 +00:00
|
|
|
void CheckTeamFinished(int ClientID);
|
|
|
|
bool TeamFinished(int Team);
|
2019-04-02 17:53:37 +00:00
|
|
|
void OnTeamFinish(CPlayer** Players, unsigned int Size, float Time, const char *pTimestamp);
|
|
|
|
void OnFinish(CPlayer* Player, float Time, const char *pTimestamp);
|
2019-01-10 08:32:23 +00:00
|
|
|
|
2010-08-28 13:47:52 +00:00
|
|
|
public:
|
2011-03-16 13:14:25 +00:00
|
|
|
enum
|
2011-01-06 05:30:19 +00:00
|
|
|
{
|
2011-12-25 13:51:04 +00:00
|
|
|
TEAMSTATE_EMPTY, TEAMSTATE_OPEN, TEAMSTATE_STARTED, TEAMSTATE_FINISHED
|
2010-08-28 13:47:52 +00:00
|
|
|
};
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2010-08-30 12:13:43 +00:00
|
|
|
CTeamsCore m_Core;
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2010-08-30 12:13:43 +00:00
|
|
|
CGameTeams(CGameContext *pGameContext);
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2010-08-28 13:47:52 +00:00
|
|
|
//helper methods
|
2011-12-25 13:51:04 +00:00
|
|
|
CCharacter* Character(int ClientID)
|
|
|
|
{
|
|
|
|
return GameServer()->GetPlayerChar(ClientID);
|
|
|
|
}
|
|
|
|
CPlayer* GetPlayer(int ClientID)
|
|
|
|
{
|
|
|
|
return GameServer()->m_apPlayers[ClientID];
|
|
|
|
}
|
|
|
|
|
|
|
|
class CGameContext *GameServer()
|
|
|
|
{
|
|
|
|
return m_pGameContext;
|
|
|
|
}
|
|
|
|
class IServer *Server()
|
|
|
|
{
|
|
|
|
return m_pGameContext->Server();
|
|
|
|
}
|
2010-08-28 20:53:42 +00:00
|
|
|
|
2011-02-02 10:49:19 +00:00
|
|
|
void OnCharacterStart(int ClientID);
|
|
|
|
void OnCharacterFinish(int ClientID);
|
2013-02-01 11:08:23 +00:00
|
|
|
void OnCharacterSpawn(int ClientID);
|
2014-04-12 10:08:20 +00:00
|
|
|
void OnCharacterDeath(int ClientID, int Weapon);
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2011-03-16 13:14:25 +00:00
|
|
|
bool SetCharacterTeam(int ClientID, int Team);
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2011-03-16 13:14:25 +00:00
|
|
|
void ChangeTeamState(int Team, int State);
|
2011-12-25 13:19:03 +00:00
|
|
|
void onChangeTeamState(int Team, int State, int OldState);
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2013-12-31 05:13:57 +00:00
|
|
|
int64_t TeamMask(int Team, int ExceptID = -1, int Asker = -1);
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2010-11-06 22:54:35 +00:00
|
|
|
int Count(int Team) const;
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2020-05-30 22:34:29 +00:00
|
|
|
//need to be very careful using this method. SERIOUSLY...
|
|
|
|
void SetForceCharacterTeam(int ClientID, int Team);
|
|
|
|
void SetForceCharacterNewTeam(int ClientID, int Team);
|
|
|
|
void ForceLeaveTeam(int ClientID);
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2010-09-24 13:37:13 +00:00
|
|
|
void Reset();
|
2011-12-25 13:51:04 +00:00
|
|
|
|
2020-05-30 22:34:29 +00:00
|
|
|
void SendTeamsState(int ClientID);
|
2013-11-15 23:44:49 +00:00
|
|
|
void SetTeamLock(int Team, bool Lock);
|
2017-04-23 20:50:07 +00:00
|
|
|
void ResetInvited(int Team);
|
|
|
|
void SetClientInvited(int Team, int ClientID, bool Invited);
|
2010-12-19 03:48:16 +00:00
|
|
|
|
|
|
|
int m_LastChat[MAX_CLIENTS];
|
2011-06-06 19:24:27 +00:00
|
|
|
|
|
|
|
int GetDDRaceState(CPlayer* Player);
|
|
|
|
int GetStartTime(CPlayer* Player);
|
|
|
|
float *GetCpCurrent(CPlayer* Player);
|
|
|
|
void SetDDRaceState(CPlayer* Player, int DDRaceState);
|
|
|
|
void SetStartTime(CPlayer* Player, int StartTime);
|
|
|
|
void SetCpActive(CPlayer* Player, int CpActive);
|
2020-06-02 14:27:31 +00:00
|
|
|
void KillSavedTeam(int ClientID, int Team);
|
|
|
|
void ResetSavedTeam(int ClientID, int Team);
|
|
|
|
void ProcessSaveTeam();
|
2014-12-17 19:38:05 +00:00
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
bool TeeFinished(int ClientID)
|
|
|
|
{
|
|
|
|
return m_TeeFinished[ClientID];
|
|
|
|
}
|
2014-12-17 19:38:05 +00:00
|
|
|
|
2011-12-25 13:51:04 +00:00
|
|
|
int GetTeamState(int Team)
|
|
|
|
{
|
|
|
|
return m_TeamState[Team];
|
|
|
|
}
|
2014-12-17 19:38:05 +00:00
|
|
|
|
2013-11-15 23:44:49 +00:00
|
|
|
bool TeamLocked(int Team)
|
|
|
|
{
|
2014-01-30 02:37:45 +00:00
|
|
|
if (Team <= TEAM_FLOCK || Team >= TEAM_SUPER)
|
|
|
|
return false;
|
|
|
|
|
2013-11-15 23:44:49 +00:00
|
|
|
return m_TeamLocked[Team];
|
|
|
|
}
|
2014-12-17 19:38:05 +00:00
|
|
|
|
2017-04-23 20:50:07 +00:00
|
|
|
bool IsInvited(int Team, int ClientID)
|
|
|
|
{
|
|
|
|
return m_Invited[Team] & 1LL << ClientID;
|
|
|
|
}
|
|
|
|
|
2014-07-26 12:46:31 +00:00
|
|
|
void SetFinished(int ClientID, bool finished)
|
|
|
|
{
|
|
|
|
m_TeeFinished[ClientID] = finished;
|
|
|
|
}
|
2020-06-24 21:14:09 +00:00
|
|
|
|
|
|
|
void SetSaving(int TeamID, std::shared_ptr<CScoreSaveResult> SaveResult)
|
2014-12-17 19:38:05 +00:00
|
|
|
{
|
2020-06-02 14:27:31 +00:00
|
|
|
m_pSaveTeamResult[TeamID] = SaveResult;
|
2014-12-17 19:38:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GetSaving(int TeamID)
|
|
|
|
{
|
2020-06-30 18:22:17 +00:00
|
|
|
if(TeamID < TEAM_FLOCK || TeamID >= TEAM_SUPER)
|
|
|
|
return false;
|
|
|
|
if(g_Config.m_SvTeam != 3 && TeamID == TEAM_FLOCK)
|
2020-06-28 11:25:39 +00:00
|
|
|
return false;
|
|
|
|
|
2020-06-02 14:27:31 +00:00
|
|
|
return m_pSaveTeamResult[TeamID] != nullptr;
|
2014-12-17 19:38:05 +00:00
|
|
|
}
|
2020-05-22 21:59:47 +00:00
|
|
|
|
|
|
|
void EnablePractice(int Team)
|
|
|
|
{
|
2020-06-30 18:22:17 +00:00
|
|
|
if(Team < TEAM_FLOCK || Team >= TEAM_SUPER)
|
|
|
|
return;
|
|
|
|
if(g_Config.m_SvTeam != 3 && Team == TEAM_FLOCK)
|
2020-05-22 21:59:47 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
m_Practice[Team] = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsPractice(int Team)
|
|
|
|
{
|
2020-06-30 18:22:17 +00:00
|
|
|
if(Team < TEAM_FLOCK || Team >= TEAM_SUPER)
|
|
|
|
return false;
|
|
|
|
if(g_Config.m_SvTeam != 3 && Team == TEAM_FLOCK)
|
2020-05-22 21:59:47 +00:00
|
|
|
return false;
|
|
|
|
|
|
|
|
return m_Practice[Team];
|
|
|
|
}
|
2010-08-28 13:47:52 +00:00
|
|
|
};
|
|
|
|
|
2010-09-08 16:22:11 +00:00
|
|
|
#endif
|