wavelength 1.0.0
Loading...
Searching...
No Matches
erasebarpacket.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
12extern int g_nEraseBarPacketType;
13
21public:
28 ~EraseBarPacket() override = default;
29
35 EraseBarPacket() : ExternalPacket(kFlagGuaranteed), mTrack(-1), mBar(-1) {
36 }
37
46 EraseBarPacket(int nTrack, int nBar)
47 : ExternalPacket(kFlagGuaranteed), mTrack(nTrack), mBar(nBar) {
48 }
49
57 static Message *New();
58
65 void *operator new(size_t nSize) {
66 return PoolMemAlloc(static_cast<int>(nSize), "EraseBarPacket", 0);
67 }
68
74 void operator delete(void *pBlock) {
75 PoolMemFree(pBlock);
76 }
77
85 Message *Clone() override {
86 return new EraseBarPacket(*this);
87 }
88
96 int Type() override {
98 }
99
107 const char *GetName() const override {
108 return "EraseBarPacket";
109 }
110
118 void saveGuts(BinStream &stream) const override;
119
127 void restoreGuts(BinStream &stream) override;
128
130 int GetBar() const {
131 return mBar;
132 }
133
135 int GetTrack() const {
136 return mTrack;
137 }
138
139private:
140 int mTrack;
141 int mBar;
142};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
void restoreGuts(BinStream &stream) override
Read the word saveGuts() writes back into the fields.
EraseBarPacket()
Construct a packet with no track and no bar.
Definition erasebarpacket.h:35
Message * Clone() override
Produce a heap copy of this packet.
Definition erasebarpacket.h:85
~EraseBarPacket() override=default
Destroy the object.
const char * GetName() const override
Report this packet's class name.
Definition erasebarpacket.h:107
int Type() override
Report this packet's registered identity.
Definition erasebarpacket.h:96
int GetTrack() const
Definition erasebarpacket.h:135
EraseBarPacket(int nTrack, int nBar)
Construct a packet for an erased bar.
Definition erasebarpacket.h:46
void saveGuts(BinStream &stream) const override
Write the track and the bar packed into one word.
static Message * New()
Produce a default-constructed packet on the heap.
int GetBar() const
Definition erasebarpacket.h:130
ExternalPacket(unsigned char nFlags=0, int nReceiver=kAllPeers)
Construct a packet from an unset sender.
Definition externalpacket.h:21
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
int g_nEraseBarPacketType
Identity that EraseBarPacket::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.