use float.h and limit.h constants instead of arbitrary large numbers

This commit is contained in:
Chris Danford
2005-03-25 20:01:51 +00:00
parent 50bd3a493c
commit bb6592a4e7
12 changed files with 30 additions and 19 deletions
+2 -2
View File
@@ -50,7 +50,7 @@ void AutoKeysounds::FinishLoading()
while(1) while(1)
{ {
/* Find the next row that either player has a note on. */ /* Find the next row that either player has a note on. */
int iNextRow = 999999999; int iNextRow = INT_MAX;
FOREACH_EnabledPlayer(pn) FOREACH_EnabledPlayer(pn)
{ {
int iNextRowForPlayer = iRow; int iNextRowForPlayer = iRow;
@@ -58,7 +58,7 @@ void AutoKeysounds::FinishLoading()
iNextRow = min( iNextRow, iNextRowForPlayer ); iNextRow = min( iNextRow, iNextRowForPlayer );
} }
if( iNextRow == 999999999 ) if( iNextRow == INT_MAX )
break; break;
iRow = iNextRow; iRow = iNextRow;
+2 -2
View File
@@ -18,8 +18,8 @@
#include "PlayerState.h" #include "PlayerState.h"
#include "Command.h" #include "Command.h"
#include "ActorUtil.h" #include "ActorUtil.h"
#include <set> #include <set>
#include <float.h>
const float FADE_SECONDS = 1.0f; const float FADE_SECONDS = 1.0f;
@@ -438,7 +438,7 @@ void Background::LoadFromSong( const Song* pSong )
continue; continue;
const float fStartBeat = change.m_fStartBeat; 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 ); m_aBGChanges.erase( m_aBGChanges.begin()+i );
--i; --i;
+3 -2
View File
@@ -8,6 +8,7 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "LuaManager.h" #include "LuaManager.h"
#include "GameManager.h" #include "GameManager.h"
#include <float.h>
static const CString RadarCategoryNames[NUM_RADAR_CATEGORIES] = { static const CString RadarCategoryNames[NUM_RADAR_CATEGORIES] = {
@@ -218,13 +219,13 @@ void DisplayBpms::Add( float f )
float DisplayBpms::GetMin() const float DisplayBpms::GetMin() const
{ {
float fMin = 99999; float fMin = FLT_MAX;
FOREACH_CONST( float, vfBpms, f ) FOREACH_CONST( float, vfBpms, f )
{ {
if( *f != -1 ) if( *f != -1 )
fMin = min( fMin, *f ); fMin = min( fMin, *f );
} }
if( fMin == 99999 ) if( fMin == FLT_MAX )
return 0; return 0;
else else
return fMin; return fMin;
+10 -5
View File
@@ -262,7 +262,7 @@ void MusicWheel::Load( CString sType )
SetOpenGroup(""); SetOpenGroup("");
// rebuild the WheelItems that appear on screen // rebuild the WheelItems that appear on screen
RebuildMusicWheelItems(); RebuildAllMusicWheelItems();
} }
MusicWheel::~MusicWheel() MusicWheel::~MusicWheel()
@@ -849,6 +849,11 @@ void CircularShift( vector<T> &v, int dist )
} }
} }
void MusicWheel::RebuildAllMusicWheelItems()
{
RebuildMusicWheelItems( INT_MAX );
}
void MusicWheel::RebuildMusicWheelItems( int dist ) void MusicWheel::RebuildMusicWheelItems( int dist )
{ {
// rewind to first index that will be displayed; // 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 // iIndex is now the index of the lowest WheelItem to draw
if( dist == -999999 ) if( dist == INT_MAX )
{ {
// Refresh all // Refresh all
for( int i=0; i<NUM_WHEEL_ITEMS; i++ ) for( int i=0; i<NUM_WHEEL_ITEMS; i++ )
@@ -1081,7 +1086,7 @@ void MusicWheel::Update( float fDeltaTime )
} }
SCREENMAN->PostMessageToTopScreen( SM_SongChanged, 0 ); SCREENMAN->PostMessageToTopScreen( SM_SongChanged, 0 );
RebuildMusicWheelItems(); RebuildAllMusicWheelItems();
TweenOnScreen(true); TweenOnScreen(true);
m_WheelState = STATE_FLYING_ON_AFTER_NEXT_SORT; m_WheelState = STATE_FLYING_ON_AFTER_NEXT_SORT;
} }
@@ -1396,7 +1401,7 @@ void MusicWheel::StartRandom()
SelectSong( GetPreferredSelectionForRandomOrPortal() ); SelectSong( GetPreferredSelectionForRandomOrPortal() );
this->Select(); this->Select();
RebuildMusicWheelItems(); RebuildAllMusicWheelItems();
} }
void MusicWheel::SetOpenGroup(CString group, SortOrder so) void MusicWheel::SetOpenGroup(CString group, SortOrder so)
@@ -1444,7 +1449,7 @@ void MusicWheel::SetOpenGroup(CString group, SortOrder so)
} }
} }
RebuildMusicWheelItems(); RebuildAllMusicWheelItems();
} }
bool MusicWheel::IsRouletting() const bool MusicWheel::IsRouletting() const
+2 -1
View File
@@ -64,7 +64,8 @@ public:
CString GetSelectedSection(){ return m_CurWheelItemData[m_iSelection]->m_sSectionName; } CString GetSelectedSection(){ return m_CurWheelItemData[m_iSelection]->m_sSectionName; }
bool WheelIsLocked() { return (m_WheelState == STATE_LOCKED ? true : false); } 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(); Song *GetPreferredSelectionForRandomOrPortal();
+2 -1
View File
@@ -4,6 +4,7 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "ThemeManager.h" #include "ThemeManager.h"
#include "Foreach.h" #include "Foreach.h"
#include <float.h>
#define GRADE_PERCENT_TIER(i) THEME->GetMetricF("PlayerStageStats",ssprintf("GradePercent%s",GradeToString((Grade)i).c_str())) #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") #define GRADE_TIER_02_IS_ALL_PERFECTS THEME->GetMetricB("PlayerStageStats","GradeTier02IsAllPerfects")
@@ -25,7 +26,7 @@ void PlayerStageStats::Init()
radarPossible.Zero(); radarPossible.Zero();
radarActual.Zero(); radarActual.Zero();
fFirstSecond = 999999; fFirstSecond = FLT_MAX;
fLastSecond = 0; fLastSecond = 0;
} }
+2 -1
View File
@@ -11,10 +11,11 @@
#include "RageDisplay.h" #include "RageDisplay.h"
#include "RageLog.h" #include "RageLog.h"
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
#include <float.h>
void RageVec3ClearBounds( RageVector3 &mins, RageVector3 &maxs ) void RageVec3ClearBounds( RageVector3 &mins, RageVector3 &maxs )
{ {
mins = RageVector3( 999999, 999999, 999999 ); mins = RageVector3( FLT_MAX, FLT_MAX, FLT_MAX );
maxs = mins * -1; maxs = mins * -1;
} }
+1 -1
View File
@@ -239,7 +239,7 @@ unsigned RageSoundReader_Chain::GetNextSoundIndex() const
int RageSoundReader_Chain::ReadBlock( int16_t *pBuffer, int iFrames ) int RageSoundReader_Chain::ReadBlock( int16_t *pBuffer, int iFrames )
{ {
/* How many samples should we read before we need to start up a sound? */ /* 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() ) if( m_iNextSound < m_Sounds.size() )
{ {
int iStartFrame = m_iCurrentFrame; int iStartFrame = m_iCurrentFrame;
+1 -1
View File
@@ -19,7 +19,7 @@ int32_t RageSurfacePalette::FindColor( const RageSurfaceColor &color ) const
int32_t RageSurfacePalette::FindClosestColor( const RageSurfaceColor &color ) const int32_t RageSurfacePalette::FindClosestColor( const RageSurfaceColor &color ) const
{ {
int iBest = -1; int iBest = -1;
int iBestDist = 99999; int iBestDist = INT_MAX;
for( int i = 0; i < ncolors; ++i ) for( int i = 0; i < ncolors; ++i )
{ {
if( colors[i] == color ) if( colors[i] == color )
+1 -1
View File
@@ -758,7 +758,7 @@ void ScreenSelectMusic::Input( const DeviceInput& DeviceI, InputEventType type,
{ {
if( type != IET_FIRST_PRESS ) return; if( type != IET_FIRST_PRESS ) return;
PREFSMAN->m_bShowNativeLanguage ^= 1; PREFSMAN->m_bShowNativeLanguage ^= 1;
m_MusicWheel.RebuildMusicWheelItems(); m_MusicWheel.RebuildAllMusicWheelItems();
m_CourseContentsFrame.SetFromGameState(); m_CourseContentsFrame.SetFromGameState();
return; return;
} }
+2 -1
View File
@@ -34,6 +34,7 @@
#include "LyricsLoader.h" #include "LyricsLoader.h"
#include <set> #include <set>
#include <float.h>
#define CACHE_DIR "Cache/" #define CACHE_DIR "Cache/"
@@ -778,7 +779,7 @@ void Song::TranslateTitles()
void Song::ReCalculateRadarValuesAndLastBeat() void Song::ReCalculateRadarValuesAndLastBeat()
{ {
float fFirstBeat = 999999; /* inf */ float fFirstBeat = FLT_MAX; /* inf */
float fLastBeat = 0; float fLastBeat = 0;
for( unsigned i=0; i<m_vpSteps.size(); i++ ) for( unsigned i=0; i<m_vpSteps.size(); i++ )
+2 -1
View File
@@ -4,6 +4,7 @@
#include "RageUtil.h" #include "RageUtil.h"
#include "RageLog.h" #include "RageLog.h"
#include "NoteTypes.h" #include "NoteTypes.h"
#include <float.h>
void BPMSegment::SetBPM( float f ) void BPMSegment::SetBPM( float f )
{ {
@@ -42,7 +43,7 @@ void SortStopSegmentsArray( vector<StopSegment> &arrayStopSegments )
void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut ) const void TimingData::GetActualBPM( float &fMinBPMOut, float &fMaxBPMOut ) const
{ {
fMinBPMOut = 99999; fMinBPMOut = FLT_MAX;
fMaxBPMOut = 0; fMaxBPMOut = 0;
for( unsigned i=0; i<m_BPMSegments.size(); i++ ) for( unsigned i=0; i<m_BPMSegments.size(); i++ )
{ {