AGS: Fix loading sound effects in AGSWaves

This commit is contained in:
Paul Gilbert 2021-07-20 21:17:28 -07:00
parent 3c616e3edc
commit f9bc18c58a
3 changed files with 20 additions and 9 deletions

View File

@ -232,6 +232,10 @@ bool AGSEngine::is64BitGame() const {
&& f.size() == -1;
}
Common::FSNode AGSEngine::getGameFolder() {
return Common::FSNode(ConfMan.get("path"));
}
bool AGSEngine::canLoadGameStateCurrently() {
return !_GP(thisroom).Options.SaveLoadDisabled &&
!_G(inside_script) && !_GP(play).fast_forward && !_G(no_blocking_functions);

View File

@ -26,6 +26,7 @@
#include "common/scummsys.h"
#include "common/system.h"
#include "common/error.h"
#include "common/fs.h"
#include "common/random.h"
#include "common/hash-str.h"
#include "common/util.h"
@ -141,6 +142,11 @@ public:
*/
bool is64BitGame() const;
/**
* Returns the game folder as a ScummVM filesystem node
*/
Common::FSNode getGameFolder();
/**
* Indicate whether a game state can be loaded.
*/

View File

@ -20,11 +20,12 @@
*
*/
#include "audio/decoders/wave.h"
#include "audio/decoders/vorbis.h"
#include "common/file.h"
#include "common/fs.h"
#include "common/util.h"
#include "ags/plugins/ags_waves/ags_waves.h"
#include "ags/ags.h"
namespace AGS3 {
namespace Plugins {
@ -192,16 +193,16 @@ void AGSWaves::SFX_Filter(ScriptMethodParams &params) {
void AGSWaves::LoadSFX(int i) {
Common::FSNode soundsFolder("sounds");
Common::FSNode soundFileNode = soundsFolder.getChild(
Common::String::format("sound%d.sfx", i));
Common::FSNode fsNode = ::AGS::g_vm->getGameFolder().getChild(
"sounds").getChild(Common::String::format("sound%d.sfx", i));
Common::File *soundFile = new Common::File();
if (soundFile->open(soundFileNode)) {
SFX[i]._stream = Audio::makeWAVStream(soundFile, DisposeAfterUse::YES);
if (fsNode.exists()) {
Common::File *soundFile = new Common::File();
if (!soundFile->open(fsNode))
error("Failed to open");
} else {
delete soundFile;
SFX[i]._stream = Audio::makeVorbisStream(soundFile, DisposeAfterUse::YES);
assert(SFX[i]._stream);
}
}