OpenClonk
C4PacketFwd Class Reference

#include <C4Network2IO.h>

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

Public Member Functions

 C4PacketFwd ()
 
 C4PacketFwd (const StdBuf &Pkt)
 
const StdCopyBufgetData () const
 
bool isNegativeList () const
 
int32_t getClient (int32_t i) const
 
int32_t getClientCnt () const
 
bool DoFwdTo (int32_t iClient) const
 
void SetData (const StdBuf &Pkt)
 
void SetListType (bool fnNegativeList)
 
void AddClient (int32_t iClient)
 
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

bool fNegativeList {false}
 
int32_t iClients [C4NetMaxClients]
 
int32_t iClientCnt {0}
 
StdCopyBuf Data
 

Detailed Description

Definition at line 390 of file C4Network2IO.h.

Constructor & Destructor Documentation

◆ C4PacketFwd() [1/2]

C4PacketFwd::C4PacketFwd ( )
default

◆ C4PacketFwd() [2/2]

C4PacketFwd::C4PacketFwd ( const StdBuf Pkt)

Definition at line 440 of file C4Packet2.cpp.

441  : Data(Pkt)
442 {
443 }
StdCopyBuf Data
Definition: C4Network2IO.h:400

Member Function Documentation

◆ AddClient()

void C4PacketFwd::AddClient ( int32_t  iClient)

Definition at line 463 of file C4Packet2.cpp.

464 {
465  if (iClientCnt + 1 > C4NetMaxClients) return;
466  // add
467  iClients[iClientCnt++] = iClient;
468 }
const int C4NetMaxClients
Definition: C4Network2IO.h:41
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:398
int32_t iClientCnt
Definition: C4Network2IO.h:399

References C4NetMaxClients, iClientCnt, and iClients.

Referenced by C4Network2ClientList::BroadcastMsgToClients(), C4Network2IO::HandleFwdReq(), and C4Network2ClientList::SendMsgToClient().

Here is the caller graph for this function:

◆ CompileFunc()

void C4PacketFwd::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 470 of file C4Packet2.cpp.

471 {
472  pComp->Value(mkNamingAdapt(fNegativeList, "Negative", false));
473  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iClientCnt), "ClientCnt", 0));
474  pComp->Value(mkNamingAdapt(mkArrayAdaptMap(iClients, iClientCnt, mkIntPackAdapt<int32_t>), "Clients", -1));
475  pComp->Value(mkNamingAdapt(Data, "Data"));
476 }
StdArrayAdapt< T, M > mkArrayAdaptMap(T *pArray, int iSize, M &&map)
Definition: StdAdaptors.h:340
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:791
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
bool fNegativeList
Definition: C4Network2IO.h:397
void Value(const T &rStruct)
Definition: StdCompiler.h:161

References Data, fNegativeList, iClientCnt, iClients, mkArrayAdaptMap(), mkIntPackAdapt(), mkNamingAdapt(), and StdCompiler::Value().

Here is the call graph for this function:

◆ DoFwdTo()

bool C4PacketFwd::DoFwdTo ( int32_t  iClient) const

Definition at line 445 of file C4Packet2.cpp.

446 {
447  for (int32_t i = 0; i < iClientCnt; i++)
448  if (iClients[i] == iClient)
449  return !fNegativeList;
450  return fNegativeList;
451 }

References fNegativeList, iClientCnt, and iClients.

Referenced by C4Network2IO::HandleFwdReq().

Here is the caller graph for this function:

◆ getClient()

int32_t C4PacketFwd::getClient ( int32_t  i) const
inline

Definition at line 405 of file C4Network2IO.h.

405 { return iClients[i]; }

References iClients.

Referenced by C4Network2IO::HandleFwdReq().

Here is the caller graph for this function:

◆ getClientCnt()

int32_t C4PacketFwd::getClientCnt ( ) const
inline

Definition at line 406 of file C4Network2IO.h.

406 { return iClientCnt; }

References iClientCnt.

Referenced by C4Network2IO::HandleFwdReq().

Here is the caller graph for this function:

◆ getData()

const StdCopyBuf& C4PacketFwd::getData ( ) const
inline

Definition at line 403 of file C4Network2IO.h.

403 { return Data; }

References Data.

Referenced by C4Network2IO::HandleFwdReq().

Here is the caller graph for this function:

◆ isNegativeList()

bool C4PacketFwd::isNegativeList ( ) const
inline

Definition at line 404 of file C4Network2IO.h.

404 { return fNegativeList; }

References fNegativeList.

◆ pack() [1/2]

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

Definition at line 150 of file C4Packet2.cpp.

151 {
152  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
153 }

Referenced by MkC4NetIOPacket().

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.

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

References mkDecompileAdapt(), and mkInsertAdapt().

Here is the call graph for this function:

◆ SetData()

void C4PacketFwd::SetData ( const StdBuf Pkt)

Definition at line 453 of file C4Packet2.cpp.

454 {
455  Data = Pkt;
456 }

References Data.

Referenced by C4Network2ClientList::BroadcastMsgToClients(), C4Network2IO::HandleFwdReq(), and C4Network2ClientList::SendMsgToClient().

Here is the caller graph for this function:

◆ SetListType()

void C4PacketFwd::SetListType ( bool  fnNegativeList)

Definition at line 458 of file C4Packet2.cpp.

459 {
460  fNegativeList = fnNegativeList;
461 }

References fNegativeList.

Referenced by C4Network2ClientList::BroadcastMsgToClients(), C4Network2IO::HandleFwdReq(), and C4Network2ClientList::SendMsgToClient().

Here is the caller graph for this function:

◆ unpack()

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

Definition at line 160 of file C4Packet2.cpp.

161 {
162  if (pStatus) *pStatus = Pkt.getStatus();
163  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
164 }
uint8_t getStatus() const
Definition: C4NetIO.h:319
StdBuf getPBuf() const
Definition: C4NetIO.h:322
C4NetIOPacket getRef() const
Definition: C4NetIO.h:325

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

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

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

Member Data Documentation

◆ Data

StdCopyBuf C4PacketFwd::Data
protected

Definition at line 400 of file C4Network2IO.h.

Referenced by CompileFunc(), getData(), and SetData().

◆ fNegativeList

bool C4PacketFwd::fNegativeList {false}
protected

Definition at line 397 of file C4Network2IO.h.

Referenced by CompileFunc(), DoFwdTo(), isNegativeList(), and SetListType().

◆ iClientCnt

int32_t C4PacketFwd::iClientCnt {0}
protected

Definition at line 399 of file C4Network2IO.h.

Referenced by AddClient(), CompileFunc(), DoFwdTo(), and getClientCnt().

◆ iClients

int32_t C4PacketFwd::iClients[C4NetMaxClients]
protected

Definition at line 398 of file C4Network2IO.h.

Referenced by AddClient(), CompileFunc(), DoFwdTo(), and getClient().


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