void HLFscheduler::all_combinations(vector<task_id> nums, unsigned int n, unsigned int minindex, const Intree& t, const vector<unsigned int>& referencelevels, vector<task_id>& current, vector<vector<task_id>>& target) const { if(n==0){ for(unsigned int i=0; i<current.size(); ++i){ if(t.get_level(current[i]) != referencelevels[i]) return; if(t.get_in_degree(current[i]) > 0) return; } target.push_back(current); return; } if(nums.size() - minindex <= n) return; for(unsigned int i=minindex+1; i<nums.size(); ++i){ vector<task_id> newcombo(current); newcombo.push_back(nums[i]); all_combinations(nums, n-1, i, t, referencelevels, newcombo, target); } }
void PlayerStageStats::AddStats( const PlayerStageStats& other ) { m_bJoined = other.m_bJoined; FOREACH_CONST( Steps*, other.m_vpPossibleSteps, s ) m_vpPossibleSteps.push_back( *s ); m_iStepsPlayed += other.m_iStepsPlayed; m_fAliveSeconds += other.m_fAliveSeconds; m_bFailed |= other.m_bFailed; m_iPossibleDancePoints += other.m_iPossibleDancePoints; m_iActualDancePoints += other.m_iActualDancePoints; m_iCurPossibleDancePoints += other.m_iCurPossibleDancePoints; m_iPossibleGradePoints += other.m_iPossibleGradePoints; for( int t=0; t<NUM_TapNoteScore; t++ ) m_iTapNoteScores[t] += other.m_iTapNoteScores[t]; for( int h=0; h<NUM_HoldNoteScore; h++ ) m_iHoldNoteScores[h] += other.m_iHoldNoteScores[h]; m_iCurCombo += other.m_iCurCombo; m_iMaxCombo += other.m_iMaxCombo; m_iCurMissCombo += other.m_iCurMissCombo; m_iScore += other.m_iScore; m_iMaxScore += other.m_iMaxScore; m_iCurMaxScore += other.m_iCurMaxScore; m_radarPossible += other.m_radarPossible; m_radarActual += other.m_radarActual; m_iSongsPassed += other.m_iSongsPassed; m_iSongsPlayed += other.m_iSongsPlayed; m_iNumControllerSteps += other.m_iNumControllerSteps; m_fCaloriesBurned += other.m_fCaloriesBurned; m_fLifeRemainingSeconds = other.m_fLifeRemainingSeconds; // don't accumulate m_bDisqualified |= other.m_bDisqualified; const float fOtherFirstSecond = other.m_fFirstSecond + m_fLastSecond; const float fOtherLastSecond = other.m_fLastSecond + m_fLastSecond; m_fLastSecond = fOtherLastSecond; map<float,float>::const_iterator it; for( it = other.m_fLifeRecord.begin(); it != other.m_fLifeRecord.end(); ++it ) { const float pos = it->first; const float life = it->second; m_fLifeRecord[fOtherFirstSecond+pos] = life; } for( unsigned i=0; i<other.m_ComboList.size(); ++i ) { const Combo_t &combo = other.m_ComboList[i]; Combo_t newcombo(combo); newcombo.m_fStartSecond += fOtherFirstSecond; m_ComboList.push_back( newcombo ); } /* Merge identical combos. This normally only happens in course mode, when * a combo continues between songs. */ for( unsigned i=1; i<m_ComboList.size(); ++i ) { Combo_t &prevcombo = m_ComboList[i-1]; Combo_t &combo = m_ComboList[i]; const float PrevComboEnd = prevcombo.m_fStartSecond + prevcombo.m_fSizeSeconds; const float ThisComboStart = combo.m_fStartSecond; if( fabsf(PrevComboEnd - ThisComboStart) > 0.001 ) continue; // These are really the same combo. prevcombo.m_fSizeSeconds += combo.m_fSizeSeconds; prevcombo.m_cnt += combo.m_cnt; m_ComboList.erase( m_ComboList.begin()+i ); --i; } }
void StageStats::AddStats( const StageStats& other ) { ASSERT( !other.vpSongs.empty() ); FOREACH_CONST( Song*, other.vpSongs, s ) vpSongs.push_back( *s ); StageType = STAGE_INVALID; // meaningless memset( fAliveSeconds, 0, sizeof(fAliveSeconds) ); // why not accumulate? -Chris fGameplaySeconds += other.fGameplaySeconds; FOREACH_PlayerNumber( p ) { FOREACH_CONST( Steps*, other.vpSteps[p], s ) vpSteps[p].push_back( *s ); fAliveSeconds[p] += other.fAliveSeconds[p]; bFailed[p] |= other.bFailed[p]; bFailedEarlier[p] |= other.bFailedEarlier[p]; iPossibleDancePoints[p] += other.iPossibleDancePoints[p]; iActualDancePoints[p] += other.iActualDancePoints[p]; for( int t=0; t<NUM_TAP_NOTE_SCORES; t++ ) iTapNoteScores[p][t] += other.iTapNoteScores[p][t]; for( int h=0; h<NUM_HOLD_NOTE_SCORES; h++ ) iHoldNoteScores[p][h] += other.iHoldNoteScores[p][h]; iCurCombo[p] += other.iCurCombo[p]; iMaxCombo[p] += other.iMaxCombo[p]; iCurMissCombo[p] += other.iCurMissCombo[p]; iScore[p] += other.iScore[p]; radarPossible[p] += other.radarPossible[p]; radarActual[p] += other.radarActual[p]; fSecondsBeforeFail[p] += other.fSecondsBeforeFail[p]; iSongsPassed[p] += other.iSongsPassed[p]; iSongsPlayed[p] += other.iSongsPlayed[p]; iTotalError[p] += other.iTotalError[p]; const float fOtherFirstSecond = other.fFirstSecond[p] + fLastSecond[p]; const float fOtherLastSecond = other.fLastSecond[p] + fLastSecond[p]; fLastSecond[p] = fOtherLastSecond; map<float,float>::const_iterator it; for( it = other.fLifeRecord[p].begin(); it != other.fLifeRecord[p].end(); ++it ) { const float pos = it->first; const float life = it->second; fLifeRecord[p][fOtherFirstSecond+pos] = life; } unsigned i; for( i=0; i<other.ComboList[p].size(); ++i ) { const Combo_t &combo = other.ComboList[p][i]; Combo_t newcombo(combo); newcombo.fStartSecond += fOtherFirstSecond; ComboList[p].push_back( newcombo ); } /* Merge identical combos. This normally only happens in course mode, when a combo * continues between songs. */ for( i=1; i<ComboList[p].size(); ++i ) { Combo_t &prevcombo = ComboList[p][i-1]; Combo_t &combo = ComboList[p][i]; const float PrevComboEnd = prevcombo.fStartSecond + prevcombo.fSizeSeconds; const float ThisComboStart = combo.fStartSecond; if( fabsf(PrevComboEnd - ThisComboStart) > 0.001 ) continue; /* These are really the same combo. */ prevcombo.fSizeSeconds += combo.fSizeSeconds; prevcombo.cnt += combo.cnt; ComboList[p].erase( ComboList[p].begin()+i ); --i; } } }