wavelength 1.0.0
Loading...
Searching...
No Matches
playerupdatepacket.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
13
22public:
29 ~PlayerUpdatePacket() override = default;
30
36 PlayerUpdatePacket() : mTrack(-1), mPoints(-1), mCatching(0), mVersion(0) {
37 }
38
49 PlayerUpdatePacket(int nTrack, int nPoints, bool bCatching, int nVersion)
50 : mTrack(nTrack), mPoints(nPoints), mCatching(bCatching), mVersion(nVersion) {
51 }
52
60 static Message *New();
61
68 void *operator new(size_t nSize) {
69 return PoolMemAlloc(static_cast<int>(nSize), "PlayerUpdatePacket", 0);
70 }
71
77 void operator delete(void *pBlock) {
78 PoolMemFree(pBlock);
79 }
80
88 Message *Clone() override {
89 return new PlayerUpdatePacket(*this);
90 }
91
99 int Type() override {
101 }
102
110 const char *GetName() const override {
111 return "PlayerUpdatePacket";
112 }
113
121 void PrintExtra(PrnStream &stream) const override;
122
133 void saveGuts(BinStream &stream) const override;
134
142 void restoreGuts(BinStream &stream) override;
143
145 int GetCatching() const {
146 return mCatching;
147 }
148
150 int GetPoints() const {
151 return mPoints;
152 }
153
155 int GetTrack() const {
156 return mTrack;
157 }
158
160 int GetVersion() const {
161 return mVersion;
162 }
163
164private:
165 int mTrack;
166 int mPoints;
167 int mCatching;
168 int mVersion;
169};
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
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
void PrintExtra(PrnStream &stream) const override
Print the track, the score, the catching state, and the version.
static Message * New()
Produce a default-constructed packet on the heap.
const char * GetName() const override
Report this packet's class name.
Definition playerupdatepacket.h:110
int Type() override
Report this packet's registered identity.
Definition playerupdatepacket.h:99
int GetTrack() const
Definition playerupdatepacket.h:155
int GetPoints() const
Definition playerupdatepacket.h:150
void restoreGuts(BinStream &stream) override
Read the word saveGuts() writes back into the fields.
PlayerUpdatePacket()
Construct a packet with no track and no score.
Definition playerupdatepacket.h:36
PlayerUpdatePacket(int nTrack, int nPoints, bool bCatching, int nVersion)
Construct a packet with every field set.
Definition playerupdatepacket.h:49
~PlayerUpdatePacket() override=default
Destroy the object.
Message * Clone() override
Produce a heap copy of this packet.
Definition playerupdatepacket.h:88
void saveGuts(BinStream &stream) const override
Write the fields packed into one word.
int GetVersion() const
Definition playerupdatepacket.h:160
int GetCatching() const
Definition playerupdatepacket.h:145
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.
int g_nPlayerUpdatePacketType
Identity that PlayerUpdatePacket::Type() reports.