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

Referenced by C4PacketConnRe::CompileFunc().

Here is the caller graph for this function:

◆ C4PacketFwd() [2/2]

C4PacketFwd::C4PacketFwd ( const StdBuf Pkt)

Definition at line 437 of file C4Packet2.cpp.

438  : Data(Pkt)
439 {
440 }
StdCopyBuf Data
Definition: C4Network2IO.h:400

Member Function Documentation

◆ AddClient()

void C4PacketFwd::AddClient ( int32_t  iClient)

Definition at line 460 of file C4Packet2.cpp.

References C4NetMaxClients, iClientCnt, and iClients.

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

461 {
462  if (iClientCnt + 1 > C4NetMaxClients) return;
463  // add
464  iClients[iClientCnt++] = iClient;
465 }
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:398
int32_t iClientCnt
Definition: C4Network2IO.h:399
const int C4NetMaxClients
Definition: C4Network2IO.h:41
Here is the caller graph for this function:

◆ CompileFunc()

void C4PacketFwd::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 467 of file C4Packet2.cpp.

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

468 {
469  pComp->Value(mkNamingAdapt(fNegativeList, "Negative", false));
470  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iClientCnt), "ClientCnt", 0));
471  pComp->Value(mkNamingAdapt(mkArrayAdaptMap(iClients, iClientCnt, mkIntPackAdapt<int32_t>), "Clients", -1));
472  pComp->Value(mkNamingAdapt(Data, "Data"));
473 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:398
void Value(const T &rStruct)
Definition: StdCompiler.h:161
bool fNegativeList
Definition: C4Network2IO.h:397
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:777
int32_t iClientCnt
Definition: C4Network2IO.h:399
StdArrayAdapt< T, M > mkArrayAdaptMap(T *pArray, int iSize, M &&map)
Definition: StdAdaptors.h:331
StdCopyBuf Data
Definition: C4Network2IO.h:400
Here is the call graph for this function:

◆ DoFwdTo()

bool C4PacketFwd::DoFwdTo ( int32_t  iClient) const

Definition at line 442 of file C4Packet2.cpp.

References fNegativeList, iClientCnt, and iClients.

Referenced by C4Network2IO::HandleFwdReq().

443 {
444  for (int32_t i = 0; i < iClientCnt; i++)
445  if (iClients[i] == iClient)
446  return !fNegativeList;
447  return fNegativeList;
448 }
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:398
bool fNegativeList
Definition: C4Network2IO.h:397
int32_t iClientCnt
Definition: C4Network2IO.h:399
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.

Referenced by C4Network2IO::HandleFwdReq().

405 { return iClients[i]; }
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:398
Here is the caller graph for this function:

◆ getClientCnt()

int32_t C4PacketFwd::getClientCnt ( ) const
inline

Definition at line 406 of file C4Network2IO.h.

References CompileFunc().

Referenced by C4Network2IO::HandleFwdReq().

406 { return iClientCnt; }
int32_t iClientCnt
Definition: C4Network2IO.h:399
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getData()

const StdCopyBuf& C4PacketFwd::getData ( ) const
inline

Definition at line 403 of file C4Network2IO.h.

Referenced by C4Network2IO::HandleFwdReq().

403 { return Data; }
StdCopyBuf Data
Definition: C4Network2IO.h:400
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; }
bool fNegativeList
Definition: C4Network2IO.h:397

◆ 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:

◆ SetData()

void C4PacketFwd::SetData ( const StdBuf Pkt)

Definition at line 450 of file C4Packet2.cpp.

References Data.

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

451 {
452  Data = Pkt;
453 }
StdCopyBuf Data
Definition: C4Network2IO.h:400
Here is the caller graph for this function:

◆ SetListType()

void C4PacketFwd::SetListType ( bool  fnNegativeList)

Definition at line 455 of file C4Packet2.cpp.

References fNegativeList.

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

456 {
457  fNegativeList = fnNegativeList;
458 }
bool fNegativeList
Definition: C4Network2IO.h:397
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.

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

◆ Data

StdCopyBuf C4PacketFwd::Data
protected

Definition at line 400 of file C4Network2IO.h.

Referenced by CompileFunc(), and SetData().

◆ fNegativeList

bool C4PacketFwd::fNegativeList {false}
protected

Definition at line 397 of file C4Network2IO.h.

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

◆ iClientCnt

int32_t C4PacketFwd::iClientCnt {0}
protected

Definition at line 399 of file C4Network2IO.h.

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

◆ iClients

int32_t C4PacketFwd::iClients[C4NetMaxClients]
protected

Definition at line 398 of file C4Network2IO.h.

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


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