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
|
|
|
|
|
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];
|
|
|
|
int m_MembersCount[MAX_CLIENTS];
|
|
|
|
bool m_TeeFinished[MAX_CLIENTS];
|
|
|
|
bool m_TeamLocked[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
|
|
|
|
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
|
|
|
|
2010-08-28 13:47:52 +00:00
|
|
|
bool TeamFinished(int Team);
|
2010-09-08 16:22:11 +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
|
|
|
|
2011-03-16 13:14:25 +00:00
|
|
|
//need to be very carefull using this method
|
|
|
|
void SetForceCharacterTeam(int id, int Team);
|
2014-01-11 14:19:34 +00:00
|
|
|
void ForceLeaveTeam(int id);
|
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
|
|
|
|
2011-03-16 13:14:25 +00:00
|
|
|
void SendTeamsState(int Cid);
|
2013-11-15 23:44:49 +00:00
|
|
|
void SetTeamLock(int Team, bool Lock);
|
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 SetRefreshTime(CPlayer* Player, int RefreshTime);
|
|
|
|
void SetCpActive(CPlayer* Player, int CpActive);
|
2013-07-21 06:46:52 +00:00
|
|
|
void OnTeamFinish(CPlayer** Players, unsigned int Size);
|
2011-06-06 19:24:27 +00:00
|
|
|
void OnFinish(CPlayer* Player);
|
2014-07-26 12:46:31 +00:00
|
|
|
void KillTeam(int Team);
|
2011-12-25 13:51:04 +00:00
|
|
|
bool TeeFinished(int ClientID)
|
|
|
|
{
|
|
|
|
return m_TeeFinished[ClientID];
|
|
|
|
}
|
|
|
|
;
|
|
|
|
int GetTeamState(int Team)
|
|
|
|
{
|
|
|
|
return m_TeamState[Team];
|
|
|
|
}
|
|
|
|
;
|
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-07-26 12:46:31 +00:00
|
|
|
void SetFinished(int ClientID, bool finished)
|
|
|
|
{
|
|
|
|
m_TeeFinished[ClientID] = finished;
|
|
|
|
}
|
|
|
|
;
|
2010-08-28 13:47:52 +00:00
|
|
|
};
|
|
|
|
|
2010-09-08 16:22:11 +00:00
|
|
|
#endif
|