- moved NeedFileStart out of the lump flag word into an empty part of the FZipLump structure.

This commit is contained in:
Christoph Oelckers 2020-04-11 13:15:37 +02:00
parent a38633aa22
commit 025e80b74a
2 changed files with 8 additions and 11 deletions

View file

@ -340,7 +340,8 @@ bool FZipFile::Open(bool quiet)
lump_p->LumpSize = LittleLong(zip_fh->UncompressedSize); lump_p->LumpSize = LittleLong(zip_fh->UncompressedSize);
lump_p->Owner = this; lump_p->Owner = this;
// The start of the Reader will be determined the first time it is accessed. // The start of the Reader will be determined the first time it is accessed.
lump_p->Flags = LUMPF_ZIPFILE | LUMPFZIP_NEEDFILESTART; lump_p->Flags = LUMPF_ZIPFILE;
lump_p->NeedFileStart = true;
lump_p->Method = uint8_t(zip_fh->Method); lump_p->Method = uint8_t(zip_fh->Method);
if (lump_p->Method != METHOD_STORED) lump_p->Flags |= LUMPF_COMPRESSED; if (lump_p->Method != METHOD_STORED) lump_p->Flags |= LUMPF_COMPRESSED;
lump_p->GPFlags = zip_fh->Flags; lump_p->GPFlags = zip_fh->Flags;
@ -382,7 +383,7 @@ FZipFile::~FZipFile()
FCompressedBuffer FZipLump::GetRawData() FCompressedBuffer FZipLump::GetRawData()
{ {
FCompressedBuffer cbuf = { (unsigned)LumpSize, (unsigned)CompressedSize, Method, GPFlags, CRC32, new char[CompressedSize] }; FCompressedBuffer cbuf = { (unsigned)LumpSize, (unsigned)CompressedSize, Method, GPFlags, CRC32, new char[CompressedSize] };
if (Flags & LUMPFZIP_NEEDFILESTART) SetLumpAddress(); if (NeedFileStart) SetLumpAddress();
Owner->Reader.Seek(Position, FileReader::SeekSet); Owner->Reader.Seek(Position, FileReader::SeekSet);
Owner->Reader.Read(cbuf.mBuffer, CompressedSize); Owner->Reader.Read(cbuf.mBuffer, CompressedSize);
return cbuf; return cbuf;
@ -406,7 +407,7 @@ void FZipLump::SetLumpAddress()
Owner->Reader.Read(&localHeader, sizeof(localHeader)); Owner->Reader.Read(&localHeader, sizeof(localHeader));
skiplen = LittleShort(localHeader.NameLength) + LittleShort(localHeader.ExtraLength); skiplen = LittleShort(localHeader.NameLength) + LittleShort(localHeader.ExtraLength);
Position += sizeof(localHeader) + skiplen; Position += sizeof(localHeader) + skiplen;
Flags &= ~LUMPFZIP_NEEDFILESTART; NeedFileStart = false;
} }
//========================================================================== //==========================================================================
@ -421,7 +422,7 @@ FileReader *FZipLump::GetReader()
// In that case always force caching of the lump // In that case always force caching of the lump
if (Method == METHOD_STORED) if (Method == METHOD_STORED)
{ {
if (Flags & LUMPFZIP_NEEDFILESTART) SetLumpAddress(); if (NeedFileStart) SetLumpAddress();
Owner->Reader.Seek(Position, FileReader::SeekSet); Owner->Reader.Seek(Position, FileReader::SeekSet);
return &Owner->Reader; return &Owner->Reader;
} }
@ -436,7 +437,7 @@ FileReader *FZipLump::GetReader()
int FZipLump::FillCache() int FZipLump::FillCache()
{ {
if (Flags & LUMPFZIP_NEEDFILESTART) SetLumpAddress(); if (NeedFileStart) SetLumpAddress();
const char *buffer; const char *buffer;
if (Method == METHOD_STORED && (buffer = Owner->Reader.GetBuffer()) != NULL) if (Method == METHOD_STORED && (buffer = Owner->Reader.GetBuffer()) != NULL)
@ -463,7 +464,7 @@ int FZipLump::FillCache()
int FZipLump::GetFileOffset() int FZipLump::GetFileOffset()
{ {
if (Method != METHOD_STORED) return -1; if (Method != METHOD_STORED) return -1;
if (Flags & LUMPFZIP_NEEDFILESTART) SetLumpAddress(); if (NeedFileStart) SetLumpAddress();
return Position; return Position;
} }

View file

@ -3,11 +3,6 @@
#include "resourcefile.h" #include "resourcefile.h"
enum
{
LUMPFZIP_NEEDFILESTART = 128
};
//========================================================================== //==========================================================================
// //
// Zip Lump // Zip Lump
@ -18,6 +13,7 @@ struct FZipLump : public FResourceLump
{ {
uint16_t GPFlags; uint16_t GPFlags;
uint8_t Method; uint8_t Method;
bool NeedFileStart;
int CompressedSize; int CompressedSize;
int Position; int Position;
unsigned CRC32; unsigned CRC32;