OpenClonk
C4PacketResDiscover Class Reference

#include <C4Network2Res.h>

Inheritance diagram for C4PacketResDiscover:
[legend]
Collaboration diagram for C4PacketResDiscover:
[legend]

Public Member Functions

 C4PacketResDiscover ()
 
int32_t getDisIDCnt () const
 
int32_t getDisID (int32_t i) const
 
bool isIDPresent (int32_t iID) const
 
bool AddDisID (int32_t iID)
 
void CompileFunc (StdCompiler *pComp) override
 
C4NetIOPacket pack (const C4NetIO::addr_t &addr=C4NetIO::addr_t()) const
 
C4NetIOPacket pack (uint8_t cStatus, const C4NetIO::addr_t &addr=C4NetIO::addr_t()) const
 
void unpack (const C4NetIOPacket &Pkt, char *pStatus=nullptr)
 

Protected Attributes

int32_t iDisIDs [16]
 
int32_t iDisIDCnt {0}
 

Detailed Description

Definition at line 417 of file C4Network2Res.h.

Constructor & Destructor Documentation

◆ C4PacketResDiscover()

C4PacketResDiscover::C4PacketResDiscover ( )
default

Referenced by C4PacketResStatus::CompileFunc().

Here is the caller graph for this function:

Member Function Documentation

◆ AddDisID()

bool C4PacketResDiscover::AddDisID ( int32_t  iID)

Definition at line 537 of file C4Packet2.cpp.

Referenced by C4Network2ResList::SendDiscover().

538 {
539  if (iDisIDCnt + 1 >= int32_t(sizeof(iDisIDs) / sizeof(*iDisIDs))) return false;
540  // add
541  iDisIDs[iDisIDCnt++] = iID;
542  return true;
543 }
Here is the caller graph for this function:

◆ CompileFunc()

void C4PacketResDiscover::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 545 of file C4Packet2.cpp.

References mkArrayAdapt(), mkIntPackAdapt(), mkNamingAdapt(), and StdCompiler::Value().

546 {
547  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iDisIDCnt), "DiscoverCnt", 0));
548  pComp->Value(mkNamingAdapt(mkArrayAdapt(iDisIDs, iDisIDCnt), "Discovers", -1));
549 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
StdArrayAdapt< T > mkArrayAdapt(T *pArray, int iSize)
Definition: StdAdaptors.h:328
void Value(const T &rStruct)
Definition: StdCompiler.h:161
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:777
Here is the call graph for this function:

◆ getDisID()

int32_t C4PacketResDiscover::getDisID ( int32_t  i) const
inline

Definition at line 427 of file C4Network2Res.h.

References C4Network2ResCore::CompileFunc(), and C4Network2ResCore::iID.

427 { return iDisIDs[i]; }
Here is the call graph for this function:

◆ getDisIDCnt()

int32_t C4PacketResDiscover::getDisIDCnt ( ) const
inline

Definition at line 426 of file C4Network2Res.h.

Referenced by C4Network2ResList::SendDiscover().

426 { return iDisIDCnt; }
Here is the caller graph for this function:

◆ isIDPresent()

bool C4PacketResDiscover::isIDPresent ( int32_t  iID) const

Definition at line 529 of file C4Packet2.cpp.

530 {
531  for (int32_t i = 0; i < iDisIDCnt; i++)
532  if (iDisIDs[i] == iID)
533  return true;
534  return false;
535 }

◆ pack() [1/2]

C4NetIOPacket C4PacketBase::pack ( const C4NetIO::addr_t addr = C4NetIO::addr_t()) const
inherited

Definition at line 150 of file C4Packet2.cpp.

Referenced by MkC4NetIOPacket().

151 {
152  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
153 }
Here is the caller graph for this function:

◆ pack() [2/2]

C4NetIOPacket C4PacketBase::pack ( uint8_t  cStatus,
const C4NetIO::addr_t addr = C4NetIO::addr_t() 
) const
inherited

Definition at line 155 of file C4Packet2.cpp.

References mkDecompileAdapt(), and mkInsertAdapt().

156 {
157  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(mkInsertAdapt(mkDecompileAdapt(*this), cStatus)), addr);
158 }
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:153
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:455
Here is the call graph for this function:

◆ unpack()

void C4PacketBase::unpack ( const C4NetIOPacket Pkt,
char *  pStatus = nullptr 
)
inherited

Definition at line 160 of file C4Packet2.cpp.

References C4PktBuf::C4PktBuf(), C4NetIOPacket::getPBuf(), C4NetIOPacket::getRef(), and C4NetIOPacket::getStatus().

Referenced by C4IDPacket::C4IDPacket(), and C4Network2IO::HandlePacket().

161 {
162  if (pStatus) *pStatus = Pkt.getStatus();
163  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
164 }
uint8_t getStatus() const
Definition: C4NetIO.h:318
StdBuf getPBuf() const
Definition: C4NetIO.h:321
C4NetIOPacket getRef() const
Definition: C4NetIO.h:324
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ iDisIDCnt

int32_t C4PacketResDiscover::iDisIDCnt {0}
protected

Definition at line 423 of file C4Network2Res.h.

◆ iDisIDs

int32_t C4PacketResDiscover::iDisIDs[16]
protected

Definition at line 423 of file C4Network2Res.h.


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