wavelength 1.0.0
Loading...
Searching...
No Matches
capturepacket.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
12extern int g_nCapturePacketType;
13
21public:
28 ~CapturePacket() override = default;
29
36 : ExternalPacket(kFlagGuaranteed), mTrack(-1), mBar(-1), mAutocatch(0), mValid(0) {
37 }
38
48 CapturePacket(int nTrack, int nBar, bool bAutocatch)
49 : ExternalPacket(kFlagGuaranteed), mTrack(nTrack), mBar(nBar), mAutocatch(bAutocatch),
50 mValid(1) {
51 }
52
60 static Message *New();
61
68 void *operator new(size_t nSize) {
69 return PoolMemAlloc(static_cast<int>(nSize), "CapturePacket", 0);
70 }
71
77 void operator delete(void *pBlock) {
78 PoolMemFree(pBlock);
79 }
80
88 Message *Clone() override {
89 return new CapturePacket(*this);
90 }
91
99 int Type() override {
101 }
102
110 const char *GetName() const override {
111 return "CapturePacket";
112 }
113
121 void saveGuts(BinStream &stream) const override;
122
130 void restoreGuts(BinStream &stream) override;
131
133 int GetAutocatch() const {
134 return mAutocatch;
135 }
136
138 int GetBar() const {
139 return mBar;
140 }
141
143 int GetTrack() const {
144 return mTrack;
145 }
146
148 int GetValid() const {
149 return mValid;
150 }
151
153 void SetValid(int nValid) {
154 mValid = nValid;
155 }
156
157private:
158 int mTrack;
159 int mBar;
160 int mAutocatch;
161 int mValid;
162};
int g_nCapturePacketType
Identity that CapturePacket::Type() reports.
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
CapturePacket()
Construct a packet with no track and no bar.
Definition capturepacket.h:35
const char * GetName() const override
Report this packet's class name.
Definition capturepacket.h:110
void saveGuts(BinStream &stream) const override
Write the fields packed into one half-word.
~CapturePacket() override=default
Destroy the object.
int GetValid() const
Definition capturepacket.h:148
static Message * New()
Produce a default-constructed packet on the heap.
void SetValid(int nValid)
Definition capturepacket.h:153
int GetTrack() const
Definition capturepacket.h:143
Message * Clone() override
Produce a heap copy of this packet.
Definition capturepacket.h:88
void restoreGuts(BinStream &stream) override
Read the half-word saveGuts() writes back into the fields.
int GetBar() const
Definition capturepacket.h:138
int GetAutocatch() const
Definition capturepacket.h:133
int Type() override
Report this packet's registered identity.
Definition capturepacket.h:99
CapturePacket(int nTrack, int nBar, bool bAutocatch)
Construct a packet with every field set.
Definition capturepacket.h:48
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
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.