ARRAYSIZE -> ARRAYLEN

This commit is contained in:
Glenn Maynard
2006-09-13 03:11:38 +00:00
parent 9fb0d09f35
commit e206261b80
21 changed files with 28 additions and 28 deletions
+1 -1
View File
@@ -1151,7 +1151,7 @@ bool Actor::TweenState::operator==( const TweenState &other ) const
COMPARE( fSkewX ); COMPARE( fSkewX );
COMPARE( crop ); COMPARE( crop );
COMPARE( fade ); COMPARE( fade );
for( unsigned i=0; i<ARRAYSIZE(diffuse); i++ ) for( unsigned i=0; i<ARRAYLEN(diffuse); i++ )
COMPARE( diffuse[i] ); COMPARE( diffuse[i] );
COMPARE( glow ); COMPARE( glow );
COMPARE( aux ); COMPARE( aux );
+2 -2
View File
@@ -61,7 +61,7 @@ static const RString EMPTY_STRING;
as_##X##Name[i] = ap; \ as_##X##Name[i] = ap; \
} \ } \
} \ } \
ASSERT( CNT == ARRAYSIZE(X##Names) ); \ ASSERT( CNT == ARRAYLEN(X##Names) ); \
if( x == CNT+1 ) \ if( x == CNT+1 ) \
return EMPTY_STRING; \ return EMPTY_STRING; \
ASSERT( x < CNT ); \ ASSERT( x < CNT ); \
@@ -88,7 +88,7 @@ static const RString EMPTY_STRING;
RString s2 = s; \ RString s2 = s; \
s2.MakeLower(); \ s2.MakeLower(); \
unsigned i; \ unsigned i; \
for( i = 0; i < ARRAYSIZE(X##Names); ++i ) \ for( i = 0; i < ARRAYLEN(X##Names); ++i ) \
if( !s2.CompareNoCase(X##Names[i]) ) \ if( !s2.CompareNoCase(X##Names[i]) ) \
return (X)i; \ return (X)i; \
return (X)(i+1); /*invalid*/ \ return (X)(i+1); /*invalid*/ \
+2 -2
View File
@@ -275,7 +275,7 @@ const glyph &Font::GetGlyph( wchar_t c ) const
ASSERT(c >= 0 && c <= 0xFFFFFF); ASSERT(c >= 0 && c <= 0xFFFFFF);
/* Fast path: */ /* Fast path: */
if( c < (int) ARRAYSIZE(m_iCharToGlyphCache) && m_iCharToGlyphCache[c] ) if( c < (int) ARRAYLEN(m_iCharToGlyphCache) && m_iCharToGlyphCache[c] )
return *m_iCharToGlyphCache[c]; return *m_iCharToGlyphCache[c];
/* Try the regular character. */ /* Try the regular character. */
@@ -767,7 +767,7 @@ void Font::Load( const RString &sIniPath, RString sChars )
ZERO( m_iCharToGlyphCache ); ZERO( m_iCharToGlyphCache );
map<longchar,glyph*>::iterator it; map<longchar,glyph*>::iterator it;
for( it = m_iCharToGlyph.begin(); it != m_iCharToGlyph.end(); ++it ) for( it = m_iCharToGlyph.begin(); it != m_iCharToGlyph.end(); ++it )
if( it->first < (int) ARRAYSIZE(m_iCharToGlyphCache) ) if( it->first < (int) ARRAYLEN(m_iCharToGlyphCache) )
m_iCharToGlyphCache[it->first] = it->second; m_iCharToGlyphCache[it->first] = it->second;
} }
} }
+1 -1
View File
@@ -2644,7 +2644,7 @@ static Style g_Styles[] =
}, },
}; };
#define NUM_STYLES ARRAYSIZE(g_Styles) #define NUM_STYLES ARRAYLEN(g_Styles)
void GameManager::GetStylesForGame( const Game *pGame, vector<const Style*>& aStylesAddTo, bool editor ) const void GameManager::GetStylesForGame( const Game *pGame, vector<const Style*>& aStylesAddTo, bool editor ) const
{ {
+2 -2
View File
@@ -130,7 +130,7 @@ public:
Actor::SetTextureRenderStates(); Actor::SetTextureRenderStates();
DISPLAY->SetTextureModeModulate(); DISPLAY->SetTextureModeModulate();
DISPLAY->DrawQuadStrip( m_Slices, ARRAYSIZE(m_Slices) ); DISPLAY->DrawQuadStrip( m_Slices, ARRAYLEN(m_Slices) );
} }
RageSpriteVertex m_Slices[2*VALUE_RESOLUTION]; RageSpriteVertex m_Slices[2*VALUE_RESOLUTION];
@@ -192,7 +192,7 @@ void GraphDisplay::LoadFromStageStats( const StageStats &ss, const PlayerStageSt
m_Values.resize( VALUE_RESOLUTION ); m_Values.resize( VALUE_RESOLUTION );
pss.GetLifeRecord( &m_Values[0], VALUE_RESOLUTION, ss.GetTotalPossibleStepsSeconds() ); pss.GetLifeRecord( &m_Values[0], VALUE_RESOLUTION, ss.GetTotalPossibleStepsSeconds() );
for( unsigned i=0; i<ARRAYSIZE(m_Values); i++ ) for( unsigned i=0; i<ARRAYLEN(m_Values); i++ )
CLAMP( m_Values[i], 0.f, 1.f ); CLAMP( m_Values[i], 0.f, 1.f );
// //
+1 -1
View File
@@ -504,7 +504,7 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
{ {
InputDevice id = vDevices[i].id; InputDevice id = vDevices[i].id;
const RString &sDescription = vDevices[i].sDesc; const RString &sDescription = vDevices[i].sDesc;
for( unsigned j=0; j<ARRAYSIZE(g_AutoJoyMappings); j++ ) for( unsigned j=0; j<ARRAYLEN(g_AutoJoyMappings); j++ )
{ {
const AutoJoyMapping& mapping = g_AutoJoyMappings[j]; const AutoJoyMapping& mapping = g_AutoJoyMappings[j];
+2 -2
View File
@@ -208,7 +208,7 @@ static int g_iNumStackCounts = 0;
Lua *LuaManager::Get() Lua *LuaManager::Get()
{ {
m_pLock->Lock(); m_pLock->Lock();
if( size_t(g_iNumStackCounts) < ARRAYSIZE(g_iStackCounts) ) if( size_t(g_iNumStackCounts) < ARRAYLEN(g_iStackCounts) )
{ {
g_iStackCounts[g_iNumStackCounts] = lua_gettop(L); g_iStackCounts[g_iNumStackCounts] = lua_gettop(L);
} }
@@ -221,7 +221,7 @@ void LuaManager::Release( Lua *&p )
ASSERT( p == L ); ASSERT( p == L );
ASSERT( g_iNumStackCounts != 0 ); ASSERT( g_iNumStackCounts != 0 );
--g_iNumStackCounts; --g_iNumStackCounts;
if( size_t(g_iNumStackCounts) < ARRAYSIZE(g_iStackCounts) ) if( size_t(g_iNumStackCounts) < ARRAYLEN(g_iStackCounts) )
{ {
ASSERT( g_iStackCounts[g_iNumStackCounts] == lua_gettop(L) ); ASSERT( g_iStackCounts[g_iNumStackCounts] == lua_gettop(L) );
} }
+1 -1
View File
@@ -43,7 +43,7 @@ static const SortOrder g_SongSortOrders[] =
SORT_ARTIST, SORT_ARTIST,
SORT_GENRE, SORT_GENRE,
}; };
const vector<SortOrder> SONG_SORT_ORDERS( g_SongSortOrders, g_SongSortOrders + ARRAYSIZE(g_SongSortOrders) ); const vector<SortOrder> SONG_SORT_ORDERS( g_SongSortOrders, g_SongSortOrders + ARRAYLEN(g_SongSortOrders) );
static SortOrder ForceAppropriateSort( PlayMode pm, SortOrder so ) static SortOrder ForceAppropriateSort( PlayMode pm, SortOrder so )
{ {
+2 -2
View File
@@ -1816,7 +1816,7 @@ const ValidRow g_ValidRows[] =
void NoteDataUtil::RemoveStretch( NoteData &inout, StepsType st, int iStartIndex, int iEndIndex ) void NoteDataUtil::RemoveStretch( NoteData &inout, StepsType st, int iStartIndex, int iEndIndex )
{ {
vector<const ValidRow*> vpValidRowsToCheck; vector<const ValidRow*> vpValidRowsToCheck;
for( unsigned i=0; i<ARRAYSIZE(g_ValidRows); i++ ) for( unsigned i=0; i<ARRAYLEN(g_ValidRows); i++ )
{ {
if( g_ValidRows[i].st == st ) if( g_ValidRows[i].st == st )
vpValidRowsToCheck.push_back( &g_ValidRows[i] ); vpValidRowsToCheck.push_back( &g_ValidRows[i] );
@@ -1954,7 +1954,7 @@ void NoteDataUtil::AddTapAttacks( NoteData &nd, Song* pSong )
TapNote::attack, TapNote::attack,
TapNote::SubType_invalid, TapNote::SubType_invalid,
TapNote::original, TapNote::original,
szAttacks[RandomInt(ARRAYSIZE(szAttacks))], szAttacks[RandomInt(ARRAYLEN(szAttacks))],
15.0f, 15.0f,
-1 ); -1 );
nd.SetTapNote( iTrack, BeatToNoteRow(fBeat), tn ); nd.SetTapNote( iTrack, BeatToNoteRow(fBeat), tn );
+1 -1
View File
@@ -20,7 +20,7 @@ void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, R
{ {
const RString sLeftSeps[] = { " -", " ~", " (", " [", "\t" }; const RString sLeftSeps[] = { " -", " ~", " (", " [", "\t" };
for( unsigned i=0; i<ARRAYSIZE(sLeftSeps); i++ ) for( unsigned i=0; i<ARRAYLEN(sLeftSeps); i++ )
{ {
size_t iBeginIndex = sFullTitle.find( sLeftSeps[i] ); size_t iBeginIndex = sFullTitle.find( sLeftSeps[i] );
if( iBeginIndex == string::npos ) if( iBeginIndex == string::npos )
+1 -1
View File
@@ -882,7 +882,7 @@ void BMSLoader::SetTimeSigAdjustments( const MeasureToTimeSig_t &sigs, Song *pOu
}; };
bool bValidTimeSignature = false; bool bValidTimeSignature = false;
for( unsigned i = 0; i < ARRAYSIZE(ValidFactors); ++i ) for( unsigned i = 0; i < ARRAYLEN(ValidFactors); ++i )
if( fabsf(fFactor-ValidFactors[i]) < 0.001 ) if( fabsf(fFactor-ValidFactors[i]) < 0.001 )
bValidTimeSignature = true; bValidTimeSignature = true;
+1 -1
View File
@@ -54,7 +54,7 @@ void OptionIcon::Set( PlayerNumber pn, const RString &_sText, bool bHeader )
"OFF", "OFF",
}; };
for( unsigned i=0; i<ARRAYSIZE(sStopWords); i++ ) for( unsigned i=0; i<ARRAYLEN(sStopWords); i++ )
if( 0==stricmp(sText,sStopWords[i]) ) if( 0==stricmp(sText,sStopWords[i]) )
sText = ""; sText = "";
+1 -1
View File
@@ -84,7 +84,7 @@ int OptionToPreferredColumn( RString sOptionText )
return 0; return 0;
} }
for( unsigned i=0; i<ARRAYSIZE(g_OptionColumnEntries); i++ ) for( unsigned i=0; i<ARRAYLEN(g_OptionColumnEntries); i++ )
if( g_OptionColumnEntries[i].szString == sOptionText ) if( g_OptionColumnEntries[i].szString == sOptionText )
return g_OptionColumnEntries[i].iSlotIndex; return g_OptionColumnEntries[i].iSlotIndex;
+1 -1
View File
@@ -14,7 +14,7 @@
#include "arch/Dialog/Dialog.h" #include "arch/Dialog/Dialog.h"
#include <float.h> #include <float.h>
#define ONE( arr ) { for( unsigned Z = 0; Z < ARRAYSIZE(arr); ++Z ) arr[Z]=1.0f; } #define ONE( arr ) { for( unsigned Z = 0; Z < ARRAYLEN(arr); ++Z ) arr[Z]=1.0f; }
void PlayerOptions::Init() void PlayerOptions::Init()
{ {
+1 -1
View File
@@ -710,7 +710,7 @@ static bool PathUsesSlowFlush( const RString &sPath )
"Save/" "Save/"
}; };
for( unsigned i = 0; i < ARRAYSIZE(FlushPaths); ++i ) for( unsigned i = 0; i < ARRAYLEN(FlushPaths); ++i )
if( !strncmp( sPath, FlushPaths[i], strlen(FlushPaths[i]) ) ) if( !strncmp( sPath, FlushPaths[i], strlen(FlushPaths[i]) ) )
return true; return true;
return false; return false;
+1 -1
View File
@@ -275,7 +275,7 @@ int RageSoundReader_Chain::ReadBlock( int16_t *pBuffer, int iFrames )
{ {
ActiveSound &s = m_apActiveSounds[i]; ActiveSound &s = m_apActiveSounds[i];
SoundReader *pSound = s.pSound; SoundReader *pSound = s.pSound;
int iSamples = min( iFramesToRead * pSound->GetNumChannels(), ARRAYSIZE(Buffer) ); int iSamples = min( iFramesToRead * pSound->GetNumChannels(), ARRAYLEN(Buffer) );
int iBytesRead = pSound->Read( (char *) Buffer, iSamples*sizeof(int16_t) ); int iBytesRead = pSound->Read( (char *) Buffer, iSamples*sizeof(int16_t) );
if( iBytesRead == -1 || iBytesRead == 0 ) if( iBytesRead == -1 || iBytesRead == 0 )
{ {
+3 -3
View File
@@ -1244,7 +1244,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
const float fSpeeds[] = { 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f, 8.0f }; const float fSpeeds[] = { 1.0f, 1.5f, 2.0f, 3.0f, 4.0f, 6.0f, 8.0f };
int iSpeed = 0; int iSpeed = 0;
for( unsigned i = 0; i < ARRAYSIZE(fSpeeds); ++i ) for( unsigned i = 0; i < ARRAYLEN(fSpeeds); ++i )
{ {
if( fSpeeds[i] == fScrollSpeed ) if( fSpeeds[i] == fScrollSpeed )
{ {
@@ -1257,7 +1257,7 @@ void ScreenEdit::InputEdit( const InputEventPlus &input, EditButton EditB )
--iSpeed; --iSpeed;
else if( EditB == EDIT_BUTTON_SCROLL_SPEED_UP ) else if( EditB == EDIT_BUTTON_SCROLL_SPEED_UP )
++iSpeed; ++iSpeed;
iSpeed = clamp( iSpeed, 0, (int) ARRAYSIZE(fSpeeds)-1 ); iSpeed = clamp( iSpeed, 0, (int) ARRAYLEN(fSpeeds)-1 );
if( fSpeeds[iSpeed] != fScrollSpeed ) if( fSpeeds[iSpeed] != fScrollSpeed )
{ {
@@ -3668,7 +3668,7 @@ void ScreenEdit::DoHelp()
{ {
g_EditHelp.rows.clear(); g_EditHelp.rows.clear();
for( unsigned i=0; i<ARRAYSIZE(g_EditHelpLines); ++i ) for( unsigned i=0; i<ARRAYLEN(g_EditHelpLines); ++i )
{ {
const EditHelpLine &hl = g_EditHelpLines[i]; const EditHelpLine &hl = g_EditHelpLines[i];
+1 -1
View File
@@ -216,7 +216,7 @@ void ScreenEvaluation::Init()
{ {
const int ScoreBonuses[] = { 10000000, 10000000, 1000000, 100000, 10000, 1000, 100 }; const int ScoreBonuses[] = { 10000000, 10000000, 1000000, 100000, 10000, 1000, 100 };
Grade g = STATSMAN->m_CurStageStats.m_player[p].GetGrade(); Grade g = STATSMAN->m_CurStageStats.m_player[p].GetGrade();
if( g < (int) ARRAYSIZE(ScoreBonuses) ) if( g < (int) ARRAYLEN(ScoreBonuses) )
{ {
STATSMAN->m_CurStageStats.m_player[p].iBonus += ScoreBonuses[(int)g]; STATSMAN->m_CurStageStats.m_player[p].iBonus += ScoreBonuses[(int)g];
STATSMAN->m_CurStageStats.m_player[p].iBonus += ScoreBonuses[(int)g]; STATSMAN->m_CurStageStats.m_player[p].iBonus += ScoreBonuses[(int)g];
+1 -1
View File
@@ -57,7 +57,7 @@ const char NAME_CHARS[] =
{ {
' ',' ',' ',' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' ' ',' ',' ',' ','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'
}; };
#define NUM_NAME_CHARS (ARRAYSIZE(NAME_CHARS)) #define NUM_NAME_CHARS (ARRAYLEN(NAME_CHARS))
#define HEIGHT_OF_ALL_CHARS (NUM_NAME_CHARS * g_fCharsSpacingY) #define HEIGHT_OF_ALL_CHARS (NUM_NAME_CHARS * g_fCharsSpacingY)
+1 -1
View File
@@ -609,7 +609,7 @@ bool CheckVideoDefaultSettings()
VideoCardDefaults defaults; VideoCardDefaults defaults;
for( unsigned i=0; i<ARRAYSIZE(g_VideoCardDefaults); i++ ) for( unsigned i=0; i<ARRAYLEN(g_VideoCardDefaults); i++ )
{ {
defaults = g_VideoCardDefaults[i]; defaults = g_VideoCardDefaults[i];
+1 -1
View File
@@ -49,7 +49,7 @@ static void InitEntities()
{ '>', "gt", } { '>', "gt", }
}; };
for( unsigned i = 0; i < ARRAYSIZE(EntityTable); ++i ) for( unsigned i = 0; i < ARRAYLEN(EntityTable); ++i )
{ {
const Entity &ent = EntityTable[i]; const Entity &ent = EntityTable[i];
g_mapEntitiesToChars[ent.pEntity] = RString(1, ent.c); g_mapEntitiesToChars[ent.pEntity] = RString(1, ent.c);