Quickly variables! Into the magic mirror!

This commit is contained in:
Jason Felds
2011-03-14 03:32:07 -04:00
parent e9df4832f6
commit 81ccc7daba
22 changed files with 80 additions and 87 deletions
+2 -2
View File
@@ -80,11 +80,11 @@ void AutoKeysounds::LoadAutoplaySoundsInto( RageSoundReader_Chain *pChain )
bool bSoundIsGlobal = true;
{
PlayerNumber pn = GetNextEnabledPlayer((PlayerNumber)-1);
const TapNote &t = tn[pn];
const TapNote &tap = tn[pn];
pn = GetNextEnabledPlayer(pn);
while( pn != PLAYER_INVALID )
{
if( tn[pn].type != TapNote::autoKeysound || tn[pn].iKeysoundIndex != t.iKeysoundIndex )
if( tn[pn].type != TapNote::autoKeysound || tn[pn].iKeysoundIndex != tap.iKeysoundIndex )
bSoundIsGlobal = false;
pn = GetNextEnabledPlayer(pn);
}
+2
View File
@@ -250,9 +250,11 @@ void BeginnerHelper::DrawPrimitives()
m_sStepCircle[scd][scde].Draw();
if( DrawCelShaded )
{
FOREACH_PlayerNumber( pn ) // Draw each dancer
if( GAMESTATE->IsHumanPlayer(pn) )
m_pDancer[pn]->DrawCelShaded();
}
else
{
DISPLAY->SetLighting( true );
+2 -2
View File
@@ -930,8 +930,8 @@ const CourseEntry *Course::FindFixedSong( const Song *pSong ) const
FOREACH_CONST( CourseEntry, m_vEntries, e )
{
const CourseEntry &entry = *e;
Song *pSong = entry.songID.ToSong();
if( pSong == pSong )
Song *lSong = entry.songID.ToSong();
if( pSong == lSong )
return &entry;
}
+6 -6
View File
@@ -311,15 +311,15 @@ const glyph &Font::GetGlyph( wchar_t c ) const
bool Font::FontCompleteForString( const wstring &str ) const
{
map<wchar_t,glyph*>::const_iterator m_pDefault = m_iCharToGlyph.find( FONT_DEFAULT_GLYPH );
if( m_pDefault == m_iCharToGlyph.end() )
map<wchar_t,glyph*>::const_iterator mapDefault = m_iCharToGlyph.find( FONT_DEFAULT_GLYPH );
if( mapDefault == m_iCharToGlyph.end() )
RageException::Throw( "The default glyph is missing from the font \"%s\".", path.c_str() );
for( unsigned i = 0; i < str.size(); ++i )
{
// If the glyph for this character is the default glyph, we're incomplete.
const glyph &g = GetGlyph( str[i] );
if( &g == m_pDefault->second )
if( &g == mapDefault->second )
return false;
}
return true;
@@ -718,8 +718,8 @@ void Font::Load( const RString &sIniPath, RString sChars )
for(unsigned i = 0; i < ImportList.size(); ++i)
{
RString path = THEME->GetPathF( "", ImportList[i], true );
if( path == "" )
RString fPath = THEME->GetPathF( "", ImportList[i], true );
if( fPath == "" )
{
RString s = ssprintf( "Font \"%s\" imports a font \"%s\" that doesn't exist", sIniPath.c_str(), ImportList[i].c_str() );
Dialog::OK( s );
@@ -727,7 +727,7 @@ void Font::Load( const RString &sIniPath, RString sChars )
}
Font subfont;
subfont.Load(path,"");
subfont.Load(fPath,"");
MergeFont(subfont);
//FONT->UnloadFont(subfont);
}
+2 -2
View File
@@ -93,8 +93,8 @@ bool GameCommand::DescribesCurrentMode( PlayerNumber pn ) const
if( m_pSteps == NULL && m_dc != Difficulty_Invalid )
{
// Why is this checking for all players?
FOREACH_HumanPlayer( pn )
if( GAMESTATE->m_PreferredDifficulty[pn] != m_dc )
FOREACH_HumanPlayer( human )
if( GAMESTATE->m_PreferredDifficulty[human] != m_dc )
return false;
}
+2 -2
View File
@@ -2361,9 +2361,9 @@ public:
return 1;
}
static int GetCurrentStepsCredits( T* p, lua_State *L )
static int GetCurrentStepsCredits( T* t, lua_State *L )
{
const Song* pSong = p->m_pCurSong;
const Song* pSong = t->m_pCurSong;
if( pSong == NULL )
return 0;
+7 -7
View File
@@ -282,22 +282,22 @@ try_again:
const NoteSkinData &data = iter->second;
RString sPath; // fill this in below
FOREACH_CONST( RString, data.vsDirSearchOrder, iter )
FOREACH_CONST( RString, data.vsDirSearchOrder, lIter )
{
if( sButtonName.empty() )
sPath = GetPathFromDirAndFile( *iter, sElement );
sPath = GetPathFromDirAndFile( *lIter, sElement );
else
sPath = GetPathFromDirAndFile( *iter, sButtonName+" "+sElement );
sPath = GetPathFromDirAndFile( *lIter, sButtonName+" "+sElement );
if( !sPath.empty() )
break; // done searching
}
if( sPath.empty() )
{
FOREACH_CONST( RString, data.vsDirSearchOrder, iter )
FOREACH_CONST( RString, data.vsDirSearchOrder, lIter )
{
if( !sButtonName.empty() )
sPath = GetPathFromDirAndFile( *iter, "Fallback "+sElement );
sPath = GetPathFromDirAndFile( *lIter, "Fallback "+sElement );
if( !sPath.empty() )
break; // done searching
}
@@ -340,9 +340,9 @@ try_again:
GetFileContents( sPath, sNewFileName, true );
RString sRealPath;
FOREACH_CONST( RString, data.vsDirSearchOrder, iter )
FOREACH_CONST( RString, data.vsDirSearchOrder, lIter )
{
sRealPath = GetPathFromDirAndFile( *iter, sNewFileName );
sRealPath = GetPathFromDirAndFile( *lIter, sNewFileName );
if( !sRealPath.empty() )
break; // done searching
}
+7 -7
View File
@@ -149,15 +149,15 @@ public:
{
// Parse the basic configuration metric.
Commands cmds = ParseCommands( ENTRY(sParam) );
if( cmds.v.size() < 1 )
Commands lCmds = ParseCommands( ENTRY(sParam) );
if( lCmds.v.size() < 1 )
RageException::Throw( "Parse error in \"ScreenOptionsMaster::%s\".", sParam.c_str() );
m_Def.m_bOneChoiceForAllPlayers = false;
const int NumCols = atoi( cmds.v[0].m_vsArgs[0] );
for( unsigned i=1; i<cmds.v.size(); i++ )
const int NumCols = atoi( lCmds.v[0].m_vsArgs[0] );
for( unsigned i=1; i<lCmds.v.size(); i++ )
{
const Command &cmd = cmds.v[i];
const Command &cmd = lCmds.v[i];
RString sName = cmd.GetName();
if( sName == "together" ) m_Def.m_bOneChoiceForAllPlayers = true;
@@ -188,8 +188,8 @@ public:
}
else if( sName == "broadcastonexport" )
{
for( unsigned i=1; i<cmd.m_vsArgs.size(); i++ )
m_vsBroadcastOnExport.push_back( cmd.m_vsArgs[i] );
for( unsigned j=1; j<cmd.m_vsArgs.size(); j++ )
m_vsBroadcastOnExport.push_back( cmd.m_vsArgs[j] );
}
else
{
+2 -2
View File
@@ -138,8 +138,8 @@ void OptionListRow::SetUnderlines( const vector<bool> &aSelections, const Option
if( pTarget->m_Def.m_selectType == SELECT_ONE )
{
int iSelection = m_pOptions->GetOneSelection(sDest);
const OptionRowHandler *pHandler = m_pOptions->m_Rows.find(sDest)->second;
int iDefault = pHandler->GetDefaultOption();
const OptionRowHandler *lHandler = m_pOptions->m_Rows.find(sDest)->second;
int iDefault = lHandler->GetDefaultOption();
if( iDefault != -1 && iSelection != iDefault )
bSelected |= true;
}
+7 -7
View File
@@ -363,8 +363,8 @@ float Profile::GetSongsActual( StepsType st, Difficulty dc ) const
FOREACHM_CONST( StepsID, HighScoresForASteps, hsfas.m_StepsHighScores, j )
{
const StepsID &id = j->first;
Steps* pSteps = id.ToSteps( pSong, true );
const StepsID &sid = j->first;
Steps* pSteps = sid.ToSteps( pSong, true );
CHECKPOINT_M( ssprintf("Profile::GetSongsActual: song %p, steps %p", pSong, pSteps) );
// If the Steps isn't loaded on the current machine, then we can't
@@ -375,7 +375,7 @@ float Profile::GetSongsActual( StepsType st, Difficulty dc ) const
if( pSteps->m_StepsType != st )
continue;
CHECKPOINT_M( ssprintf("Profile::GetSongsActual: n %s = %p", id.ToString().c_str(), pSteps) );
CHECKPOINT_M( ssprintf("Profile::GetSongsActual: n %s = %p", sid.ToString().c_str(), pSteps) );
if( pSteps->GetDifficulty() != dc )
continue; // skip
CHECKPOINT;
@@ -1303,13 +1303,13 @@ void Profile::LoadGeneralDataFromNode( const XNode* pNode )
if( style->GetName() != "Style" )
continue;
StyleID s;
s.LoadFromNode( style );
StyleID sID;
sID.LoadFromNode( style );
if( !s.IsValid() )
if( !sID.IsValid() )
WARN_AND_CONTINUE;
style->GetTextValue( m_iNumSongsPlayedByStyle[s] );
style->GetTextValue( m_iNumSongsPlayedByStyle[sID] );
}
}
}
+3 -3
View File
@@ -489,10 +489,10 @@ bool ProfileManager::DeleteLocalProfile( RString sProfileID )
g_vLocalProfile.erase( i );
// Delete all references to this profileID
FOREACH_CONST( Preference<RString>*, m_sDefaultLocalProfileID.m_v, i )
FOREACH_CONST( Preference<RString>*, m_sDefaultLocalProfileID.m_v, j )
{
if( (*i)->Get() == sProfileID )
(*i)->Set( "" );
if( (*j)->Get() == sProfileID )
(*j)->Set( "" );
}
return true;
}
+3 -3
View File
@@ -245,14 +245,14 @@ int RageFileObjDeflate::WriteInternal( const void *pBuffer, size_t iBytes )
if( m_pDeflate->avail_out < sizeof(buf) )
{
int iBytes = sizeof(buf)-m_pDeflate->avail_out;
int iRet = m_pFile->Write( buf, iBytes );
int lBytes = sizeof(buf)-m_pDeflate->avail_out;
int iRet = m_pFile->Write( buf, lBytes );
if( iRet == -1 )
{
SetError( m_pFile->GetError() );
return -1;
}
if( iRet < iBytes )
if( iRet < lBytes )
{
SetError( "Partial write" );
return -1;
-3
View File
@@ -33,7 +33,6 @@ RageSoundReader_Chain::~RageSoundReader_Chain()
while( !m_apActiveSounds.empty() )
ReleaseSound( m_apActiveSounds.front() );
map<RString, RageSoundReader *>::iterator it;
FOREACH( RageSoundReader *, m_apLoadedSounds, it )
delete *it;
}
@@ -103,7 +102,6 @@ int RageSoundReader_Chain::GetSampleRateInternal() const
if( m_apLoadedSounds.empty() )
return m_iPreferredSampleRate;
map<RString, RageSoundReader *>::const_iterator it;
int iRate = -1;
FOREACH_CONST( RageSoundReader *, m_apLoadedSounds, it )
{
@@ -120,7 +118,6 @@ void RageSoundReader_Chain::Finish()
/* Figure out how many channels we have. All sounds must either have 1 or 2 channels,
* which will be converted as needed, or have the same number of channels. */
m_iChannels = 1;
map<RString, RageSoundReader *>::iterator it;
FOREACH( RageSoundReader *, m_apLoadedSounds, it )
m_iChannels = max( m_iChannels, (*it)->GetNumChannels() );
+1 -1
View File
@@ -426,7 +426,7 @@ int RageSoundReader_MP3::do_mad_frame_decode( bool headers_only )
return -1;
}
int ret = fill_buffer();
ret = fill_buffer();
if( ret <= 0 )
return ret;
bytes_read += ret;
-1
View File
@@ -18,7 +18,6 @@ RageSoundReader_Merge::RageSoundReader_Merge()
RageSoundReader_Merge::~RageSoundReader_Merge()
{
map<RString, RageSoundReader *>::iterator it;
FOREACH( RageSoundReader *, m_aSounds, it )
delete *it;
}
+2 -2
View File
@@ -585,8 +585,8 @@ static bool blit_rgba_to_rgba( const RageSurface *src_surf, const RageSurface *d
unsigned int opixel = 0;
for( int c = 0; c < 4; ++c )
{
int src = (pixel & src_masks[c]) >> src_shifts[c];
opixel |= lookup[c][src] << dst_shifts[c];
int lSrc = (pixel & src_masks[c]) >> src_shifts[c];
opixel |= lookup[c][lSrc] << dst_shifts[c];
}
// Store it.
+6 -6
View File
@@ -454,7 +454,7 @@ static acolorhist_item *mediancut( acolorhist_item *achv, int colors, int sum, i
#ifdef REP_AVERAGE_PIXELS
int indx = bv[bi].ind;
int clrs = bv[bi].colors;
long r = 0, g = 0, b = 0, a = 0, sum = 0;
long r = 0, g = 0, b = 0, a = 0, lSum = 0;
for ( int i = 0; i < clrs; ++i )
{
@@ -462,15 +462,15 @@ static acolorhist_item *mediancut( acolorhist_item *achv, int colors, int sum, i
g += PAM_GETG( achv[indx + i].acolor ) * achv[indx + i].value;
b += PAM_GETB( achv[indx + i].acolor ) * achv[indx + i].value;
a += PAM_GETA( achv[indx + i].acolor ) * achv[indx + i].value;
sum += achv[indx + i].value;
lSum += achv[indx + i].value;
}
r = r / sum;
r = r / lSum;
r = min( r, (long) maxval );
g = g / sum;
g = g / lSum;
g = min( g, (long) maxval );
b = b / sum;
b = b / lSum;
b = min( b, (long) maxval );
a = a / sum;
a = a / lSum;
a = min( a, (long) maxval );
PAM_ASSIGN( acolormap[bi].acolor, (uint8_t)r, (uint8_t)g, (uint8_t)b, (uint8_t)a );
#endif // REP_AVERAGE_PIXELS
+19 -19
View File
@@ -273,30 +273,30 @@ void ScreenDebugOverlay::Init()
FOREACH_CONST( IDebugLine*, *g_pvpSubscribers, p )
{
{
BitmapText *p = new BitmapText;
p->SetName( "ButtonText" );
p->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") );
p->SetHorizAlign( align_right );
p->SetText( "blah" );
BitmapText *bt = new BitmapText;
bt->SetName( "ButtonText" );
bt->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") );
bt->SetHorizAlign( align_right );
bt->SetText( "blah" );
//p->SetShadowLength( 2 );
LOAD_ALL_COMMANDS( *p );
LOAD_ALL_COMMANDS( *bt );
// xxx: I shouldn't have to do this:
ON_COMMAND( p );
m_vptextButton.push_back( p );
this->AddChild( p );
ON_COMMAND( bt );
m_vptextButton.push_back( bt );
this->AddChild( bt );
}
{
BitmapText *p = new BitmapText;
p->SetName( "FunctionText" );
p->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") );
p->SetHorizAlign( align_left );
p->SetText( "blah" );
BitmapText *bt = new BitmapText;
bt->SetName( "FunctionText" );
bt->LoadFromFont( THEME->GetPathF("ScreenDebugOverlay", "line") );
bt->SetHorizAlign( align_left );
bt->SetText( "blah" );
//p->SetShadowLength( 2 );
LOAD_ALL_COMMANDS( *p );
LOAD_ALL_COMMANDS( *bt );
// xxx: I shouldn't have to do this:
ON_COMMAND( p );
m_vptextFunction.push_back( p );
this->AddChild( p );
ON_COMMAND( bt );
m_vptextFunction.push_back( bt );
this->AddChild( bt );
}
}
@@ -498,7 +498,7 @@ bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input )
bt.FinishTweening();
// blink 5 times instead of 8
// TODO: make this all metrics instead -aj
for( int i=0; i<5; i++ )
for( i=0; i<5; i++ )
{
bt.SetGlow( RageColor(1,0,0,1) );
bt.Sleep(0.1f);
-4
View File
@@ -1270,8 +1270,6 @@ void ScreenGameplay::LoadLights()
{
if( asDifficulties[0].CompareNoCase("selected") == 0 )
{
PlayerInfo pi;
// Base lights off current difficulty of active player
// Can be either P1 or P2 if they're individual or P1 if both are active
FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi )
@@ -1305,8 +1303,6 @@ void ScreenGameplay::LoadLights()
// We've also specified for Player 2 to be based off current difficulty
if( asDifficulties[1].CompareNoCase("selected") == 0 && GAMESTATE->GetNumPlayersEnabled() > 1 )
{
PlayerInfo pi;
// Base lights off current difficulty of active player
// Only do this for P2 in a two-player situation, since P1 is taken care of above
FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi )
+5 -5
View File
@@ -236,15 +236,15 @@ void ColorBitmapText::SetText( const RString& _sText, const RString& _sAlternate
RString FirstThree = m_sText.substr( i, 3 );
if( FirstThree.CompareNoCase("|c0") == 0 && iCharsLeft > 8 )
{
ColorChange change;
ColorChange cChange;
unsigned int r, g, b;
sscanf( m_sText.substr( i, 9 ).c_str(), "|%*c0%2x%2x%2x", &r, &g, &b );
change.c = RageColor( r/255.f, g/255.f, b/255.f, 1.f );
change.l = iGlyphsSoFar;
cChange.c = RageColor( r/255.f, g/255.f, b/255.f, 1.f );
cChange.l = iGlyphsSoFar;
if( iGlyphsSoFar == 0 )
m_vColors[0] = change;
m_vColors[0] = cChange;
else
m_vColors.push_back( change );
m_vColors.push_back( cChange );
i+=8;
continue;
}
-1
View File
@@ -38,7 +38,6 @@ class InputList: public BitmapText
// Update input texts
vector<RString> asInputs;
DeviceInput di;
vector<DeviceInput> DeviceInputs;
INPUTFILTER->GetPressedButtons( DeviceInputs );
FOREACH( DeviceInput, DeviceInputs, di )
+2 -2
View File
@@ -396,11 +396,11 @@ public:
return 1;
}
static int GetBestFinalGrade( T* p, lua_State *L )
static int GetBestFinalGrade( T* t, lua_State *L )
{
Grade top_grade = Grade_Failed;
StageStats stats;
p->GetFinalEvalStageStats( stats );
t->GetFinalEvalStageStats( stats );
FOREACH_HumanPlayer( p )
{
// If this player failed any stage, then their final grade is an F.