wavelength 1.0.0
Loading...
Searching...
No Matches
updaterankspkt.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
6#include "os/binstream.h"
7#include "os/mem.h"
8#include "os/prnstream.h"
9
16extern int g_nUpdateRanksPktType;
17
25public:
32 ~UpdateRanksPkt() override = default;
33
35 struct Info {
36 int mPlayer;
37 int mRank;
38 };
39
45 UpdateRanksPkt() = default;
46
54 explicit UpdateRanksPkt(const std::vector<Info> &ranks)
56 }
57
65 static Message *New();
66
73 void *operator new(size_t nSize) {
74 return PoolMemAlloc(static_cast<int>(nSize), "UpdateRanksPkt", 0);
75 }
76
82 void operator delete(void *pBlock) {
83 PoolMemFree(pBlock);
84 }
85
91 Message *Clone() override {
92 return new UpdateRanksPkt(*this);
93 }
94
100 int Type() override {
102 }
103
109 const char *GetName() const override {
110 return "UpdateRanksPkt";
111 }
112
120 void PrintExtra(PrnStream &stream) const override;
121
129 void saveGuts(BinStream &stream) const override;
130
138 void restoreGuts(BinStream &stream) override;
139
141 const std::vector<Info> &GetRanks() const {
142 return mRanks;
143 }
144
145private:
146 std::vector<Info> mRanks;
147};
148
159
170
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
InternalPacket(unsigned char nFlags=0, int nReceiver=kUnset)
Construct a packet from an unset sender.
Definition internalpacket.h:33
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
static constexpr unsigned char kFlagOrdered
Bit of mFlags that LaunchpadRT::Send() turns into the second delivery bit of the session library.
Definition packet.h:25
static constexpr int kAllPeers
Value of mReceiver that addresses every peer.
Definition packet.h:19
Text output stream.
Definition prnstream.h:16
UpdateRanksPkt()=default
Construct a packet with no ranks.
UpdateRanksPkt(const std::vector< Info > &ranks)
Construct a packet for every peer, ordered and guaranteed.
Definition updaterankspkt.h:54
const std::vector< Info > & GetRanks() const
Definition updaterankspkt.h:141
static Message * New()
Produce a default-constructed packet on the heap.
const char * GetName() const override
Report this packet's class name.
Definition updaterankspkt.h:109
void PrintExtra(PrnStream &stream) const override
Write the sender, the receiver, and the ranks.
Message * Clone() override
Produce a heap copy of this packet.
Definition updaterankspkt.h:91
~UpdateRanksPkt() override=default
Destroy the object.
void saveGuts(BinStream &stream) const override
Write the ranks.
void restoreGuts(BinStream &stream) override
Read the ranks.
int Type() override
Report this packet's registered identity.
Definition updaterankspkt.h:100
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.
The rank of one player.
Definition updaterankspkt.h:35
int mRank
Definition updaterankspkt.h:37
int mPlayer
Definition updaterankspkt.h:36
BinStream & operator>>(BinStream &stream, UpdateRanksPkt::Info &info)
Read a rank operator<<() wrote.
int g_nUpdateRanksPktType
Identity that UpdateRanksPkt::Type() reports.
PrnStream & operator<<(PrnStream &stream, const UpdateRanksPkt::Info &info)
Write a rank as player:rank.