private static void ReadSpecialNotes(SQLiteConnection connection, Score score)
 {
     using (var table = new DataTable()) {
         SQLiteHelper.ReadSpecialNotesTable(connection, score.Difficulty, table);
         foreach (DataRow row in table.Rows)
         {
             var id           = new Guid((byte[])row[SldprojDbNames.Column_ID]);
             var barIndex     = (int)(long)row[SldprojDbNames.Column_BarIndex];
             var grid         = (int)(long)row[SldprojDbNames.Column_IndexInGrid];
             var type         = (int)(long)row[SldprojDbNames.Column_NoteType];
             var paramsString = (string)row[SldprojDbNames.Column_ParamValues];
             if (barIndex >= score.Bars.Count)
             {
                 continue;
             }
             var bar = score.Bars[barIndex];
             // Special notes are not added during the ReadScores() process, so we call AddNote() rather than AddNoteWithoutUpdatingGlobalNotes().
             var note = bar.Notes.FirstOrDefault(n => n.Basic.Type == (NoteType)type && n.Basic.IndexInGrid == grid);
             if (note == null)
             {
                 note = bar.AddSpecialNote(id, (NoteType)type);
                 note.Basic.IndexInGrid = grid;
                 note.Params            = NoteExtraParams.FromDataString(paramsString, note);
             }
             else
             {
                 note.Params.UpdateByDataString(paramsString);
             }
         }
     }
 }
示例#2
0
        private static void ReadSpecialNotes(SQLiteConnection connection, Score score)
        {
            using (var table = new DataTable()) {
                SQLiteHelper.ReadSpecialNotesTable(connection, score.Difficulty, table);
                foreach (DataRow row in table.Rows)
                {
                    var id           = (int)(long)row[SldprojDbNames.Column_ID];
                    var barIndex     = (int)(long)row[SldprojDbNames.Column_BarIndex];
                    var grid         = (int)(long)row[SldprojDbNames.Column_IndexInGrid];
                    var type         = (int)(long)row[SldprojDbNames.Column_NoteType];
                    var paramsString = (string)row[SldprojDbNames.Column_ParamValues];
                    if (barIndex >= score.Bars.Count)
                    {
                        continue;
                    }
                    var bar = score.Bars[barIndex];
                    // Special notes are not added during the ReadScores() process, so we call AddNote() rather than AddNoteWithoutUpdatingGlobalNotes().
                    var note = bar.Notes.FirstOrDefault(n => n.Basic.Type == (NoteType)type && n.Basic.IndexInGrid == grid);
                    if (note == null)
                    {
                        note = bar.AddSpecialNote(id, (NoteType)type);
                        note.Basic.IndexInGrid = grid;
                        note.Params            = NoteExtraParams.FromDataString(paramsString, note);
                    }
                    else
                    {
                        note.Params.UpdateByDataString(paramsString);
                    }

                    // 2017-04-27: Fix the f**king negative grid line problem.
                    // But the unfixed version passed every test except the hit testing one, I don't know why. :(
                    // It occurs in some projects saved by certain old versions. It could be caused by
                    // incorrectly inserting variant BPM notes. But I don't know the definition of "incorrectly",
                    // and these problematic projects can't be loaded even by the versions that created them.
                    // I observed this behavior on v0.7.5, but I think it can also happen on any versions after
                    // v0.5.0, in which the variant BPM note is introducted.
                    if (note.Basic.Type == NoteType.VariantBpm)
                    {
                        var originalBar = bar;
                        var newBar      = originalBar;
                        while (note.Basic.IndexInGrid < 0)
                        {
                            bar = score.Bars[barIndex];
                            note.Basic.IndexInGrid += bar.GetNumberOfGrids();
                            newBar = bar;
                            --barIndex;
                        }
                        if (newBar != originalBar)
                        {
                            originalBar.RemoveSpecialNoteForVariantBpmFix(note);
                            var newNote = newBar.AddSpecialNote(id, (NoteType)type);
                            newNote.Basic.IndexInGrid = note.Basic.IndexInGrid;
                            newNote.Params            = note.Params;
                        }
                    }
                }
            }
        }