wavelength 1.0.0
Loading...
Searching...
No Matches
cripplerpacket.h
Go to the documentation of this file.
1#pragma once
2
4#include "os/mem.h"
5
12extern int g_nCripplerPacketType;
13
21public:
28 ~CripplerPacket() override = default;
29
37
45 explicit CripplerPacket(int nVictim) : ExternalPacket(kFlagGuaranteed), mVictim(nVictim) {
46 }
47
55 static Message *New();
56
63 void *operator new(size_t nSize) {
64 return PoolMemAlloc(static_cast<int>(nSize), "CripplerPacket", 0);
65 }
66
72 void operator delete(void *pBlock) {
73 PoolMemFree(pBlock);
74 }
75
83 Message *Clone() override {
84 return new CripplerPacket(*this);
85 }
86
94 int Type() override {
96 }
97
105 const char *GetName() const override {
106 return "CripplerPacket";
107 }
108
116 void saveGuts(BinStream &stream) const override;
117
125 void restoreGuts(BinStream &stream) override;
126
128 int GetVictim() const {
129 return mVictim;
130 }
131
132private:
133 int mVictim;
134};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
int GetVictim() const
Definition cripplerpacket.h:128
~CripplerPacket() override=default
Destroy the object.
int Type() override
Report this packet's registered identity.
Definition cripplerpacket.h:94
Message * Clone() override
Produce a heap copy of this packet.
Definition cripplerpacket.h:83
const char * GetName() const override
Report this packet's class name.
Definition cripplerpacket.h:105
void saveGuts(BinStream &stream) const override
Write the victim as one byte.
static Message * New()
Produce a default-constructed packet on the heap.
void restoreGuts(BinStream &stream) override
Read the byte saveGuts() writes back into the victim.
CripplerPacket()
Construct a packet with no victim.
Definition cripplerpacket.h:35
CripplerPacket(int nVictim)
Construct a packet for a victim.
Definition cripplerpacket.h:45
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_nCripplerPacketType
Identity that CripplerPacket::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.