bool CPatternContainer::IsPatternEmpty(const PATTERNINDEX nPat) const //------------------------------------------------------------------- { if(!IsValidPat(nPat)) return false; const ModCommand *m = m_Patterns[nPat].m_ModCommands; for(size_t i = m_Patterns[nPat].GetNumChannels() * m_Patterns[nPat].GetNumRows(); i > 0; i--, m++) { if(!m->IsEmpty(true)) return false; } return true; }
bool CPatternContainer::IsPatternEmpty(const modplug::tracker::patternindex_t nPat) const //------------------------------------------------------------------- { if(!IsValidPat(nPat)) return false; const modplug::tracker::modevent_t *m = m_Patterns[nPat].m_ModCommands; for(size_t i = m_Patterns[nPat].GetNumChannels() * m_Patterns[nPat].GetNumRows(); i > 0; i--, m++) { if(!m->IsEmpty(true)) return false; } return true; }
PATTERNINDEX CPatternContainer::GetNumPatterns() const //---------------------------------------------------- { if(Size() == 0) { return 0; } for(PATTERNINDEX nPat = Size(); nPat > 0; nPat--) { if(IsValidPat(nPat - 1)) { return nPat; } } return 0; }
PATTERNINDEX CPatternContainer::Duplicate(PATTERNINDEX from) //---------------------------------------------------------- { if(!IsValidPat(from)) { return PATTERNINDEX_INVALID; } const CPattern &oldPat = m_Patterns[from]; PATTERNINDEX newPatIndex = Insert(oldPat.GetNumRows()); if(newPatIndex != PATTERNINDEX_INVALID) { CPattern &newPat = m_Patterns[newPatIndex]; memcpy(newPat.m_ModCommands, oldPat.m_ModCommands, newPat.GetNumChannels() * newPat.GetNumRows() * sizeof(ModCommand)); newPat.m_Rows = oldPat.m_Rows; newPat.m_RowsPerBeat = oldPat.m_RowsPerBeat; newPat.m_RowsPerMeasure = oldPat.m_RowsPerMeasure; newPat.m_PatternName = oldPat.m_PatternName; } return newPatIndex; }