summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/client.cpp13
-rw-r--r--src/dirs.cpp20
-rw-r--r--src/dyetool/client.cpp13
-rw-r--r--src/dyetool/dyemain.cpp4
-rw-r--r--src/enums/simpletypes/append.h28
-rw-r--r--src/gui/windows/updaterwindow.cpp21
-rw-r--r--src/gui/windows/updaterwindow.h4
-rw-r--r--src/resources/resourcemanager.cpp9
-rw-r--r--src/resources/resourcemanager.h7
-rw-r--r--src/utils/files.cpp4
12 files changed, 86 insertions, 39 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d4293170a..fa5fcf071 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1103,6 +1103,7 @@ SET(SRCS
enums/textcommandtype.h
enums/simpletypes/allowsort.h
enums/simpletypes/allplayers.h
+ enums/simpletypes/append.h
enums/simpletypes/autorelease.h
enums/simpletypes/autotarget.h
enums/simpletypes/beingid.h
diff --git a/src/Makefile.am b/src/Makefile.am
index a046f422a..061b38cdb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -562,6 +562,7 @@ SRC += events/actionevent.h \
enums/textcommandtype.h \
enums/simpletypes/allowsort.h \
enums/simpletypes/allplayers.h \
+ enums/simpletypes/append.h \
enums/simpletypes/autorelease.h \
enums/simpletypes/autotarget.h \
enums/simpletypes/beingid.h \
diff --git a/src/client.cpp b/src/client.cpp
index e5de2effe..1eb5363a3 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -363,10 +363,13 @@ void Client::gameInit()
// Add the main data directories to our PhysicsFS search path
if (!settings.options.dataPath.empty())
- resourceManager->addToSearchPath(settings.options.dataPath, false);
+ {
+ resourceManager->addToSearchPath(settings.options.dataPath,
+ Append_false);
+ }
// Add the local data directory to PhysicsFS search path
- resourceManager->addToSearchPath(settings.localDataDir, false);
+ resourceManager->addToSearchPath(settings.localDataDir, Append_false);
TranslationManager::loadCurrentLang();
WindowManager::initTitle();
@@ -1214,7 +1217,7 @@ int Client::gameExec()
resourceManager->searchAndAddArchives(
"customdata/",
"zip",
- false);
+ Append_false);
}
if (!settings.options.skipUpdate)
@@ -1222,14 +1225,14 @@ int Client::gameExec()
resourceManager->searchAndAddArchives(
settings.updatesDir + "/local/",
"zip",
- false);
+ Append_false);
resourceManager->addToSearchPath(
settings.localDataDir +
dirSeparator +
settings.updatesDir +
"/local/",
- false);
+ Append_false);
}
logger->log("Init paths");
diff --git a/src/dirs.cpp b/src/dirs.cpp
index 8b0bbbeeb..c3d70494f 100644
--- a/src/dirs.cpp
+++ b/src/dirs.cpp
@@ -193,8 +193,9 @@ void Dirs::extractDataDir()
void Dirs::mountDataDir()
{
resourceManager->addToSearchPath(PKG_DATADIR "data/perserver/default",
- false);
- resourceManager->addToSearchPath("data/perserver/default", false);
+ Append_false);
+ resourceManager->addToSearchPath("data/perserver/default",
+ Append_false);
#if defined __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
@@ -208,28 +209,28 @@ void Dirs::mountDataDir()
CFRelease(resourcesURL);
// possible crash
strncat(path, "/data", PATH_MAX - 1);
- resourceManager->addToSearchPath(path, false);
+ resourceManager->addToSearchPath(path, Append_false);
// possible this need for support run client from dmg images.
// mPackageDir = path;
#endif
- resourceManager->addToSearchPath(PKG_DATADIR "data", false);
+ resourceManager->addToSearchPath(PKG_DATADIR "data", Append_false);
setPackageDir(PKG_DATADIR "data");
- resourceManager->addToSearchPath("data", false);
+ resourceManager->addToSearchPath("data", Append_false);
#ifdef ANDROID
#ifdef USE_SDL2
if (getenv("APPDIR"))
{
const std::string appDir = getenv("APPDIR");
- resourceManager->addToSearchPath(appDir + "/data", false);
+ resourceManager->addToSearchPath(appDir + "/data", Append_false);
resourceManager->addToSearchPath(appDir + "/data/perserver/default",
- false);
+ Append_false);
}
#endif
#endif
#if defined __native_client__
- resourceManager->addToSearchPath(_nacl_dir.append("/data"), false);
+ resourceManager->addToSearchPath(_nacl_dir.append("/data"), Append_false);
#endif
// Add branding/data to PhysFS search path
@@ -248,7 +249,8 @@ void Dirs::mountDataDir()
if (loc > 0)
{
resourceManager->addToSearchPath(path.substr(
- 0, loc + 1).append("data"), false);
+ 0, loc + 1).append("data"),
+ Append_false);
}
}
}
diff --git a/src/dyetool/client.cpp b/src/dyetool/client.cpp
index fcd978d12..3055cc80b 100644
--- a/src/dyetool/client.cpp
+++ b/src/dyetool/client.cpp
@@ -246,10 +246,13 @@ void Client::gameInit()
// Add the main data directories to our PhysicsFS search path
if (!settings.options.dataPath.empty())
- resourceManager->addToSearchPath(settings.options.dataPath, false);
+ {
+ resourceManager->addToSearchPath(settings.options.dataPath,
+ Append_false);
+ }
// Add the local data directory to PhysicsFS search path
- resourceManager->addToSearchPath(settings.localDataDir, false);
+ resourceManager->addToSearchPath(settings.localDataDir, Append_false);
TranslationManager::loadCurrentLang();
WindowManager::initTitle();
@@ -595,7 +598,7 @@ int Client::gameExec()
resourceManager->searchAndAddArchives(
"customdata/",
"zip",
- false);
+ Append_false);
}
if (!settings.options.skipUpdate)
@@ -603,11 +606,11 @@ int Client::gameExec()
resourceManager->searchAndAddArchives(
settings.updatesDir + "/local/",
"zip",
- false);
+ Append_false);
resourceManager->addToSearchPath(settings.localDataDir
+ dirSeparator + settings.updatesDir + "/local/",
- false);
+ Append_false);
}
logger->log("Init paths");
diff --git a/src/dyetool/dyemain.cpp b/src/dyetool/dyemain.cpp
index 1b8666aee..66a2adf18 100644
--- a/src/dyetool/dyemain.cpp
+++ b/src/dyetool/dyemain.cpp
@@ -77,8 +77,8 @@ int main(int argc, char **argv)
ResourceManager::init();
resourceManager->setWriteDir(".");
- resourceManager->addToSearchPath(".", false);
- resourceManager->addToSearchPath("/", false);
+ resourceManager->addToSearchPath(".", Append_false);
+ resourceManager->addToSearchPath("/", Append_false);
std::string src = argv[1];
std::string dst;
if (argc == 4)
diff --git a/src/enums/simpletypes/append.h b/src/enums/simpletypes/append.h
new file mode 100644
index 000000000..0e83218e3
--- /dev/null
+++ b/src/enums/simpletypes/append.h
@@ -0,0 +1,28 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2015 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 ENUMS_SIMPLETYPES_APPEND_H
+#define ENUMS_SIMPLETYPES_APPEND_H
+
+#include "enums/simpletypes/booldefines.h"
+
+defBoolEnum(Append);
+
+#endif // ENUMS_SIMPLETYPES_APPEND_H
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index 784fd2ad5..9597de849 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -663,7 +663,7 @@ void UpdaterWindow::loadUpdates()
UpdaterWindow::addUpdateFile(mUpdatesDir,
fixPath,
file.name,
- false);
+ Append_false);
}
loadManaPlusUpdates(mUpdatesDir);
loadMods(mUpdatesDir, mUpdateFiles);
@@ -693,7 +693,7 @@ void UpdaterWindow::loadLocalUpdates(const std::string &dir)
UpdaterWindow::addUpdateFile(dir,
fixPath,
file.name,
- false);
+ Append_false);
}
loadManaPlusUpdates(dir);
loadMods(dir, updateFiles);
@@ -740,7 +740,7 @@ void UpdaterWindow::loadManaPlusUpdates(const std::string &dir)
std::string fileName = std::string(fixPath).append(
"/").append(name);
if (!stat(fileName.c_str(), &statbuf))
- resourceManager->addToSearchPath(fileName, false);
+ resourceManager->addToSearchPath(fileName, Append_false);
}
}
}
@@ -769,10 +769,10 @@ void UpdaterWindow::unloadManaPlusUpdates(const std::string &dir)
void UpdaterWindow::addUpdateFile(const std::string &restrict path,
const std::string &restrict fixPath,
const std::string &restrict file,
- const bool append)
+ const Append append)
{
const std::string tmpPath = std::string(path).append("/").append(file);
- if (!append)
+ if (append == Append_false)
resourceManager->addToSearchPath(tmpPath, append);
const std::string fixFile = std::string(fixPath).append("/").append(file);
@@ -780,7 +780,7 @@ void UpdaterWindow::addUpdateFile(const std::string &restrict path,
if (!stat(fixFile.c_str(), &statbuf))
resourceManager->addToSearchPath(fixFile, append);
- if (append)
+ if (append == Append_false)
resourceManager->addToSearchPath(tmpPath, append);
}
@@ -1097,7 +1097,7 @@ void UpdaterWindow::loadMods(const std::string &dir,
UpdaterWindow::addUpdateFile(dir,
fixPath,
file.name,
- false);
+ Append_false);
}
}
@@ -1121,7 +1121,7 @@ void UpdaterWindow::loadMods(const std::string &dir,
std::string fileName = std::string(fixPath).append(
"/").append(name);
if (!stat(fileName.c_str(), &statbuf))
- resourceManager->addToSearchPath(fileName, false);
+ resourceManager->addToSearchPath(fileName, Append_false);
}
}
}
@@ -1148,7 +1148,10 @@ void UpdaterWindow::loadDirMods(const std::string &dir)
{
const std::string &localDir = mod->getLocalDir();
if (!localDir.empty())
- resourceManager->addToSearchPath(dir + "/" + localDir, false);
+ {
+ resourceManager->addToSearchPath(dir + "/" + localDir,
+ Append_false);
+ }
}
}
}
diff --git a/src/gui/windows/updaterwindow.h b/src/gui/windows/updaterwindow.h
index 4e6f26136..78da3bad1 100644
--- a/src/gui/windows/updaterwindow.h
+++ b/src/gui/windows/updaterwindow.h
@@ -26,6 +26,8 @@
#include "enums/net/downloadstatus.h"
#include "enums/net/updatetype.h"
+#include "enums/simpletypes/append.h"
+
#include "gui/widgets/linkhandler.h"
#include "gui/widgets/window.h"
@@ -124,7 +126,7 @@ class UpdaterWindow final : public Window,
static void addUpdateFile(const std::string &restrict path,
const std::string &restrict fixPath,
const std::string &restrict file,
- const bool append);
+ const Append append);
static void removeUpdateFile(const std::string &restrict path,
const std::string &restrict fixPath,
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index b32126403..f9f55ca03 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -333,11 +333,12 @@ bool ResourceManager::setWriteDir(const std::string &path) const
}
bool ResourceManager::addToSearchPath(const std::string &path,
- const bool append) const
+ const Append append) const
{
logger->log("Adding to PhysicsFS: %s (%s)", path.c_str(),
- append ? "append" : "prepend");
- if (!PhysFs::addToSearchPath(path.c_str(), append ? 1 : 0))
+ append == Append_true ? "append" : "prepend");
+ if (!PhysFs::addToSearchPath(path.c_str(),
+ append == Append_true ? 1 : 0))
{
logger->log("Error: %s", PHYSFS_getLastError());
return false;
@@ -358,7 +359,7 @@ bool ResourceManager::removeFromSearchPath(const std::string &path) const
void ResourceManager::searchAndAddArchives(const std::string &restrict path,
const std::string &restrict ext,
- const bool append) const
+ const Append append) const
{
const char *const dirSep = dirSeparator;
char **list = PhysFs::enumerateFiles(path.c_str());
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index c7c2cffe1..13d05f0b2 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -23,6 +23,8 @@
#ifndef RESOURCES_RESOURCEMANAGER_H
#define RESOURCES_RESOURCEMANAGER_H
+#include "enums/simpletypes/append.h"
+
#include "utils/stringvector.h"
#include <map>
@@ -78,7 +80,8 @@ class ResourceManager final
*
* @return <code>true</code> on success, <code>false</code> otherwise.
*/
- bool addToSearchPath(const std::string &path, const bool append) const;
+ bool addToSearchPath(const std::string &path,
+ const Append append) const;
/**
* Remove a directory or archive from the search path.
@@ -92,7 +95,7 @@ class ResourceManager final
*/
void searchAndAddArchives(const std::string &restrict path,
const std::string &restrict ext,
- const bool append) const;
+ const Append append) const;
/**
* Searches for zip files and remove them from the search path.
diff --git a/src/utils/files.cpp b/src/utils/files.cpp
index 578865503..07e3b2e83 100644
--- a/src/utils/files.cpp
+++ b/src/utils/files.cpp
@@ -45,7 +45,7 @@ void Files::extractLocale()
const std::string fileName2 = std::string(getenv(
"APPDIR")).append("/locale.zip");
- resourceManager->addToSearchPath(fileName2, false);
+ resourceManager->addToSearchPath(fileName2, Append_false);
const std::string localDir = std::string(getenv("APPDIR")).append("/");
char **rootDirs = PhysFs::enumerateFiles("locale");
@@ -122,7 +122,7 @@ void Files::extractZip(const std::string &restrict zipName,
const std::string &restrict inDir,
const std::string &restrict outDir)
{
- resourceManager->addToSearchPath(zipName, false);
+ resourceManager->addToSearchPath(zipName, Append_false);
copyPhysFsDir(inDir, outDir);
resourceManager->removeFromSearchPath(zipName);
remove(zipName.c_str());