wavelength 1.0.0
Loading...
Searching...
No Matches
fxpacket.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
12extern int g_nFXPacketType;
13
20class FXPacket : public ExternalPacket {
21public:
28 ~FXPacket() override = default;
29
35 FXPacket() : ExternalPacket(kFlagGuaranteed), mSection(-1), mTrack(-1), mType(0), mOn(0) {
36 }
37
45 static Message *New();
46
53 void *operator new(size_t nSize) {
54 return PoolMemAlloc(static_cast<int>(nSize), "FXPacket", 0);
55 }
56
62 void operator delete(void *pBlock) {
63 PoolMemFree(pBlock);
64 }
65
73 Message *Clone() override {
74 return new FXPacket(*this);
75 }
76
84 int Type() override {
85 return g_nFXPacketType;
86 }
87
95 const char *GetName() const override {
96 return "FXPacket";
97 }
98
106 void PrintExtra(PrnStream &stream) const override;
107
118 void saveGuts(BinStream &stream) const override;
119
127 void restoreGuts(BinStream &stream) override;
128
130 int GetOn() const {
131 return mOn;
132 }
133
135 void SetOn(int nOn) {
136 mOn = nOn;
137 }
138
140 int GetSection() const {
141 return mSection;
142 }
143
145 void SetSection(int nSection) {
146 mSection = nSection;
147 }
148
150 int GetTrack() const {
151 return mTrack;
152 }
153
155 void SetTrack(int nTrack) {
156 mTrack = nTrack;
157 }
158
160 int GetType() const {
161 return mType;
162 }
163
165 void SetType(int nType) {
166 mType = nType;
167 }
168
169private:
170 int mSection;
171 int mTrack;
172 int mType;
173 int mOn;
174};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
ExternalPacket(unsigned char nFlags=0, int nReceiver=kAllPeers)
Construct a packet from an unset sender.
Definition externalpacket.h:21
Message * Clone() override
Produce a heap copy of this packet.
Definition fxpacket.h:73
static Message * New()
Produce a default-constructed packet on the heap.
int GetOn() const
Definition fxpacket.h:130
void SetType(int nType)
Definition fxpacket.h:165
void PrintExtra(PrnStream &stream) const override
Write the section, the track, the effect, and the switch to a diagnostic stream.
int GetType() const
Definition fxpacket.h:160
int Type() override
Report this packet's registered identity.
Definition fxpacket.h:84
void SetTrack(int nTrack)
Definition fxpacket.h:155
const char * GetName() const override
Report this packet's class name.
Definition fxpacket.h:95
void SetSection(int nSection)
Definition fxpacket.h:145
int GetTrack() const
Definition fxpacket.h:150
int GetSection() const
Definition fxpacket.h:140
void SetOn(int nOn)
Definition fxpacket.h:135
void restoreGuts(BinStream &stream) override
Read the two bytes saveGuts() writes back into the fields.
void saveGuts(BinStream &stream) const override
Write the payload packed into two bytes.
FXPacket()
Construct a packet with no section and no track.
Definition fxpacket.h:35
~FXPacket() override=default
Destroy the object.
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
Text output stream.
Definition prnstream.h:16
int g_nFXPacketType
Identity that FXPacket::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.