OpenClonk
C4RoundResultsPlayers Class Reference

#include <C4RoundResults.h>

Public Member Functions

 C4RoundResultsPlayers ()=default
 
 C4RoundResultsPlayers (const C4RoundResultsPlayers &cpy)
 
 ~C4RoundResultsPlayers ()
 
void Clear ()
 
void CompileFunc (StdCompiler *pComp)
 
C4RoundResultsPlayerGetByIndex (int32_t idx) const
 
C4RoundResultsPlayerGetByID (int32_t id) const
 
int32_t GetCount () const
 
void Add (C4RoundResultsPlayer *pNewPlayer)
 
C4RoundResultsPlayerGetCreateByID (int32_t id)
 
bool operator== (const C4RoundResultsPlayers &cmp)
 
C4RoundResultsPlayersoperator= (const C4RoundResultsPlayers &cpy)
 

Detailed Description

Definition at line 93 of file C4RoundResults.h.

Constructor & Destructor Documentation

◆ C4RoundResultsPlayers() [1/2]

C4RoundResultsPlayers::C4RoundResultsPlayers ( )
default

◆ C4RoundResultsPlayers() [2/2]

C4RoundResultsPlayers::C4RoundResultsPlayers ( const C4RoundResultsPlayers cpy)
inline

Definition at line 102 of file C4RoundResults.h.

102 { *this=cpy; }

◆ ~C4RoundResultsPlayers()

C4RoundResultsPlayers::~C4RoundResultsPlayers ( )
inline

Definition at line 103 of file C4RoundResults.h.

103 { Clear(); }

References Clear().

Here is the call graph for this function:

Member Function Documentation

◆ Add()

void C4RoundResultsPlayers::Add ( C4RoundResultsPlayer pNewPlayer)

Definition at line 197 of file C4RoundResults.cpp.

198 {
199  assert(pNewPlayer);
200  if (iPlayerCount == iPlayerCapacity) GrowList(4);
201  ppPlayers[iPlayerCount++] = pNewPlayer;
202 }

Referenced by GetCreateByID(), and operator=().

Here is the caller graph for this function:

◆ Clear()

void C4RoundResultsPlayers::Clear ( )

Definition at line 138 of file C4RoundResults.cpp.

139 {
140  while (iPlayerCount) delete ppPlayers[--iPlayerCount];
141  delete [] ppPlayers;
142  ppPlayers = nullptr;
143  iPlayerCapacity = 0;
144 }

Referenced by C4RoundResults::Clear(), CompileFunc(), operator=(), and ~C4RoundResultsPlayers().

Here is the caller graph for this function:

◆ CompileFunc()

void C4RoundResultsPlayers::CompileFunc ( StdCompiler pComp)

Definition at line 146 of file C4RoundResults.cpp.

147 {
148  bool deserializing = pComp->isDeserializer();
149  if (deserializing) Clear();
150  int32_t iTemp = iPlayerCount;
151  pComp->Value(mkNamingCountAdapt<int32_t>(iTemp, "Player"));
152  if (iTemp < 0 || iTemp > C4MaxPlayer)
153  { pComp->excCorrupt("player count out of range"); return; }
154  // Grow list, if necessary
155  if (deserializing && iTemp > iPlayerCapacity)
156  {
157  GrowList(iTemp - iPlayerCapacity);
158  iPlayerCount = iTemp;
159  ZeroMem(ppPlayers, sizeof(*ppPlayers) * iPlayerCount);
160  }
161  // Compile
162  pComp->Value(mkNamingAdapt(mkArrayAdaptMap(ppPlayers, iPlayerCount, mkPtrAdaptNoNull<C4RoundResultsPlayer>), "Player"));
163  // Force specialization
164  mkPtrAdaptNoNull<C4RoundResultsPlayer>(*ppPlayers);
165 }
const int32_t C4MaxPlayer
Definition: C4Player.h:37
std::enable_if< std::is_pod< T >::value >::type ZeroMem(T *lpMem, size_t dwSize)
Definition: Standard.h:60
StdArrayAdapt< T, M > mkArrayAdaptMap(T *pArray, int iSize, M &&map)
Definition: StdAdaptors.h:340
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
void excCorrupt(const char *szMessage,...)
Definition: StdCompiler.h:249
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53

