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 ()
 
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)
 
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)
 

Detailed Description

Definition at line 414 of file C4Network2IO.h.

Constructor & Destructor Documentation

C4PacketPostMortem::C4PacketPostMortem ( )

Definition at line 1554 of file C4Network2IO.cpp.

1555  : iConnID(~0),
1556  iPacketCounter(~0),
1557  iPacketCount(0),
1558  pPackets(nullptr)
1559 {
1560 
1561 }
C4PacketPostMortem::~C4PacketPostMortem ( )

Definition at line 1563 of file C4Network2IO.cpp.

1564 {
1565  while (pPackets)
1566  {
1567  PacketLink *pDelete = pPackets;
1568  pPackets = pPackets->Next;
1569  delete pDelete;
1570  }
1571  iPacketCount = 0;
1572 }

Member Function Documentation

void C4PacketPostMortem::Add ( const C4NetIOPacket rPkt)

Definition at line 1594 of file C4Network2IO.cpp.

Referenced by C4Network2IOConnection::CreatePostMortem().

1595 {
1596  // Add to head of list (reverse order)
1597  PacketLink *pLink = new PacketLink();
1598  pLink->Pkt = rPkt;
1599  pLink->Next = pPackets;
1600  pPackets = pLink;
1601  iPacketCount++;
1602 }

Here is the caller graph for this function:

void C4PacketPostMortem::CompileFunc ( StdCompiler pComp)
virtual

Implements C4PacketBase.

Definition at line 1604 of file C4Network2IO.cpp.

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

1605 {
1606  bool deserializing = pComp->isDeserializer();
1607 
1608  // Connection ID, packet number and packet count
1609  pComp->Value(mkNamingAdapt(iConnID, "ConnID"));
1610  pComp->Value(mkNamingAdapt(iPacketCounter, "PacketCounter"));
1611  pComp->Value(mkNamingAdapt(iPacketCount, "PacketCount"));
1612 
1613  // Packets
1614  if (deserializing)
1615  {
1616  // Read packets
1617  for (uint32_t i = 0; i < iPacketCount; i++)
1618  {
1619  // Create list entry
1620  PacketLink *pLink = new PacketLink();
1621  pLink->Next = pPackets;
1622  pPackets = pLink;
1623  // Compile data
1624  pComp->Value(mkNamingAdapt(pLink->Pkt, "PacketData"));
1625  }
1626  // Reverse order
1627  PacketLink *pPackets2 = pPackets;
1628  pPackets = nullptr;
1629  while (pPackets2)
1630  {
1631  // Get link
1632  PacketLink *pLink = pPackets2;
1633  pPackets2 = pLink->Next;
1634  // Readd to list
1635  pLink->Next = pPackets;
1636  pPackets = pLink;
1637  }
1638  }
1639  else
1640  {
1641  // Write packets
1642  for (PacketLink *pLink = pPackets; pLink; pLink = pLink->Next)
1643  pComp->Value(mkNamingAdapt(pLink->Pkt, "PacketData"));
1644  }
1645 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
void Value(const T &rStruct)
Definition: StdCompiler.h:171
virtual bool isDeserializer()
Definition: StdCompiler.h:63

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 1574 of file C4Network2IO.cpp.

References Inside().

1575 {
1576  // Security
1577  if (!Inside(iNumber, iPacketCounter - iPacketCount, iPacketCounter - 1))
1578  return nullptr;
1579  // Calculate position in list
1580  iNumber = iNumber + iPacketCount - iPacketCounter;
1581  // Search for the packet with the given number
1582  PacketLink *pLink = pPackets;
1583  for (; pLink && iNumber; iNumber--)
1584  pLink = pLink->Next;
1585  // Not found?
1586  return pLink ? &pLink->Pkt : nullptr;
1587 }
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:45

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 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 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 1589 of file C4Network2IO.cpp.

Referenced by C4Network2IOConnection::CreatePostMortem().

1590 {
1591  iPacketCounter = inPacketCounter;
1592 }

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:


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