From 8808f7b5e0899af03155e3bfa0ce4817ee199784 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 20 Feb 2019 14:06:39 -0330 Subject: [PATCH] Check in WIP on config paths before I screw something up (already happened multiple times). --- src/common/main.cxx | 31 ++++++++++++++++++++++++++++--- src/emucore/OSystem.cxx | 9 +++++++-- src/emucore/Settings.cxx | 7 ++----- 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/common/main.cxx b/src/common/main.cxx index 949516620..7d373f7af 100644 --- a/src/common/main.cxx +++ b/src/common/main.cxx @@ -42,18 +42,43 @@ #include "CheatManager.hxx" #endif +/** + Checks the commandline for special settings that are used by various ports + to use a specific 'base directory'. + + This needs to be done separately from the main commandline and settings + functionality, since they both depend on the settings file being already + available. However, since a variabe basedir implies a different location + for the settings file, it *must* be processed first. + + This function will set the environment variables STELLA_BASEDIR and + STELLA_USECURRENTASBASEDIR; it is up to each port to use these as they wish. +*/ +void checkForCustomBaseDir(int ac, char* av[]); + + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void checkForCustomBaseDir(int ac, char* av[]) +{ +} // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #if defined(BSPF_MACOS) -int stellaMain(int argc, char* argv[]) +int stellaMain(int ac, char* av[]) #else -int main(int argc, char* argv[]) +int main(int ac, char* av[]) #endif { SET_MAIN_THREAD; std::ios_base::sync_with_stdio(false); + // Check for custom base directory + // This needs to be done separately from the normal startup, since it + // queries information from the commandline that both OSystem and Settings + // need *before* they are created + checkForCustomBaseDir(ac, av); + // Create the parent OSystem object unique_ptr theOSystem = MediaFactory::createOSystem(); theOSystem->loadConfig(); @@ -70,7 +95,7 @@ int main(int argc, char* argv[]) // Take care of commandline arguments theOSystem->logMessage("Loading commandline arguments ...", 2); - string romfile = theOSystem->settings().loadCommandLine(argc, argv); + string romfile = theOSystem->settings().loadCommandLine(ac, av); // Finally, make sure the settings are valid // We do it once here, so the rest of the program can assume valid settings diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 72a52a294..6d6488e0f 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -203,8 +203,13 @@ void OSystem::setConfigPaths() buildDirIfRequired(myNVRamDir, myBaseDir + "nvram"); buildDirIfRequired(myCfgDir, myBaseDir + "cfg"); - buildDirIfRequired(mySnapshotSaveDir, defaultSaveDir()); - buildDirIfRequired(mySnapshotLoadDir, defaultLoadDir()); + mySnapshotSaveDir = mySettings->getString("snapsavedir"); + if(mySnapshotSaveDir == "") mySnapshotSaveDir = defaultSaveDir(); + buildDirIfRequired(mySnapshotSaveDir, mySnapshotSaveDir); + + mySnapshotLoadDir = mySettings->getString("snaploaddir"); + if(mySnapshotLoadDir == "") mySnapshotLoadDir = defaultLoadDir(); + buildDirIfRequired(mySnapshotLoadDir, mySnapshotLoadDir); myCheatFile = FilesystemNode(myBaseDir + "stella.cht").getPath(); myPaletteFile = FilesystemNode(myBaseDir + "stella.pal").getPath(); diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 9c4a64677..4cab419b9 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -15,8 +15,6 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. //============================================================================ -#include - #include "bspf.hxx" #include "OSystem.hxx" @@ -104,7 +102,6 @@ Settings::Settings(OSystem& osystem) // Config files and paths setInternal("romdir", ""); -// FIXME setInternal("basedir", ""); // ROM browser options setInternal("exitlauncher", "false"); @@ -147,7 +144,7 @@ Settings::Settings(OSystem& osystem) setInternal("dev.rwportbreak", "true"); #endif - // player settings + // Player settings setInternal("plr.stats", "false"); setInternal("plr.bankrandom", "false"); setInternal("plr.ramrandom", "true"); @@ -164,7 +161,7 @@ Settings::Settings(OSystem& osystem) setInternal("plr.tm.horizon", "10m"); // = ~10 minutes setInternal("plr.eepromaccess", "false"); - // developer settings + // Developer settings setInternal("dev.settings", "false"); setInternal("dev.stats", "true"); setInternal("dev.bankrandom", "true");