wavelength 1.0.0
Loading...
Searching...
No Matches
HostpadRT Class Reference

The online session of a console that hosts it. More...

#include <hostpadrt.h>

Inheritance diagram for HostpadRT:
Collaboration diagram for HostpadRT:

Classes

struct  ClientClr
 The colour of a slot of the session and the player who holds it. More...
class  ClientData
 The rank and the rating of a player, from which the host ranks the players. More...

Public Member Functions

 HostpadRT (MsgSink *pScreen, MsgSink *pGame)
 Construct the session, draw its key, and start mConnectTask.
 ~HostpadRT () override
 Stop mShareTask and clear TheHostpadRT.
void EndEdit () override
 Take the settings of the game again and publish them once the remix name is filtered.
bool ShareRemix () override
 Share the remix of the game with the guests only.
int Launch () override
 Load the song on every console once every player is ready.
void BootPlayer (int nPlayer) override
 Ban a guest from the session and remove the guest.
void ReportNow () override
 Send the reports to the game server at the next poll.
void SetLocalId (int nId) override
 Take the identifier of this console and enter the host as the first player.
void AddClient (int nId) override
 Welcome a console that connected, or turn it away.
void RemovePlayer (int nId) override
 Free the colour of a player who left, and forget the player.
float GetTime () override
 Report the clock of this console, the clock of the session.
void OnConnected () override
 Report HostLaunchpadSuccessMsg to the sink of mConnectTask.
void PollPriv () override
 Poll the reports and the share, and watch the connection to the game server.
void EndGame () override
 Leave the game and send the reports.
void SendRating (int nRank) override
 Send the rating of the host and note it in mClientData.
bool DispatchPriv (Message *pMsg) override
 Act on a packet of the session, before LaunchpadRT does.
void SendGameParams ()
 Send the settings of the game to every console, and send the world report at the next poll.
bool StartShare (int nShareOnly)
 Share the remix of the game with every guest once every player is ready.
void Kick (int nId, int nBan)
 Remove a guest from the session, and ban the guest from the game server first.
void SendScores (const std::vector< NetGameScore > &scores)
 Send the final scores to every console, rate the game, and leave it.
void PollStart ()
 Start the song once every console loaded it, and remove the consoles too slow to load.
void KickUnloaded ()
 Remove every guest that has not loaded the song.
void PollShare ()
 Send the next block of the remix once every guest acknowledged the last, and remove the guests too slow to.
int CanJoin ()
 Report whether the session takes another player.
int GetWorldStatus ()
 Report the state of the session for the game server.
int AssignColor (int nId)
 Give a player the first free colour.
void FreeColor (int nId)
 Free the colour of a player.
void SendRanks ()
 Rank the players by rating and send the ranks to every console.
bool OnMsg (ClientInfoPkt *pPkt)
 Enter a console whose player arrived, or remove it when the session is full.
bool OnMsg (TimeRequestPkt *pPkt)
 Answer the clock of the session.
bool OnMsg (DataAckPkt *pPkt)
 Note a guest that received the last block of the remix.
bool OnMsg (ChatMsg *pMsg)
 Send the key of the session to the account that requested it.
bool OnMsg (ClientRatingPkt *pPkt)
 Take the rating of a player and send the ranks again.
int GetMgclConnected () const
void SetMgclConnected (int nValue)
int GetLost () const
const rtNetConnectionInfo & GetServerInfo () const
void SetServerInfo (const rtNetConnectionInfo &info)
const String & GetSessionKey () const
void SetSessionKey (const char *pszSessionKey)
NetGameParams & GetParams ()
const NetGameParams & GetParams () const
NetMultiTask & GetShareTask ()
int GetSharing () const
void SetSharing (int nValue)
bool OnMsg (ClientStatusPkt *pPkt)
 Take the state 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.
Public Member Functions inherited from LaunchpadRT
 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.
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 ~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 void Create (MsgSink *pScreen, MsgSink *pGame)
 Start hosting a session.
Static Public Member Functions inherited from LaunchpadRT
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 kMaxPlayers = 4
 The number of slots of a session.
Static Public Attributes inherited from LaunchpadRT
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.

Additional Inherited Members

Public Types inherited from LaunchpadRT
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...
Protected Attributes inherited from LaunchpadRT
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

Detailed Description

The online session of a console that hosts it.

The RTTI records the class as deriving from LaunchpadRT. The vtables are at 0x003d4698 and 0x003d4670, and the object is 0x328 bytes. The constructor stores the instance in TheHostpadRT. The host hands out the colours of the players, publishes the settings of the game, shares the remix of the game in blocks, and starts the song once every console loaded it.

