summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-14 23:38:39 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-14 23:40:46 +0300
commit015515ba20b66195840afd1c0c074f0729995a2d (patch)
treec1aaf12666cc031dd15e02b74dd0c1a5cc57a74b
parent1f67b67fcd391d5658e46f40756720199bd0004b (diff)
downloadmv-015515ba20b66195840afd1c0c074f0729995a2d.tar.gz
mv-015515ba20b66195840afd1c0c074f0729995a2d.tar.bz2
mv-015515ba20b66195840afd1c0c074f0729995a2d.tar.xz
mv-015515ba20b66195840afd1c0c074f0729995a2d.zip
Add some android fixes.
Partial impliment option to enable/disable mumble support.
-rw-r--r--src/client.cpp16
-rw-r--r--src/game.cpp8
-rw-r--r--src/localplayer.cpp4
-rw-r--r--src/logger.cpp7
-rw-r--r--src/mumblemanager.cpp4
-rw-r--r--src/mumblemanager.h5
-rw-r--r--src/utils/paths.cpp3
-rw-r--r--src/utils/stringutils.cpp1
8 files changed, 47 insertions, 1 deletions
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<int>(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 <sys/time.h>
+#ifdef __ANDROID__
+#include <android/log.h>
+#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 <string>
#include <stdint.h>
@@ -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 <list>
#include <sys/time.h>
+#include <ctype.h>
#include "debug.h"