wavelength 1.0.0
Loading...
Searching...
No Matches
gameparamspkt.h
Go to the documentation of this file.
1#pragma once
2
5#include "os/mem.h"
6
13extern int g_nGameParamsPktType;
14
22public:
28 GameParamsPkt() = default;
29
37 explicit GameParamsPkt(const NetGameParams &params)
39 }
40
48 static Message *New();
49
56 void *operator new(size_t nSize) {
57 return PoolMemAlloc(static_cast<int>(nSize), "GameParamsPkt", 0);
58 }
59
65 void operator delete(void *pBlock) {
66 PoolMemFree(pBlock);
67 }
68
74 Message *Clone() override {
75 return new GameParamsPkt(*this);
76 }
77
83 int Type() override {
85 }
86
92 const char *GetName() const override {
93 return "GameParamsPkt";
94 }
95
103 void PrintExtra(PrnStream &stream) const override;
104
112 void saveGuts(BinStream &stream) const override;
113
121 void restoreGuts(BinStream &stream) override;
122
124 const NetGameParams &GetParams() const {
125 return mParams;
126 }
127
128private:
129 NetGameParams mParams;
130};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
void PrintExtra(PrnStream &stream) const override
Write the sender, the receiver, and the settings.
const char * GetName() const override
Report this packet's class name.
Definition gameparamspkt.h:92
void restoreGuts(BinStream &stream) override
Read the settings.
int Type() override
Report this packet's registered identity.
Definition gameparamspkt.h:83
static Message * New()
Produce a default-constructed packet on the heap.
GameParamsPkt()=default
Construct a packet with the default settings.
GameParamsPkt(const NetGameParams &params)
Construct a packet for every peer, ordered and guaranteed.
Definition gameparamspkt.h:37
Message * Clone() override
Produce a heap copy of this packet.
Definition gameparamspkt.h:74
void saveGuts(BinStream &stream) const override
Write the settings.
const NetGameParams & GetParams() const
Definition gameparamspkt.h:124
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
The settings of an online game that the host publishes with its session.
Definition netgameparams.h:13
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
static constexpr int kAllPeers
Value of mReceiver that addresses every peer.
Definition packet.h:19
Text output stream.
Definition prnstream.h:16
int g_nGameParamsPktType
Identity that GameParamsPkt::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.