From 2767e78218d8ad5c53350e8c58e5f6c9729291d6 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 11 Jan 2004 04:33:21 +0000 Subject: [PATCH] cleanup options comparison --- stepmania/src/ModeChoice.cpp | 12 +++--------- stepmania/src/PlayerOptions.cpp | 5 ++--- stepmania/src/PlayerOptions.h | 3 +++ stepmania/src/SongOptions.cpp | 5 ++--- stepmania/src/SongOptions.h | 3 +++ 5 files changed, 13 insertions(+), 15 deletions(-) diff --git a/stepmania/src/ModeChoice.cpp b/stepmania/src/ModeChoice.cpp index f6e25391e2..26772b6d32 100644 --- a/stepmania/src/ModeChoice.cpp +++ b/stepmania/src/ModeChoice.cpp @@ -28,7 +28,6 @@ void ModeChoice::Init() m_bInvalid = true; } -bool ComparePlayerOptions( const PlayerOptions &po1, const PlayerOptions &po2 ); bool CompareSongOptions( const SongOptions &so1, const SongOptions &so2 ); bool ModeChoice::DescribesCurrentModeForAllPlayers() const @@ -66,14 +65,9 @@ bool ModeChoice::DescribesCurrentMode( PlayerNumber pn ) const po.FromString( m_sModifiers ); so.FromString( m_sModifiers ); - /* Did anything change? */ - bool Changed = false; - if( !ComparePlayerOptions(po, GAMESTATE->m_PlayerOptions[pn]) ) - Changed = true; - if( !CompareSongOptions(so, GAMESTATE->m_SongOptions) ) - Changed = true; - - if( Changed ) + if( po != GAMESTATE->m_PlayerOptions[pn] ) + return false; + if( so != GAMESTATE->m_SongOptions ) return false; } diff --git a/stepmania/src/PlayerOptions.cpp b/stepmania/src/PlayerOptions.cpp index 0250f9419f..20c62cc3fe 100644 --- a/stepmania/src/PlayerOptions.cpp +++ b/stepmania/src/PlayerOptions.cpp @@ -465,9 +465,9 @@ float PlayerOptions::GetReversePercentForColumn( int iCol ) return f; } -bool ComparePlayerOptions( const PlayerOptions &po1, const PlayerOptions &po2 ) +bool PlayerOptions::operator==( const PlayerOptions &other ) { -#define COMPARE(x) { if( po1.x != po2.x ) return false; } +#define COMPARE(x) { if( x != other.x ) return false; } COMPARE(m_bTimeSpacing); COMPARE(m_fScrollSpeed); COMPARE(m_fScrollBPM); @@ -492,6 +492,5 @@ bool ComparePlayerOptions( const PlayerOptions &po1, const PlayerOptions &po2 ) for( i = 0; i < PlayerOptions::NUM_TRANSFORMS; ++i ) COMPARE(m_bTransforms[i]); #undef COMPARE - return true; } diff --git a/stepmania/src/PlayerOptions.h b/stepmania/src/PlayerOptions.h index c92a6dc149..340bdf78e2 100644 --- a/stepmania/src/PlayerOptions.h +++ b/stepmania/src/PlayerOptions.h @@ -20,6 +20,9 @@ struct PlayerOptions void FromString( CString sOptions ); void ChooseRandomMofifiers(); + bool operator==( const PlayerOptions &other ); + bool operator!=( const PlayerOptions &other ) { return !operator==(other); } + enum Accel { ACCEL_BOOST, diff --git a/stepmania/src/SongOptions.cpp b/stepmania/src/SongOptions.cpp index ce7857018c..4c0ce26e6b 100644 --- a/stepmania/src/SongOptions.cpp +++ b/stepmania/src/SongOptions.cpp @@ -126,9 +126,9 @@ void SongOptions::FromString( CString sOptions ) } } -bool CompareSongOptions( const SongOptions &so1, const SongOptions &so2 ) +bool SongOptions::operator==( const SongOptions &other ) { -#define COMPARE(x) { if( so1.x != so2.x ) return false; } +#define COMPARE(x) { if( x != other.x ) return false; } COMPARE( m_LifeType ); COMPARE( m_DrainType ); COMPARE( m_iBatteryLives ); @@ -138,6 +138,5 @@ bool CompareSongOptions( const SongOptions &so1, const SongOptions &so2 ) COMPARE( m_bAutoSync ); COMPARE( m_bSaveScore ); #undef COMPARE - return true; } diff --git a/stepmania/src/SongOptions.h b/stepmania/src/SongOptions.h index df111d1f6b..4a28f58cd4 100644 --- a/stepmania/src/SongOptions.h +++ b/stepmania/src/SongOptions.h @@ -29,6 +29,9 @@ struct SongOptions void Init(); CString GetString() const; void FromString( CString sOptions ); + + bool operator==( const SongOptions &other ); + bool operator!=( const SongOptions &other ) { return !operator==(other); } }; #endif