mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-06 10:17:14 +00:00
ADL: Migrate engine to Path
This commit is contained in:
parent
e1aeab81f5
commit
4b00b7e83d
@ -54,7 +54,7 @@ class RandomSource;
|
||||
|
||||
namespace Adl {
|
||||
|
||||
Common::String getDiskImageName(const AdlGameDescription &adlDesc, byte volume);
|
||||
Common::Path getDiskImageName(const AdlGameDescription &adlDesc, byte volume);
|
||||
GameType getGameType(const AdlGameDescription &desc);
|
||||
GameVersion getGameVersion(const AdlGameDescription &desc);
|
||||
Common::Language getLanguage(const AdlGameDescription &desc);
|
||||
@ -267,7 +267,7 @@ protected:
|
||||
Common::String getSaveStateName(int slot) const override;
|
||||
int getAutosaveSlot() const override { return 15; }
|
||||
|
||||
Common::String getDiskImageName(byte volume) const { return Adl::getDiskImageName(*_gameDescription, volume); }
|
||||
Common::Path getDiskImageName(byte volume) const { return Adl::getDiskImageName(*_gameDescription, volume); }
|
||||
GameType getGameType() const { return Adl::getGameType(*_gameDescription); }
|
||||
GameVersion getGameVersion() const { return Adl::getGameVersion(*_gameDescription); }
|
||||
Common::Language getLanguage() const { return Adl::getLanguage(*_gameDescription); }
|
||||
|
@ -118,22 +118,22 @@ bool Console::Cmd_ValidCommands(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Console::dumpScripts(const Common::String &prefix) {
|
||||
void Console::dumpScripts(const Common::Path &prefix) {
|
||||
for (byte roomNr = 1; roomNr <= _engine->_state.rooms.size(); ++roomNr) {
|
||||
_engine->loadRoom(roomNr);
|
||||
if (_engine->_roomData.commands.size() != 0) {
|
||||
_engine->_dumpFile->open(prefix + Common::String::format("%03d.ADL", roomNr).c_str());
|
||||
_engine->_dumpFile->open(prefix.append(Common::String::format("%03d.ADL", roomNr)));
|
||||
_engine->doAllCommands(_engine->_roomData.commands, IDI_ANY, IDI_ANY);
|
||||
_engine->_dumpFile->close();
|
||||
}
|
||||
}
|
||||
_engine->loadRoom(_engine->_state.room);
|
||||
|
||||
_engine->_dumpFile->open(prefix + "GLOBAL.ADL");
|
||||
_engine->_dumpFile->open(prefix.append("GLOBAL.ADL"));
|
||||
_engine->doAllCommands(_engine->_globalCommands, IDI_ANY, IDI_ANY);
|
||||
_engine->_dumpFile->close();
|
||||
|
||||
_engine->_dumpFile->open(prefix + "RESPONSE.ADL");
|
||||
_engine->_dumpFile->open(prefix.append("RESPONSE.ADL"));
|
||||
_engine->doAllCommands(_engine->_roomCommands, IDI_ANY, IDI_ANY);
|
||||
_engine->_dumpFile->close();
|
||||
}
|
||||
@ -159,7 +159,7 @@ bool Console::Cmd_DumpScripts(int argc, const char **argv) {
|
||||
|
||||
for (byte regionNr = 1; regionNr <= _engine->_state.regions.size(); ++regionNr) {
|
||||
_engine->switchRegion(regionNr);
|
||||
dumpScripts(Common::String::format("%03d-", regionNr));
|
||||
dumpScripts(Common::Path(Common::String::format("%03d-", regionNr)));
|
||||
}
|
||||
|
||||
_engine->switchRegion(oldRegion);
|
||||
|
@ -60,7 +60,7 @@ private:
|
||||
|
||||
void printItem(const Item &item);
|
||||
void printWordMap(const Common::HashMap<Common::String, uint> &wordMap);
|
||||
void dumpScripts(const Common::String &prefix = Common::String());
|
||||
void dumpScripts(const Common::Path &prefix = Common::Path());
|
||||
void prepareGame();
|
||||
|
||||
AdlEngine *_engine;
|
||||
|
@ -465,10 +465,10 @@ public:
|
||||
|
||||
ADDetectedGames detectGame(const Common::FSNode &parent, const FileMap &allFiles, Common::Language language, Common::Platform platform, const Common::String &extra, uint32 skipADFlags, bool skipIncomplete) override;
|
||||
|
||||
bool addFileProps(const FileMap &allFiles, Common::String fname, FilePropertiesMap &filePropsMap) const;
|
||||
bool addFileProps(const FileMap &allFiles, const Common::Path &fname, FilePropertiesMap &filePropsMap) const;
|
||||
};
|
||||
|
||||
bool AdlMetaEngineDetection::addFileProps(const FileMap &allFiles, Common::String fname, FilePropertiesMap &filePropsMap) const {
|
||||
bool AdlMetaEngineDetection::addFileProps(const FileMap &allFiles, const Common::Path &fname, FilePropertiesMap &filePropsMap) const {
|
||||
if (filePropsMap.contains(fname))
|
||||
return true;
|
||||
|
||||
@ -479,7 +479,7 @@ bool AdlMetaEngineDetection::addFileProps(const FileMap &allFiles, Common::Strin
|
||||
fileProps.size = computeMD5(allFiles[fname], fileProps.md5, 16384);
|
||||
|
||||
if (fileProps.size != -1) {
|
||||
debugC(3, kDebugGlobalDetection, "> '%s': '%s'", fname.c_str(), fileProps.md5.c_str());
|
||||
debugC(3, kDebugGlobalDetection, "> '%s': '%s'", fname.toString().c_str(), fileProps.md5.c_str());
|
||||
filePropsMap[fname] = fileProps;
|
||||
}
|
||||
|
||||
@ -494,7 +494,7 @@ ADDetectedGames AdlMetaEngineDetection::detectGame(const Common::FSNode &parent,
|
||||
if (!matched.empty())
|
||||
return matched;
|
||||
|
||||
debugC(3, kDebugGlobalDetection, "Starting disk image detection in dir '%s'", parent.getPath().c_str());
|
||||
debugC(3, kDebugGlobalDetection, "Starting disk image detection in dir '%s'", parent.getPath().toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
FilePropertiesMap filesProps;
|
||||
|
||||
@ -517,17 +517,17 @@ ADDetectedGames AdlMetaEngineDetection::detectGame(const Common::FSNode &parent,
|
||||
|
||||
for (uint f = 0; game.desc->filesDescriptions[f].fileName; ++f) {
|
||||
const ADGameFileDescription &fDesc = game.desc->filesDescriptions[f];
|
||||
Common::String fileName;
|
||||
Common::Path fileName;
|
||||
bool foundDiskImage = false;
|
||||
|
||||
for (uint e = 0; e < ARRAYSIZE(diskImageExts); ++e) {
|
||||
if (diskImageExts[e].platform == game.desc->platform) {
|
||||
Common::String testFileName(fDesc.fileName);
|
||||
testFileName += diskImageExts[e].extension;
|
||||
Common::Path testFileName(fDesc.fileName, Common::Path::kNoSeparator);
|
||||
testFileName.appendInPlace(diskImageExts[e].extension);
|
||||
|
||||
if (addFileProps(allFiles, testFileName, filesProps)) {
|
||||
if (foundDiskImage) {
|
||||
warning("Ignoring '%s' (already found '%s')", testFileName.c_str(), fileName.c_str());
|
||||
warning("Ignoring '%s' (already found '%s')", testFileName.toString().c_str(), fileName.toString().c_str());
|
||||
filesProps.erase(testFileName);
|
||||
} else {
|
||||
foundDiskImage = true;
|
||||
@ -559,7 +559,7 @@ ADDetectedGames AdlMetaEngineDetection::detectGame(const Common::FSNode &parent,
|
||||
continue;
|
||||
}
|
||||
|
||||
debugC(3, kDebugGlobalDetection, "Matched file: %s", fileName.c_str());
|
||||
debugC(3, kDebugGlobalDetection, "Matched file: %s", fileName.toString().c_str());
|
||||
}
|
||||
|
||||
// This assumes that the detection table groups together games that have the same gameId and platform
|
||||
|
@ -468,18 +468,18 @@ static Common::SeekableReadStream *readImage_WOZ(Common::File &f, bool dos33, ui
|
||||
return new Common::MemoryReadStream(diskImage, imageSize, DisposeAfterUse::YES);
|
||||
}
|
||||
|
||||
bool DiskImage::open(const Common::String &filename) {
|
||||
bool DiskImage::open(const Common::Path &filename) {
|
||||
Common::File *f = new Common::File;
|
||||
|
||||
debug(1, "Opening '%s'", filename.c_str());
|
||||
debug(1, "Opening '%s'", filename.toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
if (!f->open(filename)) {
|
||||
warning("Failed to open '%s'", filename.c_str());
|
||||
warning("Failed to open '%s'", filename.toString(Common::Path::kNativeSeparator).c_str());
|
||||
delete f;
|
||||
return false;
|
||||
}
|
||||
|
||||
Common::String lcName(filename);
|
||||
Common::String lcName(filename.baseName());
|
||||
lcName.toLowercase();
|
||||
|
||||
if (lcName.hasSuffix(".dsk")) {
|
||||
@ -542,7 +542,7 @@ bool DiskImage::open(const Common::String &filename) {
|
||||
return false;
|
||||
|
||||
if (_stream->size() != expectedSize)
|
||||
error("Unrecognized disk image '%s' of size %d bytes (expected %d bytes)", filename.c_str(), (int)_stream->size(), expectedSize);
|
||||
error("Unrecognized disk image '%s' of size %d bytes (expected %d bytes)", filename.toString(Common::Path::kNativeSeparator).c_str(), (int)_stream->size(), expectedSize);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -627,15 +627,15 @@ int32 computeMD5(const Common::FSNode &node, Common::String &md5, uint32 md5Byte
|
||||
}
|
||||
}
|
||||
|
||||
const DataBlockPtr Files_Plain::getDataBlock(const Common::String &filename, uint offset) const {
|
||||
const DataBlockPtr Files_Plain::getDataBlock(const Common::Path &filename, uint offset) const {
|
||||
return Common::SharedPtr<Files::DataBlock>(new Files::DataBlock(this, filename, offset));
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *Files_Plain::createReadStream(const Common::String &filename, uint offset) const {
|
||||
Common::SeekableReadStream *Files_Plain::createReadStream(const Common::Path &filename, uint offset) const {
|
||||
Common::File *f(new Common::File());
|
||||
|
||||
if (!f->open(filename))
|
||||
error("Failed to open '%s'", filename.c_str());
|
||||
error("Failed to open '%s'", filename.toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
if (offset == 0)
|
||||
return f;
|
||||
@ -740,7 +740,7 @@ void Files_AppleDOS::readVTOC() {
|
||||
}
|
||||
}
|
||||
|
||||
const DataBlockPtr Files_AppleDOS::getDataBlock(const Common::String &filename, uint offset) const {
|
||||
const DataBlockPtr Files_AppleDOS::getDataBlock(const Common::Path &filename, uint offset) const {
|
||||
return Common::SharedPtr<Files::DataBlock>(new Files::DataBlock(this, filename, offset));
|
||||
}
|
||||
|
||||
@ -802,9 +802,9 @@ Common::SeekableReadStream *Files_AppleDOS::createReadStreamBinary(const TOCEntr
|
||||
return new Common::MemoryReadStream(buf, size, DisposeAfterUse::YES);
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *Files_AppleDOS::createReadStream(const Common::String &filename, uint offset) const {
|
||||
Common::SeekableReadStream *Files_AppleDOS::createReadStream(const Common::Path &filename, uint offset) const {
|
||||
if (!_toc.contains(filename))
|
||||
error("Failed to locate '%s'", filename.c_str());
|
||||
error("Failed to locate '%s'", filename.toString().c_str());
|
||||
|
||||
const TOCEntry &entry = _toc[filename];
|
||||
|
||||
@ -825,7 +825,7 @@ Common::SeekableReadStream *Files_AppleDOS::createReadStream(const Common::Strin
|
||||
return new Common::SeekableSubReadStream(stream, offset, stream->size(), DisposeAfterUse::YES);
|
||||
}
|
||||
|
||||
bool Files_AppleDOS::open(const Common::String &filename) {
|
||||
bool Files_AppleDOS::open(const Common::Path &filename) {
|
||||
_disk = new DiskImage();
|
||||
if (!_disk->open(filename))
|
||||
return false;
|
||||
|
@ -50,14 +50,14 @@ class Files {
|
||||
public:
|
||||
virtual ~Files() { }
|
||||
|
||||
virtual const DataBlockPtr getDataBlock(const Common::String &filename, uint offset = 0) const = 0;
|
||||
virtual Common::SeekableReadStream *createReadStream(const Common::String &filename, uint offset = 0) const = 0;
|
||||
virtual bool exists(const Common::String &filename) const = 0;
|
||||
virtual const DataBlockPtr getDataBlock(const Common::Path &filename, uint offset = 0) const = 0;
|
||||
virtual Common::SeekableReadStream *createReadStream(const Common::Path &filename, uint offset = 0) const = 0;
|
||||
virtual bool exists(const Common::Path &filename) const = 0;
|
||||
|
||||
protected:
|
||||
class DataBlock : public Adl::DataBlock {
|
||||
public:
|
||||
DataBlock(const Files *files, const Common::String &filename, uint offset) :
|
||||
DataBlock(const Files *files, const Common::Path &filename, uint offset) :
|
||||
_files(files),
|
||||
_filename(filename),
|
||||
_offset(offset) { }
|
||||
@ -67,7 +67,7 @@ protected:
|
||||
}
|
||||
|
||||
private:
|
||||
const Common::String _filename;
|
||||
const Common::Path _filename;
|
||||
uint _offset;
|
||||
const Files *_files;
|
||||
};
|
||||
@ -87,7 +87,7 @@ public:
|
||||
delete _stream;
|
||||
}
|
||||
|
||||
bool open(const Common::String &filename);
|
||||
bool open(const Common::Path &filename);
|
||||
const DataBlockPtr getDataBlock(uint track, uint sector, uint offset = 0, uint size = 0) const;
|
||||
Common::SeekableReadStream *createReadStream(uint track, uint sector, uint offset = 0, uint size = 0, uint sectorsUsed = 0) const;
|
||||
void setSectorLimit(uint sectorLimit) { _sectorLimit = sectorLimit; } // Maximum number of sectors to read per track before stepping
|
||||
@ -124,9 +124,9 @@ protected:
|
||||
// Data in plain files
|
||||
class Files_Plain : public Files {
|
||||
public:
|
||||
const DataBlockPtr getDataBlock(const Common::String &filename, uint offset = 0) const override;
|
||||
Common::SeekableReadStream *createReadStream(const Common::String &filename, uint offset = 0) const override;
|
||||
bool exists(const Common::String &filename) const override { return Common::File::exists(filename); }
|
||||
const DataBlockPtr getDataBlock(const Common::Path &filename, uint offset = 0) const override;
|
||||
Common::SeekableReadStream *createReadStream(const Common::Path &filename, uint offset = 0) const override;
|
||||
bool exists(const Common::Path &filename) const override { return Common::File::exists(filename); }
|
||||
};
|
||||
|
||||
// Data in files contained in Apple DOS 3.3 disk image
|
||||
@ -135,10 +135,10 @@ public:
|
||||
Files_AppleDOS();
|
||||
~Files_AppleDOS() override;
|
||||
|
||||
bool open(const Common::String &filename);
|
||||
const DataBlockPtr getDataBlock(const Common::String &filename, uint offset = 0) const override;
|
||||
Common::SeekableReadStream *createReadStream(const Common::String &filename, uint offset = 0) const override;
|
||||
bool exists(const Common::String &filename) const override { return _toc.contains(filename); }
|
||||
bool open(const Common::Path &filename);
|
||||
const DataBlockPtr getDataBlock(const Common::Path &filename, uint offset = 0) const override;
|
||||
Common::SeekableReadStream *createReadStream(const Common::Path &filename, uint offset = 0) const override;
|
||||
bool exists(const Common::Path &filename) const override { return _toc.contains(filename); }
|
||||
|
||||
private:
|
||||
enum FileType {
|
||||
@ -169,7 +169,7 @@ private:
|
||||
Common::SeekableReadStream *createReadStreamBinary(const TOCEntry &entry) const;
|
||||
|
||||
DiskImage *_disk;
|
||||
Common::HashMap<Common::String, TOCEntry> _toc;
|
||||
Common::HashMap<Common::Path, TOCEntry, Common::Path::IgnoreCase_Hash, Common::Path::IgnoreCase_EqualTo> _toc;
|
||||
};
|
||||
|
||||
// On the Apple II, sector headers contain a disk volume number. This number
|
||||
|
@ -273,7 +273,7 @@ void HiRes1Engine::init() {
|
||||
} else {
|
||||
Files_AppleDOS *files = new Files_AppleDOS();
|
||||
if (!files->open(getDiskImageName(0)))
|
||||
error("Failed to open '%s'", getDiskImageName(0).c_str());
|
||||
error("Failed to open '%s'", getDiskImageName(0).toString(Common::Path::kNativeSeparator).c_str());
|
||||
_files = files;
|
||||
}
|
||||
|
||||
@ -330,7 +330,7 @@ void HiRes1Engine::init() {
|
||||
byte block = stream->readByte();
|
||||
Common::String name = Common::String::format("BLOCK%i", block);
|
||||
uint16 offset = stream->readUint16LE();
|
||||
_pictures[i] = _files->getDataBlock(name, offset);
|
||||
_pictures[i] = _files->getDataBlock(Common::Path(name), offset);
|
||||
}
|
||||
|
||||
// Load commands from executable
|
||||
|
@ -62,7 +62,7 @@ void HiResBaseEngine::init() {
|
||||
|
||||
_disk = new DiskImage();
|
||||
if (!_disk->open(getDiskImageName(0)))
|
||||
error("Failed to open disk image '%s'", getDiskImageName(0).c_str());
|
||||
error("Failed to open disk image '%s'", getDiskImageName(0).toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
_disk->setSectorLimit(13);
|
||||
|
||||
|
@ -83,7 +83,7 @@ void HiRes4BaseEngine::init() {
|
||||
|
||||
_boot = new DiskImage();
|
||||
if (!_boot->open(getDiskImageName(0)))
|
||||
error("Failed to open disk image '%s'", getDiskImageName(0).c_str());
|
||||
error("Failed to open disk image '%s'", getDiskImageName(0).toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
insertDisk(1);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ static const ADExtraGuiOptionsMap optionsList[] = {
|
||||
AD_EXTRA_GUI_OPTIONS_TERMINATOR
|
||||
};
|
||||
|
||||
Common::String getDiskImageName(const AdlGameDescription &adlDesc, byte volume) {
|
||||
Common::Path getDiskImageName(const AdlGameDescription &adlDesc, byte volume) {
|
||||
const ADGameDescription &desc = adlDesc.desc;
|
||||
for (uint i = 0; desc.filesDescriptions[i].fileName; ++i) {
|
||||
const ADGameFileDescription &fDesc = desc.filesDescriptions[i];
|
||||
@ -109,8 +109,8 @@ Common::String getDiskImageName(const AdlGameDescription &adlDesc, byte volume)
|
||||
if (fDesc.fileType == volume) {
|
||||
for (uint e = 0; e < ARRAYSIZE(diskImageExts); ++e) {
|
||||
if (diskImageExts[e].platform == desc.platform) {
|
||||
Common::String testFileName(fDesc.fileName);
|
||||
testFileName += diskImageExts[e].extension;
|
||||
Common::Path testFileName(fDesc.fileName);
|
||||
testFileName.appendInPlace(diskImageExts[e].extension);
|
||||
if (Common::File::exists(testFileName))
|
||||
return testFileName;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user