1/*
2 * LegacyClonk
3 *
4 * Copyright (c) 1998-2000, Matthes Bender (RedWolf Design)
5 * Copyright (c) 2017-2020, The LegacyClonk Team and contributors
6 *
7 * Distributed under the terms of the ISC license; see accompanying file
8 * "COPYING" for details.
9 *
10 * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11 * See accompanying file "TRADEMARK" for details.
12 *
13 * To redistribute this file separately, substitute the full license texts
14 * for the above references.
15 */
16
17/* Dynamic list to hold runtime player data */
18
19#pragma once
20
21#include "C4ForwardDeclarations.h"
22#include "C4PlayerInfo.h"
23
24class C4Player;
25class C4PlayerInfoList;
26
27class C4PlayerList
28{
29public:
30 C4PlayerList();
31 ~C4PlayerList();
32
33public:
34 C4Player *First;
35
36public:
37 void Default();
38 void Clear();
39 void Execute();
40 void DenumeratePointers();
41 void EnumeratePointers();
42 void ClearPointers(C4Object *pObj);
43 int GetCount() const;
44 int GetCount(C4PlayerType eType) const;
45 int GetCountNotEliminated() const;
46 int AverageValueGain() const;
47 C4Player *Get(int iPlayer) const;
48 C4Player *GetByIndex(int iIndex) const;
49 C4Player *GetByIndex(int iIndex, C4PlayerType eType) const;
50 C4Player *GetByName(const char *szName, int iExcluding = NO_OWNER) const;
51 C4Player *GetLocalByKbdSet(int iKbdSet) const;
52 C4Player *GetLocalByIndex(int iIndex) const;
53 C4Player *GetAtClient(int iClient, int iIndex = 0) const;
54 C4Player *GetAtRemoteClient(int iIndex = 0) const;
55 C4Player *GetByInfoID(int iInfoID) const;
56 C4Player *Join(const char *szFilename, bool fScenarioInit, int iAtClient, const char *szAtClientName, class C4PlayerInfo *pInfo);
57 bool CtrlJoinLocalNoNetwork(const char *szFilename, int iAtClient, const char *szAtClientName);
58 bool FileInUse(const char *szFilename) const;
59 bool Retire(C4Player *pPlr);
60 bool Evaluate();
61 bool Save(bool fSaveLocalOnly);
62 bool Save(C4Group &hGroup, bool fStoreTiny, const C4PlayerInfoList &rStoreList); // save all players present in the restore list
63 bool Remove(int iPlayer, bool fDisonnected, bool fNoCalls);
64 bool RemoveUnjoined(int32_t iPlayer); // remove player objects only
65 bool Remove(C4Player *pPlr, bool fDisonnected, bool fNoCalls);
66 bool RemoveAtRemoteClient(bool fDisonnected, bool fNoCalls);
67 bool RemoveLocal(bool fDisonnected, bool fNoCalls);
68 bool MouseControlTaken() const;
69 bool RemoveAtClient(int iClient, bool fDisconnect);
70 bool CtrlRemove(int iPlayer, 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 bool ColorTaken(int iColor) const;
76 bool ControlTaken(int iControl) const;
77 bool SynchronizeLocalFiles(); // syncrhonize all local player files; resetting InGame times
78 void ClearLocalPlayerPressedComs();
79
80protected:
81 int GetFreeNumber() const;
82 void RecheckPlayerSort(C4Player *pForPlayer);
83
84 friend class C4Player;
85};
86