Constructor & Destructor Documentation

◆ HostpadRT()

HostpadRT::HostpadRT ( MsgSink * pScreen,
MsgSink * pGame )

Construct the session, draw its key, and start mConnectTask.

Parameters
pScreenThe screen that receives the result of the attempt.
pGameThe sink that receives the messages of the session.
Ghidra address:
NTSC-U/C: 0x00256be0
Ghidra address:
PAL: 0x0025fae8

◆ ~HostpadRT()

HostpadRT::~HostpadRT ( )
override

Stop mShareTask and clear TheHostpadRT.

Ghidra address:
NTSC-U/C: 0x002577d0
Ghidra address:
PAL: 0x002606d0

Member Function Documentation

◆ Create()

void HostpadRT::Create ( MsgSink * pScreen,
MsgSink * pGame )
static

Start hosting a session.

Parameters
pScreenThe screen that receives the result of the attempt.
pGameThe sink that receives the messages of the session.
Ghidra address:
NTSC-U/C: 0x00254d48
Ghidra address:
PAL: 0x0025dc60

◆ EndEdit()

void HostpadRT::EndEdit ( )
overridevirtual

Take the settings of the game again and publish them once the remix name is filtered.

Ghidra address:
NTSC-U/C: 0x002579d8
Ghidra address:
PAL: 0x002608d8

Reimplemented from NetLaunchpad.

◆ ShareRemix()

bool HostpadRT::ShareRemix ( )
overridevirtual

Share the remix of the game with the guests only.

Returns
Whether the share started.
Ghidra address:
NTSC-U/C: 0x00257c48
Ghidra address:
PAL: 0x00260b48

Reimplemented from NetLaunchpad.

◆ Launch()

int HostpadRT::Launch ( )
overridevirtual

Load the song on every console once every player is ready.

A game of a saved remix first shares the remix.

Returns
1 when the game starts, otherwise 0.
Ghidra address:
NTSC-U/C: 0x00258008
Ghidra address:
PAL: 0x00260f08

Reimplemented from NetLaunchpad.

◆ BootPlayer()

void HostpadRT::BootPlayer ( int nPlayer)
overridevirtual

Ban a guest from the session and remove the guest.

Parameters
nPlayerThe guest.
Ghidra address:
NTSC-U/C: 0x00258100
Ghidra address:
PAL: 0x00261000

Reimplemented from NetLaunchpad.

◆ ReportNow()

void HostpadRT::ReportNow ( )
overridevirtual

Send the reports to the game server at the next poll.

Ghidra address:
NTSC-U/C: 0x002589e0
Ghidra address:
PAL: 0x002618e0

Reimplemented from LaunchpadRT.

◆ SetLocalId()

void HostpadRT::SetLocalId ( int nId)
overridevirtual

Take the identifier of this console and enter the host as the first player.

Parameters
nIdThe identifier.
Ghidra address:
NTSC-U/C: 0x00258a28
Ghidra address:
PAL: 0x00261928

Reimplemented from LaunchpadRT.

◆ AddClient()

void HostpadRT::AddClient ( int nId)
overridevirtual

Welcome a console that connected, or turn it away.

Parameters
nIdThe identifier of the console.
Ghidra address:
NTSC-U/C: 0x00258dd0
Ghidra address:
PAL: 0x00261cd0

Reimplemented from LaunchpadRT.

◆ RemovePlayer()

void HostpadRT::RemovePlayer ( int nId)
overridevirtual

Free the colour of a player who left, and forget the player.

Parameters
nIdThe player's identifier in the session.
Ghidra address:
NTSC-U/C: 0x00258fc8
Ghidra address:
PAL: 0x00261ec8

Reimplemented from LaunchpadRT.

◆ GetTime()

float HostpadRT::GetTime ( )
overridevirtual

Report the clock of this console, the clock of the session.

Returns
SystemMs().
Ghidra address:
NTSC-U/C: 0x002593b0
Ghidra address:
PAL: 0x002622b0

Implements LaunchpadRT.

◆ OnConnected()

void HostpadRT::OnConnected ( )
overridevirtual

Report HostLaunchpadSuccessMsg to the sink of mConnectTask.

Ghidra address:
NTSC-U/C: 0x00259158
Ghidra address:
PAL: 0x00262058

Implements LaunchpadRT.

◆ PollPriv()

void HostpadRT::PollPriv ( )
overridevirtual

Poll the reports and the share, and watch the connection to the game server.

