diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-05-29 12:56:16 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-05-29 12:56:16 +0300 |
commit | 1b500cb24655e2ad3e6c6fd20143ce0d2d070d6f (patch) | |
tree | 3eea380919dae735fdbeacff314edf1ad06d26ab /src | |
parent | 0b7ef18ac3c7fb4e3717f6311d4e21a31ff440d5 (diff) | |
download | manaplus-1b500cb24655e2ad3e6c6fd20143ce0d2d070d6f.tar.gz manaplus-1b500cb24655e2ad3e6c6fd20143ce0d2d070d6f.tar.bz2 manaplus-1b500cb24655e2ad3e6c6fd20143ce0d2d070d6f.tar.xz manaplus-1b500cb24655e2ad3e6c6fd20143ce0d2d070d6f.zip |
Move many variables from client into settings.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/being/being.cpp | 9 | ||||
-rw-r--r-- | src/client.cpp | 270 | ||||
-rw-r--r-- | src/client.h | 60 | ||||
-rw-r--r-- | src/commands.cpp | 11 | ||||
-rw-r--r-- | src/game.cpp | 7 | ||||
-rw-r--r-- | src/gui/dialogsmanager.cpp | 6 | ||||
-rw-r--r-- | src/gui/windows/chatwindow.cpp | 5 | ||||
-rw-r--r-- | src/gui/windows/serverdialog.cpp | 5 | ||||
-rw-r--r-- | src/gui/windows/shopwindow.cpp | 5 | ||||
-rw-r--r-- | src/gui/windows/updaterwindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/whoisonline.cpp | 3 | ||||
-rw-r--r-- | src/gui/windows/worldselectdialog.cpp | 3 | ||||
-rw-r--r-- | src/listeners/errorlistener.cpp | 3 | ||||
-rw-r--r-- | src/net/download.cpp | 3 | ||||
-rw-r--r-- | src/net/ea/charserverhandler.cpp | 5 | ||||
-rw-r--r-- | src/net/ea/loginhandler.cpp | 3 | ||||
-rw-r--r-- | src/resources/atlasmanager.cpp | 2 | ||||
-rw-r--r-- | src/resources/map/map.cpp | 3 | ||||
-rw-r--r-- | src/settings.cpp | 27 | ||||
-rw-r--r-- | src/settings.h | 75 | ||||
-rw-r--r-- | src/test/testlauncher.cpp | 13 | ||||
-rw-r--r-- | src/test/testmain.cpp | 12 | ||||
-rw-r--r-- | src/utils/fuzzer.cpp | 3 |
25 files changed, 304 insertions, 236 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e6949e4c7..96e74e0b2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -902,6 +902,8 @@ SET(SRCS render/sdlgraphics.h render/softwaregraphicsdef.hpp sdlshared.h + settings.cpp + settings.h shopitem.cpp shopitem.h simpleanimation.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 4b2101d94..aa2a69671 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1015,6 +1015,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ render/sdlgraphics.h \ render/softwaregraphicsdef.hpp \ sdlshared.h \ + settings.cpp \ + settings.h \ shopitem.cpp \ shopitem.h \ simpleanimation.cpp \ diff --git a/src/being/being.cpp b/src/being/being.cpp index e24470d1e..6bdf8f166 100644 --- a/src/being/being.cpp +++ b/src/being/being.cpp @@ -30,6 +30,7 @@ #include "effectmanager.h" #include "guild.h" #include "party.h" +#include "settings.h" #include "soundmanager.h" #include "text.h" @@ -2923,10 +2924,10 @@ std::string Being::loadComment(const std::string &name, const int type) switch (type) { case ActorType::PLAYER: - str = client->getUsersDirectory(); + str = settings.usersDir; break; case ActorType::NPC: - str = client->getNpcsDirectory(); + str = settings.npcsDir; break; default: return ""; @@ -2950,10 +2951,10 @@ void Being::saveComment(const std::string &restrict name, switch (type) { case ActorType::PLAYER: - dir = client->getUsersDirectory(); + dir = settings.usersDir; break; case ActorType::NPC: - dir = client->getNpcsDirectory(); + dir = settings.npcsDir; break; default: return; diff --git a/src/client.cpp b/src/client.cpp index 1d0cb9609..443928da9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -36,6 +36,7 @@ #include "graphicsmanager.h" #include "itemshortcut.h" #include "party.h" +#include "settings.h" #include "soundconsts.h" #include "soundmanager.h" #include "statuseffect.h" @@ -213,19 +214,7 @@ namespace Client::Client(const Options &options) : ActionListener(), mOptions(options), - mConfigDir(), - mServerConfigDir(), - mLocalDataDir(), - mTempDir(), - mUpdateHost(), - mUpdatesDir(), - mScreenshotDir(), - mUsersDir(), - mNpcsDir(), mRootDir(), - mServerName(), - mOnlineListUrl(), - mLogFileName(), mCurrentServer(), mGame(nullptr), mCurrentDialog(nullptr), @@ -244,7 +233,6 @@ Client::Client(const Options &options) : mOldState(STATE_START), mIcon(nullptr), mCaption(), - mOldUpdates(), mFpsManager(), mSkin(nullptr), mGuiAlpha(1.0F), @@ -294,10 +282,10 @@ void Client::gameInit() // Configure logger if (!mOptions.logFileName.empty()) - mLogFileName = mOptions.logFileName; + settings.logFileName = mOptions.logFileName; else - mLogFileName = mLocalDataDir + "/manaplus.log"; - logger->setLogFile(mLogFileName); + settings.logFileName = settings.localDataDir + "/manaplus.log"; + logger->setLogFile(settings.logFileName); #ifdef USE_FUZZER Fuzzer::init(); @@ -316,19 +304,24 @@ void Client::gameInit() #endif const ResourceManager *const resman = ResourceManager::getInstance(); - if (!resman->setWriteDir(mLocalDataDir)) + if (!resman->setWriteDir(settings.localDataDir)) { logger->error(strprintf("%s couldn't be set as home directory! " - "Exiting.", mLocalDataDir.c_str())); + "Exiting.", settings.localDataDir.c_str())); } initLang(); chatLogger = new ChatLogger; if (mOptions.chatLogDir.empty()) - chatLogger->setBaseLogDir(mLocalDataDir + std::string("/logs/")); + { + chatLogger->setBaseLogDir(settings.localDataDir + + std::string("/logs/")); + } else + { chatLogger->setBaseLogDir(mOptions.chatLogDir); + } logger->setLogToStandardOut(config.getBoolValue("logToStandardOut")); @@ -393,7 +386,7 @@ void Client::gameInit() resman->addToSearchPath(mOptions.dataPath, false); // Add the local data directory to PhysicsFS search path - resman->addToSearchPath(mLocalDataDir, false); + resman->addToSearchPath(settings.localDataDir, false); TranslationManager::loadCurrentLang(); initTitle(); @@ -1047,15 +1040,18 @@ int Client::gameExec() else if (mState == STATE_CONNECT_SERVER && mOldState == STATE_CHOOSE_SERVER) { - mServerName = mCurrentServer.hostname; + settings.serverName = mCurrentServer.hostname; initServerConfig(mCurrentServer.hostname); initFeatures(); PlayerInfo::loadData(); loginData.registerUrl = mCurrentServer.registerUrl; if (!mCurrentServer.onlineListUrl.empty()) - mOnlineListUrl = mCurrentServer.onlineListUrl; + settings.onlineListUrl = mCurrentServer.onlineListUrl; else - mOnlineListUrl = mServerName; + settings.onlineListUrl = settings.serverName; + settings.persistentIp = mCurrentServer.persistentIp; + settings.supportUrl = mCurrentServer.supportUrl; + settings.updateMirrors = mCurrentServer.updateMirrors; if (mOptions.username.empty()) { @@ -1166,9 +1162,9 @@ int Client::gameExec() if (!mOptions.dataPath.empty()) UpdaterWindow::unloadMods(mOptions.dataPath); else - UpdaterWindow::unloadMods(mOldUpdates); + UpdaterWindow::unloadMods(settings.oldUpdates); if (!mOptions.skipUpdate) - UpdaterWindow::unloadMods(mOldUpdates + "/fix/"); + UpdaterWindow::unloadMods(settings.oldUpdates + "/fix/"); } mOldState = mState; @@ -1192,6 +1188,7 @@ int Client::gameExec() BLOCK_START("Client::gameExec STATE_CHOOSE_SERVER") logger->log1("State: CHOOSE SERVER"); mCurrentServer.supportUrl.clear(); + settings.supportUrl.clear(); ResourceManager *const resman = ResourceManager::getInstance(); if (mOptions.dataPath.empty()) @@ -1202,20 +1199,20 @@ int Client::gameExec() "zip"); } - if (!mOldUpdates.empty()) + if (!settings.oldUpdates.empty()) { - UpdaterWindow::unloadUpdates(mOldUpdates); - mOldUpdates.clear(); + UpdaterWindow::unloadUpdates(settings.oldUpdates); + settings.oldUpdates.clear(); } if (!mOptions.skipUpdate) { resman->searchAndRemoveArchives( - mUpdatesDir + "/local/", + settings.updatesDir + "/local/", "zip"); - resman->removeFromSearchPath(mLocalDataDir - + dirSeparator + mUpdatesDir + "/local/"); + resman->removeFromSearchPath(settings.localDataDir + + dirSeparator + settings.updatesDir + "/local/"); } resman->clearCache(); @@ -1234,7 +1231,7 @@ int Client::gameExec() theme->setMinimumOpacity(0.8F); mCurrentDialog = new ServerDialog(&mCurrentServer, - mConfigDir); + settings.configDir); mCurrentDialog->postInit(); } else @@ -1356,33 +1353,33 @@ int Client::gameExec() logger->log1("State: UPDATE"); // Determine which source to use for the update host if (!mOptions.updateHost.empty()) - mUpdateHost = mOptions.updateHost; + settings.updateHost = mOptions.updateHost; else - mUpdateHost = loginData.updateHost; + settings.updateHost = loginData.updateHost; initUpdatesDir(); - if (!mOldUpdates.empty()) - UpdaterWindow::unloadUpdates(mOldUpdates); + if (!settings.oldUpdates.empty()) + UpdaterWindow::unloadUpdates(settings.oldUpdates); if (mOptions.skipUpdate) { mState = STATE_LOAD_DATA; - mOldUpdates = ""; + settings.oldUpdates.clear(); UpdaterWindow::loadDirMods(mOptions.dataPath); } else if (loginData.updateType & UpdateType::Skip) { - mOldUpdates = mLocalDataDir - + dirSeparator + mUpdatesDir; - UpdaterWindow::loadLocalUpdates(mOldUpdates); + settings.oldUpdates = settings.localDataDir + + dirSeparator + settings.updatesDir; + UpdaterWindow::loadLocalUpdates(settings.oldUpdates); mState = STATE_LOAD_DATA; } else { - mOldUpdates = mLocalDataDir - + dirSeparator + mUpdatesDir; - mCurrentDialog = new UpdaterWindow(mUpdateHost, - mOldUpdates, + settings.oldUpdates = settings.localDataDir + + dirSeparator + settings.updatesDir; + mCurrentDialog = new UpdaterWindow(settings.updateHost, + settings.oldUpdates, mOptions.dataPath.empty(), loginData.updateType); mCurrentDialog->postInit(); @@ -1412,12 +1409,13 @@ int Client::gameExec() if (!mOptions.skipUpdate) { resman->searchAndAddArchives( - mUpdatesDir + "/local/", + settings.updatesDir + "/local/", "zip", false); - resman->addToSearchPath(mLocalDataDir + dirSeparator - + mUpdatesDir + "/local/", false); + resman->addToSearchPath(settings.localDataDir + + dirSeparator + settings.updatesDir + "/local/", + false); } logger->log("Init paths"); @@ -1550,7 +1548,7 @@ int Client::gameExec() theme->setMinimumOpacity(-1.0F); if (chatLogger) - chatLogger->setServerName(mServerName); + chatLogger->setServerName(settings.serverName); #ifdef ANDROID delete2(mCloseButton); @@ -1706,7 +1704,7 @@ int Client::gameExec() Net::getLoginHandler()->disconnect(); Net::getGameHandler()->disconnect(); Net::getGameHandler()->clear(); - mServerName.clear(); + settings.serverName.clear(); serverConfig.write(); serverConfig.unload(); if (setupWindow) @@ -1949,99 +1947,99 @@ void Client::initHomeDir() void Client::initLocalDataDir() { - mLocalDataDir = mOptions.localDataDir; + settings.localDataDir = mOptions.localDataDir; - if (mLocalDataDir.empty()) + if (settings.localDataDir.empty()) { #ifdef __APPLE__ // Use Application Directory instead of .mana - mLocalDataDir = std::string(PhysFs::getUserDir()) + + settings.localDataDir = std::string(PhysFs::getUserDir()) + "/Library/Application Support/" + branding.getValue("appName", "ManaPlus"); #elif defined __HAIKU__ - mLocalDataDir = std::string(PhysFs::getUserDir()) + + settings.localDataDir = std::string(PhysFs::getUserDir()) + "/config/data/Mana"; #elif defined WIN32 - mLocalDataDir = getSpecialFolderLocation(CSIDL_LOCAL_APPDATA); - if (mLocalDataDir.empty()) - mLocalDataDir = std::string(PhysFs::getUserDir()); - mLocalDataDir.append("/Mana"); + settings.localDataDir = getSpecialFolderLocation(CSIDL_LOCAL_APPDATA); + if (settings.localDataDir.empty()) + settings.localDataDir = std::string(PhysFs::getUserDir()); + settings.localDataDir.append("/Mana"); #elif defined __ANDROID__ - mLocalDataDir = getSdStoragePath() + branding.getValue( + settings.localDataDir = getSdStoragePath() + branding.getValue( "appShort", "ManaPlus") + "/local"; #elif defined __native_client__ - mLocalDataDir = _nacl_dir.append("/local"); + settings.localDataDir = _nacl_dir.append("/local"); #else - mLocalDataDir = std::string(PhysFs::getUserDir()) + + settings.localDataDir = std::string(PhysFs::getUserDir()) + ".local/share/mana"; #endif } - if (mkdir_r(mLocalDataDir.c_str())) + if (mkdir_r(settings.localDataDir.c_str())) { // TRANSLATORS: directory creation error logger->error(strprintf(_("%s doesn't exist and can't be created! " - "Exiting."), mLocalDataDir.c_str())); + "Exiting."), settings.localDataDir.c_str())); } #ifdef USE_PROFILER - Perfomance::init(mLocalDataDir + "/profiler.log"); + Perfomance::init(settings.localDataDir + "/profiler.log"); #endif } void Client::initTempDir() { - mTempDir = mLocalDataDir + dirSeparator + "temp"; + settings.tempDir = settings.localDataDir + dirSeparator + "temp"; - if (mkdir_r(mTempDir.c_str())) + if (mkdir_r(settings.tempDir.c_str())) { // TRANSLATORS: directory creation error logger->error(strprintf(_("%s doesn't exist and can't be created! " - "Exiting."), mTempDir.c_str())); + "Exiting."), settings.tempDir.c_str())); } -// ResourceManager::deleteFilesInDirectory(mTempDir); +// ResourceManager::deleteFilesInDirectory(settings.tempDir); } void Client::initConfigDir() { - mConfigDir = mOptions.configDir; + settings.configDir = mOptions.configDir; - if (mConfigDir.empty()) + if (settings.configDir.empty()) { #ifdef __APPLE__ - mConfigDir = mLocalDataDir + dirSeparator + settings.configDir = settings.localDataDir + dirSeparator + branding.getValue("appShort", "mana"); #elif defined __HAIKU__ - mConfigDir = std::string(PhysFs::getUserDir()) + + settings.configDir = std::string(PhysFs::getUserDir()) + "/config/settings/Mana" + branding.getValue("appName", "ManaPlus"); #elif defined WIN32 - mConfigDir = getSpecialFolderLocation(CSIDL_APPDATA); - if (mConfigDir.empty()) + settings.configDir = getSpecialFolderLocation(CSIDL_APPDATA); + if (settings.configDir.empty()) { - mConfigDir = mLocalDataDir; + settings.configDir = settings.localDataDir; } else { - mConfigDir.append("/mana/").append(branding.getValue( + settings.configDir.append("/mana/").append(branding.getValue( "appShort", "mana")); } #elif defined __ANDROID__ - mConfigDir = getSdStoragePath() + branding.getValue( + settings.configDir = getSdStoragePath() + branding.getValue( "appShort", "ManaPlus").append("/config"); #elif defined __native_client__ - mConfigDir = _nacl_dir.append("/config"); + settings.configDir = _nacl_dir.append("/config"); #else - mConfigDir = std::string(PhysFs::getUserDir()).append( + settings.configDir = std::string(PhysFs::getUserDir()).append( "/.config/mana/").append(branding.getValue("appShort", "mana")); #endif - logger->log("Generating config dir: " + mConfigDir); + logger->log("Generating config dir: " + settings.configDir); } - if (mkdir_r(mConfigDir.c_str())) + if (mkdir_r(settings.configDir.c_str())) { // TRANSLATORS: directory creation error logger->error(strprintf(_("%s doesn't exist and can't be created! " - "Exiting."), mConfigDir.c_str())); + "Exiting."), settings.configDir.c_str())); } } @@ -2051,15 +2049,15 @@ void Client::initConfigDir() */ void Client::initServerConfig(const std::string &serverName) { - mServerConfigDir = mConfigDir + dirSeparator + serverName; + settings.serverConfigDir = settings.configDir + dirSeparator + serverName; - if (mkdir_r(mServerConfigDir.c_str())) + if (mkdir_r(settings.serverConfigDir.c_str())) { // TRANSLATORS: directory creation error logger->error(strprintf(_("%s doesn't exist and can't be created! " - "Exiting."), mServerConfigDir.c_str())); + "Exiting."), settings.serverConfigDir.c_str())); } - const std::string configPath = mServerConfigDir + "/config.xml"; + const std::string configPath = settings.serverConfigDir + "/config.xml"; FILE *configFile = fopen(configPath.c_str(), "r"); if (!configFile) { @@ -2136,9 +2134,9 @@ void Client::initConfiguration() const std::string configPath; if (mOptions.test.empty()) - configPath = mConfigDir + "/config.xml"; + configPath = settings.configDir + "/config.xml"; else - configPath = mConfigDir + "/test.xml"; + configPath = settings.configDir + "/test.xml"; FILE *configFile = fopen(configPath.c_str(), "r"); if (!configFile) @@ -2162,7 +2160,7 @@ void Client::initConfiguration() const void Client::backupConfig() const { - const std::string confName = mConfigDir + "/config.xml.bak"; + const std::string confName = settings.configDir + "/config.xml.bak"; const int maxFileIndex = 5; ::remove((confName + toString(maxFileIndex)).c_str()); for (int f = maxFileIndex; f > 1; f --) @@ -2171,7 +2169,7 @@ void Client::backupConfig() const const std::string fileName2 = confName + toString(f); Files::renameFile(fileName1, fileName2); } - const std::string fileName3 = mConfigDir + "/config.xml"; + const std::string fileName3 = settings.configDir + "/config.xml"; const std::string fileName4 = confName + toString(1); Files::copyFile(fileName3, fileName4); } @@ -2185,51 +2183,53 @@ void Client::initUpdatesDir() std::stringstream updates; // If updatesHost is currently empty, fill it from config file - if (mUpdateHost.empty()) - mUpdateHost = config.getStringValue("updatehost"); - if (!checkPath(mUpdateHost)) + if (settings.updateHost.empty()) + settings.updateHost = config.getStringValue("updatehost"); + if (!checkPath(settings.updateHost)) return; // Don't go out of range int he next check - if (mUpdateHost.length() < 2) + if (settings.updateHost.length() < 2) return; - const size_t sz = mUpdateHost.size(); + const size_t sz = settings.updateHost.size(); // Remove any trailing slash at the end of the update host - if (mUpdateHost.at(sz - 1) == '/') - mUpdateHost.resize(sz - 1); + if (settings.updateHost.at(sz - 1) == '/') + settings.updateHost.resize(sz - 1); // Parse out any "http://" or "https://", and set the updates directory - const size_t pos = mUpdateHost.find("://"); - if (pos != mUpdateHost.npos) + const size_t pos = settings.updateHost.find("://"); + if (pos != settings.updateHost.npos) { - if (pos + 3 < mUpdateHost.length() && !mUpdateHost.empty()) + if (pos + 3 < settings.updateHost.length() + && !settings.updateHost.empty()) { - updates << "updates/" << mUpdateHost.substr(pos + 3); - mUpdatesDir = updates.str(); + updates << "updates/" << settings.updateHost.substr(pos + 3); + settings.updatesDir = updates.str(); } else { - logger->log("Error: Invalid update host: %s", mUpdateHost.c_str()); + logger->log("Error: Invalid update host: %s", + settings.updateHost.c_str()); // TRANSLATORS: update server initialisation error errorMessage = strprintf(_("Invalid update host: %s."), - mUpdateHost.c_str()); + settings.updateHost.c_str()); mState = STATE_ERROR; } } else { logger->log1("Warning: no protocol was specified for the update host"); - updates << "updates/" << mUpdateHost; - mUpdatesDir = updates.str(); + updates << "updates/" << settings.updateHost; + settings.updatesDir = updates.str(); } #ifdef WIN32 - if (mUpdatesDir.find(":") != std::string::npos) - replaceAll(mUpdatesDir, ":", "_"); + if (settings.updatesDir.find(":") != std::string::npos) + replaceAll(settings.updatesDir, ":", "_"); #endif - const std::string updateDir("/" + mUpdatesDir); + const std::string updateDir("/" + settings.updatesDir); // Verify that the updates directory exists. Create if necessary. if (!PhysFs::isDirectory(updateDir.c_str())) @@ -2237,7 +2237,8 @@ void Client::initUpdatesDir() if (!PhysFs::mkdir(updateDir.c_str())) { #if defined WIN32 - std::string newDir = mLocalDataDir + "\\" + mUpdatesDir; + std::string newDir = settings.localDataDir + + "\\" + settings.updatesDir; size_t loc = newDir.find("/", 0); while (loc != std::string::npos) @@ -2257,7 +2258,7 @@ void Client::initUpdatesDir() } #else logger->log("Error: %s/%s can't be made, but doesn't exist!", - mLocalDataDir.c_str(), mUpdatesDir.c_str()); + settings.localDataDir.c_str(), settings.updatesDir.c_str()); // TRANSLATORS: update server initialisation error errorMessage = _("Error creating updates directory!"); mState = STATE_ERROR; @@ -2276,33 +2277,34 @@ void Client::initScreenshotDir() { if (!mOptions.screenshotDir.empty()) { - mScreenshotDir = mOptions.screenshotDir; - if (mkdir_r(mScreenshotDir.c_str())) + settings.screenshotDir = mOptions.screenshotDir; + if (mkdir_r(settings.screenshotDir.c_str())) { // TRANSLATORS: directory creation error logger->log(strprintf( _("Error: %s doesn't exist and can't be created! " - "Exiting."), mScreenshotDir.c_str())); + "Exiting."), settings.screenshotDir.c_str())); } } - else if (mScreenshotDir.empty()) + else if (settings.screenshotDir.empty()) { - mScreenshotDir = decodeBase64String( + settings.screenshotDir = decodeBase64String( config.getStringValue("screenshotDirectory3")); - if (mScreenshotDir.empty()) + if (settings.screenshotDir.empty()) { #ifdef __ANDROID__ - mScreenshotDir = getSdStoragePath() + std::string("/images"); + settings.screenshotDir = getSdStoragePath() + + std::string("/images"); - if (mkdir_r(mScreenshotDir.c_str())) + if (mkdir_r(settings.screenshotDir.c_str())) { // TRANSLATORS: directory creation error logger->log(strprintf( _("Error: %s doesn't exist and can't be created! " - "Exiting."), mScreenshotDir.c_str())); + "Exiting."), settings.screenshotDir.c_str())); } #else - mScreenshotDir = getPicturesDir(); + settings.screenshotDir = getPicturesDir(); #endif if (config.getBoolValue("useScreenshotDirectorySuffix")) { @@ -2311,15 +2313,15 @@ void Client::initScreenshotDir() if (!configScreenshotSuffix.empty()) { - mScreenshotDir.append(dirSeparator).append( + settings.screenshotDir.append(dirSeparator).append( configScreenshotSuffix); } } config.setValue("screenshotDirectory3", - encodeBase64String(mScreenshotDir)); + encodeBase64String(settings.screenshotDir)); } } - logger->log("screenshotDirectory: " + mScreenshotDir); + logger->log("screenshotDirectory: " + settings.screenshotDir); } #ifndef ANDROID @@ -2446,7 +2448,7 @@ void Client::storeSafeParameters() const void Client::initTradeFilter() const { const std::string tradeListName = - getServerConfigDirectory() + "/tradefilter.txt"; + settings.serverConfigDir + "/tradefilter.txt"; std::ofstream tradeFile; struct stat statbuf; @@ -2478,20 +2480,20 @@ void Client::initTradeFilter() const void Client::initUsersDir() { - mUsersDir = getServerConfigDirectory() + "/users/"; - if (mkdir_r(mUsersDir.c_str())) + settings.usersDir = settings.serverConfigDir + "/users/"; + if (mkdir_r(settings.usersDir.c_str())) { // TRANSLATORS: directory creation error logger->error(strprintf(_("%s doesn't exist and can't be created! " - "Exiting."), mUsersDir.c_str())); + "Exiting."), settings.usersDir.c_str())); } - mNpcsDir = getServerConfigDirectory() + "/npcs/"; - if (mkdir_r(mNpcsDir.c_str())) + settings.npcsDir = settings.serverConfigDir + "/npcs/"; + if (mkdir_r(settings.npcsDir.c_str())) { // TRANSLATORS: directory creation error logger->error(strprintf(_("%s doesn't exist and can't be created! " - "Exiting."), mNpcsDir.c_str())); + "Exiting."), settings.npcsDir.c_str())); } } @@ -2573,9 +2575,9 @@ void Client::initPacketLimiter() mPacketLimits[PACKET_WHISPER].cntLimit = 1; mPacketLimits[PACKET_WHISPER].cnt = 0; - if (!mServerConfigDir.empty()) + if (!settings.serverConfigDir.empty()) { - const std::string packetLimitsName = getServerConfigDirectory() + const std::string packetLimitsName = settings.serverConfigDir + "/packetlimiter.txt"; std::ifstream inPacketFile; @@ -2740,7 +2742,7 @@ int Client::getFramerate() const bool Client::isTmw() const { - const std::string &name = getServerName(); + const std::string &name = settings.serverName; if (name == "server.themanaworld.org" || name == "themanaworld.org" || name == "192.31.187.185") @@ -2947,7 +2949,7 @@ Window *Client::openErrorDialog(const std::string &header, const std::string &message, const bool modal) { - if (getSupportUrl().empty() || config.getBoolValue("hidesupport")) + if (settings.supportUrl.empty() || config.getBoolValue("hidesupport")) { return new OkDialog(header, message, DialogType::ERROR, modal); } diff --git a/src/client.h b/src/client.h index e1faaba90..4e891236f 100644 --- a/src/client.h +++ b/src/client.h @@ -170,27 +170,6 @@ public: State getState() const A_WARN_UNUSED { return mState; } - const std::string &getConfigDirectory() const A_WARN_UNUSED - { return mConfigDir; } - - const std::string &getLocalDataDirectory() const A_WARN_UNUSED - { return mLocalDataDir; } - - const std::string &getTempDirectory() const A_WARN_UNUSED - { return mTempDir; } - - const std::string &getScreenshotDirectory() const A_WARN_UNUSED - { return mScreenshotDir; } - - const std::string getServerConfigDirectory() const A_WARN_UNUSED - { return mServerConfigDir; } - - const std::string getUsersDirectory() const A_WARN_UNUSED - { return mUsersDir; } - - const std::string getNpcsDirectory() const A_WARN_UNUSED - { return mNpcsDir; } - bool getIsMinimized() const A_WARN_UNUSED { return mIsMinimized; } @@ -210,36 +189,9 @@ public: void setMouseFocused(const bool n) { mMouseFocused = n; } - std::string getUpdatesDir() const A_WARN_UNUSED - { return mUpdatesDir; } - - std::string getServerName() const A_WARN_UNUSED - { return mServerName; } - - std::string getOnlineUrl() const A_WARN_UNUSED - { return mOnlineListUrl; } - - std::string getSupportUrl() const A_WARN_UNUSED - { return mCurrentServer.supportUrl; } - - bool getPersistentIp() const A_WARN_UNUSED - { return mCurrentServer.persistentIp; } - - std::string getLogFileName() const A_WARN_UNUSED - { return mLogFileName; } - - std::string getUpdateHost() const A_WARN_UNUSED - { return mUpdateHost; } - - std::string getOldUpdates() const A_WARN_UNUSED - { return mOldUpdates; } - const Options &getOptions() const A_WARN_UNUSED { return mOptions; } - const std::vector<std::string> &getMirrors() const A_WARN_UNUSED - { return mCurrentServer.updateMirrors; } - bool isKeyboardVisible() const; void setGuiAlpha(const float n) @@ -368,18 +320,7 @@ private: Options mOptions; - std::string mConfigDir; - std::string mServerConfigDir; - std::string mLocalDataDir; - std::string mTempDir; - std::string mUpdateHost; - std::string mUpdatesDir; - std::string mScreenshotDir; - std::string mUsersDir; - std::string mNpcsDir; std::string mRootDir; - std::string mServerName; - std::string mOnlineListUrl; std::string mLogFileName; ServerInfo mCurrentServer; @@ -404,7 +345,6 @@ private: SDL_Surface *mIcon; std::string mCaption; - std::string mOldUpdates; FPSmanager mFpsManager; Skin *mSkin; float mGuiAlpha; diff --git a/src/commands.cpp b/src/commands.cpp index 711806021..46efeffbd 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -31,6 +31,7 @@ #include "guildmanager.h" #include "main.h" #include "party.h" +#include "settings.h" #include "being/localplayer.h" #include "being/playerrelations.h" @@ -869,13 +870,13 @@ impHandler0(dirs) return; debugChatTab->chatLog("config directory: " - + client->getConfigDirectory()); + + settings.configDir); debugChatTab->chatLog("logs directory: " - + client->getLocalDataDirectory()); + + settings.localDataDir); debugChatTab->chatLog("screenshots directory: " - + client->getScreenshotDirectory()); + + settings.screenshotDir); debugChatTab->chatLog("temp directory: " - + client->getTempDirectory()); + + settings.tempDir); } impHandler2(info) @@ -1371,7 +1372,7 @@ impHandler2(uploadServerConfig) impHandler2(uploadLog) { uploadFile(_("Uploaded log into:"), - client->getLogFileName(), + settings.logFileName, "?txt", tab); } diff --git a/src/game.cpp b/src/game.cpp index e12ff98a7..2e6e9ddd3 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -36,6 +36,7 @@ #include "guildmanager.h" #include "itemshortcut.h" #include "soundmanager.h" +#include "settings.h" #include "spellshortcut.h" #include "touchmanager.h" @@ -494,7 +495,7 @@ void Game::addWatermark() return; mainGraphics->setColorAll(theme->getColor(Theme::TEXT, 255), theme->getColor(Theme::TEXT_OUTLINE, 255)); - boldFont->drawString(mainGraphics, client->getServerName(), 100, 50); + boldFont->drawString(mainGraphics, settings.serverName, 100, 50); } bool Game::createScreenshot() @@ -527,7 +528,7 @@ bool Game::createScreenshot() bool Game::saveScreenshot(SDL_Surface *const screenshot) { - std::string screenshotDirectory = client->getScreenshotDirectory(); + std::string screenshotDirectory = settings.screenshotDir; if (mkdir_r(screenshotDirectory.c_str()) != 0) { logger->log("Directory %s doesn't exist and can't be created! " @@ -548,7 +549,7 @@ bool Game::saveScreenshot(SDL_Surface *const screenshot) struct tm *const timeinfo = localtime(&rawtime); strftime(buffer, 99, "%Y-%m-%d_%H-%M-%S", timeinfo); - const std::string serverName = client->getServerName(); + const std::string serverName = settings.serverName; std::string screenShortStr; if (serverName.empty()) { diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp index ed1ea9604..b23152605 100644 --- a/src/gui/dialogsmanager.cpp +++ b/src/gui/dialogsmanager.cpp @@ -22,7 +22,7 @@ #include "gui/dialogsmanager.h" -#include "client.h" +#include "settings.h" #include "gui/windows/buyselldialog.h" #include "gui/windows/buydialog.h" @@ -56,8 +56,8 @@ void DialogsManager::closeDialogs() void DialogsManager::createUpdaterWindow() { - updaterWindow = new UpdaterWindow(client->getUpdateHost(), - client->getOldUpdates(), + updaterWindow = new UpdaterWindow(settings.updateHost, + settings.oldUpdates, false, 0); updaterWindow->postInit(); diff --git a/src/gui/windows/chatwindow.cpp b/src/gui/windows/chatwindow.cpp index fb7219ed9..921d32fff 100644 --- a/src/gui/windows/chatwindow.cpp +++ b/src/gui/windows/chatwindow.cpp @@ -29,6 +29,7 @@ #include "game.h" #include "guild.h" #include "party.h" +#include "settings.h" #include "spellshortcut.h" #include "being/attributes.h" @@ -1520,7 +1521,7 @@ void ChatWindow::localPetEmote(const std::string &nick, const uint8_t emoteId) void ChatWindow::initTradeFilter() { - const std::string tradeListName = client->getServerConfigDirectory() + const std::string tradeListName = settings.serverConfigDir + "/tradefilter.txt"; std::ifstream tradeFile; @@ -1670,7 +1671,7 @@ void ChatWindow::loadCustomList() std::ifstream listFile; struct stat statbuf; - std::string listName = client->getServerConfigDirectory() + std::string listName = settings.serverConfigDir + "/customwords.txt"; if (!stat(listName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode)) diff --git a/src/gui/windows/serverdialog.cpp b/src/gui/windows/serverdialog.cpp index 48ccd9f6d..3f537344f 100644 --- a/src/gui/windows/serverdialog.cpp +++ b/src/gui/windows/serverdialog.cpp @@ -26,6 +26,7 @@ #include "client.h" #include "configuration.h" #include "main.h" +#include "settings.h" #include "events/keyevent.h" @@ -238,6 +239,10 @@ void ServerDialog::connectToSelectedServer() mServerInfo->persistentIp = server.persistentIp; mServerInfo->updateMirrors = server.updateMirrors; + settings.persistentIp = mServerInfo->persistentIp; + settings.supportUrl = mServerInfo->supportUrl; + settings.updateMirrors = mServerInfo->updateMirrors; + if (chatLogger) chatLogger->setServerName(mServerInfo->hostname); diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp index 2d13cf23f..51d102972 100644 --- a/src/gui/windows/shopwindow.cpp +++ b/src/gui/windows/shopwindow.cpp @@ -48,6 +48,7 @@ #include "configuration.h" #include "inventory.h" #include "item.h" +#include "settings.h" #include "shopitem.h" #include "soundmanager.h" @@ -371,7 +372,7 @@ void ShopWindow::loadList() mBuyShopItems->clear(); mSellShopItems->clear(); - const std::string shopListName = client->getServerConfigDirectory() + const std::string shopListName = settings.serverConfigDir + "/shoplist.txt"; if (!stat(shopListName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode)) @@ -421,7 +422,7 @@ void ShopWindow::saveList() const return; std::ofstream shopFile; - const std::string shopListName = client->getServerConfigDirectory() + const std::string shopListName = settings.serverConfigDir + "/shoplist.txt"; std::map<int, ShopItem*> mapItems; diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp index 3248a3920..0422f7553 100644 --- a/src/gui/windows/updaterwindow.cpp +++ b/src/gui/windows/updaterwindow.cpp @@ -24,6 +24,7 @@ #include "client.h" #include "configuration.h" +#include "settings.h" #include "events/keyevent.h" @@ -583,7 +584,7 @@ void UpdaterWindow::download() } else { - const std::vector<std::string> &mirrors = client->getMirrors(); + const std::vector<std::string> &mirrors = settings.updateMirrors; FOR_EACH (std::vector<std::string>::const_iterator, it, mirrors) { mDownload->addMirror(std::string(*it).append( diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp index 312eeb129..9d0f64b5a 100644 --- a/src/gui/windows/whoisonline.cpp +++ b/src/gui/windows/whoisonline.cpp @@ -27,6 +27,7 @@ #include "configuration.h" #include "guild.h" #include "party.h" +#include "settings.h" #include "gui/onlineplayer.h" #include "gui/viewport.h" @@ -492,7 +493,7 @@ int WhoIsOnline::downloadThread(void *ptr) int attempts = 0; WhoIsOnline *const wio = reinterpret_cast<WhoIsOnline *>(ptr); CURLcode res; - const std::string url(client->getOnlineUrl() + "/online.txt"); + const std::string url(settings.onlineListUrl + "/online.txt"); while (attempts < 1 && !wio->mDownloadComplete) { diff --git a/src/gui/windows/worldselectdialog.cpp b/src/gui/windows/worldselectdialog.cpp index da7e29585..db7db88aa 100644 --- a/src/gui/windows/worldselectdialog.cpp +++ b/src/gui/windows/worldselectdialog.cpp @@ -23,6 +23,7 @@ #include "gui/windows/worldselectdialog.h" #include "client.h" +#include "settings.h" #include "input/inputaction.h" @@ -105,7 +106,7 @@ void WorldSelectDialog::action(const ActionEvent &event) mChangeLoginButton->setEnabled(false); mChooseWorld->setEnabled(false); Net::getLoginHandler()->chooseServer(mWorldList->getSelected(), - client->getPersistentIp()); + settings.persistentIp); // Check in case netcode moves us forward if (client->getState() == STATE_WORLD_SELECT) diff --git a/src/listeners/errorlistener.cpp b/src/listeners/errorlistener.cpp index f14ea7821..66c14a4bd 100644 --- a/src/listeners/errorlistener.cpp +++ b/src/listeners/errorlistener.cpp @@ -23,6 +23,7 @@ #include "listeners/errorlistener.h" #include "client.h" +#include "settings.h" #include "utils/process.h" @@ -33,6 +34,6 @@ ErrorListener errorListener; void ErrorListener::action(const ActionEvent &event) { if (event.getId() == "yes") - openBrowser(client->getSupportUrl()); + openBrowser(settings.supportUrl); client->setState(STATE_CHOOSE_SERVER); } diff --git a/src/net/download.cpp b/src/net/download.cpp index 011182a7e..2dc5cfe33 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -25,6 +25,7 @@ #include "client.h" #include "logger.h" #include "main.h" +#include "settings.h" #include "utils/files.h" #include "utils/sdlhelper.h" @@ -91,7 +92,7 @@ Download::Download(void *const ptr, mOptions.checkAdler = true; if (!mUpload) { - const std::string serverName = client->getServerName(); + const std::string serverName = settings.serverName; if (!serverName.empty()) { if (mUrl.find("?") == std::string::npos) diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp index 2f285269a..d7ad9fd11 100644 --- a/src/net/ea/charserverhandler.cpp +++ b/src/net/ea/charserverhandler.cpp @@ -24,6 +24,7 @@ #include "client.h" #include "configuration.h" +#include "settings.h" #include "gui/windows/charcreatedialog.h" #include "gui/windows/okdialog.h" @@ -244,10 +245,10 @@ void CharServerHandler::processCharMapInfo(Net::MessageIn &restrict msg, PlayerInfo::setCharId(msg.readInt32()); GameHandler *const gh = static_cast<GameHandler*>(Net::getGameHandler()); gh->setMap(msg.readString(16)); - if (config.getBoolValue("usePersistentIP") || client->getPersistentIp()) + if (config.getBoolValue("usePersistentIP") || settings.persistentIp) { msg.readInt32(); - server.hostname = client->getServerName(); + server.hostname = settings.serverName; } else { diff --git a/src/net/ea/loginhandler.cpp b/src/net/ea/loginhandler.cpp index c53cdb773..ecc51bfeb 100644 --- a/src/net/ea/loginhandler.cpp +++ b/src/net/ea/loginhandler.cpp @@ -25,6 +25,7 @@ #include "client.h" #include "configuration.h" #include "logger.h" +#include "settings.h" #include "gui/windows/logindialog.h" @@ -85,7 +86,7 @@ void LoginHandler::chooseServer(const unsigned int server, if (charServer) { if (config.getBoolValue("usePersistentIP") || persistentIp) - charServer->hostname = client->getServerName(); + charServer->hostname = settings.serverName; else charServer->hostname = ipToString(mWorlds[server]->address); charServer->port = mWorlds[server]->port; diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index e1dd05d2d..50e8cbc80 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -78,7 +78,7 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name, continue; // debug save -// ImageWriter::writePNG(surface, client->getTempDirectory() +// ImageWriter::writePNG(surface, settings.tempDir // + "/atlas" + name + toString(k) + ".png"); // k ++; diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp index 829c6b3cf..d18281c1a 100644 --- a/src/resources/map/map.cpp +++ b/src/resources/map/map.cpp @@ -27,6 +27,7 @@ #include "render/graphics.h" #include "notifications.h" #include "notifymanager.h" +#include "settings.h" #include "resources/map/mapheights.h" #include "resources/map/maplayer.h" @@ -1109,7 +1110,7 @@ void Map::saveExtraLayer() const std::string Map::getUserMapDirectory() const { - return client->getServerConfigDirectory() + + return settings.serverConfigDir + dirSeparator + getProperty("_realfilename"); } diff --git a/src/settings.cpp b/src/settings.cpp new file mode 100644 index 000000000..af0d5357d --- /dev/null +++ b/src/settings.cpp @@ -0,0 +1,27 @@ +/* + * The ManaPlus Client + * Copyright (C) 2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "settings.h" + +#include "configuration.h" + +#include "debug.h" + +Settings settings; diff --git a/src/settings.h b/src/settings.h new file mode 100644 index 000000000..f88ccb257 --- /dev/null +++ b/src/settings.h @@ -0,0 +1,75 @@ +/* + * The ManaPlus Client + * Copyright (C) 2014 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef SETTINGS_H +#define SETTINGS_H + +#include "options.h" + +#include <string> +#include <vector> + +#include "localconsts.h" + +class Settings final +{ + public: + Settings() : + updateHost(), + oldUpdates(), + updatesDir(), + configDir(), + localDataDir(), + tempDir(), + serverName(), + screenshotDir(), + onlineListUrl(), + serverConfigDir(), + usersDir(), + npcsDir(), + supportUrl(), + logFileName(), + updateMirrors(), + options(), + persistentIp(true) + { } + + std::string updateHost; + std::string oldUpdates; + std::string updatesDir; + std::string configDir; + std::string localDataDir; + std::string tempDir; + std::string serverName; + std::string screenshotDir; + std::string onlineListUrl; + std::string serverConfigDir; + std::string usersDir; + std::string npcsDir; + std::string supportUrl; + std::string logFileName; + std::vector<std::string> updateMirrors; + Options options; + bool persistentIp; +}; + +extern Settings settings; + +#endif // SETTINGS_H diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index 1bc51a7c7..cedc0c785 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -25,6 +25,7 @@ #include "client.h" #include "graphicsmanager.h" #include "graphicsvertexes.h" +#include "settings.h" #include "soundmanager.h" #include "render/sdlgraphics.h" @@ -58,8 +59,8 @@ TestLauncher::TestLauncher(std::string test) : mTest(test), file() { - file.open((client->getLocalDataDirectory() - + std::string("/test.log")).c_str(), std::ios::out); + file.open((settings.localDataDir + std::string("/test.log")).c_str(), + std::ios::out); } TestLauncher::~TestLauncher() @@ -340,9 +341,9 @@ int TestLauncher::testDye() SurfaceImageHelper::combineSurface(image->mSDLSurface, nullptr, surface, nullptr); ImageWriter::writePNG(image->mSDLSurface, - client->getTempDirectory() + "/testimage1.png"); + settings.tempDir + "/testimage1.png"); ImageWriter::writePNG(surface, - client->getTempDirectory() + "/testimage2.png"); + settings.tempDir + "/testimage2.png"); } rw = MPHYSFSRWOPS_openRead( @@ -358,9 +359,9 @@ int TestLauncher::testDye() SurfaceImageHelper::combineSurface(image->mSDLSurface, nullptr, surface, nullptr); ImageWriter::writePNG(image->mSDLSurface, - client->getTempDirectory() + "/testimage3.png"); + settings.tempDir + "/testimage3.png"); ImageWriter::writePNG(surface, - client->getTempDirectory() + "/testimage4.png"); + settings.tempDir + "/testimage4.png"); } } } diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp index 894d40537..16d36dd35 100644 --- a/src/test/testmain.cpp +++ b/src/test/testmain.cpp @@ -24,6 +24,7 @@ #ifdef USE_OPENGL #include "client.h" +#include "settings.h" #include "utils/delete2.h" #include "utils/paths.h" @@ -41,8 +42,7 @@ TestMain::TestMain() : mConfig() { fileName = getSelfName(); - log->setLogFile(client->getLocalDataDirectory() - + std::string("/manaplustest.log")); + log->setLogFile(settings.localDataDir + std::string("/manaplustest.log")); } TestMain::~TestMain() @@ -52,7 +52,7 @@ TestMain::~TestMain() void TestMain::initConfig() { - mConfig.init(client->getConfigDirectory() + "/test.xml"); + mConfig.init(settings.configDir + "/test.xml"); // mConfig.setDefaultValues(getConfigDefaults()); mConfig.setValue("hwaccel", false); @@ -246,7 +246,7 @@ void TestMain::writeConfig(const RenderType openGLMode, const int textureSize, const int detectMode) { - mConfig.init(client->getConfigDirectory() + "/config.xml"); + mConfig.init(settings.configDir + "/config.xml"); log->log("set mode to %d", static_cast<int>(openGLMode)); @@ -290,8 +290,8 @@ int TestMain::readValue(const int ver, int def) std::string tmp; int var; std::ifstream file; - file.open((client->getLocalDataDirectory() - + std::string("/test.log")).c_str(), std::ios::in); + file.open((settings.localDataDir + std::string("/test.log")).c_str(), + std::ios::in); if (!getline(file, tmp)) { file.close(); diff --git a/src/utils/fuzzer.cpp b/src/utils/fuzzer.cpp index 6d76b1329..2bb292a91 100644 --- a/src/utils/fuzzer.cpp +++ b/src/utils/fuzzer.cpp @@ -24,6 +24,7 @@ #include "client.h" #include "logger.h" +#include "settings.h" #include "utils/stringutils.h" @@ -38,7 +39,7 @@ namespace void Fuzzer::init() { fuzz = new Logger; - fuzz->setLogFile(client->getLocalDataDirectory() + "/fuzzer.log"); + fuzz->setLogFile(settings.localDataDir + "/fuzzer.log"); unsigned int sr = time(nullptr); fuzz->log("Srand: %u", sr); |