Skip to content

Commit 0ca28a9

Browse files
committed
Fix: Handle train.dat files with duplicated #MOTOR section header
e.g irtc99 Korean subway
1 parent cb68f71 commit 0ca28a9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

source/OpenBVE/Parsers/Train/TrainDatParser.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,15 @@ internal static void ParseTrainData(string FileName, System.Text.Encoding Encodi
786786
} m++;
787787
} i++; n++;
788788
}
789-
Array.Resize<TrainManager.MotorSoundTableEntry>(ref Tables[msi].Entries, n);
789+
790+
if (n != 0)
791+
{
792+
/*
793+
* Handle duplicated section header:
794+
* If no entries, don't resize
795+
*/
796+
Array.Resize<TrainManager.MotorSoundTableEntry>(ref Tables[msi].Entries, n);
797+
}
790798
i--;
791799
} break;
792800
}

0 commit comments

Comments
 (0)