Fixed AI in lan multiplayer on android

This commit is contained in:
Deve 2019-10-12 22:52:47 +02:00
parent c2a20e1526
commit 6b26737cd2
4 changed files with 32 additions and 6 deletions

View File

@ -659,10 +659,10 @@ std::string AssetsAndroid::getDataPath()
{
Log::warn("AssetsAndroid", "Cannot use standard data dir");
if (global_android_app)
if (global_android_activity)
{
AndroidApplicationInfo application_info =
CIrrDeviceAndroid::getApplicationInfo(global_android_app->activity);
CIrrDeviceAndroid::getApplicationInfo(global_android_activity);
data_path = application_info.data_dir;
}
@ -688,10 +688,10 @@ std::string AssetsAndroid::getLibPath()
#ifdef ANDROID
std::string lib_path;
if (global_android_app)
if (global_android_activity)
{
AndroidApplicationInfo application_info =
CIrrDeviceAndroid::getApplicationInfo(global_android_app->activity);
CIrrDeviceAndroid::getApplicationInfo(global_android_activity);
lib_path = application_info.native_lib_dir;
}

View File

@ -27,7 +27,16 @@
extern int main(int argc, char *argv[]);
struct android_app* global_android_app;
struct android_app* global_android_app = NULL;
ANativeActivity* global_android_activity = NULL;
extern "C"
{
void set_global_android_activity(ANativeActivity* activity)
{
global_android_activity = activity;
}
}
void override_default_params_for_mobile()
{
@ -92,6 +101,7 @@ void android_main(struct android_app* app)
Log::info("AndroidMain", "Loading application...");
global_android_app = app;
global_android_activity = app->activity;
// Initialize global Android window state variables
CIrrDeviceAndroid::onCreate();

View File

@ -23,7 +23,7 @@
#include "../../../lib/irrlicht/source/Irrlicht/stk_android_native_app_glue.h"
extern struct android_app* global_android_app;
extern ANativeActivity* global_android_activity;
#endif
#endif

View File

@ -44,6 +44,7 @@
#include <dlfcn.h>
#include <fstream>
#include "main_android.hpp"
#include "io/assets_android.hpp"
#endif
@ -388,6 +389,21 @@ bool SeparateProcess::createChildProcess(const std::string& exe,
return false;
}
typedef void (*set_activity_proc_t)(ANativeActivity*);
set_activity_proc_t set_activity_proc =
(set_activity_proc_t)dlsym(m_child_handle, "set_global_android_activity");
if (set_activity_proc == NULL)
{
Log::error("SeparateProcess", "Error: Cannot get handle to "
"set_global_android_activity()");
dlclose(m_child_handle);
m_child_handle = NULL;
return false;
}
set_activity_proc(global_android_activity);
const std::string exe_file = StringUtils::getBasename(exe);
auto rest_argv = StringUtils::split(argument, ' ');