wavelength 1.0.0
Loading...
Searching...
No Matches
clientratingpkt.h
Go to the documentation of this file.
1#pragma once
2
5#include "os/mem.h"
6
13extern int g_nClientRatingPktType;
14
22public:
28 ClientRatingPkt() : mRecord() {
29 }
30
41 ClientRatingPkt(int nRating, int nRank, int nGames, const RatingRecord &record)
42 : InternalPacket(kFlagOrdered | kFlagGuaranteed, kAllPeers), mRating(nRating), mRank(nRank),
43 mGames(nGames), mRecord(record) {
44 }
45
53 static Message *New();
54
61 void *operator new(size_t nSize) {
62 return PoolMemAlloc(static_cast<int>(nSize), "ClientRatingPkt", 0);
63 }
64
70 void operator delete(void *pBlock) {
71 PoolMemFree(pBlock);
72 }
73
79 Message *Clone() override {
80 return new ClientRatingPkt(*this);
81 }
82
88 int Type() override {
90 }
91
97 const char *GetName() const override {
98 return "ClientRatingPkt";
99 }
100
108 void PrintExtra(PrnStream &stream) const override;
109
117 void saveGuts(BinStream &stream) const override;
118
126 void restoreGuts(BinStream &stream) override;
127
129 int GetGames() const {
130 return mGames;
131 }
132
134 int GetRank() const {
135 return mRank;
136 }
137
139 int GetRating() const {
140 return mRating;
141 }
142
144 const RatingRecord &GetRecord() const {
145 return mRecord;
146 }
147
148private:
149 int mRating;
150 int mRank;
151 int mGames;
152 RatingRecord mRecord;
153};
Stream of raw bytes, the base of the memory, file, and network streams.
Definition binstream.h:22
int GetRank() const
Definition clientratingpkt.h:134
int Type() override
Report this packet's registered identity.
Definition clientratingpkt.h:88
void PrintExtra(PrnStream &stream) const override
Write the sender, the receiver, the rating, the rank, the games, and the record.
void saveGuts(BinStream &stream) const override
Write the rating, the rank, and the games as four bytes each, and the record.
ClientRatingPkt(int nRating, int nRank, int nGames, const RatingRecord &record)
Construct a packet for every peer, ordered and guaranteed.
Definition clientratingpkt.h:41
ClientRatingPkt()
Construct a packet with an empty record.
Definition clientratingpkt.h:28
const RatingRecord & GetRecord() const
Definition clientratingpkt.h:144
int GetRating() const
Definition clientratingpkt.h:139
const char * GetName() const override
Report this packet's class name.
Definition clientratingpkt.h:97
void restoreGuts(BinStream &stream) override
Read what saveGuts() wrote.
static Message * New()
Produce a default-constructed packet on the heap.
Message * Clone() override
Produce a heap copy of this packet.
Definition clientratingpkt.h:79
int GetGames() const
Definition clientratingpkt.h:129
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
int g_nClientRatingPktType
Identity that ClientRatingPkt::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.
The results of the online games of a player that the next rating weighs.
Definition ratingrecord.h:10