OpenClonk
C4PlayerList.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 
18 /* Dynamic list to hold runtime player data */
19 
20 #ifndef INC_C4PlayerList
21 #define INC_C4PlayerList
22 
23 #include "control/C4PlayerInfo.h"
24 
26 {
27 public:
28  C4PlayerList();
29  ~C4PlayerList();
30 public:
32 public:
33  void Default();
34  void Clear();
35  void Execute();
36  void DenumeratePointers();
37  void ClearPointers(C4Object *pObj);
38  int GetCount() const;
39  int GetCount(C4PlayerType eType) const;
40  int GetIndex(C4Player *pPlr) const;
41  int GetCountNotEliminated() const;
42  int AverageScoreGain() const;
43  C4Player *Get(int iPlayer) const;
44  C4Player *GetByIndex(int iIndex) const;
45  C4Player *GetByIndex(int iIndex, C4PlayerType eType) const;
46  C4Player *GetByName(const char *szName, int iExcluding=NO_OWNER) const;
47  C4Player *GetLocalByIndex(int iIndex) const;
48  C4Player *GetAtClient(int iClient, int iIndex=0) const;
49  C4Player *GetAtClient(const char *szName, int iIndex=0) const;
50  C4Player *GetAtRemoteClient(int iIndex=0) const;
51  C4Player *GetByInfoID(int iInfoID) const;
52  C4Player *Join(const char *szFilename, bool fScenarioInit, int iAtClient, const char *szAtClientName, class C4PlayerInfo *pInfo, C4ValueNumbers *);
53  void JoinNew(const char *szFilename);
54  bool CtrlJoin(const class C4Network2ResCore &ResCore, int iClientID, int idPlayerInfo);
55  bool FileInUse(const char *szFilename) const;
56  bool Retire(C4Player *pPlr);
57  bool Evaluate();
58  bool Save(bool fSaveLocalOnly);
59  bool Save(C4Group &hGroup, bool fStoreTiny, const C4PlayerInfoList &rStoreList); // save all players present in the restore list
60  bool Remove(int iPlayer, bool fDisonnected, bool fNoCalls);
61  bool RemoveUnjoined(int32_t iPlayer); // remove player objects only
62  bool Remove(C4Player *pPlr, bool fDisonnected, bool fNoCalls);
63  bool RemoveAtRemoteClient(bool fDisonnected, bool fNoCalls);
64  bool RemoveLocal(bool fDisonnected, bool fNoCalls);
65  bool MouseControlTaken() const;
66  bool RemoveAtClient(int iClient, bool fDisconnect);
67  bool RemoveAtClient(const char *szName, bool fDisconnect);
68  bool CtrlRemove(int iPlayer, bool fDisonnected);
69  bool CtrlRemoveAtClient(int iClient, bool fDisonnected);
70  bool CtrlRemoveAtClient(const char *szName, bool fDisonnected);
71  bool Valid(int iPlayer) const;
72  bool Hostile(int iPlayer1, int iPlayer2) const;
73  bool HostilityDeclared(int iPlayer1, int iPlayer2) const; // check whether iPlayer1 treats iPlayer2 as hostile, but not vice versa!
74  bool PositionTaken(int iPosition) const;
75  int CheckColorDw(DWORD dwColor, C4Player *pExclude); // return minimum difference to the other player's colors
76  bool SynchronizeLocalFiles(); // syncrhonize all local player files; resetting InGame times
77  bool HasPlayerInTeamSelection(); // Return whether any player is in the pre-join team selection dialogue
78 protected:
79  int GetFreeNumber() const;
80  void RecheckPlayerSort(C4Player *pForPlayer);
81 
82  friend class C4Player;
83 };
84 extern C4PlayerList Players;
85 
86 int32_t ValidPlr(int32_t plr);
87 int32_t Hostile(int32_t plr1, int32_t plr2);
88 #endif
C4PlayerType
Definition: C4Constants.h:152
const int NO_OWNER
Definition: C4Constants.h:137
C4PlayerList Players
int32_t Hostile(int32_t plr1, int32_t plr2)
int32_t ValidPlr(int32_t plr)
uint32_t DWORD
void ClearPointers(C4Object *pObj)
bool Remove(int iPlayer, bool fDisonnected, bool fNoCalls)
C4Player * GetAtRemoteClient(int iIndex=0) const
C4Player * Join(const char *szFilename, bool fScenarioInit, int iAtClient, const char *szAtClientName, class C4PlayerInfo *pInfo, C4ValueNumbers *)
int CheckColorDw(DWORD dwColor, C4Player *pExclude)
C4Player * GetAtClient(int iClient, int iIndex=0) const
bool Hostile(int iPlayer1, int iPlayer2) const
C4Player * GetByInfoID(int iInfoID) const
C4Player * GetByIndex(int iIndex) const
bool MouseControlTaken() const
bool RemoveUnjoined(int32_t iPlayer)
void DenumeratePointers()
C4Player * GetByName(const char *szName, int iExcluding=NO_OWNER) const
C4Player * Get(int iPlayer) const
bool FileInUse(const char *szFilename) const
int AverageScoreGain() const
C4Player * First
Definition: C4PlayerList.h:31
bool Retire(C4Player *pPlr)
void RecheckPlayerSort(C4Player *pForPlayer)
bool RemoveAtClient(int iClient, bool fDisconnect)
bool PositionTaken(int iPosition) const
int GetCountNotEliminated() const
bool HasPlayerInTeamSelection()
bool RemoveLocal(bool fDisonnected, bool fNoCalls)
bool SynchronizeLocalFiles()
int GetIndex(C4Player *pPlr) const
void JoinNew(const char *szFilename)
bool Save(bool fSaveLocalOnly)
int GetFreeNumber() const
C4Player * GetLocalByIndex(int iIndex) const
bool CtrlJoin(const class C4Network2ResCore &ResCore, int iClientID, int idPlayerInfo)
bool CtrlRemoveAtClient(int iClient, bool fDisonnected)
bool HostilityDeclared(int iPlayer1, int iPlayer2) const
bool RemoveAtRemoteClient(bool fDisonnected, bool fNoCalls)
bool CtrlRemove(int iPlayer, bool fDisonnected)
int GetCount() const
bool Valid(int iPlayer) const