Ghidra address:
NTSC-U/C: 0x002583d0
Ghidra address:
PAL: 0x002612d0

Implements LaunchpadRT.

◆ EndGame()

void HostpadRT::EndGame ( )
overridevirtual

Leave the game and send the reports.

Ghidra address:
NTSC-U/C: 0x00258398
Ghidra address:
PAL: 0x00261298

Reimplemented from LaunchpadRT.

◆ SendRating()

void HostpadRT::SendRating ( int nRank)
overridevirtual

Send the rating of the host and note it in mClientData.

Parameters
nRankThe position of the host in the ranking.
Ghidra address:
NTSC-U/C: 0x00259868
Ghidra address:
PAL: 0x00262768

Reimplemented from LaunchpadRT.

◆ DispatchPriv()

bool HostpadRT::DispatchPriv ( Message * pMsg)
overridevirtual

Act on a packet of the session, before LaunchpadRT does.

Parameters
pMsgThe message.
Returns
The result of the handler, false for every handler here.
Ghidra address:
NTSC-U/C: 0x00259d40
Ghidra address:
PAL: 0x00262c40

Implements MsgSink.

◆ SendGameParams()

void HostpadRT::SendGameParams ( )

Send the settings of the game to every console, and send the world report at the next poll.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00257b40
Ghidra address:
PAL: 0x00260a40

◆ StartShare()

bool HostpadRT::StartShare ( int nShareOnly)

Share the remix of the game with every guest once every player is ready.

The name is inferred.

Parameters
nShareOnlyNon-zero when the remix is only shared, not played.
Returns
Whether the share started.
Ghidra address:
NTSC-U/C: 0x00257c68
Ghidra address:
PAL: 0x00260b68

◆ Kick()

void HostpadRT::Kick ( int nId,
int nBan )

Remove a guest from the session, and ban the guest from the game server first.

The name is inferred.

Parameters
nIdThe guest's identifier in the session.
nBanNon-zero to ban the guest.
Ghidra address:
NTSC-U/C: 0x00258120
Ghidra address:
PAL: 0x00261020

◆ SendScores()

void HostpadRT::SendScores ( const std::vector< NetGameScore > & scores)

Send the final scores to every console, rate the game, and leave it.

The name is inferred.

Parameters
scoresThe final score of each player.
Ghidra address:
NTSC-U/C: 0x00258208
Ghidra address:
PAL: 0x00261108

◆ PollStart()

void HostpadRT::PollStart ( )

Start the song once every console loaded it, and remove the consoles too slow to load.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00258478
Ghidra address:
PAL: 0x00261378

◆ KickUnloaded()

void HostpadRT::KickUnloaded ( )

Remove every guest that has not loaded the song.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00258668
Ghidra address:
PAL: 0x00261568

◆ PollShare()

void HostpadRT::PollShare ( )

Send the next block of the remix once every guest acknowledged the last, and remove the guests too slow to.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00258718
Ghidra address:
PAL: 0x00261618

◆ CanJoin()

int HostpadRT::CanJoin ( )

Report whether the session takes another player.

The name is inferred.

Returns
Non-zero outside a game and a share while a slot is free.
Ghidra address:
NTSC-U/C: 0x00259050
Ghidra address:
PAL: 0x00261f50

◆ GetWorldStatus()

int HostpadRT::GetWorldStatus ( )

Report the state of the session for the game server.

The name is inferred.

Returns
2 during a game, otherwise 1.
Ghidra address:
NTSC-U/C: 0x002590b0
Ghidra address:
PAL: 0x00261fb0

◆ AssignColor()

int HostpadRT::AssignColor ( int nId)

Give a player the first free colour.

The name is inferred.

Parameters
nIdThe player's identifier in the session.
Returns
The colour, or -1 when every colour is taken.
Ghidra address:
NTSC-U/C: 0x002590c8
Ghidra address:
PAL: 0x00261fc8

◆ FreeColor()

void HostpadRT::FreeColor ( int nId)

Free the colour of a player.

The name is inferred.

Parameters
nIdThe player's identifier in the session.
Ghidra address:
NTSC-U/C: 0x00259110
Ghidra address:
PAL: 0x00262010

◆ SendRanks()

void HostpadRT::SendRanks ( )

Rank the players by rating and send the ranks to every console.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00259418
Ghidra address:
PAL: 0x00262318

◆ OnMsg() [1/10]

bool HostpadRT::OnMsg ( ClientInfoPkt * pPkt)

Enter a console whose player arrived, or remove it when the session is full.

