void HighScoreImpl::LoadFromNode( const XNode *pNode ) { ASSERT( pNode->GetName() == "HighScore" ); RString s; pNode->GetChildValue( "Name", sName ); pNode->GetChildValue( "Grade", s ); grade = StringToGrade( s ); pNode->GetChildValue( "Score", iScore ); pNode->GetChildValue( "PercentDP", fPercentDP ); pNode->GetChildValue( "SurviveSeconds", fSurviveSeconds ); pNode->GetChildValue( "MaxCombo", iMaxCombo ); pNode->GetChildValue( "StageAward", s ); stageAward = StringToStageAward(s); pNode->GetChildValue( "PeakComboAward", s ); peakComboAward = StringToPeakComboAward(s); pNode->GetChildValue( "Modifiers", sModifiers ); pNode->GetChildValue( "DateTime", s ); dateTime.FromString( s ); pNode->GetChildValue( "PlayerGuid", sPlayerGuid ); pNode->GetChildValue( "MachineGuid", sMachineGuid ); pNode->GetChildValue( "ProductID", iProductID ); const XNode* pTapNoteScores = pNode->GetChild( "TapNoteScores" ); if( pTapNoteScores ) FOREACH_ENUM( TapNoteScore, tns ) pTapNoteScores->GetChildValue( TapNoteScoreToString(tns), iTapNoteScores[tns] ); const XNode* pHoldNoteScores = pNode->GetChild( "HoldNoteScores" ); if( pHoldNoteScores ) FOREACH_ENUM( HoldNoteScore, hns ) pHoldNoteScores->GetChildValue( HoldNoteScoreToString(hns), iHoldNoteScores[hns] ); const XNode* pRadarValues = pNode->GetChild( "RadarValues" ); if( pRadarValues ) radarValues.LoadFromNode( pRadarValues ); pNode->GetChildValue( "LifeRemainingSeconds", fLifeRemainingSeconds ); pNode->GetChildValue( "Disqualified", bDisqualified); // Validate input. grade = clamp( grade, Grade_Tier01, Grade_Failed ); }
void RadarValues::FromString( RString sRadarValues ) { vector<RString> saValues; split( sRadarValues, ",", saValues, true ); if( saValues.size() != NUM_RadarCategory ) { MakeUnknown(); return; } FOREACH_ENUM( RadarCategory, rc ) m_Values.f[rc] = StringToFloat( saValues[rc] ); }
template<bool avx> void ALWAYSINLINE storeColors(__m_auto_i* dest, const __m_auto_i p) { alignas(avx ? 32 : 16)static __m_auto_i colors[FieldColors::numOfColors] = { _mmauto_set1_epi32(0xff7f7f7f), //none _mmauto_set1_epi32(0xffffffff), //white _mmauto_set1_epi32(0xff000000), //black _mmauto_set1_epi32(0xff00ff00), //green _mmauto_set1_epi32(0xff0000ff), //own team color _mmauto_set1_epi32(0xffff0000) //opponent team color }; __m_auto_i result = _mmauto_setzero_si_all(); FOREACH_ENUM((FieldColors) Color, i) result = _mmauto_or_si_all(result, _mmauto_and_si_all(_mmauto_cmpeq_epi32(p, _mmauto_set1_epi32(i)), colors[i])); _mmauto_storet_si_all<true>(dest, result); }
void Course::Init() { m_bIsAutogen = false; m_sPath = ""; m_sMainTitle = ""; m_sMainTitleTranslit = ""; m_sSubTitle = ""; m_sSubTitleTranslit = ""; m_sScripter = ""; m_sDescription = ""; m_sBannerPath = ""; m_sBackgroundPath = ""; m_sCDTitlePath = ""; m_sGroupName = ""; m_bRepeat = false; m_fGoalSeconds = 0; m_bShuffle = false; m_iLives = -1; FOREACH_ENUM( Difficulty,dc) m_iCustomMeter[dc] = -1; m_bSortByMeter = false; m_vEntries.clear(); m_SortOrder_TotalDifficulty = 0; m_SortOrder_Ranking = 0; m_LoadedFromProfile = ProfileSlot_Invalid; m_bIncomplete = false; m_TrailCache.clear(); m_iTrailCacheSeed = 0; m_RadarCache.clear(); }
void ScreenEvaluation::Init() { LOG->Trace( "ScreenEvaluation::Init()" ); // debugging // Only fill StageStats with fake info if we're the InitialScreen // (i.e. StageStats not already filled) if( PREFSMAN->m_sTestInitialScreen.Get() == m_sName ) { PROFILEMAN->LoadFirstAvailableProfile(PLAYER_1); PROFILEMAN->LoadFirstAvailableProfile(PLAYER_2); STATSMAN->m_vPlayedStageStats.clear(); STATSMAN->m_vPlayedStageStats.push_back( StageStats() ); StageStats &ss = STATSMAN->m_vPlayedStageStats.back(); GAMESTATE->m_PlayMode.Set( PLAY_MODE_REGULAR ); GAMESTATE->SetCurrentStyle( GAMEMAN->GameAndStringToStyle(GAMEMAN->GetDefaultGame(),"versus"), PLAYER_INVALID ); ss.m_playMode = GAMESTATE->m_PlayMode; ss.m_Stage = Stage_1st; enum_add( ss.m_Stage, rand()%3 ); ss.m_EarnedExtraStage = (EarnedExtraStage)(rand() % NUM_EarnedExtraStage); GAMESTATE->SetMasterPlayerNumber(PLAYER_1); GAMESTATE->m_pCurSong.Set( SONGMAN->GetRandomSong() ); ss.m_vpPlayedSongs.push_back( GAMESTATE->m_pCurSong ); ss.m_vpPossibleSongs.push_back( GAMESTATE->m_pCurSong ); GAMESTATE->m_pCurCourse.Set( SONGMAN->GetRandomCourse() ); GAMESTATE->m_iCurrentStageIndex = 0; FOREACH_ENUM( PlayerNumber, p ) GAMESTATE->m_iPlayerStageTokens[p] = 1; FOREACH_PlayerNumber( p ) { ss.m_player[p].m_pStyle = GAMESTATE->GetCurrentStyle(p); if( RandomInt(2) ) PO_GROUP_ASSIGN_N( GAMESTATE->m_pPlayerState[p]->m_PlayerOptions, ModsLevel_Stage, m_bTransforms, PlayerOptions::TRANSFORM_ECHO, true ); // show "disqualified" SO_GROUP_ASSIGN( GAMESTATE->m_SongOptions, ModsLevel_Stage, m_fMusicRate, 1.1f ); GAMESTATE->JoinPlayer( p ); GAMESTATE->m_pCurSteps[p].Set( GAMESTATE->m_pCurSong->GetAllSteps()[0] ); if( GAMESTATE->m_pCurCourse ) { vector<Trail*> apTrails; GAMESTATE->m_pCurCourse->GetAllTrails( apTrails ); if( apTrails.size() ) GAMESTATE->m_pCurTrail[p].Set( apTrails[0] ); } ss.m_player[p].m_vpPossibleSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] ); ss.m_player[p].m_iStepsPlayed = 1; PO_GROUP_ASSIGN( GAMESTATE->m_pPlayerState[p]->m_PlayerOptions, ModsLevel_Stage, m_fScrollSpeed, 2.0f ); PO_GROUP_CALL( GAMESTATE->m_pPlayerState[p]->m_PlayerOptions, ModsLevel_Stage, ChooseRandomModifiers ); } for( float f = 0; f < 100.0f; f += 1.0f ) { float fP1 = fmodf(f/100*4+.3f,1); ss.m_player[PLAYER_1].SetLifeRecordAt( fP1, f ); ss.m_player[PLAYER_2].SetLifeRecordAt( 1-fP1, f ); } FOREACH_PlayerNumber( p ) { float fSeconds = GAMESTATE->m_pCurSong->GetStepsSeconds(); ss.m_player[p].m_iActualDancePoints = RandomInt( 3 ); ss.m_player[p].m_iPossibleDancePoints = 2; if( RandomInt(2) ) ss.m_player[p].m_iCurCombo = RandomInt(15000); else ss.m_player[p].m_iCurCombo = 0; ss.m_player[p].UpdateComboList( 0, true ); ss.m_player[p].m_iCurCombo += 50; ss.m_player[p].UpdateComboList( 0.10f * fSeconds, false ); ss.m_player[p].m_iCurCombo = 0; ss.m_player[p].UpdateComboList( 0.15f * fSeconds, false ); ss.m_player[p].m_iCurCombo = 1; ss.m_player[p].UpdateComboList( 0.25f * fSeconds, false ); ss.m_player[p].m_iCurCombo = 50; ss.m_player[p].UpdateComboList( 0.35f * fSeconds, false ); ss.m_player[p].m_iCurCombo = 0; ss.m_player[p].UpdateComboList( 0.45f * fSeconds, false ); ss.m_player[p].m_iCurCombo = 1; ss.m_player[p].UpdateComboList( 0.50f * fSeconds, false ); ss.m_player[p].m_iCurCombo = 100; ss.m_player[p].UpdateComboList( 1.00f * fSeconds, false ); if( RandomInt(5) == 0 ) { ss.m_player[p].m_bFailed = true; } ss.m_player[p].m_iTapNoteScores[TNS_W1] = RandomInt( 3 ); ss.m_player[p].m_iTapNoteScores[TNS_W2] = RandomInt( 3 ); ss.m_player[p].m_iTapNoteScores[TNS_W3] = RandomInt( 3 ); ss.m_player[p].m_iPossibleGradePoints = 4*ScoreKeeperNormal::TapNoteScoreToGradePoints(TNS_W1, false); ss.m_player[p].m_fLifeRemainingSeconds = randomf( 90, 580 ); ss.m_player[p].m_iScore = rand() % (900*1000*1000); ss.m_player[p].m_iPersonalHighScoreIndex = (rand() % 3) - 1; ss.m_player[p].m_iMachineHighScoreIndex = (rand() % 3) - 1; ss.m_player[p].m_PeakComboAward = (PeakComboAward)(rand()%NUM_PeakComboAward); ss.m_player[p].m_StageAward = (StageAward)(rand()%NUM_StageAward); FOREACH_ENUM( RadarCategory, rc ) { switch( rc ) { case RadarCategory_Stream: case RadarCategory_Voltage: case RadarCategory_Air: case RadarCategory_Freeze: case RadarCategory_Chaos: ss.m_player[p].m_radarPossible[rc] = randomf( 0, 1 ); ss.m_player[p].m_radarActual[rc] = randomf( 0, ss.m_player[p].m_radarPossible[rc] ); break; case RadarCategory_TapsAndHolds: case RadarCategory_Jumps: case RadarCategory_Holds: case RadarCategory_Mines: case RadarCategory_Hands: case RadarCategory_Rolls: case RadarCategory_Lifts: case RadarCategory_Fakes: ss.m_player[p].m_radarPossible[rc] = 1 + (rand() % 200); ss.m_player[p].m_radarActual[rc] = rand() % (int)(ss.m_player[p].m_radarPossible[rc]); break; default: break; } ; // filled in by ScreenGameplay on start of notes } } }
void RadarValues::Zero() { FOREACH_ENUM( RadarCategory, rc ) m_Values.f[rc] = 0; }
void RadarValues::MakeUnknown() { FOREACH_ENUM( RadarCategory, rc ) m_Values.f[rc] = RADAR_VAL_UNKNOWN; }
void ScreenJukebox::SetSong() { ThemeMetric<bool> ALLOW_ADVANCED_MODIFIERS(m_sName,"AllowAdvancedModifiers"); vector<Song*> vSongs; /* Check to see if there is a theme course. If there is a course that has * the exact same name as the theme, then we pick a song from this course. */ Course *pCourse = SONGMAN->GetCourseFromName( THEME->GetCurThemeName() ); if( pCourse != NULL ) for ( unsigned i = 0; i < pCourse->m_vEntries.size(); i++ ) if( pCourse->m_vEntries[i].IsFixedSong() ) vSongs.push_back( pCourse->m_vEntries[i].songID.ToSong() ); if ( vSongs.size() == 0 ) vSongs = SONGMAN->GetSongs( GAMESTATE->m_sPreferredSongGroup ); // Still nothing? if( vSongs.size() == 0 ) return; // Calculate what difficulties to show vector<Difficulty> vDifficultiesToShow; if( m_bDemonstration ) { // HACK: This belongs in ScreenDemonstration. ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW_HERE(m_sName,"DifficultiesToShow"); vDifficultiesToShow = DIFFICULTIES_TO_SHOW_HERE.GetValue(); } else { if( GAMESTATE->m_PreferredDifficulty[PLAYER_1] != Difficulty_Invalid ) { vDifficultiesToShow.push_back( GAMESTATE->m_PreferredDifficulty[PLAYER_1] ); } else { FOREACH_ENUM( Difficulty, dc ) vDifficultiesToShow.push_back( dc ); } } ASSERT( !vDifficultiesToShow.empty() ); // Search for a Song and Steps to play during the demo. for( int i=0; i<1000; i++ ) { Song* pSong = vSongs[RandomInt(vSongs.size())]; ASSERT( pSong != NULL ); if( !pSong->HasMusic() ) continue; // skip if( !pSong->NormallyDisplayed() ) continue; if( !pSong->ShowInDemonstrationAndRanking() ) continue; // skip Difficulty dc = vDifficultiesToShow[ RandomInt(vDifficultiesToShow.size()) ]; Steps* pSteps = SongUtil::GetStepsByDifficulty( pSong, GAMESTATE->GetCurrentStyle()->m_StepsType, dc ); if( pSteps == NULL ) continue; // skip if( !PREFSMAN->m_bAutogenSteps && pSteps->IsAutogen()) continue; // skip // Found something we can use! GAMESTATE->m_pCurSong.Set( pSong ); // We just changed the song. Reset the original sync data. AdjustSync::ResetOriginalSyncData(); FOREACH_PlayerNumber( p ) GAMESTATE->m_pCurSteps[p].Set( pSteps ); bool bShowModifiers = randomf(0,1) <= SHOW_COURSE_MODIFIERS_PROBABILITY; if( bShowModifiers ) { /* If we have a modifier course containing this song, apply its * modifiers. Only check fixed course entries. */ vector<Course*> apCourses; SONGMAN->GetAllCourses( apCourses, false ); vector<const CourseEntry *> apOptions; vector<Course*> apPossibleCourses; for( unsigned j = 0; j < apCourses.size(); ++j ) { Course *lCourse = apCourses[j]; const CourseEntry *pEntry = lCourse->FindFixedSong( pSong ); if( pEntry == NULL || pEntry->attacks.size() == 0 ) continue; if( !ALLOW_ADVANCED_MODIFIERS ) { // There are some confusing mods that we don't want to show in demonstration. bool bModsAreOkToShow = true; AttackArray aAttacks = pEntry->attacks; if( !pEntry->sModifiers.empty() ) aAttacks.push_back( Attack::FromGlobalCourseModifier( pEntry->sModifiers ) ); FOREACH_CONST( Attack, aAttacks, a ) { RString s = a->sModifiers; s.MakeLower(); // todo: allow themers to modify this list? -aj if( s.find("dark") != string::npos || s.find("stealth") != string::npos ) { bModsAreOkToShow = false; break; } } if( !bModsAreOkToShow ) continue; // skip } apOptions.push_back( pEntry ); apPossibleCourses.push_back( pCourse ); } if( !apOptions.empty() ) { int iIndex = RandomInt( apOptions.size() ); m_pCourseEntry = apOptions[iIndex]; Course *lCourse = apPossibleCourses[iIndex]; PlayMode pm = CourseTypeToPlayMode( lCourse->GetCourseType() ); GAMESTATE->m_PlayMode.Set( pm ); GAMESTATE->m_pCurCourse.Set( lCourse ); FOREACH_PlayerNumber( p ) { GAMESTATE->m_pCurTrail[p].Set( lCourse->GetTrail( GAMESTATE->GetCurrentStyle()->m_StepsType ) ); ASSERT( GAMESTATE->m_pCurTrail[p] != NULL ); } }