diff --git a/src/core/core.c b/src/core/core.c index ff7cb4bc2..dbe11b781 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -94,13 +94,13 @@ bool mCoreLoadFile(struct mCore* core, const char* path) { } bool mCoreAutoloadSave(struct mCore* core) { - return core->loadSave(core, mDirectorySetOpenSuffix(&core->dirs, ".sav", O_CREAT | O_RDWR)); + return core->loadSave(core, mDirectorySetOpenSuffix(&core->dirs, core->dirs.save, ".sav", O_CREAT | O_RDWR)); } bool mCoreAutoloadPatch(struct mCore* core) { - return core->loadPatch(core, mDirectorySetOpenSuffix(&core->dirs, ".ups", O_RDONLY)) || - core->loadPatch(core, mDirectorySetOpenSuffix(&core->dirs, ".ips", O_RDONLY)) || - core->loadPatch(core, mDirectorySetOpenSuffix(&core->dirs, ".bps", O_RDONLY)); + return core->loadPatch(core, mDirectorySetOpenSuffix(&core->dirs, core->dirs.patch, ".ups", O_RDONLY)) || + core->loadPatch(core, mDirectorySetOpenSuffix(&core->dirs, core->dirs.patch, ".ips", O_RDONLY)) || + core->loadPatch(core, mDirectorySetOpenSuffix(&core->dirs, core->dirs.patch, ".bps", O_RDONLY)); } bool mCoreSaveState(struct mCore* core, int slot, int flags) { diff --git a/src/core/directories.c b/src/core/directories.c index af65cf3aa..f95eb80fc 100644 --- a/src/core/directories.c +++ b/src/core/directories.c @@ -107,10 +107,10 @@ struct VFile* mDirectorySetOpenPath(struct mDirectorySet* dirs, const char* path return file; } -struct VFile* mDirectorySetOpenSuffix(struct mDirectorySet* dirs, const char* suffix, int mode) { +struct VFile* mDirectorySetOpenSuffix(struct mDirectorySet* dirs, struct VDir* dir, const char* suffix, int mode) { char name[PATH_MAX]; snprintf(name, sizeof(name), "%s%s", dirs->baseName, suffix); - return dirs->base->openFile(dirs->base, name, mode); + return dir->openFile(dir, name, mode); } void mDirectorySetMapOptions(struct mDirectorySet* dirs, const struct mCoreOptions* opts) { diff --git a/src/core/directories.h b/src/core/directories.h index 9473f3938..55f3df513 100644 --- a/src/core/directories.h +++ b/src/core/directories.h @@ -28,7 +28,7 @@ void mDirectorySetAttachBase(struct mDirectorySet* dirs, struct VDir* base); void mDirectorySetDetachBase(struct mDirectorySet* dirs); struct VFile* mDirectorySetOpenPath(struct mDirectorySet* dirs, const char* path, bool (*filter)(struct VFile*)); -struct VFile* mDirectorySetOpenSuffix(struct mDirectorySet* dirs, const char* suffix, int mode); +struct VFile* mDirectorySetOpenSuffix(struct mDirectorySet* dirs, struct VDir* dir, const char* suffix, int mode); struct mCoreOptions; void mDirectorySetMapOptions(struct mDirectorySet* dirs, const struct mCoreOptions* opts); diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 838179fec..0af9bcead 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -310,7 +310,6 @@ void GameController::openGame(bool biosOnly) { if (!biosOnly) { mCoreLoadFile(m_threadContext.core, m_fname.toUtf8().constData()); - mCoreAutoloadSave(m_threadContext.core); } m_threadContext.core->setVideoBuffer(m_threadContext.core, m_drawContext, width); @@ -340,6 +339,10 @@ void GameController::openGame(bool biosOnly) { mCoreLoadForeignConfig(m_threadContext.core, m_config); } + if (!biosOnly) { + mCoreAutoloadSave(m_threadContext.core); + } + if (!mCoreThreadStart(&m_threadContext)) { m_gameOpen = false; emit gameFailed();