wavelength 1.0.0
Loading...
Searching...
No Matches
joinfailedpkt.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
12extern int g_nJoinFailedPktType;
13
21public:
28 ~JoinFailedPkt() override = default;
29
35 JoinFailedPkt() = default;
36
45 JoinFailedPkt(int nReceiver, int nReason)
46 : InternalPacket(kFlagOrdered | kFlagGuaranteed, nReceiver), mReason(nReason) {
47 }
48
56 static Message *New();
57
64 void *operator new(size_t nSize) {
65 return PoolMemAlloc(static_cast<int>(nSize), "JoinFailedPkt", 0);
66 }
67
73 void operator delete(void *pBlock) {
74 PoolMemFree(pBlock);
75 }
76
82 Message *Clone() override {
83 return new JoinFailedPkt(*this);
84 }
85
91 int Type() override {
93 }
94
100 const char *GetName() const override {
101 return "JoinFailedPkt";
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 int GetReason() const {
133 return mReason;
134 }
135
136private:
137 int mReason;
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
void restoreGuts(BinStream &stream) override
Read the reason as one signed byte, although saveGuts() writes four.
JoinFailedPkt()=default
Construct a packet with mReason left unset.
int Type() override
Report this packet's registered identity.
Definition joinfailedpkt.h:91
int GetReason() const
Definition joinfailedpkt.h:132
void PrintExtra(PrnStream &stream) const override
Write the reason alone, without the sender and the receiver.
JoinFailedPkt(int nReceiver, int nReason)
Construct a packet for one peer, ordered and guaranteed.
Definition joinfailedpkt.h:45
static Message * New()
Produce a default-constructed packet on the heap.
void saveGuts(BinStream &stream) const override
Write the reason as four bytes.
Message * Clone() override
Produce a heap copy of this packet.
Definition joinfailedpkt.h:82
~JoinFailedPkt() override=default
Destroy the object.
const char * GetName() const override
Report this packet's class name.
Definition joinfailedpkt.h:100
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
static constexpr unsigned char kFlagGuaranteed
Bit of mFlags that NetTransport::Send() turns into its guaranteed delivery bit.
Definition packet.h:28
static constexpr unsigned char kFlagOrdered
Bit of mFlags that LaunchpadRT::Send() turns into the second delivery bit of the session library.
Definition packet.h:25
Text output stream.
Definition prnstream.h:16
int g_nJoinFailedPktType
Identity that JoinFailedPkt::Type() reports.
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.