diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-11-18 04:24:33 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-11-18 04:24:33 +0300 |
commit | 868514ac621b3ca5c0a9f924461e37164dc712ff (patch) | |
tree | 60ef7bb390d4cca25081c7d6eeb809da2193aee3 | |
parent | db00f34d1c385c8ec007a077c2f78aef764d3bbb (diff) | |
download | plus-868514ac621b3ca5c0a9f924461e37164dc712ff.tar.gz plus-868514ac621b3ca5c0a9f924461e37164dc712ff.tar.bz2 plus-868514ac621b3ca5c0a9f924461e37164dc712ff.tar.xz plus-868514ac621b3ca5c0a9f924461e37164dc712ff.zip |
Add support for persistent directory under Android.
This directory used for updates, configs, logs.
-rw-r--r-- | src/client.cpp | 21 | ||||
-rw-r--r-- | src/client.h | 2 | ||||
-rw-r--r-- | src/compoundsprite.cpp | 3 | ||||
-rw-r--r-- | src/main.cpp | 5 |
4 files changed, 28 insertions, 3 deletions
diff --git a/src/client.cpp b/src/client.cpp index 38e30b22f..208858555 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -547,6 +547,7 @@ void Client::gameInit() SDLImageHelper::SDLSetEnableAlphaCache(config.getBoolValue("alphaCache")); ImageHelper::setEnableAlpha(config.getFloatValue("guialpha") != 1.0f); #endif + logVars(); graphicsManager.initGraphics(mOptions.noOpenGL); runCounters = config.getBoolValue("packetcounters"); applyVSync(); @@ -1804,7 +1805,8 @@ void Client::initLocalDataDir() mLocalDataDir = std::string(PHYSFS_getUserDir()); mLocalDataDir += "/Mana"; #elif defined __ANDROID__ - mLocalDataDir = "local"; + mLocalDataDir = getenv("DATADIR2") + branding.getValue( + "appShort", "ManaPlus") + "/local"; #else mLocalDataDir = std::string(PHYSFS_getUserDir()) + ".local/share/mana"; @@ -1852,7 +1854,8 @@ void Client::initConfigDir() else mConfigDir += "/mana/" + branding.getValue("appShort", "mana"); #elif defined __ANDROID__ - mConfigDir = "config"; + mConfigDir = getenv("DATADIR2") + branding.getValue( + "appShort", "ManaPlus") + "/config"; #else mConfigDir = std::string(PHYSFS_getUserDir()) + "/.config/mana/" + branding.getValue("appShort", "mana"); @@ -2098,12 +2101,17 @@ void Client::initScreenshotDir() } else if (mScreenshotDir.empty()) { +#ifdef __ANDROID__ + mLocalDataDir = getenv("DATADIR2") + std::string("/images"); +#else std::string configScreenshotDir = config.getStringValue("screenshotDirectory"); if (!configScreenshotDir.empty()) mScreenshotDir = configScreenshotDir; else mScreenshotDir = getDesktopDir(); +#endif + //config.setValue("screenshotDirectory", mScreenshotDir); logger->log("screenshotDirectory: " + mScreenshotDir); @@ -2730,3 +2738,12 @@ void Client::newChatMessage() client->mNewMessageFlag = true; } } + +void Client::logVars() +{ +#ifdef ANDROID + logger->log("APPDIR: %s", getenv("APPDIR")); + logger->log("DATADIR: %s", getenv("DATADIR")); + logger->log("DATADIR2: %s", getenv("DATADIR2")); +#endif +} diff --git a/src/client.h b/src/client.h index 43937c956..a437ebb44 100644 --- a/src/client.h +++ b/src/client.h @@ -346,6 +346,8 @@ private: void testsClear(); + void logVars(); + static Client *mInstance; static void bindTextDomain(const char *const name, const char *const path); diff --git a/src/compoundsprite.cpp b/src/compoundsprite.cpp index 146ce9a1a..ab97f9821 100644 --- a/src/compoundsprite.cpp +++ b/src/compoundsprite.cpp @@ -495,11 +495,12 @@ bool CompoundSprite::updateFromCache() const // logger->log("cache size: %d, hit %d, miss %d", // (int)imagesCache.size(), hits, miss); + const size_t sz = size(); for (ImagesCache::iterator it = imagesCache.begin(), it_end = imagesCache.end(); it != it_end; ++ it) { CompoundItem *const ic = *it; - if (ic && ic->data.size() == size()) + if (ic && ic->data.size() == sz) { bool fail(false); VectorPointers::const_iterator it2 = ic->data.begin(); diff --git a/src/main.cpp b/src/main.cpp index ea9ddb8a3..baa356386 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,6 +30,9 @@ #include <physfs.h> #include "utils/gettext.h" +#ifdef ANDROID +#include "utils/mkdir.h" +#endif #include "utils/paths.h" #include "utils/xml.h" @@ -242,6 +245,8 @@ int main(int argc, char *argv[]) // Initialize PhysicsFS #ifdef ANDROID + mkdir_r(getenv("DATADIR2")); + if (!PHYSFS_init((getRealPath(".") + "/fakebinary").c_str())) #else if (!PHYSFS_init(argv[0])) |