OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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)
 
virtual void CompileFunc (StdCompiler *pComp)
 
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
 
int32_t iClients [C4NetMaxClients]
 
int32_t iClientCnt
 
StdCopyBuf Data
 

Detailed Description

Definition at line 387 of file C4Network2IO.h.

Constructor & Destructor Documentation

C4PacketFwd::C4PacketFwd ( )

Definition at line 454 of file C4Packet2.cpp.

455  : fNegativeList(false),
456  iClientCnt(0)
457 {
458 }
bool fNegativeList
Definition: C4Network2IO.h:394
int32_t iClientCnt
Definition: C4Network2IO.h:396
C4PacketFwd::C4PacketFwd ( const StdBuf Pkt)

Definition at line 460 of file C4Packet2.cpp.

461  : fNegativeList(false), iClientCnt(0),
462  Data(Pkt)
463 {
464 }
bool fNegativeList
Definition: C4Network2IO.h:394
int32_t iClientCnt
Definition: C4Network2IO.h:396
StdCopyBuf Data
Definition: C4Network2IO.h:397

Member Function Documentation

void C4PacketFwd::AddClient ( int32_t  iClient)

Definition at line 484 of file C4Packet2.cpp.

References C4NetMaxClients, iClientCnt, and iClients.

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

485 {
486  if (iClientCnt + 1 > C4NetMaxClients) return;
487  // add
488  iClients[iClientCnt++] = iClient;
489 }
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:395
int32_t iClientCnt
Definition: C4Network2IO.h:396
const int C4NetMaxClients
Definition: C4Network2IO.h:41

Here is the caller graph for this function:

void C4PacketFwd::CompileFunc ( StdCompiler pComp)
virtual

Implements C4PacketBase.

Definition at line 491 of file C4Packet2.cpp.

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

492 {
493  pComp->Value(mkNamingAdapt(fNegativeList, "Negative", false));
494  pComp->Value(mkNamingAdapt(mkIntPackAdapt(iClientCnt), "ClientCnt", 0));
495  pComp->Value(mkNamingAdapt(mkArrayAdaptMap(iClients, iClientCnt, mkIntPackAdapt<int32_t>), "Clients", -1));
496  pComp->Value(mkNamingAdapt(Data, "Data"));
497 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:395
void Value(const T &rStruct)
Definition: StdCompiler.h:171
bool fNegativeList
Definition: C4Network2IO.h:394
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:757
int32_t iClientCnt
Definition: C4Network2IO.h:396
StdArrayAdapt< T, M > mkArrayAdaptMap(T *pArray, int iSize, M &&map)
Definition: StdAdaptors.h:311
StdCopyBuf Data
Definition: C4Network2IO.h:397

Here is the call graph for this function:

bool C4PacketFwd::DoFwdTo ( int32_t  iClient) const

Definition at line 466 of file C4Packet2.cpp.

References fNegativeList, iClientCnt, and iClients.

Referenced by C4Network2IO::HandleFwdReq().

467 {
468  for (int32_t i = 0; i < iClientCnt; i++)
469  if (iClients[i] == iClient)
470  return !fNegativeList;
471  return fNegativeList;
472 }
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:395
bool fNegativeList
Definition: C4Network2IO.h:394
int32_t iClientCnt
Definition: C4Network2IO.h:396

Here is the caller graph for this function:

int32_t C4PacketFwd::getClient ( int32_t  i) const
inline

Definition at line 402 of file C4Network2IO.h.

Referenced by C4Network2IO::HandleFwdReq().

402 { return iClients[i]; }
int32_t iClients[C4NetMaxClients]
Definition: C4Network2IO.h:395

Here is the caller graph for this function:

int32_t C4PacketFwd::getClientCnt ( ) const
inline

Definition at line 403 of file C4Network2IO.h.

References iClientCnt.

Referenced by C4Network2IO::HandleFwdReq().

403 { return iClientCnt; }
int32_t iClientCnt
Definition: C4Network2IO.h:396

Here is the caller graph for this function:

const StdCopyBuf& C4PacketFwd::getData ( ) const
inline

Definition at line 400 of file C4Network2IO.h.

References Data.

Referenced by C4Network2IO::HandleFwdReq().

400 { return Data; }
StdCopyBuf Data
Definition: C4Network2IO.h:397

Here is the caller graph for this function:

bool C4PacketFwd::isNegativeList ( ) const
inline

Definition at line 401 of file C4Network2IO.h.

References fNegativeList.

401 { return fNegativeList; }
bool fNegativeList
Definition: C4Network2IO.h:394
C4NetIOPacket C4PacketBase::pack ( const C4NetIO::addr_t addr = C4NetIO::addr_t()) const
inherited

Definition at line 156 of file C4Packet2.cpp.

Referenced by MkC4NetIOPacket().

157 {
158  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(*this), addr);
159 }

Here is the caller graph for this function:

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

Definition at line 161 of file C4Packet2.cpp.

References mkDecompileAdapt(), and mkInsertAdapt().

162 {
163  return C4NetIOPacket(DecompileToBuf<StdCompilerBinWrite>(mkInsertAdapt(mkDecompileAdapt(*this), cStatus)), addr);
164 }
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:154
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:435

Here is the call graph for this function:

void C4PacketFwd::SetData ( const StdBuf Pkt)

Definition at line 474 of file C4Packet2.cpp.

References Data.

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

475 {
476  Data = Pkt;
477 }
StdCopyBuf Data
Definition: C4Network2IO.h:397

Here is the caller graph for this function:

void C4PacketFwd::SetListType ( bool  fnNegativeList)

Definition at line 479 of file C4Packet2.cpp.

References fNegativeList.

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

480 {
481  fNegativeList = fnNegativeList;
482 }
bool fNegativeList
Definition: C4Network2IO.h:394

Here is the caller graph for this function:

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

Definition at line 166 of file C4Packet2.cpp.

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

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

167 {
168  if (pStatus) *pStatus = Pkt.getStatus();
169  CompileFromBuf<StdCompilerBinRead>(*this, pStatus ? Pkt.getPBuf() : Pkt.getRef());
170 }
StdBuf getPBuf() const
Definition: C4NetIO.h:321
C4NetIOPacket getRef() const
Definition: C4NetIO.h:324
uint8_t getStatus() const
Definition: C4NetIO.h:318

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

StdCopyBuf C4PacketFwd::Data
protected

Definition at line 397 of file C4Network2IO.h.

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

bool C4PacketFwd::fNegativeList
protected

Definition at line 394 of file C4Network2IO.h.

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

int32_t C4PacketFwd::iClientCnt
protected

Definition at line 396 of file C4Network2IO.h.

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

int32_t C4PacketFwd::iClients[C4NetMaxClients]
protected

Definition at line 395 of file C4Network2IO.h.

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


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