|
resonance 1.0.1
|
Catcher that scores the gems one track presents. More...
#include <catcher.h>


Public Member Functions | |
| Catcher (PhraseMgr *pPhraseMgr, Quantizer *pQuantizer, const TrackData *pTrackData, Sch::TickClock *pClock, int nSeekerBarCount, Sch::Tick catchWindow) | |
| virtual | ~Catcher () |
| Withdraw both commands through Stop(). | |
| virtual void | DispatchPriv (Message *pMsg) |
| Act on a message. | |
| virtual void | Start () |
| Schedule the catcher's two commands on the clock. | |
| virtual void | Stop () |
| Withdraw the catcher's two commands from the clock. | |
| virtual int | IsPhraseRunEmpty () |
| Report whether the catcher has nothing outstanding. | |
| virtual void | MissGem (int nTick, int nGem) |
| Record a missed gem. | |
| virtual void | CatchGem (int nTick, int nGem) |
| Record a caught gem. | |
| virtual void | CapturePhrase (int nBar, int nRun, int nAutoCatch)=0 |
| Capture the phrase a caught run of bars completes. | |
| virtual void | ReportCaughtPowerbar (int nBar)=0 |
| Report a caught bar's power bar. | |
| void | ProcessGemCommand (int nTick) |
| Run the post-gem command at a song position. | |
| void | SimulateRemoteGem (int nTick) |
| Play the remote player's gem at a song position, then schedule the next gem command. | |
| Public Member Functions inherited from GenericCatcher | |
| GenericCatcher () | |
| virtual | ~GenericCatcher () |
| 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. | |
Protected Member Functions | |
| void | PostPhraseMuffedMsg (int nBar, Sch::Tick position) |
| Sends a PhraseMuffedMsg for a bar once, recording the bar in mLastMuffedBar. | |
| void | PostCatchMsg (PitchRiffMsg *pMsg) |
| Scores a PitchRiffMsg for this track. | |
| void | PostCaughtBarMsg (int nBar, int nNextBar) |
| Does nothing once a gem of the phrase was missed or muffed. | |
| int | SnapToNearestGem (int nTick) |
| Returns the gem on either side of nTick nearer to it when that gem lies within mCatchWindow, and nTick otherwise. | |
| void | OnTrackSelect (TrackSelectMsg *pMsg) |
| Takes the track for the player a TrackSelectMsg names. | |
| void | OnAutoCatch (AutoCatchMsg *pMsg) |
| Plays a free bar for the player an AutoCatchMsg identifies through CapturePhrase(), marks the message handled through CmdMsg::mResult, and replays the bar from the current offset through PhraseMgr::ReplayBar() when the song is inside it. | |
| void | EndBar (int nBar) |
| Closes the counts for a bar. | |
| int | FindNextGemTick (int nTick) |
| Returns the first gem position after nTick. | |
| void | SchedulePostGemCommand (int nTick) |
| Build a PostGemCmd for the gem after nTick and queue it one tick after PostGemDelay() under the handle mPostGemCommand. | |
| void | ScheduleGemCommand (int nTick) |
| Build a GemCmd for the gem after nTick and queue it at that gem under the handle mGemCommand. | |
| int | PostGemDelay (int nTick) |
| Returns the earlier of the midpoint between nTick and the next gem, and nTick plus mCatchWindow. | |
| void | UpdateSeeker (int nBar) |
| Finds the next free bar within 32 bars of nBar (or of the bar after mLastMuffedBar) and points the seeker at the phrase starting there, or turns the seeker off. | |
| void | PostSeekerMsg () |
| Sends a SeekerMsg that turns the seeker off and clears mSeekerEnabled. | |
| void | PostSeekerRangeMsg (int nFirstBar, int nBarCount) |
| Sends a SeekerMsg for nBarCount bars from nFirstBar at position 0, and records the range in mSeekerFirstBar, mSeekerEndBar, and mSeekerEnabled. | |
| int | IsBarFree (int nBar) |
| Returns whether a bar is non-negative, playable according to TrackData::QueryBar(), and owned by no player. | |
| void | OnInvalidateSeeker (InvalidateSeekerMsg *pMsg) |
| The out-of-line copy of the InvalidateSeekerMsg branch DispatchPriv() expands inline. | |
| void | SetPhraseOwners (int nFirstBar, int nEndBar, Player *pPlayer) |
| Gives every bar from nFirstBar up to nEndBar to one player. | |
Protected Attributes | |
| Quantizer * | mQuantizer |
| PhraseMgr * | mPhraseMgr |
| const TrackData * | mTrackData |
| Player * | mPlayer |
| Sch::TickClock * | mClock |
| Sch::CmdID | mPostGemCommand |
| Sch::CmdID | mGemCommand |
| Sch::Tick | mTicksPerBar |
| int | mSeekerBarCount |
| int | mCatchWindow |
| int | mEnabled |
| Sch::Tick | mLastCaughtPosition |
| Sch::Tick | mLastMissedPosition |
| int | mTrack |
| int | mCaughtGems |
| int | mMissedGems |
| int | mMuffedGems |
| int | mLastEndedBar |
| int | mPhraseRunBars |
| int | mLastMuffedBar |
| int | mSeekerFirstBar |
| int | mSeekerEndBar |
| int | mSeekerEnabled |
| Player * | mRemotePlayer |
| float | mRemoteSuccess |
| Sch::Tick | mRemotePosition |
Additional Inherited Members | |
| Public Attributes inherited from MsgSource | |
| int | mGraphBuilt |
| A word no member of this class reads. | |
Catcher that scores the gems one track presents.
Its RTTI descriptor is at 0x00902010. It has GenericCatcher as its only base at offset 0. Its primary table is at 0x007e0c38 with eleven entries and its MsgSource subobject table at 0x007e0c10 with four. Two classes derive from it, MultiCatcher and SingleCatcher, and both retain eleven entries. Neither introduces a virtual.
The class supplies MsgSink::DispatchPriv() and GenericCatcher's Start(), Stop(), and IsPhraseRunEmpty(), and it introduces four virtuals at slots 7 through 10. CapturePhrase() and ReportCaughtPowerbar(), slots 9 and 10, address the shared pure-virtual stub at 0x005381a8. This class is therefore abstract, and the two subclasses exist to supply them. The object is 0x80 bytes, as MultiCatcher's tagged allocation measures. SingleCatcher's is 0x84 and adds one word.
The constructor's parameter list is attested rather than inferred. The anonymous-namespace marker for the file-local command class GemCmd records the enclosing constructor's signature, Catcher(PhraseMgr *, Quantizer *, const TrackData *, Sch::TickClock *, int, Sch::Tick). A second marker records PostGemCmd in the same translation unit. Both are the commands Start() schedules.
DispatchPriv() dispatches a PitchRiffMsg to PostCatchMsg(), a TrackSelectMsg to OnTrackSelect(), an AutoCatchMsg to OnAutoCatch(), and an InvalidateSeekerMsg to the inline copy of OnInvalidateSeeker(). A CatchProgressPacket for this track stores its player, success rate, and position in mRemotePlayer, mRemoteSuccess, and mRemotePosition.
The two file-local commands, PostGemCmd and GemCmd, sit in the anonymous namespace the RTTI records for this unit and call ProcessGemCommand() and SimulateRemoteGem().
0x001adb78, 0x001b15a8, 0x001b1610, 0x001b19a0, 0x001abe50, and 0x001abfd8 sit in this class's table at slots 3, 4, 5, 6, 7, and 8. SingleCatcher's table has the same six addresses at the same indices.
| Catcher::Catcher | ( | PhraseMgr * | pPhraseMgr, |
| Quantizer * | pQuantizer, | ||
| const TrackData * | pTrackData, | ||
| Sch::TickClock * | pClock, | ||
| int | nSeekerBarCount, | ||
| Sch::Tick | catchWindow ) |
| pPhraseMgr | The phrase manager for the track. |
| pQuantizer | The quantiser for the track. |
| pTrackData | The track description. |
| pClock | The clock the scheduled commands run on. |
| nSeekerBarCount | The bars each seeker range spans. MultiCatcher passes 1. |
| catchWindow | The catch window, in MIDI ticks. |
|
virtual |
Withdraw both commands through Stop().
|
virtual |
Act on a message.
Slot 3. The routine dispatches on the message's registered identity over the five identities the class documentation lists, and every other message is discarded.
| pMsg | The message. |
Implements MsgSink.
|
virtual |
Schedule the catcher's two commands on the clock.
Slot 4. The post-gem command is always scheduled and the gem command only in kGameModeNet.
Reimplemented from GenericCatcher.
|
virtual |
Withdraw the catcher's two commands from the clock.
Slot 5. The two withdrawals mirror Start(), the second being conditional on kGameModeNet in the same way.
Reimplemented from GenericCatcher.
|
virtual |
Report whether the catcher has nothing outstanding.
Slot 6.
Implements GenericCatcher.
|
virtual |
Record a missed gem.
Slot 7. The routine plays the miss sound for the player's own slot, SND_MISS_PLAYER1 through SND_MISS_PLAYER4 by Player::GetInputSlot(), and plays nothing for any other slot. It then sends a missed CatchMsg for the gem. When the tick's bar matches mLastEndedBar, or mPhraseRunBars is positive, it records the tick in mLastMissedPosition, increments mMissedGems, clears mPhraseRunBars, reports the muffed phrase, and refreshes the seeker from the bar.
| nTick | The scheduler time of the miss. |
| nGem | The gem the CatchMsg reports. |
|
virtual |
Record a caught gem.
Slot 8. The routine records the tick in mLastCaughtPosition, counts the gem in mCaughtGems, and sends the gem's riff as a MultiMuseMsg. While no gem of the phrase was missed or muffed, it totals the gems and points of the bars from the phrase's first bar up to mSeekerEndBar, and the first caught gem of a phrase sends a BeginPhraseCatchMsg with the points and the multiplier Player::GetMultiplier() reports. It then sends a caught CatchMsg with the progress through the phrase and a GemMsg, calls Player::CountCaughtGem() and discards the result, and posts the caught-bar message when the next gem lies in another bar.
| nTick | The scheduler time of the gem. |
| nGem | The gem. |
|
pure virtual |
Capture the phrase a caught run of bars completes.
Slot 9, pure. SingleCatcher captures the whole step around the bar and MultiCatcher the bar alone.
| nBar | The last bar of the run. |
| nRun | The bars the run spans. |
| nAutoCatch | Non-zero for an automatic catch. Both subclasses branch on whether it is zero. |
Implemented in MultiCatcher, and SingleCatcher.
|
pure virtual |
Report a caught bar's power bar.
Slot 10, pure. MultiCatcher's override is empty and SingleCatcher's sends a CaughtPowerbarMsg to its player when the phrase manager reports a value other than -1.
| nBar | The caught bar. SingleCatcher's override passes it to PhraseMgr::GetPowerbar(). |
Implemented in MultiCatcher, and SingleCatcher.
| void Catcher::ProcessGemCommand | ( | int | nTick | ) |
Run the post-gem command at a song position.
The PostGemCmd the class schedules calls it. A position other than mLastCaughtPosition counts a muffed gem (mMuffedGems incremented, mPhraseRunBars cleared, the muffed phrase reported, the seeker refreshed from mLastMuffedBar, and slot 15 of mPlayer invoked). The routine then ends the bar when the next gem falls in a later bar and schedules the next post-gem command.
| nTick | The song position the command was scheduled for. |
| void Catcher::SimulateRemoteGem | ( | int | nTick | ) |
Play the remote player's gem at a song position, then schedule the next gem command.
The GemCmd the class schedules calls it. A gem is played only when mRemotePlayer is not the stand-in, reports -1 from Player::GetInputSlot(), is within one bar of mRemotePosition, and a draw from the C library's rand() modulo 256 falls below mRemoteSuccess times 256. Playing it sends the riff of the gem as a MultiMuseMsg when TrackData::GetRiff() reports one, then a caught CatchMsg and a GemMsg for mRemotePlayer.
| nTick | The song position the command was scheduled for. |
|
protected |
Sends a PhraseMuffedMsg for a bar once, recording the bar in mLastMuffedBar.
The message reports the phrase as tried when the bar is free and a gem of it was caught or missed.
|
protected |
Scores a PitchRiffMsg for this track.
A riff from another player queries that player's slot 5 and plays SND_INACTIVE. A riff snapped into a bar that is not free plays SND_INACTIVE and sends a missed CatchMsg. Otherwise a riff on the gem at the snapped position, other than the last one caught, goes to CatchGem(), and every other riff to MissGem().
|
protected |
Does nothing once a gem of the phrase was missed or muffed.
Otherwise it delivers a CaughtBarMsg to the player, extends the phrase run in mPhraseRunBars towards nNextBar (bounded by the next step and mSeekerBarCount), and scores the run through CapturePhrase() when it ends the seeker range.
|
protected |
Returns the gem on either side of nTick nearer to it when that gem lies within mCatchWindow, and nTick otherwise.
PostCatchMsg() is the caller.
|
protected |
Takes the track for the player a TrackSelectMsg names.
|
protected |
Plays a free bar for the player an AutoCatchMsg identifies through CapturePhrase(), marks the message handled through CmdMsg::mResult, and replays the bar from the current offset through PhraseMgr::ReplayBar() when the song is inside it.
|
protected |
Closes the counts for a bar.
A muffed phrase is reported for the previous bar when gems were missed or muffed and some were caught.
|
protected |
Returns the first gem position after nTick.
When none lies within TrackData::mGemSearchBars bars of the track, returns nTick plus that many bars less one.
|
protected |
Build a PostGemCmd for the gem after nTick and queue it one tick after PostGemDelay() under the handle mPostGemCommand.
|
protected |
Build a GemCmd for the gem after nTick and queue it at that gem under the handle mGemCommand.
|
protected |
Returns the earlier of the midpoint between nTick and the next gem, and nTick plus mCatchWindow.
|
protected |
Finds the next free bar within 32 bars of nBar (or of the bar after mLastMuffedBar) and points the seeker at the phrase starting there, or turns the seeker off.
It does nothing while mPlayer is the stand-in or reports -1 from Player::GetInputSlot().
|
protected |
Sends a SeekerMsg that turns the seeker off and clears mSeekerEnabled.
|
protected |
Sends a SeekerMsg for nBarCount bars from nFirstBar at position 0, and records the range in mSeekerFirstBar, mSeekerEndBar, and mSeekerEnabled.
|
protected |
Returns whether a bar is non-negative, playable according to TrackData::QueryBar(), and owned by no player.
UpdateSeeker(), OnAutoCatch(), PostCatchMsg(), and PostPhraseMuffedMsg() expand the same test inline.
|
protected |
The out-of-line copy of the InvalidateSeekerMsg branch DispatchPriv() expands inline.
|
protected |
Gives every bar from nFirstBar up to nEndBar to one player.
The image has no caller.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |