private static void ReadCarIDs(Stream file, ArcadeCar[] cars) { for (int i = 0; i < cars.Length; i++) { cars[i] = new ArcadeCar { ID = file.ReadCharacters() }; file.MoveToNextMultipleOf(8); } }
static void Main(string[] args) { using (var file = File.Open("arcade", FileMode.Open, FileAccess.Read)) { file.Position = CarCounts; ArcadeCar[] classS = new ArcadeCar[file.ReadUShort()]; ArcadeCar[] classA = new ArcadeCar[file.ReadUShort()]; ArcadeCar[] classB = new ArcadeCar[file.ReadUShort()]; ArcadeCar[] classC = new ArcadeCar[file.ReadUShort()]; file.Position += 4; // skip two counts of 00 04 - home garage? ArcadeCar[] classR = new ArcadeCar[file.ReadUShort()]; file.Position = CarIDs; ReadCarIDs(file, classS); ReadCarIDs(file, classA); ReadCarIDs(file, classB); ReadCarIDs(file, classC); ReadCarIDs(file, classR); ReadCarStatsAndWriteCSV(file, classS, ClassSBars, "ClassS"); ReadCarStatsAndWriteCSV(file, classA, ClassABars, "ClassA"); ReadCarStatsAndWriteCSV(file, classB, ClassBBars, "ClassB"); ReadCarStatsAndWriteCSV(file, classC, ClassCBars, "ClassC"); ReadCarStatsAndWriteCSV(file, classR, ClassRBars, "ClassR"); } }