diff --git a/stepmania/src/ActiveAttackList.h b/stepmania/src/ActiveAttackList.h index f1471c6548..5e2ae58779 100644 --- a/stepmania/src/ActiveAttackList.h +++ b/stepmania/src/ActiveAttackList.h @@ -2,7 +2,7 @@ #define ACTIVE_ATTACK_LIST_H #include "BitmapText.h" -struct PlayerState; +class PlayerState; class ActiveAttackList : public BitmapText { diff --git a/stepmania/src/ArrowEffects.h b/stepmania/src/ArrowEffects.h index fb0c1143ed..1952a84b3a 100644 --- a/stepmania/src/ArrowEffects.h +++ b/stepmania/src/ArrowEffects.h @@ -3,7 +3,7 @@ #ifndef ARROWEFFECTS_H #define ARROWEFFECTS_H -struct PlayerState; +class PlayerState; class ArrowEffects { diff --git a/stepmania/src/Attack.h b/stepmania/src/Attack.h index 1def17032d..a36a2ac0e7 100644 --- a/stepmania/src/Attack.h +++ b/stepmania/src/Attack.h @@ -4,7 +4,7 @@ #include "GameConstantsAndTypes.h" #include "PlayerNumber.h" class Song; -struct PlayerState; +class PlayerState; struct Attack { diff --git a/stepmania/src/AttackDisplay.h b/stepmania/src/AttackDisplay.h index a83e89b7f9..8cbcb10522 100644 --- a/stepmania/src/AttackDisplay.h +++ b/stepmania/src/AttackDisplay.h @@ -6,7 +6,7 @@ #include "GameConstantsAndTypes.h" // for TapNoteScore #include "RageTexturePreloader.h" -struct PlayerState; +class PlayerState; class AttackDisplay : public ActorFrame { diff --git a/stepmania/src/Combo.h b/stepmania/src/Combo.h index 97b19a8ab0..701bde23c7 100644 --- a/stepmania/src/Combo.h +++ b/stepmania/src/Combo.h @@ -8,8 +8,8 @@ #include "BitmapText.h" #include "PlayerNumber.h" #include "ThemeMetric.h" -struct PlayerState; -struct PlayerStageStats; +class PlayerState; +class PlayerStageStats; class Combo : public ActorFrame { diff --git a/stepmania/src/ComboGraph.h b/stepmania/src/ComboGraph.h index 78beff229d..ca0b61c0a7 100644 --- a/stepmania/src/ComboGraph.h +++ b/stepmania/src/ComboGraph.h @@ -4,8 +4,8 @@ #include "ActorFrame.h" #include "PlayerNumber.h" -struct StageStats; -struct PlayerStageStats; +class StageStats; +class PlayerStageStats; class ComboGraph: public ActorFrame { diff --git a/stepmania/src/GhostArrowRow.h b/stepmania/src/GhostArrowRow.h index 4009ec9a66..5973ec9f44 100644 --- a/stepmania/src/GhostArrowRow.h +++ b/stepmania/src/GhostArrowRow.h @@ -8,7 +8,7 @@ #include "HoldGhostArrow.h" #include "GameConstantsAndTypes.h" -struct PlayerState; +class PlayerState; class GhostArrowRow : public ActorFrame { diff --git a/stepmania/src/GraphDisplay.h b/stepmania/src/GraphDisplay.h index 96cf80c588..d805bcc6d3 100644 --- a/stepmania/src/GraphDisplay.h +++ b/stepmania/src/GraphDisplay.h @@ -5,8 +5,8 @@ #include "RageTexture.h" #include "AutoActor.h" -struct StageStats; -struct PlayerStageStats; +class StageStats; +class PlayerStageStats; class GraphDisplay: public ActorFrame { diff --git a/stepmania/src/Inventory.h b/stepmania/src/Inventory.h index d17a7e4686..9669767b88 100644 --- a/stepmania/src/Inventory.h +++ b/stepmania/src/Inventory.h @@ -7,7 +7,7 @@ #include "PlayerNumber.h" #include "RageSound.h" -struct PlayerState; +class PlayerState; class Inventory : public Actor { diff --git a/stepmania/src/NoteDisplay.h b/stepmania/src/NoteDisplay.h index 99db81ff68..ea33fb90ef 100644 --- a/stepmania/src/NoteDisplay.h +++ b/stepmania/src/NoteDisplay.h @@ -9,7 +9,7 @@ class Model; struct HoldNoteResult; struct NoteMetricCache_t; -struct PlayerState; +class PlayerState; #define NOTE_COLOR_IMAGES 8 diff --git a/stepmania/src/PlayerStageStats.h b/stepmania/src/PlayerStageStats.h index ab91bea5b6..056af3a3e5 100644 --- a/stepmania/src/PlayerStageStats.h +++ b/stepmania/src/PlayerStageStats.h @@ -10,8 +10,9 @@ class Steps; struct lua_State; -struct PlayerStageStats +class PlayerStageStats { +public: PlayerStageStats() { Init(); } void Init(); diff --git a/stepmania/src/PlayerState.h b/stepmania/src/PlayerState.h index 0287805255..d3ef1fc5f4 100644 --- a/stepmania/src/PlayerState.h +++ b/stepmania/src/PlayerState.h @@ -8,11 +8,13 @@ #include #include "Attack.h" -struct PlayerState +class PlayerState { +public: PlayerState() { m_PlayerNumber = PLAYER_INVALID; + m_mp = MultiPlayer_INVALID; Reset(); } void Reset() @@ -51,6 +53,7 @@ struct PlayerState // in PlayerState and callers should not use PlayerNumber to index into // GameState. PlayerNumber m_PlayerNumber; + MultiPlayer m_mp; PlayerOptions m_CurrentPlayerOptions; // current approaches destination diff --git a/stepmania/src/ReceptorArrow.h b/stepmania/src/ReceptorArrow.h index 1a0cab5e5d..6323784b1f 100644 --- a/stepmania/src/ReceptorArrow.h +++ b/stepmania/src/ReceptorArrow.h @@ -8,7 +8,7 @@ #include "PlayerNumber.h" #include "GameConstantsAndTypes.h" -struct PlayerState; +class PlayerState; class ReceptorArrow : public ActorFrame { diff --git a/stepmania/src/ReceptorArrowRow.h b/stepmania/src/ReceptorArrowRow.h index 28800b4298..360171bccc 100644 --- a/stepmania/src/ReceptorArrowRow.h +++ b/stepmania/src/ReceptorArrowRow.h @@ -8,7 +8,7 @@ #include "GameConstantsAndTypes.h" #include "NoteTypes.h" -struct PlayerState; +class PlayerState; class ReceptorArrowRow : public ActorFrame { diff --git a/stepmania/src/ScoreKeeper.h b/stepmania/src/ScoreKeeper.h index 18e8818b43..79b761c8a1 100644 --- a/stepmania/src/ScoreKeeper.h +++ b/stepmania/src/ScoreKeeper.h @@ -17,8 +17,8 @@ class NoteData; class Inventory; class Song; class Steps; -struct PlayerState; -struct PlayerStageStats; +class PlayerState; +class PlayerStageStats; class ScoreKeeper diff --git a/stepmania/src/ScreenNameEntryTraditional.cpp b/stepmania/src/ScreenNameEntryTraditional.cpp index 3bafc8562b..2a3cecbce5 100644 --- a/stepmania/src/ScreenNameEntryTraditional.cpp +++ b/stepmania/src/ScreenNameEntryTraditional.cpp @@ -414,7 +414,7 @@ void ScreenNameEntryTraditional::Init() SET_ON( display.m_DifficultyMeter ); this->AddChild( &display.m_DifficultyMeter ); - display.m_textScore.Load( p, &ss.m_player[p], "ScreenNameEntryTraditional Percent", false ); + display.m_textScore.Load( GAMESTATE->m_pPlayerState[p], &ss.m_player[p], "ScreenNameEntryTraditional Percent", false ); display.m_textScore.SetName( ssprintf("ScoreP%i",p+1) ); SET_ON( display.m_textScore ); this->AddChild( &display.m_textScore ); diff --git a/stepmania/src/StageStats.cpp b/stepmania/src/StageStats.cpp index 5b98fd9586..10037ea6ab 100644 --- a/stepmania/src/StageStats.cpp +++ b/stepmania/src/StageStats.cpp @@ -36,6 +36,21 @@ void StageStats::AssertValid( PlayerNumber pn ) const ASSERT( vpPossibleSongs.size() == m_player[pn].vpPossibleSteps.size() ); } +void StageStats::AssertValid( MultiPlayer pn ) const +{ + ASSERT( vpPlayedSongs.size() != 0 ); + ASSERT( vpPossibleSongs.size() != 0 ); + if( vpPlayedSongs[0] ) + CHECKPOINT_M( vpPlayedSongs[0]->GetTranslitFullTitle() ); + ASSERT( m_multiPlayer[pn].vpPlayedSteps.size() != 0 ); + ASSERT( m_multiPlayer[pn].vpPlayedSteps[0] ); + ASSERT_M( playMode < NUM_PLAY_MODES, ssprintf("playmode %i", playMode) ); + ASSERT( pStyle != NULL ); + ASSERT_M( m_player[pn].vpPlayedSteps[0]->GetDifficulty() < NUM_DIFFICULTIES, ssprintf("difficulty %i", m_player[pn].vpPlayedSteps[0]->GetDifficulty()) ); + ASSERT( vpPlayedSongs.size() == m_player[pn].vpPlayedSteps.size() ); + ASSERT( vpPossibleSongs.size() == m_player[pn].vpPossibleSteps.size() ); +} + int StageStats::GetAverageMeter( PlayerNumber pn ) const { @@ -65,13 +80,13 @@ void StageStats::AddStats( const StageStats& other ) fGameplaySeconds += other.fGameplaySeconds; fStepsSeconds += other.fStepsSeconds; - FOREACH_PlayerNumber( p ) + FOREACH_EnabledMultiPlayer( p ) m_player[p].AddStats( other.m_player[p] ); } bool StageStats::OnePassed() const { - FOREACH_HumanPlayer( p ) + FOREACH_EnabledMultiPlayer( p ) if( !m_player[p].bFailed ) return true; return false; @@ -79,7 +94,7 @@ bool StageStats::OnePassed() const bool StageStats::AllFailed() const { - FOREACH_EnabledPlayer( pn ) + FOREACH_EnabledMultiPlayer( pn ) if( !m_player[pn].bFailed ) return false; return true; @@ -87,7 +102,7 @@ bool StageStats::AllFailed() const bool StageStats::AllFailedEarlier() const { - FOREACH_EnabledPlayer( p ) + FOREACH_EnabledMultiPlayer( p ) if( !m_player[p].bFailedEarlier ) return false; return true; diff --git a/stepmania/src/StageStats.h b/stepmania/src/StageStats.h index 3d338261d1..5d488860f9 100644 --- a/stepmania/src/StageStats.h +++ b/stepmania/src/StageStats.h @@ -10,12 +10,14 @@ class Style; struct lua_State; -struct StageStats +class StageStats { +public: StageStats(); void Init(); void AssertValid( PlayerNumber pn ) const; + void AssertValid( MultiPlayer mp ) const; void AddStats( const StageStats& other ); // accumulate @@ -40,6 +42,7 @@ struct StageStats float GetTotalPossibleStepsSeconds() const; // TODO: Scale this by the music rate PlayerStageStats m_player[NUM_PLAYERS]; + PlayerStageStats m_multiPlayer[NUM_MultiPlayer]; // Lua void PushSelf( lua_State *L ); diff --git a/stepmania/src/StatsManager.cpp b/stepmania/src/StatsManager.cpp index 4a38a8651c..03cb3cfc4e 100644 --- a/stepmania/src/StatsManager.cpp +++ b/stepmania/src/StatsManager.cpp @@ -46,15 +46,22 @@ StageStats AccumStageStats( const vector& vss ) * and the rest, which are counters. */ // FIXME: Weight each song by the number of stages it took to account for // long, marathon. - FOREACH_EnabledPlayer( pn ) + FOREACH_EnabledPlayer( p ) { for( int r = 0; r < RADAR_NUM_TAPS_AND_HOLDS; r++) { - ssreturn.m_player[pn].radarPossible[r] /= uNumSongs; - ssreturn.m_player[pn].radarActual[r] /= uNumSongs; + ssreturn.m_player[p].radarPossible[r] /= uNumSongs; + ssreturn.m_player[p].radarActual[r] /= uNumSongs; + } + } + FOREACH_EnabledMultiPlayer( p ) + { + for( int r = 0; r < RADAR_NUM_TAPS_AND_HOLDS; r++) + { + ssreturn.m_multiPlayer[p].radarPossible[r] /= uNumSongs; + ssreturn.m_multiPlayer[p].radarActual[r] /= uNumSongs; } } - return ssreturn; } diff --git a/stepmania/src/Style.cpp b/stepmania/src/Style.cpp index a3845cc264..9ae32b3bcd 100644 --- a/stepmania/src/Style.cpp +++ b/stepmania/src/Style.cpp @@ -25,6 +25,8 @@ void Style::GetTransformedNoteDataForStyle( PlayerNumber pn, const NoteData& original, NoteData& noteDataOut ) const { + ASSERT( pn >=0 && pn <= NUM_PLAYERS ); + int iNewToOriginalTrack[MAX_COLS_PER_PLAYER]; for( int col=0; col