HDB: Move the readMPC function to the file-manager

This commit is contained in:
Nipun Garg 2019-05-28 17:42:23 +05:30 committed by Eugene Sandulenko
parent 432ae5ad57
commit 6082037f74
2 changed files with 9 additions and 75 deletions

View File

@ -54,6 +54,8 @@ Common::Error HDBGame::run() {
_console = new Console();
//readMPC("hyperdemo.mpc");
Common::String s1("Tests");
while (!shouldQuit()) {
@ -83,48 +85,5 @@ Common::Error HDBGame::run() {
return Common::kNoError;
}
/*
void HDBGame::readMPC(const Common::String &filename) {
if (!_file.open(filename)) {
error("readMPC(): Error reading MPC file");
} else {
_dataHeader.signature[0] = _file.readByte();
_dataHeader.signature[1] = _file.readByte();
_dataHeader.signature[2] = _file.readByte();
_dataHeader.signature[3] = _file.readByte();
_dataHeader.signature[4] = '\0';
if (_dataHeader.isValid()) {
_dataHeader.dirOffset = _file.readUint32LE();
// FIXME: The MPC archive format considers dirOffset to be a uint32.
// However, File::seekg() takes an int32 as the offset, hence this
// would break if the dirOffset was larger than 2^31.
_file.seek((int32)_dataHeader.dirOffset, SEEK_SET);
_dataHeader.dirSize = _file.readUint32LE();
for (uint32 fileIndex = 0; fileIndex < _dataHeader.dirSize; fileIndex++) {
DataFile* dirEntry = new DataFile();
for (int fileNameIndex = 0; fileNameIndex < 64; fileNameIndex++) {
dirEntry->fileName[fileNameIndex] = _file.readByte();
}
dirEntry->fileName[64] = '\0';
dirEntry->filePosition = _file.readUint32LE();
dirEntry->fileLength = _file.readUint32LE();
dirEntry->unknownField1 = _file.readUint32LE();
dirEntry->unknownField2 = _file.readUint32LE();
_gameData.push_back(dirEntry);
}
} else {
debug("Invalid MPC file");
}
}
}*/
} // End of namespace HDB

View File

@ -40,15 +40,11 @@
#define GFX_CACHE_LIMIT 0x800000
/*
Subsystems
Subsystem Includes
*/
#include "file-manager.h"
/*
Game System Singletons
*/
struct ADGameDescription;
namespace HDB {
@ -72,34 +68,13 @@ public:
private:
Console *_console;
Common::File _file;
/*
Game System Pointers
*/
struct {
byte signature[5]; // 4 Bytes + '\0'
uint32 dirOffset;
uint32 dirSize;
bool isValid() {
return (signature[0] == 'M') &&
(signature[1] == 'P') &&
(signature[2] == 'C') &&
(signature[3] == 'U') &&
(signature[4] == '\0');
}
} _dataHeader;
struct DataFile {
byte fileName[65]; // 65 Bytes + '\0'
uint32 filePosition;
uint32 fileLength;
uint32 unknownField1;
uint32 unknownField2;
};
Common::Array<DataFile*> _gameData;
void readMPC(const Common::String &fileName);
FileMan* _fileMan;
};
}// End of namespace HDB