resonance 1.0.1
Loading...
Searching...
No Matches
Player Class Reference

One participant in a session, local or remote. More...

#include <player.h>

Inheritance diagram for Player:
Collaboration diagram for Player:

Public Member Functions

 Player (int nId, const HxStr &colorName, const FreqAppearance *pAppearance)
 Register the player under its identifier and start its tallies.
virtual ~Player ()
virtual int GetInputSlot () const
 Report the controller slot that drives this player.
virtual int IsNull ()
 Test whether this player is the stand-in for an absent one.
virtual int GetTrack ()
 Report the track this player occupies.
virtual int GetPlace ()
 Report the player's place on its track.
virtual int UnusedQuery ()
 Report zero.
virtual void UnusedHook ()
 Do nothing.
virtual void SetFreestyleSpan (int nStartBar, int nEndBar)
 Give the player a span of bars it plays freely.
virtual int IsFreestyleBar (int nBar)
 Test whether a bar lies in the player's freestyle span.
virtual int IsLooping ()
 Report whether the player is looping.
virtual void AnnounceState ()
 Announce the player's state.
virtual void DeactivatePlacer ()
 Deactivate the powerup placer.
virtual void Print (std::ostream &stream)
 Write a description of this player to stream.
virtual int CountCaughtGem ()
 Count one caught gem.
virtual int CountMissedGem ()
 Count one missed gem.
virtual int GetMultiplier (int nBar)
 Report the score multiplier a capture starting at a bar earns.
virtual int GetBestStreak ()
 Report the best streak of consecutive captures.
virtual float GetCaptureRatio ()
 Report the proportion of captured phrases among those captured and muffed.
virtual int GetGameMode ()
 Report the game mode the player was built in.
virtual int MarkBarScored (int nBar)
 Record that a bar scored, reporting whether it had not scored before.
virtual void DispatchPriv (Message *pMsg)
 Receive one message.
int GetJuice ()
 Report the juice the player has banked.
int GetScore ()
 Report the player's score.
void SetScore (int nScore, int nMaxScore)
 Set the score and the ceiling it is clamped to.
void SetJuice (int nJuice, int nMaxJuice)
 Set the juice and the ceiling it is clamped to.
void AddJuice (int nAmount, int bNotify)
 Add juice, clamped to 0 through the ceiling, and announce a change.
void AddScore (int nDelta, int bNotify)
 Add to the score, clamped to 0 through the ceiling, and announce a change.
void OnMsg (const PhraseCapturedMsg &msg)
 Add a captured phrase's score and juice, announcing both.
int IsLocal () const
 Report whether the player has an input slot.
HxStr GetColorName ()
 Copy the player's colour name.
HxStr GetUsername ()
 Copy the username of the player's appearance.
int StartMF ()
 Run AnnounceState() and report zero.
int StopMF ()
 Run DeactivatePlacer() and report zero.
Public Member Functions inherited from IDable< Player >
 IDable (int nId)
 Register the object in sObjects under an identifier.
virtual ~IDable ()
 Release the table slot this object occupies.
Public Member Functions inherited from IDableBase
virtual ~IDableBase ()
Public Member Functions inherited from MsgSink
void * operator new (size_t nSize)
 Allocate a sink from the tagged heap under the tag "MsgSink".
void operator delete (void *pBlock)
 Release a sink to the tagged heap.
virtual ~MsgSink ()
virtual void Dispatch (Message *pMsg)
 Accept a message.
Public Member Functions inherited from MsgSource
virtual ~MsgSource ()
virtual void AddSink (MsgSink *pSink)
 Register a sink, ignoring a sink that is already registered.
virtual void RemoveSink (MsgSink *pSink)
 Unregister the first occurrence of a sink.
void Send (Message *pMsg) const
 Deliver a message to every registered sink, in registration order.
void ClearSinks ()
 Unregister every sink.

Static Public Member Functions

static void Delete (Player *pPlayer)
 Delete a player through its virtual destructor, doing nothing for null.

Public Attributes

int mPlayerId
 Identifier a message addresses this player by.
HxStr mColorName
 The player's colour name, such as green or red.
long long mLastEraseTime
 Scheduler time of this player's last erase press, in nanoseconds.
Public Attributes inherited from MsgSource
int mGraphBuilt
 A word no member of this class reads.

Protected Attributes

int mMaxJuice
int mMaxScore
Protected Attributes inherited from IDableBase
int mId

Additional Inherited Members

