OpenClonk
C4PacketPing Class Reference

#include <C4Network2IO.h>

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

Public Member Functions

 C4PacketPing (uint32_t iPacketCounter=0, uint32_t iRemotePacketCounter=0)
 
uint32_t getTravelTime () const
 
uint32_t getPacketCounter () const
 
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

C4TimeMilliseconds tTime
 
uint32_t iPacketCounter
 

Detailed Description

Definition at line 335 of file C4Network2IO.h.

Constructor & Destructor Documentation

◆ C4PacketPing()

C4PacketPing::C4PacketPing ( uint32_t  iPacketCounter = 0,
uint32_t  iRemotePacketCounter = 0 
)

Definition at line 489 of file C4Packet2.cpp.

492 {
493 }
uint32_t iPacketCounter
Definition: C4Network2IO.h:342
C4TimeMilliseconds tTime
Definition: C4Network2IO.h:341
static C4TimeMilliseconds Now()

Member Function Documentation

◆ CompileFunc()

void C4PacketPing::CompileFunc ( StdCompiler pComp)
overridevirtual

Implements C4PacketBase.

Definition at line 500 of file C4Packet2.cpp.

References C4TimeMilliseconds::AsInt(), C4PacketResStatus::C4PacketResStatus(), iPacketCounter, mkNamingAdapt(), tTime, and StdCompiler::Value().

501 {
502  uint32_t time = tTime.AsInt();
503  pComp->Value(mkNamingAdapt(time, "Time", 0U));
504  tTime = C4TimeMilliseconds(time);
505 
506  pComp->Value(mkNamingAdapt(iPacketCounter, "PacketCounter", 0U));
507 }
uint32_t iPacketCounter
Definition: C4Network2IO.h:342
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
void Value(const T &rStruct)
Definition: StdCompiler.h:161
uint32_t AsInt() const
C4TimeMilliseconds tTime
Definition: C4Network2IO.h:341
Here is the call graph for this function:

◆ getPacketCounter()

uint32_t C4PacketPing::getPacketCounter ( ) const
inline

Definition at line 346 of file C4Network2IO.h.

References CompileFunc().

346 { return iPacketCounter; }
uint32_t iPacketCounter
Definition: C4Network2IO.h:342
Here is the call graph for this function:

◆ getTravelTime()

uint32_t C4PacketPing::getTravelTime ( ) const

Definition at line 495 of file C4Packet2.cpp.

References C4TimeMilliseconds::Now(), and tTime.

496 {
497  return C4TimeMilliseconds::Now() - tTime;
498 }
C4TimeMilliseconds tTime
Definition: C4Network2IO.h:341
static C4TimeMilliseconds Now()
Here is the call graph for this function:

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

◆ 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

◆ iPacketCounter

uint32_t C4PacketPing::iPacketCounter
protected

Definition at line 342 of file C4Network2IO.h.

Referenced by CompileFunc().

◆ tTime

C4TimeMilliseconds C4PacketPing::tTime
protected

Definition at line 341 of file C4Network2IO.h.

Referenced by CompileFunc(), and getTravelTime().


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