From bb6592a4e7d2ddbed4bba43bff22530769bac48e Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 25 Mar 2005 20:01:51 +0000 Subject: [PATCH] use float.h and limit.h constants instead of arbitrary large numbers --- stepmania/src/AutoKeysounds.cpp | 4 ++-- stepmania/src/Background.cpp | 4 ++-- stepmania/src/GameConstantsAndTypes.cpp | 5 +++-- stepmania/src/MusicWheel.cpp | 15 ++++++++++----- stepmania/src/MusicWheel.h | 3 ++- stepmania/src/PlayerStageStats.cpp | 3 ++- stepmania/src/RageMath.cpp | 3 ++- stepmania/src/RageSoundReader_Chain.cpp | 2 +- stepmania/src/RageSurface.cpp | 2 +- stepmania/src/ScreenSelectMusic.cpp | 2 +- stepmania/src/Song.cpp | 3 ++- stepmania/src/TimingData.cpp | 3 ++- 12 files changed, 30 insertions(+), 19 deletions(-) diff --git a/stepmania/src/AutoKeysounds.cpp b/stepmania/src/AutoKeysounds.cpp index fbb434d14c..b78471d5c7 100644 --- a/stepmania/src/AutoKeysounds.cpp +++ b/stepmania/src/AutoKeysounds.cpp @@ -50,7 +50,7 @@ void AutoKeysounds::FinishLoading() while(1) { /* Find the next row that either player has a note on. */ - int iNextRow = 999999999; + int iNextRow = INT_MAX; FOREACH_EnabledPlayer(pn) { int iNextRowForPlayer = iRow; @@ -58,7 +58,7 @@ void AutoKeysounds::FinishLoading() iNextRow = min( iNextRow, iNextRowForPlayer ); } - if( iNextRow == 999999999 ) + if( iNextRow == INT_MAX ) break; iRow = iNextRow; diff --git a/stepmania/src/Background.cpp b/stepmania/src/Background.cpp index 9c977a418b..6d2fe7c6c0 100644 --- a/stepmania/src/Background.cpp +++ b/stepmania/src/Background.cpp @@ -18,8 +18,8 @@ #include "PlayerState.h" #include "Command.h" #include "ActorUtil.h" - #include +#include const float FADE_SECONDS = 1.0f; @@ -438,7 +438,7 @@ void Background::LoadFromSong( const Song* pSong ) continue; const float fStartBeat = change.m_fStartBeat; - const float fLastBeat = (i+1 < m_aBGChanges.size())? m_aBGChanges[i+1].m_fStartBeat: 99999; + const float fLastBeat = (i+1 < m_aBGChanges.size())? m_aBGChanges[i+1].m_fStartBeat: FLT_MAX; m_aBGChanges.erase( m_aBGChanges.begin()+i ); --i; diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index 889fcbea4a..a6a82b65b6 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -8,6 +8,7 @@ #include "PrefsManager.h" #include "LuaManager.h" #include "GameManager.h" +#include static const CString RadarCategoryNames[NUM_RADAR_CATEGORIES] = { @@ -218,13 +219,13 @@ void DisplayBpms::Add( float f ) float DisplayBpms::GetMin() const { - float fMin = 99999; + float fMin = FLT_MAX; FOREACH_CONST( float, vfBpms, f ) { if( *f != -1 ) fMin = min( fMin, *f ); } - if( fMin == 99999 ) + if( fMin == FLT_MAX ) return 0; else return fMin; diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index f8e65b7a92..c341151dba 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -262,7 +262,7 @@ void MusicWheel::Load( CString sType ) SetOpenGroup(""); // rebuild the WheelItems that appear on screen - RebuildMusicWheelItems(); + RebuildAllMusicWheelItems(); } MusicWheel::~MusicWheel() @@ -849,6 +849,11 @@ void CircularShift( vector &v, int dist ) } } +void MusicWheel::RebuildAllMusicWheelItems() +{ + RebuildMusicWheelItems( INT_MAX ); +} + void MusicWheel::RebuildMusicWheelItems( int dist ) { // rewind to first index that will be displayed; @@ -864,7 +869,7 @@ void MusicWheel::RebuildMusicWheelItems( int dist ) // iIndex is now the index of the lowest WheelItem to draw - if( dist == -999999 ) + if( dist == INT_MAX ) { // Refresh all for( int i=0; iPostMessageToTopScreen( SM_SongChanged, 0 ); - RebuildMusicWheelItems(); + RebuildAllMusicWheelItems(); TweenOnScreen(true); m_WheelState = STATE_FLYING_ON_AFTER_NEXT_SORT; } @@ -1396,7 +1401,7 @@ void MusicWheel::StartRandom() SelectSong( GetPreferredSelectionForRandomOrPortal() ); this->Select(); - RebuildMusicWheelItems(); + RebuildAllMusicWheelItems(); } void MusicWheel::SetOpenGroup(CString group, SortOrder so) @@ -1444,7 +1449,7 @@ void MusicWheel::SetOpenGroup(CString group, SortOrder so) } } - RebuildMusicWheelItems(); + RebuildAllMusicWheelItems(); } bool MusicWheel::IsRouletting() const diff --git a/stepmania/src/MusicWheel.h b/stepmania/src/MusicWheel.h index 79d548e0c7..78957cf4b4 100644 --- a/stepmania/src/MusicWheel.h +++ b/stepmania/src/MusicWheel.h @@ -64,7 +64,8 @@ public: CString GetSelectedSection(){ return m_CurWheelItemData[m_iSelection]->m_sSectionName; } bool WheelIsLocked() { return (m_WheelState == STATE_LOCKED ? true : false); } - void RebuildMusicWheelItems( int dist = -999999 ); // -999999 = refresh all + void RebuildAllMusicWheelItems(); + void RebuildMusicWheelItems( int dist ); Song *GetPreferredSelectionForRandomOrPortal(); diff --git a/stepmania/src/PlayerStageStats.cpp b/stepmania/src/PlayerStageStats.cpp index 160f598da6..578fe6b2ba 100644 --- a/stepmania/src/PlayerStageStats.cpp +++ b/stepmania/src/PlayerStageStats.cpp @@ -4,6 +4,7 @@ #include "PrefsManager.h" #include "ThemeManager.h" #include "Foreach.h" +#include #define GRADE_PERCENT_TIER(i) THEME->GetMetricF("PlayerStageStats",ssprintf("GradePercent%s",GradeToString((Grade)i).c_str())) #define GRADE_TIER_02_IS_ALL_PERFECTS THEME->GetMetricB("PlayerStageStats","GradeTier02IsAllPerfects") @@ -25,7 +26,7 @@ void PlayerStageStats::Init() radarPossible.Zero(); radarActual.Zero(); - fFirstSecond = 999999; + fFirstSecond = FLT_MAX; fLastSecond = 0; } diff --git a/stepmania/src/RageMath.cpp b/stepmania/src/RageMath.cpp index 33d893bd79..15eaaea409 100644 --- a/stepmania/src/RageMath.cpp +++ b/stepmania/src/RageMath.cpp @@ -11,10 +11,11 @@ #include "RageDisplay.h" #include "RageLog.h" #include "arch/Dialog/Dialog.h" +#include void RageVec3ClearBounds( RageVector3 &mins, RageVector3 &maxs ) { - mins = RageVector3( 999999, 999999, 999999 ); + mins = RageVector3( FLT_MAX, FLT_MAX, FLT_MAX ); maxs = mins * -1; } diff --git a/stepmania/src/RageSoundReader_Chain.cpp b/stepmania/src/RageSoundReader_Chain.cpp index 0038504be7..227b498de9 100644 --- a/stepmania/src/RageSoundReader_Chain.cpp +++ b/stepmania/src/RageSoundReader_Chain.cpp @@ -239,7 +239,7 @@ unsigned RageSoundReader_Chain::GetNextSoundIndex() const int RageSoundReader_Chain::ReadBlock( int16_t *pBuffer, int iFrames ) { /* How many samples should we read before we need to start up a sound? */ - int iFramesToRead = 999999999; /* inf */ + int iFramesToRead = INT_MAX; if( m_iNextSound < m_Sounds.size() ) { int iStartFrame = m_iCurrentFrame; diff --git a/stepmania/src/RageSurface.cpp b/stepmania/src/RageSurface.cpp index 98be815aab..cc2ab9d495 100644 --- a/stepmania/src/RageSurface.cpp +++ b/stepmania/src/RageSurface.cpp @@ -19,7 +19,7 @@ int32_t RageSurfacePalette::FindColor( const RageSurfaceColor &color ) const int32_t RageSurfacePalette::FindClosestColor( const RageSurfaceColor &color ) const { int iBest = -1; - int iBestDist = 99999; + int iBestDist = INT_MAX; for( int i = 0; i < ncolors; ++i ) { if( colors[i] == color ) diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index 228e93b817..3a1e68fb1f 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -758,7 +758,7 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type, { if( type != IET_FIRST_PRESS ) return; PREFSMAN->m_bShowNativeLanguage ^= 1; - m_MusicWheel.RebuildMusicWheelItems(); + m_MusicWheel.RebuildAllMusicWheelItems(); m_CourseContentsFrame.SetFromGameState(); return; } diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index 080d659846..83481e9b15 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -34,6 +34,7 @@ #include "LyricsLoader.h" #include +#include #define CACHE_DIR "Cache/" @@ -778,7 +779,7 @@ void Song::TranslateTitles() void Song::ReCalculateRadarValuesAndLastBeat() { - float fFirstBeat = 999999; /* inf */ + float fFirstBeat = FLT_MAX; /* inf */ float fLastBeat = 0; for( unsigned i=0; i void BPMSegment::SetBPM( float f ) { @@ -42,7 +43,7 @@ void SortStopSegmentsArray( vector &arrayStopSegments ) void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut ) const { - fMinBPMOut = 99999; + fMinBPMOut = FLT_MAX; fMaxBPMOut = 0; for( unsigned i=0; i