Static Public Attributes inherited from IDable< Player >
static std::vector< Player * > sObjects
 Every registered object, indexed by mId.

Detailed Description

One participant in a session, local or remote.

Player in the RTTI descriptor at 0x009020c0, over three bases: IDable<Player> at offset 0, MsgSink at 8, and MsgSource at 12. Three classes derive from it, LocalPlayer, NetPlayer, and NullPlayer.

Three vtables belong to it, each walked to its all-zero terminator rather than counted from the slot titles, which understate every one of them. The primary at 0x007d2170 has 21 entries, so this class declares 19 virtuals of its own after slot 0 and the destructor. The MsgSink table at 0x007d2148 has 4 and overrides only DispatchPriv, and the MsgSource table at 0x007d2120 has 4 and overrides nothing, leaving AddSink and RemoveSink as inherited.

Almost all of the primary table is inert defaults: slots 2 and 4 return -1, six return 0, two return 1, one returns 0.0f, and five are empty. Only slots 11 and 13 have a body of any size, so this class is an interface with defaults and the three subclasses carry the behaviour.

The base subobjects account for +0x00 through +0x1f, which the destructor at 0x00132ae8 confirms by restoring a vptr at +0x04 for IDable<Player>, at +0x08 for MsgSink, and at +0x1c for MsgSource, whose own mSinks vector it tears down at +0x10. This class's own members start at +0x20, and the only one the destructor releases is the colour name at +0x24.

Constructor & Destructor Documentation

◆ Player()

Player::Player ( int nId,
const HxStr & colorName,
const FreqAppearance * pAppearance )

Register the player under its identifier and start its tallies.

The score starts at 0 with a ceiling of 1, the juice at 0 with a ceiling of 1, and the last erase time at 0.

Parameters
nIdThe identifier, also recorded in mPlayerId.
colorNameThe player's colour name.
pAppearanceThe appearance the player is drawn with.
Ghidra address:
NTSC-U/C: 0x0012f5c0
Ghidra address:
PAL: 0x0012fd78

◆ ~Player()

virtual Player::~Player ( )
virtual
Ghidra address:
NTSC-U/C: 0x00132ae8
Ghidra address:
PAL: 0x00133318

Member Function Documentation

◆ GetInputSlot()

virtual int Player::GetInputSlot ( ) const
virtual

Report the controller slot that drives this player.

Slot 2. Returns kNoInputSlot here, and NetPlayer inherits it. LocalPlayer returns the slot its constructor received, and InputMap matches a controller reading against it.

Returns
The input slot, or kNoInputSlot.
Ghidra address:
NTSC-U/C: 0x00132c20
Ghidra address:
PAL: 0x00133460

Reimplemented in LocalPlayer.

◆ IsNull()

virtual int Player::IsNull ( )
virtual

Test whether this player is the stand-in for an absent one.

Returns false here. Only NullPlayer returns true, and Print() branches on the answer to write "{player null}", which is what recovers the verb.

Returns
Non-zero when this player is a stand-in.
Ghidra address:
NTSC-U/C: 0x00132c60
Ghidra address:
PAL: 0x001334a0

Reimplemented in NullPlayer.

◆ GetTrack()

virtual int Player::GetTrack ( )
virtual

Report the track this player occupies.

Slot 4. Returns -1 here. LocalPlayer and NetPlayer return the track the last TrackSelectMsg for the player chose, and powerups deploy and riffs play on it.

Returns
The track, or -1.
Ghidra address:
NTSC-U/C: 0x00132c98
Ghidra address:
PAL: 0x001334d8

Reimplemented in LocalPlayer, and NetPlayer.

◆ GetPlace()

virtual int Player::GetPlace ( )
virtual

Report the player's place on its track.

Slot 5. Returns zero here. LocalPlayer and NetPlayer return the second word of the last TrackSelectMsg for the player, the place that TrackSelectPacket includes beside the track.

Returns
The place.
Ghidra address:
NTSC-U/C: 0x00132ca0
Ghidra address:
PAL: 0x001334e0

Reimplemented in LocalPlayer, and NetPlayer.

◆ UnusedQuery()

virtual int Player::UnusedQuery ( )
virtual

Report zero.

Slot 6. LocalPlayer's override also returns zero, and the image has no caller of the slot. The title records that the slot is unused.

Returns
Always 0.
Ghidra address:
NTSC-U/C: 0x00132ca8
Ghidra address:
PAL: 0x001334e8

Reimplemented in LocalPlayer.

◆ UnusedHook()

virtual void Player::UnusedHook ( )
virtual

