From 95007c92539ead46102f2494cfc00f3a1cdff10c Mon Sep 17 00:00:00 2001 From: Muzychenko Andrey <33288308+k4zmu2a@users.noreply.github.com> Date: Tue, 23 Nov 2021 15:23:11 +0300 Subject: [PATCH] partman: improved bad zMap skip. --- SpaceCadetPinball/partman.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SpaceCadetPinball/partman.cpp b/SpaceCadetPinball/partman.cpp index 16d811c..2901d74 100644 --- a/SpaceCadetPinball/partman.cpp +++ b/SpaceCadetPinball/partman.cpp @@ -92,16 +92,18 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode) fread(&zMapHeader, 1, sizeof(dat16BitBmpHeader), fileHandle); auto length = fieldSize - sizeof(dat16BitBmpHeader); - auto zMap = new zmap_header_type(zMapHeader.Width, zMapHeader.Height, zMapHeader.Stride); - zMap->Resolution = zMapResolution; + zmap_header_type* zMap; if (zMapHeader.Stride * zMapHeader.Height * 2u == length) { + zMap = new zmap_header_type(zMapHeader.Width, zMapHeader.Height, zMapHeader.Stride); + zMap->Resolution = zMapResolution; fread(zMap->ZPtr1, 1, length, fileHandle); } else { // 3DPB .dat has zeroed zMap headers, in groups 497 and 498, skip them. fseek(fileHandle, static_cast(length), SEEK_CUR); + zMap = new zmap_header_type(0, 0, 0); } entryData->Buffer = reinterpret_cast(zMap); }