1. Instead of a million if-elses, homeboy could just make a table associating the numbers he's checking with the parameters to the two functions he repeatedly calls, and the whole thing could look like this:
Code:
static struct {
int BandaidsNeeded;
int CharacterUnlock;
int UnlockScreen;
} TableThing[] = {
{ 10, IMGC_G15M, UNLOCK_G15M },
{ 20, IMBC_8BITMEATBOY, UNLOCK_8BITMEATBOY },
{ 30, IMBC_NINJA, UNLOCK_NINJA },
etc
};
void GSMBChapterData::AwardBandageGet()
{
int iNumBandaids = 0;
for( etc )
{
iNumBandaids = whatever;
}
for( INT i = 0; i < countof( TableThing ); i++ )
{
if ( iNumBandaids == TableThing[i].BandaidsNeeded )
{
UnlockCharacter( TableThing[i].CharacterUnlock );
SMBHUD->AddUnlockScreen( TableThing[i].UnlockScreen );
break;
}
}
}
2. WHY DO U HATE SWITCH STATEMENTS AND/OR PEOPLE WHO READ YOUR CODE