wavelength 1.0.0
Loading...
Searching...
No Matches
timeresponsepkt.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
12extern int g_nTimeResponsePktType;
13
21public:
27 TimeResponsePkt() = default;
28
38 TimeResponsePkt(int nReceiver, float fSendTime, float fRequestTime)
39 : InternalPacket(0, nReceiver), mSendTime(fSendTime), mRequestTime(fRequestTime) {
40 }
41
49 static Message *New();
50
57 void *operator new(size_t nSize) {
58 return PoolMemAlloc(static_cast<int>(nSize), "TimeResponsePkt", 0);
59 }
60
66 void operator delete(void *pBlock) {
67 PoolMemFree(pBlock);
68 }
69
75 Message *Clone() override {
76 return new TimeResponsePkt(*this);
77 }
78
84 int Type() override {
86 }
87
93 const char *GetName() const override {
94 return "TimeResponsePkt";
95 }
96
104 void PrintExtra(PrnStream &stream) const override;
105
113 void saveGuts(BinStream &stream) const override;
114
122 void restoreGuts(BinStream &stream) override;
123
125 float GetRequestTime() const {
126 return mRequestTime;
127 }
128
130 float GetSendTime() const {
131 return mSendTime;
132 }
133
134private:
135 float mSendTime;
136 float mRequestTime;
137};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
InternalPacket(unsigned char nFlags=0, int nReceiver=kUnset)
Construct a packet from an unset sender.
Definition internalpacket.h:33
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Text output stream.
Definition prnstream.h:16
const char * GetName() const override
Report this packet's class name.
Definition timeresponsepkt.h:93
static Message * New()
Produce a default-constructed packet on the heap.
float GetRequestTime() const
Definition timeresponsepkt.h:125
int Type() override
Report this packet's registered identity.
Definition timeresponsepkt.h:84
float GetSendTime() const
Definition timeresponsepkt.h:130
void restoreGuts(BinStream &stream) override
Read what saveGuts() wrote.
Message * Clone() override
Produce a heap copy of this packet.
Definition timeresponsepkt.h:75
TimeResponsePkt(int nReceiver, float fSendTime, float fRequestTime)
Construct a packet for one peer, with no delivery flag.
Definition timeresponsepkt.h:38
void PrintExtra(PrnStream &stream) const override
Write the sender, the receiver, and the two times as req: and send:.
void saveGuts(BinStream &stream) const override
Write mRequestTime and then mSendTime.
TimeResponsePkt()=default
Construct a packet with the times left unset.
void * PoolMemAlloc(int nSize, const char *pszTag, int nAlign)
Allocate a block from the pool heaps and bill it to a tag.
void PoolMemFree(void *pBlock)
Return a block PoolMemAlloc() handed out to the pool heap that owns it.
int g_nTimeResponsePktType
Identity that TimeResponsePkt::Type() reports.