ILLUSIONS: Migrate engine to Path

This commit is contained in:
Le Philousophe 2023-09-17 18:23:43 +02:00 committed by Eugene Sandulenko
parent d5736f602e
commit 0ab0721905
7 changed files with 23 additions and 23 deletions

View File

@ -47,12 +47,12 @@ void BBDOUVideoPlayer::start(uint32 videoId, uint32 objectId, uint32 priority, u
Control *videoControl = _vm->_dict->getObjectControl(objectId); Control *videoControl = _vm->_dict->getObjectControl(objectId);
videoControl->_flags |= 0x0008; videoControl->_flags |= 0x0008;
_vm->_input->discardAllEvents(); _vm->_input->discardAllEvents();
Common::String filename = Common::String::format("%08x.avi", videoId); Common::Path filename(Common::String::format("%08x.avi", videoId));
_videoDecoder = new Video::AVIDecoder(); _videoDecoder = new Video::AVIDecoder();
if (!_videoDecoder->loadFile(filename)) { if (!_videoDecoder->loadFile(filename)) {
delete _videoDecoder; delete _videoDecoder;
_videoDecoder = nullptr; _videoDecoder = nullptr;
warning("Unable to open video %s", filename.c_str()); warning("Unable to open video %s", filename.toString().c_str());
notifyCallingThread(); notifyCallingThread();
return; return;
} }

View File

@ -132,7 +132,7 @@ IllusionsEngine_BBDOU::IllusionsEngine_BBDOU(OSystem *syst, const IllusionsGameD
Common::Error IllusionsEngine_BBDOU::run() { Common::Error IllusionsEngine_BBDOU::run() {
// Init search paths // Init search paths
const Common::FSNode gameDataDir(ConfMan.get("path")); const Common::FSNode gameDataDir(ConfMan.getPath("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "music"); SearchMan.addSubDirectoryMatching(gameDataDir, "music");
SearchMan.addSubDirectoryMatching(gameDataDir, "resource"); SearchMan.addSubDirectoryMatching(gameDataDir, "resource");
SearchMan.addSubDirectoryMatching(gameDataDir, "resrem"); SearchMan.addSubDirectoryMatching(gameDataDir, "resrem");

View File

@ -41,12 +41,12 @@ void DuckmanVideoPlayer::start(uint32 videoId, uint32 callingThreadId) {
debug(0, "DuckmanVideoPlayer::play(%08X, %08X)", videoId, callingThreadId); debug(0, "DuckmanVideoPlayer::play(%08X, %08X)", videoId, callingThreadId);
_callingThreadId = callingThreadId; _callingThreadId = callingThreadId;
_vm->_input->discardAllEvents(); _vm->_input->discardAllEvents();
Common::String filename = Common::String::format("%08x.avi", videoId); Common::Path filename(Common::String::format("%08x.avi", videoId));
_videoDecoder = new Video::AVIDecoder(); _videoDecoder = new Video::AVIDecoder();
if (!_videoDecoder->loadFile(filename)) { if (!_videoDecoder->loadFile(filename)) {
delete _videoDecoder; delete _videoDecoder;
_videoDecoder = nullptr; _videoDecoder = nullptr;
warning("Unable to open video %s", filename.c_str()); warning("Unable to open video %s", filename.toString().c_str());
return; return;
} }
_videoDecoder->start(); _videoDecoder->start();

View File

@ -82,7 +82,7 @@ IllusionsEngine_Duckman::IllusionsEngine_Duckman(OSystem *syst, const IllusionsG
Common::Error IllusionsEngine_Duckman::run() { Common::Error IllusionsEngine_Duckman::run() {
// Init search paths // Init search paths
const Common::FSNode gameDataDir(ConfMan.get("path")); const Common::FSNode gameDataDir(ConfMan.getPath("path"));
SearchMan.addSubDirectoryMatching(gameDataDir, "music"); SearchMan.addSubDirectoryMatching(gameDataDir, "music");
SearchMan.addSubDirectoryMatching(gameDataDir, "sfx", 0, 2); SearchMan.addSubDirectoryMatching(gameDataDir, "sfx", 0, 2);
SearchMan.addSubDirectoryMatching(gameDataDir, "video"); SearchMan.addSubDirectoryMatching(gameDataDir, "video");

View File

@ -30,19 +30,19 @@ namespace Illusions {
byte *ResourceReaderFileReader::readResource(uint32 sceneId, uint32 resId, uint32 &dataSize) { byte *ResourceReaderFileReader::readResource(uint32 sceneId, uint32 resId, uint32 &dataSize) {
debug("ResourceReaderFileReader::readResource(%08X, %08X)", sceneId, resId); debug("ResourceReaderFileReader::readResource(%08X, %08X)", sceneId, resId);
Common::String filename = buildResourceFilename(resId); Common::Path filename = buildResourceFilename(resId);
Common::File fd; Common::File fd;
if (!fd.open(filename)) if (!fd.open(filename))
error("Resource::loadData() Could not open %s for reading", filename.c_str()); error("Resource::loadData() Could not open %s for reading", filename.toString().c_str());
dataSize = fd.size(); dataSize = fd.size();
byte *data = (byte*)malloc(dataSize); byte *data = (byte*)malloc(dataSize);
fd.read(data, dataSize); fd.read(data, dataSize);
return data; return data;
} }
Common::String ResourceReaderFileReader::buildResourceFilename(uint32 resId) { Common::Path ResourceReaderFileReader::buildResourceFilename(uint32 resId) {
const char *ext = getResourceExtension(resId); const char *ext = getResourceExtension(resId);
return Common::String::format("%08X%s", resId, ext); return Common::Path(Common::String::format("%08X%s", resId, ext));
} }
const char *ResourceReaderFileReader::getResourceExtension(uint32 resId) { const char *ResourceReaderFileReader::getResourceExtension(uint32 resId) {

View File

@ -31,7 +31,7 @@ class ResourceReaderFileReader : public BaseResourceReader {
public: public:
byte *readResource(uint32 sceneId, uint32 resId, uint32 &dataSize) override; byte *readResource(uint32 sceneId, uint32 resId, uint32 &dataSize) override;
protected: protected:
Common::String buildResourceFilename(uint32 resId); Common::Path buildResourceFilename(uint32 resId);
const char *getResourceExtension(uint32 resId); const char *getResourceExtension(uint32 resId);
}; };

View File

@ -51,15 +51,15 @@ void MusicPlayer::play(uint32 musicId, bool looping, int16 volume, int16 pan) {
} else { } else {
_flags &= ~8; _flags &= ~8;
} }
Common::String filename = Common::String::format("%08x.wav", _musicId); Common::Path filename(Common::String::format("%08x.wav", _musicId));
Common::File *fd = new Common::File(); Common::File *fd = new Common::File();
if (!fd->open(filename)) { if (!fd->open(filename)) {
delete fd; delete fd;
error("MusicPlayer::play() Could not open %s", filename.c_str()); error("MusicPlayer::play() Could not open %s", filename.toString().c_str());
} }
Audio::SeekableAudioStream *wavStream = Audio::makeWAVStream(fd, DisposeAfterUse::YES); Audio::SeekableAudioStream *wavStream = Audio::makeWAVStream(fd, DisposeAfterUse::YES);
if (wavStream == nullptr) { if (wavStream == nullptr) {
error("MusicPlayer::play() Could not load %s", filename.c_str()); error("MusicPlayer::play() Could not load %s", filename.toString().c_str());
} }
Audio::AudioStream *audioStream = Audio::makeLoopingAudioStream(wavStream, looping ? 0 : 1); Audio::AudioStream *audioStream = Audio::makeLoopingAudioStream(wavStream, looping ? 0 : 1);
g_system->getMixer()->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, audioStream, -1, volume, pan); g_system->getMixer()->playStream(Audio::Mixer::kMusicSoundType, &_soundHandle, audioStream, -1, volume, pan);
@ -158,12 +158,12 @@ void MidiPlayer::stop() {
void MidiPlayer::sysMidiPlay(uint32 musicId) { void MidiPlayer::sysMidiPlay(uint32 musicId) {
Common::StackLock lock(_mutex); Common::StackLock lock(_mutex);
Common::String filename = Common::String::format("%08x.mid", musicId); Common::Path filename(Common::String::format("%08x.mid", musicId));
debug(0, "MidiPlayer::sysMidiPlay() %s", filename.c_str()); debug(0, "MidiPlayer::sysMidiPlay() %s", filename.toString().c_str());
Common::File fd; Common::File fd;
if (!fd.open(filename)) { if (!fd.open(filename)) {
error("MidiPlayer::sysMidiPlay() Could not open %s", filename.c_str()); error("MidiPlayer::sysMidiPlay() Could not open %s", filename.toString().c_str());
} }
_dataSize = fd.size(); _dataSize = fd.size();
@ -259,15 +259,15 @@ void VoicePlayer::stopCueing() {
} }
void VoicePlayer::start(int16 volume, int16 pan) { void VoicePlayer::start(int16 volume, int16 pan) {
Common::String filename = Common::String::format("%s.wav", _voiceName.c_str()); Common::Path filename(Common::String::format("%s.wav", _voiceName.c_str()));
Common::File *fd = new Common::File(); Common::File *fd = new Common::File();
if (!fd->open(filename)) { if (!fd->open(filename)) {
delete fd; delete fd;
error("VoicePlayer::start() Could not open %s", filename.c_str()); error("VoicePlayer::start() Could not open %s", filename.toString().c_str());
} }
Audio::AudioStream *audioStream = Audio::makeWAVStream(fd, DisposeAfterUse::YES); Audio::AudioStream *audioStream = Audio::makeWAVStream(fd, DisposeAfterUse::YES);
if (audioStream == nullptr) { if (audioStream == nullptr) {
error("VoicePlayer::start() Could not load %s", filename.c_str()); error("VoicePlayer::start() Could not load %s", filename.toString().c_str());
} }
g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_soundHandle, audioStream, -1, volume, pan); g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_soundHandle, audioStream, -1, volume, pan);
_voiceStatus = 4; _voiceStatus = 4;
@ -321,15 +321,15 @@ Sound::~Sound() {
} }
void Sound::load() { void Sound::load() {
Common::String filename = Common::String::format("%08x/%08x.wav", _soundGroupId, _soundEffectId); Common::Path filename(Common::String::format("%08x/%08x.wav", _soundGroupId, _soundEffectId));
Common::File *fd = new Common::File(); Common::File *fd = new Common::File();
if (!fd->open(filename)) { if (!fd->open(filename)) {
delete fd; delete fd;
error("Sound::load() Could not open %s", filename.c_str()); error("Sound::load() Could not open %s", filename.toString().c_str());
} }
_stream = Audio::makeWAVStream(fd, DisposeAfterUse::YES); _stream = Audio::makeWAVStream(fd, DisposeAfterUse::YES);
if (_stream == nullptr) { if (_stream == nullptr) {
warning("Sound::load() Could not load %s", filename.c_str()); warning("Sound::load() Could not load %s", filename.toString().c_str());
} }
} }