wavelength 1.0.0
Loading...
Searching...
No Matches
timerequestpkt.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
12extern int g_nTimeRequestPktType;
13
21public:
28 ~TimeRequestPkt() override = default;
29
35 TimeRequestPkt() = default;
36
45 TimeRequestPkt(int nReceiver, float fSendTime)
46 : InternalPacket(0, nReceiver), mSendTime(fSendTime) {
47 }
48
56 static Message *New();
57
64 void *operator new(size_t nSize) {
65 return PoolMemAlloc(static_cast<int>(nSize), "TimeRequestPkt", 0);
66 }
67
73 void operator delete(void *pBlock) {
74 PoolMemFree(pBlock);
75 }
76
82 Message *Clone() override {
83 return new TimeRequestPkt(*this);
84 }
85
91 int Type() override {
93 }
94
100 const char *GetName() const override {
101 return "TimeRequestPkt";
102 }
103
111 void PrintExtra(PrnStream &stream) const override;
112
120 void saveGuts(BinStream &stream) const override;
121
129 void restoreGuts(BinStream &stream) override;
130
132 float GetSendTime() const {
133 return mSendTime;
134 }
135
136private:
137 float mSendTime;
138};
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
TimeRequestPkt()=default
Construct a packet with mSendTime left unset.
float GetSendTime() const
Definition timerequestpkt.h:132
void restoreGuts(BinStream &stream) override
Read the time of the request.
Message * Clone() override
Produce a heap copy of this packet.
Definition timerequestpkt.h:82
const char * GetName() const override
Report this packet's class name.
Definition timerequestpkt.h:100
~TimeRequestPkt() override=default
Destroy the object.
void saveGuts(BinStream &stream) const override
Write the time of the request.
static Message * New()
Produce a default-constructed packet on the heap.
TimeRequestPkt(int nReceiver, float fSendTime)
Construct a packet for one peer, with no delivery flag.
Definition timerequestpkt.h:45
void PrintExtra(PrnStream &stream) const override
Write the sender, the receiver, and the time of the request.
int Type() override
Report this packet's registered identity.
Definition timerequestpkt.h:91
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_nTimeRequestPktType
Identity that TimeRequestPkt::Type() reports.