wavelength 1.0.0
Loading...
Searching...
No Matches
bootpkt.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
12extern int g_nBootPktType;
13
20class BootPkt : public InternalPacket {
21public:
28 ~BootPkt() override = default;
29
37
45 static Message *New();
46
53 void *operator new(size_t nSize) {
54 return PoolMemAlloc(static_cast<int>(nSize), "BootPkt", 0);
55 }
56
62 void operator delete(void *pBlock) {
63 PoolMemFree(pBlock);
64 }
65
71 Message *Clone() override {
72 return new BootPkt(*this);
73 }
74
80 int Type() override {
81 return g_nBootPktType;
82 }
83
89 const char *GetName() const override {
90 return "BootPkt";
91 }
92
100 void PrintExtra(PrnStream &stream) const override;
101
109 void saveGuts(BinStream &stream) const override;
110
118 void restoreGuts(BinStream &stream) override;
119
121 int GetPlayer() const {
122 return mPlayer;
123 }
124
126 void SetPlayer(int nPlayer) {
127 mPlayer = nPlayer;
128 }
129
130private:
131 int mPlayer;
132};
int g_nBootPktType
Identity that BootPkt::Type() reports.
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
~BootPkt() override=default
Destroy the object.
Message * Clone() override
Produce a heap copy of this packet.
Definition bootpkt.h:71
void PrintExtra(PrnStream &stream) const override
Write the sender, the receiver, and the guest.
int Type() override
Report this packet's registered identity.
Definition bootpkt.h:80
int GetPlayer() const
Definition bootpkt.h:121
void restoreGuts(BinStream &stream) override
Read the guest.
BootPkt()
Construct a packet for every peer with no guest.
Definition bootpkt.h:35
static Message * New()
Produce a default-constructed packet on the heap.
void SetPlayer(int nPlayer)
Definition bootpkt.h:126
const char * GetName() const override
Report this packet's class name.
Definition bootpkt.h:89
void saveGuts(BinStream &stream) const override
Write the guest as four bytes.
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
static constexpr unsigned char kFlagGuaranteed
Bit of mFlags that NetTransport::Send() turns into its guaranteed delivery bit.
Definition packet.h:28
static constexpr int kUnset
Value of mSender and mReceiver that marks the member as unset.
Definition packet.h:16
static constexpr int kAllPeers
Value of mReceiver that addresses every peer.
Definition packet.h:19
Text output stream.
Definition prnstream.h:16
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.