From 015515ba20b66195840afd1c0c074f0729995a2d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 14 Oct 2012 23:38:39 +0300 Subject: Add some android fixes. Partial impliment option to enable/disable mumble support. --- src/client.cpp | 16 ++++++++++++++++ src/game.cpp | 8 ++++++++ src/localplayer.cpp | 4 ++++ src/logger.cpp | 7 +++++++ src/mumblemanager.cpp | 4 ++++ src/mumblemanager.h | 5 +++++ src/utils/paths.cpp | 3 ++- src/utils/stringutils.cpp | 1 + 8 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/client.cpp b/src/client.cpp index 7a66c445d..12a50b45d 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -693,8 +693,10 @@ void Client::gameClear() if (Net::getLoginHandler()) Net::getLoginHandler()->clearWorlds(); + #ifdef USE_MUMBLE delete mumbleManager; mumbleManager = nullptr; + #endif PlayerInfo::deinit(); @@ -819,8 +821,10 @@ int Client::gameExec() { int lastTickTime = tick_time; + #ifdef USE_MUMBLE if (!mumbleManager) mumbleManager = new MumbleManager(); + #endif SDL_Event event; @@ -873,11 +877,13 @@ int Client::gameExec() } guiInput->pushInput(event); + #ifdef USE_MUMBLE if (player_node && mumbleManager) { mumbleManager->setPos(player_node->getTileX(), player_node->getTileY(), player_node->getDirection()); } + #endif } } @@ -953,8 +959,10 @@ int Client::gameExec() Net::connectToServer(mCurrentServer); + #ifdef USE_MUMBLE if (mumbleManager) mumbleManager->setServer(mCurrentServer.hostname); + #endif GuildManager::init(); AuctionManager::init(); @@ -1329,8 +1337,10 @@ int Client::gameExec() player_node->getName().c_str()); serverConfig.setValue("lastCharacter", player_node->getName()); + #ifdef USE_MUMBLE if (mumbleManager) mumbleManager->setPlayer(player_node->getName()); + #endif } // Fade out logon-music here too to give the desired effect @@ -1706,6 +1716,9 @@ void Client::initConfigDir() mConfigDir = mLocalDataDir; else mConfigDir += "/mana/" + branding.getValue("appShort", "mana"); +#elif defined __ANDROID__ + mConfigDir = "/mnt/sdcard/Android/data/org.evolonline.manaplus" + "/config/" + branding.getValue("appShort", "mana"); #else mConfigDir = std::string(PHYSFS_getUserDir()) + "/.config/mana/" + branding.getValue("appShort", "mana"); @@ -1773,6 +1786,7 @@ void Client::initServerConfig(std::string serverName) */ void Client::initConfiguration() const { + #ifdef DEBUG_CONFIG config.setIsMain(true); #endif @@ -1819,6 +1833,7 @@ void Client::initConfiguration() const { // We reopen the file in write mode and we create it configFile = fopen(configPath.c_str(), "wt"); + logger->log1("Creating new config"); // oldConfig = false; } @@ -1834,6 +1849,7 @@ void Client::initConfiguration() const config.setDefaultValues(getConfigDefaults()); logger->log("configPath: " + configPath); } + } /** diff --git a/src/game.cpp b/src/game.cpp index c86af69a9..4aad0eec5 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -22,6 +22,8 @@ #include "game.h" +#include "main.h" + #include "actorspritemanager.h" #include "auctionmanager.h" #include "animatedsprite.h" @@ -140,7 +142,9 @@ WindowMenu *windowMenu = nullptr; ActorSpriteManager *actorSpriteManager = nullptr; ChannelManager *channelManager = nullptr; CommandHandler *commandHandler = nullptr; +#ifdef USE_MUMBLE MumbleManager *mumbleManager = nullptr; +#endif Particle *particleEngine = nullptr; EffectManager *effectManager = nullptr; SpellManager *spellManager = nullptr; @@ -459,7 +463,9 @@ Game::~Game() del_0(spellShortcut) del_0(auctionManager) del_0(guildManager) + #ifdef USE_MUMBLE del_0(mumbleManager) + #endif Being::clearCache(); @@ -1041,8 +1047,10 @@ void Game::changeMap(const std::string &mapPath) mCurrentMap = newMap; // mCurrentMap = 0; + #ifdef USE_MUMBLE if (mumbleManager) mumbleManager->setMap(mapPath); + #endif DepricatedEvent event(EVENT_MAPLOADED); event.setString("mapPath", mapPath); DepricatedEvent::trigger(CHANNEL_GAME, event); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 1d4f75c37..bc201359a 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -209,8 +209,10 @@ LocalPlayer::~LocalPlayer() void LocalPlayer::logic() { + #ifdef USE_MUMBLE if (mumbleManager) mumbleManager->setPos(mX, mY, mDirection); + #endif // Actions are allowed once per second if (get_elapsed_time(mLastAction) >= 1000) @@ -370,8 +372,10 @@ void LocalPlayer::setAction(const Action &action, const int attackType) } Being::setAction(action, attackType); + #ifdef USE_MUMBLE if (mumbleManager) mumbleManager->setAction(static_cast(action)); + #endif } void LocalPlayer::setGMLevel(const int level) diff --git a/src/logger.cpp b/src/logger.cpp index 5597f90d1..ba7c7be50 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -39,6 +39,13 @@ #include +#ifdef __ANDROID__ +#include +#define LOG_AND(x) __android_log_print(ANDROID_LOG_INFO, "manaplus", x) +#else +#define LOG_AND(x) +#endif + #include "debug.h" Logger::Logger(): diff --git a/src/mumblemanager.cpp b/src/mumblemanager.cpp index e26f67734..380101cc9 100644 --- a/src/mumblemanager.cpp +++ b/src/mumblemanager.cpp @@ -7,6 +7,8 @@ * Copyright (C) 2011-2012 The ManaPlus Developers */ +#ifdef USE_MUMBLE + #include "mumblemanager.h" #include "configuration.h" @@ -284,3 +286,5 @@ void MumbleManager::setServer(const std::string &serverName) mLinkedMemCache.uiTick ++; memcpy(mLinkedMem, &mLinkedMemCache, sizeof(mLinkedMemCache)); } + +#endif diff --git a/src/mumblemanager.h b/src/mumblemanager.h index 4398a1c01..21fa38e7d 100644 --- a/src/mumblemanager.h +++ b/src/mumblemanager.h @@ -10,6 +10,10 @@ #ifndef MUMBLEMANAGER_H #define MUMBLEMANAGER_H +#include "main.h" + +#ifdef USE_MUMBLE + #include #include @@ -66,3 +70,4 @@ class MumbleManager final extern MumbleManager *mumbleManager; #endif +#endif diff --git a/src/utils/paths.cpp b/src/utils/paths.cpp index 11ad19a2e..f67a6c473 100644 --- a/src/utils/paths.cpp +++ b/src/utils/paths.cpp @@ -48,12 +48,13 @@ std::string getRealPath(const std::string &str) { std::string path; -#if defined __OpenBSD__ +#if defined(__OpenBSD__) || defined(__ANDROID__) char *realPath = (char*)calloc(PATH_MAX, sizeof(char)); realpath(str.c_str(), realPath); #else char *realPath = realpath(str.c_str(), nullptr); #endif + if (!realPath) return ""; path = realPath; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 2ceab5b92..c201e9593 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -29,6 +29,7 @@ #include #include +#include #include "debug.h" -- cgit v1.2.3-70-g09d2