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 64 of file C4PlayerInfoConflicts.cpp.

Constructor & Destructor Documentation

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

Definition at line 114 of file C4PlayerInfoConflicts.cpp.

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

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

Here is the call graph for this function:

C4PlayerInfoListAttributeConflictResolver::~C4PlayerInfoListAttributeConflictResolver ( )

Definition at line 137 of file C4PlayerInfoConflicts.cpp.

138 {
139  delete [] ppCheckInfos;
140 }

Member Function Documentation

void C4PlayerInfoListAttributeConflictResolver::Resolve ( )

Definition at line 381 of file C4PlayerInfoConflicts.cpp.

Referenced by C4PlayerInfoList::ResolvePlayerAttributeConflicts().

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

Here is the caller graph for this function:


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