diff options
-rw-r--r-- | src/being.cpp | 8 | ||||
-rw-r--r-- | src/client.cpp | 25 | ||||
-rw-r--r-- | src/client.h | 31 | ||||
-rw-r--r-- | src/commands.cpp | 8 | ||||
-rw-r--r-- | src/game.cpp | 2 | ||||
-rw-r--r-- | src/gui/chatwindow.cpp | 4 | ||||
-rw-r--r-- | src/gui/shopwindow.cpp | 4 | ||||
-rw-r--r-- | src/map.cpp | 2 | ||||
-rw-r--r-- | src/resources/atlasmanager.cpp | 2 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 2 | ||||
-rw-r--r-- | src/test/testlauncher.cpp | 10 | ||||
-rw-r--r-- | src/test/testmain.cpp | 8 |
12 files changed, 47 insertions, 59 deletions
diff --git a/src/being.cpp b/src/being.cpp index 287cc3ecd..1a1ae6477 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -2745,10 +2745,10 @@ std::string Being::loadComment(const std::string &name, const int type) switch (type) { case PLAYER: - str = Client::getUsersDirectory(); + str = client->getUsersDirectory(); break; case NPC: - str = Client::getNpcsDirectory(); + str = client->getNpcsDirectory(); break; default: return ""; @@ -2775,10 +2775,10 @@ void Being::saveComment(const std::string &name, switch (type) { case PLAYER: - dir = Client::getUsersDirectory(); + dir = client->getUsersDirectory(); break; case NPC: - dir = Client::getNpcsDirectory(); + dir = client->getNpcsDirectory(); break; default: return; diff --git a/src/client.cpp b/src/client.cpp index ccd2b76c7..4838618b6 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2457,7 +2457,7 @@ void Client::storeSafeParameters() const void Client::initTradeFilter() const { const std::string tradeListName = - Client::getServerConfigDirectory() + "/tradefilter.txt"; + getServerConfigDirectory() + "/tradefilter.txt"; std::ofstream tradeFile; struct stat statbuf; @@ -2489,7 +2489,7 @@ void Client::initTradeFilter() const void Client::initUsersDir() { - mUsersDir = Client::getServerConfigDirectory() + "/users/"; + mUsersDir = getServerConfigDirectory() + "/users/"; if (mkdir_r(mUsersDir.c_str())) { // TRANSLATORS: directory creation error @@ -2497,7 +2497,7 @@ void Client::initUsersDir() "Exiting."), mUsersDir.c_str())); } - mNpcsDir = Client::getServerConfigDirectory() + "/npcs/"; + mNpcsDir = getServerConfigDirectory() + "/npcs/"; if (mkdir_r(mNpcsDir.c_str())) { // TRANSLATORS: directory creation error @@ -2586,8 +2586,8 @@ void Client::initPacketLimiter() if (!mServerConfigDir.empty()) { - const std::string packetLimitsName = - Client::getServerConfigDirectory() + "/packetlimiter.txt"; + const std::string packetLimitsName = getServerConfigDirectory() + + "/packetlimiter.txt"; std::ifstream inPacketFile; struct stat statbuf; @@ -2730,21 +2730,6 @@ bool Client::limitPackets(const int type) return true; } -const std::string Client::getServerConfigDirectory() -{ - return instance()->mServerConfigDir; -} - -const std::string Client::getUsersDirectory() -{ - return instance()->mUsersDir; -} - -const std::string Client::getNpcsDirectory() -{ - return instance()->mNpcsDir; -} - void Client::setGuiAlpha(const float n) { instance()->mGuiAlpha = n; diff --git a/src/client.h b/src/client.h index 73d4ae28b..3c7951ffc 100644 --- a/src/client.h +++ b/src/client.h @@ -235,29 +235,32 @@ public: void setState(const State state) { mState = state; } - State getState() A_WARN_UNUSED + State getState() const A_WARN_UNUSED { return mState; } - static const std::string &getPackageDirectory() A_WARN_UNUSED - { return instance()->mPackageDir; } + const std::string &getPackageDirectory() const A_WARN_UNUSED + { return mPackageDir; } - static const std::string &getConfigDirectory() A_WARN_UNUSED - { return instance()->mConfigDir; } + const std::string &getConfigDirectory() const A_WARN_UNUSED + { return mConfigDir; } - static const std::string &getLocalDataDirectory() A_WARN_UNUSED - { return instance()->mLocalDataDir; } + const std::string &getLocalDataDirectory() const A_WARN_UNUSED + { return mLocalDataDir; } - static const std::string &getTempDirectory() A_WARN_UNUSED - { return instance()->mTempDir; } + const std::string &getTempDirectory() const A_WARN_UNUSED + { return mTempDir; } - static const std::string &getScreenshotDirectory() A_WARN_UNUSED - { return instance()->mScreenshotDir; } + const std::string &getScreenshotDirectory() const A_WARN_UNUSED + { return mScreenshotDir; } - static const std::string getServerConfigDirectory() A_WARN_UNUSED; + const std::string getServerConfigDirectory() const A_WARN_UNUSED + { return mServerConfigDir; } - static const std::string getUsersDirectory() A_WARN_UNUSED; + const std::string getUsersDirectory() const A_WARN_UNUSED + { return mUsersDir; } - static const std::string getNpcsDirectory() A_WARN_UNUSED; + const std::string getNpcsDirectory() const A_WARN_UNUSED + { return mNpcsDir; } static bool getIsMinimized() A_WARN_UNUSED { return instance()->mIsMinimized; } diff --git a/src/commands.cpp b/src/commands.cpp index cf1e049f6..be5bc3a20 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -836,13 +836,13 @@ impHandler0(dirs) return; debugChatTab->chatLog("config directory: " - + Client::getConfigDirectory()); + + client->getConfigDirectory()); debugChatTab->chatLog("logs directory: " - + Client::getLocalDataDirectory()); + + client->getLocalDataDirectory()); debugChatTab->chatLog("screenshots directory: " - + Client::getScreenshotDirectory()); + + client->getScreenshotDirectory()); debugChatTab->chatLog("temp directory: " - + Client::getTempDirectory()); + + client->getTempDirectory()); } impHandler2(info) diff --git a/src/game.cpp b/src/game.cpp index 884034179..379bb42f6 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -500,7 +500,7 @@ bool Game::createScreenshot() bool Game::saveScreenshot(SDL_Surface *const screenshot) { - std::string screenshotDirectory = Client::getScreenshotDirectory(); + std::string screenshotDirectory = client->getScreenshotDirectory(); if (mkdir_r(screenshotDirectory.c_str()) != 0) { diff --git a/src/gui/chatwindow.cpp b/src/gui/chatwindow.cpp index 04c2a2d9a..d31278e51 100644 --- a/src/gui/chatwindow.cpp +++ b/src/gui/chatwindow.cpp @@ -1471,7 +1471,7 @@ void ChatWindow::battleChatLog(const std::string &line, Own own, void ChatWindow::initTradeFilter() { - const std::string tradeListName = Client::getServerConfigDirectory() + const std::string tradeListName = client->getServerConfigDirectory() + "/tradefilter.txt"; std::ifstream tradeFile; @@ -1621,7 +1621,7 @@ void ChatWindow::loadCustomList() std::ifstream listFile; struct stat statbuf; - std::string listName = Client::getServerConfigDirectory() + std::string listName = client->getServerConfigDirectory() + "/customwords.txt"; if (!stat(listName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode)) diff --git a/src/gui/shopwindow.cpp b/src/gui/shopwindow.cpp index db360fd33..04b994b7f 100644 --- a/src/gui/shopwindow.cpp +++ b/src/gui/shopwindow.cpp @@ -366,7 +366,7 @@ void ShopWindow::loadList() mBuyShopItems->clear(); mSellShopItems->clear(); - const std::string shopListName = Client::getServerConfigDirectory() + const std::string shopListName = client->getServerConfigDirectory() + "/shoplist.txt"; if (!stat(shopListName.c_str(), &statbuf) && S_ISREG(statbuf.st_mode)) @@ -416,7 +416,7 @@ void ShopWindow::saveList() const return; std::ofstream shopFile; - const std::string shopListName = Client::getServerConfigDirectory() + const std::string shopListName = client->getServerConfigDirectory() + "/shoplist.txt"; std::map<int, ShopItem*> mapItems; diff --git a/src/map.cpp b/src/map.cpp index d69375cf4..7b83e9c7b 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1252,7 +1252,7 @@ void Map::saveExtraLayer() const std::string Map::getUserMapDirectory() const { - return Client::getServerConfigDirectory() + + return client->getServerConfigDirectory() + dirSeparator + getProperty("_realfilename"); } diff --git a/src/resources/atlasmanager.cpp b/src/resources/atlasmanager.cpp index 2388856c1..5f4897147 100644 --- a/src/resources/atlasmanager.cpp +++ b/src/resources/atlasmanager.cpp @@ -71,7 +71,7 @@ AtlasResource *AtlasManager::loadTextureAtlas(const std::string &name, continue; // debug save -// ImageWriter::writePNG(surface, Client::getTempDirectory() +// ImageWriter::writePNG(surface, client->getTempDirectory() // + "/atlas" + name + toString(k) + ".png"); // k ++; diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 83beb8e9c..03cc2bc41 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -434,7 +434,7 @@ std::string ResourceManager::getPath(const std::string &file) const else { // if not found in search path return the default path - path = std::string(Client::getPackageDirectory()).append( + path = std::string(client->getPackageDirectory()).append( dirSeparator).append(file); } diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index b479ba9a3..1752e4380 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -53,7 +53,7 @@ TestLauncher::TestLauncher(std::string test) : mTest(test), file() { - file.open((Client::getLocalDataDirectory() + file.open((client->getLocalDataDirectory() + std::string("/test.log")).c_str(), std::ios::out); } @@ -252,9 +252,9 @@ int TestLauncher::testDye() MSDL_gfxBlitRGBA(image->mSDLSurface, nullptr, surface, nullptr); ImageWriter::writePNG(image->mSDLSurface, - Client::getTempDirectory() + "/testimage1.png"); + client->getTempDirectory() + "/testimage1.png"); ImageWriter::writePNG(surface, - Client::getTempDirectory() + "/testimage2.png"); + client->getTempDirectory() + "/testimage2.png"); } rw = PHYSFSRWOPS_openRead( @@ -271,9 +271,9 @@ int TestLauncher::testDye() MSDL_gfxBlitRGBA(image->mSDLSurface, nullptr, surface, nullptr); ImageWriter::writePNG(image->mSDLSurface, - Client::getTempDirectory() + "/testimage3.png"); + client->getTempDirectory() + "/testimage3.png"); ImageWriter::writePNG(surface, - Client::getTempDirectory() + "/testimage4.png"); + client->getTempDirectory() + "/testimage4.png"); } } } diff --git a/src/test/testmain.cpp b/src/test/testmain.cpp index 893b477f9..3d4bdd33d 100644 --- a/src/test/testmain.cpp +++ b/src/test/testmain.cpp @@ -42,7 +42,7 @@ TestMain::TestMain() : mConfig() { fileName = getSelfName(); - log->setLogFile(Client::getLocalDataDirectory() + log->setLogFile(client->getLocalDataDirectory() + std::string("/manaplustest.log")); } @@ -54,7 +54,7 @@ TestMain::~TestMain() void TestMain::initConfig() { - mConfig.init(Client::getConfigDirectory() + "/test.xml"); + mConfig.init(client->getConfigDirectory() + "/test.xml"); // mConfig.setDefaultValues(getConfigDefaults()); mConfig.setValue("hwaccel", false); @@ -216,7 +216,7 @@ void TestMain::writeConfig(const int openGLMode, const int rescale, const int sound, const std::string &info, const int batchSize A_UNUSED, const int detectMode) { - mConfig.init(Client::getConfigDirectory() + "/config.xml"); + mConfig.init(client->getConfigDirectory() + "/config.xml"); log->log("set mode to %d", openGLMode); @@ -259,7 +259,7 @@ int TestMain::readValue(const int ver, int def) std::string tmp; int var; std::ifstream file; - file.open((Client::getLocalDataDirectory() + file.open((client->getLocalDataDirectory() + std::string("/test.log")).c_str(), std::ios::in); if (!getline(file, tmp)) { |