replace ASSERT(0) with useful fail messages

This commit is contained in:
Devin J. Pohly
2012-12-27 16:59:35 -05:00
parent 376056a0cf
commit bd0e2074ad
71 changed files with 289 additions and 245 deletions
+5 -8
View File
@@ -442,7 +442,7 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties
} }
break; break;
default: default:
ASSERT(0); // invalid Effect FAIL_M(ssprintf("Invalid effect: %i", m_Effect));
} }
} }
@@ -856,13 +856,10 @@ void Actor::SetEffectClockString( const RString &s )
else else
{ {
CabinetLight cl = StringToCabinetLight( s ); CabinetLight cl = StringToCabinetLight( s );
if( cl != CabinetLight_Invalid ) if( cl == CabinetLight_Invalid )
{ FAIL_M(ssprintf("Invalid cabinet light: %s", s.c_str()));
this->SetEffectClock( (EffectClock) (cl + CLOCK_LIGHT_1) );
return; this->SetEffectClock( (EffectClock) (cl + CLOCK_LIGHT_1) );
}
else
ASSERT(0);
} }
} }
+2 -8
View File
@@ -186,10 +186,7 @@ void ActorFrame::MoveToTail( Actor* pActor )
{ {
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor ); vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
if( iter == m_SubActors.end() ) // didn't find if( iter == m_SubActors.end() ) // didn't find
{ FAIL_M("Nonexistent actor");
ASSERT(0); // called with a pActor that doesn't exist
return;
}
m_SubActors.erase( iter ); m_SubActors.erase( iter );
m_SubActors.push_back( pActor ); m_SubActors.push_back( pActor );
@@ -199,10 +196,7 @@ void ActorFrame::MoveToHead( Actor* pActor )
{ {
vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor ); vector<Actor*>::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor );
if( iter == m_SubActors.end() ) // didn't find if( iter == m_SubActors.end() ) // didn't find
{ FAIL_M("Nonexistent actor");
ASSERT(0); // called with a pActor that doesn't exist
return;
}
m_SubActors.erase( iter ); m_SubActors.erase( iter );
m_SubActors.insert( m_SubActors.begin(), pActor ); m_SubActors.insert( m_SubActors.begin(), pActor );
+2 -2
View File
@@ -59,7 +59,7 @@ retry:
case Dialog::ignore: case Dialog::ignore:
return false; return false;
default: default:
ASSERT(0); FAIL_M("Invalid response to Abort/Retry/Ignore dialog");
} }
} }
@@ -81,7 +81,7 @@ retry:
asPaths.erase( asPaths.begin()+1, asPaths.end() ); asPaths.erase( asPaths.begin()+1, asPaths.end() );
break; break;
default: default:
ASSERT(0); FAIL_M("Invalid response to Abort/Retry/Ignore dialog");
} }
} }
+8 -6
View File
@@ -148,7 +148,8 @@ void AdjustSync::HandleAutosync( float fNoteOffBySeconds, float fStepTime )
{ {
if( GAMESTATE->IsCourseMode() ) if( GAMESTATE->IsCourseMode() )
return; return;
switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType ) { SongOptions::AutosyncType type = GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType;
switch( type ) {
case SongOptions::AUTOSYNC_OFF: case SongOptions::AUTOSYNC_OFF:
return; return;
case SongOptions::AUTOSYNC_TEMPO: case SongOptions::AUTOSYNC_TEMPO:
@@ -170,7 +171,7 @@ void AdjustSync::HandleAutosync( float fNoteOffBySeconds, float fStepTime )
break; break;
} }
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid autosync type: %i", type));
} }
} }
@@ -192,7 +193,8 @@ void AdjustSync::AutosyncOffset()
const float stddev = calc_stddev( s_fAutosyncOffset, s_fAutosyncOffset+OFFSET_SAMPLE_COUNT ); const float stddev = calc_stddev( s_fAutosyncOffset, s_fAutosyncOffset+OFFSET_SAMPLE_COUNT );
RString sAutosyncType; RString sAutosyncType;
switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType ) SongOptions::AutosyncType type = GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType;
switch( type )
{ {
case SongOptions::AUTOSYNC_SONG: case SongOptions::AUTOSYNC_SONG:
sAutosyncType = AUTOSYNC_SONG; sAutosyncType = AUTOSYNC_SONG;
@@ -201,12 +203,12 @@ void AdjustSync::AutosyncOffset()
sAutosyncType = AUTOSYNC_MACHINE; sAutosyncType = AUTOSYNC_MACHINE;
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid autosync type: %i", type));
} }
if( stddev < .03f ) // If they stepped with less than .03 error if( stddev < .03f ) // If they stepped with less than .03 error
{ {
switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType ) switch( type )
{ {
case SongOptions::AUTOSYNC_SONG: case SongOptions::AUTOSYNC_SONG:
{ {
@@ -223,7 +225,7 @@ void AdjustSync::AutosyncOffset()
PREFSMAN->m_fGlobalOffsetSeconds.Set( PREFSMAN->m_fGlobalOffsetSeconds + mean ); PREFSMAN->m_fGlobalOffsetSeconds.Set( PREFSMAN->m_fGlobalOffsetSeconds + mean );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid autosync type: %i", type));
} }
SCREENMAN->SystemMessage( AUTOSYNC_CORRECTION_APPLIED.GetValue() ); SCREENMAN->SystemMessage( AUTOSYNC_CORRECTION_APPLIED.GetValue() );
+5 -5
View File
@@ -272,7 +272,7 @@ void BGAnimationLayer::LoadFromAniLayerFile( const RString& sPath )
m_vParticleVelocity[i].y *= PARTICLE_SPEED; m_vParticleVelocity[i].y *= PARTICLE_SPEED;
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Unrecognized layer effect: %i", effect));
} }
} }
} }
@@ -334,14 +334,14 @@ void BGAnimationLayer::LoadFromAniLayerFile( const RString& sPath )
pSprite->SetEffectPulse( 1, 0.3f, 1.f ); pSprite->SetEffectPulse( 1, 0.3f, 1.f );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Not a tile effect: %i", effect));
} }
} }
} }
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Unrecognized layer effect: %i", effect));
} }
@@ -527,7 +527,7 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode )
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Unrecognized layer type: %i", m_Type));
} }
bool bStartOnRandomFrame = false; bool bStartOnRandomFrame = false;
@@ -641,7 +641,7 @@ void BGAnimationLayer::UpdateInternal( float fDeltaTime )
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Unrecognized layer type: %i", m_Type));
} }
} }
+1 -1
View File
@@ -195,7 +195,7 @@ void BPMDisplay::SetBpmFromSong( const Song* pSong )
CycleRandomly(); CycleRandomly();
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid display BPM type: %i", pSong->m_DisplayBPMType));
} }
} }
+10 -5
View File
@@ -13,7 +13,8 @@ static void TugMeterPercentChangeInit( size_t /*ScoreEvent*/ i, RString &sNameOu
sNameOut = "TugMeterPercentChange" + ScoreEventToString( (ScoreEvent)i ); sNameOut = "TugMeterPercentChange" + ScoreEventToString( (ScoreEvent)i );
switch( i ) switch( i )
{ {
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid ScoreEvent: %i", i));
case SE_W1: defaultValueOut = +0.010f; break; case SE_W1: defaultValueOut = +0.010f; break;
case SE_W2: defaultValueOut = +0.008f; break; case SE_W2: defaultValueOut = +0.008f; break;
case SE_W3: defaultValueOut = +0.004f; break; case SE_W3: defaultValueOut = +0.004f; break;
@@ -77,7 +78,8 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, TapNoteScore score )
case TNS_HitMine: fPercentToMove = g_fTugMeterPercentChange[SE_HitMine]; break; case TNS_HitMine: fPercentToMove = g_fTugMeterPercentChange[SE_HitMine]; break;
case TNS_CheckpointHit: fPercentToMove = g_fTugMeterPercentChange[SE_CheckpointHit]; break; case TNS_CheckpointHit: fPercentToMove = g_fTugMeterPercentChange[SE_CheckpointHit]; break;
case TNS_CheckpointMiss:fPercentToMove = g_fTugMeterPercentChange[SE_CheckpointMiss]; break; case TNS_CheckpointMiss:fPercentToMove = g_fTugMeterPercentChange[SE_CheckpointMiss]; break;
default: ASSERT(0); break; default:
FAIL_M(ssprintf("Invalid TapNotScore: %i", score));
} }
ChangeLife( pn, fPercentToMove ); ChangeLife( pn, fPercentToMove );
@@ -95,7 +97,8 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, HoldNoteScore score, Tap
{ {
case HNS_Held: fPercentToMove = g_fTugMeterPercentChange[SE_Held]; break; case HNS_Held: fPercentToMove = g_fTugMeterPercentChange[SE_Held]; break;
case HNS_LetGo: fPercentToMove = g_fTugMeterPercentChange[SE_LetGo]; break; case HNS_LetGo: fPercentToMove = g_fTugMeterPercentChange[SE_LetGo]; break;
default: ASSERT(0); break; default:
FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
} }
ChangeLife( pn, fPercentToMove ); ChangeLife( pn, fPercentToMove );
@@ -110,7 +113,8 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, float fPercentToMove )
{ {
case PLAYER_1: fLifePercentage = GAMESTATE->m_fTugLifePercentP1; break; case PLAYER_1: fLifePercentage = GAMESTATE->m_fTugLifePercentP1; break;
case PLAYER_2: fLifePercentage = 1 - GAMESTATE->m_fTugLifePercentP1; break; case PLAYER_2: fLifePercentage = 1 - GAMESTATE->m_fTugLifePercentP1; break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid player number: %i", pn));
} }
/* Clamp the life meter only for calculating the multiplier. */ /* Clamp the life meter only for calculating the multiplier. */
@@ -122,7 +126,8 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, float fPercentToMove )
{ {
case PLAYER_1: GAMESTATE->m_fTugLifePercentP1 += fPercentToMove; break; case PLAYER_1: GAMESTATE->m_fTugLifePercentP1 += fPercentToMove; break;
case PLAYER_2: GAMESTATE->m_fTugLifePercentP1 -= fPercentToMove; break; case PLAYER_2: GAMESTATE->m_fTugLifePercentP1 -= fPercentToMove; break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid player number: %i", pn));
} }
} }
+6 -3
View File
@@ -123,7 +123,8 @@ void Course::SetCourseType( CourseType ct )
switch( ct ) switch( ct )
{ {
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid course type: %i", ct));
case COURSE_TYPE_NONSTOP: case COURSE_TYPE_NONSTOP:
break; break;
case COURSE_TYPE_ONI: case COURSE_TYPE_ONI:
@@ -141,13 +142,15 @@ void Course::SetCourseType( CourseType ct )
PlayMode Course::GetPlayMode() const PlayMode Course::GetPlayMode() const
{ {
switch( GetCourseType() ) CourseType ct = GetCourseType();
switch( ct )
{ {
case COURSE_TYPE_ENDLESS: return PLAY_MODE_ENDLESS; case COURSE_TYPE_ENDLESS: return PLAY_MODE_ENDLESS;
case COURSE_TYPE_ONI: return PLAY_MODE_ONI; case COURSE_TYPE_ONI: return PLAY_MODE_ONI;
case COURSE_TYPE_SURVIVAL: return PLAY_MODE_ONI; case COURSE_TYPE_SURVIVAL: return PLAY_MODE_ONI;
case COURSE_TYPE_NONSTOP: return PLAY_MODE_NONSTOP; case COURSE_TYPE_NONSTOP: return PLAY_MODE_NONSTOP;
default: ASSERT(0); return PlayMode_Invalid; default:
FAIL_M(ssprintf("Invalid course type: %i", ct));
} }
} }
+1 -1
View File
@@ -168,7 +168,7 @@ void StepsDisplayList::UpdatePositions()
else if( second_end < (int) Rows.size() ) else if( second_end < (int) Rows.size() )
second_end++; second_end++;
else else
ASSERT(0); // do we have room to grow or don't we? FAIL_M("Do we have room to grow, or don't we?");
} }
int pos = 0; int pos = 0;
+14 -10
View File
@@ -52,7 +52,8 @@ void EditMenu::StripLockedStepsAndDifficulty( vector<StepsAndDifficulty> &v )
void EditMenu::GetSongsToShowForGroup( const RString &sGroup, vector<Song*> &vpSongsOut ) void EditMenu::GetSongsToShowForGroup( const RString &sGroup, vector<Song*> &vpSongsOut )
{ {
vpSongsOut = SONGMAN->GetSongs( SHOW_GROUPS.GetValue()? sGroup:GROUP_ALL ); vpSongsOut = SONGMAN->GetSongs( SHOW_GROUPS.GetValue()? sGroup:GROUP_ALL );
switch( EDIT_MODE.GetValue() ) EditMode mode = EDIT_MODE.GetValue();
switch( mode )
{ {
case EditMode_Practice: case EditMode_Practice:
case EditMode_CourseMods: case EditMode_CourseMods:
@@ -67,7 +68,7 @@ void EditMenu::GetSongsToShowForGroup( const RString &sGroup, vector<Song*> &vpS
case EditMode_Full: case EditMode_Full:
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid edit mode: %i", mode));
} }
SongUtil::SortSongPointerArrayByTitle( vpSongsOut ); SongUtil::SortSongPointerArrayByTitle( vpSongsOut );
} }
@@ -391,7 +392,8 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
{ {
if( dc == Difficulty_Edit ) if( dc == Difficulty_Edit )
{ {
switch( EDIT_MODE.GetValue() ) EditMode mode = EDIT_MODE.GetValue();
switch( mode )
{ {
case EditMode_Full: case EditMode_Full:
case EditMode_CourseMods: case EditMode_CourseMods:
@@ -408,10 +410,10 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
// have only "New Edit" // have only "New Edit"
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid edit mode: %i", mode));
} }
switch( EDIT_MODE.GetValue() ) switch( mode )
{ {
case EditMode_Practice: case EditMode_Practice:
case EditMode_CourseMods: case EditMode_CourseMods:
@@ -421,7 +423,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
m_vpSteps.push_back( StepsAndDifficulty(NULL,dc) ); // "New Edit" m_vpSteps.push_back( StepsAndDifficulty(NULL,dc) ); // "New Edit"
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid edit mode: %i", mode));
} }
} }
else else
@@ -430,6 +432,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
if( pSteps && UNLOCKMAN->StepsIsLocked( GetSelectedSong(), pSteps ) ) if( pSteps && UNLOCKMAN->StepsIsLocked( GetSelectedSong(), pSteps ) )
pSteps = NULL; pSteps = NULL;
EditMode mode = EDIT_MODE.GetValue();
switch( EDIT_MODE.GetValue() ) switch( EDIT_MODE.GetValue() )
{ {
case EditMode_Home: case EditMode_Home:
@@ -446,7 +449,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
m_vpSteps.push_back( StepsAndDifficulty(pSteps,dc) ); m_vpSteps.push_back( StepsAndDifficulty(pSteps,dc) );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid edit mode: %i", mode));
} }
} }
} }
@@ -532,7 +535,8 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
m_Actions.clear(); m_Actions.clear();
if( GetSelectedSteps() ) if( GetSelectedSteps() )
{ {
switch( EDIT_MODE.GetValue() ) EditMode mode = EDIT_MODE.GetValue();
switch( mode )
{ {
case EditMode_Practice: case EditMode_Practice:
case EditMode_CourseMods: case EditMode_CourseMods:
@@ -544,7 +548,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
m_Actions.push_back( EditMenuAction_Delete ); m_Actions.push_back( EditMenuAction_Delete );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid edit mode: %i", mode));
} }
} }
else else
@@ -558,7 +562,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
m_textValue[ROW_ACTION].SetText( EditMenuActionToLocalizedString(GetSelectedAction()) ); m_textValue[ROW_ACTION].SetText( EditMenuActionToLocalizedString(GetSelectedAction()) );
break; break;
default: default:
ASSERT(0); // invalid row FAIL_M(ssprintf("Invalid EditMenuRow: %i", row));
} }
} }
+1 -1
View File
@@ -690,7 +690,7 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid StyleType: %i", m_pStyle->m_StyleType));
} }
} }
if( m_dc != Difficulty_Invalid ) if( m_dc != Difficulty_Invalid )
+2 -4
View File
@@ -2966,8 +2966,7 @@ const Style* GameManager::GetHowToPlayStyleForGame( const Game *pGame )
return style; return style;
} }
ASSERT(0); // this Game is missing a Style that can be used with HowToPlay FAIL_M(ssprintf("Game has no Style that can be used with HowToPlay: %s", pGame->m_szName));
return NULL;
} }
void GameManager::GetCompatibleStyles( const Game *pGame, int iNumPlayers, vector<const Style*> &vpStylesOut ) void GameManager::GetCompatibleStyles( const Game *pGame, int iNumPlayers, vector<const Style*> &vpStylesOut )
@@ -3052,8 +3051,7 @@ int GameManager::GetIndexFromGame( const Game* pGame )
if( g_Games[g] == pGame ) if( g_Games[g] == pGame )
return g; return g;
} }
ASSERT(0); FAIL_M(ssprintf("Game not found: %s", pGame->m_szName));
return 0;
} }
const Game* GameManager::GetGameFromIndex( int index ) const Game* GameManager::GetGameFromIndex( int index )
+9 -9
View File
@@ -1218,7 +1218,8 @@ bool GameState::IsHumanPlayer( PlayerNumber pn ) const
return true; // if we can't join, then we're on a screen like MusicScroll or GameOver return true; // if we can't join, then we're on a screen like MusicScroll or GameOver
} }
switch( GetCurrentStyle()->m_StyleType ) StyleType type = GetCurrentStyle()->m_StyleType;
switch( type )
{ {
case StyleType_TwoPlayersTwoSides: case StyleType_TwoPlayersTwoSides:
case StyleType_TwoPlayersSharedSides: case StyleType_TwoPlayersSharedSides:
@@ -1227,8 +1228,7 @@ bool GameState::IsHumanPlayer( PlayerNumber pn ) const
case StyleType_OnePlayerTwoSides: case StyleType_OnePlayerTwoSides:
return pn == this->GetMasterPlayerNumber(); return pn == this->GetMasterPlayerNumber();
default: default:
ASSERT(0); // invalid style type FAIL_M(ssprintf("Invalid style type: %i", type));
return false;
} }
} }
@@ -1544,15 +1544,15 @@ PlayerOptions::FailType GameState::GetPlayerFailType( const PlayerState *pPlayer
bool GameState::ShowW1() const bool GameState::ShowW1() const
{ {
switch( PREFSMAN->m_AllowW1 ) AllowW1 pref = PREFSMAN->m_AllowW1;
switch( pref )
{ {
case ALLOW_W1_NEVER: return false; case ALLOW_W1_NEVER: return false;
case ALLOW_W1_COURSES_ONLY: return IsCourseMode(); case ALLOW_W1_COURSES_ONLY: return IsCourseMode();
case ALLOW_W1_EVERYWHERE: return true; case ALLOW_W1_EVERYWHERE: return true;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid AllowW1 preference: %i", pref));
} }
// it should never hit here.
return false;
} }
@@ -1788,7 +1788,7 @@ void GameState::GetRankingFeats( PlayerNumber pn, vector<RankingFeat> &asFeatsOu
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid play mode: %i", m_PlayMode));
} }
} }
@@ -2088,7 +2088,7 @@ float GameState::GetGoalPercentComplete( PlayerNumber pn )
case GoalType_None: case GoalType_None:
return 0; // never complete return 0; // never complete
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid GoalType: %i", pProfile->m_GoalType));
} }
if( fGoal == 0 ) if( fGoal == 0 )
return 0; return 0;
+2 -3
View File
@@ -54,8 +54,6 @@ void HoldJudgment::SetHoldJudgment( HoldNoteScore hns )
switch( hns ) switch( hns )
{ {
case HNS_None:
ASSERT(0);
case HNS_Held: case HNS_Held:
m_sprJudgment->SetState( 0 ); m_sprJudgment->SetState( 0 );
m_sprJudgment->PlayCommand( "Held" ); m_sprJudgment->PlayCommand( "Held" );
@@ -64,8 +62,9 @@ void HoldJudgment::SetHoldJudgment( HoldNoteScore hns )
m_sprJudgment->SetState( 1 ); m_sprJudgment->SetState( 1 );
m_sprJudgment->PlayCommand( "LetGo" ); m_sprJudgment->PlayCommand( "LetGo" );
break; break;
case HNS_None:
default: default:
ASSERT(0); FAIL_M(ssprintf("Cannot set hold judgment to %i", hns));
} }
} }
+3 -2
View File
@@ -46,12 +46,13 @@ void ReloadItems()
Inventory::Inventory() Inventory::Inventory()
{ {
switch( GAMESTATE->m_PlayMode ) PlayMode mode = GAMESTATE->m_PlayMode;
switch( mode )
{ {
case PLAY_MODE_BATTLE: case PLAY_MODE_BATTLE:
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Inventory not valid for PlayMode %i", mode));
} }
} }
+1 -1
View File
@@ -12,7 +12,7 @@ LifeMeter *LifeMeter::MakeLifeMeter( SongOptions::LifeType t )
case SongOptions::LIFE_BATTERY: return new LifeMeterBattery; case SongOptions::LIFE_BATTERY: return new LifeMeterBattery;
case SongOptions::LIFE_TIME: return new LifeMeterTime; case SongOptions::LIFE_TIME: return new LifeMeterTime;
default: default:
ASSERT(0); FAIL_M(ssprintf("Unrecognized LifeMeter type: %i", t));
} }
} }
+10 -7
View File
@@ -31,7 +31,8 @@ LifeMeterBar::LifeMeterBar()
m_pPlayerState = NULL; m_pPlayerState = NULL;
switch( GAMESTATE->m_SongOptions.GetStage().m_DrainType ) SongOptions::DrainType dtype = GAMESTATE->m_SongOptions.GetStage().m_DrainType;
switch( dtype )
{ {
case SongOptions::DRAIN_NORMAL: case SongOptions::DRAIN_NORMAL:
m_fLifePercentage = INITIAL_VALUE; m_fLifePercentage = INITIAL_VALUE;
@@ -41,7 +42,8 @@ LifeMeterBar::LifeMeterBar()
case SongOptions::DRAIN_NO_RECOVER: case SongOptions::DRAIN_NO_RECOVER:
case SongOptions::DRAIN_SUDDEN_DEATH: case SongOptions::DRAIN_SUDDEN_DEATH:
m_fLifePercentage = 1.0f; break; m_fLifePercentage = 1.0f; break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid DrainType: %i", dtype));
} }
const RString sType = "LifeMeterBar"; const RString sType = "LifeMeterBar";
@@ -149,7 +151,8 @@ void LifeMeterBar::ChangeLife( TapNoteScore score )
void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore ) void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
{ {
float fDeltaLife=0.f; float fDeltaLife=0.f;
switch( GAMESTATE->m_SongOptions.GetSong().m_DrainType ) SongOptions::DrainType dtype = GAMESTATE->m_SongOptions.GetSong().m_DrainType;
switch( dtype )
{ {
case SongOptions::DRAIN_NORMAL: case SongOptions::DRAIN_NORMAL:
switch( score ) switch( score )
@@ -157,7 +160,7 @@ void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
case HNS_Held: fDeltaLife = m_fLifePercentChange.GetValue(SE_Held); break; case HNS_Held: fDeltaLife = m_fLifePercentChange.GetValue(SE_Held); break;
case HNS_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break; case HNS_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
} }
if( IsHot() && score == HNS_LetGo ) if( IsHot() && score == HNS_LetGo )
fDeltaLife = -0.10f; // make it take a while to get back to "hot" fDeltaLife = -0.10f; // make it take a while to get back to "hot"
@@ -168,7 +171,7 @@ void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
case HNS_Held: fDeltaLife = +0.000f; break; case HNS_Held: fDeltaLife = +0.000f; break;
case HNS_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break; case HNS_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
} }
break; break;
case SongOptions::DRAIN_SUDDEN_DEATH: case SongOptions::DRAIN_SUDDEN_DEATH:
@@ -177,11 +180,11 @@ void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore )
case HNS_Held: fDeltaLife = +0; break; case HNS_Held: fDeltaLife = +0; break;
case HNS_LetGo: fDeltaLife = -1.0f; break; case HNS_LetGo: fDeltaLife = -1.0f; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score));
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid DrainType: %i", dtype));
} }
ChangeLife( fDeltaLife ); ChangeLife( fDeltaLife );
+4 -2
View File
@@ -109,7 +109,8 @@ void LifeMeterTime::ChangeLife( TapNoteScore tns )
float fMeterChange = 0; float fMeterChange = 0;
switch( tns ) switch( tns )
{ {
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid TapNoteScore: %i", tns));
case TNS_W1: fMeterChange = g_fTimeMeterSecondsChange[SE_W1]; break; case TNS_W1: fMeterChange = g_fTimeMeterSecondsChange[SE_W1]; break;
case TNS_W2: fMeterChange = g_fTimeMeterSecondsChange[SE_W2]; break; case TNS_W2: fMeterChange = g_fTimeMeterSecondsChange[SE_W2]; break;
case TNS_W3: fMeterChange = g_fTimeMeterSecondsChange[SE_W3]; break; case TNS_W3: fMeterChange = g_fTimeMeterSecondsChange[SE_W3]; break;
@@ -134,7 +135,8 @@ void LifeMeterTime::ChangeLife( HoldNoteScore hns, TapNoteScore tns )
float fMeterChange = 0; float fMeterChange = 0;
switch( hns ) switch( hns )
{ {
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid HoldNoteScore: %i", hns));
case HNS_Held: fMeterChange = g_fTimeMeterSecondsChange[SE_Held]; break; case HNS_Held: fMeterChange = g_fTimeMeterSecondsChange[SE_Held]; break;
case HNS_LetGo: fMeterChange = g_fTimeMeterSecondsChange[SE_LetGo]; break; case HNS_LetGo: fMeterChange = g_fTimeMeterSecondsChange[SE_LetGo]; break;
} }
+1 -1
View File
@@ -71,7 +71,7 @@ void ModelManager::UnloadModel( RageModelGeometry *m )
} }
} }
ASSERT(0); // we tried to delete a texture that wasn't loaded. FAIL_M("Tried to delete a texture that wasn't loaded");
} }
bool ModelManager::SetPrefs( const ModelManagerPrefs& prefs ) bool ModelManager::SetPrefs( const ModelManagerPrefs& prefs )
+3 -3
View File
@@ -762,7 +762,8 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
FOREACH_ENUM( CourseType, i ) FOREACH_ENUM( CourseType, i )
vct.push_back( i ); vct.push_back( i );
break; break;
default: ASSERT(0); break; default:
FAIL_M(ssprintf("Wrong sort order: %i", so));
} }
vector<Course*> apCourses; vector<Course*> apCourses;
@@ -1139,8 +1140,7 @@ void MusicWheel::UpdateSwitch()
} }
break; break;
default: default:
ASSERT(0); // all state changes should be handled explicitly FAIL_M(ssprintf("Invalid wheel state: %i", m_WheelState));
break;
} }
} }
+1 -1
View File
@@ -1173,7 +1173,7 @@ XNode* NoteData::CreateNode() const
void NoteData::LoadFromNode( const XNode* pNode ) void NoteData::LoadFromNode( const XNode* pNode )
{ {
ASSERT(0); FAIL_M("NoteData::LoadFromNode() not implemented");
} }
template<typename ND, typename iter, typename TN> template<typename ND, typename iter, typename TN>
+5 -3
View File
@@ -163,7 +163,7 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS
* simply be invalid data in an .SM, and we don't want to die * simply be invalid data in an .SM, and we don't want to die
* due to invalid data. We should probably check for this when * due to invalid data. We should probably check for this when
* we load SM data for the first time ... */ * we load SM data for the first time ... */
// ASSERT(0); // FAIL_M("Invalid data in SM");
tn = TAP_EMPTY; tn = TAP_EMPTY;
break; break;
} }
@@ -392,7 +392,8 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet )
case TapNote::hold_head_hold: c = '2'; break; case TapNote::hold_head_hold: c = '2'; break;
case TapNote::hold_head_roll: c = '4'; break; case TapNote::hold_head_roll: c = '4'; break;
//case TapNote::hold_head_mine: c = 'N'; break; //case TapNote::hold_head_mine: c = 'N'; break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid tap note subtype: %i", tn.subType));
} }
break; break;
case TapNote::hold_tail: c = '3'; break; case TapNote::hold_tail: c = '3'; break;
@@ -402,7 +403,8 @@ void NoteDataUtil::GetSMNoteDataString( const NoteData &in, RString &sRet )
case TapNote::lift: c = 'L'; break; case TapNote::lift: c = 'L'; break;
case TapNote::fake: c = 'F'; break; case TapNote::fake: c = 'F'; break;
default: default:
c = '\0'; FAIL_M( ssprintf("tn %i", tn.type) ); // invalid enum value c = '\0';
FAIL_M(ssprintf("Invalid tap note type: %i", tn.type));
} }
sRet.append( 1, c ); sRet.append( 1, c );
+3 -2
View File
@@ -1099,7 +1099,8 @@ void NoteField::DrawPrimitives()
if( !GAMESTATE->m_bIsUsingStepTiming ) if( !GAMESTATE->m_bIsUsingStepTiming )
{ {
// BGChange text // BGChange text
switch( GAMESTATE->m_EditMode ) EditMode mode = GAMESTATE->m_EditMode;
switch( mode )
{ {
case EditMode_Home: case EditMode_Home:
case EditMode_CourseMods: case EditMode_CourseMods:
@@ -1161,7 +1162,7 @@ void NoteField::DrawPrimitives()
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid edit mode: %i", mode));
} }
} }
+5 -4
View File
@@ -51,8 +51,9 @@ float NoteTypeToBeat( NoteType nt )
case NOTE_TYPE_48TH: return 1.0f/12; // sixteenth note triplets case NOTE_TYPE_48TH: return 1.0f/12; // sixteenth note triplets
case NOTE_TYPE_64TH: return 1.0f/16; // sixty-fourth notes case NOTE_TYPE_64TH: return 1.0f/16; // sixty-fourth notes
case NOTE_TYPE_192ND: return 1.0f/48; // sixty-fourth note triplets case NOTE_TYPE_192ND: return 1.0f/48; // sixty-fourth note triplets
default: ASSERT(0); // and fall through
case NoteType_Invalid: return 1.0f/48; case NoteType_Invalid: return 1.0f/48;
default:
FAIL_M(ssprintf("Unrecognized note type: %i", nt));
} }
} }
@@ -132,7 +133,7 @@ XNode* TapNoteResult::CreateNode() const
void TapNoteResult::LoadFromNode( const XNode* pNode ) void TapNoteResult::LoadFromNode( const XNode* pNode )
{ {
ASSERT(0); FAIL_M("TapNoteResult::LoadFromNode() is not implemented");
} }
XNode* HoldNoteResult::CreateNode() const XNode* HoldNoteResult::CreateNode() const
@@ -143,7 +144,7 @@ XNode* HoldNoteResult::CreateNode() const
void HoldNoteResult::LoadFromNode( const XNode* pNode ) void HoldNoteResult::LoadFromNode( const XNode* pNode )
{ {
ASSERT(0); FAIL_M("HoldNoteResult::LoadFromNode() is not implemented");
} }
XNode* TapNote::CreateNode() const XNode* TapNote::CreateNode() const
@@ -158,7 +159,7 @@ XNode* TapNote::CreateNode() const
void TapNote::LoadFromNode( const XNode* pNode ) void TapNote::LoadFromNode( const XNode* pNode )
{ {
ASSERT(0); FAIL_M("TapNote::LoadFromNode() is not implemented");
} }
float HoldNoteResult::GetLastHeldBeat() const float HoldNoteResult::GetLastHeldBeat() const
+1 -1
View File
@@ -87,7 +87,7 @@ static void DWIcharToNote( char c, GameController i, int &note1Out, int &note2Ou
note2Out += 6; note2Out += 6;
break; break;
default: default:
ASSERT( false ); FAIL_M(ssprintf("Invalid GameController: %i", i));
} }
} }
+6 -5
View File
@@ -272,7 +272,7 @@ static void WriteDWINotesField( RageFile &f, const Steps &out, int start )
notedata.SetTapNote(start+5, row, TAP_EMPTY); notedata.SetTapNote(start+5, row, TAP_EMPTY);
break; break;
default: default:
ASSERT(0); // not a type supported by DWI. We shouldn't have called in here if that's the case FAIL_M(ssprintf("StepsType not supported by DWI: %i", out.m_StepsType));
} }
f.Write( str ); f.Write( str );
} }
@@ -299,8 +299,7 @@ static void WriteDWINotesField( RageFile &f, const Steps &out, int start )
f.Write( "'" ); f.Write( "'" );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid note type: %i", nt));
// fall though
} }
f.PutLine( "" ); f.PutLine( "" );
} }
@@ -327,14 +326,16 @@ static bool WriteDWINotesTag( RageFile &f, const Steps &out )
default: return false; // not a type supported by DWI default: return false; // not a type supported by DWI
} }
switch( out.GetDifficulty() ) Difficulty d = out.GetDifficulty();
switch( d )
{ {
case Difficulty_Beginner: f.Write( "BEGINNER:" ); break; case Difficulty_Beginner: f.Write( "BEGINNER:" ); break;
case Difficulty_Easy: f.Write( "BASIC:" ); break; case Difficulty_Easy: f.Write( "BASIC:" ); break;
case Difficulty_Medium: f.Write( "ANOTHER:" ); break; case Difficulty_Medium: f.Write( "ANOTHER:" ); break;
case Difficulty_Hard: f.Write( "MANIAC:" ); break; case Difficulty_Hard: f.Write( "MANIAC:" ); break;
case Difficulty_Challenge: f.Write( "SMANIAC:" ); break; case Difficulty_Challenge: f.Write( "SMANIAC:" ); break;
default: ASSERT(0); return false; default:
FAIL_M(ssprintf("Invalid difficulty: %i", d));
} }
f.PutLine( ssprintf("%d:", out.GetMeter()) ); f.PutLine( ssprintf("%d:", out.GetMeter()) );
+2 -1
View File
@@ -49,7 +49,8 @@ static void WriteGlobalTags( RageFile &f, Song &out )
f.Write( "#SELECTABLE:" ); f.Write( "#SELECTABLE:" );
switch(out.m_SelectionDisplay) switch(out.m_SelectionDisplay)
{ {
default: ASSERT(0); // fall through default:
FAIL_M(ssprintf("Invalid selection display: %i", out.m_SelectionDisplay));
case Song::SHOW_ALWAYS: f.Write( "YES" ); break; case Song::SHOW_ALWAYS: f.Write( "YES" ); break;
//case Song::SHOW_NONSTOP: f.Write( "NONSTOP" ); break; //case Song::SHOW_NONSTOP: f.Write( "NONSTOP" ); break;
case Song::SHOW_NEVER: f.Write( "NO" ); break; case Song::SHOW_NEVER: f.Write( "NO" ); break;
+3 -3
View File
@@ -379,7 +379,7 @@ void OptionRow::InitText( RowType type )
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid option row layout: %i", m_pHand->m_Def.m_layoutType));
} }
for( unsigned c=0; c<m_textItems.size(); c++ ) for( unsigned c=0; c<m_textItems.size(); c++ )
@@ -632,7 +632,7 @@ void OptionRow::UpdateEnabledDisabled()
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid option row layout: %i", m_pHand->m_Def.m_layoutType));
} }
} }
@@ -671,7 +671,7 @@ const BitmapText &OptionRow::GetTextItemForRow( PlayerNumber pn, int iChoiceOnRo
index = iChoiceOnRow; index = iChoiceOnRow;
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid option row layout: %i", m_pHand->m_Def.m_layoutType));
} }
ASSERT_M( index < (int)m_textItems.size(), ssprintf("%i < %i", index, (int)m_textItems.size() ) ); ASSERT_M( index < (int)m_textItems.size(), ssprintf("%i < %i", index, (int)m_textItems.size() ) );
+5 -6
View File
@@ -107,7 +107,8 @@ void TimingWindowSecondsInit( size_t /*TimingWindow*/ i, RString &sNameOut, floa
sNameOut = "TimingWindowSeconds" + TimingWindowToString( (TimingWindow)i ); sNameOut = "TimingWindowSeconds" + TimingWindowToString( (TimingWindow)i );
switch( i ) switch( i )
{ {
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid timing window: %i", i));
case TW_W1: defaultValueOut = 0.0225f; break; case TW_W1: defaultValueOut = 0.0225f; break;
case TW_W2: defaultValueOut = 0.045f; break; case TW_W2: defaultValueOut = 0.045f; break;
case TW_W3: defaultValueOut = 0.090f; break; case TW_W3: defaultValueOut = 0.090f; break;
@@ -691,7 +692,7 @@ void Player::Load()
NoteDataUtil::Turn( m_NoteData, st, NoteDataUtil::right); NoteDataUtil::Turn( m_NoteData, st, NoteDataUtil::right);
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Count %i not in range 0-3", count));
} }
count++; count++;
count %= 4; count %= 4;
@@ -1309,7 +1310,7 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, vector<TrackRowTap
break; break;
*/ */
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid tap note subtype: %i", subType));
} }
} }
@@ -2381,9 +2382,7 @@ void Player::StepStrumHopo( int col, int row, const RageTimer &tm, bool bHeld, b
break; break;
*/ */
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid player controller type: %i", m_pPlayerState->m_PlayerController));
score = TNS_None;
break;
} }
switch( pbt ) switch( pbt )
+2 -1
View File
@@ -233,7 +233,8 @@ void PlayerOptions::GetMods( vector<RString> &AddTo, bool bForceNoteSkin ) const
case FAIL_IMMEDIATE_CONTINUE: AddTo.push_back("FailImmediateContinue"); break; case FAIL_IMMEDIATE_CONTINUE: AddTo.push_back("FailImmediateContinue"); break;
case FAIL_AT_END: AddTo.push_back("FailAtEnd"); break; case FAIL_AT_END: AddTo.push_back("FailAtEnd"); break;
case FAIL_OFF: AddTo.push_back("FailOff"); break; case FAIL_OFF: AddTo.push_back("FailOff"); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid FailType: %i", m_FailType));
} }
if( m_fSkew==0 && m_fPerspectiveTilt==0 ) { if( m_bSetTiltOrSkew ) AddTo.push_back( "Overhead" ); } if( m_fSkew==0 && m_fPerspectiveTilt==0 ) { if( m_bSetTiltOrSkew ) AddTo.push_back( "Overhead" ); }
+4 -11
View File
@@ -580,10 +580,8 @@ const RString& ProfileManager::GetProfileDir( ProfileSlot slot ) const
case ProfileSlot_Machine: case ProfileSlot_Machine:
return MACHINE_PROFILE_DIR; return MACHINE_PROFILE_DIR;
default: default:
break; FAIL_M("Invalid profile slot chosen: unable to get the directory!");
} }
// it should never hit here.
FAIL_M("Invalid profile slot chosen: unable to get the directory!");
} }
RString ProfileManager::GetProfileDirImportedFrom( ProfileSlot slot ) const RString ProfileManager::GetProfileDirImportedFrom( ProfileSlot slot ) const
@@ -596,10 +594,8 @@ RString ProfileManager::GetProfileDirImportedFrom( ProfileSlot slot ) const
case ProfileSlot_Machine: case ProfileSlot_Machine:
return RString(); return RString();
default: default:
ASSERT(0); FAIL_M("Invalid profile slot chosen: unable to get the directory!");
} }
// it should never hit here.
return RString();
} }
const Profile* ProfileManager::GetProfile( ProfileSlot slot ) const const Profile* ProfileManager::GetProfile( ProfileSlot slot ) const
@@ -612,10 +608,8 @@ const Profile* ProfileManager::GetProfile( ProfileSlot slot ) const
case ProfileSlot_Machine: case ProfileSlot_Machine:
return m_pMachineProfile; return m_pMachineProfile;
default: default:
ASSERT(0); FAIL_M("Invalid profile slot chosen: unable to get the profile!");
} }
// it should never hit here.
return NULL;
} }
// //
@@ -769,8 +763,7 @@ bool ProfileManager::IsPersistentProfile( ProfileSlot slot ) const
case ProfileSlot_Machine: case ProfileSlot_Machine:
return true; return true;
default: default:
ASSERT(0); FAIL_M("Invalid profile slot chosen: unable to get profile info!");
return false;
} }
} }
+5 -3
View File
@@ -1166,7 +1166,7 @@ void RageDisplay_D3D::SetBlendMode( BlendMode mode )
g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid BlendMode: %i", mode));
} }
} }
@@ -1208,7 +1208,9 @@ void RageDisplay_D3D::SetZTestMode( ZTestMode mode )
case ZTEST_OFF: dw = D3DCMP_ALWAYS; break; case ZTEST_OFF: dw = D3DCMP_ALWAYS; break;
case ZTEST_WRITE_ON_PASS: dw = D3DCMP_LESSEQUAL; break; case ZTEST_WRITE_ON_PASS: dw = D3DCMP_LESSEQUAL; break;
case ZTEST_WRITE_ON_FAIL: dw = D3DCMP_GREATER; break; case ZTEST_WRITE_ON_FAIL: dw = D3DCMP_GREATER; break;
default: dw = D3DCMP_NEVER; ASSERT( 0 ); default:
dw = D3DCMP_NEVER;
FAIL_M(ssprintf("Invalid ZTestMode: %i", mode));
} }
g_pd3dDevice->SetRenderState( D3DRS_ZFUNC, dw ); g_pd3dDevice->SetRenderState( D3DRS_ZFUNC, dw );
} }
@@ -1319,7 +1321,7 @@ void RageDisplay_D3D::SetCullMode( CullMode mode )
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid CullMode: %i", mode));
} }
} }
+7 -4
View File
@@ -191,7 +191,8 @@ namespace
{ {
case 24: m = Swap24(m); break; case 24: m = Swap24(m); break;
case 32: m = Swap32(m); break; case 32: m = Swap32(m); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Unsupported BPP value: %i", pf.bpp));
} }
pf.masks[mask] = m; pf.masks[mask] = m;
} }
@@ -717,7 +718,8 @@ RageDisplay_GLES2::SetZTestMode( ZTestMode mode )
break; break;
case ZTEST_WRITE_ON_PASS: glDepthFunc( GL_LEQUAL ); break; case ZTEST_WRITE_ON_PASS: glDepthFunc( GL_LEQUAL ); break;
case ZTEST_WRITE_ON_FAIL: glDepthFunc( GL_GREATER ); break; case ZTEST_WRITE_ON_FAIL: glDepthFunc( GL_GREATER ); break;
default: ASSERT( 0 ); default:
FAIL_M(ssprintf("Invalid ZTestMode: %i", mode));
} }
State::bZTestEnabled = true; State::bZTestEnabled = true;
} }
@@ -834,7 +836,7 @@ RageDisplay_GLES2::SetCullMode( CullMode mode )
glDisable( GL_CULL_FACE ); glDisable( GL_CULL_FACE );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid CullMode: %i", mode));
} }
} }
@@ -875,7 +877,8 @@ RageDisplay_GLES2::SetPolygonMode(PolygonMode pm)
{ {
case POLYGON_FILL: m = GL_FILL; break; case POLYGON_FILL: m = GL_FILL; break;
case POLYGON_LINE: m = GL_LINE; break; case POLYGON_LINE: m = GL_LINE; break;
default: ASSERT(0); return; default:
FAIL_M(ssprintf("Invalid PolygonMode: %i", pm));
} }
glPolygonMode(GL_FRONT_AND_BACK, m); glPolygonMode(GL_FRONT_AND_BACK, m);
} }
+8 -5
View File
@@ -236,7 +236,8 @@ static void FixLittleEndian()
{ {
case 24: m = Swap24(m); break; case 24: m = Swap24(m); break;
case 32: m = Swap32(m); break; case 32: m = Swap32(m); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Unsupported BPP value: %i", pf.bpp));
} }
pf.masks[mask] = m; pf.masks[mask] = m;
} }
@@ -1840,7 +1841,8 @@ void RageDisplay_Legacy::SetZTestMode( ZTestMode mode )
case ZTEST_OFF: glDepthFunc( GL_ALWAYS ); break; case ZTEST_OFF: glDepthFunc( GL_ALWAYS ); break;
case ZTEST_WRITE_ON_PASS: glDepthFunc( GL_LEQUAL ); break; case ZTEST_WRITE_ON_PASS: glDepthFunc( GL_LEQUAL ); break;
case ZTEST_WRITE_ON_FAIL: glDepthFunc( GL_GREATER ); break; case ZTEST_WRITE_ON_FAIL: glDepthFunc( GL_GREATER ); break;
default: ASSERT( 0 ); default:
FAIL_M(ssprintf("Invalid ZTestMode: %i", mode));
} }
} }
@@ -1941,7 +1943,7 @@ void RageDisplay_Legacy::SetCullMode( CullMode mode )
glDisable( GL_CULL_FACE ); glDisable( GL_CULL_FACE );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid CullMode: %i", mode));
} }
} }
@@ -2419,7 +2421,7 @@ void RenderTarget_FramebufferObject::Create( const RenderTargetParam &param, int
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: FAIL_M( "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT" ); break; case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT: FAIL_M( "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT" ); break;
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: FAIL_M( "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT" ); break; case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT: FAIL_M( "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT" ); break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Unexpected GL framebuffer status: %i", status));
} }
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
@@ -2531,7 +2533,8 @@ void RageDisplay_Legacy::SetPolygonMode(PolygonMode pm)
{ {
case POLYGON_FILL: m = GL_FILL; break; case POLYGON_FILL: m = GL_FILL; break;
case POLYGON_LINE: m = GL_LINE; break; case POLYGON_LINE: m = GL_LINE; break;
default: ASSERT(0); return; default:
FAIL_M(ssprintf("Invalid PolygonMode: %i", pm));
} }
glPolygonMode(GL_FRONT_AND_BACK, m); glPolygonMode(GL_FRONT_AND_BACK, m);
} }
+7 -3
View File
@@ -144,7 +144,8 @@ bool RageFileDriverDirect::Remove( const RString &sPath_ )
{ {
RString sPath = sPath_; RString sPath = sPath_;
FDB->ResolvePath( sPath ); FDB->ResolvePath( sPath );
switch( this->GetFileType(sPath) ) RageFileManager::FileType type = this->GetFileType(sPath);
switch( type )
{ {
case RageFileManager::TYPE_FILE: case RageFileManager::TYPE_FILE:
TRACE( ssprintf("remove '%s'", (m_sRoot + sPath).c_str()) ); TRACE( ssprintf("remove '%s'", (m_sRoot + sPath).c_str()) );
@@ -166,8 +167,11 @@ bool RageFileDriverDirect::Remove( const RString &sPath_ )
FDB->DelFile( sPath ); FDB->DelFile( sPath );
return true; return true;
case RageFileManager::TYPE_NONE: return false; case RageFileManager::TYPE_NONE:
default: ASSERT(0); return false; return false;
default:
FAIL_M(ssprintf("Invalid FileType: %i", type));
} }
} }
+4 -4
View File
@@ -360,8 +360,9 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img )
{ {
case NEEDS_NO_ALPHA: ret |= TRAIT_NO_TRANSPARENCY; break; case NEEDS_NO_ALPHA: ret |= TRAIT_NO_TRANSPARENCY; break;
case NEEDS_BOOL_ALPHA: ret |= TRAIT_BOOL_TRANSPARENCY; break; case NEEDS_BOOL_ALPHA: ret |= TRAIT_BOOL_TRANSPARENCY; break;
case NEEDS_FULL_ALPHA: break; case NEEDS_FULL_ALPHA: break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid alpha type: %i", alpha_type));
} }
return ret; return ret;
@@ -670,8 +671,7 @@ void RageSurfaceUtils::Blit( const RageSurface *src, RageSurface *dst, int width
if( blit_generic(src, dst, width, height) ) if( blit_generic(src, dst, width, height) )
break; break;
// We don't do RGBA->PAL. FAIL_M("We don't do RGBA->PAL");
ASSERT(0);
} while(0); } while(0);
/* The destination surface may be larger than the source. For example, we may be /* The destination surface may be larger than the source. For example, we may be
+5 -3
View File
@@ -218,7 +218,7 @@ void RageTextureManager::DeleteTexture( RageTexture *t )
} }
} }
ASSERT(0); // we tried to delete a texture that wasn't loaded. FAIL_M("Tried to delete a texture that wasn't loaded");
} }
void RageTextureManager::GarbageCollect( GCType type ) void RageTextureManager::GarbageCollect( GCType type )
@@ -241,7 +241,8 @@ void RageTextureManager::GarbageCollect( GCType type )
bool bDeleteThis = false; bool bDeleteThis = false;
if( type==screen_changed ) if( type==screen_changed )
{ {
switch( t->GetPolicy() ) RageTextureID::TexPolicy policy = t->GetPolicy();
switch( policy )
{ {
case RageTextureID::TEX_DEFAULT: case RageTextureID::TEX_DEFAULT:
/* If m_bDelayedDelete, wait until delayed_delete. If !m_bDelayedDelete, /* If m_bDelayedDelete, wait until delayed_delete. If !m_bDelayedDelete,
@@ -253,7 +254,8 @@ void RageTextureManager::GarbageCollect( GCType type )
case RageTextureID::TEX_VOLATILE: case RageTextureID::TEX_VOLATILE:
bDeleteThis = true; bDeleteThis = true;
break; break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid texture policy: %i", policy));
} }
} }
+4 -2
View File
@@ -27,7 +27,8 @@ void PercentScoreWeightInit( size_t /*ScoreEvent*/ i, RString &sNameOut, int &de
sNameOut = "PercentScoreWeight" + ScoreEventToString( (ScoreEvent)i ); sNameOut = "PercentScoreWeight" + ScoreEventToString( (ScoreEvent)i );
switch( i ) switch( i )
{ {
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid ScoreEvent: %i", i));
case SE_W1: defaultValueOut = 3; break; case SE_W1: defaultValueOut = 3; break;
case SE_W2: defaultValueOut = 2; break; case SE_W2: defaultValueOut = 2; break;
case SE_W3: defaultValueOut = 1; break; case SE_W3: defaultValueOut = 1; break;
@@ -47,7 +48,8 @@ void GradeWeightInit( size_t /*ScoreEvent*/ i, RString &sNameOut, int &defaultVa
sNameOut = "GradeWeight" + ScoreEventToString( (ScoreEvent)i ); sNameOut = "GradeWeight" + ScoreEventToString( (ScoreEvent)i );
switch( i ) switch( i )
{ {
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid ScoreEvent: %i", i));
case SE_W1: defaultValueOut = 2; break; case SE_W1: defaultValueOut = 2; break;
case SE_W2: defaultValueOut = 2; break; case SE_W2: defaultValueOut = 2; break;
case SE_W3: defaultValueOut = 1; break; case SE_W3: defaultValueOut = 1; break;
+5 -2
View File
@@ -127,7 +127,8 @@ void ScoreKeeperRave::AddSuperMeterDelta( float fUnscaledPercentChange )
{ {
case PLAYER_1: fLifePercentage = GAMESTATE->m_fTugLifePercentP1; break; case PLAYER_1: fLifePercentage = GAMESTATE->m_fTugLifePercentP1; break;
case PLAYER_2: fLifePercentage = 1 - GAMESTATE->m_fTugLifePercentP1; break; case PLAYER_2: fLifePercentage = 1 - GAMESTATE->m_fTugLifePercentP1; break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid player number: %i", m_pPlayerState->m_PlayerNumber));
} }
CLAMP( fLifePercentage, 0.f, 1.f ); CLAMP( fLifePercentage, 0.f, 1.f );
if( fUnscaledPercentChange > 0 ) if( fUnscaledPercentChange > 0 )
@@ -163,7 +164,9 @@ void ScoreKeeperRave::AddSuperMeterDelta( float fUnscaledPercentChange )
{ {
case PLAYER_1: bWinning = GAMESTATE->m_fTugLifePercentP1 > 0.5f; break; case PLAYER_1: bWinning = GAMESTATE->m_fTugLifePercentP1 > 0.5f; break;
case PLAYER_2: bWinning = GAMESTATE->m_fTugLifePercentP1 < 0.5f; break; case PLAYER_2: bWinning = GAMESTATE->m_fTugLifePercentP1 < 0.5f; break;
default: bWinning = false; ASSERT(0); default:
bWinning = false;
FAIL_M(ssprintf("Invalid player number: %i", m_pPlayerState->m_PlayerNumber));
} }
if( !bWinning ) if( !bWinning )
m_pPlayerState->EndActiveAttacks(); m_pPlayerState->EndActiveAttacks();
+1 -1
View File
@@ -281,7 +281,7 @@ void ScreenBookkeeping::UpdateView()
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid BookkeepingView: %i", view));
} }
} }
+14 -8
View File
@@ -135,14 +135,15 @@ static LocalizedString OR( "ScreenDebugOverlay", "or" );
static RString GetDebugButtonName( const IDebugLine *pLine ) static RString GetDebugButtonName( const IDebugLine *pLine )
{ {
RString s = INPUTMAN->GetDeviceSpecificInputString(pLine->m_Button); RString s = INPUTMAN->GetDeviceSpecificInputString(pLine->m_Button);
switch( pLine->GetType() ) IDebugLine::Type type = pLine->GetType();
switch( type )
{ {
case IDebugLine::all_screens: case IDebugLine::all_screens:
return s; return s;
case IDebugLine::gameplay_only: case IDebugLine::gameplay_only:
return ssprintf( IN_GAMEPLAY.GetValue(), s.c_str() ); return ssprintf( IN_GAMEPLAY.GetValue(), s.c_str() );
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid debug line type: %i", type));
} }
} }
@@ -455,7 +456,8 @@ bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input )
// Gameplay buttons are available only in gameplay. Non-gameplay buttons // Gameplay buttons are available only in gameplay. Non-gameplay buttons
// are only available when the screen is displayed. // are only available when the screen is displayed.
switch( (*p)->GetType() ) IDebugLine::Type type = (*p)->GetType();
switch( type )
{ {
case IDebugLine::all_screens: case IDebugLine::all_screens:
if( !g_bIsDisplayed ) if( !g_bIsDisplayed )
@@ -468,7 +470,7 @@ bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input )
continue; continue;
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid debug line type: %i", type));
} }
if( input.DeviceI == (*p)->m_Button ) if( input.DeviceI == (*p)->m_Button )
@@ -569,12 +571,14 @@ class DebugLineAutoplay : public IDebugLine
virtual RString GetDisplayTitle() { return AUTO_PLAY.GetValue() + " (+Shift = AI) (+Alt = hide)"; } virtual RString GetDisplayTitle() { return AUTO_PLAY.GetValue() + " (+Shift = AI) (+Alt = hide)"; }
virtual RString GetDisplayValue() virtual RString GetDisplayValue()
{ {
switch( GamePreferences::m_AutoPlay.Get() ) PlayerController pc = GamePreferences::m_AutoPlay.Get();
switch( pc )
{ {
case PC_HUMAN: return OFF.GetValue(); break; case PC_HUMAN: return OFF.GetValue(); break;
case PC_AUTOPLAY: return ON.GetValue(); break; case PC_AUTOPLAY: return ON.GetValue(); break;
case PC_CPU: return CPU.GetValue(); break; case PC_CPU: return CPU.GetValue(); break;
default: ASSERT(0); return RString(); default:
FAIL_M(ssprintf("Invalid PlayerController: %i", pc));
} }
} }
virtual Type GetType() const { return IDebugLine::gameplay_only; } virtual Type GetType() const { return IDebugLine::gameplay_only; }
@@ -643,13 +647,15 @@ class DebugLineAutosync : public IDebugLine
virtual RString GetDisplayTitle() { return AUTOSYNC.GetValue(); } virtual RString GetDisplayTitle() { return AUTOSYNC.GetValue(); }
virtual RString GetDisplayValue() virtual RString GetDisplayValue()
{ {
switch( GAMESTATE->m_SongOptions.GetSong().m_AutosyncType ) SongOptions::AutosyncType type = GAMESTATE->m_SongOptions.GetSong().m_AutosyncType;
switch( type )
{ {
case SongOptions::AUTOSYNC_OFF: return OFF.GetValue(); break; case SongOptions::AUTOSYNC_OFF: return OFF.GetValue(); break;
case SongOptions::AUTOSYNC_SONG: return SONG.GetValue(); break; case SongOptions::AUTOSYNC_SONG: return SONG.GetValue(); break;
case SongOptions::AUTOSYNC_MACHINE: return MACHINE.GetValue(); break; case SongOptions::AUTOSYNC_MACHINE: return MACHINE.GetValue(); break;
case SongOptions::AUTOSYNC_TEMPO: return SYNC_TEMPO.GetValue(); break; case SongOptions::AUTOSYNC_TEMPO: return SYNC_TEMPO.GetValue(); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid autosync type: %i", type));
} }
} }
virtual Type GetType() const { return IDebugLine::gameplay_only; } virtual Type GetType() const { return IDebugLine::gameplay_only; }
+1 -1
View File
@@ -4445,7 +4445,7 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
{ {
case save: s = "ScreenMemcardSaveEditsAfterSave"; break; case save: s = "ScreenMemcardSaveEditsAfterSave"; break;
case save_on_exit: s = "ScreenMemcardSaveEditsAfterExit"; break; case save_on_exit: s = "ScreenMemcardSaveEditsAfterExit"; break;
default: ASSERT(0); default: FAIL_M(ssprintf("Invalid menu choice: %i", c));
} }
SCREENMAN->AddNewScreenToTop( s ); SCREENMAN->AddNewScreenToTop( s );
*/ */
+6 -6
View File
@@ -243,18 +243,18 @@ void ScreenEditMenu::MenuStart( const InputEventPlus & )
{ {
pSteps = pSong->CreateSteps(); pSteps = pSong->CreateSteps();
switch( m_Selector.EDIT_MODE ) EditMode mode = m_Selector.EDIT_MODE;
switch( mode )
{ {
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid EditMode: %i", mode));
case EditMode_Full: case EditMode_Full:
break; break;
case EditMode_Home: case EditMode_Home:
pSteps->SetLoadedFromProfile( ProfileSlot_Machine ); pSteps->SetLoadedFromProfile( ProfileSlot_Machine );
break; break;
case EditMode_Practice: case EditMode_Practice:
ASSERT(0); FAIL_M("Cannot create steps in EditMode_Practice");
break;
} }
RString sEditName; RString sEditName;
@@ -283,7 +283,7 @@ void ScreenEditMenu::MenuStart( const InputEventPlus & )
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid edit menu action: %i", action));
} }
// Go to the next screen. // Go to the next screen.
@@ -318,7 +318,7 @@ void ScreenEditMenu::MenuStart( const InputEventPlus & )
case EditMenuAction_Delete: case EditMenuAction_Delete:
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid edit menu action: %i", action));
} }
} }
+8 -7
View File
@@ -121,7 +121,8 @@ void PlayerInfo::Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField, int
if( !IsMultiPlayer() ) if( !IsMultiPlayer() )
{ {
switch( GAMESTATE->m_PlayMode ) PlayMode mode = GAMESTATE->m_PlayMode;
switch( mode )
{ {
case PLAY_MODE_REGULAR: case PLAY_MODE_REGULAR:
case PLAY_MODE_NONSTOP: case PLAY_MODE_NONSTOP:
@@ -140,7 +141,7 @@ void PlayerInfo::Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField, int
m_pPrimaryScoreDisplay = new ScoreDisplayOni; m_pPrimaryScoreDisplay = new ScoreDisplayOni;
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid PlayMode: %i", mode));
} }
} }
@@ -245,8 +246,7 @@ bool PlayerInfo::IsEnabled()
return GAMESTATE->IsMultiPlayerEnabled( m_mp ); return GAMESTATE->IsMultiPlayerEnabled( m_mp );
else if( m_bIsDummy ) else if( m_bIsDummy )
return true; return true;
ASSERT( 0 ); FAIL_M("Invalid non-dummy player.");
return false;
} }
vector<PlayerInfo>::iterator vector<PlayerInfo>::iterator
@@ -1849,7 +1849,8 @@ void ScreenGameplay::Update( float fDeltaTime )
// Check to see if it's time to play a ScreenGameplay comment // Check to see if it's time to play a ScreenGameplay comment
m_fTimeSinceLastDancingComment += fDeltaTime; m_fTimeSinceLastDancingComment += fDeltaTime;
switch( GAMESTATE->m_PlayMode ) PlayMode mode = GAMESTATE->m_PlayMode;
switch( mode )
{ {
case PLAY_MODE_REGULAR: case PLAY_MODE_REGULAR:
case PLAY_MODE_BATTLE: case PLAY_MODE_BATTLE:
@@ -1867,9 +1868,9 @@ void ScreenGameplay::Update( float fDeltaTime )
PlayAnnouncer( "gameplay comment oni", SECONDS_BETWEEN_COMMENTS ); PlayAnnouncer( "gameplay comment oni", SECONDS_BETWEEN_COMMENTS );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid PlayMode: %i", mode));
} }
} }
default: break; default: break;
} }
+6 -4
View File
@@ -216,9 +216,10 @@ void ScreenHighScores::Init()
m_Scroller.SetName( "Scroller" ); m_Scroller.SetName( "Scroller" );
LOAD_ALL_COMMANDS( m_Scroller ); LOAD_ALL_COMMANDS( m_Scroller );
switch( HIGH_SCORES_TYPE ) HighScoresType type = HIGH_SCORES_TYPE;
switch( type )
{ {
DEFAULT_FAIL( HIGH_SCORES_TYPE.GetValue() ); DEFAULT_FAIL( type );
case HighScoresType_AllSteps: case HighScoresType_AllSteps:
m_Scroller.LoadSongs( MAX_ITEMS_TO_SHOW ); m_Scroller.LoadSongs( MAX_ITEMS_TO_SHOW );
break; break;
@@ -228,9 +229,10 @@ void ScreenHighScores::Init()
case HighScoresType_AllCourses: case HighScoresType_AllCourses:
{ {
CourseType ct; CourseType ct;
switch( HIGH_SCORES_TYPE ) switch( type )
{ {
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid HighScoresType: %i", type));
case HighScoresType_NonstopCourses: ct = COURSE_TYPE_NONSTOP; break; case HighScoresType_NonstopCourses: ct = COURSE_TYPE_NONSTOP; break;
case HighScoresType_OniCourses: ct = COURSE_TYPE_ONI; break; case HighScoresType_OniCourses: ct = COURSE_TYPE_ONI; break;
case HighScoresType_SurvivalCourses: ct = COURSE_TYPE_SURVIVAL; break; case HighScoresType_SurvivalCourses: ct = COURSE_TYPE_SURVIVAL; break;
+3 -4
View File
@@ -171,7 +171,7 @@ void ScreenOptions::Init()
m_frameContainer.AddChild( &m_textExplanationTogether ); m_frameContainer.AddChild( &m_textExplanationTogether );
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid InputMode: %i", m_InputMode));
} }
if( SHOW_SCROLL_BAR ) if( SHOW_SCROLL_BAR )
@@ -640,7 +640,7 @@ void ScreenOptions::PositionRows( bool bTween )
else if( second_end < (int) Rows.size() ) else if( second_end < (int) Rows.size() )
second_end++; second_end++;
else else
ASSERT(0); // do we have room to grow or don't we? FAIL_M("Do we have room to grow or don't we?");
} }
int pos = 0; int pos = 0;
@@ -933,8 +933,7 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input )
break; break;
} }
case NAV_THREE_KEY_MENU: case NAV_THREE_KEY_MENU:
ASSERT(0); // unreachable FAIL_M("NAV_THREE_KEY_MENU should be unreachable");
break;
case NAV_FIVE_KEY: case NAV_FIVE_KEY:
/* Jump to the exit row. (If everyone's already on the exit row, then /* Jump to the exit row. (If everyone's already on the exit row, then
* we'll have already gone to the next screen above.) */ * we'll have already gone to the next screen above.) */
+1 -1
View File
@@ -264,7 +264,7 @@ void ScreenOptionsManageProfiles::HandleScreenMessage( const ScreenMessage SM )
switch( ScreenMiniMenu::s_iLastRowCode ) switch( ScreenMiniMenu::s_iLastRowCode )
{ {
default: default:
ASSERT(0); FAIL_M(ssprintf("Last row code not a valid ProfileAction: %i", ScreenMiniMenu::s_iLastRowCode));
case ProfileAction_SetDefaultP1: case ProfileAction_SetDefaultP1:
case ProfileAction_SetDefaultP2: case ProfileAction_SetDefaultP2:
{ {
+1 -2
View File
@@ -142,9 +142,8 @@ bool ScreenPrompt::CanGoRight()
case PROMPT_YES_NO_CANCEL: case PROMPT_YES_NO_CANCEL:
return m_Answer < ANSWER_CANCEL; return m_Answer < ANSWER_CANCEL;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid PromptType: %i", g_PromptType));
} }
return false;
} }
void ScreenPrompt::Change( int dir ) void ScreenPrompt::Change( int dir )
+3 -3
View File
@@ -238,7 +238,8 @@ float ScreenRanking::SetPage( const PageToShow &pts )
m_textTime[l].SetDiffuseColor( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); m_textTime[l].SetDiffuseColor( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) );
} }
switch( RANKING_TYPE ) RankingType rtype = RANKING_TYPE;
switch( rtype )
{ {
case RankingType_Category: case RankingType_Category:
{ {
@@ -332,8 +333,7 @@ float ScreenRanking::SetPage( const PageToShow &pts )
} }
return SECONDS_PER_PAGE; return SECONDS_PER_PAGE;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid RankingType: %i", rtype));
return 0;
} }
} }
+3 -3
View File
@@ -193,10 +193,10 @@ PlayerNumber ScreenSelectCharacter::GetAffectedPlayerNumber( PlayerNumber pn )
return pn; return pn;
case CHOOSING_CPU_CHARACTER: case CHOOSING_CPU_CHARACTER:
return CPU_PLAYER[pn]; return CPU_PLAYER[pn];
default:
ASSERT(0);
case FINISHED_CHOOSING: case FINISHED_CHOOSING:
return pn; return pn;
default:
FAIL_M(ssprintf("Invalid character selection state: %i", m_SelectionRow[pn]));
} }
} }
@@ -268,7 +268,7 @@ void ScreenSelectCharacter::AfterValueChange( PlayerNumber pn )
; // do nothing ; // do nothing
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid character selection state: %i", m_SelectionRow[pn]));
} }
} }
+10 -7
View File
@@ -654,7 +654,7 @@ void ScreenSelectMusic::Input( const InputEventPlus &input )
} }
else else
{ {
ASSERT(0); FAIL_M("Logic bug: L/R keys in an impossible state?");
} }
// Reset the repeat timer when the button is released. // Reset the repeat timer when the button is released.
@@ -1701,7 +1701,9 @@ void ScreenSelectMusic::AfterMusicChange()
s_lastSortOrder = GAMESTATE->m_SortOrder; s_lastSortOrder = GAMESTATE->m_SortOrder;
} }
switch( m_MusicWheel.GetSelectedType() ) WheelItemDataType wtype = m_MusicWheel.GetSelectedType();
SampleMusicPreviewMode pmode;
switch( wtype )
{ {
case WheelItemDataType_Section: case WheelItemDataType_Section:
case WheelItemDataType_Sort: case WheelItemDataType_Sort:
@@ -1728,7 +1730,7 @@ void ScreenSelectMusic::AfterMusicChange()
m_fSampleLengthSeconds = -1; m_fSampleLengthSeconds = -1;
} }
switch( m_MusicWheel.GetSelectedType() ) switch( wtype )
{ {
case WheelItemDataType_Section: case WheelItemDataType_Section:
// reduce scope // reduce scope
@@ -1776,7 +1778,7 @@ void ScreenSelectMusic::AfterMusicChange()
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid WheelItemDataType: %i", wtype));
} }
// override this if the sample music mode wants to. // override this if the sample music mode wants to.
/* /*
@@ -1792,7 +1794,8 @@ void ScreenSelectMusic::AfterMusicChange()
case WheelItemDataType_Song: case WheelItemDataType_Song:
case WheelItemDataType_Portal: case WheelItemDataType_Portal:
// check SampleMusicPreviewMode here. // check SampleMusicPreviewMode here.
switch( SAMPLE_MUSIC_PREVIEW_MODE ) pmode = SAMPLE_MUSIC_PREVIEW_MODE;
switch( pmode )
{ {
case SampleMusicPreviewMode_ScreenMusic: case SampleMusicPreviewMode_ScreenMusic:
// play the screen music // play the screen music
@@ -1812,7 +1815,7 @@ void ScreenSelectMusic::AfterMusicChange()
m_fSampleLengthSeconds = pSong->m_fMusicSampleLengthSeconds; m_fSampleLengthSeconds = pSong->m_fMusicSampleLengthSeconds;
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid preview mode: %i", pmode));
} }
SongUtil::GetPlayableSteps( pSong, m_vpSteps ); SongUtil::GetPlayableSteps( pSong, m_vpSteps );
@@ -1848,7 +1851,7 @@ void ScreenSelectMusic::AfterMusicChange()
break; break;
} }
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid WheelItemDataType: %i", wtype));
} }
m_sprCDTitleFront.UnloadTexture(); m_sprCDTitleFront.UnloadTexture();
+1 -1
View File
@@ -165,7 +165,7 @@ static RString TransferStatsMemoryCardToMachine()
s = ssprintf(PROFILE_CORRUPT.GetValue(),pn+1); s = ssprintf(PROFILE_CORRUPT.GetValue(),pn+1);
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid profile load result: %i", lr));
} }
MEMCARDMAN->UnmountCard(pn); MEMCARDMAN->UnmountCard(pn);
+2 -1
View File
@@ -128,7 +128,8 @@ void ScreenSetTime::ChangeValue( int iDirection )
case year: adjusted.tm_year += iDirection; break; case year: adjusted.tm_year += iDirection; break;
case month: adjusted.tm_mon += iDirection; break; case month: adjusted.tm_mon += iDirection; break;
case day: adjusted.tm_mday += iDirection; break; case day: adjusted.tm_mday += iDirection; break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid SetTimeSelection: %i", m_Selection));
} }
/* Normalize: */ /* Normalize: */
+9 -5
View File
@@ -102,22 +102,26 @@ void ScreenSyncOverlay::UpdateText()
if( g_bShowAutoplay ) if( g_bShowAutoplay )
{ {
switch( GamePreferences::m_AutoPlay.Get() ) PlayerController pc = GamePreferences::m_AutoPlay.Get();
switch( pc )
{ {
case PC_HUMAN: break; case PC_HUMAN: break;
case PC_AUTOPLAY: vs.push_back(AUTO_PLAY); break; case PC_AUTOPLAY: vs.push_back(AUTO_PLAY); break;
case PC_CPU: vs.push_back(AUTO_PLAY_CPU); break; case PC_CPU: vs.push_back(AUTO_PLAY_CPU); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid PlayerController: %i", pc));
} }
} }
switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType ) SongOptions::AutosyncType type = GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType;
switch( type )
{ {
case SongOptions::AUTOSYNC_OFF: break; case SongOptions::AUTOSYNC_OFF: break;
case SongOptions::AUTOSYNC_SONG: vs.push_back(AUTO_SYNC_SONG); break; case SongOptions::AUTOSYNC_SONG: vs.push_back(AUTO_SYNC_SONG); break;
case SongOptions::AUTOSYNC_MACHINE: vs.push_back(AUTO_SYNC_MACHINE); break; case SongOptions::AUTOSYNC_MACHINE: vs.push_back(AUTO_SYNC_MACHINE); break;
case SongOptions::AUTOSYNC_TEMPO: vs.push_back(AUTO_SYNC_TEMPO); break; case SongOptions::AUTOSYNC_TEMPO: vs.push_back(AUTO_SYNC_TEMPO); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid autosync type: %i", type));
} }
if( GAMESTATE->m_pCurSong != NULL && !GAMESTATE->IsCourseMode() ) // sync controls available if( GAMESTATE->m_pCurSong != NULL && !GAMESTATE->IsCourseMode() ) // sync controls available
@@ -287,7 +291,7 @@ bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input )
} }
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid sync action choice: %i", a));
} }
ShowHelp(); ShowHelp();
+3 -2
View File
@@ -97,7 +97,8 @@ namespace
} }
else // bShowCreditsMessage else // bShowCreditsMessage
{ {
switch( GAMESTATE->GetCoinMode() ) CoinMode mode = GAMESTATE->GetCoinMode();
switch( mode )
{ {
case CoinMode_Home: case CoinMode_Home:
if( GAMESTATE->PlayersCanJoin() ) if( GAMESTATE->PlayersCanJoin() )
@@ -126,7 +127,7 @@ namespace
return CREDITS_NOT_PRESENT.GetValue(); return CREDITS_NOT_PRESENT.GetValue();
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid CoinMode: %i", mode));
} }
} }
} }
+3 -2
View File
@@ -11,10 +11,11 @@ void ScreenUnlockBrowse::Init()
FOREACH_CONST( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue ) FOREACH_CONST( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue )
{ {
GameCommand gc; GameCommand gc;
switch( ue->GetUnlockEntryStatus() ) UnlockEntryStatus st = ue->GetUnlockEntryStatus();
switch( st )
{ {
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid UnlockEntryStatus: %i", st));
case UnlockEntryStatus_RequirementsMet: case UnlockEntryStatus_RequirementsMet:
case UnlockEntryStatus_Unlocked: case UnlockEntryStatus_Unlocked:
gc.m_bInvalid = false; gc.m_bInvalid = false;
+1 -2
View File
@@ -1144,8 +1144,7 @@ Song *SongManager::GetSongFromSteps( Steps *pSteps ) const
} }
} }
} }
ASSERT(0); FAIL_M("No song found for steps");
return NULL;
} }
void SongManager::DeleteSteps( Steps *pSteps ) void SongManager::DeleteSteps( Steps *pSteps )
+6 -3
View File
@@ -75,7 +75,8 @@ void SongOptions::GetMods( vector<RString> &AddTo ) const
case LIFE_TIME: case LIFE_TIME:
AddTo.push_back( "LifeTime" ); AddTo.push_back( "LifeTime" );
break; break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid LifeType: %i", m_LifeType));
} }
@@ -95,7 +96,8 @@ void SongOptions::GetMods( vector<RString> &AddTo ) const
case AUTOSYNC_SONG: AddTo.push_back("AutosyncSong"); break; case AUTOSYNC_SONG: AddTo.push_back("AutosyncSong"); break;
case AUTOSYNC_MACHINE: AddTo.push_back("AutosyncMachine"); break; case AUTOSYNC_MACHINE: AddTo.push_back("AutosyncMachine"); break;
case AUTOSYNC_TEMPO: AddTo.push_back("AutosyncTempo"); break; case AUTOSYNC_TEMPO: AddTo.push_back("AutosyncTempo"); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid autosync type: %i", m_AutosyncType));
} }
switch( m_SoundEffectType ) switch( m_SoundEffectType )
@@ -103,7 +105,8 @@ void SongOptions::GetMods( vector<RString> &AddTo ) const
case SOUNDEFFECT_OFF: break; case SOUNDEFFECT_OFF: break;
case SOUNDEFFECT_SPEED: AddTo.push_back("EffectSpeed"); break; case SOUNDEFFECT_SPEED: AddTo.push_back("EffectSpeed"); break;
case SOUNDEFFECT_PITCH: AddTo.push_back("EffectPitch"); break; case SOUNDEFFECT_PITCH: AddTo.push_back("EffectPitch"); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid sound effect type: %i", m_SoundEffectType));
} }
if( m_bAssistClap ) if( m_bAssistClap )
+5 -6
View File
@@ -581,7 +581,8 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
{ {
case SORT_TITLE: s = pSong->GetTranslitMainTitle(); break; case SORT_TITLE: s = pSong->GetTranslitMainTitle(); break;
case SORT_ARTIST: s = pSong->GetTranslitArtist(); break; case SORT_ARTIST: s = pSong->GetTranslitArtist(); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Unexpected SortOrder: %i", so));
} }
s = MakeSortString(s); // resulting string will be uppercase s = MakeSortString(s); // resulting string will be uppercase
@@ -667,8 +668,7 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so
case SORT_ONI_COURSES: case SORT_ONI_COURSES:
case SORT_ENDLESS_COURSES: case SORT_ENDLESS_COURSES:
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid SortOrder: %i", so));
return RString();
} }
} }
@@ -782,9 +782,8 @@ RString SongUtil::MakeUniqueEditDescription( const Song *pSong, StepsType st, co
return sTemp; return sTemp;
} }
// Edit limit guards should keep us from ever having more than 1000 edits per song. // Edit limit guards should prevent this
ASSERT(0); FAIL_M("Exceeded limit of 1000 edits per song");
return RString();
} }
static LocalizedString YOU_MUST_SUPPLY_NAME ( "SongUtil", "You must supply a name for your new edit." ); static LocalizedString YOU_MUST_SUPPLY_NAME ( "SongUtil", "You must supply a name for your new edit." );
+2 -2
View File
@@ -639,7 +639,7 @@ bool CheckVideoDefaultSettings()
goto found_defaults; goto found_defaults;
} }
} }
ASSERT( 0 ); // we must have matched at least one above FAIL_M("Failed to match video driver");
found_defaults: found_defaults:
@@ -1072,7 +1072,7 @@ int main(int argc, char* argv[])
case Dialog::no: case Dialog::no:
break; break;
default: default:
ASSERT(0); FAIL_M("Invalid response to Yes/No dialog");
} }
} }
else if( version_num < current_version ) else if( version_num < current_version )
+1 -1
View File
@@ -482,7 +482,7 @@ void TextureFont::Save( CString sBasePath, CString sBitmapAppendBeforeExtension,
sPageName += "-stroke"; sPageName += "-stroke";
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Unexpected value for j: %i", j));
} }
CString sFile; CString sFile;
+1 -1
View File
@@ -962,7 +962,7 @@ RString ThemeManager::GetMetricRaw( const IniFile &ini, const RString &sMetricsG
sDefaultMetricPath.c_str() ); sDefaultMetricPath.c_str() );
return RString(); return RString();
default: default:
ASSERT(0); FAIL_M("Unexpected answer to Abort/Retry/Ignore dialog");
} }
} }
} }
+2 -3
View File
@@ -304,7 +304,7 @@ const TimingSegment* TimingData::GetSegmentAtRow( int iNoteRow, TimingSegmentTyp
} }
} }
ASSERT( 0 ); FAIL_M("Could not find timing segment for row");
} }
TimingSegment* GetSegmentAtRow( int iNoteRow, TimingSegmentType tst ) TimingSegment* GetSegmentAtRow( int iNoteRow, TimingSegmentType tst )
@@ -954,8 +954,7 @@ void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, i
} }
} }
ASSERT(0); FAIL_M("Failed to get measure and beat for note row");
return;
} }
vector<RString> TimingData::ToVectorString(TimingSegmentType tst, int dec) const vector<RString> TimingData::ToVectorString(TimingSegmentType tst, int dec) const
+2 -1
View File
@@ -84,7 +84,8 @@ ITween *ITween::CreateFromType( TweenType tt )
case TWEEN_ACCELERATE: return new TweenAccelerate; case TWEEN_ACCELERATE: return new TweenAccelerate;
case TWEEN_DECELERATE: return new TweenDecelerate; case TWEEN_DECELERATE: return new TweenDecelerate;
case TWEEN_SPRING: return new TweenSpring; case TWEEN_SPRING: return new TweenSpring;
default: ASSERT(0); default:
FAIL_M(ssprintf("Invalid TweenType: %i", tt));
} }
} }
+4 -7
View File
@@ -418,8 +418,7 @@ RString UnlockEntry::GetDescription() const
switch( m_Type ) switch( m_Type )
{ {
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid UnlockRewardType: %i", m_Type));
return "";
case UnlockRewardType_Song: case UnlockRewardType_Song:
return pSong ? pSong->GetDisplayFullTitle() : ""; return pSong ? pSong->GetDisplayFullTitle() : "";
case UnlockRewardType_Steps: case UnlockRewardType_Steps:
@@ -446,8 +445,7 @@ RString UnlockEntry::GetBannerFile() const
switch( m_Type ) switch( m_Type )
{ {
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid UnlockRewardType: %i", m_Type));
return "";
case UnlockRewardType_Song: case UnlockRewardType_Song:
case UnlockRewardType_Steps: case UnlockRewardType_Steps:
case UnlockRewardType_Steps_Type: case UnlockRewardType_Steps_Type:
@@ -465,8 +463,7 @@ RString UnlockEntry::GetBackgroundFile() const
switch( m_Type ) switch( m_Type )
{ {
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid UnlockRewardType: %i", m_Type));
return "";
case UnlockRewardType_Song: case UnlockRewardType_Song:
case UnlockRewardType_Steps: case UnlockRewardType_Steps:
case UnlockRewardType_Steps_Type: case UnlockRewardType_Steps_Type:
@@ -631,7 +628,7 @@ void UnlockManager::Load()
// nothing to cache // nothing to cache
break; break;
default: default:
ASSERT(0); FAIL_M(ssprintf("Invalid UnlockRewardType: %i", e->m_Type));
} }
} }
+1 -2
View File
@@ -273,8 +273,7 @@ void WheelBase::UpdateSwitch()
case STATE_LOCKED: case STATE_LOCKED:
break; break;
default: default:
ASSERT(0); // all state changes should be handled explicitly FAIL_M(ssprintf("Invalid wheel state: %i", m_WheelState));
break;
} }
} }
+8 -7
View File
@@ -183,10 +183,8 @@ static BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP
break; break;
case IDC_BUTTON_RESTART: case IDC_BUTTON_RESTART:
Win32RestartProgram(); Win32RestartProgram();
// not reached // Possibly make W32RP a NORETURN call?
ASSERT( 0 ); FAIL_M("Win32RestartProgram failed?");
EndDialog( hWnd, 0 );
break;
case IDOK: case IDOK:
EndDialog( hWnd, 0 ); EndDialog( hWnd, 0 );
break; break;
@@ -242,8 +240,9 @@ Dialog::Result DialogDriver_Win32::AbortRetryIgnore( RString sMessage, RString I
{ {
case IDABORT: return Dialog::abort; case IDABORT: return Dialog::abort;
case IDRETRY: return Dialog::retry; case IDRETRY: return Dialog::retry;
default: ASSERT(0);
case IDIGNORE: return Dialog::ignore; case IDIGNORE: return Dialog::ignore;
default:
FAIL_M(ssprintf("Unexpected response to Abort/Retry/Ignore dialog: %i", iRet));
} }
} }
@@ -258,8 +257,9 @@ Dialog::Result DialogDriver_Win32::AbortRetry( RString sMessage, RString sID )
switch( iRet ) switch( iRet )
{ {
case IDRETRY: return Dialog::retry; case IDRETRY: return Dialog::retry;
default: ASSERT(0);
case IDCANCEL: return Dialog::abort; case IDCANCEL: return Dialog::abort;
default:
FAIL_M(ssprintf("Unexpected response to Retry/Cancel dialog: %i", iRet));
} }
} }
@@ -274,8 +274,9 @@ Dialog::Result DialogDriver_Win32::YesNo( RString sMessage, RString sID )
switch( iRet ) switch( iRet )
{ {
case IDYES: return Dialog::yes; case IDYES: return Dialog::yes;
default: ASSERT(0);
case IDNO: return Dialog::no; case IDNO: return Dialog::no;
default:
FAIL_M(ssprintf("Unexpected response to Yes/No dialog: %i", iRet));
} }
} }
@@ -269,7 +269,7 @@ void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm )
switch( device.type ) switch( device.type )
{ {
default: default:
ASSERT(0); FAIL_M(ssprintf("Unsupported DI device type: %i", device.type));
case device.KEYBOARD: case device.KEYBOARD:
{ {
unsigned char keys[256]; unsigned char keys[256];
+3 -2
View File
@@ -452,10 +452,11 @@ void MovieTexture_DShow::CreateTexture()
return; return;
PixelFormat pixfmt; PixelFormat pixfmt;
switch( TEXTUREMAN->GetPrefs().m_iMovieColorDepth ) int depth = TEXTUREMAN->GetPrefs().m_iMovieColorDepth;
switch( depth )
{ {
default: default:
ASSERT(0); FAIL_M(ssprintf("Unsupported movie color depth: %i", depth));
case 16: case 16:
if( DISPLAY->SupportsTextureFormat(PixelFormat_RGB5) ) if( DISPLAY->SupportsTextureFormat(PixelFormat_RGB5) )
pixfmt = PixelFormat_RGB5; pixfmt = PixelFormat_RGB5;
@@ -154,7 +154,8 @@ static void FixLilEndian()
{ {
case 24: m = Swap24(m); break; case 24: m = Swap24(m); break;
case 32: m = Swap32(m); break; case 32: m = Swap32(m); break;
default: ASSERT(0); default:
FAIL_M(ssprintf("Unsupported BPP value: %i", pf.bpp));
} }
pf.masks[mask] = m; pf.masks[mask] = m;
} }
@@ -232,10 +232,11 @@ void MovieTexture_Generic::CreateTexture()
{ {
/* We weren't given a natively-supported pixel format. Pick a supported /* We weren't given a natively-supported pixel format. Pick a supported
* one. This is a fallback case, and implies a second conversion. */ * one. This is a fallback case, and implies a second conversion. */
switch( TEXTUREMAN->GetPrefs().m_iMovieColorDepth ) int depth = TEXTUREMAN->GetPrefs().m_iMovieColorDepth;
switch( depth )
{ {
default: default:
ASSERT(0); FAIL_M(ssprintf("Unsupported movie color depth: %i", depth));
case 16: case 16:
if( DISPLAY->SupportsTextureFormat(PixelFormat_RGB5) ) if( DISPLAY->SupportsTextureFormat(PixelFormat_RGB5) )
pixfmt = PixelFormat_RGB5; pixfmt = PixelFormat_RGB5;