mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
MADS: Don't use intermediary struct
This commit is contained in:
committed by
Filippos Karapetis
parent
41dab15c41
commit
7ef2db032e
@@ -43,13 +43,29 @@ MpsInstaller* MpsInstaller::open(const Common::Path& baseName) {
|
||||
|
||||
uint32 indexSize = indexFile.size();
|
||||
|
||||
if (filecnt > (indexSize - 12) / sizeof(FileDescriptorBin))
|
||||
filecnt = (indexSize - 12) / sizeof(FileDescriptorBin);
|
||||
static const int kNameFieldLength = 0x52;
|
||||
static const int kEntryLength = kNameFieldLength + 0x10;
|
||||
|
||||
if (filecnt > (indexSize - 12) / kEntryLength)
|
||||
filecnt = (indexSize - 12) / kEntryLength;
|
||||
|
||||
for (uint i = 0; i < filecnt; i++) {
|
||||
FileDescriptorBin descBin;
|
||||
indexFile.read(&descBin, sizeof(descBin));
|
||||
FileDescriptor desc(descBin);
|
||||
char nameField[kNameFieldLength];
|
||||
int nameLen = kNameFieldLength;
|
||||
indexFile.read(nameField, kNameFieldLength);
|
||||
for (uint j = 0; j < kNameFieldLength; j++) {
|
||||
if (!nameField[j]) {
|
||||
nameLen = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint16 compression = indexFile.readUint16LE();
|
||||
uint16 volumeNumber = indexFile.readUint16LE();
|
||||
uint32 offsetInVolume = indexFile.readUint32LE();
|
||||
uint32 compressedSize = indexFile.readUint32LE();
|
||||
uint32 uncompressedSize = indexFile.readUint32LE();
|
||||
Common::String name(nameField, nameLen);
|
||||
FileDescriptor desc(name, compression, volumeNumber, offsetInVolume, compressedSize, uncompressedSize);
|
||||
_files[desc._fileName] = desc;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,19 +30,6 @@
|
||||
|
||||
namespace MADS {
|
||||
|
||||
#include "common/pack-start.h" // START STRUCT PACKING
|
||||
|
||||
struct FileDescriptorBin {
|
||||
char name[0x52]; // zero-terminated, rest is filled with what looks like garbage
|
||||
uint16 compression;
|
||||
uint16 volumeNumber;
|
||||
uint32 offsetInVolume;
|
||||
uint32 compressedSize;
|
||||
uint32 uncompressedSize;
|
||||
} PACKED_STRUCT;
|
||||
|
||||
#include "common/pack-end.h" // END STRUCT PACKING
|
||||
|
||||
class MpsInstaller : public Common::Archive {
|
||||
public:
|
||||
bool hasFile(const Common::Path &path) const override;
|
||||
@@ -63,12 +50,18 @@ private:
|
||||
_offsetInVolume(0),
|
||||
_volumeNumber(0) {}
|
||||
protected:
|
||||
FileDescriptor(const FileDescriptorBin &raw) : _fileName(raw.name),
|
||||
_compressedSize(FROM_LE_32(raw.compressedSize)),
|
||||
_uncompressedSize(FROM_LE_32(raw.uncompressedSize)),
|
||||
_compressionAlgo(FROM_LE_16(raw.compression)),
|
||||
_offsetInVolume(FROM_LE_32(raw.offsetInVolume)),
|
||||
_volumeNumber(FROM_LE_16(raw.volumeNumber)) {}
|
||||
FileDescriptor(const Common::String& name,
|
||||
uint16 compression,
|
||||
uint16 volumeNumber,
|
||||
uint32 offsetInVolume,
|
||||
uint32 compressedSize,
|
||||
uint32 uncompressedSize) :
|
||||
_fileName(name),
|
||||
_compressionAlgo(compression),
|
||||
_volumeNumber(volumeNumber),
|
||||
_offsetInVolume(offsetInVolume),
|
||||
_compressedSize(compressedSize),
|
||||
_uncompressedSize(uncompressedSize) {}
|
||||
|
||||
Common::String _fileName;
|
||||
uint _compressionAlgo;
|
||||
|
||||
Reference in New Issue
Block a user