partman: improved bad zMap skip.

This commit is contained in:
Muzychenko Andrey 2021-11-23 15:23:11 +03:00
parent 37198f1b99
commit 95007c9253

View File

@ -92,16 +92,18 @@ DatFile* partman::load_records(LPCSTR lpFileName, bool fullTiltMode)
fread(&zMapHeader, 1, sizeof(dat16BitBmpHeader), fileHandle); fread(&zMapHeader, 1, sizeof(dat16BitBmpHeader), fileHandle);
auto length = fieldSize - sizeof(dat16BitBmpHeader); auto length = fieldSize - sizeof(dat16BitBmpHeader);
auto zMap = new zmap_header_type(zMapHeader.Width, zMapHeader.Height, zMapHeader.Stride); zmap_header_type* zMap;
zMap->Resolution = zMapResolution;
if (zMapHeader.Stride * zMapHeader.Height * 2u == length) 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); fread(zMap->ZPtr1, 1, length, fileHandle);
} }
else else
{ {
// 3DPB .dat has zeroed zMap headers, in groups 497 and 498, skip them. // 3DPB .dat has zeroed zMap headers, in groups 497 and 498, skip them.
fseek(fileHandle, static_cast<int>(length), SEEK_CUR); fseek(fileHandle, static_cast<int>(length), SEEK_CUR);
zMap = new zmap_header_type(0, 0, 0);
} }
entryData->Buffer = reinterpret_cast<char*>(zMap); entryData->Buffer = reinterpret_cast<char*>(zMap);
} }