OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4PlayerInfo.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2004-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk 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 // permanent player information management
17 //
18 // A separate list of all local and remote player infos is held here,
19 // independantely of the global C4PlayerList.
20 // This list is used for:
21 // -player information to be known before actual join
22 // (player count for landscape width, team, color, etc.)
23 // -player file resource association (network mode)
24 // -league information to be stored for each player; even after elimination
25 // *-startup loader screen information; e.g. for replays
26 //
27 // * = 2do
28 //
29 // Please note that any fields added to C4PlayerInfo will be transferred to the masterserver and back.
30 // C4RoundResults is responsible for collecting information after player elimination.
31 
32 #ifndef INC_C4PlayerInfo
33 #define INC_C4PlayerInfo
34 
35 #include "network/C4PacketBase.h"
36 #include "network/C4Network2Res.h"
37 #include "config/C4Constants.h"
38 #include "lib/C4InputValidation.h"
39 #include "object/C4Id.h"
40 
41 // information about one player at a client
43 {
44 public:
45  // player flags
46  enum Flags
47  {
48  PIF_Joined = 1 << 0, // player has joined the game
49  PIF_Removed = 1 << 2, // player has been removed
50  PIF_HasRes = 1 << 3, // pRes is set
51  PIF_JoinIssued = 1 << 4, // flag for host to mark a player for which the join is issued
52  PIF_TempFile = 1 << 5, // player file is temporary and to be deleted after join recreation
53  PIF_InScenarioFile = 1 << 6, // player file is present within the scenario; res is not to be used
54  PIF_JoinedForSavegameOnly = 1 << 7, // player file has been specified to take over a savegame player; do not join as normal player if association fails
55  PIF_Disconnected = 1 << 8, // the player was removed because his client disconnected
56  PIF_Won = 1 << 9, // player survived until game end (for game evaluation only)
57  PIF_VotedOut = 1 << 10, // player was removed from the round after a successful voting
58  PIF_AttributesFixed = 1 << 11, // player color and name aren't changed on collision
59  PIF_NoScenarioInit = 1 << 12, // do not call ScenariInit for this player
60  PIF_NoEliminationCheck = 1 << 13, // do not eliminate player if crew is empty
61  PIF_Invisible = 1 << 14, // do not show in lobby and menus
62  PIF_NoScenarioSave = 1 << 15, // not saved in SavePlayerInfos.txt if "save as scenario" is performed
63 
64  // flags to be synchronized via network and saved into player info
66 
67  // flags to be copied from savegame-player for takeover
69  };
70 
71  // player attributes used in attribute conflict resolver
74 private:
75  uint32_t dwFlags; // DWORD-mask of C4PlayerInfoFlags-constants
76  C4PlayerType eType; // user or script player
77 
79  ValidatedStdCopyStrBuf<C4InVal::VAL_NameAllowEmpty> sForcedName; // player name if a new name is forced e.g. because the current name appeared twice
80  int32_t iID; // unique ID set by host
81  C4Network2Res::Ref pRes; // player resource to load from
82  C4Network2ResCore ResCore; // core of resource to load from
83  StdCopyStrBuf szFilename; // source filename for local players
84  uint32_t dwColor; // player color
85  uint32_t dwOriginalColor, dwAlternateColor; // original player color wish
86  int32_t idSavegamePlayer; // ID of associated savegame player
87  int32_t idTeam; // team ID
88  StdCopyStrBuf szAuthID; // authentication ID (for league server, will be cleared on successful join)
89  int32_t iInGameNumber, iInGameJoinFrame, iInGamePartFrame; // information about player in game
90  C4ID idExtraData; // extra data for script players
91 
92  ValidatedStdCopyStrBuf<C4InVal::VAL_NameAllowEmpty> sLeagueAccount; // account name on league server
93  int32_t iLeagueScore; // score on league server at join time
94  int32_t iLeagueRank; // rank on league server at join time
95  int32_t iLeagueRankSymbol; // symbolization of the player's rank
96  int32_t iLeagueScoreProjected;// score on league server in case of win
97  int32_t iLeagueProjectedGain; // projected league score increase if game is won - -1 for unknown; valid values always positive
98  ValidatedStdCopyStrBuf<C4InVal::VAL_NameAllowEmpty> sClanTag; // clan ("team") tag
99  int32_t iLeaguePerformance; // script-set league performance value, only set temporarily for masterserver end reference
100  StdCopyStrBuf sLeagueProgressData; // level progress data as reported by league
101 
102 public:
103  C4PlayerInfo() // construct empty
104  : dwFlags(0), eType(C4PT_User), iID(0), pRes(0), szFilename(), dwColor(0xffffffff),
105  dwOriginalColor(0xffffffff), dwAlternateColor(0), idSavegamePlayer(0), idTeam(0), iInGameNumber(-1),
106  iInGameJoinFrame(-1), iInGamePartFrame(-1), idExtraData(C4ID::None), sLeagueAccount(""),
107  iLeagueScore(0), iLeagueRank(0), iLeagueRankSymbol(0), iLeagueProjectedGain(-1), iLeaguePerformance(0) { }
108 
109  void Clear(); // clear fields
110 
111  bool LoadFromLocalFile(const char *szFilename); // load data from local file
112  bool SetAsScriptPlayer(const char *szName, uint32_t dwColor, uint32_t dwFlags, C4ID idExtra); // set as a script (AI) player
113 
114  void SetJoined(int32_t iNumber); // mark as joined in current game frame
115  void SetJoinIssued() { dwFlags |= PIF_JoinIssued; } // mark as joined
116  void SetRemoved(); // mark as removed in current game frame - always marks as previously joined, too
117  void SetID(int32_t iToID) { iID = iToID; } // set player info ID
118  void SetColor(DWORD dwUseClr) { dwColor = dwUseClr; } // set color to be used
119  void SetOriginalColor(DWORD dwUseClr) { dwOriginalColor = dwUseClr; } // set color the player wishes to have
120  void SetFilename(const char *szToFilename); // set new player filename
121  void SetToScenarioFilename(const char *szScenFilename); // set to file within scenario; discard resource
122  void SetTempFile() { assert(!!szFilename); dwFlags |= PIF_TempFile; } // mark filename as temp, so it is deleted in dtor or after join
123  void SetTeam(int32_t idToTeam) { idTeam = idToTeam; }
124  void DeleteTempFile(); // delete filename if temp
125  void LoadResource(); // network: Load resource if present and not being loaded yet
126  void DiscardResource(); // delete any source resource for network player infos
127  void SetAssociatedSavegamePlayer(int32_t aidSavegamePlayer) // link with savegame player from restore list
128  { idSavegamePlayer=aidSavegamePlayer; }
130  { return idSavegamePlayer; }
131  void SetJoinForSavegameOnly() // flag to be deleted if savegame association fails
132  { dwFlags |= PIF_JoinedForSavegameOnly; }
133  bool IsJoinForSavegameOnly() // flag to be deleted if savegame association fails
134  { return !!(dwFlags & PIF_JoinedForSavegameOnly); }
135  bool SetSavegameResume(C4PlayerInfo *pSavegameInfo); // take over savegame player data to do resume
136  void SetAuthID(const char *sznAuthID)
137  { szAuthID = sznAuthID; }
138  void SetLeagueData(const char *szAccount, const char *szNewClanTag, int32_t iScore, int32_t iRank, int32_t iRankSymbol, const char *szProgressData)
139  { sLeagueAccount.CopyValidated(szAccount); sClanTag.CopyValidated(szNewClanTag); iLeagueScore = iScore; iLeagueRank = iRank; iLeagueRankSymbol = iRankSymbol; sLeagueProgressData.Copy(szProgressData); }
140  void SetLeaguePerformance(int32_t iNewPerf)
141  { iLeaguePerformance = iNewPerf; }
142  void SetLeagueProgressData(const char *szNewProgressData)
143  { if (szNewProgressData) sLeagueProgressData.Copy(szNewProgressData); else sLeagueProgressData.Clear(); }
144  void SetVotedOut()
145  { dwFlags |= PIF_VotedOut; }
146  void SetLeagueProjectedGain(int32_t iProjectedGain)
147  { assert(iProjectedGain>=0); iLeagueProjectedGain = iProjectedGain; }
149  { iLeagueProjectedGain = -1; }
150  void SetForcedName(const char *szNewName)
151  { if (szNewName) sForcedName.CopyValidated(szNewName); else sForcedName.Clear(); }
152 
153  void CompileFunc(StdCompiler *pComp);
154 
155  C4PlayerType GetType() const { return eType; }
156  uint32_t GetColor() const { return dwColor; } // get player color
157  uint32_t GetLobbyColor() const;
158  uint32_t GetOriginalColor() const { return dwOriginalColor; } // get original player color
159  uint32_t GetAlternateColor() const { return dwAlternateColor; } // get secondary original player color
160  const char *GetName() const { return sLeagueAccount.getLength() ? sLeagueAccount.getData() : sForcedName.getLength() ? sForcedName.getData() : sName.getData(); } // get player name
161  const char *GetOriginalName() const { return sName.getData(); }
162  const char *GetForcedName() const { return sForcedName.getData(); }
163  StdStrBuf GetLobbyName() const; // return player name including clan/team tag if known; fallback to regular player name
164  const char *GetFilename() const { return szFilename.getData(); } // get filename for local games
165  const char *GetLocalJoinFilename() const; // get name of file to join the player from
166  C4Network2Res *GetRes() const { return pRes; } // get player resource for network games
167  bool IsRemoved() const { return !!(dwFlags & PIF_Removed); }
168  bool HasJoined() const { return !!(dwFlags & PIF_Joined); } // return whether player has joined
169  bool IsJoined() const { return HasJoined() && !(dwFlags & PIF_Removed); } // return whether player is currently in the game
170  bool HasJoinIssued() const { return !!(dwFlags & (PIF_Joined | PIF_JoinIssued)); } // return whether player join is in the queue already (or performed long ago, even)
171  bool HasJoinPending() const { return !(dwFlags & (PIF_Joined | PIF_Removed)); } // return whether player join should be done but has not been performed yet
172  bool IsUsingColor() const { return !IsRemoved() && !idSavegamePlayer; } //return whether the player is actually using the player color
173  bool IsUsingName() const { return !IsRemoved() && !sLeagueAccount.getLength(); } //return whether the player is actually using the player name (e.g. not if league name is used)
174  bool IsUsingAttribute(Attribute eAttr) const { if (eAttr == PLRATT_Color) return IsUsingColor(); else return IsUsingName(); }
175  bool IsUsingPlayerFile() const { return !IsRemoved(); } //return whether the player is using the file (i.e., isn't dead yet)
176  bool IsUsingTeam() const { return !IsRemoved(); } // whether player should be in the team list
177  bool IsAttributesFixed() const { return !!(dwFlags & PIF_AttributesFixed); }
178  bool IsInvisible() const { return !!(dwFlags & PIF_Invisible); }
179  bool IsScenarioInitDesired() const { return !(dwFlags & PIF_NoScenarioInit); }
180  bool IsScenarioSaveDesired() const { return !(dwFlags & PIF_NoScenarioSave); }
181  C4ID GetScriptPlayerExtraID() const { return idExtraData; }
182  bool IsNoEliminationCheck() const { return !!(dwFlags & PIF_NoEliminationCheck); }
183  bool HasAutoGeneratedColor() { return dwColor != dwOriginalColor; } // whether the player got a new color assigned due to color conflict
184  bool HasWon() const { return !!(dwFlags & PIF_Won); }
185  bool HasTeamWon() const;
186  const char *getAuthID() const { return szAuthID.getData(); } // returns authentication ID for this player [league]
187  const char *getLeagueAccount() const { return sLeagueAccount.getData(); } // returns account name on league server
188  int32_t getLeagueScore() const { return iLeagueScore; } // returns score number on league server (0 for not assigned)
189  int32_t getLeagueRank() const { return iLeagueRank; } // returns rank on league server (0 for not assigned)
190  int32_t getLeagueRankSymbol() const { return iLeagueRankSymbol; } // returns rank symbol on league server (0 for not assigned)
191  int32_t getLeagueScoreProjected() const { return iLeagueScoreProjected; } // returns score on league server in case of win (0 for not assigned)
192  int32_t GetInGameNumber() const { return iInGameNumber; } // returns player number the player had in the game
193  bool IsLeagueProjectedGainValid() const { return iLeagueProjectedGain>=0; }
194  int32_t GetLeagueProjectedGain() const { return iLeagueProjectedGain; } // get score gain in primary league if this player's team wins
195  const char *GetLeagueProgressData() const { return sLeagueProgressData.getData(); }
196 
197  int32_t GetID() const { return iID; } // get unique ID, if assigned
198  int32_t GetTeam() const { return idTeam; }
199  bool IsTempFile() const { return !!(dwFlags & PIF_TempFile); } // return whether filename points to temp folder
200 
201  DWORD GetFlags() { return dwFlags; } // for dbg print only
202 
203  void SetDisconnected() { dwFlags |= PIF_Disconnected; }
204  void SetWinner() { dwFlags |= PIF_Won; }
205 
206  bool LoadBigIcon(C4FacetSurface &fctTarget); // load BigIcon.png of player into target facet; return false if no bigicon present or player file not yet loaded
207 };
208 
209 // player infos for one client
210 // merely a list of player infos
212 {
213 private:
214  // std::vector...
215  int32_t iPlayerCount; // number of clients registered into the list
216  int32_t iPlayerCapacity; // size of pClients-array
217  C4PlayerInfo **ppPlayers; // array of registered client information
218  void GrowList(size_t iByVal); // increase list capacity
219 
220  int32_t iClientID; // ID of client described by this packet
221 
222  // flags for this packet
223  enum Flags
224  {
225  CIF_AddPlayers = 1<<0, // if set, the players are to be added to the current list (otherwise overwrite)
226  CIF_Updated = 1<<1, // set temporarily if changed and not transmissioned to clients (valid for host only)
227  CIF_Initial = 1<<2, // set for first-time player info packets
228  CIF_Developer = 1<<3, // set for developer hosts (by regkey); client side check only!
229  CIF_Removed = 1<<4 // client was removed
230  };
231  uint32_t dwFlags; // bit mask of the above flags
232 
233 public:
234  C4ClientPlayerInfos(const char *szJoinFilenames=nullptr, bool fAdd=false, C4PlayerInfo *pAddInfo=nullptr); // ctor; sets local data (or makes an add-player-packet if filename is given) if par is true
235  C4ClientPlayerInfos(const C4ClientPlayerInfos &rCopy); // copy ctor
236  ~C4ClientPlayerInfos() { Clear(); } // dtor
237 
239 
240  void Clear(); // del all players
241  void GrabMergeFrom(C4ClientPlayerInfos &rFrom); // merge existing player info packed into this one - empties pFrom!
242  void AddInfo(C4PlayerInfo *pAddInfo); // add info to list
243  void RemoveIndexedInfo(int32_t iAtIndex); // remove info from list (delete it)
244  void RemoveInfo(int32_t idPlr); // remove info from list (delete it)
245 
246  // update-flag
247  void SetUpdated() { dwFlags |= CIF_Updated; }
248  bool IsUpdated() { return !!(dwFlags & CIF_Updated); }
249  void ResetUpdated() { dwFlags &= ~CIF_Updated; }
250  void SetAdd() { dwFlags |= CIF_AddPlayers; }
251  void ResetAdd() { dwFlags &= ~CIF_AddPlayers; }
252 
253  // query functions
254  int32_t GetPlayerCount() const { return iPlayerCount; } // get number of player infos available
255  int32_t GetFlaggedPlayerCount(DWORD dwFlag) const; // get number of player infos with any of the given flags set
256  C4PlayerInfo *GetPlayerInfo(int32_t iIndex) const; // get indexed player info
257  C4PlayerInfo *GetPlayerInfo(int32_t iIndex, C4PlayerType eType) const; // get indexed player info of given type
258  C4PlayerInfo *GetPlayerInfoByID(int32_t id) const; // get player info by unique player ID
259  C4PlayerInfo *GetPlayerInfoByRes(int32_t idResID) const; // get player info by resource ID
260  int32_t GetClientID() const { return iClientID; } // get target client ID
261  bool HasUnjoinedPlayers() const; // check all players and return whether one of them didn't join
262  int32_t GetJoinedPlayerCount() const; // return number of players that are IsJoined()
263  bool IsAddPacket() const { return !!(dwFlags & CIF_AddPlayers); } // return whether players are to be added to the current list (otherwise overwrite)
264  bool IsInitialPacket() const { return !!(dwFlags & CIF_Initial); } // returns whether this packet was sent as the first local-join packet
265  bool IsDeveloperPacket() const { return !!(dwFlags & CIF_Developer); } // returns whether packet was created by a developer host - client side check only!
266 
267  // network: Load all resources connected with the players that are not being loaded yet
268  void LoadResources();
269 
270  // pack/unpack functions
271  void CompileFunc(StdCompiler *pComp);
272 };
273 
274 // * PID_PlayerInfoUpdRequest
275 // packet containing information about one or more joined players at a client
276 // or about lobby player-info updates
278 {
279 public:
280  C4ClientPlayerInfos Info; // info for clients to be joined
281 
282  C4PacketPlayerInfoUpdRequest() : Info() { } // std ctor
283  C4PacketPlayerInfoUpdRequest(const char *szFilenames, bool fAdd) // ctor
284  : Info(szFilenames, fAdd) { };
285 
286  C4PacketPlayerInfoUpdRequest(const C4ClientPlayerInfos &rInfo) : Info(rInfo) {} // ctor
287 
288  virtual void CompileFunc(StdCompiler *pComp);
289 };
290 
291 // * PID_PlayerInfoUpd
292 // packet containing information about one or more (updated) players at a client
294 {
295 public:
296  C4ClientPlayerInfos Info; // info for clients to be updated
297  bool fIsRecreationInfo; // if set, this info packet describes savegame recreation players
298 
299  C4PacketPlayerInfo() : Info(), fIsRecreationInfo(false) { } // std ctor
300  C4PacketPlayerInfo(const C4ClientPlayerInfos &rCopyInfos, bool fRecreationPlayers) // ctor
301  : Info(rCopyInfos), fIsRecreationInfo(fRecreationPlayers) { };
302 
303  virtual void CompileFunc(StdCompiler *pComp);
304 };
305 
306 // player info list
307 // contains player info packets for all known clients and self
309 {
310 private:
311  // std::vector...
312  int32_t iClientCount; // number of clients registered into the list
313  int32_t iClientCapacity; // size of pClients-array
314  C4ClientPlayerInfos **ppClients; // array of registered client information
315  void GrowList(size_t iByVal); // increase list capacity
316 
317  int32_t iLastPlayerID; // last ID given to a player
318 
319  enum MatchingLevel { PML_PlrFileName=0, PML_PlrName, PML_PrefColor, PML_Any };
320 
321 public:
322  C4PlayerInfoList(); // ctor
323  C4PlayerInfoList(const C4PlayerInfoList &rCpy);
324  ~C4PlayerInfoList() { Clear(); } // dtor
326  void Clear(); // clear list
327 
328  // forwards player info update request to the appropriate handler
330 
331  // performs a local player join for the given player file(s)
332  bool DoLocalNonNetworkPlayerJoin(const char *szPlayerFile);
334 
335  // sets any unset IDs (host/standalone only); also removes players that would exceed the maximum player limit
336  // returns whether any players remain
337  bool AssignPlayerIDs(C4ClientPlayerInfos *pNewClientInfo);
338 
339  // assign any unset teams (host/standalone only) - fByHost determines whether packet was sent by host
340  void AssignTeams(C4ClientPlayerInfos *pNewClientInfo, bool fByHost);
341 
342  // generate teams used by the player info list if they do not exist and auto generated teams are enabled
343  // used for replays
345 
346  // add info for client; overwriting or appending to existing info if necessary
347  // this takes over the pNewClientInfo ptr, and may invalidate (delete) it!
348  // the pointer to the info structure as it is valid in the list is returned
349  // when infos are added, unset IDs will automatically be assigned (should happen for host only!)
351 
352  // resolve any color conflicts in self AND given (optional) packet. Sets Updated-flags.
354 
355  // do color updates: Savegame color assignment; team colors; duplicate attribute check
356  void UpdatePlayerAttributes(C4ClientPlayerInfos *pForInfo, bool fResolveConflicts);
357  void UpdatePlayerAttributes();
358 
359  // query functions
360  int32_t GetInfoCount() const { return iClientCount; } // get number of registered client infos
361  C4ClientPlayerInfos *GetIndexedInfo(int32_t iIndex) const // get client player infos by indexed
362  { return (ppClients && Inside<int32_t>(iIndex, 0, iClientCount-1)) ? ppClients[iIndex] : nullptr; }
363  C4ClientPlayerInfos **GetInfoPtrByClientID(int32_t iClientID) const; // get info for a specific client ID
364  C4ClientPlayerInfos *GetInfoByClientID(int32_t iClientID) const
365  { C4ClientPlayerInfos **ppNfo = GetInfoPtrByClientID(iClientID); return ppNfo ? *ppNfo : nullptr; }
366  C4PlayerInfo *GetPlayerInfoByIndex(int32_t index) const; // get player info by index (for running through all players regardless of clients or ids)
367  C4PlayerInfo *GetPlayerInfoByID(int32_t id) const; // get player info by unique player ID
368  C4PlayerInfo *GetPlayerInfoByID(int32_t id, int32_t *pidClient) const; // get player info by unique player ID, and assign associated client
369  C4ClientPlayerInfos *GetClientInfoByPlayerID(int32_t id) const; // get client info that contains a specific player
370  C4PlayerInfo *GetPlayerInfoBySavegameID(int32_t id) const;// get player info by savegame association ID
371  C4PlayerInfo *GetNextPlayerInfoByID(int32_t id) const; // get player info with smallest ID > given id
372  C4PlayerInfo *GetActivePlayerInfoByName(const char *szName); // find info by name (case insensitive)
373  int32_t GetPlayerCount() const; // get number of players on all clients
374  int32_t GetJoinIssuedPlayerCount() const; // get number of players with PIF_JoinIssued-flag set
375  int32_t GetJoinPendingPlayerCount() const; // get number of players with PIF_JoinIssued-flag but not joined or removed flag set
376  int32_t GetActivePlayerCount(bool fCountInvisible) const; // get number of players that have not been removed
377  StdStrBuf GetActivePlayerNames(bool fCountInvisible, int32_t iAtClientID=-1) const; // get a comma-separated list of players that have not been removed yet
378  int32_t GetActiveScriptPlayerCount(bool fCountSavegameResumes, bool fCountInvisible) const; // get number of script players that have not been removed
379  C4PlayerInfo *GetPrimaryInfoByClientID(int32_t iClientID) const
380  {
381  C4ClientPlayerInfos *pInfoPkt = GetInfoByClientID(iClientID);
382  if (!pInfoPkt) return nullptr;
383  return pInfoPkt->GetPlayerInfo(0);
384  }
385  C4PlayerInfo *FindSavegameResumePlayerInfo(const C4PlayerInfo *pMatchInfo, MatchingLevel mlMatchStart, MatchingLevel mlMatchEnd) const; // automatic savegame player association: Associate by name (or prefcolor, if none matches)
386  bool HasSameTeamPlayers(int32_t iClient1, int32_t iClient2) const; // check all active players; return true if two of them on different clients are in the same team
387  C4PlayerInfo *FindUnassociatedRestoreInfo(const C4PlayerInfoList &rRestoreInfoList); // find a player in the given list that has not been associated by a player in this list
388 
389  void RemoveInfo(C4ClientPlayerInfos **ppRemoveInfo) // remove client info given by direct ptr into list
390  { *ppRemoveInfo = ppClients[--iClientCount]; /* maybe redundant self-assignment; no vector shrink */ }
391 
392 public:
393  bool Load(C4Group &hGroup, const char *szFromFile, class C4LangStringTable *pLang=nullptr); // clear self and load from group file
394  bool Save(C4Group &hGroup, const char *szToFile); // save to group file
395 
396  // external ID counter manipulation used by C4Game
397  void SetIDCounter(int32_t idNewCounter) { iLastPlayerID = idNewCounter; }
398  int32_t GetIDCounter() { return iLastPlayerID; }
399  void FixIDCounter(); // make sure ID counter is same as largest info
400 
401  // game interaction
402  bool InitLocal(); // put locally joining players into list (non-network)
403  bool LocalJoinUnjoinedPlayersInQueue(); // join all unjoined players to local input queue
404  int32_t GetStartupCount(); // get number of players already joined and to be joined
405  void CreateRestoreInfosForJoinedScriptPlayers(C4PlayerInfoList &rSavegamePlayers); // create matching script player joins for all script playeers in restore info
406  bool RecreatePlayers(C4ValueNumbers *); // directly join all players whose join-flag is set
407  bool RecreatePlayerFiles(); // update player source files
408  bool RestoreSavegameInfos(C4PlayerInfoList &rSavegamePlayers); // recreate this list from rSavegamePlayers for host/single games; just merge associated infos
409  bool SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fSaveUserPlrs, bool fSaveScriptPlrs, bool fSetUserPlrRefToLocalGroup, bool fSetScriptPlrRefToLocalGroup); // copy all joined players from player list
410  void RemoveUnassociatedPlayers(C4PlayerInfoList &rSavegamePlayers); // remove all savegame players that are not associated to this list from the game
411  int32_t GetFreePlayerSlotCount(); // get number of players that may still join
412  void ResetLeagueProjectedGain(bool fSetUpdated); // reset known projected gains for all players (to be updated by league again)
413 
414  // network: Load all resources connected with the players that are not being loaded yet
415  void LoadResources();
416 
417  // compiler
418  void CompileFunc(StdCompiler *pComp);
419 };
420 
421 #endif // INC_C4PlayerInfo
bool HasJoinPending() const
Definition: C4PlayerInfo.h:171
int32_t GetJoinedPlayerCount() const
const char * getData() const
Definition: StdBuf.h:450
const char * GetOriginalName() const
Definition: C4PlayerInfo.h:161
void CompileFunc(StdCompiler *pComp)
C4ClientPlayerInfos & operator=(const C4ClientPlayerInfos &rCopy)
void SetColor(DWORD dwUseClr)
Definition: C4PlayerInfo.h:118
C4Network2Res * GetRes() const
Definition: C4PlayerInfo.h:166
void SetToScenarioFilename(const char *szScenFilename)
C4PlayerInfoList & operator=(const C4PlayerInfoList &rCpy)
void CompileFunc(StdCompiler *pComp)
const char * GetName() const
Definition: C4PlayerInfo.h:160
void SetDisconnected()
Definition: C4PlayerInfo.h:203
virtual void CompileFunc(StdCompiler *pComp)
int32_t getLeagueRankSymbol() const
Definition: C4PlayerInfo.h:190
void RemoveInfo(int32_t idPlr)
int32_t GetJoinPendingPlayerCount() const
void AddInfo(C4PlayerInfo *pAddInfo)
void SetIDCounter(int32_t idNewCounter)
Definition: C4PlayerInfo.h:397
int32_t GetPlayerCount() const
void SetFilename(const char *szToFilename)
void SetForcedName(const char *szNewName)
Definition: C4PlayerInfo.h:150
bool SetAsRestoreInfos(C4PlayerInfoList &rFromPlayers, bool fSaveUserPlrs, bool fSaveScriptPlrs, bool fSetUserPlrRefToLocalGroup, bool fSetScriptPlrRefToLocalGroup)
bool IsJoinForSavegameOnly()
Definition: C4PlayerInfo.h:133
C4PlayerInfo * FindSavegameResumePlayerInfo(const C4PlayerInfo *pMatchInfo, MatchingLevel mlMatchStart, MatchingLevel mlMatchEnd) const
void Clear()
Definition: StdBuf.h:474
bool HasWon() const
Definition: C4PlayerInfo.h:184
C4PlayerInfo * GetPlayerInfoByRes(int32_t idResID) const
void SetLeagueProjectedGain(int32_t iProjectedGain)
Definition: C4PlayerInfo.h:146
void SetTeam(int32_t idToTeam)
Definition: C4PlayerInfo.h:123
void SetAuthID(const char *sznAuthID)
Definition: C4PlayerInfo.h:136
void RemoveInfo(C4ClientPlayerInfos **ppRemoveInfo)
Definition: C4PlayerInfo.h:389
bool RecreatePlayers(C4ValueNumbers *)
uint32_t GetLobbyColor() const
int32_t GetFreePlayerSlotCount()
C4ClientPlayerInfos Info
Definition: C4PlayerInfo.h:296
void RecheckAutoGeneratedTeams()
C4PlayerInfo * GetPlayerInfoByIndex(int32_t index) const
bool IsInvisible() const
Definition: C4PlayerInfo.h:178
void UpdatePlayerAttributes()
C4PlayerInfo * GetPrimaryInfoByClientID(int32_t iClientID) const
Definition: C4PlayerInfo.h:379
bool IsNoEliminationCheck() const
Definition: C4PlayerInfo.h:182
bool HasAutoGeneratedColor()
Definition: C4PlayerInfo.h:183
void RemoveUnassociatedPlayers(C4PlayerInfoList &rSavegamePlayers)
bool SetAsScriptPlayer(const char *szName, uint32_t dwColor, uint32_t dwFlags, C4ID idExtra)
const char * getLeagueAccount() const
Definition: C4PlayerInfo.h:187
C4ClientPlayerInfos ** GetInfoPtrByClientID(int32_t iClientID) const
uint32_t GetOriginalColor() const
Definition: C4PlayerInfo.h:158
C4PlayerInfo * GetNextPlayerInfoByID(int32_t id) const
virtual void CompileFunc(StdCompiler *pComp)
void DiscardResource()
bool IsDeveloperPacket() const
Definition: C4PlayerInfo.h:265
StdStrBuf GetLobbyName() const
void CompileFunc(StdCompiler *pComp)
C4ClientPlayerInfos * GetIndexedInfo(int32_t iIndex) const
Definition: C4PlayerInfo.h:361
C4PlayerInfo * GetPlayerInfoByID(int32_t id) const
void AssignTeams(C4ClientPlayerInfos *pNewClientInfo, bool fByHost)
bool IsInitialPacket() const
Definition: C4PlayerInfo.h:264
bool Save(C4Group &hGroup, const char *szToFile)
C4ClientPlayerInfos * GetClientInfoByPlayerID(int32_t id) const
int32_t getLeagueRank() const
Definition: C4PlayerInfo.h:189
bool IsAddPacket() const
Definition: C4PlayerInfo.h:263
const char * GetLocalJoinFilename() const
bool HasTeamWon() const
C4PacketPlayerInfoUpdRequest(const char *szFilenames, bool fAdd)
Definition: C4PlayerInfo.h:283
void GrabMergeFrom(C4ClientPlayerInfos &rFrom)
C4PlayerInfo * GetPlayerInfo(int32_t iIndex) const
int32_t getLeagueScoreProjected() const
Definition: C4PlayerInfo.h:191
bool IsUsingColor() const
Definition: C4PlayerInfo.h:172
int32_t GetJoinIssuedPlayerCount() const
int32_t GetAssociatedSavegamePlayerID() const
Definition: C4PlayerInfo.h:129
bool LocalJoinUnjoinedPlayersInQueue()
C4ClientPlayerInfos * AddInfo(C4ClientPlayerInfos *pNewClientInfo)
bool DoLocalNonNetworkPlayerJoin(const char *szPlayerFile)
void SetVotedOut()
Definition: C4PlayerInfo.h:144
bool DoPlayerInfoUpdate(C4ClientPlayerInfos *pUpdate)
bool IsJoined() const
Definition: C4PlayerInfo.h:169
C4ID GetScriptPlayerExtraID() const
Definition: C4PlayerInfo.h:181
int32_t GetClientID() const
Definition: C4PlayerInfo.h:260
const char * GetLeagueProgressData() const
Definition: C4PlayerInfo.h:195
void DeleteTempFile()
int32_t GetTeam() const
Definition: C4PlayerInfo.h:198
C4PlayerInfo * FindUnassociatedRestoreInfo(const C4PlayerInfoList &rRestoreInfoList)
int32_t GetPlayerCount() const
Definition: C4PlayerInfo.h:254
int32_t GetInfoCount() const
Definition: C4PlayerInfo.h:360
bool IsRemoved() const
Definition: C4PlayerInfo.h:167
bool HasJoinIssued() const
Definition: C4PlayerInfo.h:170
C4ClientPlayerInfos Info
Definition: C4PlayerInfo.h:280
void SetTempFile()
Definition: C4PlayerInfo.h:122
C4PlayerInfo * GetActivePlayerInfoByName(const char *szName)
StdStrBuf GetActivePlayerNames(bool fCountInvisible, int32_t iAtClientID=-1) const
int32_t getLeagueScore() const
Definition: C4PlayerInfo.h:188
bool IsUsingTeam() const
Definition: C4PlayerInfo.h:176
Definition: C4Id.h:28
C4PlayerType
Definition: C4Constants.h:152
C4ClientPlayerInfos * GetInfoByClientID(int32_t iClientID) const
Definition: C4PlayerInfo.h:364
void SetID(int32_t iToID)
Definition: C4PlayerInfo.h:117
bool IsUsingName() const
Definition: C4PlayerInfo.h:173
int32_t GetStartupCount()
bool IsScenarioInitDesired() const
Definition: C4PlayerInfo.h:179
bool RestoreSavegameInfos(C4PlayerInfoList &rSavegamePlayers)
void SetJoinIssued()
Definition: C4PlayerInfo.h:115
int32_t GetLeagueProjectedGain() const
Definition: C4PlayerInfo.h:194
bool Load(C4Group &hGroup, const char *szFromFile, class C4LangStringTable *pLang=nullptr)
const char * GetForcedName() const
Definition: C4PlayerInfo.h:162
uint32_t GetColor() const
Definition: C4PlayerInfo.h:156
const char * GetFilename() const
Definition: C4PlayerInfo.h:164
bool IsLeagueProjectedGainValid() const
Definition: C4PlayerInfo.h:193
C4ClientPlayerInfos(const char *szJoinFilenames=nullptr, bool fAdd=false, C4PlayerInfo *pAddInfo=nullptr)
void SetJoinForSavegameOnly()
Definition: C4PlayerInfo.h:131
void SetOriginalColor(DWORD dwUseClr)
Definition: C4PlayerInfo.h:119
C4PacketPlayerInfoUpdRequest(const C4ClientPlayerInfos &rInfo)
Definition: C4PlayerInfo.h:286
void SetLeaguePerformance(int32_t iNewPerf)
Definition: C4PlayerInfo.h:140
C4PacketPlayerInfo(const C4ClientPlayerInfos &rCopyInfos, bool fRecreationPlayers)
Definition: C4PlayerInfo.h:300
bool SetSavegameResume(C4PlayerInfo *pSavegameInfo)
bool LoadFromLocalFile(const char *szFilename)
int32_t GetInGameNumber() const
Definition: C4PlayerInfo.h:192
void ResolvePlayerAttributeConflicts(C4ClientPlayerInfos *pSecPacket)
bool IsScenarioSaveDesired() const
Definition: C4PlayerInfo.h:180
int32_t GetActiveScriptPlayerCount(bool fCountSavegameResumes, bool fCountInvisible) const
bool IsUsingAttribute(Attribute eAttr) const
Definition: C4PlayerInfo.h:174
void SetLeagueProgressData(const char *szNewProgressData)
Definition: C4PlayerInfo.h:142
void SetAssociatedSavegamePlayer(int32_t aidSavegamePlayer)
Definition: C4PlayerInfo.h:127
void RemoveIndexedInfo(int32_t iAtIndex)
int32_t GetIDCounter()
Definition: C4PlayerInfo.h:398
bool HasUnjoinedPlayers() const
DWORD GetFlags()
Definition: C4PlayerInfo.h:201
size_t getLength() const
Definition: StdBuf.h:453
int32_t GetID() const
Definition: C4PlayerInfo.h:197
C4PlayerInfo * GetPlayerInfoByID(int32_t id) const
C4PlayerType GetType() const
Definition: C4PlayerInfo.h:155
bool IsUsingPlayerFile() const
Definition: C4PlayerInfo.h:175
int32_t GetActivePlayerCount(bool fCountInvisible) const
uint32_t GetAlternateColor() const
Definition: C4PlayerInfo.h:159
const char * getAuthID() const
Definition: C4PlayerInfo.h:186
bool DoLocalNonNetworkPlayerInfoUpdate(C4ClientPlayerInfos *pUpdate)
uint32_t DWORD
bool AssignPlayerIDs(C4ClientPlayerInfos *pNewClientInfo)
void SetLeagueData(const char *szAccount, const char *szNewClanTag, int32_t iScore, int32_t iRank, int32_t iRankSymbol, const char *szProgressData)
Definition: C4PlayerInfo.h:138
void ResetLeagueProjectedGain(bool fSetUpdated)
C4PlayerInfo * GetPlayerInfoBySavegameID(int32_t id) const
void ResetLeagueProjectedGain()
Definition: C4PlayerInfo.h:148
bool HasJoined() const
Definition: C4PlayerInfo.h:168
void Copy()
Definition: StdBuf.h:475
bool IsAttributesFixed() const
Definition: C4PlayerInfo.h:177
void CopyValidated(const char *szFromVal)
void CreateRestoreInfosForJoinedScriptPlayers(C4PlayerInfoList &rSavegamePlayers)
int32_t GetFlaggedPlayerCount(DWORD dwFlag) const
bool LoadBigIcon(C4FacetSurface &fctTarget)
void SetJoined(int32_t iNumber)
void LoadResource()
bool HasSameTeamPlayers(int32_t iClient1, int32_t iClient2) const
void SetWinner()
Definition: C4PlayerInfo.h:204
bool IsTempFile() const
Definition: C4PlayerInfo.h:199