diff --git a/src/Actor.cpp b/src/Actor.cpp index 76ec4ae4ab..93115e06d8 100644 --- a/src/Actor.cpp +++ b/src/Actor.cpp @@ -442,7 +442,7 @@ void Actor::BeginDraw() // set the world matrix and calculate actor properties } break; default: - ASSERT(0); // invalid Effect + FAIL_M(ssprintf("Invalid effect: %i", m_Effect)); } } @@ -856,13 +856,10 @@ void Actor::SetEffectClockString( const RString &s ) else { CabinetLight cl = StringToCabinetLight( s ); - if( cl != CabinetLight_Invalid ) - { - this->SetEffectClock( (EffectClock) (cl + CLOCK_LIGHT_1) ); - return; - } - else - ASSERT(0); + if( cl == CabinetLight_Invalid ) + FAIL_M(ssprintf("Invalid cabinet light: %s", s.c_str())); + + this->SetEffectClock( (EffectClock) (cl + CLOCK_LIGHT_1) ); } } diff --git a/src/ActorFrame.cpp b/src/ActorFrame.cpp index ee01feee57..7aabc238d2 100644 --- a/src/ActorFrame.cpp +++ b/src/ActorFrame.cpp @@ -186,10 +186,7 @@ void ActorFrame::MoveToTail( Actor* pActor ) { vector::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor ); if( iter == m_SubActors.end() ) // didn't find - { - ASSERT(0); // called with a pActor that doesn't exist - return; - } + FAIL_M("Nonexistent actor"); m_SubActors.erase( iter ); m_SubActors.push_back( pActor ); @@ -199,10 +196,7 @@ void ActorFrame::MoveToHead( Actor* pActor ) { vector::iterator iter = find( m_SubActors.begin(), m_SubActors.end(), pActor ); if( iter == m_SubActors.end() ) // didn't find - { - ASSERT(0); // called with a pActor that doesn't exist - return; - } + FAIL_M("Nonexistent actor"); m_SubActors.erase( iter ); m_SubActors.insert( m_SubActors.begin(), pActor ); diff --git a/src/ActorUtil.cpp b/src/ActorUtil.cpp index 8c3d7e9b1e..e7a4658b61 100644 --- a/src/ActorUtil.cpp +++ b/src/ActorUtil.cpp @@ -59,7 +59,7 @@ retry: case Dialog::ignore: return false; default: - ASSERT(0); + FAIL_M("Invalid response to Abort/Retry/Ignore dialog"); } } @@ -81,7 +81,7 @@ retry: asPaths.erase( asPaths.begin()+1, asPaths.end() ); break; default: - ASSERT(0); + FAIL_M("Invalid response to Abort/Retry/Ignore dialog"); } } diff --git a/src/AdjustSync.cpp b/src/AdjustSync.cpp index 1b2fc879a3..7d410dad42 100644 --- a/src/AdjustSync.cpp +++ b/src/AdjustSync.cpp @@ -148,7 +148,8 @@ void AdjustSync::HandleAutosync( float fNoteOffBySeconds, float fStepTime ) { if( GAMESTATE->IsCourseMode() ) return; - switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType ) { + SongOptions::AutosyncType type = GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType; + switch( type ) { case SongOptions::AUTOSYNC_OFF: return; case SongOptions::AUTOSYNC_TEMPO: @@ -170,7 +171,7 @@ void AdjustSync::HandleAutosync( float fNoteOffBySeconds, float fStepTime ) break; } 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 ); RString sAutosyncType; - switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType ) + SongOptions::AutosyncType type = GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType; + switch( type ) { case SongOptions::AUTOSYNC_SONG: sAutosyncType = AUTOSYNC_SONG; @@ -201,12 +203,12 @@ void AdjustSync::AutosyncOffset() sAutosyncType = AUTOSYNC_MACHINE; break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid autosync type: %i", type)); } if( stddev < .03f ) // If they stepped with less than .03 error { - switch( GAMESTATE->m_SongOptions.GetCurrent().m_AutosyncType ) + switch( type ) { case SongOptions::AUTOSYNC_SONG: { @@ -223,7 +225,7 @@ void AdjustSync::AutosyncOffset() PREFSMAN->m_fGlobalOffsetSeconds.Set( PREFSMAN->m_fGlobalOffsetSeconds + mean ); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid autosync type: %i", type)); } SCREENMAN->SystemMessage( AUTOSYNC_CORRECTION_APPLIED.GetValue() ); diff --git a/src/BGAnimationLayer.cpp b/src/BGAnimationLayer.cpp index d7ff56ca07..d65e9ae3fc 100644 --- a/src/BGAnimationLayer.cpp +++ b/src/BGAnimationLayer.cpp @@ -272,7 +272,7 @@ void BGAnimationLayer::LoadFromAniLayerFile( const RString& sPath ) m_vParticleVelocity[i].y *= PARTICLE_SPEED; break; 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 ); break; default: - ASSERT(0); + FAIL_M(ssprintf("Not a tile effect: %i", effect)); } } } } break; default: - ASSERT(0); + FAIL_M(ssprintf("Unrecognized layer effect: %i", effect)); } @@ -527,7 +527,7 @@ void BGAnimationLayer::LoadFromNode( const XNode* pNode ) } break; default: - ASSERT(0); + FAIL_M(ssprintf("Unrecognized layer type: %i", m_Type)); } bool bStartOnRandomFrame = false; @@ -641,7 +641,7 @@ void BGAnimationLayer::UpdateInternal( float fDeltaTime ) } break; default: - ASSERT(0); + FAIL_M(ssprintf("Unrecognized layer type: %i", m_Type)); } } diff --git a/src/BPMDisplay.cpp b/src/BPMDisplay.cpp index 93e680cb4d..f6e3cae00c 100644 --- a/src/BPMDisplay.cpp +++ b/src/BPMDisplay.cpp @@ -195,7 +195,7 @@ void BPMDisplay::SetBpmFromSong( const Song* pSong ) CycleRandomly(); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid display BPM type: %i", pSong->m_DisplayBPMType)); } } diff --git a/src/CombinedLifeMeterTug.cpp b/src/CombinedLifeMeterTug.cpp index ca3d20c987..07b306e74f 100644 --- a/src/CombinedLifeMeterTug.cpp +++ b/src/CombinedLifeMeterTug.cpp @@ -13,7 +13,8 @@ static void TugMeterPercentChangeInit( size_t /*ScoreEvent*/ i, RString &sNameOu sNameOut = "TugMeterPercentChange" + ScoreEventToString( (ScoreEvent)i ); switch( i ) { - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid ScoreEvent: %i", i)); case SE_W1: defaultValueOut = +0.010f; break; case SE_W2: defaultValueOut = +0.008f; 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_CheckpointHit: fPercentToMove = g_fTugMeterPercentChange[SE_CheckpointHit]; 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 ); @@ -95,7 +97,8 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, HoldNoteScore score, Tap { case HNS_Held: fPercentToMove = g_fTugMeterPercentChange[SE_Held]; 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 ); @@ -110,7 +113,8 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, float fPercentToMove ) { case PLAYER_1: fLifePercentage = 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. */ @@ -122,7 +126,8 @@ void CombinedLifeMeterTug::ChangeLife( PlayerNumber pn, float fPercentToMove ) { case PLAYER_1: 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)); } } diff --git a/src/Course.cpp b/src/Course.cpp index 6736109b63..1b67acdcb8 100644 --- a/src/Course.cpp +++ b/src/Course.cpp @@ -123,7 +123,8 @@ void Course::SetCourseType( CourseType ct ) switch( ct ) { - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid course type: %i", ct)); case COURSE_TYPE_NONSTOP: break; case COURSE_TYPE_ONI: @@ -141,13 +142,15 @@ void Course::SetCourseType( CourseType ct ) PlayMode Course::GetPlayMode() const { - switch( GetCourseType() ) + CourseType ct = GetCourseType(); + switch( ct ) { case COURSE_TYPE_ENDLESS: return PLAY_MODE_ENDLESS; case COURSE_TYPE_ONI: return PLAY_MODE_ONI; case COURSE_TYPE_SURVIVAL: return PLAY_MODE_ONI; case COURSE_TYPE_NONSTOP: return PLAY_MODE_NONSTOP; - default: ASSERT(0); return PlayMode_Invalid; + default: + FAIL_M(ssprintf("Invalid course type: %i", ct)); } } diff --git a/src/DifficultyList.cpp b/src/DifficultyList.cpp index 52695cd16f..83fba9e3f2 100644 --- a/src/DifficultyList.cpp +++ b/src/DifficultyList.cpp @@ -168,7 +168,7 @@ void StepsDisplayList::UpdatePositions() else if( second_end < (int) Rows.size() ) second_end++; 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; diff --git a/src/EditMenu.cpp b/src/EditMenu.cpp index 72076ba71b..18a0336041 100644 --- a/src/EditMenu.cpp +++ b/src/EditMenu.cpp @@ -52,7 +52,8 @@ void EditMenu::StripLockedStepsAndDifficulty( vector &v ) void EditMenu::GetSongsToShowForGroup( const RString &sGroup, vector &vpSongsOut ) { 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_CourseMods: @@ -67,7 +68,7 @@ void EditMenu::GetSongsToShowForGroup( const RString &sGroup, vector &vpS case EditMode_Full: break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid edit mode: %i", mode)); } SongUtil::SortSongPointerArrayByTitle( vpSongsOut ); } @@ -391,7 +392,8 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) { if( dc == Difficulty_Edit ) { - switch( EDIT_MODE.GetValue() ) + EditMode mode = EDIT_MODE.GetValue(); + switch( mode ) { case EditMode_Full: case EditMode_CourseMods: @@ -408,10 +410,10 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) // have only "New Edit" break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid edit mode: %i", mode)); } - switch( EDIT_MODE.GetValue() ) + switch( mode ) { case EditMode_Practice: case EditMode_CourseMods: @@ -421,7 +423,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) m_vpSteps.push_back( StepsAndDifficulty(NULL,dc) ); // "New Edit" break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid edit mode: %i", mode)); } } else @@ -430,6 +432,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) if( pSteps && UNLOCKMAN->StepsIsLocked( GetSelectedSong(), pSteps ) ) pSteps = NULL; + EditMode mode = EDIT_MODE.GetValue(); switch( EDIT_MODE.GetValue() ) { case EditMode_Home: @@ -446,7 +449,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) m_vpSteps.push_back( StepsAndDifficulty(pSteps,dc) ); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid edit mode: %i", mode)); } } } @@ -532,7 +535,8 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) m_Actions.clear(); if( GetSelectedSteps() ) { - switch( EDIT_MODE.GetValue() ) + EditMode mode = EDIT_MODE.GetValue(); + switch( mode ) { case EditMode_Practice: case EditMode_CourseMods: @@ -544,7 +548,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) m_Actions.push_back( EditMenuAction_Delete ); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid edit mode: %i", mode)); } } else @@ -558,7 +562,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) m_textValue[ROW_ACTION].SetText( EditMenuActionToLocalizedString(GetSelectedAction()) ); break; default: - ASSERT(0); // invalid row + FAIL_M(ssprintf("Invalid EditMenuRow: %i", row)); } } diff --git a/src/GameCommand.cpp b/src/GameCommand.cpp index 1330ca0078..4776f98736 100644 --- a/src/GameCommand.cpp +++ b/src/GameCommand.cpp @@ -690,7 +690,7 @@ void GameCommand::ApplySelf( const vector &vpns ) const } break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid StyleType: %i", m_pStyle->m_StyleType)); } } if( m_dc != Difficulty_Invalid ) diff --git a/src/GameManager.cpp b/src/GameManager.cpp index f82744f59a..6f335f602c 100644 --- a/src/GameManager.cpp +++ b/src/GameManager.cpp @@ -2966,8 +2966,7 @@ const Style* GameManager::GetHowToPlayStyleForGame( const Game *pGame ) return style; } - ASSERT(0); // this Game is missing a Style that can be used with HowToPlay - return NULL; + FAIL_M(ssprintf("Game has no Style that can be used with HowToPlay: %s", pGame->m_szName)); } void GameManager::GetCompatibleStyles( const Game *pGame, int iNumPlayers, vector &vpStylesOut ) @@ -3052,8 +3051,7 @@ int GameManager::GetIndexFromGame( const Game* pGame ) if( g_Games[g] == pGame ) return g; } - ASSERT(0); - return 0; + FAIL_M(ssprintf("Game not found: %s", pGame->m_szName)); } const Game* GameManager::GetGameFromIndex( int index ) diff --git a/src/GameState.cpp b/src/GameState.cpp index 0daead14cf..0273b6ece8 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -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 } - switch( GetCurrentStyle()->m_StyleType ) + StyleType type = GetCurrentStyle()->m_StyleType; + switch( type ) { case StyleType_TwoPlayersTwoSides: case StyleType_TwoPlayersSharedSides: @@ -1227,8 +1228,7 @@ bool GameState::IsHumanPlayer( PlayerNumber pn ) const case StyleType_OnePlayerTwoSides: return pn == this->GetMasterPlayerNumber(); default: - ASSERT(0); // invalid style type - return false; + FAIL_M(ssprintf("Invalid style type: %i", type)); } } @@ -1544,15 +1544,15 @@ PlayerOptions::FailType GameState::GetPlayerFailType( const PlayerState *pPlayer bool GameState::ShowW1() const { - switch( PREFSMAN->m_AllowW1 ) + AllowW1 pref = PREFSMAN->m_AllowW1; + switch( pref ) { case ALLOW_W1_NEVER: return false; case ALLOW_W1_COURSES_ONLY: return IsCourseMode(); 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 &asFeatsOu } break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid play mode: %i", m_PlayMode)); } } @@ -2088,7 +2088,7 @@ float GameState::GetGoalPercentComplete( PlayerNumber pn ) case GoalType_None: return 0; // never complete default: - ASSERT(0); + FAIL_M(ssprintf("Invalid GoalType: %i", pProfile->m_GoalType)); } if( fGoal == 0 ) return 0; diff --git a/src/HoldJudgment.cpp b/src/HoldJudgment.cpp index 12b7d87c48..a050b6f9d9 100644 --- a/src/HoldJudgment.cpp +++ b/src/HoldJudgment.cpp @@ -54,8 +54,6 @@ void HoldJudgment::SetHoldJudgment( HoldNoteScore hns ) switch( hns ) { - case HNS_None: - ASSERT(0); case HNS_Held: m_sprJudgment->SetState( 0 ); m_sprJudgment->PlayCommand( "Held" ); @@ -64,8 +62,9 @@ void HoldJudgment::SetHoldJudgment( HoldNoteScore hns ) m_sprJudgment->SetState( 1 ); m_sprJudgment->PlayCommand( "LetGo" ); break; + case HNS_None: default: - ASSERT(0); + FAIL_M(ssprintf("Cannot set hold judgment to %i", hns)); } } diff --git a/src/Inventory.cpp b/src/Inventory.cpp index 70928245c7..5124d15c33 100644 --- a/src/Inventory.cpp +++ b/src/Inventory.cpp @@ -46,12 +46,13 @@ void ReloadItems() Inventory::Inventory() { - switch( GAMESTATE->m_PlayMode ) + PlayMode mode = GAMESTATE->m_PlayMode; + switch( mode ) { case PLAY_MODE_BATTLE: break; default: - ASSERT(0); + FAIL_M(ssprintf("Inventory not valid for PlayMode %i", mode)); } } diff --git a/src/LifeMeter.cpp b/src/LifeMeter.cpp index d02fe734b9..1d6fd285fb 100644 --- a/src/LifeMeter.cpp +++ b/src/LifeMeter.cpp @@ -12,7 +12,7 @@ LifeMeter *LifeMeter::MakeLifeMeter( SongOptions::LifeType t ) case SongOptions::LIFE_BATTERY: return new LifeMeterBattery; case SongOptions::LIFE_TIME: return new LifeMeterTime; default: - ASSERT(0); + FAIL_M(ssprintf("Unrecognized LifeMeter type: %i", t)); } } diff --git a/src/LifeMeterBar.cpp b/src/LifeMeterBar.cpp index a165791bb6..b81f9efcd5 100644 --- a/src/LifeMeterBar.cpp +++ b/src/LifeMeterBar.cpp @@ -31,7 +31,8 @@ LifeMeterBar::LifeMeterBar() 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: m_fLifePercentage = INITIAL_VALUE; @@ -41,7 +42,8 @@ LifeMeterBar::LifeMeterBar() case SongOptions::DRAIN_NO_RECOVER: case SongOptions::DRAIN_SUDDEN_DEATH: m_fLifePercentage = 1.0f; break; - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid DrainType: %i", dtype)); } const RString sType = "LifeMeterBar"; @@ -149,7 +151,8 @@ void LifeMeterBar::ChangeLife( TapNoteScore score ) void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore ) { 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: 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_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score)); } if( IsHot() && score == HNS_LetGo ) 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_LetGo: fDeltaLife = m_fLifePercentChange.GetValue(SE_LetGo); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score)); } break; case SongOptions::DRAIN_SUDDEN_DEATH: @@ -177,11 +180,11 @@ void LifeMeterBar::ChangeLife( HoldNoteScore score, TapNoteScore tscore ) case HNS_Held: fDeltaLife = +0; break; case HNS_LetGo: fDeltaLife = -1.0f; break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid HoldNoteScore: %i", score)); } break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid DrainType: %i", dtype)); } ChangeLife( fDeltaLife ); diff --git a/src/LifeMeterTime.cpp b/src/LifeMeterTime.cpp index fa361172da..d2eba75565 100644 --- a/src/LifeMeterTime.cpp +++ b/src/LifeMeterTime.cpp @@ -109,7 +109,8 @@ void LifeMeterTime::ChangeLife( TapNoteScore tns ) float fMeterChange = 0; switch( tns ) { - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid TapNoteScore: %i", tns)); case TNS_W1: fMeterChange = g_fTimeMeterSecondsChange[SE_W1]; break; case TNS_W2: fMeterChange = g_fTimeMeterSecondsChange[SE_W2]; break; case TNS_W3: fMeterChange = g_fTimeMeterSecondsChange[SE_W3]; break; @@ -134,7 +135,8 @@ void LifeMeterTime::ChangeLife( HoldNoteScore hns, TapNoteScore tns ) float fMeterChange = 0; switch( hns ) { - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid HoldNoteScore: %i", hns)); case HNS_Held: fMeterChange = g_fTimeMeterSecondsChange[SE_Held]; break; case HNS_LetGo: fMeterChange = g_fTimeMeterSecondsChange[SE_LetGo]; break; } diff --git a/src/ModelManager.cpp b/src/ModelManager.cpp index 4fe9d6989e..b054fd2811 100644 --- a/src/ModelManager.cpp +++ b/src/ModelManager.cpp @@ -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 ) diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index f0dfaf0031..e1c1bd4760 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -762,7 +762,8 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelIt FOREACH_ENUM( CourseType, i ) vct.push_back( i ); break; - default: ASSERT(0); break; + default: + FAIL_M(ssprintf("Wrong sort order: %i", so)); } vector apCourses; @@ -1139,8 +1140,7 @@ void MusicWheel::UpdateSwitch() } break; default: - ASSERT(0); // all state changes should be handled explicitly - break; + FAIL_M(ssprintf("Invalid wheel state: %i", m_WheelState)); } } diff --git a/src/NoteData.cpp b/src/NoteData.cpp index 7c29848c40..24bb051fea 100644 --- a/src/NoteData.cpp +++ b/src/NoteData.cpp @@ -1173,7 +1173,7 @@ XNode* NoteData::CreateNode() const void NoteData::LoadFromNode( const XNode* pNode ) { - ASSERT(0); + FAIL_M("NoteData::LoadFromNode() not implemented"); } template diff --git a/src/NoteDataUtil.cpp b/src/NoteDataUtil.cpp index 0e7e0bd599..8142ae181b 100644 --- a/src/NoteDataUtil.cpp +++ b/src/NoteDataUtil.cpp @@ -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 * due to invalid data. We should probably check for this when * we load SM data for the first time ... */ - // ASSERT(0); + // FAIL_M("Invalid data in SM"); tn = TAP_EMPTY; 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_roll: c = '4'; break; //case TapNote::hold_head_mine: c = 'N'; break; - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid tap note subtype: %i", tn.subType)); } 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::fake: c = 'F'; break; 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 ); diff --git a/src/NoteField.cpp b/src/NoteField.cpp index 3c47c33a14..eb4af75cbb 100644 --- a/src/NoteField.cpp +++ b/src/NoteField.cpp @@ -1099,7 +1099,8 @@ void NoteField::DrawPrimitives() if( !GAMESTATE->m_bIsUsingStepTiming ) { // BGChange text - switch( GAMESTATE->m_EditMode ) + EditMode mode = GAMESTATE->m_EditMode; + switch( mode ) { case EditMode_Home: case EditMode_CourseMods: @@ -1161,7 +1162,7 @@ void NoteField::DrawPrimitives() } break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid edit mode: %i", mode)); } } diff --git a/src/NoteTypes.cpp b/src/NoteTypes.cpp index e9747f5835..dd5f62e3e9 100644 --- a/src/NoteTypes.cpp +++ b/src/NoteTypes.cpp @@ -51,8 +51,9 @@ float NoteTypeToBeat( NoteType nt ) 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_192ND: return 1.0f/48; // sixty-fourth note triplets - default: ASSERT(0); // and fall through 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 ) { - ASSERT(0); + FAIL_M("TapNoteResult::LoadFromNode() is not implemented"); } XNode* HoldNoteResult::CreateNode() const @@ -143,7 +144,7 @@ XNode* HoldNoteResult::CreateNode() const void HoldNoteResult::LoadFromNode( const XNode* pNode ) { - ASSERT(0); + FAIL_M("HoldNoteResult::LoadFromNode() is not implemented"); } XNode* TapNote::CreateNode() const @@ -158,7 +159,7 @@ XNode* TapNote::CreateNode() const void TapNote::LoadFromNode( const XNode* pNode ) { - ASSERT(0); + FAIL_M("TapNote::LoadFromNode() is not implemented"); } float HoldNoteResult::GetLastHeldBeat() const diff --git a/src/NotesLoaderDWI.cpp b/src/NotesLoaderDWI.cpp index c97c39464f..4009744d9a 100644 --- a/src/NotesLoaderDWI.cpp +++ b/src/NotesLoaderDWI.cpp @@ -87,7 +87,7 @@ static void DWIcharToNote( char c, GameController i, int ¬e1Out, int ¬e2Ou note2Out += 6; break; default: - ASSERT( false ); + FAIL_M(ssprintf("Invalid GameController: %i", i)); } } diff --git a/src/NotesWriterDWI.cpp b/src/NotesWriterDWI.cpp index b512a53345..939848e7b3 100644 --- a/src/NotesWriterDWI.cpp +++ b/src/NotesWriterDWI.cpp @@ -272,7 +272,7 @@ static void WriteDWINotesField( RageFile &f, const Steps &out, int start ) notedata.SetTapNote(start+5, row, TAP_EMPTY); break; 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 ); } @@ -299,8 +299,7 @@ static void WriteDWINotesField( RageFile &f, const Steps &out, int start ) f.Write( "'" ); break; default: - ASSERT(0); - // fall though + FAIL_M(ssprintf("Invalid note type: %i", nt)); } f.PutLine( "" ); } @@ -327,14 +326,16 @@ static bool WriteDWINotesTag( RageFile &f, const Steps &out ) 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_Easy: f.Write( "BASIC:" ); break; case Difficulty_Medium: f.Write( "ANOTHER:" ); break; case Difficulty_Hard: f.Write( "MANIAC:" ); 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()) ); diff --git a/src/NotesWriterSM.cpp b/src/NotesWriterSM.cpp index cf113f0df7..9beb8d9328 100644 --- a/src/NotesWriterSM.cpp +++ b/src/NotesWriterSM.cpp @@ -49,7 +49,8 @@ static void WriteGlobalTags( RageFile &f, Song &out ) f.Write( "#SELECTABLE:" ); 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_NONSTOP: f.Write( "NONSTOP" ); break; case Song::SHOW_NEVER: f.Write( "NO" ); break; diff --git a/src/OptionRow.cpp b/src/OptionRow.cpp index 99e1039b49..f97c249206 100644 --- a/src/OptionRow.cpp +++ b/src/OptionRow.cpp @@ -379,7 +379,7 @@ void OptionRow::InitText( RowType type ) break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid option row layout: %i", m_pHand->m_Def.m_layoutType)); } for( unsigned c=0; cm_Def.m_layoutType)); } } @@ -671,7 +671,7 @@ const BitmapText &OptionRow::GetTextItemForRow( PlayerNumber pn, int iChoiceOnRo index = iChoiceOnRow; break; 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() ) ); diff --git a/src/Player.cpp b/src/Player.cpp index 1a3ab227f5..4d3b7f157f 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -107,7 +107,8 @@ void TimingWindowSecondsInit( size_t /*TimingWindow*/ i, RString &sNameOut, floa sNameOut = "TimingWindowSeconds" + TimingWindowToString( (TimingWindow)i ); switch( i ) { - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid timing window: %i", i)); case TW_W1: defaultValueOut = 0.0225f; break; case TW_W2: defaultValueOut = 0.045f; break; case TW_W3: defaultValueOut = 0.090f; break; @@ -691,7 +692,7 @@ void Player::Load() NoteDataUtil::Turn( m_NoteData, st, NoteDataUtil::right); break; default: - ASSERT(0); + FAIL_M(ssprintf("Count %i not in range 0-3", count)); } count++; count %= 4; @@ -1309,7 +1310,7 @@ void Player::UpdateHoldNotes( int iSongRow, float fDeltaTime, vectorm_PlayerController)); } switch( pbt ) diff --git a/src/PlayerOptions.cpp b/src/PlayerOptions.cpp index 543c2122c3..f0e908b79e 100644 --- a/src/PlayerOptions.cpp +++ b/src/PlayerOptions.cpp @@ -233,7 +233,8 @@ void PlayerOptions::GetMods( vector &AddTo, bool bForceNoteSkin ) const case FAIL_IMMEDIATE_CONTINUE: AddTo.push_back("FailImmediateContinue"); break; case FAIL_AT_END: AddTo.push_back("FailAtEnd"); 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" ); } diff --git a/src/ProfileManager.cpp b/src/ProfileManager.cpp index 6b154fb0fc..9aad13c857 100644 --- a/src/ProfileManager.cpp +++ b/src/ProfileManager.cpp @@ -580,10 +580,8 @@ const RString& ProfileManager::GetProfileDir( ProfileSlot slot ) const case ProfileSlot_Machine: return MACHINE_PROFILE_DIR; 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 @@ -596,10 +594,8 @@ RString ProfileManager::GetProfileDirImportedFrom( ProfileSlot slot ) const case ProfileSlot_Machine: return RString(); 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 @@ -612,10 +608,8 @@ const Profile* ProfileManager::GetProfile( ProfileSlot slot ) const case ProfileSlot_Machine: return m_pMachineProfile; 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: return true; default: - ASSERT(0); - return false; + FAIL_M("Invalid profile slot chosen: unable to get profile info!"); } } diff --git a/src/RageDisplay_D3D.cpp b/src/RageDisplay_D3D.cpp index d3881ad6a8..34fe1263f3 100644 --- a/src/RageDisplay_D3D.cpp +++ b/src/RageDisplay_D3D.cpp @@ -1166,7 +1166,7 @@ void RageDisplay_D3D::SetBlendMode( BlendMode mode ) g_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE ); break; 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_WRITE_ON_PASS: dw = D3DCMP_LESSEQUAL; 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 ); } @@ -1319,7 +1321,7 @@ void RageDisplay_D3D::SetCullMode( CullMode mode ) g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid CullMode: %i", mode)); } } diff --git a/src/RageDisplay_GLES2.cpp b/src/RageDisplay_GLES2.cpp index feb090365f..02bf140b38 100644 --- a/src/RageDisplay_GLES2.cpp +++ b/src/RageDisplay_GLES2.cpp @@ -191,7 +191,8 @@ namespace { case 24: m = Swap24(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; } @@ -717,7 +718,8 @@ RageDisplay_GLES2::SetZTestMode( ZTestMode mode ) break; case ZTEST_WRITE_ON_PASS: glDepthFunc( GL_LEQUAL ); break; case ZTEST_WRITE_ON_FAIL: glDepthFunc( GL_GREATER ); break; - default: ASSERT( 0 ); + default: + FAIL_M(ssprintf("Invalid ZTestMode: %i", mode)); } State::bZTestEnabled = true; } @@ -834,7 +836,7 @@ RageDisplay_GLES2::SetCullMode( CullMode mode ) glDisable( GL_CULL_FACE ); break; 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_LINE: m = GL_LINE; break; - default: ASSERT(0); return; + default: + FAIL_M(ssprintf("Invalid PolygonMode: %i", pm)); } glPolygonMode(GL_FRONT_AND_BACK, m); } diff --git a/src/RageDisplay_OGL.cpp b/src/RageDisplay_OGL.cpp index faa24a7f54..96f03513e9 100644 --- a/src/RageDisplay_OGL.cpp +++ b/src/RageDisplay_OGL.cpp @@ -236,7 +236,8 @@ static void FixLittleEndian() { case 24: m = Swap24(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; } @@ -1840,7 +1841,8 @@ void RageDisplay_Legacy::SetZTestMode( ZTestMode mode ) case ZTEST_OFF: glDepthFunc( GL_ALWAYS ); break; case ZTEST_WRITE_ON_PASS: glDepthFunc( GL_LEQUAL ); 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 ); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid CullMode: %i", mode)); } } @@ -2419,7 +2421,7 @@ void RenderTarget_FramebufferObject::Create( const RenderTargetParam ¶m, int 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; default: - ASSERT(0); + FAIL_M(ssprintf("Unexpected GL framebuffer status: %i", status)); } glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 ); @@ -2531,7 +2533,8 @@ void RageDisplay_Legacy::SetPolygonMode(PolygonMode pm) { case POLYGON_FILL: m = GL_FILL; 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); } diff --git a/src/RageFileDriverDirect.cpp b/src/RageFileDriverDirect.cpp index 21c380d9cd..b9be858378 100644 --- a/src/RageFileDriverDirect.cpp +++ b/src/RageFileDriverDirect.cpp @@ -144,7 +144,8 @@ bool RageFileDriverDirect::Remove( const RString &sPath_ ) { RString sPath = sPath_; FDB->ResolvePath( sPath ); - switch( this->GetFileType(sPath) ) + RageFileManager::FileType type = this->GetFileType(sPath); + switch( type ) { case RageFileManager::TYPE_FILE: TRACE( ssprintf("remove '%s'", (m_sRoot + sPath).c_str()) ); @@ -166,8 +167,11 @@ bool RageFileDriverDirect::Remove( const RString &sPath_ ) FDB->DelFile( sPath ); return true; - case RageFileManager::TYPE_NONE: return false; - default: ASSERT(0); return false; + case RageFileManager::TYPE_NONE: + return false; + + default: + FAIL_M(ssprintf("Invalid FileType: %i", type)); } } diff --git a/src/RageSurfaceUtils.cpp b/src/RageSurfaceUtils.cpp index c265116a9e..48d4a2542c 100644 --- a/src/RageSurfaceUtils.cpp +++ b/src/RageSurfaceUtils.cpp @@ -360,8 +360,9 @@ int RageSurfaceUtils::FindSurfaceTraits( const RageSurface *img ) { case NEEDS_NO_ALPHA: ret |= TRAIT_NO_TRANSPARENCY; break; case NEEDS_BOOL_ALPHA: ret |= TRAIT_BOOL_TRANSPARENCY; break; - case NEEDS_FULL_ALPHA: break; - default: ASSERT(0); + case NEEDS_FULL_ALPHA: break; + default: + FAIL_M(ssprintf("Invalid alpha type: %i", alpha_type)); } return ret; @@ -670,8 +671,7 @@ void RageSurfaceUtils::Blit( const RageSurface *src, RageSurface *dst, int width if( blit_generic(src, dst, width, height) ) break; - // We don't do RGBA->PAL. - ASSERT(0); + FAIL_M("We don't do RGBA->PAL"); } while(0); /* The destination surface may be larger than the source. For example, we may be diff --git a/src/RageTextureManager.cpp b/src/RageTextureManager.cpp index 361f427a6f..8062cabe2e 100644 --- a/src/RageTextureManager.cpp +++ b/src/RageTextureManager.cpp @@ -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 ) @@ -241,7 +241,8 @@ void RageTextureManager::GarbageCollect( GCType type ) bool bDeleteThis = false; if( type==screen_changed ) { - switch( t->GetPolicy() ) + RageTextureID::TexPolicy policy = t->GetPolicy(); + switch( policy ) { case RageTextureID::TEX_DEFAULT: /* If m_bDelayedDelete, wait until delayed_delete. If !m_bDelayedDelete, @@ -253,7 +254,8 @@ void RageTextureManager::GarbageCollect( GCType type ) case RageTextureID::TEX_VOLATILE: bDeleteThis = true; break; - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid texture policy: %i", policy)); } } diff --git a/src/ScoreKeeperNormal.cpp b/src/ScoreKeeperNormal.cpp index cab4361c14..62743275db 100644 --- a/src/ScoreKeeperNormal.cpp +++ b/src/ScoreKeeperNormal.cpp @@ -27,7 +27,8 @@ void PercentScoreWeightInit( size_t /*ScoreEvent*/ i, RString &sNameOut, int &de sNameOut = "PercentScoreWeight" + ScoreEventToString( (ScoreEvent)i ); switch( i ) { - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid ScoreEvent: %i", i)); case SE_W1: defaultValueOut = 3; break; case SE_W2: defaultValueOut = 2; 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 ); switch( i ) { - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid ScoreEvent: %i", i)); case SE_W1: defaultValueOut = 2; break; case SE_W2: defaultValueOut = 2; break; case SE_W3: defaultValueOut = 1; break; diff --git a/src/ScoreKeeperRave.cpp b/src/ScoreKeeperRave.cpp index 9669ccd18f..30c9dc7b10 100644 --- a/src/ScoreKeeperRave.cpp +++ b/src/ScoreKeeperRave.cpp @@ -127,7 +127,8 @@ void ScoreKeeperRave::AddSuperMeterDelta( float fUnscaledPercentChange ) { case PLAYER_1: fLifePercentage = 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 ); if( fUnscaledPercentChange > 0 ) @@ -163,7 +164,9 @@ void ScoreKeeperRave::AddSuperMeterDelta( float fUnscaledPercentChange ) { case PLAYER_1: 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 ) m_pPlayerState->EndActiveAttacks(); diff --git a/src/ScreenBookkeeping.cpp b/src/ScreenBookkeeping.cpp index 1322e26390..2bb33ea523 100644 --- a/src/ScreenBookkeeping.cpp +++ b/src/ScreenBookkeeping.cpp @@ -281,7 +281,7 @@ void ScreenBookkeeping::UpdateView() } break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid BookkeepingView: %i", view)); } } diff --git a/src/ScreenDebugOverlay.cpp b/src/ScreenDebugOverlay.cpp index dde63857b6..0e6eeb29b5 100644 --- a/src/ScreenDebugOverlay.cpp +++ b/src/ScreenDebugOverlay.cpp @@ -135,14 +135,15 @@ static LocalizedString OR( "ScreenDebugOverlay", "or" ); static RString GetDebugButtonName( const IDebugLine *pLine ) { RString s = INPUTMAN->GetDeviceSpecificInputString(pLine->m_Button); - switch( pLine->GetType() ) + IDebugLine::Type type = pLine->GetType(); + switch( type ) { case IDebugLine::all_screens: return s; case IDebugLine::gameplay_only: return ssprintf( IN_GAMEPLAY.GetValue(), s.c_str() ); 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 // are only available when the screen is displayed. - switch( (*p)->GetType() ) + IDebugLine::Type type = (*p)->GetType(); + switch( type ) { case IDebugLine::all_screens: if( !g_bIsDisplayed ) @@ -468,7 +470,7 @@ bool ScreenDebugOverlay::OverlayInput( const InputEventPlus &input ) continue; break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid debug line type: %i", type)); } 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 GetDisplayValue() { - switch( GamePreferences::m_AutoPlay.Get() ) + PlayerController pc = GamePreferences::m_AutoPlay.Get(); + switch( pc ) { case PC_HUMAN: return OFF.GetValue(); break; case PC_AUTOPLAY: return ON.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; } @@ -643,13 +647,15 @@ class DebugLineAutosync : public IDebugLine virtual RString GetDisplayTitle() { return AUTOSYNC.GetValue(); } 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_SONG: return SONG.GetValue(); break; case SongOptions::AUTOSYNC_MACHINE: return MACHINE.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; } diff --git a/src/ScreenEdit.cpp b/src/ScreenEdit.cpp index 996c60b957..d6252def93 100644 --- a/src/ScreenEdit.cpp +++ b/src/ScreenEdit.cpp @@ -4445,7 +4445,7 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector &iAns { case save: s = "ScreenMemcardSaveEditsAfterSave"; break; case save_on_exit: s = "ScreenMemcardSaveEditsAfterExit"; break; - default: ASSERT(0); + default: FAIL_M(ssprintf("Invalid menu choice: %i", c)); } SCREENMAN->AddNewScreenToTop( s ); */ diff --git a/src/ScreenEditMenu.cpp b/src/ScreenEditMenu.cpp index 8bd49a56ff..e4ef1bdfe4 100644 --- a/src/ScreenEditMenu.cpp +++ b/src/ScreenEditMenu.cpp @@ -243,18 +243,18 @@ void ScreenEditMenu::MenuStart( const InputEventPlus & ) { pSteps = pSong->CreateSteps(); - switch( m_Selector.EDIT_MODE ) + EditMode mode = m_Selector.EDIT_MODE; + switch( mode ) { default: - ASSERT(0); + FAIL_M(ssprintf("Invalid EditMode: %i", mode)); case EditMode_Full: break; case EditMode_Home: pSteps->SetLoadedFromProfile( ProfileSlot_Machine ); break; case EditMode_Practice: - ASSERT(0); - break; + FAIL_M("Cannot create steps in EditMode_Practice"); } RString sEditName; @@ -283,7 +283,7 @@ void ScreenEditMenu::MenuStart( const InputEventPlus & ) } break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid edit menu action: %i", action)); } // Go to the next screen. @@ -318,7 +318,7 @@ void ScreenEditMenu::MenuStart( const InputEventPlus & ) case EditMenuAction_Delete: break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid edit menu action: %i", action)); } } diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 0c4aa06803..b4a1f7f6f8 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -121,7 +121,8 @@ void PlayerInfo::Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField, int if( !IsMultiPlayer() ) { - switch( GAMESTATE->m_PlayMode ) + PlayMode mode = GAMESTATE->m_PlayMode; + switch( mode ) { case PLAY_MODE_REGULAR: case PLAY_MODE_NONSTOP: @@ -140,7 +141,7 @@ void PlayerInfo::Load( PlayerNumber pn, MultiPlayer mp, bool bShowNoteField, int m_pPrimaryScoreDisplay = new ScoreDisplayOni; break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid PlayMode: %i", mode)); } } @@ -245,8 +246,7 @@ bool PlayerInfo::IsEnabled() return GAMESTATE->IsMultiPlayerEnabled( m_mp ); else if( m_bIsDummy ) return true; - ASSERT( 0 ); - return false; + FAIL_M("Invalid non-dummy player."); } vector::iterator @@ -1849,7 +1849,8 @@ void ScreenGameplay::Update( float fDeltaTime ) // Check to see if it's time to play a ScreenGameplay comment m_fTimeSinceLastDancingComment += fDeltaTime; - switch( GAMESTATE->m_PlayMode ) + PlayMode mode = GAMESTATE->m_PlayMode; + switch( mode ) { case PLAY_MODE_REGULAR: case PLAY_MODE_BATTLE: @@ -1867,9 +1868,9 @@ void ScreenGameplay::Update( float fDeltaTime ) PlayAnnouncer( "gameplay comment oni", SECONDS_BETWEEN_COMMENTS ); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid PlayMode: %i", mode)); } - } + } default: break; } diff --git a/src/ScreenHighScores.cpp b/src/ScreenHighScores.cpp index 4f68a4cad6..2f42e89d4e 100644 --- a/src/ScreenHighScores.cpp +++ b/src/ScreenHighScores.cpp @@ -216,9 +216,10 @@ void ScreenHighScores::Init() m_Scroller.SetName( "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: m_Scroller.LoadSongs( MAX_ITEMS_TO_SHOW ); break; @@ -228,9 +229,10 @@ void ScreenHighScores::Init() case HighScoresType_AllCourses: { 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_OniCourses: ct = COURSE_TYPE_ONI; break; case HighScoresType_SurvivalCourses: ct = COURSE_TYPE_SURVIVAL; break; diff --git a/src/ScreenOptions.cpp b/src/ScreenOptions.cpp index bb8030b34d..1eaf456ea1 100644 --- a/src/ScreenOptions.cpp +++ b/src/ScreenOptions.cpp @@ -171,7 +171,7 @@ void ScreenOptions::Init() m_frameContainer.AddChild( &m_textExplanationTogether ); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid InputMode: %i", m_InputMode)); } if( SHOW_SCROLL_BAR ) @@ -640,7 +640,7 @@ void ScreenOptions::PositionRows( bool bTween ) else if( second_end < (int) Rows.size() ) second_end++; 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; @@ -933,8 +933,7 @@ void ScreenOptions::ProcessMenuStart( const InputEventPlus &input ) break; } case NAV_THREE_KEY_MENU: - ASSERT(0); // unreachable - break; + FAIL_M("NAV_THREE_KEY_MENU should be unreachable"); case NAV_FIVE_KEY: /* Jump to the exit row. (If everyone's already on the exit row, then * we'll have already gone to the next screen above.) */ diff --git a/src/ScreenOptionsManageProfiles.cpp b/src/ScreenOptionsManageProfiles.cpp index e85911f68b..7d312554c2 100644 --- a/src/ScreenOptionsManageProfiles.cpp +++ b/src/ScreenOptionsManageProfiles.cpp @@ -264,7 +264,7 @@ void ScreenOptionsManageProfiles::HandleScreenMessage( const ScreenMessage SM ) switch( ScreenMiniMenu::s_iLastRowCode ) { default: - ASSERT(0); + FAIL_M(ssprintf("Last row code not a valid ProfileAction: %i", ScreenMiniMenu::s_iLastRowCode)); case ProfileAction_SetDefaultP1: case ProfileAction_SetDefaultP2: { diff --git a/src/ScreenPrompt.cpp b/src/ScreenPrompt.cpp index 5ae2ed4505..666a700a39 100644 --- a/src/ScreenPrompt.cpp +++ b/src/ScreenPrompt.cpp @@ -142,9 +142,8 @@ bool ScreenPrompt::CanGoRight() case PROMPT_YES_NO_CANCEL: return m_Answer < ANSWER_CANCEL; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid PromptType: %i", g_PromptType)); } - return false; } void ScreenPrompt::Change( int dir ) diff --git a/src/ScreenRanking.cpp b/src/ScreenRanking.cpp index 2f63dd08de..7788f97df8 100644 --- a/src/ScreenRanking.cpp +++ b/src/ScreenRanking.cpp @@ -238,7 +238,8 @@ float ScreenRanking::SetPage( const PageToShow &pts ) m_textTime[l].SetDiffuseColor( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); } - switch( RANKING_TYPE ) + RankingType rtype = RANKING_TYPE; + switch( rtype ) { case RankingType_Category: { @@ -332,8 +333,7 @@ float ScreenRanking::SetPage( const PageToShow &pts ) } return SECONDS_PER_PAGE; default: - ASSERT(0); - return 0; + FAIL_M(ssprintf("Invalid RankingType: %i", rtype)); } } diff --git a/src/ScreenSelectCharacter.cpp b/src/ScreenSelectCharacter.cpp index b50030a87b..86d68c811e 100644 --- a/src/ScreenSelectCharacter.cpp +++ b/src/ScreenSelectCharacter.cpp @@ -193,10 +193,10 @@ PlayerNumber ScreenSelectCharacter::GetAffectedPlayerNumber( PlayerNumber pn ) return pn; case CHOOSING_CPU_CHARACTER: return CPU_PLAYER[pn]; - default: - ASSERT(0); case FINISHED_CHOOSING: 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 break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid character selection state: %i", m_SelectionRow[pn])); } } diff --git a/src/ScreenSelectMusic.cpp b/src/ScreenSelectMusic.cpp index 3db0c37271..7c594519a6 100644 --- a/src/ScreenSelectMusic.cpp +++ b/src/ScreenSelectMusic.cpp @@ -654,7 +654,7 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) } else { - ASSERT(0); + FAIL_M("Logic bug: L/R keys in an impossible state?"); } // Reset the repeat timer when the button is released. @@ -1701,7 +1701,9 @@ void ScreenSelectMusic::AfterMusicChange() s_lastSortOrder = GAMESTATE->m_SortOrder; } - switch( m_MusicWheel.GetSelectedType() ) + WheelItemDataType wtype = m_MusicWheel.GetSelectedType(); + SampleMusicPreviewMode pmode; + switch( wtype ) { case WheelItemDataType_Section: case WheelItemDataType_Sort: @@ -1728,7 +1730,7 @@ void ScreenSelectMusic::AfterMusicChange() m_fSampleLengthSeconds = -1; } - switch( m_MusicWheel.GetSelectedType() ) + switch( wtype ) { case WheelItemDataType_Section: // reduce scope @@ -1776,7 +1778,7 @@ void ScreenSelectMusic::AfterMusicChange() } break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid WheelItemDataType: %i", wtype)); } // override this if the sample music mode wants to. /* @@ -1792,7 +1794,8 @@ void ScreenSelectMusic::AfterMusicChange() case WheelItemDataType_Song: case WheelItemDataType_Portal: // check SampleMusicPreviewMode here. - switch( SAMPLE_MUSIC_PREVIEW_MODE ) + pmode = SAMPLE_MUSIC_PREVIEW_MODE; + switch( pmode ) { case SampleMusicPreviewMode_ScreenMusic: // play the screen music @@ -1812,7 +1815,7 @@ void ScreenSelectMusic::AfterMusicChange() m_fSampleLengthSeconds = pSong->m_fMusicSampleLengthSeconds; break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid preview mode: %i", pmode)); } SongUtil::GetPlayableSteps( pSong, m_vpSteps ); @@ -1848,7 +1851,7 @@ void ScreenSelectMusic::AfterMusicChange() break; } default: - ASSERT(0); + FAIL_M(ssprintf("Invalid WheelItemDataType: %i", wtype)); } m_sprCDTitleFront.UnloadTexture(); diff --git a/src/ScreenServiceAction.cpp b/src/ScreenServiceAction.cpp index 07968dc275..71bc884c04 100644 --- a/src/ScreenServiceAction.cpp +++ b/src/ScreenServiceAction.cpp @@ -165,7 +165,7 @@ static RString TransferStatsMemoryCardToMachine() s = ssprintf(PROFILE_CORRUPT.GetValue(),pn+1); break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid profile load result: %i", lr)); } MEMCARDMAN->UnmountCard(pn); diff --git a/src/ScreenSetTime.cpp b/src/ScreenSetTime.cpp index c76e914a57..2ca906dd34 100644 --- a/src/ScreenSetTime.cpp +++ b/src/ScreenSetTime.cpp @@ -128,7 +128,8 @@ void ScreenSetTime::ChangeValue( int iDirection ) case year: adjusted.tm_year += iDirection; break; case month: adjusted.tm_mon += iDirection; break; case day: adjusted.tm_mday += iDirection; break; - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid SetTimeSelection: %i", m_Selection)); } /* Normalize: */ diff --git a/src/ScreenSyncOverlay.cpp b/src/ScreenSyncOverlay.cpp index 5797634cc1..f8580fde21 100644 --- a/src/ScreenSyncOverlay.cpp +++ b/src/ScreenSyncOverlay.cpp @@ -102,22 +102,26 @@ void ScreenSyncOverlay::UpdateText() if( g_bShowAutoplay ) { - switch( GamePreferences::m_AutoPlay.Get() ) + PlayerController pc = GamePreferences::m_AutoPlay.Get(); + switch( pc ) { case PC_HUMAN: break; case PC_AUTOPLAY: vs.push_back(AUTO_PLAY); 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_SONG: vs.push_back(AUTO_SYNC_SONG); break; case SongOptions::AUTOSYNC_MACHINE: vs.push_back(AUTO_SYNC_MACHINE); 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 @@ -287,7 +291,7 @@ bool ScreenSyncOverlay::OverlayInput( const InputEventPlus &input ) } break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid sync action choice: %i", a)); } ShowHelp(); diff --git a/src/ScreenSystemLayer.cpp b/src/ScreenSystemLayer.cpp index 69cb90cc69..830ad78f18 100644 --- a/src/ScreenSystemLayer.cpp +++ b/src/ScreenSystemLayer.cpp @@ -97,7 +97,8 @@ namespace } else // bShowCreditsMessage { - switch( GAMESTATE->GetCoinMode() ) + CoinMode mode = GAMESTATE->GetCoinMode(); + switch( mode ) { case CoinMode_Home: if( GAMESTATE->PlayersCanJoin() ) @@ -126,7 +127,7 @@ namespace return CREDITS_NOT_PRESENT.GetValue(); default: - ASSERT(0); + FAIL_M(ssprintf("Invalid CoinMode: %i", mode)); } } } diff --git a/src/ScreenUnlockBrowse.cpp b/src/ScreenUnlockBrowse.cpp index 49d3f8a1ab..8d0c908225 100644 --- a/src/ScreenUnlockBrowse.cpp +++ b/src/ScreenUnlockBrowse.cpp @@ -11,10 +11,11 @@ void ScreenUnlockBrowse::Init() FOREACH_CONST( UnlockEntry, UNLOCKMAN->m_UnlockEntries, ue ) { GameCommand gc; - switch( ue->GetUnlockEntryStatus() ) + UnlockEntryStatus st = ue->GetUnlockEntryStatus(); + switch( st ) { default: - ASSERT(0); + FAIL_M(ssprintf("Invalid UnlockEntryStatus: %i", st)); case UnlockEntryStatus_RequirementsMet: case UnlockEntryStatus_Unlocked: gc.m_bInvalid = false; diff --git a/src/SongManager.cpp b/src/SongManager.cpp index 6664e0410d..0558824d46 100644 --- a/src/SongManager.cpp +++ b/src/SongManager.cpp @@ -1144,8 +1144,7 @@ Song *SongManager::GetSongFromSteps( Steps *pSteps ) const } } } - ASSERT(0); - return NULL; + FAIL_M("No song found for steps"); } void SongManager::DeleteSteps( Steps *pSteps ) diff --git a/src/SongOptions.cpp b/src/SongOptions.cpp index de846681b3..6580f729a0 100644 --- a/src/SongOptions.cpp +++ b/src/SongOptions.cpp @@ -75,7 +75,8 @@ void SongOptions::GetMods( vector &AddTo ) const case LIFE_TIME: AddTo.push_back( "LifeTime" ); break; - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid LifeType: %i", m_LifeType)); } @@ -95,7 +96,8 @@ void SongOptions::GetMods( vector &AddTo ) const case AUTOSYNC_SONG: AddTo.push_back("AutosyncSong"); break; case AUTOSYNC_MACHINE: AddTo.push_back("AutosyncMachine"); 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 ) @@ -103,7 +105,8 @@ void SongOptions::GetMods( vector &AddTo ) const case SOUNDEFFECT_OFF: break; case SOUNDEFFECT_SPEED: AddTo.push_back("EffectSpeed"); 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 ) diff --git a/src/SongUtil.cpp b/src/SongUtil.cpp index cf32736c62..8b03b31233 100644 --- a/src/SongUtil.cpp +++ b/src/SongUtil.cpp @@ -581,7 +581,8 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so { case SORT_TITLE: s = pSong->GetTranslitMainTitle(); 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 @@ -667,8 +668,7 @@ RString SongUtil::GetSectionNameFromSongAndSort( const Song* pSong, SortOrder so case SORT_ONI_COURSES: case SORT_ENDLESS_COURSES: default: - ASSERT(0); - return RString(); + FAIL_M(ssprintf("Invalid SortOrder: %i", so)); } } @@ -782,9 +782,8 @@ RString SongUtil::MakeUniqueEditDescription( const Song *pSong, StepsType st, co return sTemp; } - // Edit limit guards should keep us from ever having more than 1000 edits per song. - ASSERT(0); - return RString(); + // Edit limit guards should prevent this + FAIL_M("Exceeded limit of 1000 edits per song"); } static LocalizedString YOU_MUST_SUPPLY_NAME ( "SongUtil", "You must supply a name for your new edit." ); diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 239361fe00..f68e0ef9ce 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -639,7 +639,7 @@ bool CheckVideoDefaultSettings() goto found_defaults; } } - ASSERT( 0 ); // we must have matched at least one above + FAIL_M("Failed to match video driver"); found_defaults: @@ -1072,7 +1072,7 @@ int main(int argc, char* argv[]) case Dialog::no: break; default: - ASSERT(0); + FAIL_M("Invalid response to Yes/No dialog"); } } else if( version_num < current_version ) diff --git a/src/Texture Font Generator/TextureFont.cpp b/src/Texture Font Generator/TextureFont.cpp index 4df8b4dce3..640d74965b 100644 --- a/src/Texture Font Generator/TextureFont.cpp +++ b/src/Texture Font Generator/TextureFont.cpp @@ -482,7 +482,7 @@ void TextureFont::Save( CString sBasePath, CString sBitmapAppendBeforeExtension, sPageName += "-stroke"; break; default: - ASSERT(0); + FAIL_M(ssprintf("Unexpected value for j: %i", j)); } CString sFile; diff --git a/src/ThemeManager.cpp b/src/ThemeManager.cpp index df2cb8d187..c61a941ef3 100644 --- a/src/ThemeManager.cpp +++ b/src/ThemeManager.cpp @@ -962,7 +962,7 @@ RString ThemeManager::GetMetricRaw( const IniFile &ini, const RString &sMetricsG sDefaultMetricPath.c_str() ); return RString(); default: - ASSERT(0); + FAIL_M("Unexpected answer to Abort/Retry/Ignore dialog"); } } } diff --git a/src/TimingData.cpp b/src/TimingData.cpp index 71bb51d804..9fb9668cce 100644 --- a/src/TimingData.cpp +++ b/src/TimingData.cpp @@ -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 ) @@ -954,8 +954,7 @@ void TimingData::NoteRowToMeasureAndBeat( int iNoteRow, int &iMeasureIndexOut, i } } - ASSERT(0); - return; + FAIL_M("Failed to get measure and beat for note row"); } vector TimingData::ToVectorString(TimingSegmentType tst, int dec) const diff --git a/src/Tween.cpp b/src/Tween.cpp index c1779bf3bc..69021d0e14 100644 --- a/src/Tween.cpp +++ b/src/Tween.cpp @@ -84,7 +84,8 @@ ITween *ITween::CreateFromType( TweenType tt ) case TWEEN_ACCELERATE: return new TweenAccelerate; case TWEEN_DECELERATE: return new TweenDecelerate; case TWEEN_SPRING: return new TweenSpring; - default: ASSERT(0); + default: + FAIL_M(ssprintf("Invalid TweenType: %i", tt)); } } diff --git a/src/UnlockManager.cpp b/src/UnlockManager.cpp index 8599f33e51..687a4025c8 100644 --- a/src/UnlockManager.cpp +++ b/src/UnlockManager.cpp @@ -418,8 +418,7 @@ RString UnlockEntry::GetDescription() const switch( m_Type ) { default: - ASSERT(0); - return ""; + FAIL_M(ssprintf("Invalid UnlockRewardType: %i", m_Type)); case UnlockRewardType_Song: return pSong ? pSong->GetDisplayFullTitle() : ""; case UnlockRewardType_Steps: @@ -446,8 +445,7 @@ RString UnlockEntry::GetBannerFile() const switch( m_Type ) { default: - ASSERT(0); - return ""; + FAIL_M(ssprintf("Invalid UnlockRewardType: %i", m_Type)); case UnlockRewardType_Song: case UnlockRewardType_Steps: case UnlockRewardType_Steps_Type: @@ -465,8 +463,7 @@ RString UnlockEntry::GetBackgroundFile() const switch( m_Type ) { default: - ASSERT(0); - return ""; + FAIL_M(ssprintf("Invalid UnlockRewardType: %i", m_Type)); case UnlockRewardType_Song: case UnlockRewardType_Steps: case UnlockRewardType_Steps_Type: @@ -631,7 +628,7 @@ void UnlockManager::Load() // nothing to cache break; default: - ASSERT(0); + FAIL_M(ssprintf("Invalid UnlockRewardType: %i", e->m_Type)); } } diff --git a/src/WheelBase.cpp b/src/WheelBase.cpp index 006ac400f0..51f8905e61 100644 --- a/src/WheelBase.cpp +++ b/src/WheelBase.cpp @@ -273,8 +273,7 @@ void WheelBase::UpdateSwitch() case STATE_LOCKED: break; default: - ASSERT(0); // all state changes should be handled explicitly - break; + FAIL_M(ssprintf("Invalid wheel state: %i", m_WheelState)); } } diff --git a/src/arch/Dialog/DialogDriver_Win32.cpp b/src/arch/Dialog/DialogDriver_Win32.cpp index 1849f70c1c..967cd7c1f0 100644 --- a/src/arch/Dialog/DialogDriver_Win32.cpp +++ b/src/arch/Dialog/DialogDriver_Win32.cpp @@ -183,10 +183,8 @@ static BOOL CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP break; case IDC_BUTTON_RESTART: Win32RestartProgram(); - // not reached - ASSERT( 0 ); - EndDialog( hWnd, 0 ); - break; + // Possibly make W32RP a NORETURN call? + FAIL_M("Win32RestartProgram failed?"); case IDOK: EndDialog( hWnd, 0 ); break; @@ -242,8 +240,9 @@ Dialog::Result DialogDriver_Win32::AbortRetryIgnore( RString sMessage, RString I { case IDABORT: return Dialog::abort; case IDRETRY: return Dialog::retry; - default: ASSERT(0); 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 ) { case IDRETRY: return Dialog::retry; - default: ASSERT(0); 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 ) { case IDYES: return Dialog::yes; - default: ASSERT(0); case IDNO: return Dialog::no; + default: + FAIL_M(ssprintf("Unexpected response to Yes/No dialog: %i", iRet)); } } diff --git a/src/arch/InputHandler/InputHandler_DirectInput.cpp b/src/arch/InputHandler/InputHandler_DirectInput.cpp index 42d8387441..d1078726e9 100644 --- a/src/arch/InputHandler/InputHandler_DirectInput.cpp +++ b/src/arch/InputHandler/InputHandler_DirectInput.cpp @@ -269,7 +269,7 @@ void InputHandler_DInput::UpdatePolled( DIDevice &device, const RageTimer &tm ) switch( device.type ) { default: - ASSERT(0); + FAIL_M(ssprintf("Unsupported DI device type: %i", device.type)); case device.KEYBOARD: { unsigned char keys[256]; diff --git a/src/arch/MovieTexture/MovieTexture_DShow.cpp b/src/arch/MovieTexture/MovieTexture_DShow.cpp index 8e04007a52..55a1b7970e 100644 --- a/src/arch/MovieTexture/MovieTexture_DShow.cpp +++ b/src/arch/MovieTexture/MovieTexture_DShow.cpp @@ -452,10 +452,11 @@ void MovieTexture_DShow::CreateTexture() return; PixelFormat pixfmt; - switch( TEXTUREMAN->GetPrefs().m_iMovieColorDepth ) + int depth = TEXTUREMAN->GetPrefs().m_iMovieColorDepth; + switch( depth ) { default: - ASSERT(0); + FAIL_M(ssprintf("Unsupported movie color depth: %i", depth)); case 16: if( DISPLAY->SupportsTextureFormat(PixelFormat_RGB5) ) pixfmt = PixelFormat_RGB5; diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp index 8c75ef5ff5..5d1ba2ea80 100644 --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -154,7 +154,8 @@ static void FixLilEndian() { case 24: m = Swap24(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; } diff --git a/src/arch/MovieTexture/MovieTexture_Generic.cpp b/src/arch/MovieTexture/MovieTexture_Generic.cpp index e3f1ea0aee..21f9e313d2 100644 --- a/src/arch/MovieTexture/MovieTexture_Generic.cpp +++ b/src/arch/MovieTexture/MovieTexture_Generic.cpp @@ -232,10 +232,11 @@ void MovieTexture_Generic::CreateTexture() { /* We weren't given a natively-supported pixel format. Pick a supported * 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: - ASSERT(0); + FAIL_M(ssprintf("Unsupported movie color depth: %i", depth)); case 16: if( DISPLAY->SupportsTextureFormat(PixelFormat_RGB5) ) pixfmt = PixelFormat_RGB5;