wavelength 1.0.0
Loading...
Searching...
No Matches
editgempacket.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
12extern int g_nEditGemPacketType;
13
21public:
28 ~EditGemPacket() override = default;
29
36 : ExternalPacket(kFlagGuaranteed), mTrack(-1), mSlot(-1), mTick(-1), mRepeat(0) {
37 }
38
49 EditGemPacket(int nTrack, int nSlot, int nTick, bool bRepeat)
50 : ExternalPacket(kFlagGuaranteed), mTrack(nTrack), mSlot(nSlot), mTick(nTick),
51 mRepeat(bRepeat) {
52 }
53
61 static Message *New();
62
69 void *operator new(size_t nSize) {
70 return PoolMemAlloc(static_cast<int>(nSize), "EditGemPacket", 0);
71 }
72
78 void operator delete(void *pBlock) {
79 PoolMemFree(pBlock);
80 }
81
89 Message *Clone() override {
90 return new EditGemPacket(*this);
91 }
92
100 int Type() override {
102 }
103
111 const char *GetName() const override {
112 return "EditGemPacket";
113 }
114
124 void saveGuts(BinStream &stream) const override;
125
133 void restoreGuts(BinStream &stream) override;
134
136 int GetRepeat() const {
137 return mRepeat;
138 }
139
141 int GetSlot() const {
142 return mSlot;
143 }
144
146 int GetTick() const {
147 return mTick;
148 }
149
151 int GetTrack() const {
152 return mTrack;
153 }
154
155private:
156 int mTrack;
157 int mSlot;
158 int mTick;
159 int mRepeat;
160};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
~EditGemPacket() override=default
Destroy the object.
int GetRepeat() const
Definition editgempacket.h:136
int GetTrack() const
Definition editgempacket.h:151
EditGemPacket(int nTrack, int nSlot, int nTick, bool bRepeat)
Construct a packet for a gem placed or removed.
Definition editgempacket.h:49
EditGemPacket()
Construct a packet with no track and no gem.
Definition editgempacket.h:35
int GetTick() const
Definition editgempacket.h:146
int Type() override
Report this packet's registered identity.
Definition editgempacket.h:100
const char * GetName() const override
Report this packet's class name.
Definition editgempacket.h:111
int GetSlot() const
Definition editgempacket.h:141
Message * Clone() override
Produce a heap copy of this packet.
Definition editgempacket.h:89
void restoreGuts(BinStream &stream) override
Read the word saveGuts() writes back into the fields.
void saveGuts(BinStream &stream) const override
Write the fields packed into one word.
static Message * New()
Produce a default-constructed packet on the heap.
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_nEditGemPacketType
Identity that EditGemPacket::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.