|
wavelength 1.0.0
|
The online session of this console on top of the session library, the base of HostpadRT and JoinpadRT. More...
#include <launchpadrt.h>


Public Types | |
| enum | State { kStateFailed = -1 , kStateConnecting = 0 , kStateConnected = 1 , kStateWelcomed = 2 , kStateSynced = 3 } |
| Values of mState. More... | |
| enum | Ready { kReadyNo = 0 , kReadyYes = 1 , kReadyLoading = 2 , kReadyLoaded = 3 } |
| Values of NetLaunchpadPlayer::mReady. More... | |
Public Member Functions | |
| LaunchpadRT (MsgSink *pGame) | |
| Construct the session, stored in TheNetLaunchpad and TheLaunchpadRT. | |
| ~LaunchpadRT () override | |
| Stop the requests, and clear TheNetLaunchpad and TheLaunchpadRT. | |
| void | Cancel (MsgSink *pSink) override |
| Exit the session with reason 0. | |
| void | Activate () override |
| Mark the session active, and report this console ready when it can be. | |
| void | NotifyLoaded () override |
| Report this console loaded. | |
| int | IsGuest () override |
| Report mLocalId. | |
| int | GetPlayersVersion () override |
| Report sPlayersVersion. | |
| std::list< NetLaunchpadPlayer > * | GetPlayers () override |
| Report mPlayers. | |
| virtual void | ReportNow () |
| Vtable slot 12. | |
| virtual void | SetLocalId (int nId) |
| Vtable slot 13. | |
| virtual void | AddClient (int nId) |
| Vtable slot 14. | |
| virtual void | RemovePlayer (int nId) |
| Vtable slot 15. | |
| virtual float | GetTime ()=0 |
| Vtable slot 16. | |
| virtual void | OnConnected ()=0 |
| Vtable slot 17. | |
| virtual void | PollPriv ()=0 |
| Vtable slot 18. | |
| virtual void | EndGame () |
| Vtable slot 19. | |
| virtual void | SendRating (int nRank) |
| Vtable slot 20. | |
| bool | DispatchPriv (Message *pMsg) override |
| Act on a packet of the session. | |
| void | SetReady (int nReady) |
| Set the state of this console and send it to every console. | |
| int | Poll () |
| Service the session once per frame. | |
| NetLaunchpadPlayer * | FindPlayer (int nId) |
| Find a player of the session. | |
| NetLaunchpadPlayer * | GetLocalPlayer () |
| Find the player of this console. | |
| void | AddPlayer (const NetLaunchpadPlayer &player) |
| Insert a player before the first player with a higher colour. | |
| void | StartGame () |
| Start the song, and rate the start of a rated game as a loss of this console. | |
| void | DropRating (int nId) |
| Rate a player who left as a loser, and drop every guest when the host left. | |
| void | RateGame (const std::vector< NetGameScore > &scores) |
| Rate the players from the final scores of the game, and clear the rating. | |
| void | UpdateRating () |
| Rate the player of this console from mRatings and publish the rating. | |
| void | Exit (MsgSink *pSink, int nReason) |
| End the game and start mExitTask. | |
| int | FindIdByAccount (int nAccountId) |
| Find the identifier in the session of an account. | |
| void | Abort (int nReason) |
| Exit the session for mGameSink. | |
| void | Send (Packet *pPacket) |
| Encrypt a packet and send it to the consoles its receiver selects. | |
| void | Leave () |
| Leave the game and tell the other consoles. | |
| void | PlayersChanged () |
| Count a change of the players. | |
| void | CheckReady () |
| Report this console ready once the session is active and synced. | |
| bool | OnMsg (ClientStatusPkt *pPkt) |
| Take the state of a player. | |
| bool | OnMsg (ClientRatingPkt *pPkt) |
| Take the rating of a player. | |
| bool | OnMsg (LoadGamePkt *pPkt) |
| Enter the game, and tell mGameSink to load the song. | |
| bool | OnMsg (StartGamePkt *pPkt) |
| Take the time the song starts at and the seed of the game. | |
| bool | OnMsg (ClientAbortedPkt *pPkt) |
| Drop a player who exited the game, and end the game when the host exited. | |
| bool | OnMsg (UpdateRanksPkt *pPkt) |
| Take the ranks of the players. | |
| int | GetWorldId () const |
| void | SetWorldId (int nValue) |
| const rtNetConnectionInfo & | GetConnectionInfo () const |
| void | SetConnectionInfo (const rtNetConnectionInfo &info) |
| int | GetConnection () const |
| void | SetConnection (int nValue) |
| int | GetLocalId () const |
| void | SetLocalIdValue (int nValue) |
| int | GetState () const |
| void | SetState (int nValue) |
| int | GetError () const |
| void | SetError (int nValue) |
| MsgSink * | GetGameSink () const |
| std::list< NetLaunchpadPlayer > & | GetPlayersList () |
| const std::vector< int > & | GetClients () const |
| Public Member Functions inherited from NetLaunchpad | |
| virtual void | EndEdit () |
| Vtable slot 7. | |
| virtual bool | ShareRemix () |
| Vtable slot 8. | |
| virtual int | Launch () |
| Vtable slot 9. | |
| virtual void | BootPlayer (int nPlayer) |
| Vtable slot 10. | |
| virtual | ~NetLaunchpad () |
| Vtable slot 11. | |
| Public Member Functions inherited from MsgSink | |
| void * | operator new (size_t nSize) |
| Allocate a sink from the pool heaps under the tag "MsgSink". | |
| void | operator delete (void *pBlock) |
| Return a sink to the pool heaps. | |
| virtual | ~MsgSink () |
| virtual bool | Dispatch (Message *pMsg) |
| Accept a message. | |
| void * | operator new (size_t size) |
| Allocate from the main heap under the name MsgSink. | |
| void | operator delete (void *mem) |
| Return memory to its heap. | |
| virtual | ~MsgSink () |
| Destroy the sink. | |
| virtual bool | Dispatch (Message *msg) |
| Handle a message. | |
Static Public Member Functions | |
| static int | RegisterMessages () |
| Register the packets of the session with the session library. | |
| static void | SetMgclReady (int nReady) |
| Set sMgclReady. | |
| static int | IsMgclReady () |
| Report sMgclReady. | |
| static NetTask * | GetNetTask () |
| static void | SetNetTask (NetTask *pTask) |
| static unsigned char | DecodeByte (const char *pszText) |
| Read a byte EncodeByte() wrote. | |
| static void | EncodeByte (char *pszText, unsigned char nByte) |
| Write a byte as two characters and a terminator. | |
| static int | FindScore (const std::vector< NetGameScore > &scores, int nId) |
| Report the score of a player in the final scores. | |
| static int | Receive (int nConnection, int nType, int nSender, rtDmeMessage *pMessage) |
| Receive a message of the session, the handler rtDmeRegisterMessageHandler() registers. | |
| static void | OnNetConnect (int nConnection, int nReserved1, int nReserved2, int nStatus) |
| Receive the result of NetHostTask and NetConnectTask, and finish sNetTask. | |
| static void | OnNetClientJoin (int nConnection, int nClient, const char *pszAddress) |
| Note a console that connected to the session. | |
| static void | OnNetClientLeave (int nConnection, int nClient, const char *pszAddress) |
| Remove a console that left the session. | |
Static Public Attributes | |
| static constexpr int | kHostId = 0 |
| The identifier of the host in the session. | |
| static constexpr int | kNoId = -2 |
| The identifier of a console that has none yet. | |
| static constexpr int | kNoWorld = -1 |
| The value of mWorldId and mConnection without a session. | |
| static constexpr int | kKeyChannel = 4 |
| The chat channel the session exchanges its key on. | |
| static constexpr int | kKeySize = 16 |
| The size of the key of the session in bytes. | |
| static constexpr int | kMaxClients = 5 |
| The consoles a session takes on the session library and the game server. | |
| static constexpr int | kGameHostPeerToPeer = 2 |
| The kind of host the session reports to the servers, a host among its peers. | |
Protected Attributes | |
| int | mWorldId |
| rtNetConnectionInfo | mConnectionInfo |
| int | mConnection |
| int | mLocalId |
| int | mState |
| int | mError |
| MsgSink * | mGameSink |
| NetMultiTask | mConnectTask |
| NetMultiTask | mExitTask |
| NetMultiTask | mRankTask |
| PeriodicTask | mPlayerReport |
| TaskList | mTasks |
| std::list< NetLaunchpadPlayer > | mPlayers |
| float | mStartTime |
| int | mSeed |
| int | mActive |
| int | mShareOnly |
| int | mStarting |
| int | mInGame |
| std::vector< int > | mClients |
| std::vector< RatingStat > | mRatings |
The online session of this console on top of the session library, the base of HostpadRT and JoinpadRT.
The RTTI includes the class name and records MsgSink and NetLaunchpad as the bases. The NetLaunchpad part is at offset 0 with the vtable at 0x003d4770, and the MsgSink part is at offset 4 with the vtable at 0x003d4748. The object is 0x17c bytes. The constructor stores the instance in TheNetLaunchpad and TheLaunchpadRT.
The session runs three requests. mConnectTask connects to the session, mExitTask leaves it, and mRankTask asks for the ladder position of the player after a game. The players are listed in the order of their colours.
| enum LaunchpadRT::State |
Values of mState.
| enum LaunchpadRT::Ready |
Values of NetLaunchpadPlayer::mReady.
| Enumerator | |
|---|---|
| kReadyNo | The player is not ready. |
| kReadyYes | The player is ready. |
| kReadyLoading | The player loads the song. |
| kReadyLoaded | The player loaded the song. |
|
explicit |
Construct the session, stored in TheNetLaunchpad and TheLaunchpadRT.
The constructor gives the player report its task, registers the session for the chat of kKeyChannel, and adds the ladder position request to mRankTask.
| pGame | The sink that receives the messages of the session. |
|
override |
Stop the requests, and clear TheNetLaunchpad and TheLaunchpadRT.
|
overridevirtual |
Exit the session with reason 0.
| pSink | The sink that receives the end of the session. |
Implements NetLaunchpad.
|
overridevirtual |
Mark the session active, and report this console ready when it can be.
Implements NetLaunchpad.
|
overridevirtual |
Report this console loaded.
Implements NetLaunchpad.
|
overridevirtual |
Report mLocalId.
Implements NetLaunchpad.
|
overridevirtual |
Report sPlayersVersion.
Implements NetLaunchpad.
|
inlineoverridevirtual |
Report mPlayers.
Inline.
Implements NetLaunchpad.
|
virtual |
Vtable slot 12.
Send the player report at the next poll.
The base does so only in a session. The name is inferred.
Reimplemented in HostpadRT.
|
virtual |
Vtable slot 13.
Take the identifier of this console in the session.
The name is inferred.
| nId | The identifier. |
Reimplemented in HostpadRT.
|
virtual |
Vtable slot 14.
Note a console that connected to the session.
The base sends the console the player of this console once this console is welcomed. The name is inferred.
| nId | The identifier of the console. |
Reimplemented in HostpadRT.
|
virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
virtual |
Vtable slot 19.
Leave the game of the session and return to the launchpad.
The base closes the transport, clears the rating, marks this console not ready, and starts mRankTask. The name is inferred.
Reimplemented in HostpadRT.
|
virtual |
Vtable slot 20.
Send the rating of this console to the other consoles.
The name is inferred.
| nRank | The position of the player in the ranking. |
Reimplemented in HostpadRT.
|
overridevirtual |
Act on a packet of the session.
| pMsg | The message. |
Implements MsgSink.
| void LaunchpadRT::SetReady | ( | int | nReady | ) |
Set the state of this console and send it to every console.
The name is inferred.
| nReady | One of Ready. |
| int LaunchpadRT::Poll | ( | ) |
Service the session once per frame.
The routine polls the requests, sends the player of this console to the consoles that connected, and starts the song once its time comes.
| NetLaunchpadPlayer * LaunchpadRT::FindPlayer | ( | int | nId | ) |
Find a player of the session.
| nId | The player's identifier in the session. |
| NetLaunchpadPlayer * LaunchpadRT::GetLocalPlayer | ( | ) |
Find the player of this console.
| void LaunchpadRT::AddPlayer | ( | const NetLaunchpadPlayer & | player | ) |
Insert a player before the first player with a higher colour.
| player | The player. |
| void LaunchpadRT::StartGame | ( | ) |
Start the song, and rate the start of a rated game as a loss of this console.
The name is inferred.
| void LaunchpadRT::DropRating | ( | int | nId | ) |
Rate a player who left as a loser, and drop every guest when the host left.
The name is inferred.
| nId | The player's identifier in the session. |
| void LaunchpadRT::RateGame | ( | const std::vector< NetGameScore > & | scores | ) |
Rate the players from the final scores of the game, and clear the rating.
The name is inferred.
| scores | The final score of each player. |
| void LaunchpadRT::UpdateRating | ( | ) |
Rate the player of this console from mRatings and publish the rating.
The name is inferred.
| void LaunchpadRT::Exit | ( | MsgSink * | pSink, |
| int | nReason ) |
End the game and start mExitTask.
The name is inferred.
| pSink | The sink that receives the end of the session. |
| nReason | A LaunchpadAbortedMsg::Reason, or 0. |
| int LaunchpadRT::FindIdByAccount | ( | int | nAccountId | ) |
Find the identifier in the session of an account.
The name is inferred.
| nAccountId | The account. |
| void LaunchpadRT::Abort | ( | int | nReason | ) |
Exit the session for mGameSink.
The name is inferred.
| nReason | A LaunchpadAbortedMsg::Reason. |
| void LaunchpadRT::Send | ( | Packet * | pPacket | ) |
Encrypt a packet and send it to the consoles its receiver selects.
| pPacket | The packet. |
| void LaunchpadRT::Leave | ( | ) |
Leave the game and tell the other consoles.
The name is inferred.
| void LaunchpadRT::PlayersChanged | ( | ) |
Count a change of the players.
The name is inferred.
| void LaunchpadRT::CheckReady | ( | ) |
Report this console ready once the session is active and synced.
The name is inferred.
| bool LaunchpadRT::OnMsg | ( | ClientStatusPkt * | pPkt | ) |
Take the state of a player.
| pPkt | The packet. |
| bool LaunchpadRT::OnMsg | ( | ClientRatingPkt * | pPkt | ) |
Take the rating of a player.
| pPkt | The packet. |
| bool LaunchpadRT::OnMsg | ( | LoadGamePkt * | pPkt | ) |
Enter the game, and tell mGameSink to load the song.
| pPkt | The packet. |
| bool LaunchpadRT::OnMsg | ( | StartGamePkt * | pPkt | ) |
Take the time the song starts at and the seed of the game.
| pPkt | The packet. |
| bool LaunchpadRT::OnMsg | ( | ClientAbortedPkt * | pPkt | ) |
Drop a player who exited the game, and end the game when the host exited.
| pPkt | The packet. |
| bool LaunchpadRT::OnMsg | ( | UpdateRanksPkt * | pPkt | ) |
Take the ranks of the players.
| pPkt | The packet. |
|
static |
Register the packets of the session with the session library.
The name is inferred.
|
static |
Set sMgclReady.
The name is inferred.
| nReady | Non-zero once the game server library is ready. |
|
static |
Report sMgclReady.
The name is inferred.
|
inlinestatic |
|
inlinestatic |
| pTask | The NetHostTask or NetConnectTask that waits for OnNetConnect(), or null. |
|
static |
Read a byte EncodeByte() wrote.
Each character is a digit offset from '0' by one half of the byte. The name is inferred.
| pszText | The two characters. |
|
static |
Write a byte as two characters and a terminator.
The name is inferred.
| pszText | Receives the three characters. |
| nByte | The byte. |
|
static |
Report the score of a player in the final scores.
The name is inferred.
| scores | The final score of each player. |
| nId | The player's identifier in the session. |
|
inline |
|
inline |
| nValue | The session on the game server, or kNoWorld. |
|
inline |
|
inline |
| info | The connection to the session. |
|
inline |
|
inline |
| nValue | The connection of the session library, or -1. |
|
inline |
|
inline |
| nValue | The identifier of this console, or kNoId. |
|
inline |
|
inline |
| nValue | One of State. |
|
inline |
|
inline |
| nValue | Why the host turned the console away. |
|
inline |
|
inline |
|
inline |
|
static |
Receive a message of the session, the handler rtDmeRegisterMessageHandler() registers.
The routine decrypts the message, reads the packet, and passes it to the receivers its Packet::Route() selects.
| nConnection | The connection. |
| nType | The registered type. |
| nSender | The peer that sent the message. |
| pMessage | The message. |
|
static |
Receive the result of NetHostTask and NetConnectTask, and finish sNetTask.
The routine takes the identifier of this console from the session library. The host must have identifier kHostId and a guest must not. The name is inferred.
| nConnection | The connection. |
| nReserved1 | Not read. |
| nReserved2 | Not read. |
| nStatus | 0 for success, otherwise an error of the library. |
|
static |
Note a console that connected to the session.
The name is inferred.
| nConnection | The connection. |
| nClient | The identifier of the console. |
| pszAddress | The address of the console. Not read. |
|
static |
Remove a console that left the session.
The name is inferred.
| nConnection | The connection. |
| nClient | The identifier of the console. |
| pszAddress | The address the departure was reported for. Not read. |
|
staticconstexpr |
The identifier of the host in the session.
|
staticconstexpr |
The identifier of a console that has none yet.
|
staticconstexpr |
The value of mWorldId and mConnection without a session.
|
staticconstexpr |
The chat channel the session exchanges its key on.
|
staticconstexpr |
The size of the key of the session in bytes.
|
staticconstexpr |
The consoles a session takes on the session library and the game server.
|
staticconstexpr |
The kind of host the session reports to the servers, a host among its peers.
|
protected |
The session on the game server, or kNoWorld.
|
protected |
The connection to the session.
|
protected |
The connection of the session library, or -1.
|
protected |
The identifier of this console, or kNoId.
|
protected |
One of State.
|
protected |
Why the host turned the console away.
|
protected |
The sink that receives the session's messages. Borrowed.
|
protected |
The request that connects to the session.
|
protected |
The request that exits the session.
|
protected |
The request for the ladder position after a game.
|
protected |
The report of the player to the game server.
|
protected |
Further requests that run side by side.
|
protected |
The players, in the order of their colours.
|
protected |
The clock of the session the song starts at.
|
protected |
The seed of the game.
|
protected |
Non-zero once Activate() ran.
|
protected |
The share-only flag of the remix of the game.
|
protected |
Non-zero while the song is about to start.
|
protected |
Non-zero during the game.
|
protected |
The consoles AddClient() noted.
|
protected |
The rating of the game, while it runs.