wavelength 1.0.0
Loading...
Searching...
No Matches
freestylebumppacket.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
13
21public:
28 ~FreestyleBumpPacket() override = default;
29
35 FreestyleBumpPacket() : ExternalPacket(kFlagGuaranteed), mNetOrder(-1), mTrack(-1) {
36 }
37
46 FreestyleBumpPacket(int nNetOrder, int nTrack)
47 : ExternalPacket(kFlagGuaranteed), mNetOrder(nNetOrder), mTrack(nTrack) {
48 }
49
57 static Message *New();
58
65 void *operator new(size_t nSize) {
66 return PoolMemAlloc(static_cast<int>(nSize), "FreestyleBumpPacket", 0);
67 }
68
74 void operator delete(void *pBlock) {
75 PoolMemFree(pBlock);
76 }
77
85 Message *Clone() override {
86 return new FreestyleBumpPacket(*this);
87 }
88
96 int Type() override {
98 }
99
107 const char *GetName() const override {
108 return "FreestyleBumpPacket";
109 }
110
118 void saveGuts(BinStream &stream) const override;
119
127 void restoreGuts(BinStream &stream) override;
128
136 void PrintExtra(PrnStream &stream) const override;
137
139 int GetNetOrder() const {
140 return mNetOrder;
141 }
142
144 int GetTrack() const {
145 return mTrack;
146 }
147
148private:
149 int mNetOrder;
150 int mTrack;
151};
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 freestylebumppacket.h:85
int Type() override
Report this packet's registered identity.
Definition freestylebumppacket.h:96
FreestyleBumpPacket(int nNetOrder, int nTrack)
Construct a packet for a player and a track.
Definition freestylebumppacket.h:46
void saveGuts(BinStream &stream) const override
Write the player and the track packed into one byte.
int GetNetOrder() const
Definition freestylebumppacket.h:139
int GetTrack() const
Definition freestylebumppacket.h:144
void PrintExtra(PrnStream &stream) const override
Write the player and the track.
static Message * New()
Produce a default-constructed packet on the heap.
void restoreGuts(BinStream &stream) override
Read the byte saveGuts() writes back into the fields.
const char * GetName() const override
Report this packet's class name.
Definition freestylebumppacket.h:107
~FreestyleBumpPacket() override=default
Destroy the object.
FreestyleBumpPacket()
Construct a packet with no player and no track.
Definition freestylebumppacket.h:35
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_nFreestyleBumpPacketType
Identity that FreestyleBumpPacket::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.