References C4MaxPlayer, Clear(), StdCompiler::excCorrupt(), StdCompiler::isDeserializer(), mkArrayAdaptMap(), mkNamingAdapt(), StdCompiler::Value(), and ZeroMem().

Here is the call graph for this function:

◆ GetByID()

C4RoundResultsPlayer * C4RoundResultsPlayers::GetByID ( int32_t  id) const

Definition at line 175 of file C4RoundResults.cpp.

176 {
177  for (int32_t idx=0; idx<iPlayerCount; ++idx)
178  if (ppPlayers[idx]->GetID() == id)
179  return ppPlayers[idx];
180  return nullptr;
181 }

Referenced by GetCreateByID(), and C4RoundResults::GetLeaguePerformance().

Here is the caller graph for this function:

◆ GetByIndex()

C4RoundResultsPlayer * C4RoundResultsPlayers::GetByIndex ( int32_t  idx) const

Definition at line 167 of file C4RoundResults.cpp.

168 {
169  if (idx>=0 && idx<iPlayerCount)
170  return ppPlayers[idx];
171  else
172  return nullptr;
173 }

Referenced by C4RoundResults::EvaluateLeague(), and operator=().

Here is the caller graph for this function:

◆ GetCount()

int32_t C4RoundResultsPlayers::GetCount ( ) const
inline

Definition at line 115 of file C4RoundResults.h.

115 { return iPlayerCount; }

◆ GetCreateByID()

C4RoundResultsPlayer * C4RoundResultsPlayers::GetCreateByID ( int32_t  id)

Definition at line 204 of file C4RoundResults.cpp.

205 {
206  assert(id);
207  // find existing
208  C4RoundResultsPlayer *pPlr = GetByID(id);
209  // not found: Add new
210  if (!pPlr)
211  {
212  pPlr = new C4RoundResultsPlayer();
213  pPlr->SetID(id);
214  Add(pPlr);
215  }
216  return pPlr;
217 }
void SetID(int32_t idNew)
C4RoundResultsPlayer * GetByID(int32_t id) const
void Add(C4RoundResultsPlayer *pNewPlayer)

References Add(), GetByID(), and C4RoundResultsPlayer::SetID().

Referenced by C4RoundResults::AddCustomEvaluationString(), C4RoundResults::EvaluateLeague(), C4RoundResults::EvaluatePlayer(), and C4RoundResults::SetLeaguePerformance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

C4RoundResultsPlayers & C4RoundResultsPlayers::operator= ( const C4RoundResultsPlayers cpy)

Definition at line 229 of file C4RoundResults.cpp.

230 {
231  Clear();
232  C4RoundResultsPlayer *pPlr; int32_t i=0;
233  while ((pPlr = cpy.GetByIndex(i++)))
234  Add(new C4RoundResultsPlayer(*pPlr));
235  return *this;
236 }
C4RoundResultsPlayer * GetByIndex(int32_t idx) const

References Add(), Clear(), and GetByIndex().

Here is the call graph for this function:

◆ operator==()

bool C4RoundResultsPlayers::operator== ( const C4RoundResultsPlayers cmp)

Definition at line 219 of file C4RoundResults.cpp.

220 {
221  if (iPlayerCount != cmp.iPlayerCount) return false;
222  for (int32_t i = 0; i < iPlayerCount; ++i)
223  if (!(*ppPlayers[i] == *cmp.ppPlayers[i]))
224  return false;
225  // equal
226  return true;
227 }

The documentation for this class was generated from the following files: