wavelength 1.0.0
Loading...
Searching...
No Matches
gameendedmsg.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
5#include "game/netgamescore.h"
6#include "msg/message.h"
7#include "os/mem.h"
8
15extern int g_nGameEndedMsgType;
16
23class GameEndedMsg : public Message {
24public:
31 ~GameEndedMsg() override = default;
32
40
48 explicit GameEndedMsg(int nResult) : mResult(nResult) {
49 }
50
59 GameEndedMsg(int nResult, const std::vector<NetGameScore> &scores)
60 : mResult(nResult), mScores(scores) {
61 }
62
69 void *operator new(size_t nSize) {
70 return PoolMemAlloc(static_cast<int>(nSize), "GameEndedMsg", 0);
71 }
72
78 void operator delete(void *pBlock) {
79 PoolMemFree(pBlock);
80 }
81
87 Message *Clone() override {
88 return new GameEndedMsg(*this);
89 }
90
96 int Type() override {
98 }
99
105 const char *GetName() const override {
106 return "GameEndedMsg";
107 }
108
116 void PrintExtra(PrnStream &stream) const override;
117
125 GameEndedMsg(const GameEndedMsg &other) = default;
126
128 int GetResult() const {
129 return mResult;
130 }
131
133 const std::vector<NetGameScore> &GetScores() const {
134 return mScores;
135 }
136
137private:
138 int mResult;
139 std::vector<NetGameScore> mScores;
140};
GameEndedMsg(int nResult, const std::vector< NetGameScore > &scores)
Construct a message with the final scores.
Definition gameendedmsg.h:59
int Type() override
Report this message's registered identity.
Definition gameendedmsg.h:96
void PrintExtra(PrnStream &stream) const override
Write the result, and the scores when there are any.
const char * GetName() const override
Report this message's class name.
Definition gameendedmsg.h:105
~GameEndedMsg() override=default
Destroy the object.
GameEndedMsg(const GameEndedMsg &other)=default
Copy another message.
const std::vector< NetGameScore > & GetScores() const
Definition gameendedmsg.h:133
Message * Clone() override
Produce a heap copy of this message.
Definition gameendedmsg.h:87
GameEndedMsg(int nResult)
Construct a message with no scores.
Definition gameendedmsg.h:48
Result
Values of mResult.
Definition gameendedmsg.h:34
@ kResultConnectionLost
Definition gameendedmsg.h:37
@ kResultBooted
Definition gameendedmsg.h:38
@ kResultHostAborted
Definition gameendedmsg.h:36
@ kResultFinished
Definition gameendedmsg.h:35
int GetResult() const
Definition gameendedmsg.h:128
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Text output stream.
Definition prnstream.h:16
int g_nGameEndedMsgType
Identity that GameEndedMsg::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.