diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index d47c86f3bc..1e9ca8d70e 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -11,29 +11,8 @@ */ #include "GameConstantsAndTypes.h" -#include "PrefsManager.h" #include "GameState.h" -/* XXX: Should this be in GAMESTATE? It's not really a constant anymore. */ -int TapNoteScoreToDancePoints( TapNoteScore tns ) -{ - const bool bOni = GAMESTATE->IsCourseMode(); - - if(!PREFSMAN->m_bMarvelousTiming && tns == TNS_MARVELOUS) - tns = TNS_PERFECT; - - switch( tns ) - { - case TNS_MARVELOUS: return bOni ? +3 : +2; - case TNS_PERFECT: return +2; - case TNS_GREAT: return +1; - case TNS_GOOD: return +0; - case TNS_BOO: return bOni ? 0 : -4; - case TNS_MISS: return bOni ? 0 : -8; - case TNS_NONE: return 0; - default: ASSERT(0); return 0; - } -} CString DifficultyToString( Difficulty dc ) { diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index 2ccb455841..31b7741429 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -124,7 +124,6 @@ enum TapNoteScore { NUM_TAP_NOTE_SCORES }; -int TapNoteScoreToDancePoints( TapNoteScore tns ); //enum TapNoteTiming { // TNT_NONE, @@ -142,17 +141,6 @@ enum HoldNoteScore }; -inline int HoldNoteScoreToDancePoints( HoldNoteScore hns ) -{ - switch( hns ) - { - case HNS_OK: return +6; - case HNS_NG: return +0; - default: ASSERT(0); return 0; - } -} - - // // MemCard stuff // diff --git a/stepmania/src/NoteData.cpp b/stepmania/src/NoteData.cpp index 92c574228c..482abc9ea0 100644 --- a/stepmania/src/NoteData.cpp +++ b/stepmania/src/NoteData.cpp @@ -176,22 +176,15 @@ void NoteData::RemoveHoldNote( int iHoldIndex ) m_HoldNotes.erase(m_HoldNotes.begin()+iHoldIndex, m_HoldNotes.begin()+iHoldIndex+1); } -bool NoteData::IsThereANoteAtRow( int iRow ) const +bool NoteData::IsThereATapAtRow( int iRow ) const { for( int t=0; tTrace( "Player::Load()", ); @@ -79,6 +78,7 @@ void Player::Load( PlayerNumber pn, NoteData* pNoteData, LifeMeter* pLM, ScoreDi m_pLifeMeter = pLM; m_pScore = pScore; m_pInventory = pInventory; + m_pScoreKeeper = pScoreKeeper; const StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef(); @@ -98,9 +98,6 @@ void Player::Load( PlayerNumber pn, NoteData* pNoteData, LifeMeter* pLM, ScoreDi m_Combo.Init( pn ); m_Judgment.Reset(); - if(m_pScoreKeeper) delete m_pScoreKeeper; - m_pScoreKeeper = new ScoreKeeperMAX2(GAMESTATE->m_pCurNotes[m_PlayerNumber], *this, pn); - if( m_pScore ) m_pScore->Init( pn ); @@ -603,9 +600,8 @@ void Player::HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) return; #endif //DEBUG - if(m_pScoreKeeper) { + if(m_pScoreKeeper) m_pScoreKeeper->HandleHoldScore(holdScore, tapScore); - } if (m_pScore) m_pScore->SetScore(GAMESTATE->m_CurStageStats.fScore[m_PlayerNumber]); diff --git a/stepmania/src/Player.h b/stepmania/src/Player.h index 705161568c..f55b2ea1a7 100644 --- a/stepmania/src/Player.h +++ b/stepmania/src/Player.h @@ -45,7 +45,7 @@ public: virtual void DrawPrimitives(); ~Player(); - void Load( PlayerNumber player_no, NoteData* pNoteData, LifeMeter* pLM, ScoreDisplay* pScore, Inventory* pInventory ); + void Load( PlayerNumber player_no, NoteData* pNoteData, LifeMeter* pLM, ScoreDisplay* pScore, Inventory* pInventory, ScoreKeeper* pScoreKeeper ); void CrossedRow( int iNoteRow ); void Step( int col ); int GetPlayersMaxCombo(); diff --git a/stepmania/src/ScoreKeeper.h b/stepmania/src/ScoreKeeper.h index a92d910199..7fd1136b1b 100644 --- a/stepmania/src/ScoreKeeper.h +++ b/stepmania/src/ScoreKeeper.h @@ -20,7 +20,8 @@ #include "Actor.h" #include "PlayerNumber.h" -#include "GameConstantsAndTypes.h" +#include "GameConstantsAndTypes.h" // for TapNoteScore and HoldNoteScore +class NoteData; class ScoreKeeper: public Actor { @@ -39,6 +40,10 @@ public: virtual void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ) = 0; virtual void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ) = 0; + + virtual int TapNoteScoreToDancePoints( TapNoteScore tns ) = 0; + virtual int HoldNoteScoreToDancePoints( HoldNoteScore hns ) = 0; + virtual int GetPossibleDancePoints( const NoteData* pNoteData ) = 0; }; #endif diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index fb081f0438..e957701d9c 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -1,20 +1,33 @@ #include "global.h" +/* +----------------------------------------------------------------------------- + Class: ScoreKeeperMAX2 + + Desc: + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ #include "ScoreKeeperMAX2.h" #include "GameState.h" +#include "PrefsManager.h" +#include "Notes.h" -ScoreKeeperMAX2::ScoreKeeperMAX2(Notes *notes, NoteDataWithScoring &data, PlayerNumber pn_): +ScoreKeeperMAX2::ScoreKeeperMAX2(Notes *notes, PlayerNumber pn_): ScoreKeeper(pn_) { // Stats_DoublesCount = true; + NoteData noteData; + notes->GetNoteData( ¬eData ); + int Meter = notes? notes->GetMeter() : 5; Meter = min(Meter, 10); - /* Hold notes count as two tap notes. However, hold notes already count - * as 1 in GetNumTapNotes(), so only add 1*GetNumHoldNotes, not 2. */ - int iNumTapNotes = data.GetNumTapNotes() + data.GetNumHoldNotes(); + int N = noteData.GetNumRowsWithTaps() + noteData.GetNumHoldNotes(); - int sum = (iNumTapNotes * (iNumTapNotes + 1)) / 2; + int sum = (N * (N + 1)) / 2; if(sum) m_fScoreMultiplier = float(Meter * 1000000) / sum; @@ -50,9 +63,9 @@ void ScoreKeeperMAX2::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTa { ASSERT( iNumTapsInRow >= 1 ); - // update dance points for Oni lifemeter - GAMESTATE->m_CurStageStats.iActualDancePoints[m_PlayerNumber] += iNumTapsInRow * TapNoteScoreToDancePoints( scoreOfLastTap ); - GAMESTATE->m_CurStageStats.iTapNoteScores[m_PlayerNumber][scoreOfLastTap] += iNumTapsInRow; + // update dance points + GAMESTATE->m_CurStageStats.iActualDancePoints[m_PlayerNumber] += TapNoteScoreToDancePoints( scoreOfLastTap ); + GAMESTATE->m_CurStageStats.iTapNoteScores[m_PlayerNumber][scoreOfLastTap] += 1; /* A single step's points are calculated as follows: @@ -91,8 +104,8 @@ void ScoreKeeperMAX2::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTa keeping these seperate for as long as possible improves accuracy. */ - for( int i=0; im_bMarvelousTiming ? TNS_MARVELOUS : TNS_PERFECT; + + return pNoteData->GetNumRowsWithTaps()*TapNoteScoreToDancePoints(maxPossibleTapScore)+ + pNoteData->GetNumHoldNotes()*HoldNoteScoreToDancePoints(HNS_OK); +} + + +int ScoreKeeperMAX2::TapNoteScoreToDancePoints( TapNoteScore tns ) +{ + const bool bOni = GAMESTATE->IsCourseMode(); + + if(!PREFSMAN->m_bMarvelousTiming && tns == TNS_MARVELOUS) + tns = TNS_PERFECT; + + switch( tns ) + { + case TNS_MARVELOUS: return bOni ? +3 : +2; + case TNS_PERFECT: return +2; + case TNS_GREAT: return +1; + case TNS_GOOD: return +0; + case TNS_BOO: return bOni ? 0 : -4; + case TNS_MISS: return bOni ? 0 : -8; + case TNS_NONE: return 0; + default: ASSERT(0); return 0; + } +} + +int ScoreKeeperMAX2::HoldNoteScoreToDancePoints( HoldNoteScore hns ) +{ + switch( hns ) + { + case HNS_OK: return +6; + case HNS_NG: return +0; + default: ASSERT(0); return 0; + } +} + diff --git a/stepmania/src/ScoreKeeperMAX2.h b/stepmania/src/ScoreKeeperMAX2.h index c9f230b4e6..aa2c355454 100644 --- a/stepmania/src/ScoreKeeperMAX2.h +++ b/stepmania/src/ScoreKeeperMAX2.h @@ -13,8 +13,8 @@ */ #include "ScoreKeeper.h" -#include "Notes.h" #include "NoteDataWithScoring.h" +struct Notes; class ScoreKeeperMAX2: public ScoreKeeper { @@ -25,10 +25,14 @@ class ScoreKeeperMAX2: public ScoreKeeper void AddScore( TapNoteScore score ); public: - ScoreKeeperMAX2(Notes *notes, NoteDataWithScoring &data, PlayerNumber pn); + ScoreKeeperMAX2(Notes *notes, PlayerNumber pn); void HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTapsInRow ); void HandleHoldScore( HoldNoteScore holdScore, TapNoteScore tapScore ); + + int TapNoteScoreToDancePoints( TapNoteScore tns ); + int HoldNoteScoreToDancePoints( HoldNoteScore hns ); + int GetPossibleDancePoints( const NoteData* pNoteData ); }; #endif diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 4fe9e9bca2..b0ea1f5569 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -267,7 +267,7 @@ ScreenEdit::ScreenEdit() NOTESKIN->SwitchNoteSkin( PLAYER_1, "default" ); // change noteskin back to default before loading player - m_Player.Load( PLAYER_1, ¬eData, NULL, NULL, NULL ); + m_Player.Load( PLAYER_1, ¬eData, NULL, NULL, NULL, NULL ); m_Player.SetXY( PLAYER_X, PLAYER_Y ); m_Fade.SetClosed(); @@ -336,7 +336,7 @@ bool ScreenEdit::PlayTicks() const bool bAnyoneHasANote = false; // set this to true if any player has a note at one of the indicies we crossed for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update - bAnyoneHasANote |= m_Player.IsThereANoteAtRow( r ); + bAnyoneHasANote |= m_Player.IsThereATapAtRow( r ); iRowLastCrossed = iRowNow; @@ -1400,7 +1400,7 @@ void ScreenEdit::HandleAreaMenuChoice( AreaMenuChoice c, int* iAnswers ) m_EditMode = MODE_PLAYING; - m_Player.Load( PLAYER_1, (NoteData*)&m_NoteFieldEdit, NULL, NULL, NULL ); + m_Player.Load( PLAYER_1, (NoteData*)&m_NoteFieldEdit, NULL, NULL, NULL, NULL ); m_rectRecordBack.StopTweening(); m_rectRecordBack.BeginTweening( 0.5f ); diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index e3581ba920..e560d95ff0 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -29,8 +29,8 @@ #include "GrooveRadar.h" #include "NotesLoaderSM.h" #include "ThemeManager.h" - #include "RageTimer.h" +#include "ScoreKeeperMAX2.h" // // Defines @@ -104,7 +104,7 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration ) { LOG->Trace( "ScreenGameplay::ScreenGameplay()" ); - m_bDemonstration = bDemonstration; + m_bDemonstration = bDemonstration; SECONDS_BETWEEN_COMMENTS.Refresh(); G_TICK_EARLY_SECONDS.Refresh(); @@ -127,12 +127,23 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration ) { m_pLifeMeter[p] = NULL; m_pScoreDisplay[p] = NULL; + m_pScoreKeeper[p] = NULL; } } GAMESTATE->m_CurStageStats = StageStats(); // clear values + + int p; + for( p=0; pIsPlayerEnabled(p) ) + continue; // skip + m_pScoreKeeper[p] = new ScoreKeeperMAX2(GAMESTATE->m_pCurNotes[p], (PlayerNumber)p); + } + + // Fill in m_CurStageStats NoteData notedata; switch( GAMESTATE->m_PlayMode ) @@ -147,7 +158,8 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration ) continue; // skip GAMESTATE->m_CurStageStats.iMeter[p] = GAMESTATE->m_pCurNotes[p]->GetMeter(); GAMESTATE->m_pCurNotes[p]->GetNoteData( ¬edata ); - GAMESTATE->m_CurStageStats.iPossibleDancePoints[p] = notedata.GetPossibleDancePoints(); + // TODO: Make this more elegant + GAMESTATE->m_CurStageStats.iPossibleDancePoints[p] = m_pScoreKeeper[p]->GetPossibleDancePoints( ¬edata ); } } break; @@ -164,7 +176,7 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration ) { iTotalMeter += m_apCourseNotes[i]->GetMeter(); m_apCourseNotes[i]->GetNoteData( ¬edata ); - iTotalPossibleDancePoints += notedata.GetPossibleDancePoints(); + iTotalPossibleDancePoints += m_pScoreKeeper[p]->GetPossibleDancePoints( ¬edata ); } GAMESTATE->m_CurStageStats.pSong = NULL; @@ -214,7 +226,6 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration ) m_Background.SetDiffuse( RageColor(0.4f,0.4f,0.4f,1) ); this->AddChild( &m_Background ); - int p; for( p=0; pIsPlayerEnabled(PlayerNumber(p)) ) @@ -510,6 +521,7 @@ ScreenGameplay::~ScreenGameplay() { SAFE_DELETE( m_pLifeMeter[p] ); SAFE_DELETE( m_pScoreDisplay[p] ); + SAFE_DELETE( m_pScoreKeeper[p] ); } m_soundMusic.StopPlaying(); @@ -608,7 +620,7 @@ void ScreenGameplay::LoadNextSong() NoteData pNewNoteData; pStyleDef->GetTransformedNoteDataForStyle( (PlayerNumber)p, &pOriginalNoteData, &pNewNoteData ); - m_Player[p].Load( (PlayerNumber)p, &pNewNoteData, m_pLifeMeter[p], m_pScoreDisplay[p], &m_Inventory ); + m_Player[p].Load( (PlayerNumber)p, &pNewNoteData, m_pLifeMeter[p], m_pScoreDisplay[p], &m_Inventory, m_pScoreKeeper[p] ); } /* Set up song-specific graphics. */ @@ -724,7 +736,7 @@ bool ScreenGameplay::IsTimeToPlayTicks() const if( !GAMESTATE->IsPlayerEnabled( (PlayerNumber)p ) ) continue; // skip - bAnyoneHasANote |= m_Player[p].IsThereANoteAtRow( r ); + bAnyoneHasANote |= m_Player[p].IsThereATapAtRow( r ); break; // this will only play the tick for the first player that is joined } } diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index d8b439dbe8..d2774546fa 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -105,6 +105,7 @@ protected: Sprite m_sprScoreFrame; ScoreDisplay* m_pScoreDisplay[NUM_PLAYERS]; + ScoreKeeper* m_pScoreKeeper[NUM_PLAYERS]; BitmapText m_textPlayerOptions[NUM_PLAYERS]; BitmapText m_textSongOptions; diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 0d69e03a34..f3173b395d 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -57,10 +57,10 @@ LINK32=link.exe # SUBTRACT LINK32 /verbose /pdb:none # Begin Special Build Tool IntDir=.\../Release6 -TargetDir=\temp\stepmania +TargetDir=\stepmania\stepmania TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool @@ -92,10 +92,10 @@ LINK32=link.exe # SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib # Begin Special Build Tool IntDir=.\../Debug6 -TargetDir=\temp\stepmania +TargetDir=\stepmania\stepmania TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi ia32.vdi # End Special Build Tool