OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4PlayerInfoListAttributeConflictResolver Class Reference

Public Member Functions

 C4PlayerInfoListAttributeConflictResolver (C4PlayerInfoList &rPriCheckList, const C4PlayerInfoList &rSecCheckList, C4ClientPlayerInfos *pSecPacket)
 
 ~C4PlayerInfoListAttributeConflictResolver ()
 
void Resolve ()
 

Detailed Description

Definition at line 63 of file C4PlayerInfoConflicts.cpp.

Constructor & Destructor Documentation

C4PlayerInfoListAttributeConflictResolver::C4PlayerInfoListAttributeConflictResolver ( C4PlayerInfoList rPriCheckList,
const C4PlayerInfoList rSecCheckList,
C4ClientPlayerInfos pSecPacket 
)

Definition at line 113 of file C4PlayerInfoConflicts.cpp.

References C4PlayerInfoList::GetIndexedInfo(), and C4PlayerInfoList::GetInfoCount().

114  : ppCheckInfos(nullptr), iCheckInfoCount(0), rPriCheckList(rPriCheckList), rSecCheckList(rSecCheckList), pSecPacket(pSecPacket)
115 {
116  // prepare check array
117  int32_t iMaxCheckCount = rPriCheckList.GetInfoCount() + !!pSecPacket;
118  if (!iMaxCheckCount) return;
119  ppCheckInfos = new C4ClientPlayerInfos *[iMaxCheckCount];
120  // resolve all primary packets in reverse order, so late clients have lower priority
121  for (int32_t i=0; i<rPriCheckList.GetInfoCount(); ++i)
122  {
123  C4ClientPlayerInfos *pInfos = rPriCheckList.GetIndexedInfo(i);
124  if (pInfos != pSecPacket) // skip packet if it was explicitly passed for update
125  ppCheckInfos[iCheckInfoCount++] = pInfos;
126  else
127  {
128  // if the additional packet is in the list already, it needn't be a check packed (only resolve packet)
129  this->pSecPacket = nullptr;
130  }
131  }
132  // must check sec packet first
133  if (pSecPacket) ppCheckInfos[iCheckInfoCount++] = pSecPacket;
134 }
C4ClientPlayerInfos * GetIndexedInfo(int32_t iIndex) const
Definition: C4PlayerInfo.h:358
int32_t GetInfoCount() const
Definition: C4PlayerInfo.h:357

Here is the call graph for this function:

C4PlayerInfoListAttributeConflictResolver::~C4PlayerInfoListAttributeConflictResolver ( )

Definition at line 136 of file C4PlayerInfoConflicts.cpp.

137 {
138  delete [] ppCheckInfos;
139 }

Member Function Documentation

void C4PlayerInfoListAttributeConflictResolver::Resolve ( )

Definition at line 380 of file C4PlayerInfoConflicts.cpp.

Referenced by C4PlayerInfoList::ResolvePlayerAttributeConflicts().

381 {
382  // resolve in all packets in list until list is empty
383  // resolving in reverse order, because highest priority first in the list
384  while (iCheckInfoCount)
385  {
386  pResolvePacket = ppCheckInfos[--iCheckInfoCount];
387  ResolveInPacket();
388  }
389 }

Here is the caller graph for this function:


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