wavelength 1.0.0
Loading...
Searching...
No Matches
sectionchangepacket.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/binstream.h"
5#include "os/mem.h"
6
14
23public:
30 ~SectionChangePacket() override = default;
31
37 SectionChangePacket() : ExternalPacket(kFlagGuaranteed), mSection(-1), mTick(-1) {
38 }
39
47 static Message *New();
48
55 void *operator new(size_t nSize) {
56 return PoolMemAlloc(static_cast<int>(nSize), "SectionChangePacket", 0);
57 }
58
64 void operator delete(void *pBlock) {
65 PoolMemFree(pBlock);
66 }
67
75 Message *Clone() override {
76 return new SectionChangePacket(*this);
77 }
78
86 int Type() override {
88 }
89
97 const char *GetName() const override {
98 return "SectionChangePacket";
99 }
100
108 void saveGuts(BinStream &stream) const override;
109
117 void restoreGuts(BinStream &stream) override;
118
120 int GetSection() const {
121 return mSection;
122 }
123
125 void SetSection(int nSection) {
126 mSection = nSection;
127 }
128
130 int GetTick() const {
131 return mTick;
132 }
133
135 void SetTick(int nTick) {
136 mTick = nTick;
137 }
138
139private:
140 int mSection;
141 int mTick;
142};
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
static constexpr unsigned char kFlagGuaranteed
Bit of mFlags that NetTransport::Send() turns into its guaranteed delivery bit.
Definition packet.h:28
void saveGuts(BinStream &stream) const override
Write the payload.
int Type() override
Report this packet's registered identity.
Definition sectionchangepacket.h:86
~SectionChangePacket() override=default
Destroy the object.
void restoreGuts(BinStream &stream) override
Read the payload.
SectionChangePacket()
Construct a packet with no section.
Definition sectionchangepacket.h:37
static Message * New()
Produce a default-constructed packet on the heap.
void SetSection(int nSection)
Definition sectionchangepacket.h:125
Message * Clone() override
Produce a heap copy of this packet.
Definition sectionchangepacket.h:75
int GetSection() const
Definition sectionchangepacket.h:120
void SetTick(int nTick)
Definition sectionchangepacket.h:135
const char * GetName() const override
Report this packet's class name.
Definition sectionchangepacket.h:97
int GetTick() const
Definition sectionchangepacket.h:130
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_nSectionChangePacketType
Identity that SectionChangePacket::Type() reports.