OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4PacketPostMortem Class Reference

#include <C4Network2IO.h>

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

Public Member Functions

 C4PacketPostMortem ()
 
 ~C4PacketPostMortem () override
 
uint32_t getConnID () const
 
uint32_t getPacketCount () const
 
void SetConnID (uint32_t inConnID)
 
const C4NetIOPacketgetPacket (uint32_t iNumber) const
 
void SetPacketCounter (uint32_t iPacketCounter)
 
void Add (const C4NetIOPacket &rPkt)
 
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)
 

Detailed Description

Definition at line 414 of file C4Network2IO.h.

Constructor & Destructor Documentation

C4PacketPostMortem::C4PacketPostMortem ( )

Definition at line 1533 of file C4Network2IO.cpp.

1534  : iConnID(~0),
1535  iPacketCounter(~0)
1536 {
1537 
1538 }
C4PacketPostMortem::~C4PacketPostMortem ( )
override

Definition at line 1540 of file C4Network2IO.cpp.

1541 {
1542  while (pPackets)
1543  {
1544  PacketLink *pDelete = pPackets;
1545  pPackets = pPackets->Next;
1546  delete pDelete;
1547  }
1548  iPacketCount = 0;
1549 }

Member Function Documentation

void C4PacketPostMortem::Add ( const C4NetIOPacket rPkt)

Definition at line 1571 of file C4Network2IO.cpp.

Referenced by C4Network2IOConnection::CreatePostMortem().

1572 {
1573  // Add to head of list (reverse order)
1574  PacketLink *pLink = new PacketLink();
1575  pLink->Pkt = rPkt;
1576  pLink->Next = pPackets;
1577  pPackets = pLink;
1578  iPacketCount++;
1579 }

Here is the caller graph for this function:

void C4PacketPostMortem::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 1581 of file C4Network2IO.cpp.

References StdCompiler::isDeserializer(), mkNamingAdapt(), and StdCompiler::Value().

1582 {
1583  bool deserializing = pComp->isDeserializer();
1584 
1585  // Connection ID, packet number and packet count
1586  pComp->Value(mkNamingAdapt(iConnID, "ConnID"));
1587  pComp->Value(mkNamingAdapt(iPacketCounter, "PacketCounter"));
1588  pComp->Value(mkNamingAdapt(iPacketCount, "PacketCount"));
1589 
1590  // Packets
1591  if (deserializing)
1592  {
1593  // Read packets
1594  for (uint32_t i = 0; i < iPacketCount; i++)
1595  {
1596  // Create list entry
1597  PacketLink *pLink = new PacketLink();
1598  pLink->Next = pPackets;
1599  pPackets = pLink;
1600  // Compile data
1601  pComp->Value(mkNamingAdapt(pLink->Pkt, "PacketData"));
1602  }
1603  // Reverse order
1604  PacketLink *pPackets2 = pPackets;
1605  pPackets = nullptr;
1606  while (pPackets2)
1607  {
1608  // Get link
1609  PacketLink *pLink = pPackets2;
1610  pPackets2 = pLink->Next;
1611  // Readd to list
1612  pLink->Next = pPackets;
1613  pPackets = pLink;
1614  }
1615  }
1616  else
1617  {
1618  // Write packets
1619  for (PacketLink *pLink = pPackets; pLink; pLink = pLink->Next)
1620  pComp->Value(mkNamingAdapt(pLink->Pkt, "PacketData"));
1621  }
1622 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53

Here is the call graph for this function:

uint32_t C4PacketPostMortem::getConnID ( ) const
inline

Definition at line 432 of file C4Network2IO.h.

432 { return iConnID; }
const C4NetIOPacket * C4PacketPostMortem::getPacket ( uint32_t  iNumber) const

Definition at line 1551 of file C4Network2IO.cpp.

References Inside().

1552 {
1553  // Security
1554  if (!Inside(iNumber, iPacketCounter - iPacketCount, iPacketCounter - 1))
1555  return nullptr;
1556  // Calculate position in list
1557  iNumber = iNumber + iPacketCount - iPacketCounter;
1558  // Search for the packet with the given number
1559  PacketLink *pLink = pPackets;
1560  for (; pLink && iNumber; iNumber--)
1561  pLink = pLink->Next;
1562  // Not found?
1563  return pLink ? &pLink->Pkt : nullptr;
1564 }
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43

Here is the call graph for this function:

uint32_t C4PacketPostMortem::getPacketCount ( ) const
inline

Definition at line 433 of file C4Network2IO.h.

Referenced by C4Network2::OnDisconn().

433 { return iPacketCount; }

Here is the caller graph for this function:

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

Definition at line 149 of file C4Packet2.cpp.

Referenced by MkC4NetIOPacket().

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

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 154 of file C4Packet2.cpp.

References mkDecompileAdapt(), and mkInsertAdapt().

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

Here is the call graph for this function:

void C4PacketPostMortem::SetConnID ( uint32_t  inConnID)
inline

Definition at line 434 of file C4Network2IO.h.

Referenced by C4Network2IOConnection::CreatePostMortem().

434 { iConnID = inConnID; }

Here is the caller graph for this function:

void C4PacketPostMortem::SetPacketCounter ( uint32_t  iPacketCounter)

Definition at line 1566 of file C4Network2IO.cpp.

Referenced by C4Network2IOConnection::CreatePostMortem().

1567 {
1568  iPacketCounter = inPacketCounter;
1569 }

Here is the caller graph for this function:

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

Definition at line 159 of file C4Packet2.cpp.

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

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

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

Here is the call graph for this function:

Here is the caller graph for this function:


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