Do nothing.

Slot 7. LocalPlayer's override is also empty, and the image has no caller of the slot. The title records that the slot is unused.

Ghidra address:
NTSC-U/C: 0x00132cb0
Ghidra address:
PAL: 0x001334f0

Reimplemented in LocalPlayer.

◆ SetFreestyleSpan()

virtual void Player::SetFreestyleSpan ( int nStartBar,
int nEndBar )
virtual

Give the player a span of bars it plays freely.

Slot 8. Empty here. LocalPlayer stores both bars, and IsFreestyleBar() tests a bar against them. Gamer passes the eight-bar span of an enable-freestyle powerup and the span a solo win grants, and a jam player's constructor passes a span that never ends.

Parameters
nStartBarThe first bar of the span.
nEndBarThe bar after the span.
Ghidra address:
NTSC-U/C: 0x00132cb8
Ghidra address:
PAL: 0x001334f8

Reimplemented in LocalPlayer.

◆ IsFreestyleBar()

virtual int Player::IsFreestyleBar ( int nBar)
virtual

Test whether a bar lies in the player's freestyle span.

Slot 9. Returns zero here, ignoring its argument. NotePitcher plays a bar inside the span without the track's usual requirement.

Parameters
nBarThe bar.
Returns
Non-zero when the bar is in the span.
Ghidra address:
NTSC-U/C: 0x00132cc0
Ghidra address:
PAL: 0x00133500

Reimplemented in LocalPlayer.

◆ IsLooping()

virtual int Player::IsLooping ( )
virtual

Report whether the player is looping.

Slot 10. Returns zero here. LocalPlayer returns the flag SetLooping() and ToggleLoop() maintain.

Returns
Non-zero when looping.
Ghidra address:
NTSC-U/C: 0x00132cc8
Ghidra address:
PAL: 0x00133508

Reimplemented in LocalPlayer.

◆ AnnounceState()

virtual void Player::AnnounceState ( )
virtual

Announce the player's state.

Slot 11. Here, builds a JuiceAmountMsg on the stack for this player, with mMaxJuice clamped to a maximum of 800, and sends it through the MsgSource subobject. LocalPlayer adds its track, powerups, score ceiling, ghost, and loop state.

Ghidra address:
NTSC-U/C: 0x0012f788
Ghidra address:
PAL: 0x0012ff40

Reimplemented in LocalPlayer.

◆ DeactivatePlacer()

virtual void Player::DeactivatePlacer ( )
virtual

Deactivate the powerup placer.

Slot 12. Empty here. LocalPlayer runs PowerupPlacer::Deactivate(), the counterpart of the PowerupPlacer::Activate() that AnnounceState() runs. The image has no caller of the slot but StopMF(), itself uncalled. The title is inferred from the forwarding alone.

Ghidra address:
NTSC-U/C: 0x00132d30
Ghidra address:
PAL: 0x00133570

Reimplemented in LocalPlayer.

◆ Print()

virtual void Player::Print ( std::ostream & stream)
virtual

Write a description of this player to stream.

Writes the literal "{player null}" when IsNull() reports true, and otherwise "{player " followed by the identifier at +0x20. Those two literals at 0x007d2048 and 0x007d2058 are what attest both this routine and IsNull().

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x00133110
Ghidra address:
PAL: 0x00133960

◆ CountCaughtGem()

virtual int Player::CountCaughtGem ( )
virtual

Count one caught gem.

Slot 14. Catcher runs it for every gem the player catches and discards the result. Does not touch the return register here. The value it yields is therefore indeterminate. LocalPlayer increments its count and returns the new value. A base whose default yields an indeterminate value is faithful to the image rather than a reconstruction error.

Returns
The new count.
Ghidra address:
NTSC-U/C: 0x00132d70
Ghidra address:
PAL: 0x001335b0

Reimplemented in LocalPlayer.

◆ CountMissedGem()

virtual int Player::CountMissedGem ( )
virtual

Count one missed gem.

Slot 15. Catcher runs it when a gem passes uncaught. Does not touch the return register here, as with CountCaughtGem(). LocalPlayer increments its count and returns the new value.

Returns
The new count.
Ghidra address:
NTSC-U/C: 0x00132d78
Ghidra address:
PAL: 0x001335b8

Reimplemented in LocalPlayer.

◆ GetMultiplier()

virtual int Player::GetMultiplier ( int nBar)
virtual

Report the score multiplier a capture starting at a bar earns.

