mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-04 09:18:38 +00:00
KYRA: Migrate engine to Path
This commit is contained in:
parent
ca89a72b68
commit
abfc953046
@ -227,10 +227,10 @@ void DarkMoonEngine::loadMonsterShapes(const char *filename, int monsterIndex, b
|
||||
return;
|
||||
}
|
||||
|
||||
Common::String tmp = Common::String::format("%s.MNT", filename);
|
||||
Common::Path tmp(Common::String::format("%s.MNT", filename));
|
||||
Common::SeekableReadStream *s = _res->createReadStream(tmp);
|
||||
if (!s)
|
||||
error("Screen_EoB::loadMonsterShapes(): Failed to load file '%s'", tmp.c_str());
|
||||
error("Screen_EoB::loadMonsterShapes(): Failed to load file '%s'", tmp.toString().c_str());
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
_monsterShapes[monsterIndex + i] = loadFMTownsShape(s);
|
||||
@ -685,7 +685,7 @@ void DarkMoonEngine::snd_loadAmigaSounds(int level, int sub) {
|
||||
if (valNew >= 0 && valNew != valCur) {
|
||||
if (i < 2 && valCur >= 0 && _amigaCurSoundIndex)
|
||||
_sound->unloadSoundFile(Common::String::format("%s.SAM", _amigaLevelSoundList1[_amigaSoundIndex1[_amigaCurSoundIndex]]));
|
||||
_sound->loadSoundFile(Common::String::format("%s.CPS", _amigaLevelSoundList1[valNew]));
|
||||
_sound->loadSoundFile(Common::Path(Common::String::format("%s.CPS", _amigaLevelSoundList1[valNew])));
|
||||
assert(_amigaLevelSoundList2[valNew]);
|
||||
_amigaSoundMap[36 + i] = _amigaLevelSoundList2[valNew][0] ? _amigaLevelSoundList2[valNew] : 0;
|
||||
} else if (valNew == -2) {
|
||||
@ -695,7 +695,7 @@ void DarkMoonEngine::snd_loadAmigaSounds(int level, int sub) {
|
||||
}
|
||||
}
|
||||
|
||||
_sound->loadSoundFile(Common::String::format(sub ? "LEVEL%da.SAM" : "LEVEL%d.SAM", level));
|
||||
_sound->loadSoundFile(Common::Path(Common::String::format(sub ? "LEVEL%da.SAM" : "LEVEL%d.SAM", level)));
|
||||
|
||||
_amigaCurSoundIndex = sndIndex;
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ void EoBEngine::loadMonsterShapes(const char *filename, int monsterIndex, bool h
|
||||
0x0e, 0x0c, 0x08, 0x0f, 0x14, 0x12, 0x09, 0x0b, 0x0a, 0x13, 0x11, 0x15, 0x0d
|
||||
};
|
||||
|
||||
_sres->loadContainer(Common::String::format("L%d", _currentLevel));
|
||||
_sres->loadContainer(Common::Path(Common::String::format("L%d", _currentLevel)));
|
||||
uint8 *data = _sres->resData(monsterIndex >> 4, 0);
|
||||
const uint8 *pos = data;
|
||||
|
||||
@ -684,7 +684,7 @@ void EoBEngine::readLevelFileData(int level) {
|
||||
EoBCoreEngine::readLevelFileData(level);
|
||||
return;
|
||||
}
|
||||
_sres->loadContainer(Common::String::format("L%d", level));
|
||||
_sres->loadContainer(Common::Path(Common::String::format("L%d", level)));
|
||||
Common::SeekableReadStream *s = _sres->resStream(7);
|
||||
_screen->loadFileDataToPage(s, 5, 15000);
|
||||
delete s;
|
||||
@ -695,7 +695,7 @@ void EoBEngine::loadVcnData(const char *file, const uint8 *cgaMapping) {
|
||||
_lastBlockDataFile = file;
|
||||
delete[] _vcnBlocks;
|
||||
|
||||
Common::String fn = Common::String::format(_vcnFilePattern.c_str(), _lastBlockDataFile.c_str());
|
||||
Common::Path fn(Common::String::format(_vcnFilePattern.c_str(), _lastBlockDataFile.c_str()));
|
||||
if (_flags.platform == Common::kPlatformAmiga) {
|
||||
Common::SeekableReadStream *in = _res->createReadStream(fn);
|
||||
uint32 vcnSize = in->readUint16LE() * (_vcnSrcBitsPerPixel << 3);
|
||||
@ -705,9 +705,9 @@ void EoBEngine::loadVcnData(const char *file, const uint8 *cgaMapping) {
|
||||
in->read(_vcnBlocks, vcnSize);
|
||||
delete in;
|
||||
} else if (_flags.platform == Common::kPlatformPC98) {
|
||||
_vcnBlocks = _res->fileData(fn.c_str(), 0);
|
||||
_vcnBlocks = _res->fileData(fn, 0);
|
||||
} else if (_flags.platform == Common::kPlatformSegaCD) {
|
||||
_sres->loadContainer(Common::String::format("L%d", _currentLevel));
|
||||
_sres->loadContainer(Common::Path(Common::String::format("L%d", _currentLevel)));
|
||||
_vcnBlocks = _sres->resData(5, 0);
|
||||
} else {
|
||||
EoBCoreEngine::loadVcnData(file, cgaMapping);
|
||||
@ -717,14 +717,14 @@ void EoBEngine::loadVcnData(const char *file, const uint8 *cgaMapping) {
|
||||
Common::SeekableReadStreamEndian *EoBEngine::getVmpData(const char *file) {
|
||||
if (_flags.platform != Common::kPlatformSegaCD)
|
||||
return EoBCoreEngine::getVmpData(file);
|
||||
_sres->loadContainer(Common::String::format("L%d", _currentLevel));
|
||||
_sres->loadContainer(Common::Path(Common::String::format("L%d", _currentLevel)));
|
||||
return _sres->resStreamEndian(3);
|
||||
}
|
||||
|
||||
const uint8 *EoBEngine::getBlockFileData(int level) {
|
||||
if (_flags.platform != Common::kPlatformSegaCD)
|
||||
return EoBCoreEngine::getBlockFileData(level);
|
||||
_sres->loadContainer(Common::String::format("L%d", level));
|
||||
_sres->loadContainer(Common::Path(Common::String::format("L%d", level)));
|
||||
Common::SeekableReadStream *s = _sres->resStream(6);
|
||||
_screen->loadFileDataToPage(s, 15, s->size());
|
||||
delete s;
|
||||
@ -735,7 +735,7 @@ const uint8 *EoBEngine::getBlockFileData(int level) {
|
||||
Common::SeekableReadStreamEndian *EoBEngine::getDecDefinitions(const char *decFile) {
|
||||
if (_flags.platform != Common::kPlatformSegaCD)
|
||||
return EoBCoreEngine::getDecDefinitions(decFile);
|
||||
_sres->loadContainer(Common::String::format("L%d", _currentLevel));
|
||||
_sres->loadContainer(Common::Path(Common::String::format("L%d", _currentLevel)));
|
||||
return _sres->resStreamEndian(4);
|
||||
}
|
||||
|
||||
@ -745,7 +745,7 @@ void EoBEngine::loadDecShapesToPage3(const char *shpFile) {
|
||||
return;
|
||||
}
|
||||
if (_dcrResCur != _currentLevel) {
|
||||
_sres->loadContainer(Common::String::format("L%d", _currentLevel));
|
||||
_sres->loadContainer(Common::Path(Common::String::format("L%d", _currentLevel)));
|
||||
Common::SeekableReadStream *s = _sres->resStream(2);
|
||||
_screen->loadFileDataToPage(s, 3, s->size());
|
||||
_dcrShpDataPos = _screen->getCPagePtr(3);
|
||||
@ -760,7 +760,7 @@ void EoBEngine::loadDoorShapes(int doorType1, int shapeId1, int doorType2, int s
|
||||
const int shapeId[2] = { shapeId1, shapeId2 };
|
||||
|
||||
if (_flags.platform == Common::kPlatformSegaCD) {
|
||||
_sres->loadContainer(Common::String::format("L%d", _currentLevel));
|
||||
_sres->loadContainer(Common::Path(Common::String::format("L%d", _currentLevel)));
|
||||
Common::SeekableReadStreamEndian *in = _sres->resStreamEndian(8);
|
||||
_screen->loadFileDataToPage(in, 2, in->size());
|
||||
delete in;
|
||||
@ -983,12 +983,12 @@ void EoBEngine::snd_loadAmigaSounds(int level, int) {
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if (_amigaLevelSoundList1[level * 2 + i][0])
|
||||
_sound->loadSoundFile(Common::String::format("%s.CPS", _amigaLevelSoundList1[level * 2 + i]));
|
||||
_sound->loadSoundFile(Common::Path(Common::String::format("%s.CPS", _amigaLevelSoundList1[level * 2 + i])));
|
||||
if (_amigaLevelSoundList2[level * 2 + i][0])
|
||||
_sound->loadSoundFile(Common::String::format("%s.CPS", _amigaLevelSoundList2[level * 2 + i]));
|
||||
_sound->loadSoundFile(Common::Path(Common::String::format("%s.CPS", _amigaLevelSoundList2[level * 2 + i])));
|
||||
}
|
||||
|
||||
_sound->loadSoundFile(Common::String::format("LEVELSAM%d.CPS", level));
|
||||
_sound->loadSoundFile(Common::Path(Common::String::format("LEVELSAM%d.CPS", level)));
|
||||
|
||||
_amigaCurSoundFile = level;
|
||||
}
|
||||
|
@ -948,8 +948,8 @@ protected:
|
||||
virtual void makeNameShapes(int charId = -1) {}
|
||||
virtual void makeFaceShapes(int charId = -1);
|
||||
// Default parameters will import all present original save files and push them to the top of the save dialog.
|
||||
bool importOriginalSaveFile(int destSlot, const char *sourceFile = 0);
|
||||
Common::String readOriginalSaveFile(Common::String &file);
|
||||
bool importOriginalSaveFile(int destSlot, const Common::Path &sourceFile = Common::Path());
|
||||
Common::String readOriginalSaveFile(const Common::Path &file);
|
||||
bool saveAsOriginalSaveFile(int slot = -1);
|
||||
|
||||
void *generateMonsterTempData(LevelTempData *tmp) override;
|
||||
|
@ -1386,21 +1386,21 @@ void KyraEngine_HoF::restoreGfxRect32x32(int x, int y) {
|
||||
#pragma mark -
|
||||
|
||||
void KyraEngine_HoF::openTalkFile(int newFile) {
|
||||
Common::String talkFilename;
|
||||
Common::Path talkFilename;
|
||||
|
||||
if (_oldTalkFile > 0) {
|
||||
talkFilename = Common::String::format("CH%dVOC.TLK", _oldTalkFile);
|
||||
talkFilename = Common::Path(Common::String::format("CH%dVOC.TLK", _oldTalkFile));
|
||||
_res->unloadPakFile(talkFilename);
|
||||
_oldTalkFile = -1;
|
||||
}
|
||||
|
||||
talkFilename = newFile ? Common::String::format("CH%dVOC.TLK", newFile) : "ANYTALK.TLK";
|
||||
talkFilename = newFile ? Common::Path(Common::String::format("CH%dVOC.TLK", newFile)) : Common::Path("ANYTALK.TLK");
|
||||
|
||||
_oldTalkFile = newFile;
|
||||
|
||||
if (!_res->loadPakFile(talkFilename)) {
|
||||
if (speechEnabled()) {
|
||||
warning("Couldn't load voice file '%s', falling back to text only mode", talkFilename.c_str());
|
||||
warning("Couldn't load voice file '%s', falling back to text only mode", talkFilename.toString().c_str());
|
||||
_configVoice = 0;
|
||||
|
||||
// Sync the config manager with the new settings
|
||||
|
@ -733,7 +733,7 @@ void KyraEngine_MR::openTalkFile(int file) {
|
||||
}
|
||||
|
||||
_currentTalkFile = file;
|
||||
if (!_res->loadPakFile(talkFilename)) {
|
||||
if (!_res->loadPakFile(Common::Path(talkFilename))) {
|
||||
if (speechEnabled()) {
|
||||
warning("Couldn't load voice file '%s', falling back to text only mode", talkFilename.c_str());
|
||||
_configVoice = 0;
|
||||
|
@ -1861,7 +1861,7 @@ void LoLEngine::loadTalkFile(int index) {
|
||||
if (index > 0)
|
||||
_curTlkFile = index;
|
||||
|
||||
_res->loadPakFile(Common::String::format("%02d.TLK", index));
|
||||
_res->loadPakFile(Common::Path(Common::String::format("%02d.TLK", index)));
|
||||
}
|
||||
|
||||
int LoLEngine::characterSays(int track, int charId, bool redraw) {
|
||||
|
@ -119,7 +119,7 @@ void EoBCoreEngine::readLevelFileData(int level) {
|
||||
|
||||
for (const char *const *sf = suffix; *sf && !s; sf++) {
|
||||
file = Common::String::format("LEVEL%d.%s", level, *sf);
|
||||
s = _res->createReadStream(file);
|
||||
s = _res->createReadStream(Common::Path(file));
|
||||
}
|
||||
|
||||
if (!s)
|
||||
@ -364,7 +364,7 @@ void EoBCoreEngine::loadVcnData(const char *file, const uint8 *cgaMapping) {
|
||||
}
|
||||
|
||||
Common::SeekableReadStreamEndian *EoBCoreEngine::getVmpData(const char *file) {
|
||||
return _res->createEndianAwareReadStream(Common::String::format(_vmpFilePattern.c_str(), file));
|
||||
return _res->createEndianAwareReadStream(Common::Path(Common::String::format(_vmpFilePattern.c_str(), file)));
|
||||
}
|
||||
|
||||
void EoBCoreEngine::loadBlockProperties(const char *mazFile) {
|
||||
@ -386,7 +386,7 @@ const uint8 *EoBCoreEngine::getBlockFileData(int) {
|
||||
if (_flags.gameID == GI_EOB2 && _flags.platform == Common::kPlatformPC98) {
|
||||
_screen->loadBitmap(_curBlockFile.c_str(), 15, 15, 0);
|
||||
} else {
|
||||
Common::SeekableReadStream *s = _res->createReadStream(_curBlockFile);
|
||||
Common::SeekableReadStream *s = _res->createReadStream(Common::Path(_curBlockFile));
|
||||
_screen->loadFileDataToPage(s, 15, s->size());
|
||||
delete s;
|
||||
}
|
||||
|
@ -1261,7 +1261,7 @@ void KyraEngine_LoK::setupSceneResource(int sceneId) {
|
||||
if (!_flags.isTalkie)
|
||||
return;
|
||||
|
||||
Common::String file;
|
||||
Common::Path file;
|
||||
|
||||
if (_currentRoom != 0xFFFF) {
|
||||
assert(_currentRoom < _roomTableSize);
|
||||
@ -1270,9 +1270,9 @@ void KyraEngine_LoK::setupSceneResource(int sceneId) {
|
||||
|
||||
// unload our old room
|
||||
file = _roomFilenameTable[tableId];
|
||||
_res->unloadPakFile(file + ".VRM");
|
||||
_res->unloadPakFile(file + ".PAK");
|
||||
_res->unloadPakFile(file + ".APK");
|
||||
_res->unloadPakFile(file.append(".VRM"));
|
||||
_res->unloadPakFile(file.append(".PAK"));
|
||||
_res->unloadPakFile(file.append(".APK"));
|
||||
}
|
||||
|
||||
assert(sceneId < _roomTableSize);
|
||||
@ -1280,16 +1280,16 @@ void KyraEngine_LoK::setupSceneResource(int sceneId) {
|
||||
assert(tableId < _roomFilenameTableSize);
|
||||
|
||||
// load our new room
|
||||
file = Common::String(_roomFilenameTable[tableId]) + ".VRM";
|
||||
if (_res->exists(file.c_str()))
|
||||
file = Common::Path(_roomFilenameTable[tableId]).appendInPlace(".VRM");
|
||||
if (_res->exists(file))
|
||||
_res->loadPakFile(file);
|
||||
|
||||
file = Common::String(_roomFilenameTable[tableId]) + ".PAK";
|
||||
if (_res->exists(file.c_str()))
|
||||
file = Common::Path(_roomFilenameTable[tableId]).appendInPlace(".PAK");
|
||||
if (_res->exists(file))
|
||||
_res->loadPakFile(file);
|
||||
|
||||
file = Common::String(_roomFilenameTable[tableId]) + ".APK";
|
||||
if (_res->exists(file.c_str()))
|
||||
file = Common::Path(_roomFilenameTable[tableId]).appendInPlace(".APK");
|
||||
if (_res->exists(file))
|
||||
_res->loadPakFile(file);
|
||||
}
|
||||
|
||||
|
@ -456,7 +456,7 @@ void LoLEngine::loadLevelGraphics(const char *file, int specialColor, int weight
|
||||
generateBrightnessPalette(_screen->getPalette(0), _screen->getPalette(1), _brightness, _lampEffect);
|
||||
|
||||
if (_flags.isTalkie) {
|
||||
Common::SeekableReadStream *s = _res->createReadStream(Common::String::format("LEVEL%.02d.TLC", _currentLevel));
|
||||
Common::SeekableReadStream *s = _res->createReadStream(Common::Path(Common::String::format("LEVEL%.02d.TLC", _currentLevel)));
|
||||
s->read(_transparencyTable1, 256);
|
||||
s->read(_transparencyTable2, 5120);
|
||||
delete s;
|
||||
|
@ -315,9 +315,10 @@ void KyraEngine_MR::loadScenePal() {
|
||||
}
|
||||
|
||||
void KyraEngine_MR::loadSceneMsc() {
|
||||
Common::String filename = Common::String(_sceneList[_mainCharacter.sceneId].filename1) + ".MSC";
|
||||
Common::Path filename(_sceneList[_mainCharacter.sceneId].filename1);
|
||||
filename.appendInPlace(".MSC");
|
||||
|
||||
_res->exists(filename.c_str(), true);
|
||||
_res->exists(filename, true);
|
||||
Common::SeekableReadStream *stream = _res->createReadStream(filename);
|
||||
assert(stream);
|
||||
int16 minY = 0, height = 0;
|
||||
@ -330,7 +331,7 @@ void KyraEngine_MR::loadSceneMsc() {
|
||||
|
||||
_screen->setShapePages(5, 3, _maskPageMinY, _maskPageMaxY);
|
||||
|
||||
_screen->loadBitmap(filename.c_str(), 5, 5, nullptr, true);
|
||||
_screen->loadBitmap(filename.toString('/').c_str(), 5, 5, nullptr, true);
|
||||
|
||||
// HACK
|
||||
uint8 *data = new uint8[320*200];
|
||||
@ -347,7 +348,7 @@ void KyraEngine_MR::initSceneScript(int unk1) {
|
||||
Common::String filename = Common::String(scene.filename1) + ".DAT";
|
||||
|
||||
_res->exists(filename.c_str(), true);
|
||||
Common::SeekableReadStream *stream = _res->createReadStream(filename);
|
||||
Common::SeekableReadStream *stream = _res->createReadStream(Common::Path(filename));
|
||||
assert(stream);
|
||||
stream->seek(2, SEEK_CUR);
|
||||
|
||||
|
@ -41,7 +41,7 @@ void EoBCoreEngine::loadMonsterShapes(const char *filename, int monsterIndex, bo
|
||||
generateMonsterPalettes(filename, monsterIndex);
|
||||
|
||||
if (hasDecorations) {
|
||||
Common::SeekableReadStream *s = _res->createReadStream(Common::String::format("%s.DCR", filename));
|
||||
Common::SeekableReadStream *s = _res->createReadStream(Common::Path(Common::String::format("%s.DCR", filename)));
|
||||
if (s)
|
||||
loadMonsterDecoration(s, monsterIndex);
|
||||
delete s;
|
||||
|
@ -289,7 +289,7 @@ Common::String Util::decodeString2(const Common::String &src) {
|
||||
return reslt;
|
||||
}
|
||||
|
||||
Common::String Util::findMacResourceFile(const char *baseName, const char *suffix) {
|
||||
Common::Path Util::findMacResourceFile(const char *baseName, const char *suffix) {
|
||||
// The original executable has a TM char as its last character (character
|
||||
// 0xAA from Mac code page). Depending on the emulator or platform used to
|
||||
// copy the file it might have been reencoded to something else. So I look
|
||||
@ -304,15 +304,15 @@ Common::String Util::findMacResourceFile(const char *baseName, const char *suffi
|
||||
|
||||
Common::MacResManager resource;
|
||||
Common::String tryName(baseName);
|
||||
Common::String fileName;
|
||||
Common::Path fileName;
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
for (int ii = 0; ii < ARRAYSIZE(tryCodePages); ++ii) {
|
||||
Common::U32String fn(tryName + suffix, tryCodePages[ii]);
|
||||
fileName = fn.encode(Common::kUtf8);
|
||||
fileName = Common::Path(fn.encode(Common::kUtf8));
|
||||
if (resource.exists(fileName))
|
||||
return fileName;
|
||||
fileName = Common::punycode_encodefilename(fn);
|
||||
fileName = Common::Path(Common::punycode_encodefilename(fn));
|
||||
if (resource.exists(fileName))
|
||||
return fileName;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define KYRA_UTIL_H
|
||||
|
||||
#include "common/language.h"
|
||||
#include "common/path.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
|
||||
@ -48,7 +49,7 @@ public:
|
||||
// e. g. when typing a one-byte character, like a digit).
|
||||
static void mergeUpdateJohabChars(uint16 &destJohabChar0, uint16 &destJohabChar1, char asciiInput, bool reset);
|
||||
|
||||
static Common::String findMacResourceFile(const char *baseName, const char *suffix = "");
|
||||
static Common::Path findMacResourceFile(const char *baseName, const char *suffix = "");
|
||||
|
||||
private:
|
||||
struct DOS2JOHABEntry {
|
||||
|
@ -448,7 +448,7 @@ void Screen_EoB::loadBitmap(const char *filename, int tempPage, int dstPage, Pal
|
||||
|
||||
void Screen_EoB::loadEoBBitmap(const char *file, const uint8 *cgaMapping, int tempPage, int destPage, int convertToPage) {
|
||||
Common::String tmp = Common::String::format(_cpsFilePattern.c_str(), file);
|
||||
Common::SeekableReadStream *s = _vm->resource()->createReadStream(tmp);
|
||||
Common::SeekableReadStream *s = _vm->resource()->createReadStream(Common::Path(tmp));
|
||||
bool loadAlternative = false;
|
||||
|
||||
if (_vm->gameFlags().platform == Common::kPlatformFMTowns) {
|
||||
@ -491,7 +491,7 @@ void Screen_EoB::loadEoBBitmap(const char *file, const uint8 *cgaMapping, int te
|
||||
|
||||
} else {
|
||||
tmp.setChar('X', 0);
|
||||
s = _vm->resource()->createReadStream(tmp);
|
||||
s = _vm->resource()->createReadStream(Common::Path(tmp));
|
||||
|
||||
if (!s)
|
||||
error("Screen_EoB::loadEoBBitmap(): Failed to load file '%s'", file);
|
||||
|
@ -344,7 +344,7 @@ private:
|
||||
const int16 *kerning;
|
||||
};
|
||||
|
||||
TextFont *loadContentFile(const Common::String fileName);
|
||||
TextFont *loadContentFile(const Common::Path &fileName);
|
||||
void selectMode(int mode);
|
||||
|
||||
struct FontContent {
|
||||
|
@ -298,25 +298,21 @@ void AmigaDOSFont::unload() {
|
||||
delete[] _content;
|
||||
}
|
||||
|
||||
AmigaDOSFont::TextFont *AmigaDOSFont::loadContentFile(const Common::String fileName) {
|
||||
AmigaDOSFont::TextFont *AmigaDOSFont::loadContentFile(const Common::Path &fileName) {
|
||||
Common::SeekableReadStreamEndian *str = _res->createEndianAwareReadStream(fileName);
|
||||
|
||||
if (!str && fileName.contains('/')) {
|
||||
if (!str && !fileName.getParent().empty()) {
|
||||
// These content files are usually located in sub directories (i. e. the eobf8.font
|
||||
// has a sub dir named 'eobf8' with a file '8' in it). In case someone put the content
|
||||
// files directly in the game directory we still try to open it.
|
||||
Common::String fileNameAlt = fileName;
|
||||
while (fileNameAlt.firstChar() != '/')
|
||||
fileNameAlt.deleteChar(0);
|
||||
fileNameAlt.deleteChar(0);
|
||||
|
||||
Common::Path fileNameAlt(fileName.baseName(), Common::Path::kNoSeparator);
|
||||
str = _res->createEndianAwareReadStream(fileNameAlt);
|
||||
|
||||
if (!str) {
|
||||
// Someone might even have copied the floppy disks to the game directory with the
|
||||
// full sub directory structure. So we also try that...
|
||||
fileNameAlt = "fonts/";
|
||||
fileNameAlt += fileName;
|
||||
fileNameAlt = Common::Path("fonts");
|
||||
fileNameAlt.joinInPlace(fileName);
|
||||
|
||||
str = _res->createEndianAwareReadStream(fileNameAlt);
|
||||
}
|
||||
|
@ -505,7 +505,7 @@ bool Debugger_EoB::cmdImportSaveFile(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
debugPrintf(_vm->importOriginalSaveFile(slot, argv[2]) ? "Success.\n" : "Failure.\n");
|
||||
debugPrintf(_vm->importOriginalSaveFile(slot, Common::Path(argv[2], Common::Path::kNativeSeparator)) ? "Success.\n" : "Failure.\n");
|
||||
_vm->loadItemDefs();
|
||||
} else {
|
||||
debugPrintf("Syntax: import_savefile <dest slot> <source file>\n (Imports source save game file to dest slot.)\n import_savefile -1\n (Imports all original save game files found and puts them into the first available slots.)\n\n");
|
||||
@ -525,9 +525,7 @@ bool Debugger_EoB::cmdSaveOriginal(int argc, const char **argv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Common::String dir = ConfMan.get("savepath");
|
||||
if (dir == "None")
|
||||
dir.clear();
|
||||
Common::Path dir = ConfMan.getPath("savepath");
|
||||
|
||||
Common::FSNode nd(dir);
|
||||
if (!nd.isDirectory())
|
||||
@ -538,7 +536,7 @@ bool Debugger_EoB::cmdSaveOriginal(int argc, const char **argv) {
|
||||
if (_vm->saveAsOriginalSaveFile()) {
|
||||
Common::FSNode nf = nd.getChild(Common::String::format("EOBDATA.SAV"));
|
||||
if (nf.isReadable())
|
||||
debugPrintf("Saved to file: %s\n\n", nf.getPath().c_str());
|
||||
debugPrintf("Saved to file: %s\n\n", nf.getPath().toString(Common::Path::kNativeSeparator).c_str());
|
||||
else
|
||||
debugPrintf("Failure.\n");
|
||||
} else {
|
||||
@ -556,7 +554,7 @@ bool Debugger_EoB::cmdSaveOriginal(int argc, const char **argv) {
|
||||
} else if (_vm->saveAsOriginalSaveFile(slot)) {
|
||||
Common::FSNode nf = nd.getChild(Common::String::format("EOBDATA%d.SAV", slot));
|
||||
if (nf.isReadable())
|
||||
debugPrintf("Saved to file: %s\n\n", nf.getPath().c_str());
|
||||
debugPrintf("Saved to file: %s\n\n", nf.getPath().toString(Common::Path::kNativeSeparator).c_str());
|
||||
else
|
||||
debugPrintf("Failure.\n");
|
||||
} else {
|
||||
|
@ -568,11 +568,11 @@ void EoBCoreEngine::makeFaceShapes(int charId) {
|
||||
_screen->_curPage = 0;
|
||||
}
|
||||
|
||||
bool EoBCoreEngine::importOriginalSaveFile(int destSlot, const char *sourceFile) {
|
||||
Common::Array<Common::String> origFiles;
|
||||
bool EoBCoreEngine::importOriginalSaveFile(int destSlot, const Common::Path &sourceFile) {
|
||||
Common::Array<Common::Path> origFiles;
|
||||
Common::Array<int> newSlots;
|
||||
|
||||
if (sourceFile) {
|
||||
if (!sourceFile.empty()) {
|
||||
// If a source file is specified via the console command we just check whether it exists.
|
||||
if (Common::File::exists(sourceFile))
|
||||
origFiles.push_back(sourceFile);
|
||||
@ -583,7 +583,7 @@ bool EoBCoreEngine::importOriginalSaveFile(int destSlot, const char *sourceFile)
|
||||
int numMax = (_flags.gameID == GI_EOB1) ? 1 : 6;
|
||||
const char *pattern = (_flags.gameID == GI_EOB1) ? "EOBDATA.SAV" : "EOBDATA%d.SAV";
|
||||
for (int i = 0; i < numMax; ++i) {
|
||||
Common::String temp = Common::String::format(pattern, i);
|
||||
Common::Path temp(Common::String::format(pattern, i));
|
||||
Common::SeekableReadStream *fs = _res->createReadStream(temp);
|
||||
if (fs) {
|
||||
Common::U32String dsc;
|
||||
@ -595,7 +595,7 @@ bool EoBCoreEngine::importOriginalSaveFile(int destSlot, const char *sourceFile)
|
||||
}
|
||||
|
||||
delete fs;
|
||||
::GUI::MessageDialog dialog(Common::U32String::format(_("The following original saved game file has been found in your game path:\n\n%s %S\n\nDo you wish to use this saved game file with ScummVM?\n\n"), temp.c_str(), dsc.c_str()), _("Yes"), _("No"));
|
||||
::GUI::MessageDialog dialog(Common::U32String::format(_("The following original saved game file has been found in your game path:\n\n%s %S\n\nDo you wish to use this saved game file with ScummVM?\n\n"), temp.toString(Common::Path::kNativeSeparator).c_str(), dsc.c_str()), _("Yes"), _("No"));
|
||||
if (dialog.runModal() == ::GUI::kMessageOK)
|
||||
origFiles.push_back(temp);
|
||||
}
|
||||
@ -638,14 +638,14 @@ bool EoBCoreEngine::importOriginalSaveFile(int destSlot, const char *sourceFile)
|
||||
for (int i = 0; i < numFilesFound; i++) {
|
||||
Common::String desc = readOriginalSaveFile(origFiles[i]);
|
||||
if (desc.empty()) {
|
||||
warning("Unable to import original save file '%s'", origFiles[i].c_str());
|
||||
warning("Unable to import original save file '%s'", origFiles[i].toString().c_str());
|
||||
} else {
|
||||
// We can't make thumbnails here, since we do not want to load all the level data, monsters, etc. for each save we convert.
|
||||
// Instead, we use an empty surface to avoid that createThumbnailFromScreen() makes a completely pointless thumbnail from
|
||||
// whatever screen that is currently shown when this function is called.
|
||||
Graphics::Surface dummy;
|
||||
saveGameStateIntern(newSlots[i], desc.c_str(), &dummy);
|
||||
warning("Imported original save file '%s' ('%s')", origFiles[i].c_str(), desc.c_str());
|
||||
warning("Imported original save file '%s' ('%s')", origFiles[i].toString().c_str(), desc.c_str());
|
||||
importedCount++;
|
||||
}
|
||||
}
|
||||
@ -668,7 +668,7 @@ bool EoBCoreEngine::importOriginalSaveFile(int destSlot, const char *sourceFile)
|
||||
return true;
|
||||
}
|
||||
|
||||
Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
|
||||
Common::String EoBCoreEngine::readOriginalSaveFile(const Common::Path &file) {
|
||||
Common::String desc;
|
||||
|
||||
Common::SeekableReadStream *fs = _res->createReadStream(file);
|
||||
@ -789,7 +789,7 @@ Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
|
||||
if (c->effectFlags && _flags.gameID == GI_EOB1) {
|
||||
// Spell effect flags are completely different in EOB I. We only use EOB II style flags in ScummVM.
|
||||
// Doesn't matter much, since these are only temporary spell effects.
|
||||
warning("EoBCoreEngine::readOriginalSaveFile(): Unhandled character effect flags encountered in original EOB1 save file '%s' ('%s')", file.c_str(), desc.c_str());
|
||||
warning("EoBCoreEngine::readOriginalSaveFile(): Unhandled character effect flags encountered in original EOB1 save file '%s' ('%s')", file.toString().c_str(), desc.c_str());
|
||||
c->effectFlags = 0;
|
||||
}
|
||||
c->damageTaken = in.readByte();
|
||||
@ -809,7 +809,7 @@ Common::String EoBCoreEngine::readOriginalSaveFile(Common::String &file) {
|
||||
if (_partyEffectFlags && _flags.gameID == GI_EOB1) {
|
||||
// Spell effect flags are completely different in EOB I. We only use EOB II style flags in ScummVM.
|
||||
// Doesn't matter much, since these are only temporary spell effects.
|
||||
warning("EoBCoreEngine::readOriginalSaveFile(): Unhandled party effect flags encountered in original EOB1 save file '%s' ('%s')", file.c_str(), desc.c_str());
|
||||
warning("EoBCoreEngine::readOriginalSaveFile(): Unhandled party effect flags encountered in original EOB1 save file '%s' ('%s')", file.toString().c_str(), desc.c_str());
|
||||
_partyEffectFlags = 0;
|
||||
}
|
||||
if (_flags.gameID == GI_EOB2)
|
||||
@ -1080,9 +1080,7 @@ bool EoBCoreEngine::saveAsOriginalSaveFile(int slot) {
|
||||
if (_flags.gameID == GI_EOB2 && (slot < 0 || slot > 5))
|
||||
return false;
|
||||
|
||||
Common::String dir = ConfMan.get("savepath");
|
||||
if (dir == "None")
|
||||
dir.clear();
|
||||
Common::Path dir = ConfMan.getPath("savepath");
|
||||
|
||||
Common::FSNode nd(dir);
|
||||
if (!nd.isDirectory())
|
||||
|
@ -33,7 +33,7 @@
|
||||
namespace Kyra {
|
||||
|
||||
Common::Archive *Resource::loadKyra1MacInstaller() {
|
||||
Common::String kyraInstaller = Util::findMacResourceFile("Install Legend of Kyrandia");
|
||||
Common::Path kyraInstaller = Util::findMacResourceFile("Install Legend of Kyrandia");
|
||||
|
||||
if (!kyraInstaller.empty()) {
|
||||
Common::Archive *archive = loadStuffItArchive(kyraInstaller, "Install Legend of Kyrandia");
|
||||
@ -47,12 +47,12 @@ Common::Archive *Resource::loadKyra1MacInstaller() {
|
||||
if (!kyraInstaller.empty()) {
|
||||
Common::Array<Common::SharedPtr<Common::SeekableReadStream>> parts;
|
||||
for (int i = 1; i <= 5; i++) {
|
||||
Common::String partName = i == 1 ? kyraInstaller : Common::String::format("%s.%d", kyraInstaller.c_str(), i);
|
||||
Common::Path partName = i == 1 ? kyraInstaller : kyraInstaller.append(Common::String::format(".%d", i));
|
||||
Common::SeekableReadStream *stream = Common::MacResManager::openFileOrDataFork(partName);
|
||||
if (!stream)
|
||||
error("Failed to load Legend of Kyrandia installer file part %s", partName.c_str());
|
||||
error("Failed to load Legend of Kyrandia installer file part %s", partName.toString().c_str());
|
||||
if (stream->size() <= 100)
|
||||
error("Legend of Kyrandia installer file part %s is too short", partName.c_str());
|
||||
error("Legend of Kyrandia installer file part %s is too short", partName.toString().c_str());
|
||||
parts.push_back(Common::SharedPtr<Common::SeekableReadStream>(new Common::SeekableSubReadStream(stream, 100, stream->size(), DisposeAfterUse::YES)));
|
||||
}
|
||||
return loadStuffItArchive(new Common::ConcatReadStream(parts), "Install Legend of Kyrandia", "Legend of Kyrandia(TM) Installer.*");
|
||||
@ -65,15 +65,15 @@ Resource::Resource(KyraEngine_v1 *vm) : _archiveCache(), _files(), _archiveFiles
|
||||
initializeLoaders();
|
||||
|
||||
if (_vm->game() == GI_KYRA1 && _vm->gameFlags().platform == Common::Platform::kPlatformMacintosh)
|
||||
SearchMan.addSubDirectoryMatching(Common::FSNode(ConfMan.get("path")), "runtime");
|
||||
SearchMan.addSubDirectoryMatching(Common::FSNode(ConfMan.getPath("path")), "runtime");
|
||||
|
||||
// Initialize directories for playing from CD or with original
|
||||
// directory structure
|
||||
if (_vm->game() == GI_KYRA3)
|
||||
SearchMan.addSubDirectoryMatching(Common::FSNode(ConfMan.get("path")), "malcolm");
|
||||
SearchMan.addSubDirectoryMatching(Common::FSNode(ConfMan.getPath("path")), "malcolm");
|
||||
|
||||
if (_vm->game() == GI_LOL)
|
||||
SearchMan.addSubDirectoryMatching(Common::FSNode(ConfMan.get("path")), "data", 0, 2);
|
||||
SearchMan.addSubDirectoryMatching(Common::FSNode(ConfMan.getPath("path")), "data", 0, 2);
|
||||
|
||||
_files.add("global_search", &Common::SearchManager::instance(), 3, false);
|
||||
// compressed installer archives are added at level '2',
|
||||
@ -93,10 +93,10 @@ Resource::~Resource() {
|
||||
bool Resource::reset() {
|
||||
unloadAllPakFiles();
|
||||
|
||||
Common::FSNode dir(ConfMan.get("path"));
|
||||
Common::FSNode dir(ConfMan.getPath("path"));
|
||||
|
||||
if (!dir.exists() || !dir.isDirectory())
|
||||
error("invalid game path '%s'", dir.getPath().c_str());
|
||||
error("invalid game path '%s'", dir.getPath().toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
if (_vm->game() == GI_KYRA1 && _vm->gameFlags().platform == Common::kPlatformMacintosh && _vm->gameFlags().useInstallerPackage) {
|
||||
Common::Archive *archive = loadKyra1MacInstaller();
|
||||
@ -155,7 +155,7 @@ bool Resource::reset() {
|
||||
if (name == ((_vm->gameFlags().lang == Common::EN_ANY) ? "JMC.PAK" : "EMC.PAK"))
|
||||
continue;
|
||||
|
||||
Common::Archive *archive = loadArchive(name, *i);
|
||||
Common::Archive *archive = loadArchive((*i)->getName(), *i);
|
||||
|
||||
if (archive) {
|
||||
// Hack for the Spanish version of EOB1. It has an invalid item.dat file in the
|
||||
@ -203,32 +203,34 @@ bool Resource::reset() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Resource::loadPakFile(Common::String filename) {
|
||||
filename.toUppercase();
|
||||
bool Resource::loadPakFile(const Common::Path &filename) {
|
||||
Common::Path filenameFixed(filename);
|
||||
filenameFixed.toUppercase();
|
||||
|
||||
Common::ArchiveMemberPtr file = _files.getMember(filename);
|
||||
Common::ArchiveMemberPtr file = _files.getMember(filenameFixed);
|
||||
if (!file)
|
||||
return false;
|
||||
|
||||
return loadPakFile(filename, file);
|
||||
return loadPakFile(filenameFixed.toString('/'), file);
|
||||
}
|
||||
|
||||
bool Resource::loadPakFile(Common::String name, Common::ArchiveMemberPtr file) {
|
||||
name.toUppercase();
|
||||
bool Resource::loadPakFile(const Common::String &name, Common::ArchiveMemberPtr file) {
|
||||
Common::String nameFixed(name);
|
||||
nameFixed.toUppercase();
|
||||
|
||||
if (_archiveFiles.hasArchive(name) || _protectedFiles.hasArchive(name))
|
||||
if (_archiveFiles.hasArchive(nameFixed) || _protectedFiles.hasArchive(nameFixed))
|
||||
return true;
|
||||
|
||||
Common::Archive *archive = loadArchive(name, file);
|
||||
Common::Archive *archive = loadArchive(nameFixed, file);
|
||||
if (!archive)
|
||||
return false;
|
||||
|
||||
_archiveFiles.add(name, archive, 0, false);
|
||||
_archiveFiles.add(nameFixed, archive, 0, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Resource::loadFileList(const Common::String &filedata) {
|
||||
bool Resource::loadFileList(const Common::Path &filedata) {
|
||||
Common::SeekableReadStream *f = createReadStream(filedata);
|
||||
|
||||
if (!f)
|
||||
@ -248,12 +250,13 @@ bool Resource::loadFileList(const Common::String &filedata) {
|
||||
filename.toUppercase();
|
||||
|
||||
if (filename.hasSuffix(".PAK")) {
|
||||
if (!exists(filename.c_str()) && _vm->gameFlags().isDemo) {
|
||||
Common::Path path(filename);
|
||||
if (!exists(path) && _vm->gameFlags().isDemo) {
|
||||
// the demo version supplied with Kyra3 does not
|
||||
// contain all pak files listed in filedata.fdt
|
||||
// so we don't do anything here if they are non
|
||||
// existent.
|
||||
} else if (!loadPakFile(filename)) {
|
||||
} else if (!loadPakFile(path)) {
|
||||
delete f;
|
||||
error("couldn't load file '%s'", filename.c_str());
|
||||
return false; // for compilers that don't support NORETURN
|
||||
@ -295,31 +298,34 @@ bool Resource::loadProtectedFiles(const char *const *list) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void Resource::unloadPakFile(Common::String filename, bool remFromCache) {
|
||||
filename.toUppercase();
|
||||
void Resource::unloadPakFile(const Common::String &name, bool remFromCache) {
|
||||
Common::String nameFixed(name);
|
||||
nameFixed.toUppercase();
|
||||
|
||||
// We do not remove files from '_protectedFiles' here, since
|
||||
// those are protected against unloading.
|
||||
if (_archiveFiles.hasArchive(filename)) {
|
||||
_archiveFiles.remove(filename);
|
||||
if (_archiveFiles.hasArchive(nameFixed)) {
|
||||
_archiveFiles.remove(nameFixed);
|
||||
if (remFromCache) {
|
||||
ArchiveMap::iterator iter = _archiveCache.find(filename);
|
||||
ArchiveMap::iterator iter = _archiveCache.find(nameFixed);
|
||||
if (iter != _archiveCache.end()) {
|
||||
delete iter->_value;
|
||||
_archiveCache.erase(filename);
|
||||
_archiveCache.erase(nameFixed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Resource::isInPakList(Common::String filename) {
|
||||
filename.toUppercase();
|
||||
return (_archiveFiles.hasArchive(filename) || _protectedFiles.hasArchive(filename));
|
||||
bool Resource::isInPakList(const Common::String &name) {
|
||||
Common::String nameFixed(name);
|
||||
nameFixed.toUppercase();
|
||||
return (_archiveFiles.hasArchive(nameFixed) || _protectedFiles.hasArchive(nameFixed));
|
||||
}
|
||||
|
||||
bool Resource::isInCacheList(Common::String name) {
|
||||
name.toUppercase();
|
||||
return (_archiveCache.find(name) != _archiveCache.end());
|
||||
bool Resource::isInCacheList(const Common::String &name) {
|
||||
Common::String nameFixed(name);
|
||||
nameFixed.toUppercase();
|
||||
return (_archiveCache.find(nameFixed) != _archiveCache.end());
|
||||
}
|
||||
|
||||
void Resource::unloadAllPakFiles() {
|
||||
@ -327,11 +333,11 @@ void Resource::unloadAllPakFiles() {
|
||||
_protectedFiles.clear();
|
||||
}
|
||||
|
||||
void Resource::listFiles(const Common::String &pattern, Common::ArchiveMemberList &list) {
|
||||
void Resource::listFiles(const Common::Path &pattern, Common::ArchiveMemberList &list) {
|
||||
_files.listMatchingMembers(list, pattern);
|
||||
}
|
||||
|
||||
uint8 *Resource::fileData(const char *file, uint32 *size) {
|
||||
uint8 *Resource::fileData(const Common::Path &file, uint32 *size) {
|
||||
Common::SeekableReadStream *stream = createReadStream(file);
|
||||
if (!stream)
|
||||
return nullptr;
|
||||
@ -346,15 +352,15 @@ uint8 *Resource::fileData(const char *file, uint32 *size) {
|
||||
return buffer;
|
||||
}
|
||||
|
||||
bool Resource::exists(const char *file, bool errorOutOnFail) {
|
||||
bool Resource::exists(const Common::Path &file, bool errorOutOnFail) {
|
||||
if (_files.hasFile(file))
|
||||
return true;
|
||||
else if (errorOutOnFail)
|
||||
error("File '%s' can't be found", file);
|
||||
error("File '%s' can't be found", file.toString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 Resource::getFileSize(const char *file) {
|
||||
uint32 Resource::getFileSize(const Common::Path &file) {
|
||||
Common::SeekableReadStream *stream = createReadStream(file);
|
||||
if (!stream)
|
||||
return 0;
|
||||
@ -364,7 +370,7 @@ uint32 Resource::getFileSize(const char *file) {
|
||||
return size;
|
||||
}
|
||||
|
||||
bool Resource::loadFileToBuf(const char *file, void *buf, uint32 maxSize) {
|
||||
bool Resource::loadFileToBuf(const Common::Path &file, void *buf, uint32 maxSize) {
|
||||
Common::SeekableReadStream *stream = createReadStream(file);
|
||||
if (!stream)
|
||||
return false;
|
||||
@ -380,11 +386,11 @@ Common::Archive *Resource::getCachedArchive(const Common::String &file) const {
|
||||
return a != _archiveCache.end() ? a->_value : 0;
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *Resource::createReadStream(const Common::String &file) {
|
||||
Common::SeekableReadStream *Resource::createReadStream(const Common::Path &file) {
|
||||
return _files.createReadStreamForMember(file);
|
||||
}
|
||||
|
||||
Common::SeekableReadStreamEndian *Resource::createEndianAwareReadStream(const Common::String &file, int endianness) {
|
||||
Common::SeekableReadStreamEndian *Resource::createEndianAwareReadStream(const Common::Path &file, int endianness) {
|
||||
Common::SeekableReadStream *stream = _files.createReadStreamForMember(file);
|
||||
return stream ? new Common::SeekableReadStreamEndianWrapper(stream, (endianness == kForceBE) ? true : (endianness == kForceLE ? false : _bigEndianPlatForm), DisposeAfterUse::YES) : nullptr;
|
||||
}
|
||||
@ -421,8 +427,9 @@ Common::Archive *Resource::loadArchive(const Common::String &name, Common::Archi
|
||||
return archive;
|
||||
}
|
||||
|
||||
Common::Archive *Resource::loadInstallerArchive(const Common::String &file, const Common::String &ext, const uint8 offset) {
|
||||
ArchiveMap::iterator cachedArchive = _archiveCache.find(file);
|
||||
Common::Archive *Resource::loadInstallerArchive(const Common::Path &file, const Common::String &ext, const uint8 offset) {
|
||||
Common::String name(file.toString('/'));
|
||||
ArchiveMap::iterator cachedArchive = _archiveCache.find(name);
|
||||
if (cachedArchive != _archiveCache.end())
|
||||
return cachedArchive->_value;
|
||||
|
||||
@ -430,11 +437,11 @@ Common::Archive *Resource::loadInstallerArchive(const Common::String &file, cons
|
||||
if (!archive)
|
||||
return nullptr;
|
||||
|
||||
_archiveCache[file] = archive;
|
||||
_archiveCache[name] = archive;
|
||||
return archive;
|
||||
}
|
||||
|
||||
Common::Archive *Resource::loadStuffItArchive(const Common::String &file, const Common::String& canonicalName) {
|
||||
Common::Archive *Resource::loadStuffItArchive(const Common::Path &file, const Common::String &canonicalName) {
|
||||
ArchiveMap::iterator cachedArchive = _archiveCache.find(canonicalName);
|
||||
if (cachedArchive != _archiveCache.end())
|
||||
return cachedArchive->_value;
|
||||
@ -447,7 +454,7 @@ Common::Archive *Resource::loadStuffItArchive(const Common::String &file, const
|
||||
return archive;
|
||||
}
|
||||
|
||||
Common::Archive *Resource::loadStuffItArchive(Common::SeekableReadStream *stream, const Common::String& canonicalName, const Common::String& debugName) {
|
||||
Common::Archive *Resource::loadStuffItArchive(Common::SeekableReadStream *stream, const Common::String &canonicalName, const Common::String &debugName) {
|
||||
ArchiveMap::iterator cachedArchive = _archiveCache.find(canonicalName);
|
||||
if (cachedArchive != _archiveCache.end()) {
|
||||
delete stream;
|
||||
|
@ -52,28 +52,30 @@ public:
|
||||
|
||||
bool reset();
|
||||
|
||||
bool loadPakFile(Common::String filename);
|
||||
bool loadPakFile(Common::String name, Common::ArchiveMemberPtr file);
|
||||
bool loadPakFile(const Common::Path &filename);
|
||||
bool loadPakFile(const Common::String &name, Common::ArchiveMemberPtr file);
|
||||
|
||||
void unloadPakFile(Common::String filename, bool remFromCache = false);
|
||||
void unloadPakFile(const Common::String &name, bool remFromCache = false);
|
||||
void unloadPakFile(const char *name, bool remFromCache = false) { unloadPakFile(Common::String(name), remFromCache); }
|
||||
void unloadPakFile(const Common::Path &name, bool remFromCache = false) { unloadPakFile(name.toString('/'), remFromCache); }
|
||||
|
||||
bool isInPakList(Common::String filename);
|
||||
bool isInPakList(const Common::String &name);
|
||||
|
||||
bool isInCacheList(Common::String name);
|
||||
bool isInCacheList(const Common::String &name);
|
||||
|
||||
bool loadFileList(const Common::String &filedata);
|
||||
bool loadFileList(const Common::Path &filedata);
|
||||
bool loadFileList(const char *const *filelist, uint32 numFiles);
|
||||
|
||||
// This unloads *all* pakfiles, even kyra.dat and protected ones.
|
||||
// It does not remove files from cache though!
|
||||
void unloadAllPakFiles();
|
||||
|
||||
void listFiles(const Common::String &pattern, Common::ArchiveMemberList &list);
|
||||
void listFiles(const Common::Path &pattern, Common::ArchiveMemberList &list);
|
||||
|
||||
bool exists(const char *file, bool errorOutOnFail=false);
|
||||
uint32 getFileSize(const char *file);
|
||||
uint8 *fileData(const char *file, uint32 *size);
|
||||
Common::SeekableReadStream *createReadStream(const Common::String &file);
|
||||
bool exists(const Common::Path &file, bool errorOutOnFail=false);
|
||||
uint32 getFileSize(const Common::Path &file);
|
||||
uint8 *fileData(const Common::Path &file, uint32 *size);
|
||||
Common::SeekableReadStream *createReadStream(const Common::Path &file);
|
||||
|
||||
enum Endianness {
|
||||
kPlatformEndianness = 0,
|
||||
@ -81,9 +83,9 @@ public:
|
||||
kForceBE
|
||||
};
|
||||
|
||||
Common::SeekableReadStreamEndian *createEndianAwareReadStream(const Common::String &file, int endianness = kPlatformEndianness);
|
||||
Common::SeekableReadStreamEndian *createEndianAwareReadStream(const Common::Path &file, int endianness = kPlatformEndianness);
|
||||
|
||||
bool loadFileToBuf(const char *file, void *buf, uint32 maxSize);
|
||||
bool loadFileToBuf(const Common::Path &file, void *buf, uint32 maxSize);
|
||||
|
||||
Common::Archive *getCachedArchive(const Common::String &file) const;
|
||||
|
||||
@ -96,9 +98,9 @@ protected:
|
||||
Common::SearchSet _protectedFiles;
|
||||
|
||||
Common::Archive *loadArchive(const Common::String &name, Common::ArchiveMemberPtr member);
|
||||
Common::Archive *loadInstallerArchive(const Common::String &file, const Common::String &ext, const uint8 offset);
|
||||
Common::Archive *loadStuffItArchive(const Common::String &file, const Common::String& canonicalName);
|
||||
Common::Archive *loadStuffItArchive(Common::SeekableReadStream *stream, const Common::String& canonicalName, const Common::String& debugName);
|
||||
Common::Archive *loadInstallerArchive(const Common::Path &file, const Common::String &ext, const uint8 offset);
|
||||
Common::Archive *loadStuffItArchive(const Common::Path &file, const Common::String &canonicalName);
|
||||
Common::Archive *loadStuffItArchive(Common::SeekableReadStream *stream, const Common::String &canonicalName, const Common::String &debugName);
|
||||
Common::Archive *loadKyra1MacInstaller();
|
||||
|
||||
bool loadProtectedFiles(const char *const * list);
|
||||
|
@ -39,8 +39,7 @@ PlainArchive::PlainArchive(Common::ArchiveMemberPtr file)
|
||||
}
|
||||
|
||||
bool PlainArchive::hasFile(const Common::Path &path) const {
|
||||
Common::String name = path.toString();
|
||||
return (_files.find(name) != _files.end());
|
||||
return (_files.find(path) != _files.end());
|
||||
}
|
||||
|
||||
int PlainArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||
@ -55,16 +54,14 @@ int PlainArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||
}
|
||||
|
||||
const Common::ArchiveMemberPtr PlainArchive::getMember(const Common::Path &path) const {
|
||||
Common::String name = path.toString();
|
||||
if (!hasFile(name))
|
||||
if (!hasFile(path))
|
||||
return Common::ArchiveMemberPtr();
|
||||
|
||||
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, *this));
|
||||
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(path, *this));
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *PlainArchive::createReadStreamForMember(const Common::Path &path) const {
|
||||
Common::String name = path.toString();
|
||||
FileMap::const_iterator fDesc = _files.find(name);
|
||||
FileMap::const_iterator fDesc = _files.find(path);
|
||||
if (fDesc == _files.end())
|
||||
return nullptr;
|
||||
|
||||
@ -75,11 +72,11 @@ Common::SeekableReadStream *PlainArchive::createReadStreamForMember(const Common
|
||||
return new Common::SeekableSubReadStream(parent, fDesc->_value.offset, fDesc->_value.offset + fDesc->_value.size, DisposeAfterUse::YES);
|
||||
}
|
||||
|
||||
void PlainArchive::addFileEntry(const Common::String &name, const Entry entry) {
|
||||
void PlainArchive::addFileEntry(const Common::Path &name, const Entry entry) {
|
||||
_files[name] = entry;
|
||||
}
|
||||
|
||||
PlainArchive::Entry PlainArchive::getFileEntry(const Common::String &name) const {
|
||||
PlainArchive::Entry PlainArchive::getFileEntry(const Common::Path &name) const {
|
||||
FileMap::const_iterator fDesc = _files.find(name);
|
||||
if (fDesc == _files.end())
|
||||
return Entry();
|
||||
@ -97,8 +94,7 @@ TlkArchive::~TlkArchive() {
|
||||
}
|
||||
|
||||
bool TlkArchive::hasFile(const Common::Path &path) const {
|
||||
Common::String name = path.toString();
|
||||
return (findFile(name) != nullptr);
|
||||
return (findFile(path) != nullptr);
|
||||
}
|
||||
|
||||
int TlkArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||
@ -113,16 +109,14 @@ int TlkArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||
}
|
||||
|
||||
const Common::ArchiveMemberPtr TlkArchive::getMember(const Common::Path &path) const {
|
||||
Common::String name = path.toString();
|
||||
if (!hasFile(name))
|
||||
if (!hasFile(path))
|
||||
return Common::ArchiveMemberPtr();
|
||||
|
||||
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, *this));
|
||||
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(path, *this));
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *TlkArchive::createReadStreamForMember(const Common::Path &path) const {
|
||||
Common::String name = path.toString();
|
||||
const uint32 *fileDesc = findFile(name);
|
||||
const uint32 *fileDesc = findFile(path);
|
||||
if (!fileDesc)
|
||||
return nullptr;
|
||||
|
||||
@ -137,8 +131,8 @@ Common::SeekableReadStream *TlkArchive::createReadStreamForMember(const Common::
|
||||
return new Common::SeekableSubReadStream(parent, fileStart, fileStart + size, DisposeAfterUse::YES);
|
||||
}
|
||||
|
||||
const uint32 *TlkArchive::findFile(const Common::String &name) const {
|
||||
Common::String uppercaseName = name;
|
||||
const uint32 *TlkArchive::findFile(const Common::Path &path) const {
|
||||
Common::String uppercaseName = path.baseName();
|
||||
uppercaseName.toUppercase();
|
||||
|
||||
if (!uppercaseName.hasSuffix(".AUD"))
|
||||
@ -181,7 +175,7 @@ CachedArchive::CachedArchive(const FileInputList &files)
|
||||
entry.data = i->data;
|
||||
entry.size = i->size;
|
||||
|
||||
Common::String name = i->name;
|
||||
Common::Path name = i->name;
|
||||
name.toLowercase();
|
||||
_files[name] = entry;
|
||||
}
|
||||
@ -194,8 +188,7 @@ CachedArchive::~CachedArchive() {
|
||||
}
|
||||
|
||||
bool CachedArchive::hasFile(const Common::Path &path) const {
|
||||
Common::String name = path.toString();
|
||||
return (_files.find(name) != _files.end());
|
||||
return (_files.find(path) != _files.end());
|
||||
}
|
||||
|
||||
int CachedArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||
@ -210,16 +203,14 @@ int CachedArchive::listMembers(Common::ArchiveMemberList &list) const {
|
||||
}
|
||||
|
||||
const Common::ArchiveMemberPtr CachedArchive::getMember(const Common::Path &path) const {
|
||||
Common::String name = path.toString();
|
||||
if (!hasFile(name))
|
||||
if (!hasFile(path))
|
||||
return Common::ArchiveMemberPtr();
|
||||
|
||||
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(name, *this));
|
||||
return Common::ArchiveMemberPtr(new Common::GenericArchiveMember(path, *this));
|
||||
}
|
||||
|
||||
Common::SeekableReadStream *CachedArchive::createReadStreamForMember(const Common::Path &path) const {
|
||||
Common::String name = path.toString();
|
||||
FileMap::const_iterator fDesc = _files.find(name);
|
||||
FileMap::const_iterator fDesc = _files.find(path);
|
||||
if (fDesc == _files.end())
|
||||
return nullptr;
|
||||
|
||||
@ -230,9 +221,12 @@ Common::SeekableReadStream *CachedArchive::createReadStreamForMember(const Commo
|
||||
|
||||
// -> ResLoaderPak implementation
|
||||
|
||||
bool ResLoaderPak::checkFilename(Common::String filename) const {
|
||||
filename.toUppercase();
|
||||
return (filename.hasSuffix(".PAK") || filename.hasSuffix(".APK") || filename.hasSuffix(".VRM") || filename.hasSuffix(".CMP") || filename.hasSuffix(".TLK") || filename.equalsIgnoreCase(StaticResource::staticDataFilename()));
|
||||
bool ResLoaderPak::checkFilename(const Common::String &filename) const {
|
||||
Common::String filenameFixed(filename);
|
||||
filenameFixed.toUppercase();
|
||||
return (filenameFixed.hasSuffix(".PAK") || filenameFixed.hasSuffix(".APK") ||
|
||||
filenameFixed.hasSuffix(".VRM") || filenameFixed.hasSuffix(".CMP") ||
|
||||
filenameFixed.hasSuffix(".TLK") || filenameFixed.equalsIgnoreCase(StaticResource::staticDataFilename()));
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -315,7 +309,7 @@ Common::Archive *ResLoaderPak::load(Common::ArchiveMemberPtr memberFile, Common:
|
||||
startoffset = SWAP_BYTES_32(startoffset);
|
||||
}
|
||||
|
||||
Common::String file;
|
||||
Common::Path file;
|
||||
while (!stream.eos()) {
|
||||
// The start offset of a file should never be in the filelist
|
||||
if (startoffset < stream.pos() || startoffset > filesize || startoffset < 0) {
|
||||
@ -323,7 +317,7 @@ Common::Archive *ResLoaderPak::load(Common::ArchiveMemberPtr memberFile, Common:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
file = readString(stream);
|
||||
file = Common::Path(readString(stream));
|
||||
|
||||
if (stream.eos()) {
|
||||
warning("PAK file '%s' is corrupted", memberFile->getName().c_str());
|
||||
@ -371,15 +365,15 @@ Common::Archive *ResLoaderPak::load(Common::ArchiveMemberPtr memberFile, Common:
|
||||
|
||||
const uint32 links = stream.readUint32BE();
|
||||
for (uint32 i = 0; i < links; ++i) {
|
||||
const Common::String linksTo = readString(stream);
|
||||
const Common::Path linksTo(readString(stream));
|
||||
const uint32 sources = stream.readUint32BE();
|
||||
|
||||
PlainArchive::Entry destination = result->getFileEntry(linksTo);
|
||||
if (destination.size == 0)
|
||||
error("PAK file link destination '%s' not found", linksTo.c_str());
|
||||
error("PAK file link destination '%s' not found", linksTo.toString().c_str());
|
||||
|
||||
for (uint32 j = 0; j < sources; ++j) {
|
||||
const Common::String dest = readString(stream);
|
||||
const Common::Path dest(readString(stream));
|
||||
result->addFileEntry(dest, destination);
|
||||
}
|
||||
}
|
||||
@ -390,9 +384,10 @@ Common::Archive *ResLoaderPak::load(Common::ArchiveMemberPtr memberFile, Common:
|
||||
|
||||
// -> ResLoaderInsMalcolm implementation
|
||||
|
||||
bool ResLoaderInsMalcolm::checkFilename(Common::String filename) const {
|
||||
filename.toUppercase();
|
||||
if (!filename.hasSuffix(".001"))
|
||||
bool ResLoaderInsMalcolm::checkFilename(const Common::String &filename) const {
|
||||
Common::String filenameFixed(filename);
|
||||
filenameFixed.toUppercase();
|
||||
if (!filenameFixed.hasSuffix(".001"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@ -448,16 +443,17 @@ Common::Archive *ResLoaderInsMalcolm::load(Common::ArchiveMemberPtr memberFile,
|
||||
const uint32 fileSize = stream.readUint32LE();
|
||||
const uint32 fileOffset = stream.pos();
|
||||
|
||||
result->addFileEntry(*file, PlainArchive::Entry(fileOffset, fileSize));
|
||||
result->addFileEntry(Common::Path(*file, Common::Path::kNoSeparator), PlainArchive::Entry(fileOffset, fileSize));
|
||||
stream.seek(fileSize, SEEK_CUR);
|
||||
}
|
||||
|
||||
return result.release();
|
||||
}
|
||||
|
||||
bool ResLoaderTlk::checkFilename(Common::String filename) const {
|
||||
filename.toUppercase();
|
||||
return (filename.hasSuffix(".TLK"));
|
||||
bool ResLoaderTlk::checkFilename(const Common::String &filename) const {
|
||||
Common::String filenameFixed(filename);
|
||||
filenameFixed.toUppercase();
|
||||
return (filenameFixed.hasSuffix(".TLK"));
|
||||
}
|
||||
|
||||
bool ResLoaderTlk::isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const {
|
||||
@ -920,7 +916,7 @@ uint8 FileExpander::calcCmdAndIndex(const uint8 *tbl, int16 ¶) {
|
||||
namespace {
|
||||
|
||||
struct InsArchive {
|
||||
Common::String filename;
|
||||
Common::Path filename;
|
||||
uint32 firstFile;
|
||||
uint32 startOffset;
|
||||
uint32 lastFile;
|
||||
@ -944,17 +940,17 @@ private:
|
||||
uint8 *_sndArray;
|
||||
};
|
||||
|
||||
Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &filename, const Common::String &extension, const uint8 containerOffset) {
|
||||
Common::Archive *InstallerLoader::load(Resource *owner, const Common::Path &filename, const Common::String &extension, const uint8 containerOffset) {
|
||||
uint32 pos = 0;
|
||||
uint32 bytesleft = 0;
|
||||
bool startFile = true;
|
||||
|
||||
Common::String filenameBase = filename;
|
||||
Common::String filenameTemp;
|
||||
Common::Path filenameBase = filename;
|
||||
Common::Path filenameTemp;
|
||||
char filenameExt[4];
|
||||
|
||||
if (filenameBase.lastChar() != '.')
|
||||
filenameBase += '.';
|
||||
if (filenameBase.baseName().lastChar() != '.')
|
||||
filenameBase.appendInPlace(".");
|
||||
|
||||
InsArchive newArchive;
|
||||
Common::List<InsArchive> archives;
|
||||
@ -963,10 +959,10 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
|
||||
|
||||
for (int8 currentFile = 1; currentFile; currentFile++) {
|
||||
Common::sprintf_s(filenameExt, extension.c_str(), currentFile);
|
||||
filenameTemp = filenameBase + Common::String(filenameExt);
|
||||
filenameTemp = filenameBase.append(filenameExt);
|
||||
|
||||
if (!(tmpFile = owner->createReadStream(filenameTemp))) {
|
||||
debug(3, "couldn't open file '%s'\n", filenameTemp.c_str());
|
||||
debug(3, "couldn't open file '%s'\n", filenameTemp.toString().c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1041,10 +1037,10 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
|
||||
startFile = true;
|
||||
for (uint32 i = a->firstFile; i != (a->lastFile + 1); i++) {
|
||||
Common::sprintf_s(filenameExt, extension.c_str(), i);
|
||||
filenameTemp = a->filename + Common::String(filenameExt);
|
||||
filenameTemp = a->filename.append(filenameExt);
|
||||
|
||||
if (!(tmpFile = owner->createReadStream(filenameTemp))) {
|
||||
debug(3, "couldn't open file '%s'\n", filenameTemp.c_str());
|
||||
debug(3, "couldn't open file '%s'\n", filenameTemp.toString().c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1116,7 +1112,7 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
|
||||
}
|
||||
|
||||
Common::sprintf_s(filenameExt, extension.c_str(), i + 1);
|
||||
filenameTemp = a->filename + Common::String(filenameExt);
|
||||
filenameTemp = a->filename.append(filenameExt);
|
||||
|
||||
Common::SeekableReadStream *tmpFile2 = owner->createReadStream(filenameTemp);
|
||||
tmpFile->read(hdr, m);
|
||||
@ -1217,11 +1213,11 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
|
||||
return new CachedArchive(fileList);
|
||||
}
|
||||
|
||||
Common::Archive *StuffItLoader::load(Resource *owner, const Common::String &filename) {
|
||||
return load(owner, Common::MacResManager::openFileOrDataFork(filename), filename);
|
||||
Common::Archive *StuffItLoader::load(Resource *owner, const Common::Path &filename) {
|
||||
return load(owner, Common::MacResManager::openFileOrDataFork(filename), filename.toString('/'));
|
||||
}
|
||||
|
||||
Common::Archive *StuffItLoader::load(Resource *owner, Common::SeekableReadStream *stream, const Common::String& debugName) {
|
||||
Common::Archive *StuffItLoader::load(Resource *owner, Common::SeekableReadStream *stream, const Common::String &debugName) {
|
||||
if (stream) {
|
||||
Common::Archive *archive = Common::createStuffItArchive(stream, true);
|
||||
return archive;
|
||||
|
@ -46,8 +46,8 @@ public:
|
||||
|
||||
PlainArchive(Common::ArchiveMemberPtr file);
|
||||
|
||||
void addFileEntry(const Common::String &name, const Entry entry);
|
||||
Entry getFileEntry(const Common::String &name) const;
|
||||
void addFileEntry(const Common::Path &name, const Entry entry);
|
||||
Entry getFileEntry(const Common::Path &name) const;
|
||||
|
||||
// Common::Archive API implementation
|
||||
bool hasFile(const Common::Path &path) const override;
|
||||
@ -55,7 +55,7 @@ public:
|
||||
const Common::ArchiveMemberPtr getMember(const Common::Path &path) const override;
|
||||
Common::SeekableReadStream *createReadStreamForMember(const Common::Path &path) const override;
|
||||
private:
|
||||
typedef Common::HashMap<Common::String, Entry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
|
||||
typedef Common::HashMap<Common::Path, Entry, Common::Path::IgnoreCase_Hash, Common::Path::IgnoreCase_EqualTo> FileMap;
|
||||
|
||||
Common::ArchiveMemberPtr _file;
|
||||
FileMap _files;
|
||||
@ -73,7 +73,7 @@ public:
|
||||
private:
|
||||
Common::ArchiveMemberPtr _file;
|
||||
|
||||
const uint32 *findFile(const Common::String &name) const;
|
||||
const uint32 *findFile(const Common::Path &path) const;
|
||||
|
||||
const uint16 _entryCount;
|
||||
const uint32 *const _fileEntries;
|
||||
@ -82,7 +82,7 @@ private:
|
||||
class CachedArchive : public Common::Archive {
|
||||
public:
|
||||
struct InputEntry {
|
||||
Common::String name;
|
||||
Common::Path name;
|
||||
|
||||
byte *data;
|
||||
uint32 size;
|
||||
@ -103,7 +103,7 @@ private:
|
||||
uint32 size;
|
||||
};
|
||||
|
||||
typedef Common::HashMap<Common::String, Entry, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> FileMap;
|
||||
typedef Common::HashMap<Common::Path, Entry, Common::Path::IgnoreCase_Hash, Common::Path::IgnoreCase_EqualTo> FileMap;
|
||||
FileMap _files;
|
||||
};
|
||||
|
||||
@ -111,40 +111,40 @@ private:
|
||||
class ResArchiveLoader {
|
||||
public:
|
||||
virtual ~ResArchiveLoader() {}
|
||||
virtual bool checkFilename(Common::String filename) const = 0;
|
||||
virtual bool checkFilename(const Common::String &filename) const = 0;
|
||||
virtual bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const = 0;
|
||||
virtual Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const = 0;
|
||||
};
|
||||
|
||||
class ResLoaderPak : public ResArchiveLoader {
|
||||
public:
|
||||
bool checkFilename(Common::String filename) const override;
|
||||
bool checkFilename(const Common::String &filename) const override;
|
||||
bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const override;
|
||||
Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const override;
|
||||
};
|
||||
|
||||
class ResLoaderInsMalcolm : public ResArchiveLoader {
|
||||
public:
|
||||
bool checkFilename(Common::String filename) const override;
|
||||
bool checkFilename(const Common::String &filename) const override;
|
||||
bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const override;
|
||||
Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const override;
|
||||
};
|
||||
|
||||
class ResLoaderTlk : public ResArchiveLoader {
|
||||
public:
|
||||
bool checkFilename(Common::String filename) const override;
|
||||
bool checkFilename(const Common::String &filename) const override;
|
||||
bool isLoadable(const Common::String &filename, Common::SeekableReadStream &stream) const override;
|
||||
Common::Archive *load(Common::ArchiveMemberPtr file, Common::SeekableReadStream &stream) const override;
|
||||
};
|
||||
|
||||
class InstallerLoader {
|
||||
public:
|
||||
static Common::Archive *load(Resource *owner, const Common::String &filename, const Common::String &extension, const uint8 offset);
|
||||
static Common::Archive *load(Resource *owner, const Common::Path &filename, const Common::String &extension, const uint8 offset);
|
||||
};
|
||||
|
||||
class StuffItLoader {
|
||||
public:
|
||||
static Common::Archive *load(Resource *owner, const Common::String &filename);
|
||||
static Common::Archive *load(Resource *owner, const Common::Path &filename);
|
||||
static Common::Archive *load(Resource *owner, Common::SeekableReadStream *stream, const Common::String &debugName);
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,7 @@ SegaCDResource::~SegaCDResource() {
|
||||
unloadContainer();
|
||||
}
|
||||
|
||||
bool SegaCDResource::loadContainer(const Common::String &filename, uint32 offset, uint32 size) {
|
||||
bool SegaCDResource::loadContainer(const Common::Path &filename, uint32 offset, uint32 size) {
|
||||
if (_curFile.equals(filename) && _curOffset == offset && _curSize == size)
|
||||
return true;
|
||||
|
||||
@ -43,7 +43,7 @@ bool SegaCDResource::loadContainer(const Common::String &filename, uint32 offset
|
||||
|
||||
_str = _res->createEndianAwareReadStream(filename);
|
||||
if (!_str) {
|
||||
error("SegaCDResource: File '%s' not found.", filename.c_str());
|
||||
error("SegaCDResource: File '%s' not found.", filename.toString().c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
SegaCDResource(Resource *res);
|
||||
~SegaCDResource();
|
||||
|
||||
bool loadContainer(const Common::String &filename, uint32 offset = 0, uint32 size = 0);
|
||||
bool loadContainer(const Common::Path &filename, uint32 offset = 0, uint32 size = 0);
|
||||
void unloadContainer();
|
||||
|
||||
Common::SeekableReadStreamEndian *resStreamEndian(int resID);
|
||||
@ -60,7 +60,7 @@ private:
|
||||
TableEntry *_resTable;
|
||||
int _numResources;
|
||||
Common::SeekableReadStreamEndian *_str;
|
||||
Common::String _curFile;
|
||||
Common::Path _curFile;
|
||||
uint32 _curOffset;
|
||||
uint32 _curSize;
|
||||
};
|
||||
|
@ -142,7 +142,7 @@ bool StaticResource::loadStaticResourceFile() {
|
||||
return true;
|
||||
|
||||
Common::ArchiveMemberList kyraDatFiles;
|
||||
res->listFiles(staticDataFilename(), kyraDatFiles);
|
||||
res->listFiles(Common::Path(staticDataFilename()), kyraDatFiles);
|
||||
|
||||
bool foundWorkingKyraDat = false;
|
||||
for (Common::ArchiveMemberList::iterator i = kyraDatFiles.begin(); i != kyraDatFiles.end(); ++i) {
|
||||
@ -218,7 +218,7 @@ Common::SeekableReadStream *StaticResource::loadIdMap(Common::Language lang) {
|
||||
|
||||
|
||||
// load the ID map for our game
|
||||
const Common::String filenamePattern = Common::String::format("0%01X%01X%01X000%01X", game, platform, special, lng);
|
||||
const Common::Path filenamePattern(Common::String::format("0%01X%01X%01X000%01X", game, platform, special, lng));
|
||||
return _vm->resource()->createReadStream(filenamePattern);
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ bool StaticResource::prefetchId(int id) {
|
||||
ResData data;
|
||||
data.id = id;
|
||||
data.type = dDesc->_value.type;
|
||||
Common::SeekableReadStream *fileStream = _vm->resource()->createReadStream(Common::String::format("%08X", dDesc->_value.filename));
|
||||
Common::SeekableReadStream *fileStream = _vm->resource()->createReadStream(Common::Path(Common::String::format("%08X", dDesc->_value.filename)));
|
||||
if (!fileStream)
|
||||
return false;
|
||||
|
||||
|
@ -1219,7 +1219,7 @@ void DarkmoonSequenceHelper::loadScene(int index, int pageNum, bool ignorePalett
|
||||
|
||||
if (_config->cpsFiles) {
|
||||
file = _config->cpsFiles[index];
|
||||
s = _vm->resource()->createReadStream(file);
|
||||
s = _vm->resource()->createReadStream(Common::Path(file));
|
||||
}
|
||||
|
||||
if (s) {
|
||||
@ -1254,7 +1254,7 @@ void DarkmoonSequenceHelper::loadScene(int index, int pageNum, bool ignorePalett
|
||||
} else {
|
||||
if (!s) {
|
||||
file.setChar('X', 0);
|
||||
s = _vm->resource()->createReadStream(file);
|
||||
s = _vm->resource()->createReadStream(Common::Path(file));
|
||||
}
|
||||
|
||||
if (!s)
|
||||
|
@ -395,7 +395,7 @@ SeqPlayer_HOF::SeqPlayer_HOF(KyraEngine_v1 *vm, Screen_v2 *screen, OSystem *syst
|
||||
|
||||
int tempSize = 0;
|
||||
_vm->resource()->unloadAllPakFiles();
|
||||
_vm->resource()->loadPakFile(StaticResource::staticDataFilename());
|
||||
_vm->resource()->loadPakFile(Common::Path(StaticResource::staticDataFilename()));
|
||||
const char *const *files = _vm->staticres()->loadStrings(k2SeqplayPakFiles, tempSize);
|
||||
_vm->resource()->loadFileList(files, tempSize);
|
||||
|
||||
|
@ -172,18 +172,18 @@ void LoLEngine::setupPrologueData(bool load) {
|
||||
|
||||
const char *const *fileList = _flags.isTalkie ? (_flags.isDemo ? fileListCDDemo : fileListCD) : (_flags.platform == Common::kPlatformFMTowns ? fileListTowns : fileListFloppy);
|
||||
|
||||
Common::String filename;
|
||||
Common::Path filename;
|
||||
for (uint i = 0; fileList[i]; ++i) {
|
||||
filename.clear();
|
||||
|
||||
if (_flags.isTalkie && !_flags.isDemo)
|
||||
filename = Common::String(_languageExt[_lang]) + "/";
|
||||
filename = Common::Path(_languageExt[_lang]);
|
||||
|
||||
filename += fileList[i];
|
||||
filename.joinInPlace(fileList[i]);
|
||||
|
||||
if (load) {
|
||||
if (!_res->loadPakFile(filename))
|
||||
error("Couldn't load file: '%s'", filename.c_str());
|
||||
error("Couldn't load file: '%s'", filename.toString().c_str());
|
||||
} else {
|
||||
_res->unloadPakFile(filename);
|
||||
}
|
||||
@ -1064,18 +1064,18 @@ void LoLEngine::setupEpilogueData(bool load) {
|
||||
const char *const *fileList = _flags.isTalkie ? fileListCD : (_flags.platform == Common::kPlatformFMTowns ? fileListTowns : fileListFloppy);
|
||||
assert(fileList);
|
||||
|
||||
Common::String filename;
|
||||
Common::Path filename;
|
||||
for (uint i = 0; fileList[i]; ++i) {
|
||||
filename.clear();
|
||||
|
||||
if (_flags.isTalkie)
|
||||
filename = Common::String(_languageExt[_lang]) + "/";
|
||||
filename = Common::Path(_languageExt[_lang]);
|
||||
|
||||
filename += fileList[i];
|
||||
filename.joinInPlace(fileList[i]);
|
||||
|
||||
if (load) {
|
||||
if (!_res->loadPakFile(filename))
|
||||
error("Couldn't load file: '%s'", filename.c_str());
|
||||
error("Couldn't load file: '%s'", filename.toString().c_str());
|
||||
} else {
|
||||
_res->unloadPakFile(filename);
|
||||
}
|
||||
|
@ -77,12 +77,12 @@ int32 Sound::voicePlay(const char *file, Audio::SoundHandle *handle, uint8 volum
|
||||
}
|
||||
|
||||
Audio::SeekableAudioStream *Sound::getVoiceStream(const char *file) const {
|
||||
Common::String filename;
|
||||
Common::Path filename;
|
||||
|
||||
Audio::SeekableAudioStream *audioStream = nullptr;
|
||||
for (int i = 0; _supportedCodecs[i].fileext; ++i) {
|
||||
filename = file;
|
||||
filename += _supportedCodecs[i].fileext;
|
||||
filename.appendInPlace(_supportedCodecs[i].fileext);
|
||||
|
||||
Common::SeekableReadStream *stream = _vm->resource()->createReadStream(filename);
|
||||
if (!stream)
|
||||
@ -213,13 +213,13 @@ void MixedSoundDriver::loadSoundFile(uint file) {
|
||||
_sfx->loadSoundFile(file);
|
||||
}
|
||||
|
||||
void MixedSoundDriver::loadSoundFile(Common::String file) {
|
||||
void MixedSoundDriver::loadSoundFile(const Common::Path &file) {
|
||||
_music->loadSoundFile(file);
|
||||
_sfx->loadSoundFile(Common::move(file));
|
||||
_sfx->loadSoundFile(file);
|
||||
}
|
||||
|
||||
void MixedSoundDriver::loadSfxFile(Common::String file) {
|
||||
_sfx->loadSoundFile(Common::move(file));
|
||||
void MixedSoundDriver::loadSfxFile(const Common::Path &file) {
|
||||
_sfx->loadSoundFile(file);
|
||||
}
|
||||
|
||||
void MixedSoundDriver::playTrack(uint8 track) {
|
||||
|
@ -165,18 +165,18 @@ public:
|
||||
* Load a sound file for playing music
|
||||
* (and sometimes sound effects) from.
|
||||
*/
|
||||
virtual void loadSoundFile(Common::String file) = 0;
|
||||
virtual void loadSoundFile(const Common::Path &file) = 0;
|
||||
|
||||
/**
|
||||
* Unload a specifc sound file that has been loaded before.
|
||||
*/
|
||||
virtual void unloadSoundFile(Common::String file) {}
|
||||
virtual void unloadSoundFile(const Common::String &file) {}
|
||||
|
||||
/**
|
||||
* Load a sound file for playing sound
|
||||
* effects from.
|
||||
*/
|
||||
virtual void loadSfxFile(Common::String file) {}
|
||||
virtual void loadSfxFile(const Common::Path &file) {}
|
||||
|
||||
/**
|
||||
* Plays the specified track.
|
||||
@ -342,9 +342,9 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override;
|
||||
void loadSoundFile(uint file) override;
|
||||
void loadSoundFile(Common::String file) override;
|
||||
void loadSoundFile(const Common::Path &file) override;
|
||||
|
||||
void loadSfxFile(Common::String file) override;
|
||||
void loadSfxFile(const Common::Path &file) override;
|
||||
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
|
@ -76,12 +76,12 @@ void SoundAmiga_EoB::selectAudioResourceSet(int set) {
|
||||
_currentResourceSet = set;
|
||||
}
|
||||
|
||||
void SoundAmiga_EoB::loadSoundFile(Common::String file) {
|
||||
void SoundAmiga_EoB::loadSoundFile(const Common::Path &file) {
|
||||
if (!_ready)
|
||||
return;
|
||||
|
||||
Common::SeekableReadStream *in = _vm->resource()->createReadStream(file);
|
||||
debugC(6, kDebugLevelSound, "SoundAmiga_EoB::loadSoundFile(): Attempting to load sound file '%s'...%s", file.c_str(), in ? "SUCCESS" : "FILE NOT FOUND");
|
||||
debugC(6, kDebugLevelSound, "SoundAmiga_EoB::loadSoundFile(): Attempting to load sound file '%s'...%s", file.toString().c_str(), in ? "SUCCESS" : "FILE NOT FOUND");
|
||||
if (!in)
|
||||
return;
|
||||
|
||||
@ -110,17 +110,17 @@ void SoundAmiga_EoB::loadSoundFile(Common::String file) {
|
||||
} else if (cmp == 4) {
|
||||
Screen::decodeFrame4(_fileBuffer, buf, outSize);
|
||||
} else {
|
||||
error("SoundAmiga_EoB::loadSoundFile(): Failed to load sound file '%s'", file.c_str());
|
||||
error("SoundAmiga_EoB::loadSoundFile(): Failed to load sound file '%s'", file.toString().c_str());
|
||||
}
|
||||
|
||||
Common::MemoryReadStream soundFile(buf, outSize);
|
||||
if (!_driver->loadRessourceFile(&soundFile))
|
||||
error("SoundAmiga_EoB::loadSoundFile(): Failed to load sound file '%s'", file.c_str());
|
||||
error("SoundAmiga_EoB::loadSoundFile(): Failed to load sound file '%s'", file.toString().c_str());
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
void SoundAmiga_EoB::unloadSoundFile(Common::String file) {
|
||||
void SoundAmiga_EoB::unloadSoundFile(const Common::String &file) {
|
||||
if (!_ready)
|
||||
return;
|
||||
debugC(5, kDebugLevelSound, "SoundAmiga_EoB::unloadSoundFile(): Attempting to free resource '%s'...%s", file.c_str(), _driver->stopSound(file) ? "SUCCESS" : "FAILURE");
|
||||
|
@ -150,10 +150,10 @@ int SoundDigital_MR::playSound(const char *filename, uint8 priority, Audio::Mixe
|
||||
Common::SeekableReadStream *stream = nullptr;
|
||||
int usedCodec = -1;
|
||||
for (int i = 0; _supportedCodecs[i].fileext; ++i) {
|
||||
Common::String file = filename;
|
||||
file += _supportedCodecs[i].fileext;
|
||||
Common::Path file(filename);
|
||||
file.appendInPlace(_supportedCodecs[i].fileext);
|
||||
|
||||
if (!_vm->resource()->exists(file.c_str()))
|
||||
if (!_vm->resource()->exists(file))
|
||||
continue;
|
||||
|
||||
stream = _vm->resource()->createReadStream(file);
|
||||
|
@ -70,8 +70,8 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override;
|
||||
void loadSoundFile(uint file) override;
|
||||
void loadSoundFile(Common::String file) override;
|
||||
void loadSfxFile(Common::String file) override;
|
||||
void loadSoundFile(const Common::Path &file) override;
|
||||
void loadSfxFile(const Common::Path &file) override;
|
||||
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
@ -93,7 +93,7 @@ private:
|
||||
bool _fadeMusicOut;
|
||||
|
||||
// Midi file related
|
||||
Common::String _mFileName, _sFileName;
|
||||
Common::Path _mFileName, _sFileName;
|
||||
byte *_musicFile, *_sfxFile;
|
||||
|
||||
MidiParser *_music;
|
||||
@ -105,7 +105,7 @@ private:
|
||||
|
||||
// misc
|
||||
kType _type;
|
||||
Common::String getFileName(const Common::String &str);
|
||||
Common::Path getFileName(const Common::Path &str);
|
||||
|
||||
bool _nativeMT32;
|
||||
MidiDriver *_driver;
|
||||
@ -128,7 +128,7 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override;
|
||||
void loadSoundFile(uint file) override;
|
||||
void loadSoundFile(Common::String) override {}
|
||||
void loadSoundFile(const Common::Path &) override {}
|
||||
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
@ -182,7 +182,7 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override;
|
||||
void loadSoundFile(uint file) override;
|
||||
void loadSoundFile(Common::String file) override;
|
||||
void loadSoundFile(const Common::Path &file) override;
|
||||
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
@ -218,7 +218,7 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override;
|
||||
void loadSoundFile(uint file) override {}
|
||||
void loadSoundFile(Common::String file) override;
|
||||
void loadSoundFile(const Common::Path &file) override;
|
||||
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
@ -333,7 +333,7 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override;
|
||||
void loadSoundFile(uint file) override;
|
||||
void loadSoundFile(Common::String) override {}
|
||||
void loadSoundFile(const Common::Path &) override {}
|
||||
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
@ -369,7 +369,7 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint) const override { return true; }
|
||||
void loadSoundFile(uint) override {}
|
||||
void loadSoundFile(Common::String) override {}
|
||||
void loadSoundFile(const Common::Path &) override {}
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
void playSoundEffect(uint16 track, uint8) override;
|
||||
@ -423,7 +423,7 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override;
|
||||
void loadSoundFile(uint file) override;
|
||||
void loadSoundFile(Common::String name) override;
|
||||
void loadSoundFile(const Common::Path &name) override;
|
||||
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
@ -477,8 +477,8 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override { return false; }
|
||||
void loadSoundFile(uint) override {}
|
||||
void loadSoundFile(Common::String file) override;
|
||||
void unloadSoundFile(Common::String file) override;
|
||||
void loadSoundFile(const Common::Path &file) override;
|
||||
void unloadSoundFile(const Common::String &file) override;
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
void playSoundEffect(uint16 track, uint8 volume = 0xFF) override;
|
||||
@ -513,8 +513,8 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override { return false; }
|
||||
void loadSoundFile(uint file) override;
|
||||
void loadSoundFile(Common::String file) override {}
|
||||
void loadSfxFile(Common::String file) override;
|
||||
void loadSoundFile(const Common::Path &file) override {}
|
||||
void loadSfxFile(const Common::Path &file) override;
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
void playSoundEffect(uint16 track, uint8) override;
|
||||
@ -548,7 +548,7 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override { return true; }
|
||||
void loadSoundFile(uint file) override;
|
||||
void loadSoundFile(Common::String name) override;
|
||||
void loadSoundFile(const Common::Path &name) override;
|
||||
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
@ -580,7 +580,7 @@ private:
|
||||
SoundResourceInfo_PC *_resInfo[3];
|
||||
int _currentResourceSet;
|
||||
|
||||
Common::String _soundFileLoaded;
|
||||
Common::Path _soundFileLoaded;
|
||||
|
||||
MidiDriver::DeviceHandle _dev;
|
||||
kType _drvType;
|
||||
@ -600,7 +600,7 @@ public:
|
||||
void selectAudioResourceSet(int) override {}
|
||||
bool hasSoundFile(uint file) const override { return false; }
|
||||
void loadSoundFile(uint file) override {}
|
||||
void loadSoundFile(Common::String file) override {}
|
||||
void loadSoundFile(const Common::Path &file) override {}
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
void playSoundEffect(uint16 track, uint8 volume) override;
|
||||
|
@ -251,7 +251,7 @@ void LoLEngine::snd_loadSoundFile(int track) {
|
||||
int t = (track - 250) * 3;
|
||||
if (t < 0 || (_curMusicFileIndex == _musicTrackMap[t] && _curMusicFileExt == (char)_musicTrackMap[t + 1]))
|
||||
return;
|
||||
_sound->loadSoundFile(Common::String::format("LORE%02d%c", _musicTrackMap[t], (char)_musicTrackMap[t + 1]));
|
||||
_sound->loadSoundFile(Common::Path(Common::String::format("LORE%02d%c", _musicTrackMap[t], (char)_musicTrackMap[t + 1])));
|
||||
_curMusicFileIndex = _musicTrackMap[t];
|
||||
_curMusicFileExt = (char)_musicTrackMap[t + 1];
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ bool SoundMacRes::init() {
|
||||
if (!_resMan)
|
||||
return false;
|
||||
|
||||
_kyraMacExe = _stuffItArchive ? "Legend of Kyrandia\xaa" : Util::findMacResourceFile("Legend of Kyrandia");
|
||||
_kyraMacExe = _stuffItArchive ? Common::Path("Legend of Kyrandia\xaa") : Util::findMacResourceFile("Legend of Kyrandia");
|
||||
if (_kyraMacExe.empty() && _isTalkie)
|
||||
_kyraMacExe = Util::findMacResourceFile("LK");
|
||||
|
||||
@ -99,23 +99,23 @@ Common::SeekableReadStream *SoundMacRes::getResource(uint16 id, uint32 type) {
|
||||
|
||||
bool SoundMacRes::setQuality(bool hi) {
|
||||
Common::StackLock lock(_mutex);
|
||||
Common::String s[2];
|
||||
Common::Path s[2];
|
||||
s[0] = hi ? "HQ_Music.res" : "LQ_Music.res";
|
||||
s[1] = _kyraMacExe;
|
||||
int err = 0;
|
||||
|
||||
if (_stuffItArchive) {
|
||||
for (int i = 0; i < 2; ++i)
|
||||
err |= (_resMan[i].open(Common::Path(s[i]), *_stuffItArchive) ? 0 : (1 << i));
|
||||
err |= (_resMan[i].open(s[i], *_stuffItArchive) ? 0 : (1 << i));
|
||||
} else {
|
||||
for (int i = 0; i < 2; ++i)
|
||||
err |= (_resMan[i].open(Common::Path(s[i])) ? 0 : (1 << i));
|
||||
err |= (_resMan[i].open(s[i]) ? 0 : (1 << i));
|
||||
}
|
||||
|
||||
if (err) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if (err & (1 << i))
|
||||
warning("SoundMacRes::setQuality(): Error opening resource container: '%s'", s[i].c_str());
|
||||
warning("SoundMacRes::setQuality(): Error opening resource container: '%s'", s[i].toString().c_str());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
Common::SeekableReadStream *getResource(uint16 id, uint32 type);
|
||||
|
||||
private:
|
||||
Common::String _kyraMacExe;
|
||||
Common::Path _kyraMacExe;
|
||||
Common::MacResManager *_resMan;
|
||||
Common::Archive *_stuffItArchive;
|
||||
Common::Mutex _mutex;
|
||||
|
@ -89,27 +89,28 @@ void SoundPC98_Darkmoon::loadSoundFile(uint file) {
|
||||
loadSoundFile(res()->fileList[file]);
|
||||
}
|
||||
|
||||
void SoundPC98_Darkmoon::loadSoundFile(Common::String name) {
|
||||
void SoundPC98_Darkmoon::loadSoundFile(const Common::Path &name) {
|
||||
if (!_ready)
|
||||
return;
|
||||
|
||||
haltTrack();
|
||||
stopAllSoundEffects();
|
||||
|
||||
name += (_drvType == kPC98 ? ".SDO" : ".SDM");
|
||||
if (!_ready || _soundFileLoaded == name)
|
||||
Common::Path path(name);
|
||||
path.appendInPlace(_drvType == kPC98 ? ".SDO" : ".SDM");
|
||||
if (!_ready || _soundFileLoaded == path)
|
||||
return;
|
||||
|
||||
Common::SeekableReadStream *in = _vm->resource()->createReadStream(name.c_str());
|
||||
Common::SeekableReadStream *in = _vm->resource()->createReadStream(path);
|
||||
if (!in)
|
||||
error("SoundPC98_Darkmoon::loadSoundFile(): Failed to load sound file '%s'", name.c_str());
|
||||
error("SoundPC98_Darkmoon::loadSoundFile(): Failed to load sound file '%s'", path.toString().c_str());
|
||||
|
||||
uint16 sz = in->readUint16LE();
|
||||
uint8 cmp = in->readByte();
|
||||
in->seek(1, SEEK_CUR);
|
||||
uint32 outSize = in->readUint32LE();
|
||||
if ((cmp == 0 && outSize > 10500) || (cmp != 0 && outSize > 20600))
|
||||
error("SoundPC98_Darkmoon::loadSoundFile(): Failed to load sound file '%s'", name.c_str());
|
||||
error("SoundPC98_Darkmoon::loadSoundFile(): Failed to load sound file '%s'", path.toString().c_str());
|
||||
sz -= in->pos();
|
||||
in->seek(2, SEEK_CUR);
|
||||
|
||||
@ -126,12 +127,12 @@ void SoundPC98_Darkmoon::loadSoundFile(Common::String name) {
|
||||
} else if (cmp == 4) {
|
||||
Screen::decodeFrame4(_fileBuffer, _soundData, outSize);
|
||||
} else {
|
||||
error("SoundPC98_Darkmoon::loadSoundFile(): Failed to load sound file '%s'", name.c_str());
|
||||
error("SoundPC98_Darkmoon::loadSoundFile(): Failed to load sound file '%s'", path.toString().c_str());
|
||||
}
|
||||
|
||||
uint16 instrOffs = READ_LE_UINT16(_soundData);
|
||||
if (instrOffs >= 20600)
|
||||
error("SoundPC98_Darkmoon::loadSoundFile(): Failed to load sound file '%s'", name.c_str());
|
||||
error("SoundPC98_Darkmoon::loadSoundFile(): Failed to load sound file '%s'", path.toString().c_str());
|
||||
|
||||
_driver->loadFMInstruments(_soundData + instrOffs);
|
||||
_driver->reset();
|
||||
|
@ -78,7 +78,7 @@ void SoundPC98_EoB::loadSoundFile(uint file) {
|
||||
delete s;
|
||||
}
|
||||
|
||||
void SoundPC98_EoB::loadSfxFile(Common::String file) {
|
||||
void SoundPC98_EoB::loadSfxFile(const Common::Path &file) {
|
||||
if (!_ready)
|
||||
return;
|
||||
|
||||
|
@ -85,9 +85,9 @@ void SoundPC98_LoK::loadSoundFile(uint) {
|
||||
}
|
||||
}
|
||||
|
||||
void SoundPC98_LoK::loadSoundFile(Common::String file) {
|
||||
void SoundPC98_LoK::loadSoundFile(const Common::Path &file) {
|
||||
delete[] _sfxTrackData;
|
||||
_sfxTrackData = _vm->resource()->fileData(file.c_str(), nullptr);
|
||||
_sfxTrackData = _vm->resource()->fileData(file, nullptr);
|
||||
}
|
||||
|
||||
void SoundPC98_LoK::playTrack(uint8 track) {
|
||||
|
@ -107,9 +107,9 @@ bool SoundTownsPC98_v2::hasSoundFile(uint file) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SoundTownsPC98_v2::loadSoundFile(Common::String file) {
|
||||
void SoundTownsPC98_v2::loadSoundFile(const Common::Path &file) {
|
||||
delete[] _sfxTrackData;
|
||||
_sfxTrackData = _vm->resource()->fileData(file.c_str(), nullptr);
|
||||
_sfxTrackData = _vm->resource()->fileData(file, nullptr);
|
||||
}
|
||||
|
||||
void SoundTownsPC98_v2::process() {
|
||||
|
@ -232,14 +232,14 @@ void SoundMidiPC::loadSoundFile(uint file) {
|
||||
loadSoundFile(res()->fileList[file]);
|
||||
}
|
||||
|
||||
void SoundMidiPC::loadSoundFile(Common::String file) {
|
||||
void SoundMidiPC::loadSoundFile(const Common::Path &file) {
|
||||
Common::StackLock lock(_mutex);
|
||||
file = getFileName(file);
|
||||
Common::Path path = getFileName(file);
|
||||
|
||||
if (_mFileName == file)
|
||||
if (_mFileName == path)
|
||||
return;
|
||||
|
||||
if (!_vm->resource()->exists(file.c_str()))
|
||||
if (!_vm->resource()->exists(path))
|
||||
return;
|
||||
|
||||
haltTrack();
|
||||
@ -249,8 +249,8 @@ void SoundMidiPC::loadSoundFile(Common::String file) {
|
||||
|
||||
delete[] _musicFile;
|
||||
uint32 fileSize = 0;
|
||||
_musicFile = _vm->resource()->fileData(file.c_str(), &fileSize);
|
||||
_mFileName = file;
|
||||
_musicFile = _vm->resource()->fileData(path, &fileSize);
|
||||
_mFileName = path;
|
||||
|
||||
_music->loadMusic(_musicFile, fileSize);
|
||||
|
||||
@ -269,7 +269,7 @@ void SoundMidiPC::loadSoundFile(Common::String file) {
|
||||
// are sent in a different order, but that makes no practical difference.)
|
||||
// The initial pitch bend neutral events are then sent again when the track
|
||||
// loops.
|
||||
if (file == "LOREINTR.XMI" && fileSize >= 0x6221 && _musicFile[0x6210] == 0xE1) {
|
||||
if (path == "LOREINTR.XMI" && fileSize >= 0x6221 && _musicFile[0x6210] == 0xE1) {
|
||||
// MT-32 floppy version.
|
||||
|
||||
// Overwrite first pitch bend event with for loop event.
|
||||
@ -281,7 +281,7 @@ void SoundMidiPC::loadSoundFile(Common::String file) {
|
||||
_musicFile[0x621F] = 0xE1;
|
||||
_musicFile[0x6220] = 0x00;
|
||||
_musicFile[0x6221] = 0x40;
|
||||
} else if (file == "LOREINTR.C55" && fileSize >= 0x216D && _musicFile[0x215C] == 0xE0) {
|
||||
} else if (path == "LOREINTR.C55" && fileSize >= 0x216D && _musicFile[0x215C] == 0xE0) {
|
||||
// GM floppy and CD version.
|
||||
|
||||
// Overwrite first pitch bend event with for loop event.
|
||||
@ -304,19 +304,19 @@ void SoundMidiPC::loadSoundFile(Common::String file) {
|
||||
}
|
||||
}
|
||||
|
||||
void SoundMidiPC::loadSfxFile(Common::String file) {
|
||||
void SoundMidiPC::loadSfxFile(const Common::Path &file) {
|
||||
Common::StackLock lock(_mutex);
|
||||
|
||||
// Kyrandia 1 doesn't use a special sfx file
|
||||
if (_vm->game() == GI_KYRA1)
|
||||
return;
|
||||
|
||||
file = getFileName(file);
|
||||
Common::Path path = getFileName(file);
|
||||
|
||||
if (_sFileName == file)
|
||||
if (_sFileName == path)
|
||||
return;
|
||||
|
||||
if (!_vm->resource()->exists(file.c_str()))
|
||||
if (!_vm->resource()->exists(path))
|
||||
return;
|
||||
|
||||
stopAllSoundEffects();
|
||||
@ -324,8 +324,8 @@ void SoundMidiPC::loadSfxFile(Common::String file) {
|
||||
delete[] _sfxFile;
|
||||
|
||||
uint32 fileSize = 0;
|
||||
_sfxFile = _vm->resource()->fileData(file.c_str(), &fileSize);
|
||||
_sFileName = file;
|
||||
_sfxFile = _vm->resource()->fileData(path, &fileSize);
|
||||
_sFileName = path;
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
_sfx[i]->loadMusic(_sfxFile, fileSize);
|
||||
@ -437,19 +437,19 @@ void SoundMidiPC::onTimer(void *data) {
|
||||
}
|
||||
}
|
||||
|
||||
Common::String SoundMidiPC::getFileName(const Common::String &str) {
|
||||
Common::String file = str;
|
||||
Common::Path SoundMidiPC::getFileName(const Common::Path &str) {
|
||||
Common::Path file(str);
|
||||
if (_type == kMidiMT32)
|
||||
file += ".XMI";
|
||||
file.appendInPlace(".XMI");
|
||||
else if (_type == kMidiGM)
|
||||
file += ".C55";
|
||||
file.appendInPlace(".C55");
|
||||
else if (_type == kPCSpkr)
|
||||
file += ".PCS";
|
||||
file.appendInPlace(".PCS");
|
||||
|
||||
if (_vm->resource()->exists(file.c_str()))
|
||||
if (_vm->resource()->exists(file))
|
||||
return file;
|
||||
|
||||
return str + ".XMI";
|
||||
return str.append(".XMI");
|
||||
}
|
||||
|
||||
} // End of namespace Kyra
|
||||
|
@ -211,13 +211,14 @@ void SoundPC_v1::loadSoundFile(uint file) {
|
||||
internalLoadFile(res()->fileList[file]);
|
||||
}
|
||||
|
||||
void SoundPC_v1::loadSoundFile(Common::String file) {
|
||||
internalLoadFile(Common::move(file));
|
||||
void SoundPC_v1::loadSoundFile(const Common::Path &file) {
|
||||
internalLoadFile(file);
|
||||
}
|
||||
|
||||
void SoundPC_v1::internalLoadFile(Common::String file) {
|
||||
file += ((_version == 1) ? ".DAT" : (_type == kPCSpkr ? ".SND" : ".ADL"));
|
||||
if (_soundFileLoaded == file)
|
||||
void SoundPC_v1::internalLoadFile(const Common::Path &file) {
|
||||
Common::Path path(file);
|
||||
path.appendInPlace((_version == 1) ? ".DAT" : (_type == kPCSpkr ? ".SND" : ".ADL"));
|
||||
if (_soundFileLoaded == path)
|
||||
return;
|
||||
|
||||
if (_soundDataPtr)
|
||||
@ -225,9 +226,9 @@ void SoundPC_v1::internalLoadFile(Common::String file) {
|
||||
|
||||
uint8 *fileData = nullptr; uint32 fileSize = 0;
|
||||
|
||||
fileData = _vm->resource()->fileData(file.c_str(), &fileSize);
|
||||
fileData = _vm->resource()->fileData(path, &fileSize);
|
||||
if (!fileData) {
|
||||
warning("Couldn't find music file: '%s'", file.c_str());
|
||||
warning("Couldn't find music file: '%s'", path.toString().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -259,7 +260,7 @@ void SoundPC_v1::internalLoadFile(Common::String file) {
|
||||
delete[] fileData;
|
||||
delete[] oldData;
|
||||
|
||||
_soundFileLoaded = file;
|
||||
_soundFileLoaded = path;
|
||||
}
|
||||
|
||||
} // End of namespace Kyra
|
||||
|
@ -62,7 +62,7 @@ public:
|
||||
void selectAudioResourceSet(int set) override;
|
||||
bool hasSoundFile(uint file) const override;
|
||||
void loadSoundFile(uint file) override;
|
||||
void loadSoundFile(Common::String file) override;
|
||||
void loadSoundFile(const Common::Path &file) override;
|
||||
|
||||
void playTrack(uint8 track) override;
|
||||
void haltTrack() override;
|
||||
@ -75,7 +75,7 @@ public:
|
||||
int checkTrigger() override;
|
||||
void resetTrigger() override;
|
||||
private:
|
||||
void internalLoadFile(Common::String file);
|
||||
void internalLoadFile(const Common::Path &file);
|
||||
|
||||
void play(uint8 track, uint8 volume);
|
||||
|
||||
@ -91,7 +91,7 @@ private:
|
||||
uint8 *_soundDataPtr;
|
||||
int _sfxPlayingSound;
|
||||
|
||||
Common::String _soundFileLoaded;
|
||||
Common::Path _soundFileLoaded;
|
||||
|
||||
int _numSoundTriggers;
|
||||
const int *_soundTriggers;
|
||||
|
@ -123,10 +123,10 @@ void SoundTowns_Darkmoon::loadSoundFile(uint file) {
|
||||
loadSoundFile(_fileList[file]);
|
||||
}
|
||||
|
||||
void SoundTowns_Darkmoon::loadSoundFile(Common::String name) {
|
||||
Common::SeekableReadStream *s = _vm->resource()->createReadStream(Common::String::format("%s.SDT", name.c_str()));
|
||||
void SoundTowns_Darkmoon::loadSoundFile(const Common::Path &name) {
|
||||
Common::SeekableReadStream *s = _vm->resource()->createReadStream(name.append(".SDT"));
|
||||
if (!s)
|
||||
error("Failed to load sound file '%s.SDT'", name.c_str());
|
||||
error("Failed to load sound file '%s.SDT'", name.toString().c_str());
|
||||
|
||||
for (int i = 0; i < 120; i++) {
|
||||
_soundTable[i].type = s->readSByte();
|
||||
@ -137,7 +137,7 @@ void SoundTowns_Darkmoon::loadSoundFile(Common::String name) {
|
||||
delete s;
|
||||
|
||||
uint32 bytesLeft;
|
||||
uint8 *pmb = _vm->resource()->fileData(Common::String::format("%s.PMB", name.c_str()).c_str(), &bytesLeft);
|
||||
uint8 *pmb = _vm->resource()->fileData(name.append(".PMB"), &bytesLeft);
|
||||
|
||||
_vm->delay(300);
|
||||
|
||||
@ -159,7 +159,7 @@ void SoundTowns_Darkmoon::loadSoundFile(Common::String name) {
|
||||
|
||||
delete[] pmb;
|
||||
} else {
|
||||
warning("Sound file '%s.PMB' not found.", name.c_str());
|
||||
warning("Sound file '%s.PMB' not found.", name.toString().c_str());
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
@ -658,14 +658,14 @@ void KyraEngine_MR::updateDlgBuffer() {
|
||||
if (_curDlgIndex == _mainCharacter.dlgIndex && _curDlgChapter == _currentChapter && _curDlgLang == _lang)
|
||||
return;
|
||||
|
||||
Common::String dlgFile = Common::String::format("CH%.02d-S%.02d.%s", _currentChapter, _mainCharacter.dlgIndex, _languageExtension[_lang]);
|
||||
Common::String cnvFile = Common::String::format("CH%.02d-S%.02d.CNV", _currentChapter, _mainCharacter.dlgIndex);
|
||||
Common::Path dlgFile(Common::String::format("CH%.02d-S%.02d.%s", _currentChapter, _mainCharacter.dlgIndex, _languageExtension[_lang]));
|
||||
Common::Path cnvFile(Common::String::format("CH%.02d-S%.02d.CNV", _currentChapter, _mainCharacter.dlgIndex));
|
||||
|
||||
delete _cnvFile;
|
||||
delete _dlgBuffer;
|
||||
|
||||
_res->exists(cnvFile.c_str(), true);
|
||||
_res->exists(dlgFile.c_str(), true);
|
||||
_res->exists(cnvFile, true);
|
||||
_res->exists(dlgFile, true);
|
||||
_cnvFile = _res->createReadStream(cnvFile);
|
||||
_dlgBuffer = _res->createReadStream(dlgFile);
|
||||
assert(_cnvFile);
|
||||
|
Loading…
x
Reference in New Issue
Block a user