private void parseSections(Song2014 xml, Sng2014File sng)
{
sng.Sections = new SectionSection();
sng.Sections.Count = xml.Sections.Length;
sng.Sections.Sections = new Section[sng.Sections.Count];
for (int i = 0; i < sng.Sections.Count; i++)
{
var section = xml.Sections[i];
var s = new Section();
readString(section.Name, s.Name);
s.Number = section.Number;
s.StartTime = section.StartTime;
if (i + 1 < sng.Sections.Count)
s.EndTime = xml.Sections[i + 1].StartTime;
else
s.EndTime = xml.SongLength;
s.StartPhraseIterationId = getPhraseIterationId(xml, s.StartTime, false);
s.EndPhraseIterationId = getPhraseIterationId(xml, s.EndTime, true);
for (int j = getMaxDifficulty(xml); j >= 0; j--)
{
// used string mask for section at all difficulty j
Byte mask = 0;
foreach (var note in xml.Levels[j].Notes)
if (note.Time >= s.StartTime && note.Time < s.EndTime)
{
mask |= (Byte)(1 << note.String);
}
foreach (var chord in xml.Levels[j].Chords)
if (chord.Time >= s.StartTime && chord.Time < s.EndTime)
{
var ch = xml.ChordTemplates[chord.ChordId];
if (ch.Fret0 != -1)
mask |= (Byte)(1 << 0);
if (ch.Fret1 != -1)
mask |= (Byte)(1 << 1);
if (ch.Fret2 != -1)
mask |= (Byte)(1 << 2);
if (ch.Fret3 != -1)
mask |= (Byte)(1 << 3);
if (ch.Fret4 != -1)
mask |= (Byte)(1 << 4);
if (ch.Fret5 != -1)
mask |= (Byte)(1 << 5);
if (mask == 0x3F)
break;
}
// use mask from next section if there are no notes
if (mask == 0 && j < getMaxDifficulty(xml))
mask = s.StringMask[j + 1];
s.StringMask[j] = mask;
}
sng.Sections.Sections[i] = s;
}
}