ARRAYLEN
This commit is contained in:
@@ -50,7 +50,7 @@ static const DeviceButton g_keys[] =
|
||||
|
||||
static DeviceButton GetRandomKeyboardKey()
|
||||
{
|
||||
int index = RandomInt( ARRAYSIZE(g_keys) );
|
||||
int index = RandomInt( ARRAYLEN(g_keys) );
|
||||
return g_keys[index];
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ void InputHandler_Win32_Pump::HandleInput( int iDevice, int iEvent )
|
||||
|
||||
InputDevice id = InputDevice( DEVICE_PUMP1 + iDevice );
|
||||
|
||||
for( int iButton = 0; iButton < ARRAYSIZE(bits); ++iButton )
|
||||
for( int iButton = 0; iButton < ARRAYLEN(bits); ++iButton )
|
||||
{
|
||||
DeviceInput di( id, enum_add2(JOY_BUTTON_1, iButton) );
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ static DeviceButton XSymToDeviceButton( int key )
|
||||
return ASCIIKeySyms[key & 0xFF];
|
||||
|
||||
/* 32...127: */
|
||||
if( key < int(ARRAYSIZE(ASCIIKeySyms)))
|
||||
if( key < int(ARRAYLEN(ASCIIKeySyms)))
|
||||
return ASCIIKeySyms[key];
|
||||
|
||||
/* XK_KP_0 ... XK_KP_9 to KEY_KP_C0 ... KEY_KP_C9 */
|
||||
|
||||
@@ -96,7 +96,7 @@ void InputHandler_Xbox::Update()
|
||||
XInputGetState( joysticks[i], &xis );
|
||||
|
||||
// check buttons
|
||||
for(int j = 0; j < ARRAYSIZE(buttonMasks); j++)
|
||||
for(int j = 0; j < ARRAYLEN(buttonMasks); j++)
|
||||
{
|
||||
DWORD nowPressed = xis.Gamepad.wButtons & buttonMasks[j];
|
||||
DWORD wasPressed = lastState[i].wButtons & buttonMasks[j];
|
||||
@@ -116,7 +116,7 @@ void InputHandler_Xbox::Update()
|
||||
}
|
||||
|
||||
// check analog buttons
|
||||
for(int j = 0; j < ARRAYSIZE(xis.Gamepad.bAnalogButtons); j++)
|
||||
for(int j = 0; j < ARRAYLEN(xis.Gamepad.bAnalogButtons); j++)
|
||||
{
|
||||
bool nowPressed = xis.Gamepad.bAnalogButtons[j] > XINPUT_GAMEPAD_MAX_CROSSTALK;
|
||||
bool wasPressed = lastState[i].bAnalogButtons[j] > XINPUT_GAMEPAD_MAX_CROSSTALK;
|
||||
@@ -138,7 +138,7 @@ void InputHandler_Xbox::Update()
|
||||
// check thumbsticks
|
||||
SHORT axes[] = { xis.Gamepad.sThumbLX, xis.Gamepad.sThumbLY, xis.Gamepad.sThumbRX, xis.Gamepad.sThumbRY};
|
||||
|
||||
for(int j = 0; j < ARRAYSIZE(axes); j++)
|
||||
for(int j = 0; j < ARRAYLEN(axes); j++)
|
||||
{
|
||||
if(axes[j] != 0)
|
||||
{
|
||||
|
||||
@@ -301,7 +301,7 @@ static RString CheckMixingBlacklist()
|
||||
/* ALSA Driver: 0: Aureal Vortex au8830 [au8830], device 0: AU88x0 ADB [adb], 32/32 subdevices avail
|
||||
* ALSA segfaults after creating about ten subdevices. */
|
||||
"au8830",
|
||||
}, *blacklist_end = blacklist+ARRAYSIZE(blacklist);
|
||||
}, *blacklist_end = blacklist+ARRAYLEN(blacklist);
|
||||
|
||||
if( find( &blacklist[0], blacklist_end, sID ) != blacklist_end )
|
||||
return ssprintf( "ALSA driver \"%s\" not using hardware mixing", sID.c_str() );
|
||||
|
||||
@@ -63,7 +63,7 @@ void RageSound_Generic_Software::Mix( int16_t *buf, int frames, int64_t frameno,
|
||||
|
||||
static RageSoundMixBuffer mix;
|
||||
|
||||
for( unsigned i = 0; i < ARRAYSIZE(sounds); ++i )
|
||||
for( unsigned i = 0; i < ARRAYLEN(sounds); ++i )
|
||||
{
|
||||
/* s.snd can not safely be accessed from here. */
|
||||
sound &s = sounds[i];
|
||||
@@ -174,7 +174,7 @@ void RageSound_Generic_Software::DecodeThread()
|
||||
LockMut( m_Mutex );
|
||||
// LOG->Trace("begin mix");
|
||||
|
||||
for( unsigned i = 0; i < ARRAYSIZE(sounds); ++i )
|
||||
for( unsigned i = 0; i < ARRAYLEN(sounds); ++i )
|
||||
{
|
||||
/* The volume can change while the sound is playing; update it. */
|
||||
/* XXX: We can't access snd when in STOPPING; it doesn't exist anymore. */
|
||||
@@ -195,7 +195,7 @@ void RageSound_Generic_Software::DecodeThread()
|
||||
* causing major CPU bursts when the stream starts or underruns. (Filling 32k
|
||||
* takes more CPU than filling 4k frames, and may cause a gameplay skip.)
|
||||
*/
|
||||
for( unsigned i = 0; i < ARRAYSIZE(sounds); ++i )
|
||||
for( unsigned i = 0; i < ARRAYLEN(sounds); ++i )
|
||||
{
|
||||
if( sounds[i].state != sound::PLAYING )
|
||||
continue;
|
||||
@@ -245,7 +245,7 @@ int RageSound_Generic_Software::GetDataForSound( sound &s )
|
||||
ASSERT( psize[0] > 0 );
|
||||
|
||||
sound_block *b = p[0];
|
||||
int size = ARRAYSIZE(b->buf)/channels;
|
||||
int size = ARRAYLEN(b->buf)/channels;
|
||||
bool eof = !s.snd->GetDataToPlay( b->buf, size, b->position, b->frames_in_buffer );
|
||||
b->p = b->buf;
|
||||
|
||||
@@ -263,7 +263,7 @@ void RageSound_Generic_Software::Update()
|
||||
/* We must not lock here, since the decoder thread might hold the lock for a
|
||||
* while at a time. This is threadsafe, because once a sound is in STOPPING,
|
||||
* this is the only place it'll be changed (to STOPPED). */
|
||||
for( unsigned i = 0; i < ARRAYSIZE(sounds); ++i )
|
||||
for( unsigned i = 0; i < ARRAYLEN(sounds); ++i )
|
||||
{
|
||||
switch( sounds[i].state )
|
||||
{
|
||||
@@ -316,10 +316,10 @@ void RageSound_Generic_Software::StartMixing( RageSoundBase *snd )
|
||||
m_SoundListMutex.Lock();
|
||||
|
||||
unsigned i;
|
||||
for( i = 0; i < ARRAYSIZE(sounds); ++i )
|
||||
for( i = 0; i < ARRAYLEN(sounds); ++i )
|
||||
if( sounds[i].state == sound::AVAILABLE )
|
||||
break;
|
||||
if( i == ARRAYSIZE(sounds) )
|
||||
if( i == ARRAYLEN(sounds) )
|
||||
{
|
||||
m_SoundListMutex.Unlock();
|
||||
return;
|
||||
@@ -381,10 +381,10 @@ void RageSound_Generic_Software::StopMixing( RageSoundBase *snd )
|
||||
|
||||
/* Find the sound. */
|
||||
unsigned i;
|
||||
for( i = 0; i < ARRAYSIZE(sounds); ++i )
|
||||
for( i = 0; i < ARRAYLEN(sounds); ++i )
|
||||
if( sounds[i].state != sound::AVAILABLE && sounds[i].snd == snd )
|
||||
break;
|
||||
if( i == ARRAYSIZE(sounds) )
|
||||
if( i == ARRAYLEN(sounds) )
|
||||
{
|
||||
LOG->Trace( "not stopping a sound because it's not playing" );
|
||||
return;
|
||||
@@ -416,14 +416,14 @@ bool RageSound_Generic_Software::PauseMixing( RageSoundBase *snd, bool bStop )
|
||||
|
||||
/* Find the sound. */
|
||||
unsigned i;
|
||||
for( i = 0; i < ARRAYSIZE(sounds); ++i )
|
||||
for( i = 0; i < ARRAYLEN(sounds); ++i )
|
||||
if( sounds[i].state != sound::AVAILABLE && sounds[i].snd == snd )
|
||||
break;
|
||||
|
||||
/* A sound can be paused in PLAYING or STOPPING. (STOPPING means the sound
|
||||
* has been decoded to the end, and we're waiting for that data to finish, so
|
||||
* externally it looks and acts like PLAYING.) */
|
||||
if( i == ARRAYSIZE(sounds) ||
|
||||
if( i == ARRAYLEN(sounds) ||
|
||||
(sounds[i].state != sound::PLAYING && sounds[i].state != sound::STOPPING) )
|
||||
{
|
||||
LOG->Trace( "not pausing a sound because it's not playing" );
|
||||
|
||||
@@ -8,7 +8,7 @@ static unsigned g_iNumEmergencyFuncs = 0;
|
||||
|
||||
void RegisterEmergencyShutdownCallback( void (*pFunc)() )
|
||||
{
|
||||
ASSERT( g_iNumEmergencyFuncs+1 < ARRAYSIZE(g_pEmergencyFunc) );
|
||||
ASSERT( g_iNumEmergencyFuncs+1 < ARRAYLEN(g_pEmergencyFunc) );
|
||||
g_pEmergencyFunc[ g_iNumEmergencyFuncs++ ] = pFunc;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace VDDebugInfo
|
||||
|
||||
pctx->sRawBlock = RString();
|
||||
pctx->pRVAHeap = NULL;
|
||||
GetVDIPath( pctx->sFilename, ARRAYSIZE(pctx->sFilename) );
|
||||
GetVDIPath( pctx->sFilename, ARRAYLEN(pctx->sFilename) );
|
||||
pctx->sError = RString();
|
||||
|
||||
HANDLE h = CreateFile( pctx->sFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
|
||||
|
||||
@@ -63,7 +63,7 @@ void DialogUtil::LocalizeDialogAndContents( HWND hdlg )
|
||||
RString sGroup;
|
||||
|
||||
{
|
||||
::GetWindowText( hdlg, szTemp, ARRAYSIZE(szTemp) );
|
||||
::GetWindowText( hdlg, szTemp, ARRAYLEN(szTemp) );
|
||||
RString s = szTemp;
|
||||
sGroup = "Dialog-"+s;
|
||||
s = THEME->GetString( sGroup, s );
|
||||
@@ -72,7 +72,7 @@ void DialogUtil::LocalizeDialogAndContents( HWND hdlg )
|
||||
|
||||
for( HWND hwndChild = ::GetTopWindow(hdlg); hwndChild != NULL; hwndChild = ::GetNextWindow(hwndChild,GW_HWNDNEXT) )
|
||||
{
|
||||
::GetWindowText( hwndChild, szTemp, ARRAYSIZE(szTemp) );
|
||||
::GetWindowText( hwndChild, szTemp, ARRAYLEN(szTemp) );
|
||||
RString s = szTemp;
|
||||
if( s.empty() )
|
||||
continue;
|
||||
|
||||
@@ -122,7 +122,7 @@ static Bignum rsa_privkey_op(Bignum input, const RSAKey *key)
|
||||
|
||||
SHA512_State ss;
|
||||
unsigned char digest512[64];
|
||||
unsigned digestused = ARRAYSIZE(digest512);
|
||||
unsigned digestused = ARRAYLEN(digest512);
|
||||
int hashseq = 0;
|
||||
|
||||
/*
|
||||
|
||||
@@ -344,7 +344,7 @@ bool RunTests( SoundReader *snd, const TestFile &tf )
|
||||
if( !Identical )
|
||||
{
|
||||
LOG->Trace("Expected data:");
|
||||
dump( tf.initial, ARRAYSIZE(tf.initial) );
|
||||
dump( tf.initial, ARRAYLEN(tf.initial) );
|
||||
LOG->Trace(" ");
|
||||
Failed = true;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ bool RunTests( SoundReader *snd, const TestFile &tf )
|
||||
if( !Identical )
|
||||
{
|
||||
LOG->Trace("Expected half second data:");
|
||||
dump( tf.later, ARRAYSIZE(tf.later) );
|
||||
dump( tf.later, ARRAYLEN(tf.later) );
|
||||
LOG->Trace("Got half second data:");
|
||||
dump( LaterData, 16 );
|
||||
Failed = true;
|
||||
|
||||
Reference in New Issue
Block a user