Parameters
pPktThe packet.
Returns
False.
Ghidra address:
NTSC-U/C: 0x002598e0
Ghidra address:
PAL: 0x002627e0

◆ OnMsg() [2/10]

bool HostpadRT::OnMsg ( TimeRequestPkt * pPkt)

Answer the clock of the session.

Parameters
pPktThe packet.
Returns
False.
Ghidra address:
NTSC-U/C: 0x00259b60
Ghidra address:
PAL: 0x00262a60

◆ OnMsg() [3/10]

bool HostpadRT::OnMsg ( DataAckPkt * pPkt)

Note a guest that received the last block of the remix.

Parameters
pPktThe packet.
Returns
False.
Ghidra address:
NTSC-U/C: 0x00259c28
Ghidra address:
PAL: 0x00262b28

◆ OnMsg() [4/10]

bool HostpadRT::OnMsg ( ChatMsg * pMsg)

Send the key of the session to the account that requested it.

Parameters
pMsgThe message.
Returns
False.
Ghidra address:
NTSC-U/C: 0x00259c50
Ghidra address:
PAL: 0x00262b50

◆ OnMsg() [5/10]

bool HostpadRT::OnMsg ( ClientRatingPkt * pPkt)

Take the rating of a player and send the ranks again.

Parameters
pPktThe packet.
Returns
False.
Ghidra address:
NTSC-U/C: 0x00259cd0
Ghidra address:
PAL: 0x00262bd0

◆ GetMgclConnected()

int HostpadRT::GetMgclConnected ( ) const
inline
Returns
Non-zero while the game server library is connected.

◆ SetMgclConnected()

void HostpadRT::SetMgclConnected ( int nValue)
inline
Parameters
nValueNon-zero while the game server library is connected.

◆ GetLost()

int HostpadRT::GetLost ( ) const
inline
Returns
Non-zero once the game server library failed.

◆ GetServerInfo()

const rtNetConnectionInfo & HostpadRT::GetServerInfo ( ) const
inline
Returns
The game server the authentication returned.

◆ SetServerInfo()

void HostpadRT::SetServerInfo ( const rtNetConnectionInfo & info)
inline
Parameters
infoThe game server the authentication returned.

◆ GetSessionKey()

const String & HostpadRT::GetSessionKey ( ) const
inline
Returns
The key of the session on the game server.

◆ SetSessionKey()

void HostpadRT::SetSessionKey ( const char * pszSessionKey)
inline
Parameters
pszSessionKeyThe key of the session on the game server.

◆ GetParams() [1/2]

NetGameParams & HostpadRT::GetParams ( )
inline
Returns
The settings of the game.

◆ GetParams() [2/2]

const NetGameParams & HostpadRT::GetParams ( ) const
inline
Returns
The settings of the game.

◆ GetShareTask()

NetMultiTask & HostpadRT::GetShareTask ( )
inline
Returns
The share of the remix before the song loads.

◆ GetSharing()

int HostpadRT::GetSharing ( ) const
inline
Returns
Non-zero while the remix is shared.

◆ SetSharing()

void HostpadRT::SetSharing ( int nValue)
inline
Parameters
nValueNon-zero while the remix is shared.

◆ OnMsg() [6/10]

Take the state of a player.

Parameters
pPktThe packet.
Returns
False.
Ghidra address:
NTSC-U/C: 0x00256760
Ghidra address:
PAL: 0x0025f668

◆ OnMsg() [7/10]

Enter the game, and tell mGameSink to load the song.

Parameters
pPktThe packet.
Returns
False.
Ghidra address:
NTSC-U/C: 0x00256830
Ghidra address:
PAL: 0x0025f738

◆ OnMsg() [8/10]

Take the time the song starts at and the seed of the game.

Parameters
pPktThe packet.
Returns
False.
Ghidra address:
NTSC-U/C: 0x002568b8
Ghidra address:
PAL: 0x0025f7c0

◆ OnMsg() [9/10]

Drop a player who exited the game, and end the game when the host exited.

Parameters
pPktThe packet.
Returns
False.
Ghidra address:
NTSC-U/C: 0x00256940
Ghidra address:
PAL: 0x0025f848

◆ OnMsg() [10/10]

Take the ranks of the players.

Parameters
pPktThe packet.
Returns
False.
Ghidra address:
NTSC-U/C: 0x00256a48
Ghidra address:
PAL: 0x0025f950

Member Data Documentation

◆ kMaxPlayers

int HostpadRT::kMaxPlayers = 4
staticconstexpr

The number of slots of a session.


The documentation for this class was generated from the following file: