From 829f49f6227034d1c7313331ddc6f6f5ac3bf01e Mon Sep 17 00:00:00 2001 From: sukibaby <163092272+sukibaby@users.noreply.github.com> Date: Sun, 2 Jun 2024 21:16:38 -0700 Subject: [PATCH] Fix NotesLoaderDWI.cpp This resolves the following issues with DWI format simfiles: - DWI files containing valid charts may fail to load and appear to have 0 or 1 notes - DWI files opened in the editor would not save the original contents of the chart into a new file --- src/NotesLoaderDWI.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/NotesLoaderDWI.cpp b/src/NotesLoaderDWI.cpp index 331a13695a..b2ea1d5ee5 100644 --- a/src/NotesLoaderDWI.cpp +++ b/src/NotesLoaderDWI.cpp @@ -190,6 +190,12 @@ static StepsType GetTypeFromMode(const RString &mode) static NoteData ParseNoteData(RString &step1, RString &step2, Steps &out, const RString &path) { + if (step1.size() < 2 && step2.size() < 2) + { + LOG->Warn("Didn't get enough data when attempting to load a DWI file"); + // Handle the error by returning an empty NoteData object + return NoteData(); + } g_mapDanceNoteToNoteDataColumn.clear(); switch( out.m_StepsType ) { @@ -300,7 +306,7 @@ static NoteData ParseNoteData(RString &step1, RString &step2, /* It's a jump. * We need to keep reading notes until we hit a >. */ jump = true; - i++; + c = sStepData[i++]; } const int iIndex = BeatToNoteRow( (float)fCurrentBeat ); @@ -355,6 +361,10 @@ static NoteData ParseNoteData(RString &step1, RString &step2, iIndex, TAP_ORIGINAL_HOLD_HEAD); } + + if (jump && i < sStepData.size()) { + c = sStepData[i++]; + } } while( jump ); fCurrentBeat += fCurrentIncrementer;