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;
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) );
}
}
+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 );
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<Actor*>::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 );
+2 -2
View File
@@ -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");
}
}
+8 -6
View File
@@ -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() );
+5 -5
View File
@@ -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));
}
}
+1 -1
View File
@@ -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));
}
}
+10 -5
View File
@@ -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));
}
}
+6 -3
View File
@@ -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));
}
}
+1 -1
View File
@@ -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;
+14 -10
View File
@@ -52,7 +52,8 @@ void EditMenu::StripLockedStepsAndDifficulty( vector<StepsAndDifficulty> &v )
void EditMenu::GetSongsToShowForGroup( const RString &sGroup, vector<Song*> &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<Song*> &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));
}
}
+1 -1
View File
@@ -690,7 +690,7 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
}
break;
default:
ASSERT(0);
FAIL_M(ssprintf("Invalid StyleType: %i", m_pStyle->m_StyleType));
}
}
if( m_dc != Difficulty_Invalid )
+2 -4
View File
@@ -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<const Style*> &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 )
+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
}
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<RankingFeat> &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;
+2 -3
View File
@@ -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));
}
}
+3 -2
View File
@@ -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));
}
}
+1 -1
View File
@@ -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));
}
}
+10 -7
View File
@@ -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 );
+4 -2
View File
@@ -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;
}
+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 )
+3 -3
View File
@@ -762,7 +762,8 @@ void MusicWheel::BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelIt
FOREACH_ENUM( CourseType, i )
vct.push_back( i );
break;
default: ASSERT(0); break;
default:
FAIL_M(ssprintf("Wrong sort order: %i", so));
}
vector<Course*> 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));
}
}
+1 -1
View File
@@ -1173,7 +1173,7 @@ XNode* NoteData::CreateNode() const
void NoteData::LoadFromNode( const XNode* pNode )
{
ASSERT(0);
FAIL_M("NoteData::LoadFromNode() not implemented");
}
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
* 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 );
+3 -2
View File
@@ -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));
}
}
+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_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
+1 -1
View File
@@ -87,7 +87,7 @@ static void DWIcharToNote( char c, GameController i, int &note1Out, int &note2Ou
note2Out += 6;
break;
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);
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()) );
+2 -1
View File
@@ -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;
+3 -3
View File
@@ -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; c<m_textItems.size(); c++ )
@@ -632,7 +632,7 @@ void OptionRow::UpdateEnabledDisabled()
}
break;
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;
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() ) );
+5 -6
View File
@@ -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, vector<TrackRowTap
break;
*/
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;
*/
default:
ASSERT(0);
score = TNS_None;
break;
FAIL_M(ssprintf("Invalid player controller type: %i", m_pPlayerState->m_PlayerController));
}
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_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" ); }
+4 -11
View File
@@ -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!");
}
}
+5 -3
View File
@@ -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));
}
}
+7 -4
View File
@@ -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);
}
+8 -5
View File
@@ -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 &param, 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);
}
+7 -3
View File
@@ -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));
}
}
+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_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
+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 )
@@ -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));
}
}
+4 -2
View File
@@ -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;
+5 -2
View File
@@ -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();
+1 -1
View File
@@ -281,7 +281,7 @@ void ScreenBookkeeping::UpdateView()
}
break;
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 )
{
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; }
+1 -1
View File
@@ -4445,7 +4445,7 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &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 );
*/
+6 -6
View File
@@ -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));
}
}
+8 -7
View File
@@ -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<PlayerInfo>::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;
}
+6 -4
View File
@@ -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;
+3 -4
View File
@@ -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.) */
+1 -1
View File
@@ -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:
{
+1 -2
View File
@@ -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 )
+3 -3
View File
@@ -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));
}
}
+3 -3
View File
@@ -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]));
}
}
+10 -7
View File
@@ -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();
+1 -1
View File
@@ -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);
+2 -1
View File
@@ -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: */
+9 -5
View File
@@ -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();
+3 -2
View File
@@ -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));
}
}
}
+3 -2
View File
@@ -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;
+1 -2
View File
@@ -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 )
+6 -3
View File
@@ -75,7 +75,8 @@ void SongOptions::GetMods( vector<RString> &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<RString> &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<RString> &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 )
+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_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." );
+2 -2
View File
@@ -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 )
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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");
}
}
}
+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 )
@@ -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<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_DECELERATE: return new TweenDecelerate;
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 )
{
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));
}
}
+1 -2
View File
@@ -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));
}
}
+8 -7
View File
@@ -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));
}
}
@@ -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];
+3 -2
View File
@@ -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;
@@ -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;
}
@@ -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;