Slot 16. Returns 1 here, ignoring its argument. Catcher and Scratcher pass the result in a BeginPhraseCatchMsg.

Parameters
nBarThe bar.
Returns
The multiplier.
Ghidra address:
NTSC-U/C: 0x00132d80
Ghidra address:
PAL: 0x001335c0

Reimplemented in LocalPlayer.

◆ GetBestStreak()

virtual int Player::GetBestStreak ( )
virtual

Report the best streak of consecutive captures.

Slot 17. Returns zero here. Gamer records it as the solo tally.

Returns
The streak.
Ghidra address:
NTSC-U/C: 0x00132d88
Ghidra address:
PAL: 0x001335c8

Reimplemented in LocalPlayer.

◆ GetCaptureRatio()

virtual float Player::GetCaptureRatio ( )
virtual

Report the proportion of captured phrases among those captured and muffed.

Slot 18. Returns 0.0f here. Gamer records it as the solo ratio.

Returns
A fraction between 0 and 1.
Ghidra address:
NTSC-U/C: 0x00132d90
Ghidra address:
PAL: 0x001335d0

Reimplemented in LocalPlayer.

◆ GetGameMode()

virtual int Player::GetGameMode ( )
virtual

Report the game mode the player was built in.

Slot 19. Returns zero here.

Returns
The game mode.
Ghidra address:
NTSC-U/C: 0x00132da0
Ghidra address:
PAL: 0x001335e0

Reimplemented in LocalPlayer.

◆ MarkBarScored()

virtual int Player::MarkBarScored ( int nBar)
virtual

Record that a bar scored, reporting whether it had not scored before.

Slot 20. Returns 1 here, ignoring its argument. Scratcher does not award points for a bar the slot reports zero for.

Parameters
nBarThe bar.
Returns
Non-zero when the bar is later than every bar recorded before.
Ghidra address:
NTSC-U/C: 0x00132db0
Ghidra address:
PAL: 0x001335f0

Reimplemented in LocalPlayer.

◆ DispatchPriv()

virtual void Player::DispatchPriv ( Message * pMsg)
virtual

Receive one message.

The only MsgSink virtual this class overrides, at slot 3 of its MsgSink table. An UpdateScorePacket for this player adds its delta without notifying, and a PhraseCapturedMsg is awarded through OnMsg() whichever player it identifies. Every other message is discarded.

Parameters
pMsgThe message.
Ghidra address:
NTSC-U/C: 0x00133240
Ghidra address:
PAL: 0x00133a90

Implements MsgSink.

Reimplemented in LocalPlayer, NetPlayer, and NullPlayer.

◆ GetJuice()

int Player::GetJuice ( )

Report the juice the player has banked.

The routine at 0x0012f970 clamps the value to 0 through mMaxJuice, the maximum JuiceAmountMsg announces, and the message accessor at 0x003e4198 divides it by that announced maximum.

Returns
The juice.
Ghidra address:
NTSC-U/C: 0x001330f8
Ghidra address:
PAL: 0x00133948

◆ GetScore()

int Player::GetScore ( )

Report the player's score.

The routine at 0x0012f808 clamps the value to 0 through mMaxScore. Renderer compares the scores of every world player through this accessor to find the leader.

Returns
The score.
Ghidra address:
NTSC-U/C: 0x001330e0
Ghidra address:
PAL: 0x00133930

◆ SetScore()

void Player::SetScore ( int nScore,
int nMaxScore )

Set the score and the ceiling it is clamped to.

Gamer's constructor sets every player to 0 with a ceiling of 100000. The title is inferred.

Parameters
nScoreThe score.
nMaxScoreThe ceiling.
Ghidra address:
NTSC-U/C: 0x001330e8
Ghidra address:
PAL: 0x00133938

◆ SetJuice()

void Player::SetJuice ( int nJuice,
int nMaxJuice )

Set the juice and the ceiling it is clamped to.

Gamer's constructor passes two configuration values in kGameModeSolo and zeros otherwise. The title is inferred.

Parameters
nJuiceThe juice.
nMaxJuiceThe ceiling.
Ghidra address:
NTSC-U/C: 0x00133100
Ghidra address:
PAL: 0x00133950

◆ AddJuice()

void Player::AddJuice ( int nAmount,
int bNotify )

Add juice, clamped to 0 through the ceiling, and announce a change.

A change sends a JuiceAmountMsg through the MsgSource subobject and, when bNotify is set, an UpdateScorePacket with the amount. The script command that adds juice is the recovered caller. The title is inferred.

Parameters
nAmountThe juice to add, which may be negative.
bNotifyNon-zero to also send the UpdateScorePacket.
Ghidra address:
NTSC-U/C: 0x0012f970
Ghidra address:
PAL: 0x00130128

◆ AddScore()

void Player::AddScore ( int nDelta,
int bNotify )

Add to the score, clamped to 0 through the ceiling, and announce a change.

The score counterpart of AddJuice(). A change sends a PointAmountMsg with the ceiling capped at 800 and, when bNotify is set, an UpdateScorePacket with the delta. PhraseNeutralizer is a recovered caller. The title is inferred.

Parameters
nDeltaThe points to add, which may be negative.
bNotifyNon-zero to also send the UpdateScorePacket.
Ghidra address:
NTSC-U/C: 0x0012f808
Ghidra address:
PAL: 0x0012ffc0

◆ OnMsg()

void Player::OnMsg ( const PhraseCapturedMsg & msg)

Add a captured phrase's score and juice, announcing both.

LocalPlayer::DispatchPriv() and the routine at 0x00122be8 are the callers.

Parameters
msgThe capture.
Ghidra address:
NTSC-U/C: 0x001331c8
Ghidra address:
PAL: 0x00133a18

◆ IsLocal()

int Player::IsLocal ( ) const
inline

Report whether the player has an input slot.

Inline, and TrackSelector::DispatchPriv() expands it. The address is its uncalled out-of-line copy.

Returns
Non-zero when GetInputSlot() reports a value other than -1.
Ghidra address:
NTSC-U/C: 0x00132c30
Ghidra address:
PAL: 0x00133470

◆ Delete()

void Player::Delete ( Player * pPlayer)
inlinestatic

Delete a player through its virtual destructor, doing nothing for null.

Inline. GrooveWorld::DeletePlayers() passes it to std::for_each, which is what gives it the out-of-line copy at this address. The title is inferred.

Parameters
pPlayerThe player to delete, or null.
Ghidra address:
NTSC-U/C: 0x00132d38
Ghidra address:
PAL: 0x00133578

◆ GetColorName()

HxStr Player::GetColorName ( )

Copy the player's colour name.

Inline. The address is its uncalled out-of-line copy. The title is inferred.

Returns
mColorName, by value.
Ghidra address:
NTSC-U/C: 0x00132c68
Ghidra address:
PAL: 0x001334a8

◆ GetUsername()

HxStr Player::GetUsername ( )

Copy the username of the player's appearance.

Inline. The address is its uncalled out-of-line copy. The title is inferred.

Returns
FreqAppearance::mUserName of mAppearance, by value.
Ghidra address:
NTSC-U/C: 0x001330a8
Ghidra address:
PAL: 0x001338f8

◆ StartMF()

int Player::StartMF ( )

Run AnnounceState() and report zero.

Inline. The address is its uncalled out-of-line copy.

Returns
Always 0.
Ghidra address:
NTSC-U/C: 0x00132cd0
Ghidra address:
PAL: 0x00133510

◆ StopMF()

int Player::StopMF ( )

Run DeactivatePlacer() and report zero.

Inline. The address is its uncalled out-of-line copy.

Returns
Always 0.
Ghidra address:
NTSC-U/C: 0x00132d00
Ghidra address:
PAL: 0x00133540

Member Data Documentation

◆ mPlayerId

int Player::mPlayerId

Identifier a message addresses this player by.

Print() writes it after the "{player " literal and DispatchPriv compares it against a field of an incoming message. Gem reads it directly at 0x001a2608 and 0x001a2d84 from outside the hierarchy, and the image exposes no accessor. The member is therefore public here. A friend declaration for Gem fits the image equally well.

+0x20

◆ mColorName

HxStr Player::mColorName

The player's colour name, such as green or red.

+0x24

~Player releases its buffer at +0x28 with the inlined HxStr destructor. HudScore, HudFreq, and HudScorePulse copy-construct it directly at 0x00419848, 0x00419b40, and 0x0041c2d0 from outside the hierarchy, and the image has no accessor for it.

◆ mMaxJuice

int Player::mMaxJuice
protected

◆ mMaxScore

int Player::mMaxScore
protected

◆ mLastEraseTime

long long Player::mLastEraseTime

Scheduler time of this player's last erase press, in nanoseconds.

The constructor at 0x0012f5c0 zeroes it. InputMap::OnControllerReading() reads and writes it directly at 0x00119a6c and 0x00119adc to detect a double tap, and the image has no accessor for it. +0x40


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